X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fstm-demo%2Fao_demo.c;h=db432c2ae91a6f257a6a02847aa88f02c868e7ff;hb=29f9880f7b09bc135d34bf0dcb221bdede7726b3;hp=ec572fdc204a8a8871046085b91a73ac6f981a50;hpb=b1a43ce313c85cb7f8f16f7f0647d9d4320ba692;p=fw%2Faltos diff --git a/src/stm-demo/ao_demo.c b/src/stm-demo/ao_demo.c index ec572fdc..db432c2a 100644 --- a/src/stm-demo/ao_demo.c +++ b/src/stm-demo/ao_demo.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -153,6 +154,7 @@ ao_temp (void) printf ("temp: %d\n", temp); } +#if 0 static void ao_event(void) { @@ -168,22 +170,41 @@ ao_event(void) } } +#endif + +static uint8_t ao_blinking = 0; + +static void +ao_blink(void) +{ + for (;;) { + while (!ao_blinking) + ao_sleep(&ao_blinking); + while (ao_blinking) { + ao_led_toggle(AO_LED_BLUE|AO_LED_GREEN); + ao_delay(AO_MS_TO_TICKS(500)); + } + } +} + +static struct ao_task ao_blink_task; static void -ao_boot_loader(void) +ao_blink_toggle(void) { - flush(); - ao_boot_reboot((uint32_t *) 0); + ao_blinking = !ao_blinking; + ao_wakeup(&ao_blinking); } + __code struct ao_cmds ao_demo_cmds[] = { { ao_dma_test, "D\0DMA test" }, { ao_spi_write, "W\0SPI write" }, { ao_spi_read, "R\0SPI read" }, { ao_i2c_write, "i\0I2C write" }, { ao_temp, "t\0Show temp" }, - { ao_event, "e\0Monitor event queue" }, - { ao_boot_loader, "L\0Reboot to boot loader" }, + { ao_blink_toggle, "b\0Toggle LED blinking" }, +/* { ao_event, "e\0Monitor event queue" }, */ { 0, NULL } }; @@ -194,23 +215,26 @@ main(void) ao_task_init(); - ao_serial_init(); + ao_led_init(LEDS_AVAILABLE); + ao_led_on(AO_LED_GREEN); + ao_led_off(AO_LED_BLUE); ao_timer_init(); ao_dma_init(); ao_cmd_init(); // ao_lcd_stm_init(); // ao_lcd_font_init(); - ao_spi_init(); - ao_i2c_init(); - ao_exti_init(); +// ao_spi_init(); +// ao_i2c_init(); +// ao_exti_init(); // ao_quadrature_init(); // ao_button_init(); - ao_timer_set_adc_interval(100); +// ao_timer_set_adc_interval(100); - ao_adc_init(); +// ao_adc_init(); ao_usb_init(); + ao_add_task(&ao_blink_task, ao_blink, "blink"); ao_cmd_register(&ao_demo_cmds[0]); ao_start_scheduler();