From 7c04888cf9809e0c73f0813c74e8dd972facde3a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 5 Aug 2018 12:23:22 +0800 Subject: altos: Switch to newlib-nano for libc on arm Stop using pdclib Signed-off-by: Keith Packard --- src/easymega-v1.0/Makefile | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'src/easymega-v1.0') diff --git a/src/easymega-v1.0/Makefile b/src/easymega-v1.0/Makefile index c3b360b4..3344da06 100644 --- a/src/easymega-v1.0/Makefile +++ b/src/easymega-v1.0/Makefile @@ -26,10 +26,8 @@ INC = \ ao_whiten.h \ ao_sample_profile.h \ ao_quaternion.h \ - math.h \ ao_mpu.h \ stm32l.h \ - math.h \ Makefile # @@ -47,21 +45,6 @@ INC = \ #STACK_GUARD=ao_mpu_stm.c #STACK_GUARD_DEF=-DHAS_STACK_GUARD=1 -MATH_SRC=\ - ef_acos.c \ - ef_sqrt.c \ - ef_rem_pio2.c \ - kf_cos.c \ - kf_sin.c \ - kf_rem_pio2.c \ - sf_copysign.c \ - sf_cos.c \ - sf_fabs.c \ - sf_floor.c \ - sf_scalbn.c \ - sf_sin.c \ - ef_log.c - ALTOS_SRC = \ ao_boot_chain.c \ ao_interrupt.c \ @@ -102,7 +85,6 @@ ALTOS_SRC = \ ao_flight.c \ ao_companion.c \ ao_pyro.c \ - $(MATH_SRC) \ $(PROFILE) \ $(SAMPLE_PROFILE) \ $(STACK_GUARD) -- cgit v1.2.3 From cdaa0d7b272505c49017f409b7c0b8e3240608f0 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 11 Sep 2018 10:40:24 -0700 Subject: altos: Eliminate 'pin' field from GPIO functions This was used with the 8051 bit-addressing mode to provide single-instruction access to GPIO pins. Signed-off-by: Keith Packard --- src/attiny/ao_arch_funcs.h | 12 ++++++------ src/avr/ao_arch_funcs.h | 10 +++++----- src/drivers/ao_btm.c | 4 ++-- src/drivers/ao_button.c | 5 ++--- src/drivers/ao_cc1120.c | 2 +- src/drivers/ao_cc1200.c | 2 +- src/drivers/ao_companion.c | 4 +--- src/drivers/ao_mma655x.c | 6 ++---- src/drivers/ao_ms5607.c | 6 +++--- src/drivers/ao_pad.c | 24 ++++++++++++------------ src/drivers/ao_ps2.c | 8 ++++---- src/drivers/ao_rn4678.c | 28 ++++++++++++++-------------- src/drivers/ao_sdcard.c | 4 ++-- src/drivers/ao_trng_send.c | 8 ++++---- src/drivers/ao_watchdog.c | 6 +++--- src/easymega-v1.0/ao_pins.h | 3 --- src/easymini-v1.0/ao_pins.h | 2 -- src/easymini-v2.0/ao_pins.h | 2 -- src/kernel/ao_ignite.c | 10 ++++------ src/kernel/ao_pyro.c | 32 ++++++++++++++++---------------- src/kernel/ao_tracker.c | 2 +- src/lpc/ao_arch_funcs.h | 18 +++++++++--------- src/lpc/ao_boot_pin.c | 2 +- src/lpc/ao_usb_lpc.c | 6 +++--- src/stm/ao_arch_funcs.h | 18 +++++++++--------- src/stm/ao_led.c | 8 ++++---- src/stm/ao_serial_stm.c | 8 ++++---- src/stmf0/ao_arch_funcs.h | 14 +++++++------- src/stmf0/ao_beep_stm.c | 2 +- src/teleballoon-v2.0/ao_pins.h | 3 --- src/telemega-v0.1/ao_pins.h | 3 --- src/telemega-v1.0/ao_pins.h | 3 --- src/telemega-v2.0/ao_pins.h | 3 --- src/telemega-v3.0/ao_pins.h | 3 --- src/telemetrum-v2.0/ao_pins.h | 3 --- src/telemetrum-v3.0/ao_pins.h | 3 --- src/telemini-v3.0/ao_pins.h | 2 -- src/telemini-v3.0/ao_telemini.c | 2 +- 38 files changed, 122 insertions(+), 159 deletions(-) (limited to 'src/easymega-v1.0') diff --git a/src/attiny/ao_arch_funcs.h b/src/attiny/ao_arch_funcs.h index 35901154..69b259d9 100644 --- a/src/attiny/ao_arch_funcs.h +++ b/src/attiny/ao_arch_funcs.h @@ -28,21 +28,21 @@ (reg) |= (mask); \ } while (0) -#define ao_spi_get_bit(reg,bit,pin,bus,speed) ao_spi_get_mask(reg,(1<<(bit)),bus,speed) +#define ao_spi_get_bit(reg,bit,bus,speed) ao_spi_get_mask(reg,(1<<(bit)),bus,speed) -#define ao_spi_put_bit(reg,bit,pin,bus) ao_spi_put_mask(reg,(1<<(bit)),bus) +#define ao_spi_put_bit(reg,bit,bus) ao_spi_put_mask(reg,(1<<(bit)),bus) #define ao_gpio_token_paster(x,y) x ## y #define ao_gpio_token_evaluator(x,y) ao_gpio_token_paster(x,y) -#define ao_gpio_set(port, bit, pin, v) do { \ +#define ao_gpio_set(port, bit, v) do { \ if (v) \ PORTB |= (1 << bit); \ else \ PORTB &= ~(1 << bit); \ } while (0) -#define ao_gpio_get(port, bit, pin) ((PORTB >> (bit)) & 1) +#define ao_gpio_get(port, bit) ((PORTB >> (bit)) & 1) /* * The SPI mutex must be held to call either of these @@ -50,8 +50,8 @@ * from chip select low to chip select high */ -#define ao_enable_output(port, bit, pin, v) do { \ - ao_gpio_set(port, bit, pin, v); \ +#define ao_enable_output(port, bit, v) do { \ + ao_gpio_set(port, bit, v); \ ao_gpio_token_evaluator(DDR,port) |= (1 << bit); \ } while (0) diff --git a/src/avr/ao_arch_funcs.h b/src/avr/ao_arch_funcs.h index dc248660..f2a58af0 100644 --- a/src/avr/ao_arch_funcs.h +++ b/src/avr/ao_arch_funcs.h @@ -32,12 +32,12 @@ extern uint8_t ao_spi_mutex; ao_mutex_put(&ao_spi_mutex); \ } while (0) -#define ao_spi_get_bit(reg,bit,pin,bus,speed) do { \ +#define ao_spi_get_bit(reg,bit,bus,speed) do { \ ao_mutex_get(&ao_spi_mutex); \ (pin) = 0; \ } while (0) -#define ao_spi_put_bit(reg,bit,pin,bus) do { \ +#define ao_spi_put_bit(reg,bit,bus) do { \ (pin) = 1; \ ao_mutex_put(&ao_spi_mutex); \ } while (0) @@ -46,7 +46,7 @@ extern uint8_t ao_spi_mutex; #define ao_gpio_token_paster(x,y) x ## y #define ao_gpio_token_evaluator(x,y) ao_gpio_token_paster(x,y) -#define ao_gpio_set(port, bit, pin, v) do { \ +#define ao_gpio_set(port, bit, v) do { \ if (v) \ (ao_gpio_token_evaluator(PORT,port)) |= (1 << bit); \ else \ @@ -59,8 +59,8 @@ extern uint8_t ao_spi_mutex; * from chip select low to chip select high */ -#define ao_enable_output(port, bit, pin, v) do { \ - ao_gpio_set(port, bit, pin, v); \ +#define ao_enable_output(port, bit, v) do { \ + ao_gpio_set(port, bit, v); \ ao_gpio_token_evaluator(DDR,port) |= (1 << bit); \ } while (0) diff --git a/src/drivers/ao_btm.c b/src/drivers/ao_btm.c index 2930d00e..04bf4138 100644 --- a/src/drivers/ao_btm.c +++ b/src/drivers/ao_btm.c @@ -347,7 +347,7 @@ ao_btm_check_link() ); #else ao_arch_block_interrupts(); - if (ao_gpio_get(AO_BTM_INT_PORT, AO_BTM_INT_PIN, AO_BTM_INT) == 0) { + if (ao_gpio_get(AO_BTM_INT_PORT, AO_BTM_INT_PIN) == 0) { ao_btm_connected = 1; } else { ao_btm_connected = 0; @@ -455,7 +455,7 @@ ao_btm_init (void) ao_serial_btm_set_speed(AO_SERIAL_SPEED_19200); #ifdef AO_BTM_RESET_PORT - ao_enable_output(AO_BTM_RESET_PORT,AO_BTM_RESET_PIN,AO_BTM_RESET,0); + ao_enable_output(AO_BTM_RESET_PORT,AO_BTM_RESET_PIN,0); #endif #ifdef AO_BTM_INT_PORT diff --git a/src/drivers/ao_button.c b/src/drivers/ao_button.c index f6a9676b..c8103e88 100644 --- a/src/drivers/ao_button.c +++ b/src/drivers/ao_button.c @@ -37,7 +37,6 @@ static struct ao_button_state ao_button_state[AO_BUTTON_COUNT]; #define port(q) AO_BUTTON_ ## q ## _PORT #define bit(q) AO_BUTTON_ ## q -#define pin(q) AO_BUTTON_ ## q ## _PIN #ifndef AO_BUTTON_INVERTED #define AO_BUTTON_INVERTED 1 @@ -45,9 +44,9 @@ static struct ao_button_state ao_button_state[AO_BUTTON_COUNT]; #if AO_BUTTON_INVERTED /* pins are inverted */ -#define ao_button_value(b) !ao_gpio_get(port(b), bit(b), pin(b)) +#define ao_button_value(b) !ao_gpio_get(port(b), bit(b)) #else -#define ao_button_value(b) ao_gpio_get(port(b), bit(b), pin(b)) +#define ao_button_value(b) ao_gpio_get(port(b), bit(b)) #endif static uint8_t diff --git a/src/drivers/ao_cc1120.c b/src/drivers/ao_cc1120.c index aea0a3fe..b1a13778 100644 --- a/src/drivers/ao_cc1120.c +++ b/src/drivers/ao_cc1120.c @@ -208,7 +208,7 @@ ao_radio_fifo_write_fixed(uint8_t data, uint8_t len) static uint8_t ao_radio_int_pin(void) { - return ao_gpio_get(AO_CC1120_INT_PORT, AO_CC1120_INT_PIN, AO_CC1120_INT); + return ao_gpio_get(AO_CC1120_INT_PORT, AO_CC1120_INT_PIN); } #if CC1120_DEBUG diff --git a/src/drivers/ao_cc1200.c b/src/drivers/ao_cc1200.c index 45f5711e..105e0d50 100644 --- a/src/drivers/ao_cc1200.c +++ b/src/drivers/ao_cc1200.c @@ -192,7 +192,7 @@ ao_radio_fifo_write_fixed(uint8_t data, uint8_t len) static uint8_t ao_radio_int_pin(void) { - return ao_gpio_get(AO_CC1200_INT_PORT, AO_CC1200_INT_PIN, AO_CC1200_INT); + return ao_gpio_get(AO_CC1200_INT_PORT, AO_CC1200_INT_PIN); } static uint8_t diff --git a/src/drivers/ao_companion.c b/src/drivers/ao_companion.c index 3967090b..44868fb6 100644 --- a/src/drivers/ao_companion.c +++ b/src/drivers/ao_companion.c @@ -31,7 +31,6 @@ #define COMPANION_SELECT() do { \ ao_spi_get_bit(AO_COMPANION_CS_PORT, \ AO_COMPANION_CS_PIN, \ - AO_COMPANION_CS, \ AO_COMPANION_SPI_BUS, \ AO_SPI_SPEED_200kHz); \ } while (0) @@ -39,7 +38,6 @@ #define COMPANION_DESELECT() do { \ ao_spi_put_bit(AO_COMPANION_CS_PORT, \ AO_COMPANION_CS_PIN, \ - AO_COMPANION_CS, \ AO_COMPANION_SPI_BUS); \ } while (0) @@ -144,7 +142,7 @@ static struct ao_task ao_companion_task; void ao_companion_init(void) { - ao_enable_output(AO_COMPANION_CS_PORT, AO_COMPANION_CS_PIN, AO_COMPANION_CS, 1); + ao_enable_output(AO_COMPANION_CS_PORT, AO_COMPANION_CS_PIN, 1); ao_cmd_register(&ao_companion_cmds[0]); ao_add_task(&ao_companion_task, ao_companion, "companion"); } diff --git a/src/drivers/ao_mma655x.c b/src/drivers/ao_mma655x.c index a48c1db2..e8eeea6e 100644 --- a/src/drivers/ao_mma655x.c +++ b/src/drivers/ao_mma655x.c @@ -34,7 +34,6 @@ static void ao_mma655x_start(void) { ao_spi_get_bit(AO_MMA655X_CS_PORT, AO_MMA655X_CS_PIN, - AO_MMA655X_CS, AO_MMA655X_SPI_INDEX, AO_SPI_SPEED_FAST); } @@ -43,19 +42,18 @@ static void ao_mma655x_stop(void) { ao_spi_put_bit(AO_MMA655X_CS_PORT, AO_MMA655X_CS_PIN, - AO_MMA655X_CS, AO_MMA655X_SPI_INDEX); } static void ao_mma655x_restart(void) { uint8_t i; - ao_gpio_set(AO_MMA655X_CS_PORT, AO_MMA655X_CS_PIN, AO_MMA655X_CS, 1); + ao_gpio_set(AO_MMA655X_CS_PORT, AO_MMA655X_CS_PIN, 1); /* Emperical testing on STM32L151 at 32MHz for this delay amount */ for (i = 0; i < 10; i++) ao_arch_nop(); - ao_gpio_set(AO_MMA655X_CS_PORT, AO_MMA655X_CS_PIN, AO_MMA655X_CS, 0); + ao_gpio_set(AO_MMA655X_CS_PORT, AO_MMA655X_CS_PIN, 0); } static uint8_t diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c index a468fee3..a00d54c8 100644 --- a/src/drivers/ao_ms5607.c +++ b/src/drivers/ao_ms5607.c @@ -31,12 +31,12 @@ static uint8_t ms5607_configured; static void ao_ms5607_start(void) { - ao_spi_get_bit(AO_MS5607_CS_PORT, AO_MS5607_CS_PIN, AO_MS5607_CS, AO_MS5607_SPI_INDEX, AO_MS5607_SPI_SPEED); + ao_spi_get_bit(AO_MS5607_CS_PORT, AO_MS5607_CS_PIN, AO_MS5607_SPI_INDEX, AO_MS5607_SPI_SPEED); } static void ao_ms5607_stop(void) { - ao_spi_put_bit(AO_MS5607_CS_PORT, AO_MS5607_CS_PIN, AO_MS5607_CS, AO_MS5607_SPI_INDEX); + ao_spi_put_bit(AO_MS5607_CS_PORT, AO_MS5607_CS_PIN, AO_MS5607_SPI_INDEX); } static void @@ -164,7 +164,7 @@ ao_ms5607_get_sample(uint8_t cmd) { ao_spi_put(AO_MS5607_SPI_INDEX); #endif ao_arch_block_interrupts(); - while (!ao_gpio_get(AO_MS5607_MISO_PORT, AO_MS5607_MISO_PIN, AO_MS5607_MISO) && + while (!ao_gpio_get(AO_MS5607_MISO_PORT, AO_MS5607_MISO_PIN) && !ao_ms5607_done) ao_sleep((void *) &ao_ms5607_done); ao_arch_release_interrupts(); diff --git a/src/drivers/ao_pad.c b/src/drivers/ao_pad.c index c08798ac..85691f5c 100644 --- a/src/drivers/ao_pad.c +++ b/src/drivers/ao_pad.c @@ -50,7 +50,7 @@ static void ao_siren(uint8_t v) { #ifdef AO_SIREN - ao_gpio_set(AO_SIREN_PORT, AO_SIREN_PIN, AO_SIREN, v); + ao_gpio_set(AO_SIREN_PORT, AO_SIREN_PIN, v); #else #if HAS_BEEP ao_beep(v ? AO_BEEP_MID : 0); @@ -64,7 +64,7 @@ static void ao_strobe(uint8_t v) { #ifdef AO_STROBE - ao_gpio_set(AO_STROBE_PORT, AO_STROBE_PIN, AO_STROBE, v); + ao_gpio_set(AO_STROBE_PORT, AO_STROBE_PIN, v); #else (void) v; #endif @@ -589,34 +589,34 @@ ao_pad_init(void) } #endif #if AO_PAD_NUM > 0 - ao_enable_output(AO_PAD_0_PORT, AO_PAD_PIN_0, AO_PAD_0, 0); + ao_enable_output(AO_PAD_0_PORT, AO_PAD_PIN_0, 0); #endif #if AO_PAD_NUM > 1 - ao_enable_output(AO_PAD_1_PORT, AO_PAD_PIN_1, AO_PAD_1, 0); + ao_enable_output(AO_PAD_1_PORT, AO_PAD_PIN_1, 0); #endif #if AO_PAD_NUM > 2 - ao_enable_output(AO_PAD_2_PORT, AO_PAD_PIN_2, AO_PAD_2, 0); + ao_enable_output(AO_PAD_2_PORT, AO_PAD_PIN_2, 0); #endif #if AO_PAD_NUM > 3 - ao_enable_output(AO_PAD_3_PORT, AO_PAD_PIN_3, AO_PAD_3, 0); + ao_enable_output(AO_PAD_3_PORT, AO_PAD_PIN_3, 0); #endif #if AO_PAD_NUM > 4 - ao_enable_output(AO_PAD_4_PORT, AO_PAD_PIN_4, AO_PAD_4, 0); + ao_enable_output(AO_PAD_4_PORT, AO_PAD_PIN_4, 0); #endif #if AO_PAD_NUM > 5 - ao_enable_output(AO_PAD_5_PORT, AO_PAD_PIN_5, AO_PAD_5, 0); + ao_enable_output(AO_PAD_5_PORT, AO_PAD_PIN_5, 0); #endif #if AO_PAD_NUM > 5 - ao_enable_output(AO_PAD_6_PORT, AO_PAD_PIN_6, AO_PAD_6, 0); + ao_enable_output(AO_PAD_6_PORT, AO_PAD_PIN_6, 0); #endif #if AO_PAD_NUM > 7 - ao_enable_output(AO_PAD_7_PORT, AO_PAD_PIN_7, AO_PAD_7, 0); + ao_enable_output(AO_PAD_7_PORT, AO_PAD_PIN_7, 0); #endif #ifdef AO_STROBE - ao_enable_output(AO_STROBE_PORT, AO_STROBE_PIN, AO_STROBE, 0); + ao_enable_output(AO_STROBE_PORT, AO_STROBE_PIN, 0); #endif #ifdef AO_SIREN - ao_enable_output(AO_SIREN_PORT, AO_SIREN_PIN, AO_SIREN, 0); + ao_enable_output(AO_SIREN_PORT, AO_SIREN_PIN, 0); #endif ao_cmd_register(&ao_pad_cmds[0]); ao_add_task(&ao_pad_task, ao_pad, "pad listener"); diff --git a/src/drivers/ao_ps2.c b/src/drivers/ao_ps2.c index 29eecea8..c7520b3a 100644 --- a/src/drivers/ao_ps2.c +++ b/src/drivers/ao_ps2.c @@ -91,11 +91,11 @@ ao_ps2_put(uint8_t c) ao_arch_release_interrupts(); /* pull the clock pin down */ - ao_enable_output(AO_PS2_CLOCK_PORT, AO_PS2_CLOCK_BIT, AO_PS2_CLOCK_PIN, 0); + ao_enable_output(AO_PS2_CLOCK_PORT, AO_PS2_CLOCK_BIT, 0); ao_delay(0); /* pull the data pin down for the start bit */ - ao_enable_output(AO_PS2_DATA_PORT, AO_PS2_DATA_BIT, AO_PS2_DATA_PIN, 0); + ao_enable_output(AO_PS2_DATA_PORT, AO_PS2_DATA_BIT, 0); ao_delay(0); /* switch back to input mode for the interrupt to work */ @@ -369,7 +369,7 @@ ao_ps2_isr(void) uint8_t bit; if (ao_ps2_tx_count) { - ao_gpio_set(AO_PS2_DATA_PORT, AO_PS2_DATA_BIT, AO_PS2_DATA_PIN, ao_ps2_tx&1); + ao_gpio_set(AO_PS2_DATA_PORT, AO_PS2_DATA_BIT, ao_ps2_tx&1); ao_ps2_tx >>= 1; ao_ps2_tx_count--; if (!ao_ps2_tx_count) { @@ -383,7 +383,7 @@ ao_ps2_isr(void) ao_ps2_count = 0; ao_ps2_tick = ao_tick_count; - bit = ao_gpio_get(AO_PS2_DATA_PORT, AO_PS2_DATA_BIT, AO_PS2_DATA_PIN); + bit = ao_gpio_get(AO_PS2_DATA_PORT, AO_PS2_DATA_BIT); if (ao_ps2_count == 0) { /* check for start bit, ignore if not zero */ if (bit) diff --git a/src/drivers/ao_rn4678.c b/src/drivers/ao_rn4678.c index 98dc35b5..4ace4b78 100644 --- a/src/drivers/ao_rn4678.c +++ b/src/drivers/ao_rn4678.c @@ -335,7 +335,7 @@ ao_rn_get_name(char *name, int len) static void ao_rn_check_link(void) { - ao_rn_connected = 1 - ao_gpio_get(AO_RN_CONNECTED_PORT, AO_RN_CONNECTED_PIN, foo); + ao_rn_connected = 1 - ao_gpio_get(AO_RN_CONNECTED_PORT, AO_RN_CONNECTED_PIN); } static void @@ -384,17 +384,17 @@ ao_rn(void) ao_rn_dbg("ao_rn top\n"); /* Select CMD mode after the device gets out of reset */ - ao_gpio_set(AO_RN_CMD_PORT, AO_RN_CMD_PIN, foo, AO_RN_CMD_CMD); + ao_gpio_set(AO_RN_CMD_PORT, AO_RN_CMD_PIN, AO_RN_CMD_CMD); for (i = 0; i < 3; i++) { ao_rn_dbg("reset device\n"); - ao_gpio_set(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, foo, 0); + ao_gpio_set(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, 0); ao_delay(AO_MS_TO_TICKS(100)); /* Reboot the RN4678 and wait for it to start talking */ ao_rn_drain(); - ao_gpio_set(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, foo, 1); + ao_gpio_set(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, 1); status = ao_rn_wait_for(AO_RN_REBOOT_TIMEOUT, AO_RN_REBOOT_MSG); if (status != AO_RN_OK) { ao_rn_dbg("reboot failed\n"); @@ -468,7 +468,7 @@ ao_rn(void) if (status != AO_RN_OK) ao_bt_panic(4); - ao_gpio_set(AO_RN_CMD_PORT, AO_RN_CMD_PIN, foo, AO_RN_CMD_DATA); + ao_gpio_set(AO_RN_CMD_PORT, AO_RN_CMD_PIN, AO_RN_CMD_DATA); /* Wait for the hardware to finish sending messages, then clear the queue */ ao_delay(AO_MS_TO_TICKS(200)); @@ -530,16 +530,16 @@ ao_rn_factory(void) */ /* Select our target output pin */ - ao_enable_output(AO_RN_P3_1_PORT, AO_RN_P3_1_PIN, foo, v); + ao_enable_output(AO_RN_P3_1_PORT, AO_RN_P3_1_PIN, v); /* Turn off the BT device using the SW_BTN pin */ printf("Power down BT\n"); flush(); - ao_gpio_set(AO_RN_SW_BTN_PORT, AO_RN_SW_BTN_PIN, foo, 0); + ao_gpio_set(AO_RN_SW_BTN_PORT, AO_RN_SW_BTN_PIN, 0); ao_delay(AO_MS_TO_TICKS(1000)); /* And turn it back on */ printf("Power up BT\n"); flush(); - ao_gpio_set(AO_RN_SW_BTN_PORT, AO_RN_SW_BTN_PIN, foo, 1); + ao_gpio_set(AO_RN_SW_BTN_PORT, AO_RN_SW_BTN_PIN, 1); /* Right after power on, poke P3_1 five times to force a * factory reset @@ -547,7 +547,7 @@ ao_rn_factory(void) for (i = 0; i < 20; i++) { v = 1-v; ao_delay(AO_MS_TO_TICKS(50)); - ao_gpio_set(AO_RN_P3_1_PORT, AO_RN_P3_1_PIN, foo, v); + ao_gpio_set(AO_RN_P3_1_PORT, AO_RN_P3_1_PIN, v); ao_led_toggle(AO_BT_LED); } @@ -556,9 +556,9 @@ ao_rn_factory(void) printf("Reboot BT\n"); flush(); ao_delay(AO_MS_TO_TICKS(100)); - ao_gpio_set(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, foo, 0); + ao_gpio_set(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, 0); ao_delay(AO_MS_TO_TICKS(100)); - ao_gpio_set(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, foo, 1); + ao_gpio_set(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, 1); } #if AO_RN_DEBUG @@ -588,13 +588,13 @@ ao_rn4678_init(void) ao_serial_rn_set_speed(AO_SERIAL_SPEED_115200); /* Reset line */ - ao_enable_output(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, foo, 0); + ao_enable_output(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, 0); /* SW_BTN */ - ao_enable_output(AO_RN_SW_BTN_PORT, AO_RN_SW_BTN_PIN, foo, 1); + ao_enable_output(AO_RN_SW_BTN_PORT, AO_RN_SW_BTN_PIN, 1); /* P3_7 command/data selector */ - ao_enable_output(AO_RN_CMD_PORT, AO_RN_CMD_PIN, foo, AO_RN_CMD_CMD); + ao_enable_output(AO_RN_CMD_PORT, AO_RN_CMD_PIN, AO_RN_CMD_CMD); ao_enable_input(AO_RN_CONNECTED_PORT, AO_RN_CONNECTED_PIN, AO_EXTI_MODE_PULL_NONE); ao_exti_setup(AO_RN_CONNECTED_PORT, AO_RN_CONNECTED_PIN, diff --git a/src/drivers/ao_sdcard.c b/src/drivers/ao_sdcard.c index 45454000..9d36c397 100644 --- a/src/drivers/ao_sdcard.c +++ b/src/drivers/ao_sdcard.c @@ -34,8 +34,8 @@ extern uint8_t ao_radio_mutex; #define ao_sdcard_send_fixed(d,l) ao_spi_send_fixed((d), (l), AO_SDCARD_SPI_BUS) #define ao_sdcard_send(d,l) ao_spi_send((d), (l), AO_SDCARD_SPI_BUS) #define ao_sdcard_recv(d,l) ao_spi_recv((d), (l), AO_SDCARD_SPI_BUS) -#define ao_sdcard_select() ao_gpio_set(AO_SDCARD_SPI_CS_PORT,AO_SDCARD_SPI_CS_PIN,AO_SDCARD_SPI_CS,0) -#define ao_sdcard_deselect() ao_gpio_set(AO_SDCARD_SPI_CS_PORT,AO_SDCARD_SPI_CS_PIN,AO_SDCARD_SPI_CS,1) +#define ao_sdcard_select() ao_gpio_set(AO_SDCARD_SPI_CS_PORT,AO_SDCARD_SPI_CS_PIN,0) +#define ao_sdcard_deselect() ao_gpio_set(AO_SDCARD_SPI_CS_PORT,AO_SDCARD_SPI_CS_PIN,1) /* Include SD card commands */ #ifndef SDCARD_DEBUG diff --git a/src/drivers/ao_trng_send.c b/src/drivers/ao_trng_send.c index e8df4cea..adeed590 100644 --- a/src/drivers/ao_trng_send.c +++ b/src/drivers/ao_trng_send.c @@ -140,7 +140,7 @@ ao_trng_send(void) usb_buf_id = ao_usb_alloc(buffer); #ifdef AO_TRNG_ENABLE_PORT - ao_gpio_set(AO_TRNG_ENABLE_PORT, AO_TRNG_ENABLE_BIT, AO_TRNG_ENABLE_PIN, 1); + ao_gpio_set(AO_TRNG_ENABLE_PORT, AO_TRNG_ENABLE_BIT, 1); #endif trng_power_time = ao_time(); @@ -211,7 +211,7 @@ static void ao_trng_suspend(void *arg) { (void) arg; #ifdef AO_TRNG_ENABLE_PORT - ao_gpio_set(AO_TRNG_ENABLE_PORT, AO_TRNG_ENABLE_BIT, AO_TRNG_ENABLE_PIN, 0); + ao_gpio_set(AO_TRNG_ENABLE_PORT, AO_TRNG_ENABLE_BIT, 0); #endif trng_running = false; } @@ -220,7 +220,7 @@ static void ao_trng_resume(void *arg) { (void) arg; #ifdef AO_TRNG_ENABLE_PORT - ao_gpio_set(AO_TRNG_ENABLE_PORT, AO_TRNG_ENABLE_BIT, AO_TRNG_ENABLE_PIN, 1); + ao_gpio_set(AO_TRNG_ENABLE_PORT, AO_TRNG_ENABLE_BIT, 1); #endif trng_power_time = ao_time(); } @@ -236,7 +236,7 @@ void ao_trng_send_init(void) { #ifdef AO_TRNG_ENABLE_PORT - ao_enable_output(AO_TRNG_ENABLE_PORT, AO_TRNG_ENABLE_BIT, AO_TRNG_ENABLE_PIN, 0); + ao_enable_output(AO_TRNG_ENABLE_PORT, AO_TRNG_ENABLE_BIT, 0); ao_power_register(&ao_trng_power); #endif ao_enable_input(AO_RAW_PORT, AO_RAW_BIT, AO_EXTI_MODE_PULL_UP); diff --git a/src/drivers/ao_watchdog.c b/src/drivers/ao_watchdog.c index 4d774c3a..612496bc 100644 --- a/src/drivers/ao_watchdog.c +++ b/src/drivers/ao_watchdog.c @@ -28,9 +28,9 @@ ao_watchdog(void) ao_sleep(&ao_watchdog_enabled); while (ao_watchdog_enabled) { ao_delay(AO_WATCHDOG_INTERVAL); - ao_gpio_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG_PIN, 1); + ao_gpio_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, 1); ao_delay(1); - ao_gpio_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG_PIN, 0); + ao_gpio_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, 0); } } } @@ -56,7 +56,7 @@ static struct ao_task watchdog_task; void ao_watchdog_init(void) { - ao_enable_output(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG, 0); + ao_enable_output(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, 0); ao_cmd_register(&ao_watchdog_cmds[0]); ao_add_task(&watchdog_task, ao_watchdog, "watchdog"); } diff --git a/src/easymega-v1.0/ao_pins.h b/src/easymega-v1.0/ao_pins.h index b8016478..e7382e4b 100644 --- a/src/easymega-v1.0/ao_pins.h +++ b/src/easymega-v1.0/ao_pins.h @@ -165,9 +165,6 @@ /* Number of general purpose pyro channels available */ #define AO_PYRO_NUM 4 -#define AO_IGNITER_SET_DROGUE(v) stm_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, v) -#define AO_IGNITER_SET_MAIN(v) stm_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, v) - /* * ADC */ diff --git a/src/easymini-v1.0/ao_pins.h b/src/easymini-v1.0/ao_pins.h index 45c6891d..201b913e 100644 --- a/src/easymini-v1.0/ao_pins.h +++ b/src/easymini-v1.0/ao_pins.h @@ -123,11 +123,9 @@ struct ao_adc { #define AO_IGNITER_DROGUE_PORT 0 #define AO_IGNITER_DROGUE_PIN 2 -#define AO_IGNITER_SET_DROGUE(v) ao_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, AO_IGNITER_DROGUE, v) #define AO_IGNITER_MAIN_PORT 0 #define AO_IGNITER_MAIN_PIN 3 -#define AO_IGNITER_SET_MAIN(v) ao_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, AO_IGNITER_MAIN, v) #define AO_SENSE_DROGUE(p) ((p)->adc.sense_a) #define AO_SENSE_MAIN(p) ((p)->adc.sense_m) diff --git a/src/easymini-v2.0/ao_pins.h b/src/easymini-v2.0/ao_pins.h index 47eb577e..38d46310 100644 --- a/src/easymini-v2.0/ao_pins.h +++ b/src/easymini-v2.0/ao_pins.h @@ -132,11 +132,9 @@ struct ao_adc { #define AO_IGNITER_DROGUE_PORT (&stm_gpioa) #define AO_IGNITER_DROGUE_PIN 3 -#define AO_IGNITER_SET_DROGUE(v) ao_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, AO_IGNITER_DROGUE, v) #define AO_IGNITER_MAIN_PORT (&stm_gpiob) #define AO_IGNITER_MAIN_PIN 7 -#define AO_IGNITER_SET_MAIN(v) ao_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, AO_IGNITER_MAIN, v) #define AO_SENSE_DROGUE(p) ((p)->adc.sense_a) #define AO_SENSE_MAIN(p) ((p)->adc.sense_m) diff --git a/src/kernel/ao_ignite.c b/src/kernel/ao_ignite.c index 5f41c552..a6ff9979 100644 --- a/src/kernel/ao_ignite.c +++ b/src/kernel/ao_ignite.c @@ -72,10 +72,8 @@ ao_igniter_status(enum ao_igniter igniter) return ao_igniter_unknown; } -#ifndef AO_IGNITER_SET_DROGUE -#define AO_IGNITER_SET_DROGUE(v) AO_IGNITER_DROGUE = (v) -#define AO_IGNITER_SET_MAIN(v) AO_IGNITER_MAIN = (v) -#endif +#define AO_IGNITER_SET_DROGUE(v) ao_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, v) +#define AO_IGNITER_SET_MAIN(v) ao_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, v) #ifndef AO_IGNITER_FIRE_TIME #define AO_IGNITER_FIRE_TIME AO_MS_TO_TICKS(50) @@ -226,8 +224,8 @@ struct ao_task ao_igniter_task; void ao_ignite_set_pins(void) { - ao_enable_output(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, AO_IGNITER_DROGUE, 0); - ao_enable_output(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, AO_IGNITER_MAIN, 0); + ao_enable_output(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, 0); + ao_enable_output(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, 0); } #endif diff --git a/src/kernel/ao_pyro.c b/src/kernel/ao_pyro.c index c01c9512..30d1518f 100644 --- a/src/kernel/ao_pyro.c +++ b/src/kernel/ao_pyro.c @@ -216,28 +216,28 @@ ao_pyro_pin_set(uint8_t p, uint8_t v) { switch (p) { #if AO_PYRO_NUM > 0 - case 0: ao_gpio_set(AO_PYRO_PORT_0, AO_PYRO_PIN_0, AO_PYRO_0, v); break; + case 0: ao_gpio_set(AO_PYRO_PORT_0, AO_PYRO_PIN_0, v); break; #endif #if AO_PYRO_NUM > 1 - case 1: ao_gpio_set(AO_PYRO_PORT_1, AO_PYRO_PIN_1, AO_PYRO_1, v); break; + case 1: ao_gpio_set(AO_PYRO_PORT_1, AO_PYRO_PIN_1, v); break; #endif #if AO_PYRO_NUM > 2 - case 2: ao_gpio_set(AO_PYRO_PORT_2, AO_PYRO_PIN_2, AO_PYRO_2, v); break; + case 2: ao_gpio_set(AO_PYRO_PORT_2, AO_PYRO_PIN_2, v); break; #endif #if AO_PYRO_NUM > 3 - case 3: ao_gpio_set(AO_PYRO_PORT_3, AO_PYRO_PIN_3, AO_PYRO_3, v); break; + case 3: ao_gpio_set(AO_PYRO_PORT_3, AO_PYRO_PIN_3, v); break; #endif #if AO_PYRO_NUM > 4 - case 4: ao_gpio_set(AO_PYRO_PORT_4, AO_PYRO_PIN_4, AO_PYRO_4, v); break; + case 4: ao_gpio_set(AO_PYRO_PORT_4, AO_PYRO_PIN_4, v); break; #endif #if AO_PYRO_NUM > 5 - case 5: ao_gpio_set(AO_PYRO_PORT_5, AO_PYRO_PIN_5, AO_PYRO_5, v); break; + case 5: ao_gpio_set(AO_PYRO_PORT_5, AO_PYRO_PIN_5, v); break; #endif #if AO_PYRO_NUM > 6 - case 6: ao_gpio_set(AO_PYRO_PORT_6, AO_PYRO_PIN_6, AO_PYRO_6, v); break; + case 6: ao_gpio_set(AO_PYRO_PORT_6, AO_PYRO_PIN_6, v); break; #endif #if AO_PYRO_NUM > 7 - case 7: ao_gpio_set(AO_PYRO_PORT_7, AO_PYRO_PIN_7, AO_PYRO_7, v); break; + case 7: ao_gpio_set(AO_PYRO_PORT_7, AO_PYRO_PIN_7, v); break; #endif default: break; } @@ -555,28 +555,28 @@ void ao_pyro_init(void) { #if AO_PYRO_NUM > 0 - ao_enable_output(AO_PYRO_PORT_0, AO_PYRO_PIN_0, AO_PYRO_0, 0); + ao_enable_output(AO_PYRO_PORT_0, AO_PYRO_PIN_0, 0); #endif #if AO_PYRO_NUM > 1 - ao_enable_output(AO_PYRO_PORT_1, AO_PYRO_PIN_1, AO_PYRO_1, 0); + ao_enable_output(AO_PYRO_PORT_1, AO_PYRO_PIN_1, 0); #endif #if AO_PYRO_NUM > 2 - ao_enable_output(AO_PYRO_PORT_2, AO_PYRO_PIN_2, AO_PYRO_2, 0); + ao_enable_output(AO_PYRO_PORT_2, AO_PYRO_PIN_2, 0); #endif #if AO_PYRO_NUM > 3 - ao_enable_output(AO_PYRO_PORT_3, AO_PYRO_PIN_3, AO_PYRO_3, 0); + ao_enable_output(AO_PYRO_PORT_3, AO_PYRO_PIN_3, 0); #endif #if AO_PYRO_NUM > 4 - ao_enable_output(AO_PYRO_PORT_4, AO_PYRO_PIN_4, AO_PYRO_4, 0); + ao_enable_output(AO_PYRO_PORT_4, AO_PYRO_PIN_4, 0); #endif #if AO_PYRO_NUM > 5 - ao_enable_output(AO_PYRO_PORT_5, AO_PYRO_PIN_5, AO_PYRO_5, 0); + ao_enable_output(AO_PYRO_PORT_5, AO_PYRO_PIN_5, 0); #endif #if AO_PYRO_NUM > 6 - ao_enable_output(AO_PYRO_PORT_6, AO_PYRO_PIN_6, AO_PYRO_6, 0); + ao_enable_output(AO_PYRO_PORT_6, AO_PYRO_PIN_6, 0); #endif #if AO_PYRO_NUM > 7 - ao_enable_output(AO_PYRO_PORT_7, AO_PYRO_PIN_7, AO_PYRO_7, 0); + ao_enable_output(AO_PYRO_PORT_7, AO_PYRO_PIN_7, 0); #endif ao_add_task(&ao_pyro_task, ao_pyro, "pyro"); } diff --git a/src/kernel/ao_tracker.c b/src/kernel/ao_tracker.c index f79bd18a..1454c17c 100644 --- a/src/kernel/ao_tracker.c +++ b/src/kernel/ao_tracker.c @@ -30,7 +30,7 @@ static uint8_t ao_tracker_force_telem; static inline uint8_t ao_usb_connected(void) { - return ao_gpio_get(AO_USB_CONNECT_PORT, AO_USB_CONNECT_PIN, AO_USB_CONNECT) != 0; + return ao_gpio_get(AO_USB_CONNECT_PORT, AO_USB_CONNECT_PIN) != 0; } #else #define ao_usb_connected() 1 diff --git a/src/lpc/ao_arch_funcs.h b/src/lpc/ao_arch_funcs.h index 15106dea..0454b38b 100644 --- a/src/lpc/ao_arch_funcs.h +++ b/src/lpc/ao_arch_funcs.h @@ -19,17 +19,17 @@ #ifndef _AO_ARCH_FUNCS_H_ #define _AO_ARCH_FUNCS_H_ -#define ao_spi_get_bit(reg,bit,pin,bus,speed) ao_spi_get_mask(reg,(1<bsrr = (colors & ao_led_enable); @@ -105,7 +105,7 @@ ao_led_off(AO_LED_TYPE colors) AO_LED_TYPE i; for (i = 0; i < N_LED; i++) if (colors & (1 << i)) - ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, foo, 0); + ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, 0); #else #ifdef LED_PORT LED_PORT->bsrr = (uint32_t) (colors & ao_led_enable) << 16; @@ -137,7 +137,7 @@ ao_led_toggle(AO_LED_TYPE colors) AO_LED_TYPE i; for (i = 0; i < N_LED; i++) if (colors & (1 << i)) - ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, foo, ~ao_gpio_get(ao_leds[i].port, ao_leds[i].pin, foo)); + ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, ~ao_gpio_get(ao_leds[i].port, ao_leds[i].pin)); #else #ifdef LED_PORT LED_PORT->odr ^= (colors & ao_led_enable); @@ -173,7 +173,7 @@ ao_led_init(AO_LED_TYPE enable) ao_led_enable = enable; #if LED_PER_LED for (bit = 0; bit < N_LED; bit++) - ao_enable_output(ao_leds[bit].port, ao_leds[bit].pin, foo, 0); + ao_enable_output(ao_leds[bit].port, ao_leds[bit].pin, 0); #else #ifdef LED_PORT stm_rcc.ahbenr |= (1 << LED_PORT_ENABLE); diff --git a/src/stm/ao_serial_stm.c b/src/stm/ao_serial_stm.c index 2afee5b5..c1a2f1bd 100644 --- a/src/stm/ao_serial_stm.c +++ b/src/stm/ao_serial_stm.c @@ -33,7 +33,7 @@ _ao_usart_tx_start(struct ao_stm_usart *usart) { if (!ao_fifo_empty(usart->tx_fifo)) { #if HAS_SERIAL_SW_FLOW - if (usart->gpio_cts && ao_gpio_get(usart->gpio_cts, usart->pin_cts, foo) == 1) { + if (usart->gpio_cts && ao_gpio_get(usart->gpio_cts, usart->pin_cts) == 1) { ao_exti_enable(usart->gpio_cts, usart->pin_cts); return 0; } @@ -73,7 +73,7 @@ _ao_usart_rx(struct ao_stm_usart *usart, int is_stdin) * for it to drain a bunch */ if (usart->gpio_rts && ao_fifo_mostly(usart->rx_fifo)) { - ao_gpio_set(usart->gpio_rts, usart->pin_rts, usart->pin_rts, 1); + ao_gpio_set(usart->gpio_rts, usart->pin_rts, 1); usart->rts = 0; } #endif @@ -118,7 +118,7 @@ _ao_usart_pollchar(struct ao_stm_usart *usart) #if HAS_SERIAL_SW_FLOW /* If we've cleared RTS, check if there's space now and turn it back on */ if (usart->gpio_rts && usart->rts == 0 && ao_fifo_barely(usart->rx_fifo)) { - ao_gpio_set(usart->gpio_rts, usart->pin_rts, foo, 0); + ao_gpio_set(usart->gpio_rts, usart->pin_rts, 0); usart->rts = 1; } #endif @@ -403,7 +403,7 @@ ao_serial_set_sw_rts_cts(struct ao_stm_usart *usart, { /* Pull RTS low to note that there's space in the FIFO */ - ao_enable_output(port_rts, pin_rts, foo, 0); + ao_enable_output(port_rts, pin_rts, 0); usart->gpio_rts = port_rts; usart->pin_rts = pin_rts; usart->rts = 1; diff --git a/src/stmf0/ao_arch_funcs.h b/src/stmf0/ao_arch_funcs.h index 96c033f9..70f273d3 100644 --- a/src/stmf0/ao_arch_funcs.h +++ b/src/stmf0/ao_arch_funcs.h @@ -168,8 +168,8 @@ ao_spi_try_get_mask(struct stm_gpio *reg, uint16_t mask, uint8_t bus, uint32_t s ao_spi_put(bus); \ } while (0) -#define ao_spi_get_bit(reg,bit,pin,bus,speed) ao_spi_get_mask(reg,(1<adc.sense_a) #define AO_SENSE_MAIN(p) ((p)->adc.sense_m) diff --git a/src/telemini-v3.0/ao_telemini.c b/src/telemini-v3.0/ao_telemini.c index a2c0a598..66f75f0a 100644 --- a/src/telemini-v3.0/ao_telemini.c +++ b/src/telemini-v3.0/ao_telemini.c @@ -26,7 +26,7 @@ ao_check_recovery(void) ao_enable_input(AO_RECOVERY_PORT, AO_RECOVERY_PIN, AO_RECOVERY_MODE); for (i = 0; i < 100; i++) ao_arch_nop(); - if (ao_gpio_get(AO_RECOVERY_PORT, AO_RECOVERY_PIN, AO_RECOVERY) == AO_RECOVERY_VALUE) { + if (ao_gpio_get(AO_RECOVERY_PORT, AO_RECOVERY_PIN) == AO_RECOVERY_VALUE) { ao_flight_force_idle = 1; ao_force_freq = 1; } -- cgit v1.2.3 From 2cdb1f30c49ba460b0850d23ba9c85e0336af290 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 11 Sep 2018 11:57:50 -0700 Subject: altos: Add generic LED driver. This driver uses the generic GPIO functions and allows per-LED port and pin configuration. It supports up to 32 LEDs. Rename SoC-specific LED drivers. Remove enabled parameter to ao_led_init Signed-off-by: Keith Packard --- src/attiny/ao_arch.h | 2 + src/attiny/ao_led.c | 64 --------- src/attiny/ao_led_tiny.c | 61 ++++++++ src/avr-demo/Makefile | 2 +- src/avr/ao_led.c | 68 --------- src/avr/ao_led_avr.c | 68 +++++++++ src/chaoskey-v0.1/Makefile | 2 +- src/chaoskey-v1.0/Makefile | 2 +- src/chaoskey-v1.0/ao_chaoskey.c | 2 +- src/detherm/Makefile | 2 +- src/drivers/ao_led.c | 174 +++++++++++++++++++++++ src/easymega-v1.0/Makefile | 2 +- src/easymega-v1.0/ao_easymega.c | 2 +- src/fox1ihu/Makefile | 2 +- src/fox1ihu/ao_fox1ihu.c | 2 +- src/kernel/ao.h | 2 +- src/kernel/ao_led.h | 202 +++++++++++++++++++++++++- src/kernel/ao_task.c | 1 + src/kernel/ao_task.h | 2 +- src/lambdakey-v1.0/Makefile | 2 +- src/lpc/ao_led_lpc.c | 17 ++- src/megadongle-v0.1/Makefile | 2 +- src/microkite/Makefile | 2 +- src/micropeak-v2.0/Makefile | 2 +- src/micropeak-v2.0/ao_micropeak.c | 2 +- src/micropeak/Makefile | 2 +- src/microsplash/Makefile | 2 +- src/nanopeak-v0.1/Makefile | 2 +- src/nucleao-32/Makefile | 2 +- src/pnpservo-v1/Makefile | 2 +- src/product/ao_micropeak.c | 2 +- src/stm-demo/Makefile | 2 +- src/stm-scheme-newlib/Makefile | 2 +- src/stm-vga/Makefile | 2 +- src/stm/ao_led.c | 216 ---------------------------- src/stm/ao_led_stm.c | 144 +++++++++++++++++++ src/stm32f4-disco/Makefile | 5 +- src/stm32f4-disco/ao_disco.c | 41 ++++-- src/stm32f4-disco/ao_pins.h | 29 ++-- src/stm32f4/ao_arch.h | 3 - src/stm32f4/ao_arch_funcs.h | 228 ++++++++++++++++++++++++++++++ src/stmf0/ao_led.c | 126 ----------------- src/stmf0/ao_led_stmf0.c | 123 ++++++++++++++++ src/teleballoon-v2.0/Makefile | 2 +- src/teleballoon-v2.0/ao_teleballoon.c | 7 +- src/telebt-v3.0/Makefile | 2 +- src/telebt-v3.0/ao_telebt.c | 2 +- src/telebt-v4.0/Makefile | 2 +- src/telebt-v4.0/ao_telebt.c | 2 +- src/teledongle-v1.8/Makefile | 2 +- src/teledongle-v3.0/ao_teledongle.c | 2 +- src/telefireeight-v1.0/ao_pins.h | 29 +--- src/telefireeight-v1.0/ao_telefireeight.c | 5 +- src/telefireone-v1.0/Makefile | 2 +- src/telefiretwo-v0.1/Makefile | 2 +- src/telefiretwo-v0.1/ao_telefiretwo.c | 5 +- src/telefiretwo-v0.2/Makefile | 2 +- src/telegps-v0.1/Makefile | 2 +- src/telegps-v2.0/Makefile | 2 +- src/telegps-v2.0/ao_telegps.c | 7 +- src/telelco-v0.2-cc1200/Makefile | 2 +- src/telelco-v0.2-cc1200/ao_telelco.c | 7 +- src/telelco-v0.2/Makefile | 2 +- src/telelco-v0.2/ao_telelco.c | 14 +- src/telelco-v0.3/Makefile | 2 +- src/telelco-v0.3/ao_telelco.c | 6 +- src/telelco-v2.0/ao_lco_v2.c | 4 +- src/telelco-v2.0/ao_pins.h | 73 +++------- src/telelco-v2.0/ao_telelco.c | 6 +- src/telelcotwo-v0.1/Makefile | 2 +- src/telelcotwo-v0.1/ao_telelcotwo.c | 6 +- src/telemega-v0.1/Makefile | 2 +- src/telemega-v0.1/ao_telemega.c | 5 +- src/telemega-v1.0/Makefile | 2 +- src/telemega-v1.0/ao_telemega.c | 2 +- src/telemega-v2.0/Makefile | 2 +- src/telemega-v2.0/ao_telemega.c | 2 +- src/telemega-v3.0/Makefile | 2 +- src/telemega-v3.0/ao_telemega.c | 2 +- src/telemetrum-v2.0/Makefile | 2 +- src/telemetrum-v2.0/ao_telemetrum.c | 2 +- src/telemetrum-v3.0/Makefile | 2 +- src/telemetrum-v3.0/ao_telemetrum.c | 5 +- src/telepyro-v0.1/Makefile | 2 +- src/telescience-pwm/Makefile | 2 +- src/telescience-v0.1/Makefile | 2 +- src/telescience-v0.2/Makefile | 2 +- src/tmgps-v2.0/Makefile | 2 +- src/usbtrng-v2.0/Makefile | 2 +- 89 files changed, 1186 insertions(+), 679 deletions(-) delete mode 100644 src/attiny/ao_led.c create mode 100644 src/attiny/ao_led_tiny.c delete mode 100644 src/avr/ao_led.c create mode 100644 src/avr/ao_led_avr.c create mode 100644 src/drivers/ao_led.c delete mode 100644 src/stm/ao_led.c create mode 100644 src/stm/ao_led_stm.c delete mode 100644 src/stmf0/ao_led.c create mode 100644 src/stmf0/ao_led_stmf0.c (limited to 'src/easymega-v1.0') diff --git a/src/attiny/ao_arch.h b/src/attiny/ao_arch.h index 84a94be7..a9c450fc 100644 --- a/src/attiny/ao_arch.h +++ b/src/attiny/ao_arch.h @@ -34,6 +34,8 @@ #define AO_PORT_TYPE uint8_t +#define AO_LED_TYPE uint8_t + /* Various definitions to make GCC look more like SDCC */ #define ao_arch_naked_declare __attribute__((naked)) diff --git a/src/attiny/ao_led.c b/src/attiny/ao_led.c deleted file mode 100644 index 88505490..00000000 --- a/src/attiny/ao_led.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright © 2009 Keith Packard - * - * 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; 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 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -uint8_t ao_led_enable; - -#define LED_PORT PORTB -#define LED_DDR DDRB - -void -ao_led_on(uint8_t colors) -{ - LED_PORT |= (colors & ao_led_enable); -} - -void -ao_led_off(uint8_t colors) -{ - LED_PORT &= ~(colors & ao_led_enable); -} - -void -ao_led_set(uint8_t colors) -{ - LED_PORT = (LED_PORT & ~(ao_led_enable)) | (colors & ao_led_enable); -} - -void -ao_led_toggle(uint8_t colors) -{ - LED_PORT ^= (colors & ao_led_enable); -} - -void -ao_led_for(uint8_t colors, uint16_t ticks) -{ - ao_led_on(colors); - ao_delay(ticks); - ao_led_off(colors); -} - -void -ao_led_init(uint8_t enable) -{ - ao_led_enable = enable; - LED_PORT &= ~enable; - LED_DDR |= enable; -} diff --git a/src/attiny/ao_led_tiny.c b/src/attiny/ao_led_tiny.c new file mode 100644 index 00000000..cd620f46 --- /dev/null +++ b/src/attiny/ao_led_tiny.c @@ -0,0 +1,61 @@ +/* + * Copyright © 2009 Keith Packard + * + * 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; 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 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "ao.h" + +#define LED_PORT PORTB +#define LED_DDR DDRB + +void +ao_led_on(uint8_t colors) +{ + LED_PORT |= colors; +} + +void +ao_led_off(uint8_t colors) +{ + LED_PORT &= ~colors; +} + +void +ao_led_set(uint8_t colors) +{ + LED_PORT = (LED_PORT & ~LEDS_AVAILABLE) | (colors & LEDS_AVAILABLE); +} + +void +ao_led_toggle(uint8_t colors) +{ + LED_PORT ^= (colors & LEDS_AVAILABLE); +} + +void +ao_led_for(uint8_t colors, AO_TICK_TYPE ticks) +{ + ao_led_on(colors); + ao_delay(ticks); + ao_led_off(colors); +} + +void +ao_led_init(void) +{ + LED_PORT &= ~LEDS_AVAILABLE; + LED_DDR |= LEDS_AVAILABLE; +} diff --git a/src/avr-demo/Makefile b/src/avr-demo/Makefile index e21ad047..0aca6f8a 100644 --- a/src/avr-demo/Makefile +++ b/src/avr-demo/Makefile @@ -38,7 +38,7 @@ ALTOS_SRC = \ ao_stdio.c \ ao_task.c \ ao_timer.c \ - ao_led.c \ + ao_led_avr.c \ ao_usb_avr.c \ ao_lcd.c diff --git a/src/avr/ao_led.c b/src/avr/ao_led.c deleted file mode 100644 index 165e95d3..00000000 --- a/src/avr/ao_led.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright © 2009 Keith Packard - * - * 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; 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 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -uint8_t ao_led_enable; - -#define LED_PORT PORTB -#define LED_DDR DDRB - -void -ao_led_on(uint8_t colors) -{ - LED_PORT |= (colors & ao_led_enable); -} - -void -ao_led_off(uint8_t colors) -{ - LED_PORT &= ~(colors & ao_led_enable); -} - -void -ao_led_set(uint8_t colors) -{ - LED_PORT = (LED_PORT & ~(ao_led_enable)) | (colors & ao_led_enable); -} - -void -ao_led_toggle(uint8_t colors) -{ - LED_PORT ^= (colors & ao_led_enable); -} - -void -ao_led_for(uint8_t colors, uint16_t ticks) -{ - ao_led_on(colors); - ao_delay(ticks); - ao_led_off(colors); -} - -void -ao_led_init(uint8_t enable) -{ - ao_led_enable = enable; - if ((LED_DDR & enable)) { - printf ("oops! restarted\n"); - ao_panic(AO_PANIC_REBOOT); - } - LED_PORT &= ~enable; - LED_DDR |= enable; -} diff --git a/src/avr/ao_led_avr.c b/src/avr/ao_led_avr.c new file mode 100644 index 00000000..165e95d3 --- /dev/null +++ b/src/avr/ao_led_avr.c @@ -0,0 +1,68 @@ +/* + * Copyright © 2009 Keith Packard + * + * 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; 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 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "ao.h" + +uint8_t ao_led_enable; + +#define LED_PORT PORTB +#define LED_DDR DDRB + +void +ao_led_on(uint8_t colors) +{ + LED_PORT |= (colors & ao_led_enable); +} + +void +ao_led_off(uint8_t colors) +{ + LED_PORT &= ~(colors & ao_led_enable); +} + +void +ao_led_set(uint8_t colors) +{ + LED_PORT = (LED_PORT & ~(ao_led_enable)) | (colors & ao_led_enable); +} + +void +ao_led_toggle(uint8_t colors) +{ + LED_PORT ^= (colors & ao_led_enable); +} + +void +ao_led_for(uint8_t colors, uint16_t ticks) +{ + ao_led_on(colors); + ao_delay(ticks); + ao_led_off(colors); +} + +void +ao_led_init(uint8_t enable) +{ + ao_led_enable = enable; + if ((LED_DDR & enable)) { + printf ("oops! restarted\n"); + ao_panic(AO_PANIC_REBOOT); + } + LED_PORT &= ~enable; + LED_DDR |= enable; +} diff --git a/src/chaoskey-v0.1/Makefile b/src/chaoskey-v0.1/Makefile index 85392280..faa4a291 100644 --- a/src/chaoskey-v0.1/Makefile +++ b/src/chaoskey-v0.1/Makefile @@ -28,7 +28,7 @@ ALTOS_SRC = \ ao_adc_fast.c \ ao_crc_stm.c \ ao_stdio.c \ - ao_led.c \ + ao_led_stmf0.c \ ao_romconfig.c \ ao_boot_chain.c \ ao_usb_stm.c \ diff --git a/src/chaoskey-v1.0/Makefile b/src/chaoskey-v1.0/Makefile index c6cf45bd..329f603d 100644 --- a/src/chaoskey-v1.0/Makefile +++ b/src/chaoskey-v1.0/Makefile @@ -30,7 +30,7 @@ ALTOS_SRC = \ ao_adc_fast.c \ ao_crc_stm.c \ ao_stdio.c \ - ao_led.c \ + ao_led_stmf0.c \ ao_romconfig.c \ ao_boot_chain.c \ ao_usb_stm.c \ diff --git a/src/chaoskey-v1.0/ao_chaoskey.c b/src/chaoskey-v1.0/ao_chaoskey.c index 1165e454..80f5a4ba 100644 --- a/src/chaoskey-v1.0/ao_chaoskey.c +++ b/src/chaoskey-v1.0/ao_chaoskey.c @@ -24,7 +24,7 @@ void main(void) { - ao_led_init(LEDS_AVAILABLE); + ao_led_init(); ao_clock_init(); ao_task_init(); ao_timer_init(); diff --git a/src/detherm/Makefile b/src/detherm/Makefile index 6b0e0bf8..7681a049 100644 --- a/src/detherm/Makefile +++ b/src/detherm/Makefile @@ -27,7 +27,7 @@ ALTOS_SRC = \ ao_spi_stm.c \ ao_exti_stm.c \ ao_stdio.c \ - ao_led.c \ + ao_led_stmf0.c \ ao_log.c \ ao_log_mini.c \ ao_sample.c \ diff --git a/src/drivers/ao_led.c b/src/drivers/ao_led.c new file mode 100644 index 00000000..0f7b7c27 --- /dev/null +++ b/src/drivers/ao_led.c @@ -0,0 +1,174 @@ +/* + * Copyright © 2018 Keith Packard + * + * 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; 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 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "ao.h" + +static const struct { + struct stm_gpio *port; + uint16_t pin; +} ao_leds[] = { +#ifdef LED_0_PORT + [0] { LED_0_PORT, LED_0_PIN }, +#endif +#ifdef LED_1_PORT + [1] { LED_1_PORT, LED_1_PIN }, +#endif +#ifdef LED_2_PORT + [2] { LED_2_PORT, LED_2_PIN }, +#endif +#ifdef LED_3_PORT + [3] { LED_3_PORT, LED_3_PIN }, +#endif +#ifdef LED_4_PORT + [4] { LED_4_PORT, LED_4_PIN }, +#endif +#ifdef LED_5_PORT + [5] { LED_5_PORT, LED_5_PIN }, +#endif +#ifdef LED_6_PORT + [6] { LED_6_PORT, LED_6_PIN }, +#endif +#ifdef LED_7_PORT + [7] { LED_7_PORT, LED_7_PIN }, +#endif +#ifdef LED_8_PORT + [8] { LED_8_PORT, LED_8_PIN }, +#endif +#ifdef LED_9_PORT + [9] { LED_9_PORT, LED_9_PIN }, +#endif +#ifdef LED_10_PORT + [10] { LED_10_PORT, LED_10_PIN }, +#endif +#ifdef LED_11_PORT + [11] { LED_11_PORT, LED_11_PIN }, +#endif +#ifdef LED_12_PORT + [12] { LED_12_PORT, LED_12_PIN }, +#endif +#ifdef LED_13_PORT + [13] { LED_13_PORT, LED_13_PIN }, +#endif +#ifdef LED_14_PORT + [14] { LED_14_PORT, LED_14_PIN }, +#endif +#ifdef LED_15_PORT + [15] { LED_15_PORT, LED_15_PIN }, +#endif +#ifdef LED_16_PORT + [16] { LED_16_PORT, LED_16_PIN }, +#endif +#ifdef LED_17_PORT + [17] { LED_17_PORT, LED_17_PIN }, +#endif +#ifdef LED_18_PORT + [18] { LED_18_PORT, LED_18_PIN }, +#endif +#ifdef LED_19_PORT + [19] { LED_19_PORT, LED_19_PIN }, +#endif +#ifdef LED_20_PORT + [20] { LED_20_PORT, LED_20_PIN }, +#endif +#ifdef LED_21_PORT + [21] { LED_21_PORT, LED_21_PIN }, +#endif +#ifdef LED_22_PORT + [22] { LED_22_PORT, LED_22_PIN }, +#endif +#ifdef LED_23_PORT + [23] { LED_23_PORT, LED_23_PIN }, +#endif +#ifdef LED_24_PORT + [24] { LED_24_PORT, LED_24_PIN }, +#endif +#ifdef LED_25_PORT + [25] { LED_25_PORT, LED_25_PIN }, +#endif +#ifdef LED_26_PORT + [26] { LED_26_PORT, LED_26_PIN }, +#endif +#ifdef LED_27_PORT + [27] { LED_27_PORT, LED_27_PIN }, +#endif +#ifdef LED_28_PORT + [28] { LED_28_PORT, LED_28_PIN }, +#endif +#ifdef LED_29_PORT + [29] { LED_29_PORT, LED_29_PIN }, +#endif +#ifdef LED_30_PORT + [30] { LED_30_PORT, LED_30_PIN }, +#endif +#ifdef LED_31_PORT + [31] { LED_31_PORT, LED_31_PIN }, +#endif +}; +#define N_LED (sizeof (ao_leds)/sizeof(ao_leds[0])) + +void +ao_led_on(AO_LED_TYPE colors) +{ + AO_LED_TYPE i; + for (i = 0; i < N_LED; i++) + if (colors & (1 << i)) + ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, 1); +} + +void +ao_led_off(AO_LED_TYPE colors) +{ + AO_LED_TYPE i; + for (i = 0; i < N_LED; i++) + if (colors & (1 << i)) + ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, 0); +} + +void +ao_led_set(AO_LED_TYPE colors) +{ + AO_LED_TYPE i; + for (i = 0; i < N_LED; i++) + ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, (colors >> i) & 1); +} + +void +ao_led_toggle(AO_LED_TYPE colors) +{ + AO_LED_TYPE i; + for (i = 0; i < N_LED; i++) + if (colors & (1 << i)) + ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, ~ao_gpio_get(ao_leds[i].port, ao_leds[i].pin)); +} + +void +ao_led_for(AO_LED_TYPE colors, AO_TICK_TYPE ticks) +{ + ao_led_on(colors); + ao_delay(ticks); + ao_led_off(colors); +} + +void +ao_led_init(void) +{ + AO_LED_TYPE bit; + + for (bit = 0; bit < N_LED; bit++) + ao_enable_output(ao_leds[bit].port, ao_leds[bit].pin, 0); +} diff --git a/src/easymega-v1.0/Makefile b/src/easymega-v1.0/Makefile index 3344da06..76e7319e 100644 --- a/src/easymega-v1.0/Makefile +++ b/src/easymega-v1.0/Makefile @@ -53,7 +53,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/easymega-v1.0/ao_easymega.c b/src/easymega-v1.0/ao_easymega.c index 9848c367..d00585f9 100644 --- a/src/easymega-v1.0/ao_easymega.c +++ b/src/easymega-v1.0/ao_easymega.c @@ -43,7 +43,7 @@ main(void) #endif ao_task_init(); - ao_led_init(LEDS_AVAILABLE); + ao_led_init(); ao_led_on(LEDS_AVAILABLE); ao_timer_init(); diff --git a/src/fox1ihu/Makefile b/src/fox1ihu/Makefile index e3226a24..61314db9 100644 --- a/src/fox1ihu/Makefile +++ b/src/fox1ihu/Makefile @@ -37,7 +37,7 @@ ALTOS_SRC = \ ao_romconfig.c \ ao_cmd.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/fox1ihu/ao_fox1ihu.c b/src/fox1ihu/ao_fox1ihu.c index 2e1a2fdf..5ebb4b54 100644 --- a/src/fox1ihu/ao_fox1ihu.c +++ b/src/fox1ihu/ao_fox1ihu.c @@ -31,7 +31,7 @@ main(void) #endif ao_task_init(); - ao_led_init(LEDS_AVAILABLE); + ao_led_init(); ao_led_on(AO_LED_RED|AO_LED_GREEN|AO_LED_RED_2|AO_LED_GREEN_2); ao_timer_init(); diff --git a/src/kernel/ao.h b/src/kernel/ao.h index 9c0c8604..1b269d73 100644 --- a/src/kernel/ao.h +++ b/src/kernel/ao.h @@ -230,7 +230,7 @@ ao_cmd_filter(void); #include #endif -#if LEDS_AVAILABLE +#if LEDS_AVAILABLE || HAS_LED #include #endif diff --git a/src/kernel/ao_led.h b/src/kernel/ao_led.h index 803f85b3..5d982ca6 100644 --- a/src/kernel/ao_led.h +++ b/src/kernel/ao_led.h @@ -26,7 +26,7 @@ #define AO_LED_NONE 0 #ifndef AO_LED_TYPE -#define AO_LED_TYPE uint8_t +#define AO_LED_TYPE uint32_t #endif /* Turn on the specified LEDs */ @@ -55,6 +55,204 @@ ao_led_for(AO_LED_TYPE colors, uint16_t ticks); /* Initialize the LEDs */ void -ao_led_init(AO_LED_TYPE enable); +ao_led_init(void); + +#ifdef LED_0_PORT +#define AO_LED_0 (1 << 0) +#else +#define AO_LED_0 0 +#endif +#ifdef LED_1_PORT +#define AO_LED_1 (1 << 1) +#else +#define AO_LED_1 0 +#endif +#ifdef LED_2_PORT +#define AO_LED_2 (1 << 2) +#else +#define AO_LED_2 0 +#endif +#ifdef LED_3_PORT +#define AO_LED_3 (1 << 3) +#else +#define AO_LED_3 0 +#endif +#ifdef LED_4_PORT +#define AO_LED_4 (1 << 4) +#else +#define AO_LED_4 0 +#endif +#ifdef LED_5_PORT +#define AO_LED_5 (1 << 5) +#else +#define AO_LED_5 0 +#endif +#ifdef LED_6_PORT +#define AO_LED_6 (1 << 6) +#else +#define AO_LED_6 0 +#endif +#ifdef LED_7_PORT +#define AO_LED_7 (1 << 7) +#else +#define AO_LED_7 0 +#endif +#ifdef LED_8_PORT +#define AO_LED_8 (1 << 8) +#else +#define AO_LED_8 0 +#endif +#ifdef LED_9_PORT +#define AO_LED_9 (1 << 9) +#else +#define AO_LED_9 0 +#endif +#ifdef LED_10_PORT +#define AO_LED_10 (1 << 10) +#else +#define AO_LED_10 0 +#endif +#ifdef LED_11_PORT +#define AO_LED_11 (1 << 11) +#else +#define AO_LED_11 0 +#endif +#ifdef LED_12_PORT +#define AO_LED_12 (1 << 12) +#else +#define AO_LED_12 0 +#endif +#ifdef LED_13_PORT +#define AO_LED_13 (1 << 13) +#else +#define AO_LED_13 0 +#endif +#ifdef LED_14_PORT +#define AO_LED_14 (1 << 14) +#else +#define AO_LED_14 0 +#endif +#ifdef LED_15_PORT +#define AO_LED_15 (1 << 15) +#else +#define AO_LED_15 0 +#endif +#ifdef LED_16_PORT +#define AO_LED_16 (1 << 16) +#else +#define AO_LED_16 0 +#endif +#ifdef LED_17_PORT +#define AO_LED_17 (1 << 17) +#else +#define AO_LED_17 0 +#endif +#ifdef LED_18_PORT +#define AO_LED_18 (1 << 18) +#else +#define AO_LED_18 0 +#endif +#ifdef LED_19_PORT +#define AO_LED_19 (1 << 19) +#else +#define AO_LED_19 0 +#endif +#ifdef LED_20_PORT +#define AO_LED_20 (1 << 20) +#else +#define AO_LED_20 0 +#endif +#ifdef LED_21_PORT +#define AO_LED_21 (1 << 21) +#else +#define AO_LED_21 0 +#endif +#ifdef LED_22_PORT +#define AO_LED_22 (1 << 22) +#else +#define AO_LED_22 0 +#endif +#ifdef LED_23_PORT +#define AO_LED_23 (1 << 23) +#else +#define AO_LED_23 0 +#endif +#ifdef LED_24_PORT +#define AO_LED_24 (1 << 24) +#else +#define AO_LED_24 0 +#endif +#ifdef LED_25_PORT +#define AO_LED_25 (1 << 25) +#else +#define AO_LED_25 0 +#endif +#ifdef LED_26_PORT +#define AO_LED_26 (1 << 26) +#else +#define AO_LED_26 0 +#endif +#ifdef LED_27_PORT +#define AO_LED_27 (1 << 27) +#else +#define AO_LED_27 0 +#endif +#ifdef LED_28_PORT +#define AO_LED_28 (1 << 28) +#else +#define AO_LED_28 0 +#endif +#ifdef LED_29_PORT +#define AO_LED_29 (1 << 29) +#else +#define AO_LED_29 0 +#endif +#ifdef LED_30_PORT +#define AO_LED_30 (1 << 30) +#else +#define AO_LED_30 0 +#endif +#ifdef LED_31_PORT +#define AO_LED_31 (1 << 31) +#else +#define AO_LED_31 0 +#endif + +#define AO_LEDS_AVAILABLE (AO_LED_0 | \ + AO_LED_1 | \ + AO_LED_2 | \ + AO_LED_3 | \ + AO_LED_4 | \ + AO_LED_5 | \ + AO_LED_6 | \ + AO_LED_7 | \ + AO_LED_8 | \ + AO_LED_9 | \ + AO_LED_10 | \ + AO_LED_11 | \ + AO_LED_12 | \ + AO_LED_13 | \ + AO_LED_14 | \ + AO_LED_15 | \ + AO_LED_16 | \ + AO_LED_17 | \ + AO_LED_18 | \ + AO_LED_19 | \ + AO_LED_20 | \ + AO_LED_21 | \ + AO_LED_22 | \ + AO_LED_23 | \ + AO_LED_24 | \ + AO_LED_25 | \ + AO_LED_26 | \ + AO_LED_27 | \ + AO_LED_28 | \ + AO_LED_29 | \ + AO_LED_30 | \ + AO_LED_31) + +#ifndef LEDS_AVAILABLE +#define LEDS_AVAILABLE AO_LEDS_AVAILABLE +#endif #endif /* _AO_LED_H_ */ diff --git a/src/kernel/ao_task.c b/src/kernel/ao_task.c index 4f7072cb..dc5c1913 100644 --- a/src/kernel/ao_task.c +++ b/src/kernel/ao_task.c @@ -569,4 +569,5 @@ ao_start_scheduler(void) ao_arch_start_scheduler(); #endif ao_yield(); + __builtin_unreachable(); } diff --git a/src/kernel/ao_task.h b/src/kernel/ao_task.h index ffeb7313..f3789fa2 100644 --- a/src/kernel/ao_task.h +++ b/src/kernel/ao_task.h @@ -134,7 +134,7 @@ ao_task_info(void); /* Start the scheduler. This will not return */ void -ao_start_scheduler(void); +ao_start_scheduler(void) __attribute__((noreturn)); #if HAS_TASK_QUEUE void diff --git a/src/lambdakey-v1.0/Makefile b/src/lambdakey-v1.0/Makefile index b94c3873..f8b5c7f5 100644 --- a/src/lambdakey-v1.0/Makefile +++ b/src/lambdakey-v1.0/Makefile @@ -27,7 +27,7 @@ ALTOS_SRC = \ ao_interrupt.c \ ao_product.c \ ao_cmd.c \ - ao_led.c \ + ao_led_stmf0.c \ ao_notask.c \ ao_stdio.c \ ao_panic.c \ diff --git a/src/lpc/ao_led_lpc.c b/src/lpc/ao_led_lpc.c index 5fc726c0..3a2d4c98 100644 --- a/src/lpc/ao_led_lpc.c +++ b/src/lpc/ao_led_lpc.c @@ -35,8 +35,8 @@ ao_led_off(AO_PORT_TYPE colors) void ao_led_set(AO_PORT_TYPE colors) { - AO_PORT_TYPE on = colors & ao_led_enable; - AO_PORT_TYPE off = ~colors & ao_led_enable; + AO_PORT_TYPE on = colors & LEDS_AVAILABLE; + AO_PORT_TYPE off = ~colors & LEDS_AVAILABLE; ao_led_off(off); ao_led_on(on); @@ -57,18 +57,17 @@ ao_led_for(AO_PORT_TYPE colors, uint16_t ticks) } void -ao_led_init(AO_PORT_TYPE enable) +ao_led_init(void) { - ao_led_enable = enable; ao_enable_port(LED_PORT); if (LED_PORT == 0) { - if (enable & (1 << 11)) + if (LEDS_AVAILABLE & (1 << 11)) lpc_ioconf.pio0_11 = LPC_IOCONF_FUNC_PIO0_11 | (1 << LPC_IOCONF_ADMODE); - if (enable & (1 << 12)) + if (LEDS_AVAILABLE & (1 << 12)) lpc_ioconf.pio0_12 = LPC_IOCONF_FUNC_PIO0_12 | (1 << LPC_IOCONF_ADMODE); - if (enable & (1 << 14)) + if (LEDS_AVAILABLE & (1 << 14)) lpc_ioconf.pio0_14 = LPC_IOCONF_FUNC_PIO0_14 | (1 << LPC_IOCONF_ADMODE); } - lpc_gpio.dir[LED_PORT] |= enable; - ao_led_off(enable); + lpc_gpio.dir[LED_PORT] |= LEDS_AVAILABLE; + ao_led_off(LEDS_AVAILABLE); } diff --git a/src/megadongle-v0.1/Makefile b/src/megadongle-v0.1/Makefile index bbe2ea58..4290e088 100644 --- a/src/megadongle-v0.1/Makefile +++ b/src/megadongle-v0.1/Makefile @@ -36,7 +36,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/microkite/Makefile b/src/microkite/Makefile index b7523758..5eb97206 100644 --- a/src/microkite/Makefile +++ b/src/microkite/Makefile @@ -29,7 +29,7 @@ LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w: ALTOS_SRC = \ ao_micropeak.c \ ao_spi_attiny.c \ - ao_led.c \ + ao_led_tiny.c \ ao_clock.c \ ao_ms5607.c \ ao_exti.c \ diff --git a/src/micropeak-v2.0/Makefile b/src/micropeak-v2.0/Makefile index 32154fa6..c7d1b22d 100644 --- a/src/micropeak-v2.0/Makefile +++ b/src/micropeak-v2.0/Makefile @@ -18,7 +18,7 @@ ALTOS_SRC = \ ao_micropeak.c \ ao_spi_stm.c \ ao_dma_stm.c \ - ao_led.c \ + ao_led_stmf0.c \ ao_timer.c \ ao_ms5607.c \ ao_exti_stm.c \ diff --git a/src/micropeak-v2.0/ao_micropeak.c b/src/micropeak-v2.0/ao_micropeak.c index 1cfa1209..df557e60 100644 --- a/src/micropeak-v2.0/ao_micropeak.c +++ b/src/micropeak-v2.0/ao_micropeak.c @@ -252,7 +252,7 @@ main(void) else ao_hsi_init(); - ao_led_init(LEDS_AVAILABLE); + ao_led_init(); ao_task_init(); ao_timer_init(); ao_serial_init(); diff --git a/src/micropeak/Makefile b/src/micropeak/Makefile index 6e8cae14..f80d61b0 100644 --- a/src/micropeak/Makefile +++ b/src/micropeak/Makefile @@ -29,7 +29,7 @@ LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w: ALTOS_SRC = \ ao_micropeak.c \ ao_spi_attiny.c \ - ao_led.c \ + ao_led_tiny.c \ ao_clock.c \ ao_ms5607.c \ ao_exti.c \ diff --git a/src/microsplash/Makefile b/src/microsplash/Makefile index 9bb636f1..0342838e 100644 --- a/src/microsplash/Makefile +++ b/src/microsplash/Makefile @@ -29,7 +29,7 @@ LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w: ALTOS_SRC = \ ao_micropeak.c \ ao_spi_attiny.c \ - ao_led.c \ + ao_led_tiny.c \ ao_clock.c \ ao_ms5607.c \ ao_exti.c \ diff --git a/src/nanopeak-v0.1/Makefile b/src/nanopeak-v0.1/Makefile index d3779594..774d4adc 100644 --- a/src/nanopeak-v0.1/Makefile +++ b/src/nanopeak-v0.1/Makefile @@ -19,7 +19,7 @@ LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w: ALTOS_SRC = \ ao_micropeak.c \ ao_spi_attiny.c \ - ao_led.c \ + ao_led_tiny.c \ ao_clock.c \ ao_ms5607.c \ ao_exti.c \ diff --git a/src/nucleao-32/Makefile b/src/nucleao-32/Makefile index 2b9fe14f..1ab2eea1 100644 --- a/src/nucleao-32/Makefile +++ b/src/nucleao-32/Makefile @@ -26,7 +26,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stmf0.c \ ao_beep_stm.c \ ao_dma_stm.c \ ao_stdio.c \ diff --git a/src/pnpservo-v1/Makefile b/src/pnpservo-v1/Makefile index 8606b1ae..443a6afb 100644 --- a/src/pnpservo-v1/Makefile +++ b/src/pnpservo-v1/Makefile @@ -24,7 +24,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stmf0.c \ ao_dma_stm.c \ ao_stdio.c \ ao_mutex.c \ diff --git a/src/product/ao_micropeak.c b/src/product/ao_micropeak.c index 8aac79cd..8fed3069 100644 --- a/src/product/ao_micropeak.c +++ b/src/product/ao_micropeak.c @@ -57,7 +57,7 @@ ao_pips(void) int main(void) { - ao_led_init(LEDS_AVAILABLE); + ao_led_init(); ao_timer_init(); /* Init external hardware */ diff --git a/src/stm-demo/Makefile b/src/stm-demo/Makefile index d4569c1a..ccce37a5 100644 --- a/src/stm-demo/Makefile +++ b/src/stm-demo/Makefile @@ -23,7 +23,7 @@ ALTOS_SRC = \ ao_romconfig.c \ ao_cmd.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/stm-scheme-newlib/Makefile b/src/stm-scheme-newlib/Makefile index a4c249a3..1db58f10 100644 --- a/src/stm-scheme-newlib/Makefile +++ b/src/stm-scheme-newlib/Makefile @@ -30,7 +30,7 @@ ALTOS_SRC = \ ao_romconfig.c \ ao_cmd.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio_newlib.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/stm-vga/Makefile b/src/stm-vga/Makefile index 46a77272..fa0d008f 100644 --- a/src/stm-vga/Makefile +++ b/src/stm-vga/Makefile @@ -28,7 +28,7 @@ ALTOS_SRC = \ ao_romconfig.c \ ao_cmd.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/stm/ao_led.c b/src/stm/ao_led.c deleted file mode 100644 index 481a6e87..00000000 --- a/src/stm/ao_led.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright © 2012 Keith Packard - * - * 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; 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 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -#if LED_PER_LED -static const struct { - struct stm_gpio *port; - uint16_t pin; -} ao_leds[] = { -#ifdef LED_0_PORT - [0] { LED_0_PORT, LED_0_PIN }, -#endif -#ifdef LED_1_PORT - [1] { LED_1_PORT, LED_1_PIN }, -#endif -#ifdef LED_2_PORT - [2] { LED_2_PORT, LED_2_PIN }, -#endif -#ifdef LED_3_PORT - [3] { LED_3_PORT, LED_3_PIN }, -#endif -#ifdef LED_4_PORT - [4] { LED_4_PORT, LED_4_PIN }, -#endif -#ifdef LED_5_PORT - [5] { LED_5_PORT, LED_5_PIN }, -#endif -#ifdef LED_6_PORT - [6] { LED_6_PORT, LED_6_PIN }, -#endif -#ifdef LED_7_PORT - [7] { LED_7_PORT, LED_7_PIN }, -#endif -#ifdef LED_8_PORT - [8] { LED_8_PORT, LED_8_PIN }, -#endif -#ifdef LED_9_PORT - [9] { LED_9_PORT, LED_9_PIN }, -#endif -#ifdef LED_10_PORT - [10] { LED_10_PORT, LED_10_PIN }, -#endif -#ifdef LED_11_PORT - [11] { LED_11_PORT, LED_11_PIN }, -#endif -#ifdef LED_12_PORT - [12] { LED_12_PORT, LED_12_PIN }, -#endif -#ifdef LED_13_PORT - [13] { LED_13_PORT, LED_13_PIN }, -#endif -#ifdef LED_14_PORT - [14] { LED_14_PORT, LED_14_PIN }, -#endif -#ifdef LED_15_PORT - [15] { LED_15_PORT, LED_15_PIN }, -#endif -}; -#define N_LED (sizeof (ao_leds)/sizeof(ao_leds[0])) -#endif -static AO_LED_TYPE ao_led_enable; - -void -ao_led_on(AO_LED_TYPE colors) -{ -#ifdef LED_PER_LED - AO_LED_TYPE i; - for (i = 0; i < N_LED; i++) - if (colors & (1 << i)) - ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, 1); -#else -#ifdef LED_PORT - LED_PORT->bsrr = (colors & ao_led_enable); -#else -#ifdef LED_PORT_0 - LED_PORT_0->bsrr = ((colors & ao_led_enable) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT; -#endif -#ifdef LED_PORT_1 - LED_PORT_1->bsrr = ((colors & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT; -#endif -#endif -#endif -} - -void -ao_led_off(AO_LED_TYPE colors) -{ -#ifdef LED_PER_LED - AO_LED_TYPE i; - for (i = 0; i < N_LED; i++) - if (colors & (1 << i)) - ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, 0); -#else -#ifdef LED_PORT - LED_PORT->bsrr = (uint32_t) (colors & ao_led_enable) << 16; -#else -#ifdef LED_PORT_0 - LED_PORT_0->bsrr = ((uint32_t) (colors & ao_led_enable) & LED_PORT_0_MASK) << (LED_PORT_0_SHIFT + 16); -#endif -#ifdef LED_PORT_1 - LED_PORT_1->bsrr = ((uint32_t) (colors & ao_led_enable) & LED_PORT_1_MASK) << (LED_PORT_1_SHIFT + 16); -#endif -#endif -#endif -} - -void -ao_led_set(AO_LED_TYPE colors) -{ - AO_LED_TYPE on = colors & ao_led_enable; - AO_LED_TYPE off = ~colors & ao_led_enable; - - ao_led_off(off); - ao_led_on(on); -} - -void -ao_led_toggle(AO_LED_TYPE colors) -{ -#ifdef LED_PER_LED - AO_LED_TYPE i; - for (i = 0; i < N_LED; i++) - if (colors & (1 << i)) - ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, ~ao_gpio_get(ao_leds[i].port, ao_leds[i].pin)); -#else -#ifdef LED_PORT - LED_PORT->odr ^= (colors & ao_led_enable); -#else -#ifdef LED_PORT_0 - LED_PORT_0->odr ^= ((colors & ao_led_enable) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT; -#endif -#ifdef LED_PORT_1 - LED_PORT_1->odr ^= ((colors & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT; -#endif -#endif -#endif -} - -void -ao_led_for(AO_LED_TYPE colors, AO_LED_TYPE ticks) -{ - ao_led_on(colors); - ao_delay(ticks); - ao_led_off(colors); -} - -#define init_led_pin(port, bit) do { \ - stm_moder_set(port, bit, STM_MODER_OUTPUT); \ - stm_otyper_set(port, bit, STM_OTYPER_PUSH_PULL); \ - } while (0) - -void -ao_led_init(AO_LED_TYPE enable) -{ - AO_LED_TYPE bit; - - ao_led_enable = enable; -#if LED_PER_LED - for (bit = 0; bit < N_LED; bit++) - ao_enable_output(ao_leds[bit].port, ao_leds[bit].pin, 0); -#else -#ifdef LED_PORT - stm_rcc.ahbenr |= (1 << LED_PORT_ENABLE); - LED_PORT->odr &= ~enable; -#else -#ifdef LED_PORT_0 - stm_rcc.ahbenr |= (1 << LED_PORT_0_ENABLE); - LED_PORT_0->odr &= ~((enable & ao_led_enable) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT; -#endif -#ifdef LED_PORT_1 - stm_rcc.ahbenr |= (1 << LED_PORT_1_ENABLE); - LED_PORT_1->odr &= ~((enable & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT; -#endif -#ifdef LED_PORT_2 - stm_rcc.ahbenr |= (1 << LED_PORT_1_ENABLE); - LED_PORT_1->odr &= ~((enable & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT; -#endif -#endif - for (bit = 0; bit < 16; bit++) { - if (enable & (1 << bit)) { -#ifdef LED_PORT - init_led_pin(LED_PORT, bit); -#else -#ifdef LED_PORT_0 - if (LED_PORT_0_MASK & (1 << bit)) - init_led_pin(LED_PORT_0, bit + LED_PORT_0_SHIFT); -#endif -#ifdef LED_PORT_1 - if (LED_PORT_1_MASK & (1 << bit)) - init_led_pin(LED_PORT_1, bit + LED_PORT_1_SHIFT); -#endif -#ifdef LED_PORT_2 - if (LED_PORT_2_MASK & (1 << bit)) - init_led_pin(LED_PORT_2, bit + LED_PORT_2_SHIFT); -#endif -#endif - } - } -#endif -} diff --git a/src/stm/ao_led_stm.c b/src/stm/ao_led_stm.c new file mode 100644 index 00000000..7dcbb661 --- /dev/null +++ b/src/stm/ao_led_stm.c @@ -0,0 +1,144 @@ +/* + * Copyright © 2012 Keith Packard + * + * 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; 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 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "ao.h" + +#if LED_PER_LED +#error LED_PER_LED support is in ao_led.c now +#endif + +void +ao_led_on(AO_LED_TYPE colors) +{ +#ifdef LED_PORT + LED_PORT->bsrr = (colors & LEDS_AVAILABLE); +#else +#ifdef LED_PORT_0 + LED_PORT_0->bsrr = ((colors & LEDS_AVAILABLE) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT; +#endif +#ifdef LED_PORT_1 + LED_PORT_1->bsrr = ((colors & LEDS_AVAILABLE) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT; +#endif +#ifdef LED_PORT_2 + LED_PORT_2->bsrr = ((colors & LEDS_AVAILABLE) & LED_PORT_2_MASK) << LED_PORT_2_SHIFT; +#endif +#endif +} + +void +ao_led_off(AO_LED_TYPE colors) +{ +#ifdef LED_PORT + LED_PORT->bsrr = (uint32_t) (colors & LEDS_AVAILABLE) << 16; +#else +#ifdef LED_PORT_0 + LED_PORT_0->bsrr = ((uint32_t) (colors & LEDS_AVAILABLE) & LED_PORT_0_MASK) << (LED_PORT_0_SHIFT + 16); +#endif +#ifdef LED_PORT_1 + LED_PORT_1->bsrr = ((uint32_t) (colors & LEDS_AVAILABLE) & LED_PORT_1_MASK) << (LED_PORT_1_SHIFT + 16); +#endif +#ifdef LED_PORT_2 + LED_PORT_2->bsrr = ((uint32_t) (colors & LEDS_AVAILABLE) & LED_PORT_2_MASK) << (LED_PORT_2_SHIFT + 16); +#endif +#endif +} + +void +ao_led_set(AO_LED_TYPE colors) +{ + AO_LED_TYPE on = colors & LEDS_AVAILABLE; + AO_LED_TYPE off = ~colors & LEDS_AVAILABLE; + + ao_led_off(off); + ao_led_on(on); +} + +void +ao_led_toggle(AO_LED_TYPE colors) +{ +#ifdef LED_PORT + LED_PORT->odr ^= (colors & LEDS_AVAILABLE); +#else +#ifdef LED_PORT_0 + LED_PORT_0->odr ^= ((colors & LEDS_AVAILABLE) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT; +#endif +#ifdef LED_PORT_1 + LED_PORT_1->odr ^= ((colors & LEDS_AVAILABLE) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT; +#endif +#ifdef LED_PORT_2 + LED_PORT_2->odr ^= ((colors & LEDS_AVAILABLE) & LED_PORT_2_MASK) << LED_PORT_2_SHIFT; +#endif +#endif +} + +void +ao_led_for(AO_LED_TYPE colors, AO_LED_TYPE ticks) +{ + ao_led_on(colors); + ao_delay(ticks); + ao_led_off(colors); +} + +#define init_led_pin(port, bit) do { \ + stm_moder_set(port, bit, STM_MODER_OUTPUT); \ + stm_otyper_set(port, bit, STM_OTYPER_PUSH_PULL); \ + } while (0) + +void +ao_led_init(void) +{ + AO_LED_TYPE bit; + +#ifdef LED_PORT + stm_rcc.ahbenr |= (1 << LED_PORT_ENABLE); + LED_PORT->odr &= ~LEDS_AVAILABLE; +#else +#ifdef LED_PORT_0 + stm_rcc.ahbenr |= (1 << LED_PORT_0_ENABLE); + LED_PORT_0->odr &= (uint32_t) ~(LEDS_AVAILABLE & LED_PORT_0_MASK) << LED_PORT_0_SHIFT; +#endif +#ifdef LED_PORT_1 + stm_rcc.ahbenr |= (1 << LED_PORT_1_ENABLE); + LED_PORT_1->odr &= (uint32_t) ~(LEDS_AVAILABLE & LED_PORT_1_MASK) << LED_PORT_1_SHIFT; +#endif +#ifdef LED_PORT_2 + stm_rcc.ahbenr |= (1 << LED_PORT_2_ENABLE); + LED_PORT_2->odr &= (uint32_t) ~(LEDS_AVAILABLE & LED_PORT_2_MASK) << LED_PORT_2_SHIFT; +#endif +#endif + for (bit = 0; bit < sizeof (AO_LED_TYPE) * 8; bit++) { + if (LEDS_AVAILABLE & (1 << bit)) { +#ifdef LED_PORT + init_led_pin(LED_PORT, bit); +#else +#ifdef LED_PORT_0 + if (LED_PORT_0_MASK & (1 << bit)) + init_led_pin(LED_PORT_0, bit + LED_PORT_0_SHIFT); +#endif +#ifdef LED_PORT_1 + if (LED_PORT_1_MASK & (1 << bit)) + init_led_pin(LED_PORT_1, bit + LED_PORT_1_SHIFT); +#endif +#ifdef LED_PORT_2 + if (LED_PORT_2_MASK & (1 << bit)) + init_led_pin(LED_PORT_2, bit + LED_PORT_2_SHIFT); +#endif +#endif + } + } +} diff --git a/src/stm32f4-disco/Makefile b/src/stm32f4-disco/Makefile index 2d912b22..c970b879 100644 --- a/src/stm32f4-disco/Makefile +++ b/src/stm32f4-disco/Makefile @@ -3,7 +3,10 @@ include ../stm32f4/Makefile-raw.defs ALTOS_SRC = \ ao_interrupt.c \ ao_panic.c \ - ao_timer.c + ao_timer.c \ + ao_led.c \ + ao_task.c \ + ao_stdio.c CFLAGS = $(STM32F4_CFLAGS) diff --git a/src/stm32f4-disco/ao_disco.c b/src/stm32f4-disco/ao_disco.c index efbed947..c6cdbd23 100644 --- a/src/stm32f4-disco/ao_disco.c +++ b/src/stm32f4-disco/ao_disco.c @@ -14,24 +14,35 @@ #include -void main(void) +static struct ao_task red_task; +static struct ao_task green_task; + +static void +red(void) { - float x; - int r = 1; - int g = 0; + for (;;) { + ao_led_toggle(LED_RED); + ao_delay(AO_MS_TO_TICKS(500)); + } +} - ao_clock_init(); +static void +green(void) +{ + for (;;) { + ao_led_toggle(LED_GREEN); + ao_delay(AO_MS_TO_TICKS(450)); + } +} +void main(void) +{ + ao_clock_init(); ao_timer_init(); + ao_led_init(); + ao_task_init(); - ao_enable_output(LED_GREEN_PORT, LED_GREEN_PIN, 0); - ao_enable_output(LED_RED_PORT, LED_RED_PIN, 1); - for (;;) { - ao_gpio_set(LED_GREEN_PORT, LED_GREEN_PIN, g); - ao_gpio_set(LED_RED_PORT, LED_RED_PIN, r); - g ^= 1; - r ^= 1; - for (x = 0.0f; x < 100000.0f; x = x + 0.1f) - ao_arch_nop(); - } + ao_add_task(&red_task, red, "red"); + ao_add_task(&green_task, green, "green"); + ao_start_scheduler(); } diff --git a/src/stm32f4-disco/ao_pins.h b/src/stm32f4-disco/ao_pins.h index c4dc5b4b..bbbc306e 100644 --- a/src/stm32f4-disco/ao_pins.h +++ b/src/stm32f4-disco/ao_pins.h @@ -14,16 +14,7 @@ #ifndef _AO_PINS_H_ #define _AO_PINS_H_ -#define HAS_BEEP 0 - -#define B_USER_PORT (&stm_gpioa) -#define B_USER_PIN 0 - -#define LED_GREEN_PORT (&stm_gpioc) -#define LED_GREEN_PIN 5 -#define LED_RED_PORT (&stm_gpioe) -#define LED_RED_PIN 3 - +/* Clock tree configuration */ #define AO_HSE 8000000 /* fed from st/link processor */ #define AO_HSE_BYPASS 1 /* no xtal, directly fed */ @@ -43,4 +34,22 @@ #define DEBUG_THE_CLOCK 1 +#define HAS_USB 0 +#define HAS_BEEP 0 + +#define B_USER_PORT (&stm_gpioa) +#define B_USER_PIN 0 + +/* LEDs */ + +#define HAS_LED 1 + +#define LED_0_PORT (&stm_gpioc) +#define LED_0_PIN 5 +#define LED_GREEN (1 << 0) + +#define LED_1_PORT (&stm_gpioe) +#define LED_1_PIN 3 +#define LED_RED (1 << 1) + #endif /* _AO_PINS_H_ */ diff --git a/src/stm32f4/ao_arch.h b/src/stm32f4/ao_arch.h index 805d756d..73eb793f 100644 --- a/src/stm32f4/ao_arch.h +++ b/src/stm32f4/ao_arch.h @@ -29,9 +29,6 @@ #define ao_arch_task_members\ uint32_t *sp; /* saved stack pointer */ -#define ao_arch_block_interrupts() asm("cpsid i") -#define ao_arch_release_interrupts() asm("cpsie i") - #define ao_arch_naked_declare __attribute__((naked)) #define ao_arch_naked_define diff --git a/src/stm32f4/ao_arch_funcs.h b/src/stm32f4/ao_arch_funcs.h index 252fe77a..8c0da03b 100644 --- a/src/stm32f4/ao_arch_funcs.h +++ b/src/stm32f4/ao_arch_funcs.h @@ -15,6 +15,234 @@ #ifndef _AO_ARCH_FUNCS_H_ #define _AO_ARCH_FUNCS_H_ +/* task functions */ + +#define ARM_PUSH32(stack, val) (*(--(stack)) = (val)) + +typedef uint32_t ao_arch_irq_t; + +static inline void +ao_arch_block_interrupts(void) { +#ifdef AO_NONMASK_INTERRUPTS + asm("msr basepri,%0" : : "r" (AO_STM_NVIC_BASEPRI_MASK)); +#else + asm("cpsid i"); +#endif +} + +static inline void +ao_arch_release_interrupts(void) { +#ifdef AO_NONMASK_INTERRUPTS + asm("msr basepri,%0" : : "r" (0x0)); +#else + asm("cpsie i"); +#endif +} + +static inline uint32_t +ao_arch_irqsave(void) { + uint32_t val; +#ifdef AO_NONMASK_INTERRUPTS + asm("mrs %0,basepri" : "=r" (val)); +#else + asm("mrs %0,primask" : "=r" (val)); +#endif + ao_arch_block_interrupts(); + return val; +} + +static inline void +ao_arch_irqrestore(uint32_t basepri) { +#ifdef AO_NONMASK_INTERRUPTS + asm("msr basepri,%0" : : "r" (basepri)); +#else + asm("msr primask,%0" : : "r" (basepri)); +#endif +} + +static inline void +ao_arch_memory_barrier() { + asm volatile("" ::: "memory"); +} + +static inline void +ao_arch_irq_check(void) { +#ifdef AO_NONMASK_INTERRUPTS + uint32_t basepri; + asm("mrs %0,basepri" : "=r" (basepri)); + if (basepri == 0) + ao_panic(AO_PANIC_IRQ); +#else + uint32_t primask; + asm("mrs %0,primask" : "=r" (primask)); + if ((primask & 1) == 0) + ao_panic(AO_PANIC_IRQ); +#endif +} + +#if HAS_TASK +static inline void +ao_arch_init_stack(struct ao_task *task, void *start) +{ + uint32_t *sp = (uint32_t *) ((void*) task->stack + AO_STACK_SIZE); + uint32_t a = (uint32_t) start; + int i; + + /* Return address (goes into LR) */ + ARM_PUSH32(sp, a); + + /* Clear register values r0-r12 */ + i = 13; + while (i--) + ARM_PUSH32(sp, 0); + + /* APSR */ + ARM_PUSH32(sp, 0); + + /* Clear register values s0-s31 */ + i = 32; + while (i--) + ARM_PUSH32(sp, 0); + + /* FPSCR */ + ARM_PUSH32(sp, 0); + + /* BASEPRI with interrupts enabled */ + ARM_PUSH32(sp, 0); + + task->sp = sp; +} + +static inline void ao_arch_save_regs(void) { + /* Save general registers */ + asm("push {r0-r12,lr}"); + + /* Save APSR */ + asm("mrs r0,apsr"); + asm("push {r0}"); + + /* Save FPU registers */ + asm("vpush {s0-s15}"); + asm("vpush {s16-s31}"); + + /* Save FPSCR */ + asm("vmrs r0,fpscr"); + asm("push {r0}"); + +#ifdef AO_NONMASK_INTERRUPTS + /* Save BASEPRI */ + asm("mrs r0,basepri"); +#else + /* Save PRIMASK */ + asm("mrs r0,primask"); +#endif + asm("push {r0}"); +} + +static inline void ao_arch_save_stack(void) { + uint32_t *sp; + asm("mov %0,sp" : "=&r" (sp) ); + ao_cur_task->sp = (sp); +} + +static inline void ao_arch_restore_stack(void) { + /* Switch stacks */ + asm("mov sp, %0" : : "r" (ao_cur_task->sp) ); + +#ifdef AO_NONMASK_INTERRUPTS + /* Restore BASEPRI */ + asm("pop {r0}"); + asm("msr basepri,r0"); +#else + /* Restore PRIMASK */ + asm("pop {r0}"); + asm("msr primask,r0"); +#endif + + /* Restore FPSCR */ + asm("pop {r0}"); + asm("vmsr fpscr,r0"); + + /* Restore FPU registers */ + asm("vpop {s16-s31}"); + asm("vpop {s0-s15}"); + + /* Restore APSR */ + asm("pop {r0}"); + asm("msr apsr_nczvq,r0"); + + /* Restore general registers */ + asm("pop {r0-r12,lr}\n"); + + /* Return to calling function */ + asm("bx lr"); +} + +#ifndef HAS_SAMPLE_PROFILE +#define HAS_SAMPLE_PROFILE 0 +#endif + +#if DEBUG +#define HAS_ARCH_VALIDATE_CUR_STACK 1 + +static inline void +ao_validate_cur_stack(void) +{ + uint8_t *psp; + + asm("mrs %0,psp" : "=&r" (psp)); + if (ao_cur_task && + psp <= ao_cur_task->stack && + psp >= ao_cur_task->stack - 256) + ao_panic(AO_PANIC_STACK); +} +#endif + +#if !HAS_SAMPLE_PROFILE +#define HAS_ARCH_START_SCHEDULER 1 + +static inline void ao_arch_start_scheduler(void) { + uint32_t sp; + uint32_t control; + + asm("mrs %0,msp" : "=&r" (sp)); + asm("msr psp,%0" : : "r" (sp)); + asm("mrs %0,control" : "=r" (control)); + control |= (1 << 1); + asm("msr control,%0" : : "r" (control)); + asm("isb"); +} +#endif + +#define ao_arch_isr_stack() + +#endif + +static inline void +ao_arch_wait_interrupt(void) { +#ifdef AO_NONMASK_INTERRUPTS + asm( + "dsb\n" /* Serialize data */ + "isb\n" /* Serialize instructions */ + "cpsid i\n" /* Block all interrupts */ + "msr basepri,%0\n" /* Allow all interrupts through basepri */ + "wfi\n" /* Wait for an interrupt */ + "cpsie i\n" /* Allow all interrupts */ + "msr basepri,%1\n" /* Block interrupts through basepri */ + : : "r" (0), "r" (AO_STM_NVIC_BASEPRI_MASK)); +#else + asm("\twfi\n"); + ao_arch_release_interrupts(); + ao_arch_block_interrupts(); +#endif +} + +#define ao_arch_critical(b) do { \ + uint32_t __mask = ao_arch_irqsave(); \ + do { b } while (0); \ + ao_arch_irqrestore(__mask); \ + } while (0) + /* GPIO functions */ #define ao_power_register(gpio) diff --git a/src/stmf0/ao_led.c b/src/stmf0/ao_led.c deleted file mode 100644 index a162932a..00000000 --- a/src/stmf0/ao_led.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright © 2012 Keith Packard - * - * 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; 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 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -uint16_t ao_led_enable; - -void -ao_led_on(uint16_t colors) -{ -#ifdef LED_PORT - LED_PORT->bsrr = (colors & ao_led_enable); -#else -#ifdef LED_PORT_0 - LED_PORT_0->bsrr = ((colors & ao_led_enable) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT; -#endif -#ifdef LED_PORT_1 - LED_PORT_1->bsrr = ((colors & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT; -#endif -#endif -} - -void -ao_led_off(uint16_t colors) -{ -#ifdef LED_PORT - LED_PORT->bsrr = (uint32_t) (colors & ao_led_enable) << 16; -#else -#ifdef LED_PORT_0 - LED_PORT_0->bsrr = ((uint32_t) (colors & ao_led_enable) & LED_PORT_0_MASK) << (LED_PORT_0_SHIFT + 16); -#endif -#ifdef LED_PORT_1 - LED_PORT_1->bsrr = ((uint32_t) (colors & ao_led_enable) & LED_PORT_1_MASK) << (LED_PORT_1_SHIFT + 16); -#endif -#endif -} - -void -ao_led_set(uint16_t colors) -{ - uint16_t on = colors & ao_led_enable; - uint16_t off = ~colors & ao_led_enable; - - ao_led_off(off); - ao_led_on(on); -} - -void -ao_led_toggle(uint16_t colors) -{ -#ifdef LED_PORT - LED_PORT->odr ^= (colors & ao_led_enable); -#else -#ifdef LED_PORT_0 - LED_PORT_0->odr ^= ((colors & ao_led_enable) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT; -#endif -#ifdef LED_PORT_1 - LED_PORT_1->odr ^= ((colors & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT; -#endif -#endif -} - -void -ao_led_for(uint16_t colors, uint16_t ticks) -{ - ao_led_on(colors); - ao_delay(ticks); - ao_led_off(colors); -} - -#define init_led_pin(port, bit) do { \ - stm_moder_set(port, bit, STM_MODER_OUTPUT); \ - stm_otyper_set(port, bit, STM_OTYPER_PUSH_PULL); \ - } while (0) - -void -ao_led_init(uint16_t enable) -{ - int bit; - - ao_led_enable = enable; -#ifdef LED_PORT - stm_rcc.ahbenr |= (1 << LED_PORT_ENABLE); - LED_PORT->odr &= ~enable; -#else -#ifdef LED_PORT_0 - stm_rcc.ahbenr |= (1 << LED_PORT_0_ENABLE); - LED_PORT_0->odr &= ~((enable & ao_led_enable) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT; -#endif -#ifdef LED_PORT_1 - stm_rcc.ahbenr |= (1 << LED_PORT_1_ENABLE); - LED_PORT_1->odr &= ~((enable & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT; -#endif -#endif - for (bit = 0; bit < 16; bit++) { - if (enable & (1 << bit)) { -#ifdef LED_PORT - init_led_pin(LED_PORT, bit); -#else -#ifdef LED_PORT_0 - if (LED_PORT_0_MASK & (1 << bit)) - init_led_pin(LED_PORT_0, bit + LED_PORT_0_SHIFT); -#endif -#ifdef LED_PORT_1 - if (LED_PORT_1_MASK & (1 << bit)) - init_led_pin(LED_PORT_1, bit + LED_PORT_1_SHIFT); -#endif -#endif - } - } -} diff --git a/src/stmf0/ao_led_stmf0.c b/src/stmf0/ao_led_stmf0.c new file mode 100644 index 00000000..1564535e --- /dev/null +++ b/src/stmf0/ao_led_stmf0.c @@ -0,0 +1,123 @@ +/* + * Copyright © 2012 Keith Packard + * + * 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; 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 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "ao.h" + +void +ao_led_on(AO_LED_TYPE colors) +{ +#ifdef LED_PORT + LED_PORT->bsrr = (colors & LEDS_AVAILABLE); +#else +#ifdef LED_PORT_0 + LED_PORT_0->bsrr = ((colors & LEDS_AVAILABLE) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT; +#endif +#ifdef LED_PORT_1 + LED_PORT_1->bsrr = ((colors & LEDS_AVAILABLE) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT; +#endif +#endif +} + +void +ao_led_off(AO_LED_TYPE colors) +{ +#ifdef LED_PORT + LED_PORT->bsrr = (uint32_t) (colors & LEDS_AVAILABLE) << 16; +#else +#ifdef LED_PORT_0 + LED_PORT_0->bsrr = ((uint32_t) (colors & LEDS_AVAILABLE) & LED_PORT_0_MASK) << (LED_PORT_0_SHIFT + 16); +#endif +#ifdef LED_PORT_1 + LED_PORT_1->bsrr = ((uint32_t) (colors & LEDS_AVAILABLE) & LED_PORT_1_MASK) << (LED_PORT_1_SHIFT + 16); +#endif +#endif +} + +void +ao_led_set(AO_LED_TYPE colors) +{ + AO_LED_TYPE on = colors & LEDS_AVAILABLE; + AO_LED_TYPE off = ~colors & LEDS_AVAILABLE; + + ao_led_off(off); + ao_led_on(on); +} + +void +ao_led_toggle(AO_LED_TYPE colors) +{ +#ifdef LED_PORT + LED_PORT->odr ^= (colors & LEDS_AVAILABLE); +#else +#ifdef LED_PORT_0 + LED_PORT_0->odr ^= ((colors & LEDS_AVAILABLE) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT; +#endif +#ifdef LED_PORT_1 + LED_PORT_1->odr ^= ((colors & LEDS_AVAILABLE) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT; +#endif +#endif +} + +void +ao_led_for(AO_LED_TYPE colors, AO_TICK_TYPE ticks) +{ + ao_led_on(colors); + ao_delay(ticks); + ao_led_off(colors); +} + +#define init_led_pin(port, bit) do { \ + stm_moder_set(port, bit, STM_MODER_OUTPUT); \ + stm_otyper_set(port, bit, STM_OTYPER_PUSH_PULL); \ + } while (0) + +void +ao_led_init(void) +{ + int bit; + +#ifdef LED_PORT + stm_rcc.ahbenr |= (1 << LED_PORT_ENABLE); + LED_PORT->odr &= ~LEDS_AVAILABLE; +#else +#ifdef LED_PORT_0 + stm_rcc.ahbenr |= (1 << LED_PORT_0_ENABLE); + LED_PORT_0->odr &= (uint32_t) ~(LEDS_AVAILABLE & LED_PORT_0_MASK) << LED_PORT_0_SHIFT; +#endif +#ifdef LED_PORT_1 + stm_rcc.ahbenr |= (1 << LED_PORT_1_ENABLE); + LED_PORT_1->odr &= (uint32_t) ~(LEDS_AVAILABLE & LED_PORT_1_MASK) << LED_PORT_1_SHIFT; +#endif +#endif + for (bit = 0; bit < 16; bit++) { + if (LEDS_AVAILABLE & (1 << bit)) { +#ifdef LED_PORT + init_led_pin(LED_PORT, bit); +#else +#ifdef LED_PORT_0 + if (LED_PORT_0_MASK & (1 << bit)) + init_led_pin(LED_PORT_0, bit + LED_PORT_0_SHIFT); +#endif +#ifdef LED_PORT_1 + if (LED_PORT_1_MASK & (1 << bit)) + init_led_pin(LED_PORT_1, bit + LED_PORT_1_SHIFT); +#endif +#endif + } + } +} diff --git a/src/teleballoon-v2.0/Makefile b/src/teleballoon-v2.0/Makefile index cb2ce253..ddbfaf5f 100644 --- a/src/teleballoon-v2.0/Makefile +++ b/src/teleballoon-v2.0/Makefile @@ -46,7 +46,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/teleballoon-v2.0/ao_teleballoon.c b/src/teleballoon-v2.0/ao_teleballoon.c index acb11f44..94393da0 100644 --- a/src/teleballoon-v2.0/ao_teleballoon.c +++ b/src/teleballoon-v2.0/ao_teleballoon.c @@ -43,8 +43,8 @@ main(void) ao_task_init(); ao_serial_init(); - ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_RED); + ao_led_init(); + ao_led_on(LEDS_AVAILABLE); ao_timer_init(); ao_spi_init(); @@ -87,7 +87,8 @@ main(void) #if HAS_SAMPLE_PROFILE ao_sample_profile_init(); #endif - + ao_led_off(LEDS_AVAILABLE); + ao_start_scheduler(); return 0; } diff --git a/src/telebt-v3.0/Makefile b/src/telebt-v3.0/Makefile index 4636c046..9892ad5f 100644 --- a/src/telebt-v3.0/Makefile +++ b/src/telebt-v3.0/Makefile @@ -37,7 +37,7 @@ ALTOS_SRC = \ ao_config.c \ ao_data.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/telebt-v3.0/ao_telebt.c b/src/telebt-v3.0/ao_telebt.c index 63633c90..3d48b6b9 100644 --- a/src/telebt-v3.0/ao_telebt.c +++ b/src/telebt-v3.0/ao_telebt.c @@ -34,7 +34,7 @@ main(void) ao_clock_init(); ao_task_init(); - ao_led_init(LEDS_AVAILABLE); + ao_led_init(); ao_led_on(LEDS_AVAILABLE); ao_timer_init(); diff --git a/src/telebt-v4.0/Makefile b/src/telebt-v4.0/Makefile index 38ac7513..4ad3287d 100644 --- a/src/telebt-v4.0/Makefile +++ b/src/telebt-v4.0/Makefile @@ -27,7 +27,7 @@ ALTOS_SRC = \ ao_config.c \ ao_data.c \ ao_task.c \ - ao_led.c \ + ao_led_stmf0.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/telebt-v4.0/ao_telebt.c b/src/telebt-v4.0/ao_telebt.c index 953ec4bc..7c3c6e2a 100644 --- a/src/telebt-v4.0/ao_telebt.c +++ b/src/telebt-v4.0/ao_telebt.c @@ -29,7 +29,7 @@ main(void) ao_clock_init(); ao_task_init(); - ao_led_init(LEDS_AVAILABLE); + ao_led_init(); ao_led_on(LEDS_AVAILABLE); ao_timer_init(); diff --git a/src/teledongle-v1.8/Makefile b/src/teledongle-v1.8/Makefile index 6c05ce9f..461b5855 100644 --- a/src/teledongle-v1.8/Makefile +++ b/src/teledongle-v1.8/Makefile @@ -38,7 +38,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/teledongle-v3.0/ao_teledongle.c b/src/teledongle-v3.0/ao_teledongle.c index 32899af2..69abea6e 100644 --- a/src/teledongle-v3.0/ao_teledongle.c +++ b/src/teledongle-v3.0/ao_teledongle.c @@ -31,7 +31,7 @@ main(void) #endif ao_task_init(); - ao_led_init(LEDS_AVAILABLE); + ao_led_init(); ao_led_on(LEDS_AVAILABLE); ao_timer_init(); diff --git a/src/telefireeight-v1.0/ao_pins.h b/src/telefireeight-v1.0/ao_pins.h index 15e1fa11..ef533b36 100644 --- a/src/telefireeight-v1.0/ao_pins.h +++ b/src/telefireeight-v1.0/ao_pins.h @@ -107,7 +107,7 @@ #define AO_CC1200_INT_GPIO 2 #define AO_CC1200_INT_GPIO_IOCFG CC1200_IOCFG2 -#define LED_PER_LED 1 +#define HAS_LED 1 #define LED_TYPE uint16_t /* Continuity leds 1-8 */ @@ -128,14 +128,8 @@ #define LED_7_PORT (&stm_gpioa) #define LED_7_PIN 10 -#define LED_PIN_CONTINUITY_0 0 -#define LED_PIN_CONTINUITY_1 1 -#define LED_PIN_CONTINUITY_2 2 -#define LED_PIN_CONTINUITY_3 3 -#define LED_PIN_CONTINUITY_4 4 -#define LED_PIN_CONTINUITY_5 5 -#define LED_PIN_CONTINUITY_6 6 -#define LED_PIN_CONTINUITY_7 7 +#define AO_LED_CONTINUITY(c) (1 << (c)) +#define AO_LED_CONTINUITY_MASK (0xff) /* ARM */ #define LED_8_PORT (&stm_gpioe) @@ -151,19 +145,10 @@ #define LED_11_PORT (&stm_gpioe) #define LED_11_PIN 6 -#define LED_PIN_GREEN 9 -#define LED_PIN_AMBER 10 -#define LED_PIN_RED 11 - -#define AO_LED_CONTINUITY(c) (1 << (c)) -#define AO_LED_CONTINUITY_MASK (0xff) - -#define AO_LED_ARMED (1 << LED_PIN_ARMED) -#define AO_LED_GREEN (1 << LED_PIN_GREEN) -#define AO_LED_AMBER (1 << LED_PIN_AMBER) -#define AO_LED_RED (1 << LED_PIN_RED) - -#define LEDS_AVAILABLE (0xfff) +#define AO_LED_ARMED AO_LED_8 +#define AO_LED_GREEN AO_LED_9 +#define AO_LED_AMBER AO_LED_10 +#define AO_LED_RED AO_LED_11 /* Alarm A */ #define AO_SIREN diff --git a/src/telefireeight-v1.0/ao_telefireeight.c b/src/telefireeight-v1.0/ao_telefireeight.c index bdcf3213..89541a02 100644 --- a/src/telefireeight-v1.0/ao_telefireeight.c +++ b/src/telefireeight-v1.0/ao_telefireeight.c @@ -26,7 +26,8 @@ main(void) { ao_clock_init(); - ao_led_init(LEDS_AVAILABLE); + ao_led_init(); + ao_led_on(LEDS_AVAILABLE); ao_task_init(); @@ -51,5 +52,7 @@ main(void) // ao_radio_cmac_cmd_init(); + ao_led_off(LEDS_AVAILABLE); + ao_start_scheduler(); } diff --git a/src/telefireone-v1.0/Makefile b/src/telefireone-v1.0/Makefile index 53f088cb..773c8f69 100644 --- a/src/telefireone-v1.0/Makefile +++ b/src/telefireone-v1.0/Makefile @@ -34,7 +34,7 @@ ALTOS_SRC = \ ao_data.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/telefiretwo-v0.1/Makefile b/src/telefiretwo-v0.1/Makefile index 6454d6fd..72171fac 100644 --- a/src/telefiretwo-v0.1/Makefile +++ b/src/telefiretwo-v0.1/Makefile @@ -33,7 +33,7 @@ ALTOS_SRC = \ ao_data.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/telefiretwo-v0.1/ao_telefiretwo.c b/src/telefiretwo-v0.1/ao_telefiretwo.c index bdcf3213..89541a02 100644 --- a/src/telefiretwo-v0.1/ao_telefiretwo.c +++ b/src/telefiretwo-v0.1/ao_telefiretwo.c @@ -26,7 +26,8 @@ main(void) { ao_clock_init(); - ao_led_init(LEDS_AVAILABLE); + ao_led_init(); + ao_led_on(LEDS_AVAILABLE); ao_task_init(); @@ -51,5 +52,7 @@ main(void) // ao_radio_cmac_cmd_init(); + ao_led_off(LEDS_AVAILABLE); + ao_start_scheduler(); } diff --git a/src/telefiretwo-v0.2/Makefile b/src/telefiretwo-v0.2/Makefile index 30985f9c..f43ece71 100644 --- a/src/telefiretwo-v0.2/Makefile +++ b/src/telefiretwo-v0.2/Makefile @@ -33,7 +33,7 @@ ALTOS_SRC = \ ao_data.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/telegps-v0.1/Makefile b/src/telegps-v0.1/Makefile index 46eb0ac5..0365f91f 100644 --- a/src/telegps-v0.1/Makefile +++ b/src/telegps-v0.1/Makefile @@ -44,7 +44,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/telegps-v2.0/Makefile b/src/telegps-v2.0/Makefile index 19d088d3..617efa65 100644 --- a/src/telegps-v2.0/Makefile +++ b/src/telegps-v2.0/Makefile @@ -21,7 +21,7 @@ INC = \ ALTOS_SRC = \ ao_adc_stm.c \ - ao_led.c \ + ao_led_stmf0.c \ ao_interrupt.c \ ao_boot_chain.c \ ao_product.c \ diff --git a/src/telegps-v2.0/ao_telegps.c b/src/telegps-v2.0/ao_telegps.c index 998c2008..1ba67f67 100644 --- a/src/telegps-v2.0/ao_telegps.c +++ b/src/telegps-v2.0/ao_telegps.c @@ -29,8 +29,8 @@ main(void) ao_cmd_init(); ao_config_init(); - ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_GREEN); + ao_led_init(); + ao_led_on(LEDS_AVAILABLE); /* internal systems */ ao_timer_init(); @@ -53,8 +53,7 @@ main(void) ao_telemetry_init(); ao_tracker_init(); - ao_led_off(AO_LED_GREEN); + ao_led_off(LEDS_AVAILABLE); ao_start_scheduler(); - return 0; } diff --git a/src/telelco-v0.2-cc1200/Makefile b/src/telelco-v0.2-cc1200/Makefile index 4ccf494c..9307aa2d 100644 --- a/src/telelco-v0.2-cc1200/Makefile +++ b/src/telelco-v0.2-cc1200/Makefile @@ -40,7 +40,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/telelco-v0.2-cc1200/ao_telelco.c b/src/telelco-v0.2-cc1200/ao_telelco.c index 3266da00..26f49d59 100644 --- a/src/telelco-v0.2-cc1200/ao_telelco.c +++ b/src/telelco-v0.2-cc1200/ao_telelco.c @@ -45,9 +45,8 @@ main(void) ao_timer_init(); ao_dma_init(); - ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_GREEN); - + ao_led_init(); + ao_led_on(LEDS_AVAILABLE); ao_spi_init(); ao_exti_init(); @@ -74,6 +73,8 @@ main(void) ao_lco_cmd_init(); // ao_radio_cmac_cmd_init(); + ao_led_off(LEDS_AVAILABLE); + ao_start_scheduler(); return 0; } diff --git a/src/telelco-v0.2/Makefile b/src/telelco-v0.2/Makefile index 8279cac1..91ae67f0 100644 --- a/src/telelco-v0.2/Makefile +++ b/src/telelco-v0.2/Makefile @@ -39,7 +39,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/telelco-v0.2/ao_telelco.c b/src/telelco-v0.2/ao_telelco.c index 7b04d386..4eba3597 100644 --- a/src/telelco-v0.2/ao_telelco.c +++ b/src/telelco-v0.2/ao_telelco.c @@ -35,9 +35,9 @@ int main(void) { ao_clock_init(); - - ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_GREEN); + + ao_led_init(); + ao_led_on(LEDS_AVAILABLE); ao_task_init(); ao_timer_init(); @@ -55,17 +55,19 @@ main(void) ao_button_init(); ao_eeprom_init(); - + ao_radio_init(); ao_usb_init(); ao_config_init(); - + ao_lco_init(); ao_lco_cmd_init(); // ao_radio_cmac_cmd_init(); - + + ao_led_off(LEDS_AVAILABLE); + ao_start_scheduler(); return 0; } diff --git a/src/telelco-v0.3/Makefile b/src/telelco-v0.3/Makefile index c2592bf8..567ddf41 100644 --- a/src/telelco-v0.3/Makefile +++ b/src/telelco-v0.3/Makefile @@ -40,7 +40,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/telelco-v0.3/ao_telelco.c b/src/telelco-v0.3/ao_telelco.c index 7b04d386..c2ca68aa 100644 --- a/src/telelco-v0.3/ao_telelco.c +++ b/src/telelco-v0.3/ao_telelco.c @@ -36,8 +36,8 @@ main(void) { ao_clock_init(); - ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_GREEN); + ao_led_init(); + ao_led_on(LEDS_AVAILABLE); ao_task_init(); ao_timer_init(); @@ -66,6 +66,8 @@ main(void) ao_lco_cmd_init(); // ao_radio_cmac_cmd_init(); + ao_led_off(LEDS_AVAILABLE); + ao_start_scheduler(); return 0; } diff --git a/src/telelco-v2.0/ao_lco_v2.c b/src/telelco-v2.0/ao_lco_v2.c index 90324cc8..daecf380 100644 --- a/src/telelco-v2.0/ao_lco_v2.c +++ b/src/telelco-v2.0/ao_lco_v2.c @@ -243,9 +243,9 @@ ao_lco_display_test() ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, 8 | 0x10); ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, 8 | 0x10); ao_mutex_put(&ao_lco_display_mutex); - ao_led_on(LEDS_AVAILABLE); + ao_led_on(AO_LEDS_AVAILABLE); ao_delay(AO_MS_TO_TICKS(1000)); - ao_led_off(LEDS_AVAILABLE); + ao_led_off(AO_LEDS_AVAILABLE); } static void diff --git a/src/telelco-v2.0/ao_pins.h b/src/telelco-v2.0/ao_pins.h index 95998dc7..ea709c1d 100644 --- a/src/telelco-v2.0/ao_pins.h +++ b/src/telelco-v2.0/ao_pins.h @@ -99,13 +99,7 @@ #define LOW_LEVEL_DEBUG 0 -#define LED_PER_LED 1 -#define LED_TYPE uint16_t - -#define LED_ENABLE_BITS ((1 << STM_RCC_AHBENR_GPIOAEN) | \ - (1 << STM_RCC_AHBENR_GPIOCEN) | \ - (1 << STM_RCC_AHBENR_GPIODEN) | \ - (1 << STM_RCC_AHBENR_GPIOEEN)) +#define HAS_LED 1 /* PC7 - PC9, LED 0 - 2 */ #define LED_0_PORT (&stm_gpioc) @@ -147,56 +141,23 @@ #define LED_15_PORT (&stm_gpioa) #define LED_15_PIN 5 -#define LED_PIN_RED 0 -#define LED_PIN_AMBER 1 -#define LED_PIN_GREEN 2 -#define LED_PIN_BOX 3 -#define LED_PIN_PAD 4 -#define LED_PIN_DRAG 5 -#define LED_PIN_CONTINUITY_7 6 -#define LED_PIN_CONTINUITY_6 7 -#define LED_PIN_CONTINUITY_5 8 -#define LED_PIN_CONTINUITY_4 9 -#define LED_PIN_CONTINUITY_3 10 -#define LED_PIN_CONTINUITY_2 11 -#define LED_PIN_CONTINUITY_1 12 -#define LED_PIN_CONTINUITY_0 13 -#define LED_PIN_REMOTE_ARM 14 -#define LED_PIN_FIRE 15 -#define AO_LED_RED (1 << LED_PIN_RED) -#define AO_LED_AMBER (1 << LED_PIN_AMBER) -#define AO_LED_GREEN (1 << LED_PIN_GREEN) -#define AO_LED_BOX (1 << LED_PIN_BOX) -#define AO_LED_PAD (1 << LED_PIN_PAD) -#define AO_LED_DRAG (1 << LED_PIN_DRAG) -#define AO_LED_CONTINUITY_7 (1 << LED_PIN_CONTINUITY_7) -#define AO_LED_CONTINUITY_6 (1 << LED_PIN_CONTINUITY_6) -#define AO_LED_CONTINUITY_5 (1 << LED_PIN_CONTINUITY_5) -#define AO_LED_CONTINUITY_4 (1 << LED_PIN_CONTINUITY_4) -#define AO_LED_CONTINUITY_3 (1 << LED_PIN_CONTINUITY_3) -#define AO_LED_CONTINUITY_2 (1 << LED_PIN_CONTINUITY_2) -#define AO_LED_CONTINUITY_1 (1 << LED_PIN_CONTINUITY_1) -#define AO_LED_CONTINUITY_0 (1 << LED_PIN_CONTINUITY_0) +#define AO_LED_RED AO_LED_0 +#define AO_LED_AMBER AO_LED_1 +#define AO_LED_GREEN AO_LED_2 +#define AO_LED_BOX AO_LED_3 +#define AO_LED_PAD AO_LED_4 +#define AO_LED_DRAG AO_LED_5 +#define AO_LED_CONTINUITY_7 AO_LED_6 +#define AO_LED_CONTINUITY_6 AO_LED_7 +#define AO_LED_CONTINUITY_5 AO_LED_8 +#define AO_LED_CONTINUITY_4 AO_LED_9 +#define AO_LED_CONTINUITY_3 AO_LED_10 +#define AO_LED_CONTINUITY_2 AO_LED_11 +#define AO_LED_CONTINUITY_1 AO_LED_12 +#define AO_LED_CONTINUITY_0 AO_LED_13 #define AO_LED_CONTINUITY_NUM 8 -#define AO_LED_REMOTE_ARM (1 << LED_PIN_REMOTE_ARM) -#define AO_LED_FIRE (1 << LED_PIN_FIRE) - -#define LEDS_AVAILABLE (AO_LED_RED | \ - AO_LED_AMBER | \ - AO_LED_GREEN | \ - AO_LED_BOX | \ - AO_LED_PAD | \ - AO_LED_DRAG | \ - AO_LED_CONTINUITY_7 | \ - AO_LED_CONTINUITY_6 | \ - AO_LED_CONTINUITY_5 | \ - AO_LED_CONTINUITY_4 | \ - AO_LED_CONTINUITY_3 | \ - AO_LED_CONTINUITY_2 | \ - AO_LED_CONTINUITY_1 | \ - AO_LED_CONTINUITY_0 | \ - AO_LED_REMOTE_ARM | \ - AO_LED_FIRE) +#define AO_LED_REMOTE_ARM AO_LED_14 +#define AO_LED_FIRE AO_LED_15 /* LCD displays */ diff --git a/src/telelco-v2.0/ao_telelco.c b/src/telelco-v2.0/ao_telelco.c index 9693c657..59582569 100644 --- a/src/telelco-v2.0/ao_telelco.c +++ b/src/telelco-v2.0/ao_telelco.c @@ -37,8 +37,8 @@ main(void) { ao_clock_init(); - ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_GREEN); + ao_led_init(); + ao_led_on(LEDS_AVAILABLE); ao_task_init(); ao_timer_init(); @@ -68,6 +68,8 @@ main(void) ao_lco_cmd_init(); // ao_radio_cmac_cmd_init(); + ao_led_off(LEDS_AVAILABLE); + ao_start_scheduler(); return 0; } diff --git a/src/telelcotwo-v0.1/Makefile b/src/telelcotwo-v0.1/Makefile index c68f3eb5..6a114aae 100644 --- a/src/telelcotwo-v0.1/Makefile +++ b/src/telelcotwo-v0.1/Makefile @@ -36,7 +36,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/telelcotwo-v0.1/ao_telelcotwo.c b/src/telelcotwo-v0.1/ao_telelcotwo.c index b3fcd200..6ced1912 100644 --- a/src/telelcotwo-v0.1/ao_telelcotwo.c +++ b/src/telelcotwo-v0.1/ao_telelcotwo.c @@ -34,8 +34,8 @@ main(void) { ao_clock_init(); - ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_GREEN); + ao_led_init(); + ao_led_on(LEDS_AVAILABLE); ao_beep_init(); ao_task_init(); @@ -61,6 +61,8 @@ main(void) ao_lco_cmd_init(); // ao_radio_cmac_cmd_init(); + ao_led_off(LEDS_AVAILABLE); + ao_start_scheduler(); return 0; } diff --git a/src/telemega-v0.1/Makefile b/src/telemega-v0.1/Makefile index 78cfdefd..fde35aae 100644 --- a/src/telemega-v0.1/Makefile +++ b/src/telemega-v0.1/Makefile @@ -53,7 +53,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/telemega-v0.1/ao_telemega.c b/src/telemega-v0.1/ao_telemega.c index f8b7ecfa..d6ecbf31 100644 --- a/src/telemega-v0.1/ao_telemega.c +++ b/src/telemega-v0.1/ao_telemega.c @@ -45,8 +45,8 @@ main(void) ao_task_init(); ao_serial_init(); - ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_GREEN); + ao_led_init(); + ao_led_on(LEDS_AVAILABLE); ao_timer_init(); ao_i2c_init(); @@ -98,6 +98,7 @@ main(void) ao_sample_profile_init(); #endif + ao_led_off(LEDS_AVAILABLE); ao_start_scheduler(); return 0; } diff --git a/src/telemega-v1.0/Makefile b/src/telemega-v1.0/Makefile index 372d53b8..62eda4ad 100644 --- a/src/telemega-v1.0/Makefile +++ b/src/telemega-v1.0/Makefile @@ -55,7 +55,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/telemega-v1.0/ao_telemega.c b/src/telemega-v1.0/ao_telemega.c index 50428b61..328c17ff 100644 --- a/src/telemega-v1.0/ao_telemega.c +++ b/src/telemega-v1.0/ao_telemega.c @@ -45,7 +45,7 @@ main(void) ao_task_init(); ao_serial_init(); - ao_led_init(LEDS_AVAILABLE); + ao_led_init(); ao_led_on(LEDS_AVAILABLE); ao_timer_init(); diff --git a/src/telemega-v2.0/Makefile b/src/telemega-v2.0/Makefile index 2592587a..78829fff 100644 --- a/src/telemega-v2.0/Makefile +++ b/src/telemega-v2.0/Makefile @@ -55,7 +55,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/telemega-v2.0/ao_telemega.c b/src/telemega-v2.0/ao_telemega.c index 6a58547e..623e8d1e 100644 --- a/src/telemega-v2.0/ao_telemega.c +++ b/src/telemega-v2.0/ao_telemega.c @@ -46,7 +46,7 @@ main(void) ao_task_init(); ao_serial_init(); - ao_led_init(LEDS_AVAILABLE); + ao_led_init(); ao_led_on(LEDS_AVAILABLE); ao_timer_init(); diff --git a/src/telemega-v3.0/Makefile b/src/telemega-v3.0/Makefile index df0f4dbb..b449b397 100644 --- a/src/telemega-v3.0/Makefile +++ b/src/telemega-v3.0/Makefile @@ -53,7 +53,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/telemega-v3.0/ao_telemega.c b/src/telemega-v3.0/ao_telemega.c index 2577f90c..d987c1ec 100644 --- a/src/telemega-v3.0/ao_telemega.c +++ b/src/telemega-v3.0/ao_telemega.c @@ -45,7 +45,7 @@ main(void) ao_task_init(); ao_serial_init(); - ao_led_init(LEDS_AVAILABLE); + ao_led_init(); ao_led_on(LEDS_AVAILABLE); ao_timer_init(); diff --git a/src/telemetrum-v2.0/Makefile b/src/telemetrum-v2.0/Makefile index 0196936b..e0192f61 100644 --- a/src/telemetrum-v2.0/Makefile +++ b/src/telemetrum-v2.0/Makefile @@ -46,7 +46,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/telemetrum-v2.0/ao_telemetrum.c b/src/telemetrum-v2.0/ao_telemetrum.c index 65f9be2c..dbf6090c 100644 --- a/src/telemetrum-v2.0/ao_telemetrum.c +++ b/src/telemetrum-v2.0/ao_telemetrum.c @@ -43,7 +43,7 @@ main(void) ao_task_init(); ao_serial_init(); - ao_led_init(LEDS_AVAILABLE); + ao_led_init(); ao_led_on(LEDS_AVAILABLE); ao_timer_init(); diff --git a/src/telemetrum-v3.0/Makefile b/src/telemetrum-v3.0/Makefile index c72e781a..071fd8dd 100644 --- a/src/telemetrum-v3.0/Makefile +++ b/src/telemetrum-v3.0/Makefile @@ -46,7 +46,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/telemetrum-v3.0/ao_telemetrum.c b/src/telemetrum-v3.0/ao_telemetrum.c index 2bb5192a..d75f339d 100644 --- a/src/telemetrum-v3.0/ao_telemetrum.c +++ b/src/telemetrum-v3.0/ao_telemetrum.c @@ -43,8 +43,8 @@ main(void) ao_task_init(); ao_serial_init(); - ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_RED); + ao_led_init(); + ao_led_on(LEDS_AVAILABLE); ao_timer_init(); ao_spi_init(); @@ -88,6 +88,7 @@ main(void) #if HAS_SAMPLE_PROFILE ao_sample_profile_init(); #endif + ao_led_off(LEDS_AVAILABLE); ao_start_scheduler(); return 0; diff --git a/src/telepyro-v0.1/Makefile b/src/telepyro-v0.1/Makefile index dcac03dc..9b51d466 100644 --- a/src/telepyro-v0.1/Makefile +++ b/src/telepyro-v0.1/Makefile @@ -29,7 +29,7 @@ ALTOS_SRC = \ ao_stdio.c \ ao_task.c \ ao_timer.c \ - ao_led.c \ + ao_led_avr.c \ ao_avr_stdio.c \ ao_romconfig.c \ ao_usb_avr.c \ diff --git a/src/telescience-pwm/Makefile b/src/telescience-pwm/Makefile index 493bd480..10c63d49 100644 --- a/src/telescience-pwm/Makefile +++ b/src/telescience-pwm/Makefile @@ -42,7 +42,7 @@ ALTOS_SRC = \ ao_stdio.c \ ao_task.c \ ao_timer.c \ - ao_led.c \ + ao_led_avr.c \ ao_avr_stdio.c \ ao_romconfig.c \ ao_usb_avr.c \ diff --git a/src/telescience-v0.1/Makefile b/src/telescience-v0.1/Makefile index c55c48e2..8445c64d 100644 --- a/src/telescience-v0.1/Makefile +++ b/src/telescience-v0.1/Makefile @@ -42,7 +42,7 @@ ALTOS_SRC = \ ao_stdio.c \ ao_task.c \ ao_timer.c \ - ao_led.c \ + ao_led_avr.c \ ao_avr_stdio.c \ ao_romconfig.c \ ao_usb_avr.c \ diff --git a/src/telescience-v0.2/Makefile b/src/telescience-v0.2/Makefile index 6b7ea8c7..bc0a1986 100644 --- a/src/telescience-v0.2/Makefile +++ b/src/telescience-v0.2/Makefile @@ -35,7 +35,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/tmgps-v2.0/Makefile b/src/tmgps-v2.0/Makefile index 9e3965c6..8a1293d2 100644 --- a/src/tmgps-v2.0/Makefile +++ b/src/tmgps-v2.0/Makefile @@ -46,7 +46,7 @@ ALTOS_SRC = \ ao_cmd.c \ ao_config.c \ ao_task.c \ - ao_led.c \ + ao_led_stm.c \ ao_stdio.c \ ao_panic.c \ ao_timer.c \ diff --git a/src/usbtrng-v2.0/Makefile b/src/usbtrng-v2.0/Makefile index 49798f1c..678a24de 100644 --- a/src/usbtrng-v2.0/Makefile +++ b/src/usbtrng-v2.0/Makefile @@ -27,7 +27,7 @@ ALTOS_SRC = \ ao_adc_fast.c \ ao_crc_stm.c \ ao_stdio.c \ - ao_led.c \ + ao_led_stmf0.c \ ao_romconfig.c \ ao_boot_chain.c \ ao_cmd.c \ -- cgit v1.2.3 From dbc52686c6d9808275c35e0c9c987cbbd9f7859d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 13 Oct 2018 13:42:34 -0700 Subject: altos/stm: Make beeper driver support all possible tim234 configs And update all users to be explicit about the desired config. Signed-off-by: Keith Packard --- src/easymega-v1.0/ao_pins.h | 4 + src/easymega-v2.0/ao_pins.h | 4 + src/stm/ao_beep_stm.c | 166 +++++++++++++++++++------------------- src/stm/stm32l.h | 15 ++-- src/teleballoon-v2.0/ao_pins.h | 3 + src/telefireeight-v1.0/ao_pins.h | 4 + src/telefireone-v1.0/ao_pins.h | 1 + src/telefiretwo-v0.2/ao_pins.h | 1 + src/telelco-v0.2-cc1200/ao_pins.h | 4 + src/telelco-v0.2/ao_pins.h | 4 + src/telelco-v0.3/ao_pins.h | 4 + src/telelco-v2.0/ao_pins.h | 4 + src/telelcotwo-v0.1/ao_pins.h | 3 + src/telemega-v0.1/ao_pins.h | 4 + src/telemega-v1.0/ao_pins.h | 4 + src/telemega-v2.0/ao_pins.h | 4 + src/telemega-v3.0/ao_pins.h | 4 + src/telemetrum-v2.0/ao_pins.h | 3 + src/telemetrum-v3.0/ao_pins.h | 3 + src/telemini-v3.0/ao_pins.h | 4 +- 20 files changed, 150 insertions(+), 93 deletions(-) (limited to 'src/easymega-v1.0') diff --git a/src/easymega-v1.0/ao_pins.h b/src/easymega-v1.0/ao_pins.h index e7382e4b..bfa777c6 100644 --- a/src/easymega-v1.0/ao_pins.h +++ b/src/easymega-v1.0/ao_pins.h @@ -77,6 +77,10 @@ #define USE_STORAGE_CONFIG 0 #define HAS_USB 1 #define HAS_BEEP 1 +#define BEEPER_TIMER 3 +#define BEEPER_CHANNEL 1 +#define BEEPER_PORT (&stm_gpioc) +#define BEEPER_PIN 6 #define HAS_BATTERY_REPORT 1 #define HAS_RADIO 0 #define HAS_TELEMETRY 0 diff --git a/src/easymega-v2.0/ao_pins.h b/src/easymega-v2.0/ao_pins.h index aff06cdd..508c043c 100644 --- a/src/easymega-v2.0/ao_pins.h +++ b/src/easymega-v2.0/ao_pins.h @@ -77,6 +77,10 @@ #define USE_STORAGE_CONFIG 0 #define HAS_USB 1 #define HAS_BEEP 1 +#define BEEPER_TIMER 2 +#define BEEPER_CHANNEL 3 +#define BEEPER_PORT (&stm_gpioa) +#define BEEPER_PIN 2 #define HAS_BATTERY_REPORT 1 #define HAS_RADIO 0 #define HAS_TELEMETRY 0 diff --git a/src/stm/ao_beep_stm.c b/src/stm/ao_beep_stm.c index f9fa14c2..2746d7f8 100644 --- a/src/stm/ao_beep_stm.c +++ b/src/stm/ao_beep_stm.c @@ -18,37 +18,59 @@ #include "ao.h" -#ifndef BEEPER_CHANNEL -#define BEEPER_CHANNEL 1 +#if BEEPER_TIMER == 2 +#define stm_beeper stm_tim2 +#define RCC_BEEPER STM_RCC_APB1ENR_TIM2EN +#define BEEPER_AFR STM_AFR_AF1 +#elif BEEPER_TIMER == 3 +#define stm_beeper stm_tim3 +#define RCC_BEEPER STM_RCC_APB1ENR_TIM3EN +#define BEEPER_AFR STM_AFR_AF2 +#elif BEEPER_TIMER == 4 +#define stm_beeper stm_tim4 +#define RCC_BEEPER STM_RCC_APB1ENR_TIM4EN +#define BEEPER_AFR STM_AFR_AF2 +#else +#error BEEPER_TIMER must be 2, 3 or 4 #endif void ao_beep(uint8_t beep) { if (beep == 0) { - stm_tim3.cr1 = 0; - stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_TIM3EN); + stm_beeper.cr1 = 0; + stm_rcc.apb1enr &= ~(1 << RCC_BEEPER); } else { - stm_rcc.apb1enr |= (1 << STM_RCC_APB1ENR_TIM3EN); + stm_rcc.apb1enr |= (1 << RCC_BEEPER); - stm_tim3.cr2 = ((0 << STM_TIM234_CR2_TI1S) | + stm_beeper.cr2 = ((0 << STM_TIM234_CR2_TI1S) | (STM_TIM234_CR2_MMS_RESET << STM_TIM234_CR2_MMS) | (0 << STM_TIM234_CR2_CCDS)); /* Set prescaler to match cc1111 clocks */ - stm_tim3.psc = AO_TIM23467_CLK / 750000; + stm_beeper.psc = AO_TIM23467_CLK / 750000; /* 1. Select the counter clock (internal, external, prescaler). * * Setting SMCR to zero means use the internal clock */ - stm_tim3.smcr = 0; + stm_beeper.smcr = 0; /* 2. Write the desired data in the TIMx_ARR and TIMx_CCRx registers. */ - stm_tim3.arr = beep; - stm_tim3.ccr1 = beep; + stm_beeper.arr = beep; +#if BEEPER_CHANNEL == 1 + stm_beeper.ccr1 = beep; +#elif BEEPER_CHANNEL == 2 + stm_beeper.ccr2 = beep; +#elif BEEPER_CHANNEL == 3 + stm_beeper.ccr3 = beep; +#elif BEEPER_CHANNEL == 4 + stm_beeper.ccr4 = beep; +#else +#error invalid BEEPER_CHANNEL +#endif /* 3. Set the CCxIE and/or CCxDE bits if an interrupt and/or a * DMA request is to be generated. @@ -61,63 +83,56 @@ ao_beep(uint8_t beep) * is enabled and active high. */ -#if BEEPER_CHANNEL == 1 - stm_tim3.ccmr1 = ((0 << STM_TIM234_CCMR1_OC2CE) | - (STM_TIM234_CCMR1_OC2M_FROZEN << STM_TIM234_CCMR1_OC2M) | - (0 << STM_TIM234_CCMR1_OC2PE) | - (0 << STM_TIM234_CCMR1_OC2FE) | - (STM_TIM234_CCMR1_CC2S_OUTPUT << STM_TIM234_CCMR1_CC2S) | - - (0 << STM_TIM234_CCMR1_OC1CE) | - (STM_TIM234_CCMR1_OC1M_TOGGLE << STM_TIM234_CCMR1_OC1M) | - (0 << STM_TIM234_CCMR1_OC1PE) | - (0 << STM_TIM234_CCMR1_OC1FE) | - (STM_TIM234_CCMR1_CC1S_OUTPUT << STM_TIM234_CCMR1_CC1S)); - - stm_tim3.ccer = ((0 << STM_TIM234_CCER_CC4NP) | - (0 << STM_TIM234_CCER_CC4P) | - (0 << STM_TIM234_CCER_CC4E) | - (0 << STM_TIM234_CCER_CC3NP) | - (0 << STM_TIM234_CCER_CC3P) | - (0 << STM_TIM234_CCER_CC3E) | - (0 << STM_TIM234_CCER_CC2NP) | - (0 << STM_TIM234_CCER_CC2P) | - (0 << STM_TIM234_CCER_CC2E) | - (0 << STM_TIM234_CCER_CC1NP) | - (0 << STM_TIM234_CCER_CC1P) | - (1 << STM_TIM234_CCER_CC1E)); +#define OC1M (BEEPER_CHANNEL == 1 ? STM_TIM234_CCMR1_OC1M_TOGGLE : STM_TIM234_CCMR1_OC1M_FROZEN) +#define OC2M (BEEPER_CHANNEL == 2 ? STM_TIM234_CCMR1_OC2M_TOGGLE : STM_TIM234_CCMR1_OC2M_FROZEN) +#define OC3M (BEEPER_CHANNEL == 3 ? STM_TIM234_CCMR2_OC3M_TOGGLE : STM_TIM234_CCMR2_OC3M_FROZEN) +#define OC4M (BEEPER_CHANNEL == 4 ? STM_TIM234_CCMR2_OC4M_TOGGLE : STM_TIM234_CCMR2_OC4M_FROZEN) + +#define CCER(n) (BEEPER_CHANNEL == (n) ? 1 : 0) + +#if BEEPER_CHANNEL == 1 || BEEPER_CHANNEL == 2 + stm_beeper.ccmr1 = ((0 << STM_TIM234_CCMR1_OC2CE) | + (OC2M << STM_TIM234_CCMR1_OC2M) | + (0 << STM_TIM234_CCMR1_OC2PE) | + (0 << STM_TIM234_CCMR1_OC2FE) | + (STM_TIM234_CCMR1_CC2S_OUTPUT << STM_TIM234_CCMR1_CC2S) | + + (0 << STM_TIM234_CCMR1_OC1CE) | + (OC1M << STM_TIM234_CCMR1_OC1M) | + (0 << STM_TIM234_CCMR1_OC1PE) | + (0 << STM_TIM234_CCMR1_OC1FE) | + (STM_TIM234_CCMR1_CC1S_OUTPUT << STM_TIM234_CCMR1_CC1S)); +#elif BEEPER_CHANNEL == 3 || BEEPER_CHANNEL == 4 + stm_beeper.ccmr2 = ((0 << STM_TIM234_CCMR2_OC4CE) | + (OC4M << STM_TIM234_CCMR2_OC4M) | + (0 << STM_TIM234_CCMR2_OC4PE) | + (0 << STM_TIM234_CCMR2_OC4FE) | + (STM_TIM234_CCMR2_CC4S_OUTPUT << STM_TIM234_CCMR2_CC4S) | + + (0 << STM_TIM234_CCMR2_OC3CE) | + (OC3M << STM_TIM234_CCMR2_OC3M) | + (0 << STM_TIM234_CCMR2_OC3PE) | + (0 << STM_TIM234_CCMR2_OC3FE) | + (STM_TIM234_CCMR2_CC3S_OUTPUT << STM_TIM234_CCMR2_CC3S)); +#else +#error invalid BEEPER_CHANNEL #endif -#if BEEPER_CHANNEL == 4 - stm_tim3.ccmr2 = ((0 << STM_TIM234_CCMR2_OC4CE) | - (STM_TIM234_CCMR2_OC4M_TOGGLE << STM_TIM234_CCMR2_OC4M) | - (0 << STM_TIM234_CCMR2_OC4PE) | - (0 << STM_TIM234_CCMR2_OC4FE) | - (STM_TIM234_CCMR2_CC4S_OUTPUT << STM_TIM234_CCMR2_CC4S) | - - (0 << STM_TIM234_CCMR2_OC3CE) | - (STM_TIM234_CCMR2_OC3M_FROZEN << STM_TIM234_CCMR2_OC3M) | - (0 << STM_TIM234_CCMR2_OC3PE) | - (0 << STM_TIM234_CCMR2_OC3FE) | - (STM_TIM234_CCMR2_CC3S_OUTPUT << STM_TIM234_CCMR2_CC3S)); - - stm_tim3.ccer = ((0 << STM_TIM234_CCER_CC4NP) | - (0 << STM_TIM234_CCER_CC4P) | - (1 << STM_TIM234_CCER_CC4E) | - (0 << STM_TIM234_CCER_CC3NP) | - (0 << STM_TIM234_CCER_CC3P) | - (0 << STM_TIM234_CCER_CC3E) | - (0 << STM_TIM234_CCER_CC2NP) | - (0 << STM_TIM234_CCER_CC2P) | - (0 << STM_TIM234_CCER_CC2E) | - (0 << STM_TIM234_CCER_CC1NP) | - (0 << STM_TIM234_CCER_CC1P) | - (0 << STM_TIM234_CCER_CC1E)); -#endif - + stm_beeper.ccer = ((0 << STM_TIM234_CCER_CC4NP) | + (0 << STM_TIM234_CCER_CC4P) | + (CCER(4) << STM_TIM234_CCER_CC4E) | + (0 << STM_TIM234_CCER_CC3NP) | + (0 << STM_TIM234_CCER_CC3P) | + (CCER(3) << STM_TIM234_CCER_CC3E) | + (0 << STM_TIM234_CCER_CC2NP) | + (0 << STM_TIM234_CCER_CC2P) | + (CCER(2) << STM_TIM234_CCER_CC2E) | + (0 << STM_TIM234_CCER_CC1NP) | + (0 << STM_TIM234_CCER_CC1P) | + (CCER(1) << STM_TIM234_CCER_CC1E)); /* 5. Enable the counter by setting the CEN bit in the TIMx_CR1 register. */ - stm_tim3.cr1 = ((STM_TIM234_CR1_CKD_1 << STM_TIM234_CR1_CKD) | + stm_beeper.cr1 = ((STM_TIM234_CR1_CKD_1 << STM_TIM234_CR1_CKD) | (0 << STM_TIM234_CR1_ARPE) | (STM_TIM234_CR1_CMS_EDGE << STM_TIM234_CR1_CMS) | (0 << STM_TIM234_CR1_DIR) | @@ -127,12 +142,12 @@ ao_beep(uint8_t beep) (1 << STM_TIM234_CR1_CEN)); /* Update the values */ - stm_tim3.egr = (1 << STM_TIM234_EGR_UG); + stm_beeper.egr = (1 << STM_TIM234_EGR_UG); } } void -ao_beep_for(uint8_t beep, uint16_t ticks) +ao_beep_for(uint8_t beep, uint16_t ticks) { ao_beep(beep); ao_delay(ticks); @@ -142,24 +157,9 @@ ao_beep_for(uint8_t beep, uint16_t ticks) void ao_beep_init(void) { -#if BEEPER_CHANNEL == 1 - - /* Our beeper is on PC6, which is hooked to TIM3_CH1. - */ - stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_GPIOCEN); - - stm_afr_set(&stm_gpioc, 6, STM_AFR_AF2); -#endif -#if BEEPER_CHANNEL == 4 - - /* Our beeper is on PB1, which is hooked to TIM3_CH4. - */ - stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_GPIOBEN); - - stm_afr_set(&stm_gpiob, 1, STM_AFR_AF2); -#endif + ao_enable_port(BEEPER_PORT); + stm_afr_set(BEEPER_PORT, BEEPER_PIN, BEEPER_AFR); /* Leave the timer off until requested */ - - stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_TIM3EN); + stm_rcc.apb1enr &= ~(1 << RCC_BEEPER); } diff --git a/src/stm/stm32l.h b/src/stm/stm32l.h index 1da817e7..0109ec81 100644 --- a/src/stm/stm32l.h +++ b/src/stm/stm32l.h @@ -241,15 +241,14 @@ stm_gpio_get_all(struct stm_gpio *gpio) { * ao_enable_gpio macro will expand into a huge pile of code * as the compiler won't do correct constant folding and * dead-code elimination + */ - extern struct stm_gpio stm_gpioa; - extern struct stm_gpio stm_gpiob; - extern struct stm_gpio stm_gpioc; - extern struct stm_gpio stm_gpiod; - extern struct stm_gpio stm_gpioe; - extern struct stm_gpio stm_gpioh; - -*/ +extern struct stm_gpio stm_gpioa; +extern struct stm_gpio stm_gpiob; +extern struct stm_gpio stm_gpioc; +extern struct stm_gpio stm_gpiod; +extern struct stm_gpio stm_gpioe; +extern struct stm_gpio stm_gpioh; #define stm_gpioh (*((struct stm_gpio *) 0x40021400)) #define stm_gpioe (*((struct stm_gpio *) 0x40021000)) diff --git a/src/teleballoon-v2.0/ao_pins.h b/src/teleballoon-v2.0/ao_pins.h index 4f27bad6..cb0ec838 100644 --- a/src/teleballoon-v2.0/ao_pins.h +++ b/src/teleballoon-v2.0/ao_pins.h @@ -74,6 +74,9 @@ #define HAS_BEEP 1 #define HAS_BATTERY_REPORT 1 #define BEEPER_CHANNEL 4 +#define BEEPER_TIMER 3 +#define BEEPER_PORT (&stm_gpiob) +#define BEEPER_PIN 1 #define HAS_RADIO 1 #define HAS_TELEMETRY 1 #define HAS_APRS 1 diff --git a/src/telefireeight-v1.0/ao_pins.h b/src/telefireeight-v1.0/ao_pins.h index ef533b36..c15e06bf 100644 --- a/src/telefireeight-v1.0/ao_pins.h +++ b/src/telefireeight-v1.0/ao_pins.h @@ -25,6 +25,10 @@ #define HAS_FLIGHT 0 #define HAS_USB 1 #define HAS_BEEP 0 +#define BEEPER_TIMER 3 +#define BEEPER_CHANNEL 1 +#define BEEPER_PORT (&stm_gpioc) +#define BEEPER_PIN 6 #define HAS_GPS 0 #define HAS_SERIAL_1 0 #define HAS_ADC 1 diff --git a/src/telefireone-v1.0/ao_pins.h b/src/telefireone-v1.0/ao_pins.h index d36d9d82..15b158ef 100644 --- a/src/telefireone-v1.0/ao_pins.h +++ b/src/telefireone-v1.0/ao_pins.h @@ -27,6 +27,7 @@ #define HAS_USB 1 #define HAS_BEEP 1 #define BEEPER_CHANNEL 4 +#define BEEPER_TIMER 3 #define HAS_GPS 0 #define HAS_SERIAL_1 0 #define HAS_ADC 1 diff --git a/src/telefiretwo-v0.2/ao_pins.h b/src/telefiretwo-v0.2/ao_pins.h index 469e9937..01faace2 100644 --- a/src/telefiretwo-v0.2/ao_pins.h +++ b/src/telefiretwo-v0.2/ao_pins.h @@ -27,6 +27,7 @@ #define HAS_USB 1 #define HAS_BEEP 1 #define BEEPER_CHANNEL 4 +#define BEEPER_TIMER 3 #define HAS_GPS 0 #define HAS_SERIAL_1 0 #define HAS_ADC 1 diff --git a/src/telelco-v0.2-cc1200/ao_pins.h b/src/telelco-v0.2-cc1200/ao_pins.h index bc325e06..f3850ebd 100644 --- a/src/telelco-v0.2-cc1200/ao_pins.h +++ b/src/telelco-v0.2-cc1200/ao_pins.h @@ -50,6 +50,10 @@ #define USE_STORAGE_CONFIG 0 #define HAS_USB 1 #define HAS_BEEP 1 +#define BEEPER_TIMER 3 +#define BEEPER_CHANNEL 1 +#define BEEPER_PORT (&stm_gpioc) +#define BEEPER_PIN 6 #define HAS_RADIO 1 #define HAS_RADIO_RATE 1 #define HAS_TELEMETRY 0 diff --git a/src/telelco-v0.2/ao_pins.h b/src/telelco-v0.2/ao_pins.h index f0da4fe4..3d06a647 100644 --- a/src/telelco-v0.2/ao_pins.h +++ b/src/telelco-v0.2/ao_pins.h @@ -48,6 +48,10 @@ #define USE_STORAGE_CONFIG 0 #define HAS_USB 1 #define HAS_BEEP 1 +#define BEEPER_TIMER 3 +#define BEEPER_CHANNEL 1 +#define BEEPER_PORT (&stm_gpioc) +#define BEEPER_PIN 6 #define HAS_RADIO 1 #define HAS_RADIO_RATE 1 #define HAS_TELEMETRY 0 diff --git a/src/telelco-v0.3/ao_pins.h b/src/telelco-v0.3/ao_pins.h index 6023739c..c806268f 100644 --- a/src/telelco-v0.3/ao_pins.h +++ b/src/telelco-v0.3/ao_pins.h @@ -50,6 +50,10 @@ #define USE_STORAGE_CONFIG 0 #define HAS_USB 1 #define HAS_BEEP 1 +#define BEEPER_TIMER 3 +#define BEEPER_CHANNEL 1 +#define BEEPER_PORT (&stm_gpioc) +#define BEEPER_PIN 6 #define HAS_RADIO 1 #define HAS_RADIO_RATE 1 #define HAS_TELEMETRY 0 diff --git a/src/telelco-v2.0/ao_pins.h b/src/telelco-v2.0/ao_pins.h index ea709c1d..e0663314 100644 --- a/src/telelco-v2.0/ao_pins.h +++ b/src/telelco-v2.0/ao_pins.h @@ -50,6 +50,10 @@ #define USE_STORAGE_CONFIG 0 #define HAS_USB 1 #define HAS_BEEP 1 +#define BEEPER_TIMER 3 +#define BEEPER_CHANNEL 1 +#define BEEPER_PORT (&stm_gpioc) +#define BEEPER_PIN 6 #define HAS_RADIO 1 #define HAS_RADIO_RATE 1 #define HAS_TELEMETRY 0 diff --git a/src/telelcotwo-v0.1/ao_pins.h b/src/telelcotwo-v0.1/ao_pins.h index 1941e03d..3ef88c74 100644 --- a/src/telelcotwo-v0.1/ao_pins.h +++ b/src/telelcotwo-v0.1/ao_pins.h @@ -51,6 +51,9 @@ #define HAS_USB 1 #define HAS_BEEP 1 #define BEEPER_CHANNEL 4 +#define BEEPER_TIMER 3 +#define BEEPER_PORT (&stm_gpiob) +#define BEEPER_PIN 1 #define HAS_RADIO 1 #define HAS_RADIO_RATE 1 #define HAS_TELEMETRY 0 diff --git a/src/telemega-v0.1/ao_pins.h b/src/telemega-v0.1/ao_pins.h index 64535c30..0208fafa 100644 --- a/src/telemega-v0.1/ao_pins.h +++ b/src/telemega-v0.1/ao_pins.h @@ -77,6 +77,10 @@ #define USE_STORAGE_CONFIG 0 #define HAS_USB 1 #define HAS_BEEP 1 +#define BEEPER_TIMER 3 +#define BEEPER_CHANNEL 1 +#define BEEPER_PORT (&stm_gpioc) +#define BEEPER_PIN 6 #define HAS_BATTERY_REPORT 1 #define HAS_RADIO 1 #define HAS_TELEMETRY 1 diff --git a/src/telemega-v1.0/ao_pins.h b/src/telemega-v1.0/ao_pins.h index 354da6a4..a154225e 100644 --- a/src/telemega-v1.0/ao_pins.h +++ b/src/telemega-v1.0/ao_pins.h @@ -77,6 +77,10 @@ #define USE_STORAGE_CONFIG 0 #define HAS_USB 1 #define HAS_BEEP 1 +#define BEEPER_TIMER 3 +#define BEEPER_CHANNEL 1 +#define BEEPER_PORT (&stm_gpioc) +#define BEEPER_PIN 6 #define HAS_BATTERY_REPORT 1 #define HAS_RADIO 1 #define HAS_TELEMETRY 1 diff --git a/src/telemega-v2.0/ao_pins.h b/src/telemega-v2.0/ao_pins.h index 46207884..ba302c74 100644 --- a/src/telemega-v2.0/ao_pins.h +++ b/src/telemega-v2.0/ao_pins.h @@ -77,6 +77,10 @@ #define USE_STORAGE_CONFIG 0 #define HAS_USB 1 #define HAS_BEEP 1 +#define BEEPER_TIMER 3 +#define BEEPER_CHANNEL 1 +#define BEEPER_PORT (&stm_gpioc) +#define BEEPER_PIN 6 #define HAS_BATTERY_REPORT 1 #define HAS_RADIO 1 #define HAS_TELEMETRY 1 diff --git a/src/telemega-v3.0/ao_pins.h b/src/telemega-v3.0/ao_pins.h index ddcd0eb9..ce223907 100644 --- a/src/telemega-v3.0/ao_pins.h +++ b/src/telemega-v3.0/ao_pins.h @@ -77,6 +77,10 @@ #define USE_STORAGE_CONFIG 0 #define HAS_USB 1 #define HAS_BEEP 1 +#define BEEPER_TIMER 3 +#define BEEPER_CHANNEL 1 +#define BEEPER_PORT (&stm_gpioc) +#define BEEPER_PIN 6 #define HAS_BATTERY_REPORT 1 #define HAS_RADIO 1 #define HAS_TELEMETRY 1 diff --git a/src/telemetrum-v2.0/ao_pins.h b/src/telemetrum-v2.0/ao_pins.h index 47f6dd2a..e8c97ff4 100644 --- a/src/telemetrum-v2.0/ao_pins.h +++ b/src/telemetrum-v2.0/ao_pins.h @@ -74,6 +74,9 @@ #define HAS_BEEP 1 #define HAS_BATTERY_REPORT 1 #define BEEPER_CHANNEL 4 +#define BEEPER_TIMER 3 +#define BEEPER_PORT (&stm_gpiob) +#define BEEPER_PIN 1 #define HAS_RADIO 1 #define HAS_TELEMETRY 1 #define HAS_APRS 1 diff --git a/src/telemetrum-v3.0/ao_pins.h b/src/telemetrum-v3.0/ao_pins.h index a8043bba..f4ccc9f3 100644 --- a/src/telemetrum-v3.0/ao_pins.h +++ b/src/telemetrum-v3.0/ao_pins.h @@ -74,6 +74,9 @@ #define HAS_BEEP 1 #define HAS_BATTERY_REPORT 1 #define BEEPER_CHANNEL 4 +#define BEEPER_TIMER 3 +#define BEEPER_PORT (&stm_gpiob) +#define BEEPER_PIN 1 #define HAS_RADIO 1 #define HAS_TELEMETRY 1 #define HAS_APRS 1 diff --git a/src/telemini-v3.0/ao_pins.h b/src/telemini-v3.0/ao_pins.h index 546d91e0..d91b1d21 100644 --- a/src/telemini-v3.0/ao_pins.h +++ b/src/telemini-v3.0/ao_pins.h @@ -74,9 +74,9 @@ #define AO_RECOVERY_VALUE 0 #define AO_RECOVERY_MODE AO_EXTI_MODE_PULL_UP -/* Beeper is on Tim1 CH3 */ +/* Beeper is on Tim3 CH4 */ #define BEEPER_CHANNEL 4 -#define BEEPER_TIMER 2 +#define BEEPER_TIMER 3 #define BEEPER_PORT (&stm_gpioa) #define BEEPER_PIN 3 -- cgit v1.2.3