aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Code_Composer/twine_usblib_demo/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Code_Composer/twine_usblib_demo/main.c')
-rw-r--r--Software/Code_Composer/twine_usblib_demo/main.c109
1 files changed, 109 insertions, 0 deletions
diff --git a/Software/Code_Composer/twine_usblib_demo/main.c b/Software/Code_Composer/twine_usblib_demo/main.c
new file mode 100644
index 000000000..d7bcae1dd
--- /dev/null
+++ b/Software/Code_Composer/twine_usblib_demo/main.c
@@ -0,0 +1,109 @@
+#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 "drivers/pinout.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 "utils/ustdlib.h"
+#include "usb_serial_adapter.h"
+#include "graphics_adapter.h"
+#include "protobuf/person-pb-c.h"
+
+//*****************************************************************************
+//
+// The system tick rate expressed both as ticks per second and a millisecond
+// period.
+//
+//*****************************************************************************
+#define TICKS_PER_SECOND 100
+
+//*****************************************************************************
+//
+// Global system tick counter
+//
+//*****************************************************************************
+static volatile uint32_t g_ui32SysTickCount = 0;
+
+// Flags used to pass commands from interrupt context to the main loop.
+static volatile uint32_t g_ui32Flags;
+
+
+//*****************************************************************************
+//
+// Interrupt handler for the system tick counter.
+//
+//*****************************************************************************
+void SysTickHandler(void)
+{
+ // Update our system time.
+ g_ui32SysTickCount++;
+}
+
+//*****************************************************************************
+//
+// Interrupt handler for the UART which we are redirecting via USB.
+//
+//*****************************************************************************
+void USB0Handler(void)
+{
+ InitUSB();
+}
+
+void receive_callback(char* buffer, size_t length)
+{
+ //SendChars(buffer,length);
+ draw_string(buffer, length);
+ //draw_image((uint8_t *)buffer);
+
+// Person* p = person__unpack (NULL, length, (uint8_t*)buffer);
+// void* buf = malloc (length);
+// person__pack (p, buf);
+// SendChars(buf,length);
+// free(p);
+// free(buf);
+}
+
+int main(void)
+{
+ uint32_t ui32SysClock, ui32PLLRate;
+
+ // Set the system clock to run at 120MHz from the PLL.
+ ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
+ SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
+ SYSCTL_CFG_VCO_480), 120000000);
+
+ // Configure the device pins.
+ PinoutSet();
+
+ // Save the PLL rate used by this application.
+ SysCtlVCOGet(SYSCTL_XTAL_25MHZ, &ui32PLLRate);
+
+ // Enable the system tick.
+ ROM_SysTickPeriodSet(ui32SysClock / TICKS_PER_SECOND);
+ ROM_SysTickIntEnable();
+ ROM_SysTickEnable();
+
+ init_graphics(ui32SysClock);
+
+ RegisterReceiveCallback(&receive_callback);
+ StartUSB(ui32SysClock);
+
+ while(1){};
+}