Skip to content

Commit

Permalink
Added ability to toggle heartbeat LED
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldegrasse committed Aug 22, 2020
1 parent 67fbfcc commit 7a02aae
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
25 changes: 24 additions & 1 deletion heartbeat_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,41 @@
/* TI-RTOS drivers */
#include <ti/drivers/GPIO.h>

#include <stdbool.h>

/* Board Header file */
#include "Board.h"

bool LED_ENABLED = false;

static void button_pressed(unsigned int index) {
// Toggle the LED enabled state, and disable the LED.
LED_ENABLED ^= true;
GPIO_toggle(Board_LED0);
}

/**
* Sets up the heart beat task, Enabling the Heartbeat LED to be toggled.
*/
void heartbeat_prebios(void) {
// Install button callback.
GPIO_setCallback(Board_BUTTON1, button_pressed);
// Enable button interrupt.
GPIO_enableInt(Board_BUTTON1);
}

/*
* ======== heartBeatFxn ========
* Toggle the Board_LED0. The Task_sleep is determined by arg0 which
* is configured for the heartBeat Task instance.
*/
void heartBeatFxn(UArg arg0, UArg arg1) {
LED_ENABLED = true;
while (1) {
Task_sleep((UInt)arg0);
GPIO_toggle(Board_LED0);
if (LED_ENABLED) {
GPIO_toggle(Board_LED0);
}
/*
* Turn off the SD write LED. This way if the UART logger hasn't
* written data in a while, the LED will be off.
Expand Down
12 changes: 12 additions & 0 deletions heartbeat_task.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef HEARTBEAT_H
#define HEARTBEAT_H
/**
* @file heartbeat_task.h
* Implements the heartbeat task, which simply flashes a LED on the board.
*/

/**
* Sets up the heart beat task, Enabling the Heartbeat LED to be toggled.
*/
void heartbeat_prebios(void);
#endif
2 changes: 0 additions & 2 deletions sd_card.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ void sd_setup(void) {
}
// Set up SPI bus.
Board_initSDSPI();
// Enable GPIO.
Board_initGPIO();
}

/**
Expand Down
4 changes: 4 additions & 0 deletions sd_logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/* Board Header file */
#include "Board.h"

#include "heartbeat_task.h"
#include "sd_card.h"
#include "uart_console_task.h"
#include "uart_logger_task.h"
Expand All @@ -24,6 +25,9 @@ int main(void) {
Board_initGeneral();
Board_initUART(); // Done here since both the console and logger use it.
uart_console_prebios();
// Enable the heartbeat task
Board_initGPIO();
heartbeat_prebios();
uart_logger_prebios();
// Setup required pthread variables for the SD card.
sd_setup();
Expand Down

0 comments on commit 7a02aae

Please sign in to comment.