feat: add prototypes+functions for moar LED blinks

yes. moar.
* also for now remove the built-in delay() function callsas it's doing
  pretty much nothing and use system() to call OS sleep command (works
  on GNU/Linux)
This commit is contained in:
surtur 2020-12-11 17:12:01 +01:00
parent 633a3acf02
commit 77a5ad2549
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
3 changed files with 40 additions and 4 deletions

@ -23,10 +23,14 @@ void LEDS_Init(void) {
/* Configure pins as output*/
pinMode(LED_GREEN, OUTPUT);
pinMode(LED_BLUE, OUTPUT);
pinMode(LED_RED, OUTPUT);
/* Turn off the LEDs; they are turned off by HIGH value. */
pinWrite(LED_GREEN, HIGH);
pinWrite(LED_BLUE, HIGH);
pinWrite(LED_RED, HIGH);
}
@ -37,6 +41,18 @@ void LEDS_GreenOn(void) {
}
void LEDS_BlueOn(void) {
pinWrite(LED_BLUE, LOW);
}
void LEDS_RedOn(void) {
pinWrite(LED_RED, LOW);
}
/* Turn off green LED (RGB LED on FRDM-KL25Z board) */
void LEDS_GreenOff(void) {
@ -45,4 +61,14 @@ void LEDS_GreenOff(void) {
}
// TODO: add more functions...
void LEDS_BlueOff(void) {
pinWrite(LED_BLUE, HIGH);
}
void LEDS_RedOff(void) {
pinWrite(LED_RED, HIGH);
}

8
leds.h

@ -18,11 +18,17 @@ void LEDS_Init(void);
/* Turn on green LED (RGB LED on FRDM-KL25Z board) */
void LEDS_GreenOn(void);
void LEDS_BlueOn(void);
void LEDS_RedOn(void);
/* Turn off green LED (RGB LED on FRDM-KL25Z board) */
void LEDS_GreenOff(void);
// TODO: add Red and Blue LED functions
void LEDS_BlueOff(void);
void LEDS_RedOff(void);
#endif /* SOURCES_DRV_LEDS_H_ */

@ -11,9 +11,13 @@ int main()
// blikani LED
while(1) {
LEDS_GreenOn();
delay();
system("sleep 1");
LEDS_BlueOn();
system("sleep 1");
LEDS_GreenOff();
delay();
system("sleep 1");
LEDS_BlueOff();
system("sleep 1");
}
return 0;
}