diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2014-09-01 21:02:51 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2014-09-01 21:02:51 +0200 |
commit | 5a4b6a5e6979fa034d537a803d43c04181a5ade7 (patch) | |
tree | bcbbe758c30c55e6b4e5b70faa8cf720f3fb7e34 | |
parent | e98d39ba86142ba17b608ebf2f2880940f5621c2 (diff) |
Rename LED functions to be more in thread with the rest of the code.
-rw-r--r-- | firmware/drivers/led.c | 20 | ||||
-rw-r--r-- | firmware/drivers/led.h | 8 | ||||
-rw-r--r-- | firmware/src/p2m.c | 10 |
3 files changed, 21 insertions, 17 deletions
diff --git a/firmware/drivers/led.c b/firmware/drivers/led.c index fe8d6f5..293d627 100644 --- a/firmware/drivers/led.c +++ b/firmware/drivers/led.c @@ -28,28 +28,32 @@ #include <LPC17xx.h> -int led_state = 0; +static int led_state = 0; -void LED_Init() +void led_init() { - LPC_SC->PCONP |= ( 1 << 15 ); // power up GPIO + // See table 46, pg. 63 + uint32_t *pconp = (uint32_t*)0x400FC0C4; + *pconp |= (0b1 << 15); // power up GPIO + + // See table 104, pg. 124 LPC_GPIO1->FIODIR |= 1 << 29; // puts P1.29 into output mode. } -void LED_on() +void led_on() { led_state = 1; LPC_GPIO1->FIOPIN |= 1 << 29; // make P1.29 high } -void LED_off() +void led_off() { led_state = 0; LPC_GPIO1->FIOPIN &= ~( 1 << 29 ); // make P1.29 low } -void LED_toggle() +void led_toggle() { - if(led_state) LED_off(); - else LED_on(); + if(led_state) led_off(); + else led_on(); } diff --git a/firmware/drivers/led.h b/firmware/drivers/led.h index 2c81474..d2af83f 100644 --- a/firmware/drivers/led.h +++ b/firmware/drivers/led.h @@ -27,9 +27,9 @@ #ifndef __PEDAL2METAL_LED_H__ #define __PEDAL2METAL_LED_H__ -void LED_Init(); -void LED_on(); -void LED_off(); -void LED_toggle(); +void led_init(); +void led_on(); +void led_off(); +void led_toggle(); #endif/*__PEDAL2METAL_LED_H__*/ diff --git a/firmware/src/p2m.c b/firmware/src/p2m.c index aa5250d..95acc21 100644 --- a/firmware/src/p2m.c +++ b/firmware/src/p2m.c @@ -146,7 +146,7 @@ int main (void) // SystemCoreClockUpdate();
// SystemInit();
- LED_Init();
+ led_init();
uint8_t portnum = 0;
@@ -226,13 +226,13 @@ int main (void) // Indicate that we didn't crash before the end...
while(1) { // slow blink
- LED_toggle();
+ led_toggle();
_delay(1 << 21);
}
fail:
while(1) { // fast blink
- LED_toggle();
+ led_toggle();
_delay(1 << 17);
}
}
@@ -260,7 +260,7 @@ typedef unsigned char uint8_t; int main (void)
{
- LED_Init(); // Bent code
+ led_init(); // Bent code
// 3. Initializing
/*
@@ -353,7 +353,7 @@ int main (void) // Indicate that we didn't crash before the end...
int i = 0;
while(1) {
- LED_toggle();
+ led_toggle();
_delay(1 << 21);
i = 1 - i;
}
|