CLEON  Version 1
Cloud-Offloaded GPS Receiver
sys_usb.h
Go to the documentation of this file.
1 
7 #ifndef __SYS_USB_H__
8 #define __SYS_USB_H__
9 
11 #define USB_FRAME_HEADER 0x55
12 #define USB_FRAME_FOOTER 0xAA
13 
14 #define USB_FRAME_DATA_FIELD_LENGTH 29
15 #define USB_FRAME_COMMAND_AND_DATA_FIELD_LENGTH 30
16 #define USB_FRAME_LENGTH 36
17 
18 #define USB_FRAME_COMMAND_CONNECT 0x01
19 #define USB_FRAME_COMMAND_UPDATE_RTC_TIME 0x02
20 #define USB_FRAME_COMMAND_UPDATE_TIME_TICK 0x03
21 #define USB_FRAME_COMMAND_UPDATE_SAMPLE_COUNT 0x04
22 #define USB_FRAME_COMMAND_UPDATE_SAMPLE_GAP 0x05
23 #define USB_FRAME_COMMAND_UPDATE_CHUNK_COUNT 0x06
24 #define USB_FRAME_COMMAND_UPDATE_CHUNK_GAP 0x07
25 #define USB_FRAME_COMMAND_ACK 0xFF
26 
27 
28 typedef struct{
29  unsigned char ucHeader[2]; // 2 bytes
30  unsigned char ucLength; // 1 bytes
31  unsigned char ucCommand; // 1 bytes
32  unsigned char ucData[USB_FRAME_DATA_FIELD_LENGTH]; // 29 bytes
33  unsigned char ucCRC; // 1 byte
34  unsigned char ucFooter[2]; // 2 bytes
35 }usb_frame_s; // 36 bytes
36 
37 typedef union{
39  unsigned char ucSingleByte[USB_FRAME_LENGTH];
41 
42 #define SYS_USB_IsUSBConnected() ((USB_STATUS_PORT(IN) & BV(USB_STATUS_PIN)) >> USB_STATUS_PIN)
43 
44 void SYS_USB_Init(void);
45 void SYS_USB_SendACK(unsigned char ucCommand);
46 int SYS_USB_Printf(char *format, ... );
47 void SYS_USB_ReceiveFrame(unsigned char ucData);
48 unsigned char SYS_USB_BuildCRC(usb_frame_u *uniUSBFrame);
49 void SYS_USB_TransmitSingleByte(unsigned char ucData);
50 
51 #endif