|
9 | 9 | * Copyright (C) 2009 ARM Limited. All rights reserved. |
10 | 10 | * |
11 | 11 | * @par |
12 | | - * ARM Limited (ARM) is supplying this software for use with Cortex-M |
13 | | - * processor based microcontrollers. This file can be freely distributed |
| 12 | + * ARM Limited (ARM) is supplying this software for use with Cortex-M |
| 13 | + * processor based microcontrollers. This file can be freely distributed |
14 | 14 | * within development tools that are supporting such ARM based processors. |
15 | 15 | * |
16 | 16 | * @par |
|
25 | 25 | #include "LPC17xx.h" |
26 | 26 |
|
27 | 27 | /* |
28 | | - * To see how the LEDs are connected, see for instance: |
| 28 | + * To see how the LEDs are connected, refer to: |
29 | 29 | * http://mbed.org/projects/libraries/svn/mbed/trunk/PinNames.h |
30 | 30 | */ |
31 | | -#define LED1 (1<<18) // LED1 = P1_18 |
32 | | -#define LED2 (1<<20) // LED2 = P1_20 |
33 | | -#define LED3 (1<<21) // LED3 = P1_21 |
34 | | -#define LED4 (1<<22) // LED4 = P1_22 |
| 31 | +#define LED1 (1<<18) /* LED1 = P1_18 */ |
| 32 | +#define LED2 (1<<20) /* LED2 = P1_20 */ |
| 33 | +#define LED3 (1<<21) /* LED3 = P1_21 */ |
| 34 | +#define LED4 (1<<22) /* LED4 = P1_22 */ |
35 | 35 |
|
| 36 | +volatile uint32_t msTicks; /* counts 1ms timeTicks */ |
36 | 37 |
|
37 | | -volatile uint32_t msTicks; /* counts 1ms timeTicks */ |
38 | 38 | /*---------------------------------------------------------------------------- |
39 | 39 | SysTick_Handler |
40 | 40 | *----------------------------------------------------------------------------*/ |
41 | 41 | void SysTick_Handler(void) { |
42 | | - msTicks++; /* increment counter necessary in Delay() */ |
| 42 | + msTicks++; /* increment counter necessary in Delay() */ |
43 | 43 | } |
44 | 44 |
|
45 | 45 | /*------------------------------------------------------------------------------ |
46 | 46 | delays number of tick Systicks (happens every 1 ms) |
47 | 47 | *------------------------------------------------------------------------------*/ |
48 | 48 | __INLINE static void Delay (uint32_t dlyTicks) { |
49 | | - uint32_t curTicks; |
| 49 | + uint32_t curTicks; |
50 | 50 |
|
51 | | - curTicks = msTicks; |
52 | | - while ((msTicks - curTicks) < dlyTicks); |
| 51 | + curTicks = msTicks; |
| 52 | + while ((msTicks - curTicks) < dlyTicks); |
53 | 53 | } |
54 | 54 |
|
55 | 55 | /*------------------------------------------------------------------------------ |
56 | 56 | configer LED pins |
57 | 57 | *------------------------------------------------------------------------------*/ |
58 | 58 | __INLINE static void LED_Config(void) { |
59 | | - |
60 | | - LPC_GPIO1->FIODIR = 0xFFFFFFFF; /* LEDs PORT1 are Output */ |
| 59 | + LPC_GPIO1->FIODIR = 0xFFFFFFFF; /* LEDs PORT1 are Output */ |
61 | 60 | } |
62 | 61 |
|
63 | 62 | /*------------------------------------------------------------------------------ |
64 | 63 | Switch on LEDs |
65 | 64 | *------------------------------------------------------------------------------*/ |
66 | 65 | __INLINE static void LED_On (uint32_t led) { |
67 | | - |
68 | | - LPC_GPIO1->FIOPIN |= (led); /* Turn On LED */ |
| 66 | + LPC_GPIO1->FIOPIN |= (led); /* Turn On LED */ |
69 | 67 | } |
70 | 68 |
|
71 | 69 |
|
72 | 70 | /*------------------------------------------------------------------------------ |
73 | 71 | Switch off LEDs |
74 | 72 | *------------------------------------------------------------------------------*/ |
75 | 73 | __INLINE static void LED_Off (uint32_t led) { |
76 | | - |
77 | | - LPC_GPIO1->FIOPIN &= ~(led); /* Turn Off LED */ |
| 74 | + LPC_GPIO1->FIOPIN &= ~(led); /* Turn Off LED */ |
78 | 75 | } |
79 | 76 |
|
80 | 77 | /*---------------------------------------------------------------------------- |
81 | 78 | MAIN function |
82 | 79 | *----------------------------------------------------------------------------*/ |
83 | 80 | int main (void) { |
84 | | - /* Adjust SystemCoreClock global according to clock registers */ |
85 | | - SystemCoreClockUpdate(); |
86 | | - |
87 | | - if (SysTick_Config(SystemCoreClock / 1000)) { /* Setup SysTick Timer for 1 msec interrupts */ |
88 | | - while (1); /* Capture error */ |
89 | | - } |
| 81 | + /* Adjust SystemCoreClock global according to clock registers */ |
| 82 | + SystemCoreClockUpdate(); |
90 | 83 |
|
91 | | - LED_Config(); |
| 84 | + if (SysTick_Config(SystemCoreClock / 1000)) { /* Setup SysTick Timer for 1 msec interrupts */ |
| 85 | + while (1); /* Capture error */ |
| 86 | + } |
92 | 87 |
|
93 | | - while(1) { |
94 | | - LED_On (LED1); /* Turn on the LED. */ |
95 | | - Delay (100); /* delay 100 Msec */ |
96 | | - LED_Off (LED1); /* Turn off the LED. */ |
97 | | - Delay (100); /* delay 100 Msec */ |
98 | | - } |
| 88 | + LED_Config(); |
99 | 89 |
|
| 90 | + while(1) { |
| 91 | + LED_On(LED1); /* Turn on the LED */ |
| 92 | + Delay(100); /* Delay 100 Msec */ |
| 93 | + LED_Off(LED1); /* Turn off the LED */ |
| 94 | + Delay(100); /* Delay 100 Msec */ |
| 95 | + } |
100 | 96 | } |
101 | 97 |
|
0 commit comments