2016-08-15 14:11:00 +00:00
|
|
|
//
|
|
|
|
// This file is part of the GNU ARM Eclipse distribution.
|
|
|
|
// Copyright (c) 2014 Liviu Ionescu.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "diag/Trace.h"
|
|
|
|
|
|
|
|
#include "Timer.h"
|
|
|
|
#include "BlinkLed.h"
|
|
|
|
|
|
|
|
// Keep the LED on for 2/3 of a second.
|
|
|
|
#define BLINK_ON_TICKS (TIMER_FREQUENCY_HZ * 3 / 4)
|
|
|
|
#define BLINK_OFF_TICKS (TIMER_FREQUENCY_HZ - BLINK_ON_TICKS)
|
|
|
|
|
|
|
|
// Sample pragmas to cope with warnings. Please note the related line at
|
|
|
|
// the end of this function, used to pop the compiler diagnostics status.
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
|
|
|
#pragma GCC diagnostic ignored "-Wmissing-declarations"
|
|
|
|
#pragma GCC diagnostic ignored "-Wreturn-type"
|
|
|
|
|
2016-08-15 19:41:22 +00:00
|
|
|
int main(int argc, char* argv[])
|
2016-08-15 14:11:00 +00:00
|
|
|
{
|
2016-08-15 19:41:22 +00:00
|
|
|
trace_puts("Hello ARM World!");
|
|
|
|
trace_printf("System clock: %u Hz\n", SystemCoreClock);
|
|
|
|
timer_start();
|
|
|
|
blink_led_init();
|
|
|
|
uint32_t seconds = 0;
|
|
|
|
while(1) {
|
|
|
|
blink_led_on();
|
|
|
|
timer_sleep(seconds == 0 ? TIMER_FREQUENCY_HZ : BLINK_ON_TICKS);
|
|
|
|
blink_led_off();
|
|
|
|
timer_sleep(BLINK_OFF_TICKS);
|
|
|
|
++seconds;
|
|
|
|
trace_printf("Second %u\n", seconds);
|
|
|
|
}
|
2016-08-15 14:11:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma GCC diagnostic pop
|