These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers clock-arch.c Source File

clock-arch.c

00001 #include "clock-arch.h"
00002 #include "LPC17xx.h"
00003 
00004 __IO clock_time_t Ticks;
00005 
00006 #define LED_PIN     (1<<6)
00007 
00008 /* SysTick timer interrupt  handler */
00009 void SysTick_Handler (void)
00010 {
00011     ++Ticks;
00012     if (!(Ticks & 0x07)){
00013         LPC_GPIO2->FIOPIN ^= LED_PIN;
00014     }
00015 }
00016 
00017 /* Timer init */
00018 void clock_init(void)
00019 {
00020     Ticks = 0;
00021 
00022     // NXP: Initialize System tick timer
00023     // Generate interrupt each SYSTICK_PERIOD microsecond
00024     if (SysTick_Config((SystemCoreClock/CLOCK_CONF_SECOND))){
00025         // Capture error
00026         while (1);
00027     }
00028 }
00029 
00030 /* returned The current clock time, measured in system ticks */
00031 clock_time_t clock_time(void)
00032 {
00033   return(Ticks);
00034 }