1 /***************************************************************************
2 * Copyright (C) 2009 by Simon Qian <SimonQian@SimonQian.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18 ***************************************************************************/
20 #ifndef __VERSALOON_H_INCLUDED__
21 #define __VERSALOON_H_INCLUDED__
23 struct usart_status_t
{
24 uint32_t tx_buff_avail
;
25 uint32_t tx_buff_size
;
26 uint32_t rx_buff_avail
;
27 uint32_t rx_buff_size
;
30 #include "usbtoxxx/usbtoxxx.h"
33 #define GPIO_SRST (1 << 0)
34 #define GPIO_TRST (1 << 1)
35 #define GPIO_USR1 (1 << 2)
36 #define GPIO_USR2 (1 << 3)
37 #define GPIO_TCK (1 << 4)
38 #define GPIO_TDO (1 << 5)
39 #define GPIO_TDI (1 << 6)
40 #define GPIO_RTCK (1 << 7)
41 #define GPIO_TMS (1 << 8)
43 struct interface_gpio_t
{
44 RESULT(*init
)(uint8_t interface_index
);
45 RESULT(*fini
)(uint8_t interface_index
);
46 RESULT(*config
)(uint8_t interface_index
, uint32_t pin_mask
, uint32_t io
,
47 uint32_t pull_en_mask
, uint32_t input_pull_mask
);
48 RESULT(*out
)(uint8_t interface_index
, uint32_t pin_mask
, uint32_t value
);
49 RESULT(*in
)(uint8_t interface_index
, uint32_t pin_mask
, uint32_t *value
);
52 struct interface_delay_t
{
53 RESULT(*delayms
)(uint16_t ms
);
54 RESULT(*delayus
)(uint16_t us
);
57 struct interface_swd_t
{
58 RESULT(*init
)(uint8_t interface_index
);
59 RESULT(*fini
)(uint8_t interface_index
);
60 RESULT(*config
)(uint8_t interface_index
, uint8_t trn
, uint16_t retry
,
62 RESULT(*seqout
)(uint8_t interface_index
, uint8_t *data
, uint16_t bitlen
);
63 RESULT(*seqin
)(uint8_t interface_index
, uint8_t *data
, uint16_t bitlen
);
64 RESULT(*transact
)(uint8_t interface_index
, uint8_t request
,
65 uint32_t *data
, uint8_t *ack
);
68 struct interface_jtag_raw_t
{
69 RESULT(*init
)(uint8_t interface_index
);
70 RESULT(*fini
)(uint8_t interface_index
);
71 RESULT(*config
)(uint8_t interface_index
, uint32_t kHz
);
72 RESULT(*execute
)(uint8_t interface_index
, uint8_t *tdi
, uint8_t *tms
,
73 uint8_t *tdo
, uint32_t bitlen
);
76 struct interface_target_voltage_t
{
77 RESULT(*get
)(uint16_t *voltage
);
78 RESULT(*set
)(uint16_t voltage
);
81 struct versaloon_adaptors_t
{
82 struct interface_target_voltage_t target_voltage
;
83 struct interface_gpio_t gpio
;
84 struct interface_delay_t delay
;
85 struct interface_swd_t swd
;
86 struct interface_jtag_raw_t jtag_raw
;
87 RESULT(*peripheral_commit
)(void);
90 struct versaloon_usb_setting_t
{
101 struct versaloon_interface_t
{
104 struct versaloon_adaptors_t adaptors
;
105 struct versaloon_usb_setting_t usb_setting
;
108 extern struct versaloon_interface_t versaloon_interface
;
109 extern usb_dev_handle
*versaloon_usb_device_handle
;
111 #endif /* __VERSALOON_H_INCLUDED__ */