From 4f9462e9835a8a05a131837424f0093fe0848996 Mon Sep 17 00:00:00 2001 From: "Collin J. Doering" Date: Thu, 15 Oct 2015 05:39:07 -0400 Subject: [PATCH] Move led flashing code from lcdLib to lcdOutput Refactor led flashing code from lcdLib.c and lcdLib.h to lcdOutput.c. Signed-off-by: Collin J. Doering --- lcdLib.c | 16 ---------------- lcdLib.h | 8 -------- lcdOutput.c | 15 +++++++++++++++ 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/lcdLib.c b/lcdLib.c index 9a6ca4d..179e939 100644 --- a/lcdLib.c +++ b/lcdLib.c @@ -35,18 +35,6 @@ const uint8_t lineBeginnings[LCD_NUMBER_OF_LINES] = { LCD_LINE_BEGINNINGS }; //------------------------------------------------------------------------------------------ // Function definitions -void flashLED(uint8_t times) { - while (times > 0) { - STATUS_LED_PORT |= 1 << STATUS_LED; // turn on status LED - _delay_ms(100); - STATUS_LED_PORT &= ~(1 << STATUS_LED); // turn status LED off - _delay_ms(100); - times--; - } -} - -//------------------------------------ - void clkLCD(void) { LCD_ENABLE_PORT |= (1 << LCD_ENABLE); _delay_us(LCD_ENABLE_HIGH_DELAY); @@ -63,7 +51,6 @@ void loop_until_LCD_BF_clear(void) { // Set LCD_BF as input LCD_DBUS7_DDR &= ~(1 << LCD_BF); - STATUS_LED_PORT |= 1 << STATUS_LED; // DEBUG do { bf = 0; LCD_ENABLE_PORT |= (1 << LCD_ENABLE); @@ -81,7 +68,6 @@ void loop_until_LCD_BF_clear(void) { _delay_us(1); // 'address hold time', 'data hold time' and 'enable cycle width' #endif } while (bf); - STATUS_LED_PORT &= ~(1 << STATUS_LED); // DEBUG #if defined (FOUR_BIT_MODE) || defined (EIGHT_BIT_ARBITRARY_PIN_MODE) LCD_DBUS7_DDR |= (1 << LCD_DBUS7); @@ -406,8 +392,6 @@ void initLCD (void) { // Display on, cursor on, blink off writeLCDInstr(INSTR_DISPLAY | (1 << INSTR_DISPLAY_D) | (1 << INSTR_DISPLAY_C)); - - flashLED(5); // DEBUG } /* diff --git a/lcdLib.h b/lcdLib.h index 5522360..39800fb 100644 --- a/lcdLib.h +++ b/lcdLib.h @@ -67,15 +67,7 @@ //------------------------------------ - -#define STATUS_LED_PORT PORTC -#define STATUS_LED_DDR DDRC -#define STATUS_LED PC5 - // Function definitions -void flashLED(uint8_t times); - -//------------------------------------ /** Bring LCD_ENABLE line high, wait for LCD_ENABLE_HIGH_DELAY; then bring LCD_ENABLE line low diff --git a/lcdOutput.c b/lcdOutput.c index 53a6240..1ebc7b7 100644 --- a/lcdOutput.c +++ b/lcdOutput.c @@ -34,6 +34,20 @@ #include "ansi_escapes.h" #include "USART.h" +#define STATUS_LED_PORT PORTC +#define STATUS_LED_DDR DDRC +#define STATUS_LED PC5 + +void flashLED(uint8_t times) { + while (times > 0) { + STATUS_LED_PORT |= 1 << STATUS_LED; // turn on status LED + _delay_ms(100); + STATUS_LED_PORT &= ~(1 << STATUS_LED); // turn status LED off + _delay_ms(100); + times--; + } +} + int main(void) { clock_prescale_set(clock_div_1); @@ -44,6 +58,7 @@ int main(void) { initLCD(); //initLCDByInternalReset(); + flashLED(5); // DEBUG while (1) { serialChar = receiveByte();