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 ***************************************************************************/
19 #ifndef __VERSALOON_H_INCLUDED__
20 #define __VERSALOON_H_INCLUDED__
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)
42 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
54 RESULT (*delayms)(uint16_t ms);
55 RESULT (*delayus)(uint16_t us);
58 struct interface_swd_t
60 RESULT (*init)(uint8_t interface_index);
61 RESULT (*fini)(uint8_t interface_index);
62 RESULT (*config)(uint8_t interface_index, uint8_t trn, uint16_t retry,
64 RESULT (*seqout)(uint8_t interface_index, uint8_t *data, uint16_t bitlen);
65 RESULT (*seqin)(uint8_t interface_index, uint8_t *data, uint16_t bitlen);
66 RESULT (*transact)(uint8_t interface_index, uint8_t request,
67 uint32_t *data, uint8_t *ack);
70 struct interface_jtag_raw_t
72 RESULT (*init)(uint8_t interface_index);
73 RESULT (*fini)(uint8_t interface_index);
74 RESULT (*config)(uint8_t interface_index, uint32_t kHz);
75 RESULT (*execute)(uint8_t interface_index, uint8_t* tdi, uint8_t* tms,
76 uint8_t *tdo, uint32_t bitlen);
79 struct interface_target_voltage_t
81 RESULT (*get)(uint16_t *voltage);
82 RESULT (*set)(uint16_t voltage);
85 struct versaloon_adaptors_t
87 struct interface_target_voltage_t target_voltage;
88 struct interface_gpio_t gpio;
89 struct interface_delay_t delay;
90 struct interface_swd_t swd;
91 struct interface_jtag_raw_t jtag_raw;
92 RESULT (*peripheral_commit)(void);
95 struct versaloon_usb_setting_t
107 struct versaloon_interface_t
109 RESULT (*init)(void);
110 RESULT (*fini)(void);
111 struct versaloon_adaptors_t adaptors;
112 struct versaloon_usb_setting_t usb_setting;
115 extern struct versaloon_interface_t versaloon_interface;
116 extern usb_dev_handle *versaloon_usb_device_handle;
118 #endif /* __VERSALOON_H_INCLUDED__ */