aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/usb/usb_callbacks.h
blob: a71af01f01025d74431abe7a60e8613c90fda07c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* insert license */

#ifndef __USB_CALLBACKS
#define __USB_CALLBACKS

#include "libmaple.h"
#include "usb_config.h"

#include "usb_type.h"
#include "usb_core.h"

#define SET_LINE_CODING        0x20
#define GET_LINE_CODING        0x21
#define SET_COMM_FEATURE       0x02
#define SET_CONTROL_LINE_STATE 0x22
#define CONTROL_LINE_DTR       (0x01)
#define CONTROL_LINE_RTS       (0x02)

#if defined(__cplusplus)
extern "C" {
#endif

typedef struct {
  uint32 bitrate;
  uint8  format;
  uint8  paritytype;
  uint8  datatype;
} USB_Line_Coding;

typedef enum {
  DTR_UNSET,
  DTR_HIGH,
  DTR_NEGEDGE,
  DTR_LOW
} RESET_STATE;

extern RESET_STATE reset_state;  /* tracks DTR/RTS */
extern uint8       line_dtr_rts;
extern volatile uint32 countTx;
extern uint8 vcomBufferRx[VCOM_RX_BUFLEN];  /* no reason this has to be VCOM_RX_EPSIZE, could be bigger */
extern volatile uint32 recvBufIn;   /* the FIFO in index to the recvbuffer */
extern volatile uint32 recvBufOut;  /* the FIFO out index to the recvbuffer */
extern volatile uint32 maxNewBytes;
extern volatile uint32 newBytes;

void vcomDataTxCb(void);
void vcomDataRxCb(void);
void vcomManagementCb(void);

uint8* vcomGetSetLineCoding(uint16 length);
void vcomSetLineSate(void);

void usbInit(void);
/* internal functions (as per the usb_core pProperty structure) */
void usbInit(void);
void usbReset(void);
void usbStatusIn(void);
void usbStatusOut(void);

RESULT usbDataSetup(uint8 request);
RESULT usbNoDataSetup(uint8 request);
RESULT usbGetInterfaceSetting(uint8,uint8);

uint8* usbGetDeviceDescriptor(uint16 length);
uint8* usbGetConfigDescriptor(uint16 length);
uint8* usbGetStringDescriptor(uint16 length);

/* internal callbacks to respond to standard requests */
void usbSetConfiguration(void);
void usbSetDeviceAddress(void);

#if defined(__cplusplus)
}
#endif


#endif