aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Common/Utilities/Update.c
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-03-06 12:09:02 +0200
committerShlomo Hecht <shlomo@twine-s.com>2018-03-06 12:09:02 +0200
commitfb2d080fbbcea3a91e598b4ea8837a230de6a319 (patch)
tree6b3ce09a252d2ebab8189a92b3326ffbba6dbe4b /Software/Embedded_SW/Embedded/Common/Utilities/Update.c
parentd734bb5cf08ba2433b74fc86a8858d2437d1a237 (diff)
downloadTango-fb2d080fbbcea3a91e598b4ea8837a230de6a319.tar.gz
Tango-fb2d080fbbcea3a91e598b4ea8837a230de6a319.zip
A new forlder for embedded software in our common structure
Diffstat (limited to 'Software/Embedded_SW/Embedded/Common/Utilities/Update.c')
-rw-r--r--Software/Embedded_SW/Embedded/Common/Utilities/Update.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/Software/Embedded_SW/Embedded/Common/Utilities/Update.c b/Software/Embedded_SW/Embedded/Common/Utilities/Update.c
new file mode 100644
index 000000000..8eeee64cf
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Common/Utilities/Update.c
@@ -0,0 +1,98 @@
+
+#include "include.h"
+//#include <stdbool.h>
+
+//#include "Drivers/USB_Communication/USBCDCD.h"
+
+
+extern Semaphore_Handle updateSem;
+
+
+void UpdateUsb(void)
+{
+ //
+ // Terminate the USB device and detach from the bus.
+ //
+ USBDCDTerm(0);
+
+ //
+ // Disable all interrupts.
+ //
+ ROM_IntMasterDisable();
+
+ //
+ // Disable SysTick and its interrupt.
+ //
+ ROM_SysTickIntDisable();
+ ROM_SysTickDisable();
+
+ //
+ // Disable all processor interrupts. Instead of disabling them one at a
+ // time, a direct write to NVIC is done to disable all peripheral
+ // interrupts.
+ //
+ HWREG(NVIC_DIS0) = 0xffffffff;
+ HWREG(NVIC_DIS1) = 0xffffffff;
+ HWREG(NVIC_DIS2) = 0xffffffff;
+ HWREG(NVIC_DIS3) = 0xffffffff;
+ HWREG(NVIC_DIS4) = 0xffffffff;
+
+ //
+ // Enable and reset the USB peripheral.
+ //
+ ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
+ ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_USB0);
+ ROM_USBClockEnable(USB0_BASE, 8, USB_CLOCK_INTERNAL);
+
+ //
+ // Wait for about a second.
+ //
+ ROM_SysCtlDelay(SYS_CLK_FREQ / 3);
+
+ //
+ // Re-enable interrupts at the NVIC level.
+ //
+ ROM_IntMasterEnable();
+
+ //
+ // Call the USB boot loader.
+ //
+ ROM_UpdateUSB(0);
+
+ //
+ // Should never get here, but just in case.
+ //
+ while(1)
+ {
+ }
+}
+
+Void updateTask(UArg arg0, UArg arg1)
+{
+
+ //
+ // Wait until new updTE ARRIVED
+ //
+ Semaphore_pend(updateSem, BIOS_WAIT_FOREVER);
+ UpdateUsb();
+}
+extern Semaphore_Handle ReconnectSem;
+
+
+void ReconnectUsb(void)
+{
+ //USBCDC_close();
+}
+
+Void ReconnectTask(UArg arg0, UArg arg1)
+{
+
+ //
+ // Wait until new updTE ARRIVED
+ //
+ while (1)
+ {
+ Semaphore_pend(ReconnectSem, BIOS_WAIT_FOREVER);
+ ReconnectUsb();
+ }
+}