blob: 0e630f62719a0fa4513785d4680b9a594b1beb5c (
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
|
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_uart.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "driverlib/timer.h"
#include "driverlib/uart.h"
#include "driverlib/usb.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "usblib/usblib.h"
#include "usblib/usbcdc.h"
#include "usblib/usb-ids.h"
#include "usblib/device/usbdevice.h"
#include "usblib/device/usbdcdc.h"
//#include <ti/sysbios/knl/Task.h>
#include "utils/ustdlib.h"
#include "usb_serial_structs.h"
//*****************************************************************************
//
// The system tick rate expressed both as ticks per second and a millisecond
// period.
//
//*****************************************************************************
#define TICKS_PER_SECOND 100
//*****************************************************************************
//
// Variables tracking transmit and receive counts.
//
//*****************************************************************************
static volatile uint32_t g_RxCount;
#ifdef DEBUG
uint32_t g_ui32UARTRxErrors;
#endif
//*****************************************************************************
//
// Flags used to pass commands from interrupt context to the main loop.
//
//*****************************************************************************
#define FLAG_STATUS_UPDATE 0
#define FLAG_USB_CONFIGURED 1
#define FLAG_SENDING_BREAK 2
static volatile uint32_t g_ui32Flags;
static void (*callback)(char* buffer, size_t length);
//*****************************************************************************
//
// Internal function prototypes.
//
//*****************************************************************************
static void CheckForSerialStateChange(const tUSBDCDCDevice *psDevice, uint32_t ui32Errors);
static void SetControlLineState(uint16_t ui16State);
static void GetLineCoding(tLineCoding *psLineCoding);
static void handleRx(void);
void StartUSB(uint32_t ui32SysClock);
void InitUSB(void);
uint32_t SendChars(char* buffer,size_t length);
void RegisterReceiveCallback(void (*callback_ptr)(char* buffer, size_t length));
|