1 /***************************************************************************
2 * Copyright (C) 2009 - 2010 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 OPENOCD_JTAG_DRIVERS_VERSALOON_VERSALOON_INTERNAL_H
19 #define OPENOCD_JTAG_DRIVERS_VERSALOON_VERSALOON_INTERNAL_H
21 #define VERSALOON_PRODUCTSTRING_INDEX 2
22 #define VERSALOON_SERIALSTRING_INDEX 3
24 #define VERSALOON_PRODUCTSTRING "Versaloon"
26 #define VERSALOON_VID 0x0483
27 #define VERSALOON_PID 0xA038
28 #define VERSALOON_INP 0x82
29 #define VERSALOON_OUTP 0x03
30 #define VERSALOON_IFACE 0x00
32 #define VERSALOON_FULL 1
33 #define VERSALOON_MINI 2
34 #define VERSALOON_NANO 3
36 #define VERSALOON_TIMEOUT 5000
37 #define VERSALOON_TIMEOUT_LONG 60000
41 #define VERSALOON_COMMON_CMD_START 0x00
42 #define VERSALOON_COMMON_CMD_END 0x0F
44 #define VERSALOON_GET_INFO 0x00
45 #define VERSALOON_GET_TVCC 0x01
46 #define VERSALOON_GET_HARDWARE 0x02
47 #define VERSALOON_GET_OFFLINE_SIZE 0x08
48 #define VERSALOON_ERASE_OFFLINE_DATA 0x09
49 #define VERSALOON_WRITE_OFFLINE_DATA 0x0A
50 #define VERSALOON_GET_OFFLINE_CHECKSUM 0x0B
51 #define VERSALOON_FW_UPDATE 0x0F
52 #define VERSALOON_FW_UPDATE_KEY 0xAA
55 #define VERSALOON_MCU_CMD_START 0x10
56 #define VERSALOON_MCU_CMD_END 0x1F
58 /* USB_TO_XXX Command */
59 #define VERSALOON_USB_TO_XXX_CMD_START 0x20
60 #define VERSALOON_USB_TO_XXX_CMD_END 0x7F
63 #define VERSALOON_VSLLINK_CMD_START 0x80
64 #define VERSALOON_VSLLINK_CMD_END 0xFF
73 #define VERSALOON_MAX_PENDING_NUMBER 4096
74 typedef RESULT(*versaloon_callback_t)(void *, uint8_t *, uint8_t *);
75 struct versaloon_want_pos_t {
79 struct versaloon_want_pos_t *next;
81 struct versaloon_pending_t {
84 uint16_t want_data_pos;
85 uint16_t want_data_size;
86 uint16_t actual_data_size;
90 struct versaloon_want_pos_t *pos;
92 versaloon_callback_t callback;
94 extern struct versaloon_pending_t \
95 versaloon_pending[VERSALOON_MAX_PENDING_NUMBER];
96 extern uint16_t versaloon_pending_idx;
97 void versaloon_set_pending_id(uint32_t id);
98 void versaloon_set_callback(versaloon_callback_t callback);
99 void versaloon_set_extra_data(void *p);
100 RESULT versaloon_add_want_pos(uint16_t offset, uint16_t size, uint8_t *buff);
101 RESULT versaloon_add_pending(uint8_t type, uint8_t cmd, uint16_t actual_szie,
102 uint16_t want_pos, uint16_t want_size, uint8_t *buffer, uint8_t collect);
103 void versaloon_free_want_pos(void);
105 RESULT versaloon_send_command(uint16_t out_len, uint16_t *inlen);
106 extern uint8_t *versaloon_buf;
107 extern uint8_t *versaloon_cmd_buf;
108 extern uint16_t versaloon_buf_size;
110 #endif /* OPENOCD_JTAG_DRIVERS_VERSALOON_VERSALOON_INTERNAL_H */