From 1058d8147438a9801f6df3e4890957c3ef7d9a37 Mon Sep 17 00:00:00 2001 From: JonWoellhaf Date: Sat, 14 Nov 2020 21:47:05 -0700 Subject: [PATCH 1/2] Create .project --- .project | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .project diff --git a/.project b/.project new file mode 100644 index 0000000..ed8dc0b --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + electronic-leadscrew + + + + + + + + From 092d6769125f70fc993bb5d548e50f59a17da470 Mon Sep 17 00:00:00 2001 From: JonWoellhaf Date: Sat, 14 Nov 2020 22:25:17 -0700 Subject: [PATCH 2/2] Rhythmically blink LED4 (red) and LED5 (green) on the TI LAUNCHXL-F280049C board. This allows those who do not have an oscilloscope to verify the user interface loop is running. --- els-f280049c/Debug.cpp | 12 ++++++++++++ els-f280049c/Debug.h | 28 ++++++++++++++++++++++++++++ els-f280049c/main.cpp | 3 +++ 3 files changed, 43 insertions(+) diff --git a/els-f280049c/Debug.cpp b/els-f280049c/Debug.cpp index 3da41e7..0da10c9 100644 --- a/els-f280049c/Debug.cpp +++ b/els-f280049c/Debug.cpp @@ -35,13 +35,25 @@ Debug :: Debug( void ) void Debug :: initHardware( void ) { + // Initialize GPIO + // Doesn't work if put after EALLOW + InitGpio(); + // set up GPIO pins as output for debugging EALLOW; + GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 0; GpioCtrlRegs.GPADIR.bit.GPIO2 = 1; GpioDataRegs.GPACLEAR.bit.GPIO2 = 1; + GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 0; GpioCtrlRegs.GPADIR.bit.GPIO3 = 1; GpioDataRegs.GPACLEAR.bit.GPIO3 = 1; + + // LED4 on LAUNCHXL (red) + GpioCtrlRegs.GPAMUX2.bit.GPIO23 = 0; + GpioCtrlRegs.GPADIR.bit.GPIO23 = 1; + GpioDataRegs.GPACLEAR.bit.GPIO23 = 1; + EDIS; } diff --git a/els-f280049c/Debug.h b/els-f280049c/Debug.h index 993e032..2782843 100644 --- a/els-f280049c/Debug.h +++ b/els-f280049c/Debug.h @@ -31,6 +31,9 @@ class Debug { +private: + Uint16 heartbeatCount; + public: Debug(void); void initHardware(void); @@ -42,6 +45,8 @@ class Debug // analyzer pin 2 void begin2( void ); void end2( void ); + + void heartbeat( void ); }; @@ -65,5 +70,28 @@ inline void Debug :: end2( void ) GpioDataRegs.GPACLEAR.bit.GPIO3 = 1; } +inline void Debug :: heartbeat( void ) +{ + ++heartbeatCount; + + if (heartbeatCount > 50) + { + heartbeatCount = 1; + } + + if (heartbeatCount == 15) + { + // Turn off red LED and turn on green LED + GpioDataRegs.GPASET.bit.GPIO23 = 1; + GpioDataRegs.GPBCLEAR.bit.GPIO34 = 1; + } + + if (heartbeatCount == 1) + { + // Turn on red LED and turn off green LED + GpioDataRegs.GPACLEAR.bit.GPIO23 = 1; + GpioDataRegs.GPBSET.bit.GPIO34 = 1; + } +} #endif // __DEBUG_H diff --git a/els-f280049c/main.cpp b/els-f280049c/main.cpp index 24c4872..fe28342 100644 --- a/els-f280049c/main.cpp +++ b/els-f280049c/main.cpp @@ -139,6 +139,9 @@ void main(void) // mark beginning of loop for debugging debug.begin2(); + // service heartbeat + debug.heartbeat(); + // service the user interface userInterface.loop();