1 /******************************************************************************
\r
3 * @purpose: CMSIS Cortex-M3 Core Peripheral Access Layer Source File
\r
4 * Blink a LED using CM3 SysTick
\r
6 * @date: 22. May 2009
\r
7 *----------------------------------------------------------------------------
\r
9 * Copyright (C) 2008 ARM Limited. All rights reserved.
\r
11 * ARM Limited (ARM) is supplying this software for use with Cortex-M3
\r
12 * processor based microcontrollers. This file can be freely distributed
\r
13 * within development tools that are supporting such ARM based processors.
\r
15 * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
\r
16 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
\r
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
\r
18 * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
\r
19 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
\r
21 ******************************************************************************/
\r
23 #include "LPC17xx.h"
\r
26 uint32_t msTicks; /* counts 1ms timeTicks */
\r
27 /*----------------------------------------------------------------------------
\r
29 *----------------------------------------------------------------------------*/
\r
30 void SysTick_Handler(void) {
\r
31 msTicks++; /* increment counter necessary in Delay() */
\r
34 /*------------------------------------------------------------------------------
\r
35 delays number of tick Systicks (happens every 1 ms)
\r
36 *------------------------------------------------------------------------------*/
\r
37 __inline static void Delay (uint32_t dlyTicks) {
\r
41 while ((msTicks - curTicks) < dlyTicks);
\r
44 /*------------------------------------------------------------------------------
\r
46 *------------------------------------------------------------------------------*/
\r
47 __inline static void LED_Config(void) {
\r
49 GPIO1->FIODIR = (1<<29)|(1<<18); /* LEDs on PORT1 18 & 29 are Output */
\r
52 /*------------------------------------------------------------------------------
\r
54 *------------------------------------------------------------------------------*/
\r
55 __inline static void LED_On (uint32_t led) {
\r
57 GPIO1->FIOPIN |= (led); /* Turn On LED */
\r
61 /*------------------------------------------------------------------------------
\r
63 *------------------------------------------------------------------------------*/
\r
64 __inline static void LED_Off (uint32_t led) {
\r
66 GPIO1->FIOPIN &= ~(led); /* Turn Off LED */
\r
69 /*----------------------------------------------------------------------------
\r
71 *----------------------------------------------------------------------------*/
\r
74 SystemInit(); /* setup clocks */
\r
75 if (SysTick_Config(SystemFrequency / 1000)) { /* Setup SysTick Timer for 1 msec interrupts */
\r
76 while (1); /* Capture error */
\r
82 LED_On ((1<<29)); /* Turn on the LED. */
\r
83 LED_On ((1<<18)); /* Turn on the LED. */
\r
84 Delay (100); /* delay 100 Msec */
\r
85 LED_Off ((1<<29)); /* Turn on the LED. */
\r
86 Delay (100); /* delay 100 Msec */
\r
87 LED_Off ((1<<18)); /* Turn on the LED. */
\r
88 LED_On ((1<<29)); /* Turn on the LED. */
\r
89 Delay (100); /* delay 100 Msec */
\r