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, see <http://www.gnu.org/licenses/>. *
16 ***************************************************************************/
18 #ifndef __VERSALOON_H_INCLUDED__
19 #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
, const uint8_t *data
,
64 RESULT(*seqin
)(uint8_t interface_index
, uint8_t *data
, uint16_t bitlen
);
65 RESULT(*transact
)(uint8_t interface_index
, uint8_t request
,
66 uint32_t *data
, uint8_t *ack
);
69 struct interface_jtag_raw_t
{
70 RESULT(*init
)(uint8_t interface_index
);
71 RESULT(*fini
)(uint8_t interface_index
);
72 RESULT(*config
)(uint8_t interface_index
, uint32_t kHz
);
73 RESULT(*execute
)(uint8_t interface_index
, uint8_t *tdi
, uint8_t *tms
,
74 uint8_t *tdo
, uint32_t bitlen
);
77 struct interface_target_voltage_t
{
78 RESULT(*get
)(uint16_t *voltage
);
79 RESULT(*set
)(uint16_t voltage
);
82 struct versaloon_adaptors_t
{
83 struct interface_target_voltage_t target_voltage
;
84 struct interface_gpio_t gpio
;
85 struct interface_delay_t delay
;
86 struct interface_swd_t swd
;
87 struct interface_jtag_raw_t jtag_raw
;
88 RESULT(*peripheral_commit
)(void);
91 struct versaloon_usb_setting_t
{
102 struct versaloon_interface_t
{
105 struct versaloon_adaptors_t adaptors
;
106 struct versaloon_usb_setting_t usb_setting
;
109 extern struct versaloon_interface_t versaloon_interface
;
110 extern libusb_device_handle
*versaloon_usb_device_handle
;
112 #endif /* __VERSALOON_H_INCLUDED__ */