SingingCat
0
application
include
usb.h
1
#ifndef USB_H
2
#define USB_H 1
3
#include <main-header.h>
4
struct
usb_app_packet
{
5
uint8_t type;
6
uint16_t headersize;
// w/o type and control packet, e.g. start_upload = 10
7
uint16_t datasize;
8
uint16_t number;
9
union
{
10
struct
{
11
uint32_t base;
12
uint32_t flags;
13
uint32_t size;
14
} start_upload;
15
struct
{
16
uint8_t header_length;
17
uint16_t data_length;
18
uint32_t checksum;
19
} data;
20
struct
{
21
uint32_t checksum;
22
uint32_t len;
23
uint8_t flags;
24
} done;
25
struct
{
26
uint8_t code;
27
uint32_t extra;
28
} nack;
29
struct
{
30
uint32_t extra;
31
} ack;
32
struct
{
33
uint32_t action;
34
uint32_t actiondata;
35
uint32_t datalen;
36
} action;
37
};
38
};
39
40
#define USBAPP_ERROR_DATA_CHECKSUM 1
41
#define USBAPP_ERROR_FLASH_FAILURE 2
42
#define USBAPP_ERROR_INV_PACKET 3
43
#define USBAPP_ERROR_PACKET_ORDER 4
44
#define USBAPP_ERROR_DATA_SIZE_MISMATCH 5
45
#define USBAPP_ERROR_DATA_SIZE_INVALID 6
46
#define USBAPP_ERROR_TOTAL_SIZE_MISMATCH 7
47
#define USBAPP_ERROR_TOTAL_CHECKSUM 8
48
#define USBAPP_ERROR_CURRENT_BASE 9
49
#define USBAPP_ERROR_ACTION 10
50
#define USBAPP_ERROR_DATA_BEFORE_START 11
51
52
int
usb_appupdate();
53
void
usb_start();
54
void
usb_restore_irq();
55
void
usb_byte_received(
byte
b);
56
void
usb_finish_app_update();
57
int
usb_start_app_update();
58
void
usb_process_packet_appupdate();
59
int
simulate_send_to_usb(
int
len,
byte
*
string
);
60
int
usb_app_parse(
byte
*buf,
int
size,
struct
usb_app_packet
*target);
61
void
print_usb_app_packet(
struct
usb_app_packet
*pack);
62
uint32_t parse32(
byte
*tmpbuf,
int
offset);
63
void
usb_appupdate_byte_received(
byte
b);
64
#endif
usb_app_packet
Definition:
usb.h:4
Generated on Tue May 28 2024 19:13:43 for SingingCat by
1.9.4