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, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
18 ***************************************************************************/
20 #ifndef __VERSALOON_INTERNAL_H_INCLUDED__
21 #define __VERSALOON_INTERNAL_H_INCLUDED__
23 #define VERSALOON_PRODUCTSTRING_INDEX 2
24 #define VERSALOON_SERIALSTRING_INDEX 3
26 #define VERSALOON_PRODUCTSTRING "Versaloon"
28 #define VERSALOON_VID 0x0483
29 #define VERSALOON_PID 0xA038
30 #define VERSALOON_INP 0x82
31 #define VERSALOON_OUTP 0x03
32 #define VERSALOON_IFACE 0x00
34 #define VERSALOON_FULL 1
35 #define VERSALOON_MINI 2
36 #define VERSALOON_NANO 3
38 #define VERSALOON_TIMEOUT 5000
39 #define VERSALOON_TIMEOUT_LONG 60000
43 #define VERSALOON_COMMON_CMD_START 0x00
44 #define VERSALOON_COMMON_CMD_END 0x0F
46 #define VERSALOON_GET_INFO 0x00
47 #define VERSALOON_GET_TVCC 0x01
48 #define VERSALOON_GET_HARDWARE 0x02
49 #define VERSALOON_GET_OFFLINE_SIZE 0x08
50 #define VERSALOON_ERASE_OFFLINE_DATA 0x09
51 #define VERSALOON_WRITE_OFFLINE_DATA 0x0A
52 #define VERSALOON_GET_OFFLINE_CHECKSUM 0x0B
53 #define VERSALOON_FW_UPDATE 0x0F
54 #define VERSALOON_FW_UPDATE_KEY 0xAA
57 #define VERSALOON_MCU_CMD_START 0x10
58 #define VERSALOON_MCU_CMD_END 0x1F
60 /* USB_TO_XXX Command */
61 #define VERSALOON_USB_TO_XXX_CMD_START 0x20
62 #define VERSALOON_USB_TO_XXX_CMD_END 0x7F
65 #define VERSALOON_VSLLINK_CMD_START 0x80
66 #define VERSALOON_VSLLINK_CMD_END 0xFF
75 #define VERSALOON_MAX_PENDING_NUMBER 4096
76 typedef RESULT(*versaloon_callback_t
)(void *, uint8_t *, uint8_t *);
77 struct versaloon_want_pos_t
{
81 struct versaloon_want_pos_t
*next
;
83 struct versaloon_pending_t
{
86 uint16_t want_data_pos
;
87 uint16_t want_data_size
;
88 uint16_t actual_data_size
;
92 struct versaloon_want_pos_t
*pos
;
94 versaloon_callback_t callback
;
96 extern struct versaloon_pending_t \
97 versaloon_pending
[VERSALOON_MAX_PENDING_NUMBER
];
98 extern uint16_t versaloon_pending_idx
;
99 void versaloon_set_pending_id(uint32_t id
);
100 void versaloon_set_callback(versaloon_callback_t callback
);
101 void versaloon_set_extra_data(void *p
);
102 RESULT
versaloon_add_want_pos(uint16_t offset
, uint16_t size
, uint8_t *buff
);
103 RESULT
versaloon_add_pending(uint8_t type
, uint8_t cmd
, uint16_t actual_szie
,
104 uint16_t want_pos
, uint16_t want_size
, uint8_t *buffer
, uint8_t collect
);
105 void versaloon_free_want_pos(void);
107 RESULT
versaloon_send_command(uint16_t out_len
, uint16_t *inlen
);
108 extern uint8_t *versaloon_buf
;
109 extern uint8_t *versaloon_cmd_buf
;
110 extern uint16_t versaloon_buf_size
;
112 #endif /* __VERSALOON_INTERNAL_H_INCLUDED__ */