Use systick, which is built into the ARM core
Signed-off-by: Keith Packard <keithp@keithp.com>
void
ao_led_on(uint16_t colors)
{
- lpc_gpio.pin[LED_PORT] = 0xffffffff;
+ lpc_gpio.pin[LED_PORT] |= colors;
}
void
ao_led_off(uint16_t colors)
{
- lpc_gpio.pin[LED_PORT] = 0;
+ lpc_gpio.pin[LED_PORT] &= ~colors;
}
void
void
ao_led_toggle(uint16_t colors)
{
+ lpc_gpio.pin[LED_PORT] ^= colors;
}
void
}
#endif
-#define SYSTICK_RELOAD ((AO_LPC_CLKOUT / 2) / 100 - 1)
+#define SYSTICK_RELOAD ((AO_LPC_SYSCLK / 2) / 100 - 1)
/* Initialize our 100Hz clock */
void
#include "ao.h"
+struct ao_task demo_task;
+
+static void demo(void) {
+ for (;;) {
+ ao_delay(100);
+ ao_led_toggle(AO_LED_RED);
+ }
+}
+
int
main(void)
{
ao_led_init(LEDS_AVAILABLE);
ao_led_on(AO_LED_RED);
ao_clock_init();
+ ao_timer_init();
+
+ ao_task_init();
+
+ ao_add_task(&demo_task, demo, "demo");
+
+ ao_start_scheduler();
for (;;) {
ao_led_off(AO_LED_RED);
- for (i = 0; i < 100000; i++)
- ao_arch_nop();
+ for (;;)
+ if (ao_tick_count & 1)
+ break;
ao_led_on(AO_LED_RED);
- for (i = 0; i < 100000; i++)
- ao_arch_nop();
+ for (;;)
+ if (!(ao_tick_count & 1))
+ break;
}
}