ef0be5d169b3e16c931861c93055aff4aab0a03b
[rapper.git] / new_cmsis / led.h
1 #ifndef LED_H
2 #define LED_H
3
4 #include <board.h>
5
6 extern uint32_t msTicks;                               /* counts 1ms timeTicks */
7
8 /*------------------------------------------------------------------------------
9   delays number of tick Systicks (happens every 1 ms)
10  *------------------------------------------------------------------------------*/
11 __inline static void Delay (uint32_t dlyTicks) {
12   uint32_t curTicks;
13
14   curTicks = msTicks;
15   while ((msTicks - curTicks) < dlyTicks);
16 }
17
18 /*------------------------------------------------------------------------------
19   configer LED pins
20  *------------------------------------------------------------------------------*/
21 __inline static void LED_Config(void) {
22
23   GPIO1->FIODIR = (1<<29)|(1<<18);     /* LEDs on PORT1 18 & 29 are Output */
24 }
25
26 /*------------------------------------------------------------------------------
27   Switch on LEDs
28  *------------------------------------------------------------------------------*/
29 __inline static void LED_On (uint32_t led) {
30
31   GPIO1->FIOPIN |=  (led);                      /* Turn On  LED */
32 }
33
34
35 /*------------------------------------------------------------------------------
36   Switch off LEDs
37  *------------------------------------------------------------------------------*/
38 __inline static void LED_Off (uint32_t led) {
39
40   GPIO1->FIOPIN &= ~(led);                      /* Turn Off LED */
41 }
42
43 #endif