X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=sidebyside;f=new_cmsis%2Fmain.c;fp=new_cmsis%2Fmain.c;h=2c70737f4a6944592f829d614372ae88aabd1f15;hb=3438bf0abc23eef37e92dfc56cd9410663b35434;hp=0000000000000000000000000000000000000000;hpb=1da5e41a8eecc5bc9d4fe835c320643d951ef6c0;p=rapper.git diff --git a/new_cmsis/main.c b/new_cmsis/main.c new file mode 100644 index 0000000..2c70737 --- /dev/null +++ b/new_cmsis/main.c @@ -0,0 +1,89 @@ +/****************************************************************************** + * @file: main.c + * @purpose: CMSIS Cortex-M3 Core Peripheral Access Layer Source File + * Blink a LED using CM3 SysTick + * @version: V1.0 + * @date: 22. May 2009 + *---------------------------------------------------------------------------- + * + * Copyright (C) 2008 ARM Limited. All rights reserved. + * + * ARM Limited (ARM) is supplying this software for use with Cortex-M3 + * processor based microcontrollers. This file can be freely distributed + * within development tools that are supporting such ARM based processors. + * + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +#include "LPC17xx.h" + + +uint32_t msTicks; /* counts 1ms timeTicks */ +/*---------------------------------------------------------------------------- + SysTick_Handler + *----------------------------------------------------------------------------*/ +void SysTick_Handler(void) { + msTicks++; /* increment counter necessary in Delay() */ +} + +/*------------------------------------------------------------------------------ + delays number of tick Systicks (happens every 1 ms) + *------------------------------------------------------------------------------*/ +__inline static void Delay (uint32_t dlyTicks) { + uint32_t curTicks; + + curTicks = msTicks; + while ((msTicks - curTicks) < dlyTicks); +} + +/*------------------------------------------------------------------------------ + configer LED pins + *------------------------------------------------------------------------------*/ +__inline static void LED_Config(void) { + + GPIO1->FIODIR = 0xB0000000; /* LEDs PORT1 are Output */ +} + +/*------------------------------------------------------------------------------ + Switch on LEDs + *------------------------------------------------------------------------------*/ +__inline static void LED_On (uint32_t led) { + + GPIO1->FIOPIN |= (led); /* Turn On LED */ +} + + +/*------------------------------------------------------------------------------ + Switch off LEDs + *------------------------------------------------------------------------------*/ +__inline static void LED_Off (uint32_t led) { + + GPIO1->FIOPIN &= ~(led); /* Turn Off LED */ +} + +/*---------------------------------------------------------------------------- + MAIN function + *----------------------------------------------------------------------------*/ +int main (void) { + + SystemInit(); /* setup clocks */ + if (SysTick_Config(SystemFrequency / 1000)) { /* Setup SysTick Timer for 1 msec interrupts */ + while (1); /* Capture error */ + } + + LED_Config(); + + while(1) { + LED_On ((1<<28)); /* Turn on the LED. */ + Delay (100); /* delay 100 Msec */ + LED_Off ((1<<28)); /* Turn off the LED. */ + Delay (100); /* delay 100 Msec */ + } + +} +