-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.c
61 lines (45 loc) · 1.01 KB
/
main.c
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
#include <xc.h>
#include <stdint.h>
#include <stdbool.h>
#include "system.h"
#include "usb.h"
#include "usb_device.h"
#include "usb_device_cdc.h"
#include "fpga_uart.h"
#include "spi_flash.h"
/*
void EchoTask(uint8_t cdc_port) {
if (!USBUSARTIsTxTrfReady(cdc_port)) {
return;
}
uint8_t buf[140];
uint8_t bytes_read = getsUSBUSART(cdc_port, buf, sizeof(buf));
if (bytes_read == 0) {
return;
}
for (uint8_t i = 0; i < bytes_read; ++i) {
if (buf[i] != 0x0a && buf[i] != 0x0d) {
buf[i] += cdc_port;
}
}
putUSBUSART(cdc_port, buf, bytes_read);
}
*/
void main(void) {
ConfigureOscillator();
USBDeviceInit();
USBDeviceAttach();
SpiFlashInit();
FpgaUartInit();
while(1) {
#if defined(USB_POLLING)
USBDeviceTasks();
#endif
if( USBGetDeviceState() < CONFIGURED_STATE || USBIsDeviceSuspended()) {
continue;
}
SpiFlashTask();
FpgaUartTask();
CDCTxService();
}
}