Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'heartbeat' #108

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>electronic-leadscrew</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
12 changes: 12 additions & 0 deletions els-f280049c/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
28 changes: 28 additions & 0 deletions els-f280049c/Debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@

class Debug
{
private:
Uint16 heartbeatCount;

public:
Debug(void);
void initHardware(void);
Expand All @@ -42,6 +45,8 @@ class Debug
// analyzer pin 2
void begin2( void );
void end2( void );

void heartbeat( void );
};


Expand All @@ -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
3 changes: 3 additions & 0 deletions els-f280049c/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down