2011-09-06 21:05:41 +02:00
|
|
|
/*
|
|
|
|
%atmel_license%
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file cmsis example */
|
|
|
|
|
2011-09-05 22:59:49 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <compiler.h>
|
|
|
|
#include <board.h>
|
|
|
|
#include "conf_board.h"
|
|
|
|
|
2011-09-06 21:05:41 +02:00
|
|
|
//! counts 1ms timeTicks
|
|
|
|
volatile uint32_t dw_ms_ticks = 0;
|
2011-09-05 22:59:49 +02:00
|
|
|
|
2011-09-06 21:05:41 +02:00
|
|
|
/**
|
|
|
|
* \brief SysTick_Handler.
|
|
|
|
*/
|
2011-09-05 22:59:49 +02:00
|
|
|
void SysTick_Handler(void)
|
|
|
|
{
|
2011-09-06 21:05:41 +02:00
|
|
|
// increment counter necessary in delay()
|
|
|
|
dw_ms_ticks++;
|
2011-09-05 22:59:49 +02:00
|
|
|
}
|
|
|
|
|
2011-09-06 21:05:41 +02:00
|
|
|
/**
|
|
|
|
* \brief delays number of tick Systicks (happens every 1 ms)
|
|
|
|
*/
|
|
|
|
__INLINE static void delay_ms(uint32_t dw_dly_ticks)
|
2011-09-05 22:59:49 +02:00
|
|
|
{
|
2011-09-06 21:05:41 +02:00
|
|
|
uint32_t dw_cur_ticks;
|
2011-09-05 22:59:49 +02:00
|
|
|
|
2011-09-06 21:05:41 +02:00
|
|
|
dw_cur_ticks = dw_ms_ticks;
|
|
|
|
while ((dw_ms_ticks - dw_cur_ticks) < dw_dly_ticks);
|
2011-09-05 22:59:49 +02:00
|
|
|
}
|
|
|
|
|
2011-09-06 21:05:41 +02:00
|
|
|
/**
|
|
|
|
* \brief configer LED pins
|
|
|
|
*/
|
|
|
|
__INLINE static void led_config(void)
|
2011-09-05 22:59:49 +02:00
|
|
|
{
|
2011-09-06 21:05:41 +02:00
|
|
|
// Setup LED Pin
|
|
|
|
LED0_PIO->PIO_PER = LED0_MASK;
|
2011-09-05 22:59:49 +02:00
|
|
|
LED0_PIO->PIO_OER = LED0_MASK;
|
|
|
|
LED0_PIO->PIO_PUDR = LED0_MASK;
|
|
|
|
}
|
|
|
|
|
2011-09-06 21:05:41 +02:00
|
|
|
/**
|
|
|
|
* \brief Switch on LED
|
|
|
|
*/
|
|
|
|
__INLINE static void led_on(uint32_t dw_led)
|
2011-09-05 22:59:49 +02:00
|
|
|
{
|
2011-09-06 21:05:41 +02:00
|
|
|
// Turn On LED
|
|
|
|
LED0_PIO->PIO_CODR = dw_led;
|
2011-09-05 22:59:49 +02:00
|
|
|
}
|
|
|
|
|
2011-09-06 21:05:41 +02:00
|
|
|
/**
|
|
|
|
* \brief Switch off LED
|
|
|
|
*/
|
|
|
|
__INLINE static void led_off(uint32_t dw_led)
|
2011-09-05 22:59:49 +02:00
|
|
|
{
|
2011-09-06 21:05:41 +02:00
|
|
|
// Turn Off LED
|
|
|
|
LED0_PIO->PIO_SODR = dw_led;
|
2011-09-05 22:59:49 +02:00
|
|
|
}
|
|
|
|
|
2011-09-06 21:05:41 +02:00
|
|
|
/**
|
|
|
|
* \brief Application entry point.
|
|
|
|
*
|
|
|
|
* \return Unused (ANSI-C compatibility).
|
|
|
|
*/
|
2011-09-05 22:59:49 +02:00
|
|
|
int main(void)
|
|
|
|
{
|
2011-09-06 21:05:41 +02:00
|
|
|
SystemInit();
|
|
|
|
|
|
|
|
WDT->WDT_MR = WDT_MR_WDDIS;
|
|
|
|
|
|
|
|
// Setup SysTick Timer for 1 msec interrupts
|
|
|
|
if (SysTick_Config(SystemCoreClock / 1000)) {
|
|
|
|
// Capture error
|
|
|
|
while (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
led_config();
|
|
|
|
|
|
|
|
// Flash the LED
|
2011-09-05 22:59:49 +02:00
|
|
|
while(1) {
|
2011-09-06 21:05:41 +02:00
|
|
|
// Turn on the LED.
|
|
|
|
led_on (LED0_MASK);
|
|
|
|
// delay 1000 Msec.
|
|
|
|
delay_ms (1000);
|
|
|
|
|
|
|
|
// Turn off the LED.
|
|
|
|
led_off(LED0_MASK);
|
|
|
|
// delay 1000 Msec.
|
|
|
|
delay_ms (1000);
|
2011-09-05 22:59:49 +02:00
|
|
|
}
|
|
|
|
}
|