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/kernel/ao.h | 9 +++++++++ src/kernel/ao_stdio.c | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/ao.h b/src/kernel/ao.h index 0a3981d7..204eaae7 100644 --- a/src/kernel/ao.h +++ b/src/kernel/ao.h @@ -26,6 +26,15 @@ #include #include +/* replace stdio macros with direct calls to our functions */ +#undef putchar +#undef getchar +#define putchar(c) ao_putchar(c) +#define getchar ao_getchar + +extern int ao_putchar(char c); +extern char ao_getchar(void); + #define TRUE 1 #define FALSE 0 diff --git a/src/kernel/ao_stdio.c b/src/kernel/ao_stdio.c index dc09b5c7..227499c8 100644 --- a/src/kernel/ao_stdio.c +++ b/src/kernel/ao_stdio.c @@ -83,7 +83,7 @@ __pdata int8_t ao_cur_stdio; #define ao_num_stdios 0 #endif -void +int ao_putchar(char c) { #if LOW_LEVEL_DEBUG @@ -92,12 +92,13 @@ ao_putchar(char c) if (c == '\n') ao_debug_out('\r'); ao_debug_out(c); - return; + return 0; } #endif if (c == '\n') (*ao_stdios[ao_cur_stdio].putchar)('\r'); (*ao_stdios[ao_cur_stdio].putchar)(c); + return 0; } void @@ -158,3 +159,33 @@ ao_add_stdio(int (*_pollchar)(void), return 0; #endif } + +/* + * Basic I/O functions to support newlib tinystdio package + */ + +static int +ao_putc(char c, FILE *ignore) +{ + (void) ignore; + return ao_putchar(c); +} + +static int +ao_getc(FILE *ignore) +{ + (void) ignore; + return ao_getchar(); +} + +static int +ao_flushc(FILE *ignore) +{ + (void) ignore; + flush(); + return 0; +} + +static FILE __stdio = FDEV_SETUP_STREAM(ao_putc, ao_getc, ao_flushc, _FDEV_SETUP_RW); + +FILE *const __iob[3] = { &__stdio, &__stdio, &__stdio }; -- cgit v1.2.3 From 6023ff81f1bbd240169b9548209133d3b02d475f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 15 Aug 2018 17:34:20 -0700 Subject: altos: Remove *_TO_DATA macros Now that we don't support 8051, we don't need these Signed-off-by: Keith Packard --- src/drivers/ao_companion.c | 2 +- src/drivers/ao_gps_skytraq.c | 4 ++-- src/drivers/ao_ms5607.c | 6 +++--- src/drivers/ao_packet.c | 2 +- src/drivers/ao_pad.c | 2 +- src/kernel/ao.h | 11 ----------- src/kernel/ao_balloon.c | 4 ++-- src/kernel/ao_config.c | 6 +++--- src/kernel/ao_data.h | 4 +--- src/kernel/ao_flight.c | 16 ++++++++-------- src/kernel/ao_flight_nano.c | 6 +++--- src/kernel/ao_forward.c | 2 +- src/kernel/ao_host.h | 6 +++--- src/kernel/ao_log_telem.c | 4 ++-- src/kernel/ao_log_tiny.c | 4 ++-- src/kernel/ao_monitor.c | 16 ++++++++-------- src/kernel/ao_report.c | 4 ++-- src/kernel/ao_sample.c | 4 ++-- src/kernel/ao_telemetry.c | 2 +- src/product/ao_terraui.c | 2 +- src/test/ao_flight_test.c | 2 +- 21 files changed, 48 insertions(+), 61 deletions(-) (limited to 'src/kernel') diff --git a/src/drivers/ao_companion.c b/src/drivers/ao_companion.c index f82558a3..598b5815 100644 --- a/src/drivers/ao_companion.c +++ b/src/drivers/ao_companion.c @@ -107,7 +107,7 @@ ao_companion(void) break; } while (ao_companion_running) { - if (ao_sleep_for(DATA_TO_XDATA(&ao_flight_state), ao_companion_setup.update_period)) + if (ao_sleep_for(&ao_flight_state, ao_companion_setup.update_period)) ao_companion_get_data(); else ao_companion_notify(); diff --git a/src/drivers/ao_gps_skytraq.c b/src/drivers/ao_gps_skytraq.c index c483382e..3ecae435 100644 --- a/src/drivers/ao_gps_skytraq.c +++ b/src/drivers/ao_gps_skytraq.c @@ -298,7 +298,7 @@ ao_nmea_gga(void) ao_mutex_get(&ao_gps_mutex); ao_gps_new |= AO_GPS_NEW_DATA; ao_gps_tick = ao_gps_next_tick; - ao_xmemcpy(&ao_gps_data, PDATA_TO_XDATA(&ao_gps_next), sizeof (ao_gps_data)); + ao_xmemcpy(&ao_gps_data, &ao_gps_next, sizeof (ao_gps_data)); ao_mutex_put(&ao_gps_mutex); ao_wakeup(&ao_gps_new); } @@ -357,7 +357,7 @@ ao_nmea_gsv(void) else if (done) { ao_mutex_get(&ao_gps_mutex); ao_gps_new |= AO_GPS_NEW_TRACKING; - ao_xmemcpy(&ao_gps_tracking_data, PDATA_TO_XDATA(&ao_gps_tracking_next), sizeof(ao_gps_tracking_data)); + ao_xmemcpy(&ao_gps_tracking_data, &ao_gps_tracking_next, sizeof(ao_gps_tracking_data)); ao_mutex_put(&ao_gps_mutex); ao_wakeup(&ao_gps_new); } diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c index 53ed992a..4bfc17db 100644 --- a/src/drivers/ao_ms5607.c +++ b/src/drivers/ao_ms5607.c @@ -45,7 +45,7 @@ ao_ms5607_reset(void) { cmd = AO_MS5607_RESET; ao_ms5607_start(); - ao_spi_send(DATA_TO_XDATA(&cmd), 1, AO_MS5607_SPI_INDEX); + ao_spi_send(&cmd, 1, AO_MS5607_SPI_INDEX); ao_delay(AO_MS_TO_TICKS(10)); ao_ms5607_stop(); } @@ -106,7 +106,7 @@ ao_ms5607_prom_read(__xdata struct ao_ms5607_prom *prom) for (addr = 0; addr < 8; addr++) { uint8_t cmd = AO_MS5607_PROM_READ(addr); ao_ms5607_start(); - ao_spi_send(DATA_TO_XDATA(&cmd), 1, AO_MS5607_SPI_INDEX); + ao_spi_send(&cmd, 1, AO_MS5607_SPI_INDEX); ao_spi_recv(r, 2, AO_MS5607_SPI_INDEX); ao_ms5607_stop(); r++; @@ -156,7 +156,7 @@ ao_ms5607_get_sample(uint8_t cmd) { ao_ms5607_done = 0; ao_ms5607_start(); - ao_spi_send(DATA_TO_XDATA(&cmd), 1, AO_MS5607_SPI_INDEX); + ao_spi_send(&cmd, 1, AO_MS5607_SPI_INDEX); ao_exti_enable(AO_MS5607_MISO_PORT, AO_MS5607_MISO_PIN); diff --git a/src/drivers/ao_packet.c b/src/drivers/ao_packet.c index 008af5db..1c931921 100644 --- a/src/drivers/ao_packet.c +++ b/src/drivers/ao_packet.c @@ -91,7 +91,7 @@ ao_packet_recv(uint16_t timeout) if (ao_xmemcmp(ao_rx_packet.packet.callsign, ao_config.callsign, AO_MAX_CALLSIGN) != 0 && - ao_xmemcmp(ao_config.callsign, CODE_TO_XDATA("N0CALL"), 7) != 0) + ao_xmemcmp(ao_config.callsign, "N0CALL", 7) != 0) return 0; /* SYN packets carry no data */ diff --git a/src/drivers/ao_pad.c b/src/drivers/ao_pad.c index c6efc311..208841fb 100644 --- a/src/drivers/ao_pad.c +++ b/src/drivers/ao_pad.c @@ -203,7 +203,7 @@ ao_pad_monitor(void) ao_arch_critical( while (sample == ao_data_head) - ao_sleep((void *) DATA_TO_XDATA(&ao_data_head)); + ao_sleep((void *) &ao_data_head); ); diff --git a/src/kernel/ao.h b/src/kernel/ao.h index 204eaae7..520f6ef2 100644 --- a/src/kernel/ao.h +++ b/src/kernel/ao.h @@ -38,17 +38,6 @@ extern char ao_getchar(void); #define TRUE 1 #define FALSE 0 -/* Convert a __data pointer into an __xdata pointer */ -#ifndef DATA_TO_XDATA -#define DATA_TO_XDATA(a) (a) -#endif -#ifndef PDATA_TO_XDATA -#define PDATA_TO_XDATA(a) (a) -#endif -#ifndef CODE_TO_XDATA -#define CODE_TO_XDATA(a) (a) -#endif - #ifndef HAS_TASK #define HAS_TASK 1 #endif diff --git a/src/kernel/ao_balloon.c b/src/kernel/ao_balloon.c index 47b69e25..d0f80a5d 100644 --- a/src/kernel/ao_balloon.c +++ b/src/kernel/ao_balloon.c @@ -96,7 +96,7 @@ ao_flight(void) ao_led_off(AO_LED_RED); } /* wakeup threads due to state change */ - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); break; case ao_flight_pad: @@ -118,7 +118,7 @@ ao_flight(void) ao_wakeup(&ao_gps_new); #endif - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); } break; default: diff --git a/src/kernel/ao_config.c b/src/kernel/ao_config.c index 86d4838f..10a67116 100644 --- a/src/kernel/ao_config.c +++ b/src/kernel/ao_config.c @@ -135,7 +135,7 @@ _ao_config_get(void) /* Version 0 stuff */ ao_config.main_deploy = AO_CONFIG_DEFAULT_MAIN_DEPLOY; ao_xmemset(&ao_config.callsign, '\0', sizeof (ao_config.callsign)); - ao_xmemcpy(&ao_config.callsign, CODE_TO_XDATA(AO_CONFIG_DEFAULT_CALLSIGN), + ao_xmemcpy(&ao_config.callsign, AO_CONFIG_DEFAULT_CALLSIGN, sizeof(AO_CONFIG_DEFAULT_CALLSIGN) - 1); ao_config._legacy_radio_channel = 0; } @@ -246,7 +246,7 @@ _ao_config_get(void) #if HAS_RADIO_RATE ao_config.radio_rate = AO_CONFIG_DEFAULT_RADIO_RATE; #endif - ao_xmemcpy(&ao_config.callsign, CODE_TO_XDATA(AO_CONFIG_DEFAULT_CALLSIGN), + ao_xmemcpy(&ao_config.callsign, AO_CONFIG_DEFAULT_CALLSIGN, sizeof(AO_CONFIG_DEFAULT_CALLSIGN) - 1); } #endif @@ -421,7 +421,7 @@ ao_config_accel_calibrate_auto(char *orientation) __reentrant accel_total = 0; cal_data_ring = ao_sample_data; while (i) { - ao_sleep(DATA_TO_XDATA(&ao_sample_data)); + ao_sleep(&ao_sample_data); while (i && cal_data_ring != ao_sample_data) { accel_total += (int32_t) ao_data_accel(&ao_data_ring[cal_data_ring]); #if HAS_GYRO diff --git a/src/kernel/ao_data.h b/src/kernel/ao_data.h index 88d0e916..30616ef0 100644 --- a/src/kernel/ao_data.h +++ b/src/kernel/ao_data.h @@ -113,9 +113,7 @@ extern volatile __data uint8_t ao_data_count; * Wait until it is time to write a sensor sample; this is * signaled by the timer tick */ -#define AO_DATA_WAIT() do { \ - ao_sleep(DATA_TO_XDATA ((void *) &ao_data_count)); \ - } while (0) +#define AO_DATA_WAIT() ao_sleep((void *) &ao_data_count) #endif /* AO_DATA_RING */ diff --git a/src/kernel/ao_flight.c b/src/kernel/ao_flight.c index c2700d20..170396ff 100644 --- a/src/kernel/ao_flight.c +++ b/src/kernel/ao_flight.c @@ -175,7 +175,7 @@ ao_flight(void) #endif } /* wakeup threads due to state change */ - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); break; case ao_flight_pad: @@ -219,7 +219,7 @@ ao_flight(void) ao_wakeup(&ao_gps_new); #endif - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); } break; case ao_flight_boost: @@ -244,7 +244,7 @@ ao_flight(void) ao_flight_state = ao_flight_coast; #endif ++ao_motor_number; - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); } break; #if HAS_ACCEL @@ -257,7 +257,7 @@ ao_flight(void) if (ao_speed < AO_MS_TO_SPEED(AO_MAX_BARO_SPEED)) { ao_flight_state = ao_flight_coast; - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); } else goto check_re_boost; break; @@ -306,7 +306,7 @@ ao_flight(void) /* and enter drogue state */ ao_flight_state = ao_flight_drogue; - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); } #if HAS_ACCEL else { @@ -315,7 +315,7 @@ ao_flight(void) if (ao_coast_avg_accel > AO_MSS_TO_ACCEL(20)) { ao_boost_tick = ao_sample_tick; ao_flight_state = ao_flight_boost; - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); } } #endif @@ -352,7 +352,7 @@ ao_flight(void) ao_interval_min_height = ao_interval_max_height = ao_avg_height; ao_flight_state = ao_flight_main; - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); } break; @@ -379,7 +379,7 @@ ao_flight(void) ao_timer_set_adc_interval(0); #endif - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); } ao_interval_min_height = ao_interval_max_height = ao_avg_height; ao_interval_end = ao_sample_tick + AO_INTERVAL_TICKS; diff --git a/src/kernel/ao_flight_nano.c b/src/kernel/ao_flight_nano.c index d849dc64..797ea344 100644 --- a/src/kernel/ao_flight_nano.c +++ b/src/kernel/ao_flight_nano.c @@ -70,7 +70,7 @@ ao_flight_nano(void) ao_led_off(AO_LED_RED); /* wakeup threads due to state change */ - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); break; case ao_flight_pad: if (ao_height> AO_M_TO_HEIGHT(20)) { @@ -80,7 +80,7 @@ ao_flight_nano(void) /* start logging data */ ao_log_start(); - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); } break; case ao_flight_drogue: @@ -101,7 +101,7 @@ ao_flight_nano(void) /* turn off the ADC capture */ ao_timer_set_adc_interval(0); - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); } ao_interval_min_height = ao_interval_max_height = ao_height; ao_interval_end = ao_sample_tick + AO_INTERVAL_TICKS; diff --git a/src/kernel/ao_forward.c b/src/kernel/ao_forward.c index 721b52d0..b1ab3f54 100644 --- a/src/kernel/ao_forward.c +++ b/src/kernel/ao_forward.c @@ -27,7 +27,7 @@ ao_monitor_forward(void) for (;;) { while (ao_monitoring) - ao_sleep(DATA_TO_XDATA(&ao_monitoring)); + ao_sleep(&ao_monitoring); if (!ao_radio_recv(&packet, sizeof(packet), 0)) continue; diff --git a/src/kernel/ao_host.h b/src/kernel/ao_host.h index 50583f52..638dba99 100644 --- a/src/kernel/ao_host.h +++ b/src/kernel/ao_host.h @@ -47,9 +47,9 @@ struct ao_adc { #define __code #define __reentrant -#define DATA_TO_XDATA(a) (a) -#define PDATA_TO_XDATA(a) (a) -#define CODE_TO_XDATA(a) (a) +#define a (a) +#define a (a) +#define a (a) enum ao_flight_state { ao_flight_startup = 0, diff --git a/src/kernel/ao_log_telem.c b/src/kernel/ao_log_telem.c index 1305a84d..8969e029 100644 --- a/src/kernel/ao_log_telem.c +++ b/src/kernel/ao_log_telem.c @@ -50,7 +50,7 @@ ao_log_telem_track() { ao_flight_state = ao_log_single_write_data.telemetry.sensor.state; if (ao_flight_state == ao_flight_pad) ao_max_height = 0; - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); } } } @@ -111,7 +111,7 @@ ao_log_single(void) ao_log_telem_track(); } /* Wait for more telemetry data to arrive */ - ao_sleep(DATA_TO_XDATA(&ao_monitor_head)); + ao_sleep(&ao_monitor_head); } } } diff --git a/src/kernel/ao_log_tiny.c b/src/kernel/ao_log_tiny.c index 0b8e39d6..046b7b20 100644 --- a/src/kernel/ao_log_tiny.c +++ b/src/kernel/ao_log_tiny.c @@ -41,7 +41,7 @@ static void ao_log_tiny_data(uint16_t d) if (ao_log_current_pos >= ao_log_end_pos && ao_log_running) ao_log_stop(); if (ao_log_running) { - ao_storage_write(ao_log_current_pos, DATA_TO_XDATA(&d), 2); + ao_storage_write(ao_log_current_pos, &d, 2); ao_log_current_pos += 2; } } @@ -102,7 +102,7 @@ ao_log(void) /* * Add in pending sample data */ - ao_sleep(DATA_TO_XDATA(&ao_sample_data)); + ao_sleep(&ao_sample_data); while (ao_log_data != ao_sample_data) { sum += ao_data_pres(&ao_data_ring[ao_log_data]); count++; diff --git a/src/kernel/ao_monitor.c b/src/kernel/ao_monitor.c index 7cbee288..b9a39bfc 100644 --- a/src/kernel/ao_monitor.c +++ b/src/kernel/ao_monitor.c @@ -59,7 +59,7 @@ _ao_monitor_adjust(void) else ao_monitoring = ao_internal_monitoring; } - ao_wakeup(DATA_TO_XDATA(&ao_monitoring)); + ao_wakeup(&ao_monitoring); } void @@ -70,7 +70,7 @@ ao_monitor_get(void) for (;;) { switch (ao_monitoring) { case 0: - ao_sleep(DATA_TO_XDATA(&ao_monitoring)); + ao_sleep(&ao_monitoring); continue; #if LEGACY_MONITOR case AO_MONITORING_ORIG: @@ -86,7 +86,7 @@ ao_monitor_get(void) if (!ao_radio_recv(&ao_monitor_ring[ao_monitor_head], size + 2, 0)) continue; ao_monitor_head = ao_monitor_ring_next(ao_monitor_head); - ao_wakeup(DATA_TO_XDATA(&ao_monitor_head)); + ao_wakeup(&ao_monitor_head); } } @@ -100,7 +100,7 @@ ao_monitor_blink(void) uint8_t *recv; #endif for (;;) { - ao_sleep(DATA_TO_XDATA(&ao_monitor_head)); + ao_sleep(&ao_monitor_head); #ifdef AO_MONITOR_BAD recv = (uint8_t *) &ao_monitor_ring[ao_monitor_ring_prev(ao_monitor_head)]; if (ao_monitoring && !(recv[ao_monitoring + 1] & AO_RADIO_STATUS_CRC_OK)) @@ -142,9 +142,9 @@ ao_monitor_put(void) ao_monitor_tail = ao_monitor_head; for (;;) { while (!ao_external_monitoring) - ao_sleep(DATA_TO_XDATA(&ao_external_monitoring)); + ao_sleep(&ao_external_monitoring); while (ao_monitor_tail == ao_monitor_head && ao_external_monitoring) - ao_sleep(DATA_TO_XDATA(&ao_monitor_head)); + ao_sleep(&ao_monitor_head); if (!ao_external_monitoring) continue; m = &ao_monitor_ring[ao_monitor_tail]; @@ -298,8 +298,8 @@ set_monitor(void) { ao_cmd_hex(); ao_external_monitoring = ao_cmd_lex_i; - ao_wakeup(DATA_TO_XDATA(&ao_external_monitoring)); - ao_wakeup(DATA_TO_XDATA(&ao_monitor_head)); + ao_wakeup(&ao_external_monitoring); + ao_wakeup(&ao_monitor_head); _ao_monitor_adjust(); } diff --git a/src/kernel/ao_report.c b/src/kernel/ao_report.c index af48b390..73f87cdd 100644 --- a/src/kernel/ao_report.c +++ b/src/kernel/ao_report.c @@ -183,7 +183,7 @@ ao_report_battery(void) ao_data_get(&packet); if (packet.adc.v_batt != 0) break; - ao_sleep(DATA_TO_XDATA(&ao_sample_data)); + ao_sleep(&ao_sample_data); } ao_report_number(ao_battery_decivolt(packet.adc.v_batt)); } @@ -281,7 +281,7 @@ ao_report(void) } #endif while (ao_report_state == ao_flight_state) - ao_sleep(DATA_TO_XDATA(&ao_flight_state)); + ao_sleep(&ao_flight_state); } } diff --git a/src/kernel/ao_sample.c b/src/kernel/ao_sample.c index f8012e34..9f5082bb 100644 --- a/src/kernel/ao_sample.c +++ b/src/kernel/ao_sample.c @@ -321,8 +321,8 @@ static gyro_t inline ao_gyro(void) { uint8_t ao_sample(void) { - ao_wakeup(DATA_TO_XDATA(&ao_sample_data)); - ao_sleep((void *) DATA_TO_XDATA(&ao_data_head)); + ao_wakeup(&ao_sample_data); + ao_sleep((void *) &ao_data_head); while (ao_sample_data != ao_data_head) { __xdata struct ao_data *ao_data; diff --git a/src/kernel/ao_telemetry.c b/src/kernel/ao_telemetry.c index 9ed612ce..8ff28fde 100644 --- a/src/kernel/ao_telemetry.c +++ b/src/kernel/ao_telemetry.c @@ -337,7 +337,7 @@ ao_send_configuration(void) ao_config.callsign, AO_MAX_CALLSIGN); ao_xmemcpy (telemetry.configuration.version, - CODE_TO_XDATA(ao_version), + ao_version, AO_MAX_VERSION); ao_telemetry_config_cur = ao_telemetry_config_max; ao_telemetry_send(); diff --git a/src/product/ao_terraui.c b/src/product/ao_terraui.c index c2bbc30e..f8f23a0f 100644 --- a/src/product/ao_terraui.c +++ b/src/product/ao_terraui.c @@ -588,7 +588,7 @@ ao_terramonitor(void) monitor = ao_monitor_ring_next(monitor)) { while (monitor == ao_monitor_head) - ao_sleep(DATA_TO_XDATA(&ao_monitor_head)); + ao_sleep(&ao_monitor_head); if (ao_monitoring != sizeof (union ao_telemetry_all)) continue; if (!(ao_monitor_ring[monitor].all.status & PKT_APPEND_STATUS_1_CRC_OK)) diff --git a/src/test/ao_flight_test.c b/src/test/ao_flight_test.c index 746a6814..0913e7ba 100644 --- a/src/test/ao_flight_test.c +++ b/src/test/ao_flight_test.c @@ -362,7 +362,7 @@ struct ao_ms5607_prom ao_ms5607_prom; struct ao_config ao_config; -#define DATA_TO_XDATA(x) (x) +#define x (x) extern int16_t ao_ground_accel, ao_flight_accel; -- cgit v1.2.3 From c6e57291d91f1f6c4de5c54a5cfd3eef66d9f830 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 15 Aug 2018 17:47:37 -0700 Subject: altos: Remove 8051 address space specifiers Signed-off-by: Keith Packard --- src/aes/ao_aes.c | 6 +-- src/attiny/ao_arch.h | 6 --- src/attiny/ao_arch_funcs.h | 8 +-- src/attiny/ao_i2c_attiny.c | 4 +- src/attiny/ao_led.c | 4 +- src/attiny/ao_spi_attiny.c | 4 +- src/avr/ao_adc_avr.c | 12 ++--- src/avr/ao_arch.h | 6 --- src/avr/ao_arch_funcs.h | 6 +-- src/avr/ao_eeprom_avr.c | 20 ++++---- src/avr/ao_i2c_usart.c | 6 +-- src/avr/ao_led.c | 4 +- src/avr/ao_pwmin.c | 8 +-- src/avr/ao_pwmin.h | 2 +- src/avr/ao_serial_avr.c | 10 ++-- src/avr/ao_spi_usart.c | 6 +-- src/avr/ao_timer.c | 8 +-- src/avr/ao_usb_avr.c | 46 ++++++++--------- src/cortexelf-v1/ao_cortexelf.c | 2 +- src/cortexelf-v1/cortexelf.ld | 4 +- src/drivers/ao_25lc1024.c | 30 +++++------ src/drivers/ao_74hc165.c | 2 +- src/drivers/ao_74hc497.c | 2 +- src/drivers/ao_at24c.c | 12 ++--- src/drivers/ao_at45db161d.c | 40 +++++++-------- src/drivers/ao_btm.c | 14 +++--- src/drivers/ao_cc1120.c | 2 +- src/drivers/ao_cc1200.c | 2 +- src/drivers/ao_companion.c | 16 +++--- src/drivers/ao_gps_sirf.c | 42 ++++++++-------- src/drivers/ao_gps_skytraq.c | 48 +++++++++--------- src/drivers/ao_gps_ublox.c | 32 ++++++------ src/drivers/ao_lcd.c | 2 +- src/drivers/ao_lco.c | 2 +- src/drivers/ao_lco_cmd.c | 22 ++++---- src/drivers/ao_lco_func.c | 4 +- src/drivers/ao_lco_two.c | 2 +- src/drivers/ao_m25.c | 22 ++++---- src/drivers/ao_mma655x.c | 4 +- src/drivers/ao_mr25.c | 22 ++++---- src/drivers/ao_ms5607.c | 26 +++++----- src/drivers/ao_ms5607.h | 10 ++-- src/drivers/ao_ms5607_convert_8051.c | 4 +- src/drivers/ao_packet.c | 22 ++++---- src/drivers/ao_packet_master.c | 12 ++--- src/drivers/ao_pad.c | 36 +++++++------- src/drivers/ao_pca9922.c | 4 +- src/drivers/ao_pyro_slave.c | 2 +- src/drivers/ao_quadrature.c | 2 +- src/drivers/ao_quadrature.h | 2 +- src/drivers/ao_radio_master.c | 26 +++++----- src/drivers/ao_radio_slave.c | 8 +-- src/drivers/ao_watchdog.c | 2 +- src/kernel/ao.h | 94 +++++++++++++++++------------------ src/kernel/ao_aes.h | 8 +-- src/kernel/ao_balloon.c | 10 ++-- src/kernel/ao_beep.h | 2 +- src/kernel/ao_cmd.c | 46 ++++++++--------- src/kernel/ao_companion.h | 10 ++-- src/kernel/ao_config.c | 94 +++++++++++++++++------------------ src/kernel/ao_config.h | 8 +-- src/kernel/ao_convert.c | 6 +-- src/kernel/ao_data.c | 8 +-- src/kernel/ao_data.h | 10 ++-- src/kernel/ao_ee_fake.c | 4 +- src/kernel/ao_eeprom.h | 4 +- src/kernel/ao_flight.c | 24 ++++----- src/kernel/ao_flight.h | 14 +++--- src/kernel/ao_flight_nano.c | 14 +++--- src/kernel/ao_forward.c | 6 +-- src/kernel/ao_forward.h | 2 +- src/kernel/ao_freq.c | 8 +-- src/kernel/ao_gps_print.c | 6 +-- src/kernel/ao_gps_report.c | 8 +-- src/kernel/ao_gps_report_mega.c | 8 +-- src/kernel/ao_gps_report_metrum.c | 8 +-- src/kernel/ao_gps_show.c | 2 +- src/kernel/ao_host.h | 6 +-- src/kernel/ao_ignite.c | 18 +++---- src/kernel/ao_int64.c | 16 +++--- src/kernel/ao_int64.h | 16 +++--- src/kernel/ao_kalman.c | 24 ++++----- src/kernel/ao_led.h | 2 +- src/kernel/ao_log.c | 40 +++++++-------- src/kernel/ao_log.h | 20 ++++---- src/kernel/ao_log_big.c | 4 +- src/kernel/ao_log_fireone.c | 12 ++--- src/kernel/ao_log_mega.c | 4 +- src/kernel/ao_log_metrum.c | 4 +- src/kernel/ao_log_mini.c | 4 +- src/kernel/ao_log_single.c | 18 +++---- src/kernel/ao_log_telem.c | 12 ++--- src/kernel/ao_log_telescience.c | 6 +-- src/kernel/ao_log_tiny.c | 8 +-- src/kernel/ao_monitor.c | 28 +++++------ src/kernel/ao_mutex.c | 6 +-- src/kernel/ao_notask.c | 4 +- src/kernel/ao_notask.h | 4 +- src/kernel/ao_packet.h | 18 +++---- src/kernel/ao_pyro.c | 6 +-- src/kernel/ao_radio_cmac.c | 14 +++--- src/kernel/ao_radio_cmac.h | 6 +-- src/kernel/ao_radio_cmac_cmd.c | 8 +-- src/kernel/ao_report.c | 16 +++--- src/kernel/ao_report_micro.c | 8 +-- src/kernel/ao_rssi.c | 8 +-- src/kernel/ao_sample.c | 74 +++++++++++++-------------- src/kernel/ao_sample.h | 70 +++++++++++++------------- src/kernel/ao_sample_profile.c | 2 +- src/kernel/ao_send_packet.c | 8 +-- src/kernel/ao_serial.h | 16 +++--- src/kernel/ao_stdio.c | 14 +++--- src/kernel/ao_storage.c | 24 ++++----- src/kernel/ao_storage.h | 24 ++++----- src/kernel/ao_task.c | 24 ++++----- src/kernel/ao_task.h | 20 ++++---- src/kernel/ao_telemetry.c | 54 ++++++++++---------- src/kernel/ao_usb.h | 6 +-- src/lpc/altos-loader.ld | 4 +- src/lpc/altos-standalone.ld | 4 +- src/lpc/altos.ld | 4 +- src/lpc/ao_adc_lpc.c | 4 +- src/lpc/ao_arch.h | 5 -- src/lpc/ao_beep_lpc.c | 2 +- src/lpc/ao_interrupt.c | 4 +- src/lpc/ao_led_lpc.c | 4 +- src/lpc/ao_timer_lpc.c | 6 +-- src/lpc/ao_usb_lpc.c | 2 +- src/micropeak-v2.0/micropeak.ld | 4 +- src/nucleao-32/load.ld | 4 +- src/pnpservo-v1/lambda.ld | 4 +- src/product/ao_flash_task.c | 2 +- src/product/ao_terraui.c | 56 ++++++++++----------- src/product/ao_test.c | 18 +++---- src/stm-bringup/bringup.ld | 4 +- src/stm-demo/ao_demo.c | 2 +- src/stm-scheme-newlib/ao_demo.c | 2 +- src/stm-vga/ao_demo.c | 2 +- src/stm/altos-512.ld | 4 +- src/stm/altos-loader.ld | 4 +- src/stm/altos-ram.ld | 4 +- src/stm/altos.ld | 4 +- src/stm/ao_adc_single_stm.c | 2 +- src/stm/ao_adc_stm.c | 6 +-- src/stm/ao_arch.h | 5 -- src/stm/ao_beep_stm.c | 2 +- src/stm/ao_eeprom_stm.c | 6 +-- src/stm/ao_interrupt.c | 4 +- src/stm/ao_led.c | 2 +- src/stm/ao_timer.c | 4 +- src/stm/ao_usb_stm.c | 2 +- src/stmf0/altos-loader.ld | 4 +- src/stmf0/altos-raw.ld | 4 +- src/stmf0/altos.ld | 4 +- src/stmf0/ao_adc_stm.c | 2 +- src/stmf0/ao_arch.h | 5 -- src/stmf0/ao_beep_stm.c | 2 +- src/stmf0/ao_interrupt.c | 4 +- src/stmf0/ao_led.c | 4 +- src/stmf0/ao_storage_stm.c | 6 +-- src/stmf0/ao_timer.c | 4 +- src/stmf0/ao_usb_stm.c | 2 +- src/telefireone-v1.0/ao_telefireone.c | 2 +- src/telelco-v2.0/ao_lco_v2.c | 2 +- src/test/ao_aes_test.c | 6 +-- src/test/ao_eeprom_read.h | 6 +-- src/test/ao_flight_test.c | 6 +-- src/test/ao_gps_test_skytraq.c | 4 +- src/test/ao_gps_test_ublox.c | 4 +- src/test/ao_int64_test.c | 4 -- src/test/ao_ms5607_convert_test.c | 4 -- src/usbrelay-v0.1/ao_usbrelay.c | 4 +- 172 files changed, 974 insertions(+), 1025 deletions(-) (limited to 'src/kernel') diff --git a/src/aes/ao_aes.c b/src/aes/ao_aes.c index fd90c5bf..0bc8188e 100644 --- a/src/aes/ao_aes.c +++ b/src/aes/ao_aes.c @@ -372,7 +372,7 @@ ao_aes_set_mode(enum ao_aes_mode mode) } void -ao_aes_set_key(__xdata uint8_t *in) +ao_aes_set_key(uint8_t *in) { memcpy(key, in, 16); xrijndaelKeySched((word32 *) key, 128, 128, &rkk); @@ -385,8 +385,8 @@ ao_aes_zero_iv(void) } void -ao_aes_run(__xdata uint8_t *in, - __xdata uint8_t *out) +ao_aes_run(uint8_t *in, + uint8_t *out) { uint8_t i; uint8_t *_iv = (uint8_t *) iv; diff --git a/src/attiny/ao_arch.h b/src/attiny/ao_arch.h index 68f5702d..84a94be7 100644 --- a/src/attiny/ao_arch.h +++ b/src/attiny/ao_arch.h @@ -38,12 +38,6 @@ #define ao_arch_naked_declare __attribute__((naked)) #define ao_arch_naked_define -#define __pdata -#define __data -#define __xdata -#define __code const -#define __reentrant -#define __critical #define __interrupt(n) #define __at(n) diff --git a/src/attiny/ao_arch_funcs.h b/src/attiny/ao_arch_funcs.h index 0b67a407..35901154 100644 --- a/src/attiny/ao_arch_funcs.h +++ b/src/attiny/ao_arch_funcs.h @@ -57,10 +57,10 @@ void -ao_spi_send_bus(void __xdata *block, uint16_t len) __reentrant; +ao_spi_send_bus(void *block, uint16_t len); void -ao_spi_recv_bus(void __xdata *block, uint16_t len) __reentrant; +ao_spi_recv_bus(void *block, uint16_t len); #define ao_spi_send(block, len, bus) ao_spi_send_bus(block, len) #define ao_spi_recv(block, len, bus) ao_spi_recv_bus(block, len) @@ -110,10 +110,10 @@ ao_i2c_init(void); /* notask.c */ uint8_t -ao_sleep(__xdata void *wchan); +ao_sleep(void *wchan); void -ao_wakeup(__xdata void *wchan); +ao_wakeup(void *wchan); extern alt_t ao_max_height; diff --git a/src/attiny/ao_i2c_attiny.c b/src/attiny/ao_i2c_attiny.c index f29ed6a9..34185b5a 100644 --- a/src/attiny/ao_i2c_attiny.c +++ b/src/attiny/ao_i2c_attiny.c @@ -173,7 +173,7 @@ ao_i2c_stop_bus(void) * so using interrupts would take way too long */ uint8_t -ao_i2c_send_bus(void __xdata *block, uint16_t len, uint8_t stop) +ao_i2c_send_bus(void *block, uint16_t len, uint8_t stop) { uint8_t *d = block; @@ -206,7 +206,7 @@ ao_i2c_send_fixed_bus(uint8_t d, uint16_t len, uint8_t stop) * Poll, sending zeros and reading data back */ uint8_t -ao_i2c_recv_bus(void __xdata *block, uint16_t len, uint8_t stop) +ao_i2c_recv_bus(void *block, uint16_t len, uint8_t stop) { uint8_t *d = block; diff --git a/src/attiny/ao_led.c b/src/attiny/ao_led.c index 5f53129e..88505490 100644 --- a/src/attiny/ao_led.c +++ b/src/attiny/ao_led.c @@ -18,7 +18,7 @@ #include "ao.h" -__pdata uint8_t ao_led_enable; +uint8_t ao_led_enable; #define LED_PORT PORTB #define LED_DDR DDRB @@ -48,7 +48,7 @@ ao_led_toggle(uint8_t colors) } void -ao_led_for(uint8_t colors, uint16_t ticks) __reentrant +ao_led_for(uint8_t colors, uint16_t ticks) { ao_led_on(colors); ao_delay(ticks); diff --git a/src/attiny/ao_spi_attiny.c b/src/attiny/ao_spi_attiny.c index f63eb651..1c90ad56 100644 --- a/src/attiny/ao_spi_attiny.c +++ b/src/attiny/ao_spi_attiny.c @@ -82,7 +82,7 @@ ao_spi_transfer(uint8_t i) * so using interrupts would take way too long */ void -ao_spi_send_bus(void __xdata *block, uint16_t len) __reentrant +ao_spi_send_bus(void *block, uint16_t len) { uint8_t *d = block; @@ -95,7 +95,7 @@ ao_spi_send_bus(void __xdata *block, uint16_t len) __reentrant * Poll, sending zeros and reading data back */ void -ao_spi_recv_bus(void __xdata *block, uint16_t len) __reentrant +ao_spi_recv_bus(void *block, uint16_t len) { uint8_t *d = block; diff --git a/src/avr/ao_adc_avr.c b/src/avr/ao_adc_avr.c index 2732c4db..2aae95ac 100644 --- a/src/avr/ao_adc_avr.c +++ b/src/avr/ao_adc_avr.c @@ -19,8 +19,8 @@ #include "ao.h" #include "ao_pwmin.h" -volatile __xdata struct ao_data ao_data_ring[AO_DATA_RING]; -volatile __data uint8_t ao_data_head; +volatile struct ao_data ao_data_ring[AO_DATA_RING]; +volatile uint8_t ao_data_head; #ifdef TELESCIENCE const uint8_t adc_channels[AO_LOG_TELESCIENCE_NUM_ADC] = { @@ -119,16 +119,16 @@ ao_adc_poll(void) } void -ao_data_get(__xdata struct ao_data *packet) +ao_data_get(struct ao_data *packet) { uint8_t i = ao_data_ring_prev(ao_data_head); memcpy(packet, (void *) &ao_data_ring[i], sizeof (struct ao_data)); } static void -ao_adc_dump(void) __reentrant +ao_adc_dump(void) { - static __xdata struct ao_data packet; + static struct ao_data packet; uint8_t i; ao_data_get(&packet); printf("tick: %5u", packet.tick); @@ -137,7 +137,7 @@ ao_adc_dump(void) __reentrant printf("\n"); } -__code struct ao_cmds ao_adc_cmds[] = { +const struct ao_cmds ao_adc_cmds[] = { { ao_adc_dump, "a\0ADC" }, { 0, NULL }, }; diff --git a/src/avr/ao_arch.h b/src/avr/ao_arch.h index 2b1da642..6166c50e 100644 --- a/src/avr/ao_arch.h +++ b/src/avr/ao_arch.h @@ -48,12 +48,6 @@ #define ao_arch_naked_declare __attribute__((naked)) #define ao_arch_naked_define -#define __pdata -#define __data -#define __xdata -#define __code const -#define __reentrant -#define __critical #define __interrupt(n) #define __at(n) diff --git a/src/avr/ao_arch_funcs.h b/src/avr/ao_arch_funcs.h index 891ad9b1..dc248660 100644 --- a/src/avr/ao_arch_funcs.h +++ b/src/avr/ao_arch_funcs.h @@ -20,7 +20,7 @@ * ao_spi.c */ -extern __xdata uint8_t ao_spi_mutex; +extern uint8_t ao_spi_mutex; #define ao_spi_get_mask(reg,mask,bus,speed) do { \ ao_mutex_get(&ao_spi_mutex); \ @@ -66,10 +66,10 @@ extern __xdata uint8_t ao_spi_mutex; void -ao_spi_send_bus(void __xdata *block, uint16_t len) __reentrant; +ao_spi_send_bus(void *block, uint16_t len); void -ao_spi_recv_bus(void __xdata *block, uint16_t len) __reentrant; +ao_spi_recv_bus(void *block, uint16_t len); #define ao_spi_send(block, len, bus) ao_spi_send_bus(block, len) #define ao_spi_recv(block, len, bus) ao_spi_recv_bus(block, len) diff --git a/src/avr/ao_eeprom_avr.c b/src/avr/ao_eeprom_avr.c index 2fdf177b..84942cd7 100644 --- a/src/avr/ao_eeprom_avr.c +++ b/src/avr/ao_eeprom_avr.c @@ -21,16 +21,16 @@ #include /* Total bytes of available storage */ -__pdata ao_pos_t ao_storage_total = 1024; +ao_pos_t ao_storage_total = 1024; /* Block size - device is erased in these units. */ -__pdata ao_pos_t ao_storage_block = 1024; +ao_pos_t ao_storage_block = 1024; /* Byte offset of config block. Will be ao_storage_block bytes long */ -__pdata ao_pos_t ao_storage_config = 0; +ao_pos_t ao_storage_config = 0; /* Storage unit size - device reads and writes must be within blocks of this size. */ -__pdata uint16_t ao_storage_unit = 1024; +uint16_t ao_storage_unit = 1024; /* * The internal flash chip is arranged in 8 byte sectors; the @@ -45,7 +45,7 @@ __pdata uint16_t ao_storage_unit = 1024; * Erase the specified sector */ uint8_t -ao_storage_erase(ao_pos_t pos) __reentrant +ao_storage_erase(ao_pos_t pos) { /* Not necessary */ return 1; @@ -83,10 +83,10 @@ ao_intflash_read(uint16_t pos) */ uint8_t -ao_storage_device_write(ao_pos_t pos32, __xdata void *v, uint16_t len) __reentrant +ao_storage_device_write(ao_pos_t pos32, void *v, uint16_t len) { uint16_t pos = pos32; - __xdata uint8_t *d = v; + uint8_t *d = v; if (pos >= ao_storage_total || pos + len > ao_storage_total) return 0; @@ -101,7 +101,7 @@ ao_storage_device_write(ao_pos_t pos32, __xdata void *v, uint16_t len) __reentra * Read from flash */ uint8_t -ao_storage_device_read(ao_pos_t pos, __xdata void *v, uint16_t len) __reentrant +ao_storage_device_read(ao_pos_t pos, void *v, uint16_t len) { uint8_t *d = v; @@ -113,7 +113,7 @@ ao_storage_device_read(ao_pos_t pos, __xdata void *v, uint16_t len) __reentrant } void -ao_storage_flush(void) __reentrant +ao_storage_flush(void) { } @@ -123,7 +123,7 @@ ao_storage_setup(void) } void -ao_storage_device_info(void) __reentrant +ao_storage_device_info(void) { printf ("Using internal flash\n"); } diff --git a/src/avr/ao_i2c_usart.c b/src/avr/ao_i2c_usart.c index c95548d4..67bee339 100644 --- a/src/avr/ao_i2c_usart.c +++ b/src/avr/ao_i2c_usart.c @@ -22,7 +22,7 @@ * Atmega32u4 TWI master mode (I2C) */ -__xdata uint8_t ao_i2c_mutex; +uint8_t ao_i2c_mutex; /* Send bytes over I2C. * @@ -30,7 +30,7 @@ __xdata uint8_t ao_i2c_mutex; * so using interrupts would take way too long */ void -ao_i2c_send(void __xdata *block, uint16_t len) __reentrant +ao_i2c_send(void *block, uint16_t len) { uint8_t *d = block; @@ -51,7 +51,7 @@ ao_i2c_send(void __xdata *block, uint16_t len) __reentrant * clocks the data coming in. */ void -ao_i2c_recv(void __xdata *block, uint16_t len) __reentrant +ao_i2c_recv(void *block, uint16_t len) { uint8_t *d = block; diff --git a/src/avr/ao_led.c b/src/avr/ao_led.c index 8eba4898..165e95d3 100644 --- a/src/avr/ao_led.c +++ b/src/avr/ao_led.c @@ -18,7 +18,7 @@ #include "ao.h" -__pdata uint8_t ao_led_enable; +uint8_t ao_led_enable; #define LED_PORT PORTB #define LED_DDR DDRB @@ -48,7 +48,7 @@ ao_led_toggle(uint8_t colors) } void -ao_led_for(uint8_t colors, uint16_t ticks) __reentrant +ao_led_for(uint8_t colors, uint16_t ticks) { ao_led_on(colors); ao_delay(ticks); diff --git a/src/avr/ao_pwmin.c b/src/avr/ao_pwmin.c index 5eb392a4..2d83380f 100644 --- a/src/avr/ao_pwmin.c +++ b/src/avr/ao_pwmin.c @@ -26,8 +26,8 @@ * project payload developed at Challenger Middle School. */ -volatile __data uint16_t ao_icp3_count = 0; -volatile __data uint16_t ao_icp3_last = 0; +volatile uint16_t ao_icp3_count = 0; +volatile uint16_t ao_icp3_last = 0; uint16_t ao_icp3(void) { @@ -39,7 +39,7 @@ uint16_t ao_icp3(void) } static void -ao_pwmin_display(void) __reentrant +ao_pwmin_display(void) { /* display the most recent value */ printf("icp 3: %5u\n", ao_icp3()); @@ -62,7 +62,7 @@ ISR(TIMER3_CAPT_vect) ao_icp3_last = ao_icp3_this; } -__code struct ao_cmds ao_pwmin_cmds[] = { +const struct ao_cmds ao_pwmin_cmds[] = { { ao_pwmin_display, "p\0PWM input" }, { 0, NULL }, }; diff --git a/src/avr/ao_pwmin.h b/src/avr/ao_pwmin.h index 43c12f53..fcb5e267 100644 --- a/src/avr/ao_pwmin.h +++ b/src/avr/ao_pwmin.h @@ -18,4 +18,4 @@ void ao_pwmin_init(void); -extern volatile __data uint16_t ao_icp3_count; +extern volatile uint16_t ao_icp3_count; diff --git a/src/avr/ao_serial_avr.c b/src/avr/ao_serial_avr.c index ab82b7b1..cfdd7dfe 100644 --- a/src/avr/ao_serial_avr.c +++ b/src/avr/ao_serial_avr.c @@ -18,8 +18,8 @@ #include "ao.h" -__xdata struct ao_fifo ao_serial1_rx_fifo; -__xdata struct ao_fifo ao_serial1_tx_fifo; +struct ao_fifo ao_serial1_rx_fifo; +struct ao_fifo ao_serial1_tx_fifo; void ao_debug_out(char c) @@ -40,7 +40,7 @@ ISR(USART1_RX_vect) #endif } -static __xdata uint8_t ao_serial_tx1_started; +static uint8_t ao_serial_tx1_started; static void ao_serial1_tx_start(void) @@ -75,7 +75,7 @@ _ao_serial1_pollchar(void) #endif char -ao_serial1_getchar(void) __critical +ao_serial1_getchar(void) { char c; @@ -99,7 +99,7 @@ ao_serial1_putchar(char c) } void -ao_serial1_drain(void) __critical +ao_serial1_drain(void) { ao_arch_block_interrupts(); while (!ao_fifo_empty(ao_serial1_tx_fifo)) diff --git a/src/avr/ao_spi_usart.c b/src/avr/ao_spi_usart.c index 0d509cb7..6c30b025 100644 --- a/src/avr/ao_spi_usart.c +++ b/src/avr/ao_spi_usart.c @@ -22,7 +22,7 @@ * Atmega32u4 USART in MSPIM (master SPI mode) */ -__xdata uint8_t ao_spi_mutex; +uint8_t ao_spi_mutex; /* Send bytes over SPI. * @@ -30,7 +30,7 @@ __xdata uint8_t ao_spi_mutex; * so using interrupts would take way too long */ void -ao_spi_send_bus(void __xdata *block, uint16_t len) __reentrant +ao_spi_send_bus(void *block, uint16_t len) { uint8_t *d = block; @@ -47,7 +47,7 @@ ao_spi_send_bus(void __xdata *block, uint16_t len) __reentrant * Poll, sending zeros and reading data back */ void -ao_spi_recv_bus(void __xdata *block, uint16_t len) __reentrant +ao_spi_recv_bus(void *block, uint16_t len) { uint8_t *d = block; diff --git a/src/avr/ao_timer.c b/src/avr/ao_timer.c index 2eaa8b63..ff6a829a 100644 --- a/src/avr/ao_timer.c +++ b/src/avr/ao_timer.c @@ -18,7 +18,7 @@ #include "ao.h" -volatile __data uint16_t ao_tick_count; +volatile uint16_t ao_tick_count; uint16_t ao_time(void) { @@ -33,8 +33,8 @@ uint16_t ao_time(void) #define T1_SAMPLE_TIME 30000 /* 3e6/30000 = 100 */ #if HAS_ADC -volatile __data uint8_t ao_adc_interval = 1; -volatile __data uint8_t ao_adc_count; +volatile uint8_t ao_adc_interval = 1; +volatile uint8_t ao_adc_count; #endif void @@ -53,7 +53,7 @@ ISR(TIMER1_COMPA_vect) #if HAS_ADC void -ao_timer_set_adc_interval(uint8_t interval) __critical +ao_timer_set_adc_interval(uint8_t interval) { ao_adc_interval = interval; ao_adc_count = 0; diff --git a/src/avr/ao_usb_avr.c b/src/avr/ao_usb_avr.c index 41d3c1be..df800994 100644 --- a/src/avr/ao_usb_avr.c +++ b/src/avr/ao_usb_avr.c @@ -27,7 +27,7 @@ #define debug(format, args...) #endif -struct ao_task __xdata ao_usb_task; +struct ao_task ao_usb_task; struct ao_usb_setup { uint8_t dir_type_recip; @@ -35,21 +35,21 @@ struct ao_usb_setup { uint16_t value; uint16_t index; uint16_t length; -} __xdata ao_usb_setup; - -static __xdata uint8_t ao_usb_ep0_state; -static const uint8_t * __xdata ao_usb_ep0_in_data; -static __xdata uint8_t ao_usb_ep0_in_len; -static __xdata uint8_t ao_usb_ep0_in_pending; -static __xdata uint8_t ao_usb_addr_pending; -static __xdata uint8_t ao_usb_ep0_in_buf[2]; -static __xdata uint8_t ao_usb_ep0_out_len; -static __xdata uint8_t *__xdata ao_usb_ep0_out_data; - -static __xdata uint8_t ao_usb_in_flushed; -__xdata uint8_t ao_usb_running; -static __xdata uint8_t ao_usb_configuration; -static __xdata uint8_t ueienx_0; +} ao_usb_setup; + +static uint8_t ao_usb_ep0_state; +static const uint8_t * ao_usb_ep0_in_data; +static uint8_t ao_usb_ep0_in_len; +static uint8_t ao_usb_ep0_in_pending; +static uint8_t ao_usb_addr_pending; +static uint8_t ao_usb_ep0_in_buf[2]; +static uint8_t ao_usb_ep0_out_len; +static uint8_t *ao_usb_ep0_out_data; + +static uint8_t ao_usb_in_flushed; +uint8_t ao_usb_running; +static uint8_t ao_usb_configuration; +static uint8_t ueienx_0; void ao_usb_set_address(uint8_t address) @@ -143,9 +143,9 @@ struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8}; static void ao_usb_get_descriptor(uint16_t value) { - const uint8_t *__xdata descriptor; - __xdata uint8_t type = value >> 8; - __xdata uint8_t index = value; + const uint8_t *descriptor; + uint8_t type = value >> 8; + uint8_t index = value; descriptor = ao_usb_descriptors; while (descriptor[0] != 0) { @@ -174,7 +174,7 @@ ao_usb_ep0_set_in_pending(uint8_t in_pending) static void ao_usb_ep0_flush(void) { - __xdata uint8_t this_len; + uint8_t this_len; cli(); UENUM = 0; @@ -242,7 +242,7 @@ static void ao_usb_ep0_setup(void) { /* Pull the setup packet out of the fifo */ - ao_usb_ep0_out_data = (__xdata uint8_t *) &ao_usb_setup; + ao_usb_ep0_out_data = (uint8_t *) &ao_usb_setup; ao_usb_ep0_out_len = 8; ao_usb_ep0_fill(8, (1 << RXSTPI) | (1 << RXOUTI) | (1 << TXINI)); if (ao_usb_ep0_out_len != 0) { @@ -334,7 +334,7 @@ ao_usb_ep0_setup(void) case AO_USB_SET_LINE_CODING: debug ("set line coding\n"); ao_usb_ep0_out_len = 7; - ao_usb_ep0_out_data = (__xdata uint8_t *) &ao_usb_line_coding; + ao_usb_ep0_out_data = (uint8_t *) &ao_usb_line_coding; break; case AO_USB_GET_LINE_CODING: debug ("get line coding\n"); @@ -636,7 +636,7 @@ ao_usb_enable(void) } #if USB_DEBUG -struct ao_task __xdata ao_usb_echo_task; +struct ao_task ao_usb_echo_task; static void ao_usb_echo(void) diff --git a/src/cortexelf-v1/ao_cortexelf.c b/src/cortexelf-v1/ao_cortexelf.c index 5ed78bf0..6bc2624f 100644 --- a/src/cortexelf-v1/ao_cortexelf.c +++ b/src/cortexelf-v1/ao_cortexelf.c @@ -218,7 +218,7 @@ led_cmd(void) ao_as1107_write_8(start, value); } -__code struct ao_cmds ao_demo_cmds[] = { +const struct ao_cmds ao_demo_cmds[] = { { ao_video_toggle, "V\0Toggle video" }, { ao_ball_toggle, "B\0Toggle ball" }, { ao_ps2_read_keys, "K\0Read keys from keyboard" }, diff --git a/src/cortexelf-v1/cortexelf.ld b/src/cortexelf-v1/cortexelf.ld index 6ad2a679..069fe5bd 100644 --- a/src/cortexelf-v1/cortexelf.ld +++ b/src/cortexelf-v1/cortexelf.ld @@ -75,10 +75,10 @@ SECTIONS { /* Data -- relocated to RAM, but written to ROM */ .data : { - __data_start__ = .; + _start__ = .; *(.data) /* initialized data */ . = ALIGN(4); - __data_end__ = .; + _end__ = .; } >ram AT>rom .bss : { diff --git a/src/drivers/ao_25lc1024.c b/src/drivers/ao_25lc1024.c index a9c897b3..c73f54df 100644 --- a/src/drivers/ao_25lc1024.c +++ b/src/drivers/ao_25lc1024.c @@ -24,16 +24,16 @@ #define EE_DEVICE_SIZE ((uint32_t) 128 * (uint32_t) 1024) /* Total bytes of available storage */ -__pdata uint32_t ao_storage_total; +uint32_t ao_storage_total; /* Block size - device is erased in these units. At least 256 bytes */ -__pdata uint32_t ao_storage_block; +uint32_t ao_storage_block; /* Byte offset of config block. Will be ao_storage_block bytes long */ -__pdata uint32_t ao_storage_config; +uint32_t ao_storage_config; /* Storage unit size - device reads and writes must be within blocks of this size. Usually 256 bytes. */ -__pdata uint16_t ao_storage_unit; +uint16_t ao_storage_unit; /* * Using SPI on USART 0, with P1_2 as the chip select @@ -43,7 +43,7 @@ __pdata uint16_t ao_storage_unit; #define EE_CS P1_2 #define EE_CS_PIN 2 -static __xdata uint8_t ao_ee_mutex; +static uint8_t ao_ee_mutex; #define ao_ee_delay() do { \ _asm nop _endasm; \ @@ -58,7 +58,7 @@ static __xdata uint8_t ao_ee_mutex; struct ao_ee_instruction { uint8_t instruction; uint8_t address[3]; -} __xdata ao_ee_instruction; +} ao_ee_instruction; static void ao_ee_write_enable(void) @@ -92,9 +92,9 @@ ao_ee_wrsr(uint8_t status) #define EE_BLOCK_NONE 0xffff -static __xdata uint8_t ao_ee_data[EE_BLOCK_SIZE]; -static __pdata uint16_t ao_ee_block = EE_BLOCK_NONE; -static __pdata uint8_t ao_ee_block_dirty; +static uint8_t ao_ee_data[EE_BLOCK_SIZE]; +static uint16_t ao_ee_block = EE_BLOCK_NONE; +static uint8_t ao_ee_block_dirty; /* Write the current block to the EEPROM */ static void @@ -157,7 +157,7 @@ ao_ee_fill(uint16_t block) } uint8_t -ao_storage_device_write(uint32_t pos, __xdata void *buf, uint16_t len) __reentrant +ao_storage_device_write(uint32_t pos, void *buf, uint16_t len) { uint16_t block = (uint16_t) (pos >> EE_BLOCK_SHIFT); @@ -176,7 +176,7 @@ ao_storage_device_write(uint32_t pos, __xdata void *buf, uint16_t len) __reentra } uint8_t -ao_storage_device_read(uint32_t pos, __xdata void *buf, uint16_t len) __reentrant +ao_storage_device_read(uint32_t pos, void *buf, uint16_t len) { uint16_t block = (uint16_t) (pos >> EE_BLOCK_SHIFT); @@ -189,7 +189,7 @@ ao_storage_device_read(uint32_t pos, __xdata void *buf, uint16_t len) __reentran } void -ao_storage_flush(void) __reentrant +ao_storage_flush(void) { ao_mutex_get(&ao_ee_mutex); { ao_ee_flush_internal(); @@ -197,7 +197,7 @@ ao_storage_flush(void) __reentrant } uint8_t -ao_storage_erase(uint32_t pos) __reentrant +ao_storage_erase(uint32_t pos) { ao_mutex_get(&ao_ee_mutex); { ao_ee_flush_internal(); @@ -209,7 +209,7 @@ ao_storage_erase(uint32_t pos) __reentrant } static void -ee_store(void) __reentrant +ee_store(void) { } @@ -225,7 +225,7 @@ ao_storage_setup(void) } void -ao_storage_device_info(void) __reentrant +ao_storage_device_info(void) { } diff --git a/src/drivers/ao_74hc165.c b/src/drivers/ao_74hc165.c index 8842801d..b62e0134 100644 --- a/src/drivers/ao_74hc165.c +++ b/src/drivers/ao_74hc165.c @@ -27,7 +27,7 @@ uint8_t ao_74hc165_read(void) { - static __xdata state; + static state; ao_spi_get(AO_74HC165_SPI_BUS); ao_spi_set_speed(AO_74HC165_SPI_BUS, AO_SPI_SPEED_FAST); AO_74HC165_CS = 1; diff --git a/src/drivers/ao_74hc497.c b/src/drivers/ao_74hc497.c index b3fd3c91..e8c39430 100644 --- a/src/drivers/ao_74hc497.c +++ b/src/drivers/ao_74hc497.c @@ -27,7 +27,7 @@ uint8_t ao_74hc497_read(void) { - static __xdata state; + static state; ao_spi_get_bit(AO_74HC497_CS_PORT, AO_74HC497_CS_PIN, AO_74HC497_CS, AO_74HC497_SPI_BUS, AO_SPI_SPEED_FAST); ao_spi_recv(&state, 1, AO_74HC497_SPI_BUS); ao_spi_put_bit(AO_74HC497_CS_PORT, AO_74HC497_CS_PIN, AO_74HC497_CS, AO_74HC497_SPI_BUS); diff --git a/src/drivers/ao_at24c.c b/src/drivers/ao_at24c.c index 8f91e3ca..16141c73 100644 --- a/src/drivers/ao_at24c.c +++ b/src/drivers/ao_at24c.c @@ -25,10 +25,10 @@ #define AO_AT24C_PAGE_LEN 128 /* Total bytes of available storage */ -__pdata ao_pos_t ao_storage_total = 64l * 1024l; +ao_pos_t ao_storage_total = 64l * 1024l; /* Storage unit size - device reads and writes must be within blocks of this size. */ -__pdata uint16_t ao_storage_unit = 128; +uint16_t ao_storage_unit = 128; static void ao_at24c_set_address(uint8_t addr, ao_pos_t pos) @@ -45,7 +45,7 @@ ao_at24c_set_address(uint8_t addr, ao_pos_t pos) * Erase the specified sector */ uint8_t -ao_storage_erase(ao_pos_t pos) __reentrant +ao_storage_erase(ao_pos_t pos) { if (pos >= ao_storage_total || pos + AO_AT24C_PAGE_LEN > ao_storage_total) return 0; @@ -61,7 +61,7 @@ ao_storage_erase(ao_pos_t pos) __reentrant * Write to flash */ uint8_t -ao_storage_device_write(ao_pos_t pos, __xdata void *d, uint16_t len) __reentrant +ao_storage_device_write(ao_pos_t pos, void *d, uint16_t len) { if (pos >= ao_storage_total || pos + len > ao_storage_total) return 0; @@ -77,7 +77,7 @@ ao_storage_device_write(ao_pos_t pos, __xdata void *d, uint16_t len) __reentrant * Read from flash */ uint8_t -ao_storage_device_read(ao_pos_t pos, __xdata void *d, uint16_t len) __reentrant +ao_storage_device_read(ao_pos_t pos, void *d, uint16_t len) { if (pos >= ao_storage_total || pos + len > ao_storage_total) return 0; @@ -89,7 +89,7 @@ ao_storage_device_read(ao_pos_t pos, __xdata void *d, uint16_t len) __reentrant } void -ao_storage_flush(void) __reentrant +ao_storage_flush(void) { } diff --git a/src/drivers/ao_at45db161d.c b/src/drivers/ao_at45db161d.c index abba3f1f..516811b8 100644 --- a/src/drivers/ao_at45db161d.c +++ b/src/drivers/ao_at45db161d.c @@ -20,23 +20,23 @@ #include "ao_at45db161d.h" /* Total bytes of available storage */ -__pdata uint32_t ao_storage_total; +uint32_t ao_storage_total; /* Block size - device is erased in these units. At least 256 bytes */ -__pdata uint32_t ao_storage_block; +uint32_t ao_storage_block; /* Byte offset of config block. Will be ao_storage_block bytes long */ -__pdata uint32_t ao_storage_config; +uint32_t ao_storage_config; /* Storage unit size - device reads and writes must be within blocks of this size. Usually 256 bytes. */ -__pdata uint16_t ao_storage_unit; +uint16_t ao_storage_unit; #define FLASH_CS P1_1 #define FLASH_CS_INDEX 1 #define FLASH_BLOCK_SIZE_MAX 512 -__xdata uint8_t ao_flash_mutex; +uint8_t ao_flash_mutex; #define ao_flash_delay() do { \ _asm nop _endasm; \ @@ -51,7 +51,7 @@ __xdata uint8_t ao_flash_mutex; struct ao_flash_instruction { uint8_t instruction; uint8_t address[3]; -} __xdata ao_flash_instruction; +} ao_flash_instruction; static void ao_flash_set_pagesize_512(void) @@ -79,17 +79,17 @@ ao_flash_read_status(void) #define FLASH_BLOCK_NONE 0xffff -static __xdata uint8_t ao_flash_data[FLASH_BLOCK_SIZE_MAX]; -static __pdata uint16_t ao_flash_block = FLASH_BLOCK_NONE; -static __pdata uint8_t ao_flash_block_dirty; -static __pdata uint8_t ao_flash_write_pending; -static __pdata uint8_t ao_flash_setup_done; -static __pdata uint8_t ao_flash_block_shift; -static __pdata uint16_t ao_flash_block_size; -static __pdata uint16_t ao_flash_block_mask; +static uint8_t ao_flash_data[FLASH_BLOCK_SIZE_MAX]; +static uint16_t ao_flash_block = FLASH_BLOCK_NONE; +static uint8_t ao_flash_block_dirty; +static uint8_t ao_flash_write_pending; +static uint8_t ao_flash_setup_done; +static uint8_t ao_flash_block_shift; +static uint16_t ao_flash_block_size; +static uint16_t ao_flash_block_mask; void -ao_storage_setup(void) __reentrant +ao_storage_setup(void) { uint8_t status; @@ -234,7 +234,7 @@ ao_flash_fill(uint16_t block) } uint8_t -ao_storage_device_write(uint32_t pos, __xdata void *buf, uint16_t len) __reentrant +ao_storage_device_write(uint32_t pos, void *buf, uint16_t len) { uint16_t block = (uint16_t) (pos >> ao_flash_block_shift); @@ -255,7 +255,7 @@ ao_storage_device_write(uint32_t pos, __xdata void *buf, uint16_t len) __reentra } uint8_t -ao_storage_device_read(uint32_t pos, __xdata void *buf, uint16_t len) __reentrant +ao_storage_device_read(uint32_t pos, void *buf, uint16_t len) { uint16_t block = (uint16_t) (pos >> ao_flash_block_shift); @@ -270,7 +270,7 @@ ao_storage_device_read(uint32_t pos, __xdata void *buf, uint16_t len) __reentran } void -ao_storage_flush(void) __reentrant +ao_storage_flush(void) { ao_mutex_get(&ao_flash_mutex); { ao_flash_flush_internal(); @@ -278,7 +278,7 @@ ao_storage_flush(void) __reentrant } uint8_t -ao_storage_erase(uint32_t pos) __reentrant +ao_storage_erase(uint32_t pos) { ao_mutex_get(&ao_flash_mutex); { ao_flash_flush_internal(); @@ -290,7 +290,7 @@ ao_storage_erase(uint32_t pos) __reentrant } void -ao_storage_device_info(void) __reentrant +ao_storage_device_info(void) { uint8_t status; diff --git a/src/drivers/ao_btm.c b/src/drivers/ao_btm.c index c65a8548..3591f8f2 100644 --- a/src/drivers/ao_btm.c +++ b/src/drivers/ao_btm.c @@ -30,12 +30,12 @@ #endif int8_t ao_btm_stdio; -__xdata uint8_t ao_btm_connected; +uint8_t ao_btm_connected; #define BT_DEBUG 0 #if BT_DEBUG -__xdata char ao_btm_buffer[256]; +char ao_btm_buffer[256]; uint16_t ao_btm_ptr; char ao_btm_dir; @@ -137,7 +137,7 @@ ao_btm_send(void) ao_wakeup((void *) &ao_serial_btm_rx_fifo); } -__code struct ao_cmds ao_btm_cmds[] = { +const struct ao_cmds ao_btm_cmds[] = { { ao_btm_dump, "d\0Dump btm buffer." }, { ao_btm_speed, "s <19200,57600>\0Set btm serial speed." }, { ao_btm_send, "S\0BTM interactive mode. ~ to exit." }, @@ -153,7 +153,7 @@ __code struct ao_cmds ao_btm_cmds[] = { #endif #define AO_BTM_MAX_REPLY 16 -__xdata char ao_btm_reply[AO_BTM_MAX_REPLY]; +char ao_btm_reply[AO_BTM_MAX_REPLY]; /* * Read one bluetooth character. @@ -252,7 +252,7 @@ ao_btm_wait_reply(void) } void -ao_btm_string(__code char *cmd) +ao_btm_string(const char *cmd) { char c; @@ -261,7 +261,7 @@ ao_btm_string(__code char *cmd) } uint8_t -ao_btm_cmd(__code char *cmd) +ao_btm_cmd(const char *cmd) { ao_btm_drain(); @@ -351,7 +351,7 @@ ao_btm_check_link() #endif } -__xdata struct ao_task ao_btm_task; +struct ao_task ao_btm_task; /* * A thread to initialize the bluetooth device and diff --git a/src/drivers/ao_cc1120.c b/src/drivers/ao_cc1120.c index 2f091485..d581c246 100644 --- a/src/drivers/ao_cc1120.c +++ b/src/drivers/ao_cc1120.c @@ -1066,7 +1066,7 @@ ao_radio_rx_wait(void) } uint8_t -ao_radio_recv(__xdata void *d, uint8_t size, uint8_t timeout) +ao_radio_recv(void *d, uint8_t size, uint8_t timeout) { uint8_t len; uint8_t radio_rssi = 0; diff --git a/src/drivers/ao_cc1200.c b/src/drivers/ao_cc1200.c index de282000..f2f9c372 100644 --- a/src/drivers/ao_cc1200.c +++ b/src/drivers/ao_cc1200.c @@ -988,7 +988,7 @@ ao_radio_dump_state(struct ao_radio_state *s) #endif uint8_t -ao_radio_recv(__xdata void *d, uint8_t size, uint8_t timeout) +ao_radio_recv(void *d, uint8_t size, uint8_t timeout) { uint8_t success = 0; diff --git a/src/drivers/ao_companion.c b/src/drivers/ao_companion.c index 598b5815..3967090b 100644 --- a/src/drivers/ao_companion.c +++ b/src/drivers/ao_companion.c @@ -43,12 +43,12 @@ AO_COMPANION_SPI_BUS); \ } while (0) -__xdata struct ao_companion_command ao_companion_command; -__xdata struct ao_companion_setup ao_companion_setup; +struct ao_companion_command ao_companion_command; +struct ao_companion_setup ao_companion_setup; -__xdata uint16_t ao_companion_data[AO_COMPANION_MAX_CHANNELS]; -__pdata uint8_t ao_companion_running; -__xdata uint8_t ao_companion_mutex; +uint16_t ao_companion_data[AO_COMPANION_MAX_CHANNELS]; +uint8_t ao_companion_running; +uint8_t ao_companion_mutex; static void ao_companion_send_command(uint8_t command) @@ -116,7 +116,7 @@ ao_companion(void) } void -ao_companion_status(void) __reentrant +ao_companion_status(void) { uint8_t i; printf("Companion running: %d\n", ao_companion_running); @@ -134,12 +134,12 @@ ao_companion_status(void) __reentrant printf("\n"); } -__code struct ao_cmds ao_companion_cmds[] = { +const struct ao_cmds ao_companion_cmds[] = { { ao_companion_status, "L\0Companion link status" }, { 0, NULL }, }; -static __xdata struct ao_task ao_companion_task; +static struct ao_task ao_companion_task; void ao_companion_init(void) diff --git a/src/drivers/ao_gps_sirf.c b/src/drivers/ao_gps_sirf.c index 8bebd610..bdd9410e 100644 --- a/src/drivers/ao_gps_sirf.c +++ b/src/drivers/ao_gps_sirf.c @@ -20,11 +20,11 @@ #include "ao.h" #endif -__xdata uint8_t ao_gps_new; -__xdata uint8_t ao_gps_mutex; -__pdata uint16_t ao_gps_tick; -__xdata struct ao_telemetry_location ao_gps_data; -__xdata struct ao_telemetry_satellite ao_gps_tracking_data; +uint8_t ao_gps_new; +uint8_t ao_gps_mutex; +uint16_t ao_gps_tick; +struct ao_telemetry_location ao_gps_data; +struct ao_telemetry_satellite ao_gps_tracking_data; static const char ao_gps_set_nmea[] = "\r\n$PSRF100,0,57600,8,1,0*37\r\n"; @@ -107,7 +107,7 @@ struct sirf_geodetic_nav_data { uint8_t hdop; }; -static __xdata struct sirf_geodetic_nav_data ao_sirf_data; +static struct sirf_geodetic_nav_data ao_sirf_data; struct sirf_measured_sat_data { uint8_t svid; @@ -121,10 +121,10 @@ struct sirf_measured_tracker_data { struct sirf_measured_sat_data sats[12]; }; -static __xdata struct sirf_measured_tracker_data ao_sirf_tracker_data; +static struct sirf_measured_tracker_data ao_sirf_tracker_data; -static __pdata uint16_t ao_sirf_cksum; -static __pdata uint16_t ao_sirf_len; +static uint16_t ao_sirf_cksum; +static uint16_t ao_sirf_len; #ifndef ao_sirf_getchar #define ao_sirf_getchar ao_serial1_getchar @@ -142,11 +142,11 @@ static uint8_t data_byte(void) return c; } -static char __xdata *sirf_target; +static char *sirf_target; static void sirf_u16(uint8_t offset) { - uint16_t __xdata *ptr = (uint16_t __xdata *) (sirf_target + offset); + uint16_t *ptr = (uint16_t *) (sirf_target + offset); uint16_t val; val = data_byte() << 8; @@ -156,16 +156,16 @@ static void sirf_u16(uint8_t offset) static void sirf_u8(uint8_t offset) { - uint8_t __xdata *ptr = (uint8_t __xdata *) (sirf_target + offset); + uint8_t *ptr = (uint8_t *) (sirf_target + offset); uint8_t val; val = data_byte (); *ptr = val; } -static void sirf_u32(uint8_t offset) __reentrant +static void sirf_u32(uint8_t offset) { - uint32_t __xdata *ptr = (uint32_t __xdata *) (sirf_target + offset); + uint32_t *ptr = (uint32_t *) (sirf_target + offset); uint32_t val; val = ((uint32_t) data_byte ()) << 24; @@ -194,7 +194,7 @@ struct sirf_packet_parse { }; static void -ao_sirf_parse(void __xdata *target, const struct sirf_packet_parse *parse) __reentrant +ao_sirf_parse(void *target, const struct sirf_packet_parse *parse) { uint8_t i, offset, j; @@ -258,7 +258,7 @@ static const struct sirf_packet_parse geodetic_nav_data_packet[] = { }; static void -ao_sirf_parse_41(void) __reentrant +ao_sirf_parse_41(void) { ao_sirf_parse(&ao_sirf_data, geodetic_nav_data_packet); } @@ -279,7 +279,7 @@ static const struct sirf_packet_parse measured_sat_data_packet[] = { }; static void -ao_sirf_parse_4(void) __reentrant +ao_sirf_parse_4(void) { uint8_t i; ao_sirf_parse(&ao_sirf_tracker_data, measured_tracker_data_packet); @@ -288,7 +288,7 @@ ao_sirf_parse_4(void) __reentrant } static void -ao_gps_setup(void) __reentrant +ao_gps_setup(void) { uint8_t i, k; ao_sirf_set_speed(AO_SERIAL_SPEED_4800); @@ -309,7 +309,7 @@ static const char ao_gps_set_message_rate[] = { }; void -ao_sirf_set_message_rate(uint8_t msg, uint8_t rate) __reentrant +ao_sirf_set_message_rate(uint8_t msg, uint8_t rate) { uint16_t cksum = 0x00a6; uint8_t i; @@ -337,7 +337,7 @@ static const uint8_t sirf_disable[] = { }; void -ao_gps(void) __reentrant +ao_gps(void) { uint8_t i, k; uint16_t cksum; @@ -443,7 +443,7 @@ ao_gps(void) __reentrant } } -__xdata struct ao_task ao_gps_task; +struct ao_task ao_gps_task; void ao_gps_init(void) diff --git a/src/drivers/ao_gps_skytraq.c b/src/drivers/ao_gps_skytraq.c index 3ecae435..193f20dc 100644 --- a/src/drivers/ao_gps_skytraq.c +++ b/src/drivers/ao_gps_skytraq.c @@ -33,20 +33,20 @@ #define ao_gps_set_speed ao_serial1_set_speed #endif -__xdata uint8_t ao_gps_new; -__xdata uint8_t ao_gps_mutex; -static __data char ao_gps_char; -static __data uint8_t ao_gps_cksum; -static __data uint8_t ao_gps_error; +uint8_t ao_gps_new; +uint8_t ao_gps_mutex; +static char ao_gps_char; +static uint8_t ao_gps_cksum; +static uint8_t ao_gps_error; -__pdata uint16_t ao_gps_tick; -__xdata struct ao_telemetry_location ao_gps_data; -__xdata struct ao_telemetry_satellite ao_gps_tracking_data; +uint16_t ao_gps_tick; +struct ao_telemetry_location ao_gps_data; +struct ao_telemetry_satellite ao_gps_tracking_data; -static __pdata uint16_t ao_gps_next_tick; -static __pdata struct ao_telemetry_location ao_gps_next; -static __pdata uint8_t ao_gps_date_flags; -static __pdata struct ao_telemetry_satellite ao_gps_tracking_next; +static uint16_t ao_gps_next_tick; +static struct ao_telemetry_location ao_gps_next; +static uint8_t ao_gps_date_flags; +static struct ao_telemetry_satellite ao_gps_tracking_next; #define STQ_S 0xa0, 0xa1 #define STQ_E 0x0d, 0x0a @@ -60,7 +60,7 @@ static __pdata struct ao_telemetry_satellite ao_gps_tracking_next; STQ_S, 0,15, id, a,b,c,d,e,f,g,h,i,j,k,l,m,n, \ (id^a^b^c^d^e^f^g^h^i^j^k^l^m^n), STQ_E -static __code uint8_t ao_gps_config[] = { +static const uint8_t ao_gps_config[] = { SKYTRAQ_MSG_8(0x08, 1, 0, 1, 0, 1, 0, 0, 0), /* configure nmea */ /* gga interval */ /* gsa interval */ @@ -107,7 +107,7 @@ ao_gps_skip_sep(void) ao_gps_lexchar(); } -__data static uint8_t ao_gps_num_width; +static uint8_t ao_gps_num_width; static int16_t ao_gps_decimal(uint8_t max_width) @@ -162,11 +162,11 @@ ao_gps_hex(void) } static int32_t -ao_gps_parse_pos(uint8_t deg_width) __reentrant +ao_gps_parse_pos(uint8_t deg_width) { - static __pdata uint16_t d; - static __pdata uint8_t m; - static __pdata uint16_t f; + static uint16_t d; + static uint8_t m; + static uint16_t f; char c; d = ao_gps_decimal(deg_width); @@ -414,7 +414,7 @@ ao_nmea_rmc(void) #define ao_skytraq_sendstruct(s) ao_skytraq_sendbytes((s), sizeof(s)) static void -ao_skytraq_sendbytes(__code uint8_t *b, uint8_t l) +ao_skytraq_sendbytes(const uint8_t *b, uint8_t l) { while (l--) { uint8_t c = *b++; @@ -462,7 +462,7 @@ ao_gps_nmea_parse(void) static uint8_t ao_gps_updating; void -ao_gps(void) __reentrant +ao_gps(void) { ao_gps_set_speed(AO_SERIAL_SPEED_9600); @@ -486,9 +486,9 @@ ao_gps(void) __reentrant } } -__xdata struct ao_task ao_gps_task; +struct ao_task ao_gps_task; -static __code uint8_t ao_gps_115200[] = { +static const uint8_t ao_gps_115200[] = { SKYTRAQ_MSG_3(5,0,5,0) /* Set to 115200 baud */ }; @@ -500,7 +500,7 @@ ao_gps_set_speed_delay(uint8_t speed) { } static void -gps_update(void) __reentrant +gps_update(void) { ao_gps_updating = 1; ao_task_minimize_latency = 1; @@ -517,7 +517,7 @@ gps_update(void) __reentrant ao_gps_putchar(ao_usb_getchar()); } -__code struct ao_cmds ao_gps_cmds[] = { +const struct ao_cmds ao_gps_cmds[] = { { ao_gps_show, "g\0Display GPS" }, { gps_update, "U\0Update GPS firmware" }, { 0, NULL }, diff --git a/src/drivers/ao_gps_ublox.c b/src/drivers/ao_gps_ublox.c index c720f802..f5268aa7 100644 --- a/src/drivers/ao_gps_ublox.c +++ b/src/drivers/ao_gps_ublox.c @@ -26,11 +26,11 @@ #include -__xdata uint8_t ao_gps_new; -__xdata uint8_t ao_gps_mutex; -__pdata uint16_t ao_gps_tick; -__xdata struct ao_telemetry_location ao_gps_data; -__xdata struct ao_telemetry_satellite ao_gps_tracking_data; +uint8_t ao_gps_new; +uint8_t ao_gps_mutex; +uint16_t ao_gps_tick; +struct ao_telemetry_location ao_gps_data; +struct ao_telemetry_satellite ao_gps_tracking_data; #undef AO_SERIAL_SPEED_UBLOX @@ -58,8 +58,8 @@ struct ao_ublox_cksum { uint8_t a, b; }; -static __pdata struct ao_ublox_cksum ao_ublox_cksum; -static __pdata uint16_t ao_ublox_len; +static struct ao_ublox_cksum ao_ublox_cksum; +static uint16_t ao_ublox_len; #if AO_UBLOX_DEBUG @@ -152,11 +152,11 @@ static uint8_t data_byte(void) return header_byte(); } -static char __xdata *ublox_target; +static char *ublox_target; static void ublox_u16(uint8_t offset) { - uint16_t __xdata *ptr = (uint16_t __xdata *) (void __xdata *) (ublox_target + offset); + uint16_t *ptr = (uint16_t *) (void *) (ublox_target + offset); uint16_t val; val = data_byte(); @@ -166,16 +166,16 @@ static void ublox_u16(uint8_t offset) static void ublox_u8(uint8_t offset) { - uint8_t __xdata *ptr = (uint8_t __xdata *) (ublox_target + offset); + uint8_t *ptr = (uint8_t *) (ublox_target + offset); uint8_t val; val = data_byte (); *ptr = val; } -static void ublox_u32(uint8_t offset) __reentrant +static void ublox_u32(uint8_t offset) { - uint32_t __xdata *ptr = (uint32_t __xdata *) (void __xdata *) (ublox_target + offset); + uint32_t *ptr = (uint32_t *) (void *) (ublox_target + offset); uint32_t val; val = ((uint32_t) data_byte ()); @@ -203,7 +203,7 @@ struct ublox_packet_parse { }; static void -ao_ublox_parse(void __xdata *target, const struct ublox_packet_parse *parse) __reentrant +ao_ublox_parse(void *target, const struct ublox_packet_parse *parse) { uint8_t i, offset; @@ -610,7 +610,7 @@ ao_gps_set_rate(uint8_t rate) } void -ao_gps(void) __reentrant +ao_gps(void) { uint8_t class, id; struct ao_ublox_cksum cksum; @@ -796,12 +796,12 @@ static void ao_gps_option(void) #define ao_gps_option ao_gps_show #endif -__code struct ao_cmds ao_gps_cmds[] = { +const struct ao_cmds ao_gps_cmds[] = { { ao_gps_option, "g\0Display GPS" }, { 0, NULL }, }; -__xdata struct ao_task ao_gps_task; +struct ao_task ao_gps_task; void ao_gps_init(void) diff --git a/src/drivers/ao_lcd.c b/src/drivers/ao_lcd.c index c35093bc..294361eb 100644 --- a/src/drivers/ao_lcd.c +++ b/src/drivers/ao_lcd.c @@ -20,7 +20,7 @@ static uint16_t ao_lcd_time = 3; -static __xdata uint8_t ao_lcd_mutex; +static uint8_t ao_lcd_mutex; static void ao_lcd_delay(void) diff --git a/src/drivers/ao_lco.c b/src/drivers/ao_lco.c index e892c8c0..86635200 100644 --- a/src/drivers/ao_lco.c +++ b/src/drivers/ao_lco.c @@ -324,7 +324,7 @@ ao_lco_set_debug(void) ao_lco_debug = ao_cmd_lex_i != 0; } -__code struct ao_cmds ao_lco_cmds[] = { +const struct ao_cmds ao_lco_cmds[] = { { ao_lco_set_debug, "D <0 off, 1 on>\0Debug" }, { ao_lco_search, "s\0Search for pad boxes" }, { 0, NULL } diff --git a/src/drivers/ao_lco_cmd.c b/src/drivers/ao_lco_cmd.c index dba9a76a..3fcdc859 100644 --- a/src/drivers/ao_lco_cmd.c +++ b/src/drivers/ao_lco_cmd.c @@ -26,12 +26,12 @@ #define HAS_STATIC_TEST 1 #endif -static __pdata uint16_t lco_box; -static __pdata uint8_t lco_channels; -static __pdata uint16_t tick_offset; +static uint16_t lco_box; +static uint8_t lco_channels; +static uint16_t tick_offset; static void -lco_args(void) __reentrant +lco_args(void) { ao_cmd_decimal(); lco_box = ao_cmd_lex_i; @@ -71,7 +71,7 @@ lco_ignite(uint8_t cmd) } static void -lco_report_cmd(void) __reentrant +lco_report_cmd(void) { int8_t r; uint8_t c; @@ -122,7 +122,7 @@ lco_report_cmd(void) __reentrant } static void -lco_fire_cmd(void) __reentrant +lco_fire_cmd(void) { uint8_t secs; uint8_t i; @@ -156,7 +156,7 @@ lco_fire_cmd(void) __reentrant #if HAS_STATIC_TEST static void -lco_static_cmd(void) __reentrant +lco_static_cmd(void) { uint8_t secs; uint8_t i; @@ -190,7 +190,7 @@ lco_static_cmd(void) __reentrant #endif static void -lco_arm_cmd(void) __reentrant +lco_arm_cmd(void) { uint8_t i; int8_t r; @@ -205,7 +205,7 @@ lco_arm_cmd(void) __reentrant } static void -lco_ignite_cmd(void) __reentrant +lco_ignite_cmd(void) { uint8_t i; lco_args(); @@ -216,13 +216,13 @@ lco_ignite_cmd(void) __reentrant #if HAS_STATIC_TEST static void -lco_endstatic_cmd(void) __reentrant +lco_endstatic_cmd(void) { lco_ignite(AO_PAD_ENDSTATIC); } #endif -static __code struct ao_cmds ao_lco_cmds[] = { +static const struct ao_cmds ao_lco_cmds[] = { { lco_report_cmd, "l \0Get remote status" }, { lco_fire_cmd, "F \0Fire remote igniters" }, #if HAS_STATIC_TEST diff --git a/src/drivers/ao_lco_func.c b/src/drivers/ao_lco_func.c index 92b344ed..06350694 100644 --- a/src/drivers/ao_lco_func.c +++ b/src/drivers/ao_lco_func.c @@ -21,8 +21,8 @@ #include #include -static __xdata struct ao_pad_command command; -static __xdata uint8_t ao_lco_mutex; +static struct ao_pad_command command; +static uint8_t ao_lco_mutex; int8_t ao_lco_query(uint16_t box, struct ao_pad_query *query, uint16_t *tick_offset) diff --git a/src/drivers/ao_lco_two.c b/src/drivers/ao_lco_two.c index 6f2d81ff..12c02e88 100644 --- a/src/drivers/ao_lco_two.c +++ b/src/drivers/ao_lco_two.c @@ -129,7 +129,7 @@ ao_lco_set_debug(void) ao_lco_debug = ao_cmd_lex_i; } -__code struct ao_cmds ao_lco_cmds[] = { +const struct ao_cmds ao_lco_cmds[] = { { ao_lco_set_debug, "D <0 off, 1 on>\0Debug" }, { 0, NULL } }; diff --git a/src/drivers/ao_m25.c b/src/drivers/ao_m25.c index b506b0a7..72617cc4 100644 --- a/src/drivers/ao_m25.c +++ b/src/drivers/ao_m25.c @@ -19,16 +19,16 @@ #include "ao.h" /* Total bytes of available storage */ -__pdata uint32_t ao_storage_total; +uint32_t ao_storage_total; /* Block size - device is erased in these units. At least 256 bytes */ -__pdata uint32_t ao_storage_block; +uint32_t ao_storage_block; /* Byte offset of config block. Will be ao_storage_block bytes long */ -__pdata uint32_t ao_storage_config; +uint32_t ao_storage_config; /* Storage unit size - device reads and writes must be within blocks of this size. Usually 256 bytes. */ -__pdata uint16_t ao_storage_unit; +uint16_t ao_storage_unit; #define M25_DEBUG 0 /* @@ -89,7 +89,7 @@ static uint8_t ao_m25_numchips; /* number of chips detected */ static uint8_t ao_m25_total; /* total sectors available */ static ao_port_t ao_m25_wip; /* write in progress */ -static __xdata uint8_t ao_m25_mutex; +static uint8_t ao_m25_mutex; /* * This little array is abused to send and receive data. A particular @@ -99,7 +99,7 @@ static __xdata uint8_t ao_m25_mutex; * of which touch those last three bytes. */ -static __xdata uint8_t ao_m25_instruction[4]; +static uint8_t ao_m25_instruction[4]; #define M25_SELECT(cs) ao_spi_get_mask(AO_M25_SPI_CS_PORT,cs,AO_M25_SPI_BUS, AO_SPI_SPEED_FAST) #define M25_DESELECT(cs) ao_spi_put_mask(AO_M25_SPI_CS_PORT,cs,AO_M25_SPI_BUS) @@ -239,7 +239,7 @@ ao_m25_scan(void) * Erase the specified sector */ uint8_t -ao_storage_erase(uint32_t pos) __reentrant +ao_storage_erase(uint32_t pos) { ao_port_t cs; @@ -267,7 +267,7 @@ ao_storage_erase(uint32_t pos) __reentrant * Write to flash */ uint8_t -ao_storage_device_write(uint32_t pos, __xdata void *d, uint16_t len) __reentrant +ao_storage_device_write(uint32_t pos, void *d, uint16_t len) { ao_port_t cs; @@ -294,7 +294,7 @@ ao_storage_device_write(uint32_t pos, __xdata void *d, uint16_t len) __reentrant * Read from flash */ uint8_t -ao_storage_device_read(uint32_t pos, __xdata void *d, uint16_t len) __reentrant +ao_storage_device_read(uint32_t pos, void *d, uint16_t len) { ao_port_t cs; @@ -317,7 +317,7 @@ ao_storage_device_read(uint32_t pos, __xdata void *d, uint16_t len) __reentrant } void -ao_storage_flush(void) __reentrant +ao_storage_flush(void) { } @@ -330,7 +330,7 @@ ao_storage_setup(void) } void -ao_storage_device_info(void) __reentrant +ao_storage_device_info(void) { #if M25_DEBUG ao_port_t cs; diff --git a/src/drivers/ao_mma655x.c b/src/drivers/ao_mma655x.c index 5d44bffd..a48c1db2 100644 --- a/src/drivers/ao_mma655x.c +++ b/src/drivers/ao_mma655x.c @@ -259,7 +259,7 @@ ao_mma655x_dump(void) printf ("MMA655X value %d\n", ao_mma655x_current); } -__code struct ao_cmds ao_mma655x_cmds[] = { +const struct ao_cmds ao_mma655x_cmds[] = { { ao_mma655x_dump, "A\0Display MMA655X data" }, { 0, NULL }, }; @@ -277,7 +277,7 @@ ao_mma655x(void) } } -static __xdata struct ao_task ao_mma655x_task; +static struct ao_task ao_mma655x_task; void ao_mma655x_init(void) diff --git a/src/drivers/ao_mr25.c b/src/drivers/ao_mr25.c index 2d355c9f..86dda22a 100644 --- a/src/drivers/ao_mr25.c +++ b/src/drivers/ao_mr25.c @@ -19,16 +19,16 @@ #include "ao.h" /* Total bytes of available storage */ -__pdata uint32_t ao_storage_total; +uint32_t ao_storage_total; /* Block size - device is erased in these units. At least 256 bytes */ -__pdata uint32_t ao_storage_block; +uint32_t ao_storage_block; /* Byte offset of config block. Will be ao_storage_block bytes long */ -__pdata uint32_t ao_storage_config; +uint32_t ao_storage_config; /* Storage unit size - device reads and writes must be within blocks of this size. Usually 256 bytes. */ -__pdata uint16_t ao_storage_unit; +uint16_t ao_storage_unit; /* * MRAM is entirely random access; no erase operations are required, @@ -51,7 +51,7 @@ __pdata uint16_t ao_storage_unit; #define MR25_STATUS_BP_SHIFT (2) #define MR25_STATUS_WEL (1 << 1) /* Write enable latch */ -static __xdata uint8_t ao_mr25_mutex; +static uint8_t ao_mr25_mutex; /* * This little array is abused to send and receive data. A particular @@ -61,7 +61,7 @@ static __xdata uint8_t ao_mr25_mutex; * those last three bytes. */ -static __xdata uint8_t ao_mr25_instruction[4]; +static uint8_t ao_mr25_instruction[4]; #define MR25_SELECT() ao_spi_get_mask(AO_MR25_SPI_CS_PORT,(1 << AO_MR25_SPI_CS_PIN),AO_MR25_SPI_BUS, AO_SPI_SPEED_FAST) #define MR25_DESELECT() ao_spi_put_mask(AO_MR25_SPI_CS_PORT,(1 << AO_MR25_SPI_CS_PIN),AO_MR25_SPI_BUS) @@ -93,7 +93,7 @@ ao_mr25_set_address(uint32_t pos) * Erase the specified sector (no-op for MRAM) */ uint8_t -ao_storage_erase(uint32_t pos) __reentrant +ao_storage_erase(uint32_t pos) { if (pos >= ao_storage_total || pos + ao_storage_block > ao_storage_total) return 0; @@ -104,7 +104,7 @@ ao_storage_erase(uint32_t pos) __reentrant * Write to flash */ uint8_t -ao_storage_device_write(uint32_t pos, __xdata void *d, uint16_t len) __reentrant +ao_storage_device_write(uint32_t pos, void *d, uint16_t len) { if (pos >= ao_storage_total || pos + len > ao_storage_total) return 0; @@ -128,7 +128,7 @@ ao_storage_device_write(uint32_t pos, __xdata void *d, uint16_t len) __reentrant * Read from flash */ uint8_t -ao_storage_device_read(uint32_t pos, __xdata void *d, uint16_t len) __reentrant +ao_storage_device_read(uint32_t pos, void *d, uint16_t len) { if (pos >= ao_storage_total || pos + len > ao_storage_total) return 0; @@ -147,7 +147,7 @@ ao_storage_device_read(uint32_t pos, __xdata void *d, uint16_t len) __reentrant } void -ao_storage_flush(void) __reentrant +ao_storage_flush(void) { } @@ -157,7 +157,7 @@ ao_storage_setup(void) } void -ao_storage_device_info(void) __reentrant +ao_storage_device_info(void) { printf ("Detected chips 1 size %d\n", ao_storage_total >> 8); } diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c index 4bfc17db..a468fee3 100644 --- a/src/drivers/ao_ms5607.c +++ b/src/drivers/ao_ms5607.c @@ -22,8 +22,8 @@ #if HAS_MS5607 || HAS_MS5611 -__xdata struct ao_ms5607_prom ao_ms5607_prom; -static __xdata uint8_t ms5607_configured; +struct ao_ms5607_prom ao_ms5607_prom; +static uint8_t ms5607_configured; #ifndef AO_MS5607_SPI_SPEED #define AO_MS5607_SPI_SPEED AO_SPI_SPEED_FAST @@ -97,12 +97,12 @@ ao_ms5607_prom_valid(uint8_t *prom) } static void -ao_ms5607_prom_read(__xdata struct ao_ms5607_prom *prom) +ao_ms5607_prom_read(struct ao_ms5607_prom *prom) { uint8_t addr; uint16_t *r; - r = (__xdata uint16_t *) prom; + r = (uint16_t *) prom; for (addr = 0; addr < 8; addr++) { uint8_t cmd = AO_MS5607_PROM_READ(addr); ao_ms5607_start(); @@ -138,20 +138,20 @@ ao_ms5607_setup(void) ao_ms5607_prom_read(&ao_ms5607_prom); } -static __xdata volatile uint8_t ao_ms5607_done; +static volatile uint8_t ao_ms5607_done; static void ao_ms5607_isr(void) { ao_exti_disable(AO_MS5607_MISO_PORT, AO_MS5607_MISO_PIN); ao_ms5607_done = 1; - ao_wakeup((__xdata void *) &ao_ms5607_done); + ao_wakeup((void *) &ao_ms5607_done); } static uint32_t ao_ms5607_get_sample(uint8_t cmd) { - __xdata uint8_t reply[3]; - __xdata uint8_t read; + uint8_t reply[3]; + uint8_t read; ao_ms5607_done = 0; @@ -198,7 +198,7 @@ ao_ms5607_get_sample(uint8_t cmd) { #define AO_CONVERT_D2 token_evaluator(AO_MS5607_CONVERT_D2_, AO_MS5607_TEMP_OVERSAMPLE) void -ao_ms5607_sample(__xdata struct ao_ms5607_sample *sample) +ao_ms5607_sample(struct ao_ms5607_sample *sample) { sample->pres = ao_ms5607_get_sample(AO_CONVERT_D1); sample->temp = ao_ms5607_get_sample(AO_CONVERT_D2); @@ -214,7 +214,7 @@ ao_ms5607_sample(__xdata struct ao_ms5607_sample *sample) #define HAS_MS5607_TASK HAS_TASK #endif -__xdata struct ao_ms5607_sample ao_ms5607_current; +struct ao_ms5607_sample ao_ms5607_current; #if HAS_MS5607_TASK static void @@ -233,7 +233,7 @@ ao_ms5607(void) } } -__xdata struct ao_task ao_ms5607_task; +struct ao_task ao_ms5607_task; #endif #if HAS_TASK @@ -253,7 +253,7 @@ ao_ms5607_info(void) static void ao_ms5607_dump(void) { - __xdata struct ao_ms5607_value value; + struct ao_ms5607_value value; ao_ms5607_convert(&ao_ms5607_current, &value); printf ("Pressure: %8lu %8ld\n", ao_ms5607_current.pres, value.pres); @@ -261,7 +261,7 @@ ao_ms5607_dump(void) printf ("Altitude: %ld\n", ao_pa_to_altitude(value.pres)); } -__code struct ao_cmds ao_ms5607_cmds[] = { +const struct ao_cmds ao_ms5607_cmds[] = { { ao_ms5607_dump, "B\0Display MS5607 data" }, { 0, NULL }, }; diff --git a/src/drivers/ao_ms5607.h b/src/drivers/ao_ms5607.h index 18f99bf8..322cc468 100644 --- a/src/drivers/ao_ms5607.h +++ b/src/drivers/ao_ms5607.h @@ -57,8 +57,8 @@ struct ao_ms5607_value { int32_t temp; /* in °C * 100 */ }; -extern __xdata struct ao_ms5607_sample ao_ms5607_current; -extern __xdata struct ao_ms5607_prom ao_ms5607_prom; +extern struct ao_ms5607_sample ao_ms5607_current; +extern struct ao_ms5607_prom ao_ms5607_prom; void ao_ms5607_setup(void); @@ -70,10 +70,10 @@ void ao_ms5607_info(void); void -ao_ms5607_sample(__xdata struct ao_ms5607_sample *sample); +ao_ms5607_sample(struct ao_ms5607_sample *sample); void -ao_ms5607_convert(__xdata struct ao_ms5607_sample *sample, - __xdata struct ao_ms5607_value *value); +ao_ms5607_convert(struct ao_ms5607_sample *sample, + struct ao_ms5607_value *value); #endif /* _AO_MS5607_H_ */ diff --git a/src/drivers/ao_ms5607_convert_8051.c b/src/drivers/ao_ms5607_convert_8051.c index b7081107..e9052b41 100644 --- a/src/drivers/ao_ms5607_convert_8051.c +++ b/src/drivers/ao_ms5607_convert_8051.c @@ -32,8 +32,8 @@ #endif void -ao_ms5607_convert(__xdata struct ao_ms5607_sample *sample, - __xdata struct ao_ms5607_value *value) +ao_ms5607_convert(struct ao_ms5607_sample *sample, + struct ao_ms5607_value *value) { __LOCAL int32_t dT; __LOCAL int32_t TEMP; diff --git a/src/drivers/ao_packet.c b/src/drivers/ao_packet.c index 1c931921..b5a0a4b7 100644 --- a/src/drivers/ao_packet.c +++ b/src/drivers/ao_packet.c @@ -18,20 +18,20 @@ #include "ao.h" -__xdata struct ao_packet_recv ao_rx_packet; -__xdata struct ao_packet ao_tx_packet; -__pdata uint8_t ao_packet_rx_len, ao_packet_rx_used, ao_packet_tx_used; +struct ao_packet_recv ao_rx_packet; +struct ao_packet ao_tx_packet; +uint8_t ao_packet_rx_len, ao_packet_rx_used, ao_packet_tx_used; -static __xdata uint8_t tx_data[AO_PACKET_MAX]; -static __xdata uint8_t rx_data[AO_PACKET_MAX]; -static __pdata uint8_t rx_seq; +static uint8_t tx_data[AO_PACKET_MAX]; +static uint8_t rx_data[AO_PACKET_MAX]; +static uint8_t rx_seq; -__xdata struct ao_task ao_packet_task; -__xdata uint8_t ao_packet_enable; -__xdata uint8_t ao_packet_restart; +struct ao_task ao_packet_task; +uint8_t ao_packet_enable; +uint8_t ao_packet_restart; #if PACKET_HAS_MASTER -__xdata uint8_t ao_packet_master_sleeping; +uint8_t ao_packet_master_sleeping; #endif void @@ -150,7 +150,7 @@ ao_packet_flush(void) #endif /* PACKET_HAS_MASTER */ void -ao_packet_putchar(char c) __reentrant +ao_packet_putchar(char c) { /* No need to block interrupts, all variables here * are only manipulated in task context diff --git a/src/drivers/ao_packet_master.c b/src/drivers/ao_packet_master.c index e63771e5..68a5efef 100644 --- a/src/drivers/ao_packet_master.c +++ b/src/drivers/ao_packet_master.c @@ -39,7 +39,7 @@ ao_packet_getchar(void) } static void -ao_packet_echo(void) __reentrant +ao_packet_echo(void) { int c; while (ao_packet_enable) { @@ -50,9 +50,9 @@ ao_packet_echo(void) __reentrant ao_exit(); } -static __xdata struct ao_task ao_packet_echo_task; -static __xdata uint16_t ao_packet_master_delay; -static __xdata uint16_t ao_packet_master_time; +static struct ao_task ao_packet_echo_task; +static uint16_t ao_packet_master_delay; +static uint16_t ao_packet_master_time; #define AO_PACKET_MASTER_DELAY_SHORT AO_MS_TO_TICKS(100) #define AO_PACKET_MASTER_DELAY_LONG AO_MS_TO_TICKS(1000) @@ -114,7 +114,7 @@ ao_packet_master(void) } static void -ao_packet_forward(void) __reentrant +ao_packet_forward(void) { char c; ao_packet_enable = 1; @@ -152,7 +152,7 @@ ao_packet_signal(void) printf ("RSSI: %d\n", ao_radio_rssi); } -__code struct ao_cmds ao_packet_master_cmds[] = { +const struct ao_cmds ao_packet_master_cmds[] = { { ao_packet_forward, "p\0Remote packet link." }, { ao_packet_signal, "s\0Report signal strength." }, { 0, NULL }, diff --git a/src/drivers/ao_pad.c b/src/drivers/ao_pad.c index 208841fb..7e139c78 100644 --- a/src/drivers/ao_pad.c +++ b/src/drivers/ao_pad.c @@ -22,14 +22,14 @@ #include #include -static __xdata uint8_t ao_pad_ignite; -static __xdata struct ao_pad_command command; -static __xdata struct ao_pad_query query; -static __pdata uint8_t ao_pad_armed; -static __pdata uint16_t ao_pad_arm_time; -static __pdata uint8_t ao_pad_box; -static __xdata uint8_t ao_pad_disabled; -static __pdata uint16_t ao_pad_packet_time; +static uint8_t ao_pad_ignite; +static struct ao_pad_command command; +static struct ao_pad_query query; +static uint8_t ao_pad_armed; +static uint16_t ao_pad_arm_time; +static uint8_t ao_pad_box; +static uint8_t ao_pad_disabled; +static uint16_t ao_pad_packet_time; #ifndef AO_PAD_RSSI_MINIMUM #define AO_PAD_RSSI_MINIMUM -90 @@ -38,7 +38,7 @@ static __pdata uint16_t ao_pad_packet_time; #define DEBUG 1 #if DEBUG -static __pdata uint8_t ao_pad_debug; +static uint8_t ao_pad_debug; #define PRINTD(...) (ao_pad_debug ? (printf(__VA_ARGS__), 0) : 0) #define FLUSHD() (ao_pad_debug ? (flush(), 0) : 0) #else @@ -189,17 +189,17 @@ ao_pad_monitor(void) { uint8_t c; uint8_t sample; - __pdata AO_LED_TYPE prev = 0, cur = 0; - __pdata uint8_t beeping = 0; - __xdata volatile struct ao_data *packet; - __pdata uint16_t arm_beep_time = 0; + AO_LED_TYPE prev = 0, cur = 0; + uint8_t beeping = 0; + volatile struct ao_data *packet; + uint16_t arm_beep_time = 0; sample = ao_data_head; ao_led_set(LEDS_AVAILABLE); ao_delay(AO_MS_TO_TICKS(1000)); ao_led_set(0); for (;;) { - __pdata int16_t pyro; + int16_t pyro; ao_arch_critical( while (sample == ao_data_head) @@ -526,9 +526,9 @@ ao_pad_manual(void) } } -static __xdata struct ao_task ao_pad_task; -static __xdata struct ao_task ao_pad_ignite_task; -static __xdata struct ao_task ao_pad_monitor_task; +static struct ao_task ao_pad_task; +static struct ao_task ao_pad_ignite_task; +static struct ao_task ao_pad_monitor_task; #if DEBUG void @@ -560,7 +560,7 @@ ao_pad_alarm_debug(void) } #endif -__code struct ao_cmds ao_pad_cmds[] = { +const struct ao_cmds ao_pad_cmds[] = { { ao_pad_test, "t\0Test pad continuity" }, { ao_pad_manual, "i \0Fire igniter. is doit with D&I" }, #if DEBUG diff --git a/src/drivers/ao_pca9922.c b/src/drivers/ao_pca9922.c index 09f52a0e..3516f03a 100644 --- a/src/drivers/ao_pca9922.c +++ b/src/drivers/ao_pca9922.c @@ -23,7 +23,7 @@ #include -static __xdata uint8_t ao_led_state; +static uint8_t ao_led_state; static void ao_led_apply(void) @@ -93,7 +93,7 @@ ao_led_toggle(uint8_t colors) } void -ao_led_for(uint8_t colors, uint16_t ticks) __reentrant +ao_led_for(uint8_t colors, uint16_t ticks) { ao_led_on(colors); ao_delay(ticks); diff --git a/src/drivers/ao_pyro_slave.c b/src/drivers/ao_pyro_slave.c index a293d929..8ea6d858 100644 --- a/src/drivers/ao_pyro_slave.c +++ b/src/drivers/ao_pyro_slave.c @@ -33,7 +33,7 @@ static const struct ao_companion_setup ao_telepyro_setup = { struct ao_config ao_config; -extern volatile __data uint16_t ao_tick_count; +extern volatile uint16_t ao_tick_count; uint16_t ao_boost_tick; void ao_spi_slave(void) diff --git a/src/drivers/ao_quadrature.c b/src/drivers/ao_quadrature.c index 250e035f..20781c40 100644 --- a/src/drivers/ao_quadrature.c +++ b/src/drivers/ao_quadrature.c @@ -22,7 +22,7 @@ #include #include -__xdata int32_t ao_quadrature_count[AO_QUADRATURE_COUNT]; +int32_t ao_quadrature_count[AO_QUADRATURE_COUNT]; #ifndef AO_QUADRATURE_SINGLE_CODE static int8_t ao_quadrature_step[AO_QUADRATURE_COUNT]; #endif diff --git a/src/drivers/ao_quadrature.h b/src/drivers/ao_quadrature.h index a99e4cc5..ee551f65 100644 --- a/src/drivers/ao_quadrature.h +++ b/src/drivers/ao_quadrature.h @@ -19,7 +19,7 @@ #ifndef _AO_QUADRATURE_H_ #define _AO_QUADRATURE_H_ -extern __xdata int32_t ao_quadrature_count[AO_QUADRATURE_COUNT]; +extern int32_t ao_quadrature_count[AO_QUADRATURE_COUNT]; int32_t ao_quadrature_wait(uint8_t q); diff --git a/src/drivers/ao_radio_master.c b/src/drivers/ao_radio_master.c index 79e4b22b..8b62a4de 100644 --- a/src/drivers/ao_radio_master.c +++ b/src/drivers/ao_radio_master.c @@ -21,15 +21,15 @@ #include #include -static __xdata struct ao_radio_spi_reply ao_radio_spi_reply; -static __xdata struct ao_radio_spi_request ao_radio_spi_request; -static volatile __xdata uint8_t ao_radio_wait_mode; -static volatile __xdata uint8_t ao_radio_done = 0; -static volatile __xdata uint8_t ao_radio_ready = 1; -static __xdata uint8_t ao_radio_mutex; -static __xdata uint8_t ao_radio_aes_seq; +static struct ao_radio_spi_reply ao_radio_spi_reply; +static struct ao_radio_spi_request ao_radio_spi_request; +static volatile uint8_t ao_radio_wait_mode; +static volatile uint8_t ao_radio_done = 0; +static volatile uint8_t ao_radio_ready = 1; +static uint8_t ao_radio_mutex; +static uint8_t ao_radio_aes_seq; -__xdata int8_t ao_radio_cmac_rssi; +int8_t ao_radio_cmac_rssi; #if 0 #define PRINTD(...) do { printf ("\r%5u %s: ", ao_tick_count, __func__); printf(__VA_ARGS__); flush(); } while(0) @@ -126,7 +126,7 @@ ao_radio_put(void) } static void -ao_radio_get_data(__xdata void *d, uint8_t size) +ao_radio_get_data(void *d, uint8_t size) { PRINTD ("fetch\n"); ao_radio_master_start(); @@ -157,7 +157,7 @@ ao_radio_send(const void *d, uint8_t size) uint8_t -ao_radio_recv(__xdata void *d, uint8_t size, uint8_t timeout) +ao_radio_recv(void *d, uint8_t size, uint8_t timeout) { int8_t ret; uint8_t recv; @@ -198,7 +198,7 @@ ao_radio_cmac_set_key(void) } int8_t -ao_radio_cmac_send(__xdata void *packet, uint8_t len) __reentrant +ao_radio_cmac_send(void *packet, uint8_t len) { if (len > AO_CMAC_MAX_LEN) return AO_RADIO_CMAC_LEN_ERROR; @@ -220,7 +220,7 @@ ao_radio_cmac_send(__xdata void *packet, uint8_t len) __reentrant } int8_t -ao_radio_cmac_recv(__xdata void *packet, uint8_t len, uint16_t timeout) __reentrant +ao_radio_cmac_recv(void *packet, uint8_t len, uint16_t timeout) { int8_t ret; int8_t recv; @@ -296,7 +296,7 @@ ao_radio_test_cmd(void) ao_radio_test(0); } -__code struct ao_cmds ao_radio_cmds[] = { +const struct ao_cmds ao_radio_cmds[] = { { ao_radio_test_cmd, "C <1 start, 0 stop, none both>\0Radio carrier test" }, { 0, NULL }, }; diff --git a/src/drivers/ao_radio_slave.c b/src/drivers/ao_radio_slave.c index 2f1dab29..7859d6b6 100644 --- a/src/drivers/ao_radio_slave.c +++ b/src/drivers/ao_radio_slave.c @@ -20,11 +20,11 @@ #include #include -static __xdata struct ao_radio_spi_reply ao_radio_spi_reply; +static struct ao_radio_spi_reply ao_radio_spi_reply; -static __xdata struct ao_radio_spi_request ao_radio_spi_request; +static struct ao_radio_spi_request ao_radio_spi_request; -static __xdata uint8_t slave_state; +static uint8_t slave_state; static void ao_radio_slave_low(void) @@ -123,7 +123,7 @@ ao_radio_slave_spi(void) } } -static __xdata struct ao_task ao_radio_slave_spi_task; +static struct ao_task ao_radio_slave_spi_task; void ao_radio_slave_init(void) diff --git a/src/drivers/ao_watchdog.c b/src/drivers/ao_watchdog.c index 1a877fcb..01c3cd0e 100644 --- a/src/drivers/ao_watchdog.c +++ b/src/drivers/ao_watchdog.c @@ -46,7 +46,7 @@ ao_watchdog_set(void) } -static __code struct ao_cmds ao_watchdog_cmds[] = { +static const struct ao_cmds ao_watchdog_cmds[] = { { ao_watchdog_set, "Q <0 off, 1 on>\0Enable or disable watchdog timer" }, { 0, NULL }, }; diff --git a/src/kernel/ao.h b/src/kernel/ao.h index 520f6ef2..fd1d1276 100644 --- a/src/kernel/ao.h +++ b/src/kernel/ao.h @@ -92,7 +92,7 @@ ao_panic(uint8_t reason); #define AO_TICK_SIGNED int16_t #endif -extern volatile __data AO_TICK_TYPE ao_tick_count; +extern volatile AO_TICK_TYPE ao_tick_count; /* Our timer runs at 100Hz */ #ifndef AO_HERTZ @@ -141,13 +141,13 @@ ao_clock_resume(void); #ifndef ao_mutex_get uint8_t -ao_mutex_try(__xdata uint8_t *ao_mutex, uint8_t task_id) __reentrant; +ao_mutex_try(uint8_t *ao_mutex, uint8_t task_id); void -ao_mutex_get(__xdata uint8_t *ao_mutex) __reentrant; +ao_mutex_get(uint8_t *ao_mutex); void -ao_mutex_put(__xdata uint8_t *ao_mutex) __reentrant; +ao_mutex_put(uint8_t *ao_mutex); #endif /* @@ -160,13 +160,13 @@ enum ao_cmd_status { ao_cmd_syntax_error = 2, }; -extern __pdata uint16_t ao_cmd_lex_i; -extern __pdata uint32_t ao_cmd_lex_u32; -extern __pdata char ao_cmd_lex_c; -extern __pdata enum ao_cmd_status ao_cmd_status; +extern uint16_t ao_cmd_lex_i; +extern uint32_t ao_cmd_lex_u32; +extern char ao_cmd_lex_c; +extern enum ao_cmd_status ao_cmd_status; void -ao_put_string(__code char *s); +ao_put_string(const char *s); void ao_cmd_readline(void); @@ -196,22 +196,22 @@ void ao_cmd_hex(void); void -ao_cmd_decimal(void) __reentrant; +ao_cmd_decimal(void); /* Read a single hex nibble off stdin. */ uint8_t ao_getnibble(void); uint8_t -ao_match_word(__code char *word); +ao_match_word(const char *word); struct ao_cmds { void (*func)(void); - __code char *help; + const char *help; }; void -ao_cmd_register(const __code struct ao_cmds *cmds); +ao_cmd_register(const struct ao_cmds *cmds); void ao_cmd_init(void); @@ -295,13 +295,13 @@ ao_report_init(void); #if HAS_BARO /* pressure from the sensor to altitude in meters */ alt_t -ao_pres_to_altitude(pres_t pres) __reentrant; +ao_pres_to_altitude(pres_t pres); pres_t -ao_altitude_to_pres(alt_t alt) __reentrant; +ao_altitude_to_pres(alt_t alt); int16_t -ao_temp_to_dC(int16_t temp) __reentrant; +ao_temp_to_dC(int16_t temp); #endif /* @@ -377,11 +377,11 @@ ao_spi_slave(void); #define AO_GPS_NEW_DATA 1 #define AO_GPS_NEW_TRACKING 2 -extern __xdata uint8_t ao_gps_new; -extern __pdata uint16_t ao_gps_tick; -extern __xdata uint8_t ao_gps_mutex; -extern __xdata struct ao_telemetry_location ao_gps_data; -extern __xdata struct ao_telemetry_satellite ao_gps_tracking_data; +extern uint8_t ao_gps_new; +extern uint16_t ao_gps_tick; +extern uint8_t ao_gps_mutex; +extern struct ao_telemetry_location ao_gps_data; +extern struct ao_telemetry_satellite ao_gps_tracking_data; struct ao_gps_orig { uint8_t year; @@ -421,13 +421,13 @@ void ao_gps(void); void -ao_gps_print(__xdata struct ao_gps_orig *gps_data); +ao_gps_print(struct ao_gps_orig *gps_data); void -ao_gps_tracking_print(__xdata struct ao_gps_tracking_orig *gps_tracking_data); +ao_gps_tracking_print(struct ao_gps_tracking_orig *gps_tracking_data); void -ao_gps_show(void) __reentrant; +ao_gps_show(void); void ao_gps_init(void); @@ -558,9 +558,9 @@ ao_telemetry_tiny_init(void); * ao_radio.c */ -extern __xdata uint8_t ao_radio_dma; +extern uint8_t ao_radio_dma; -extern __xdata int8_t ao_radio_rssi; +extern int8_t ao_radio_rssi; #ifdef PKT_APPEND_STATUS_1_CRC_OK #define AO_RADIO_STATUS_CRC_OK PKT_APPEND_STATUS_1_CRC_OK @@ -590,12 +590,12 @@ ao_radio_general_isr(void) ao_arch_interrupt(16); #if HAS_RADIO_XMIT void -ao_radio_send(const __xdata void *d, uint8_t size) __reentrant; +ao_radio_send(const void *d, uint8_t size); #endif #if HAS_RADIO_RECV uint8_t -ao_radio_recv(__xdata void *d, uint8_t size, uint8_t timeout) __reentrant; +ao_radio_recv(void *d, uint8_t size, uint8_t timeout); void ao_radio_recv_abort(void); @@ -673,14 +673,14 @@ union ao_monitor { #endif }; -extern __xdata union ao_monitor ao_monitor_ring[AO_MONITOR_RING]; +extern union ao_monitor ao_monitor_ring[AO_MONITOR_RING]; #define ao_monitor_ring_next(n) (((n) + 1) & (AO_MONITOR_RING - 1)) #define ao_monitor_ring_prev(n) (((n) - 1) & (AO_MONITOR_RING - 1)) -extern __xdata uint8_t ao_monitoring_mutex; -extern __data uint8_t ao_monitoring; -extern __data uint8_t ao_monitor_head; +extern uint8_t ao_monitoring_mutex; +extern uint8_t ao_monitoring; +extern uint8_t ao_monitor_head; void ao_monitor(void); @@ -698,7 +698,7 @@ void ao_monitor_enable(void); void -ao_monitor_init(void) __reentrant; +ao_monitor_init(void); #endif @@ -710,27 +710,27 @@ ao_monitor_init(void) __reentrant; struct ao_stdio { int (*_pollchar)(void); /* Called with interrupts blocked */ - void (*putchar)(char c) __reentrant; + void (*putchar)(char c); void (*flush)(void); uint8_t echo; }; -extern __xdata struct ao_stdio ao_stdios[]; -extern __pdata int8_t ao_cur_stdio; -extern __pdata int8_t ao_num_stdios; +extern struct ao_stdio ao_stdios[]; +extern int8_t ao_cur_stdio; +extern int8_t ao_num_stdios; void flush(void); -extern __xdata uint8_t ao_stdin_ready; +extern uint8_t ao_stdin_ready; uint8_t ao_echo(void); int8_t ao_add_stdio(int (*pollchar)(void), - void (*putchar)(char) __reentrant, - void (*flush)(void)) __reentrant; + void (*putchar)(char) , + void (*flush)(void)); /* * ao_ignite.c @@ -757,14 +757,14 @@ struct ao_ignition { uint8_t firing; }; -extern __code char * __code ao_igniter_status_names[]; +extern const char * const ao_igniter_status_names[]; -extern __xdata struct ao_ignition ao_ignition[2]; +extern struct ao_ignition ao_ignition[2]; enum ao_igniter_status ao_igniter_status(enum ao_igniter igniter); -extern __pdata uint8_t ao_igniter_present; +extern uint8_t ao_igniter_present; void ao_ignite_set_pins(void); @@ -785,7 +785,7 @@ ao_igniter_init(void); /* * Set this to force the frequency to 434.550MHz */ -extern __xdata uint8_t ao_force_freq; +extern uint8_t ao_force_freq; #endif /* @@ -885,8 +885,8 @@ union ao_log_single { uint8_t bytes[AO_LOG_SINGLE_SIZE]; }; -extern __xdata union ao_log_single ao_log_single_write_data; -extern __xdata union ao_log_single ao_log_single_read_data; +extern union ao_log_single ao_log_single_write_data; +extern union ao_log_single ao_log_single_read_data; void ao_log_single_extra_query(void); @@ -969,7 +969,7 @@ ao_sqrt(uint32_t op); * ao_freq.c */ -int32_t ao_freq_to_set(int32_t freq, int32_t cal) __reentrant; +int32_t ao_freq_to_set(int32_t freq, int32_t cal); /* * ao_ms5607.c diff --git a/src/kernel/ao_aes.h b/src/kernel/ao_aes.h index 5ae98424..f41b2e87 100644 --- a/src/kernel/ao_aes.h +++ b/src/kernel/ao_aes.h @@ -21,7 +21,7 @@ /* ao_aes.c */ -extern __xdata uint8_t ao_aes_mutex; +extern uint8_t ao_aes_mutex; /* AES keys and blocks are 128 bits */ @@ -40,14 +40,14 @@ void ao_aes_set_mode(enum ao_aes_mode mode); void -ao_aes_set_key(__xdata uint8_t *in); +ao_aes_set_key(uint8_t *in); void ao_aes_zero_iv(void); void -ao_aes_run(__xdata uint8_t *in, - __xdata uint8_t *out); +ao_aes_run(uint8_t *in, + uint8_t *out); void ao_aes_init(void); diff --git a/src/kernel/ao_balloon.c b/src/kernel/ao_balloon.c index d0f80a5d..a5be8c16 100644 --- a/src/kernel/ao_balloon.c +++ b/src/kernel/ao_balloon.c @@ -34,16 +34,16 @@ #if HAS_SENSOR_ERRORS /* Any sensor can set this to mark the flight computer as 'broken' */ -__xdata uint8_t ao_sensor_errors; +uint8_t ao_sensor_errors; #endif -__pdata uint16_t ao_motor_number; /* number of motors burned so far */ +uint16_t ao_motor_number; /* number of motors burned so far */ /* Main flight thread. */ -__pdata enum ao_flight_state ao_flight_state; /* current flight state */ +enum ao_flight_state ao_flight_state; /* current flight state */ -__pdata uint8_t ao_flight_force_idle; +uint8_t ao_flight_force_idle; void ao_flight(void) @@ -127,7 +127,7 @@ ao_flight(void) } } -static __xdata struct ao_task flight_task; +static struct ao_task flight_task; void ao_flight_init(void) diff --git a/src/kernel/ao_beep.h b/src/kernel/ao_beep.h index 1306af62..fdc150f1 100644 --- a/src/kernel/ao_beep.h +++ b/src/kernel/ao_beep.h @@ -85,7 +85,7 @@ ao_beep(uint8_t beep); /* Turn on the beeper for the specified time */ void -ao_beep_for(uint8_t beep, uint16_t ticks) __reentrant; +ao_beep_for(uint8_t beep, uint16_t ticks); /* Initialize the beeper */ void diff --git a/src/kernel/ao_cmd.c b/src/kernel/ao_cmd.c index 7bb4654e..d28db5b7 100644 --- a/src/kernel/ao_cmd.c +++ b/src/kernel/ao_cmd.c @@ -19,10 +19,10 @@ #include "ao.h" #include "ao_task.h" -__pdata uint16_t ao_cmd_lex_i; -__pdata uint32_t ao_cmd_lex_u32; -__pdata char ao_cmd_lex_c; -__pdata enum ao_cmd_status ao_cmd_status; +uint16_t ao_cmd_lex_i; +uint32_t ao_cmd_lex_u32; +char ao_cmd_lex_c; +enum ao_cmd_status ao_cmd_status; #ifndef AO_CMD_LEN #if AO_PYRO_NUM @@ -32,12 +32,12 @@ __pdata enum ao_cmd_status ao_cmd_status; #endif #endif -static __xdata char cmd_line[AO_CMD_LEN]; -static __pdata uint8_t cmd_len; -static __pdata uint8_t cmd_i; +static char cmd_line[AO_CMD_LEN]; +static uint8_t cmd_len; +static uint8_t cmd_i; void -ao_put_string(__code char *s) +ao_put_string(const char *s) { char c; while ((c = *s++)) @@ -196,7 +196,7 @@ ao_cmd_hexbyte(void) void ao_cmd_hex(void) { - __pdata uint8_t r = ao_cmd_lex_error; + uint8_t r = ao_cmd_lex_error; int8_t n; ao_cmd_lex_i = 0; @@ -214,7 +214,7 @@ ao_cmd_hex(void) } void -ao_cmd_decimal(void) __reentrant +ao_cmd_decimal(void) { uint8_t r = ao_cmd_lex_error; @@ -234,7 +234,7 @@ ao_cmd_decimal(void) __reentrant } uint8_t -ao_match_word(__code char *word) +ao_match_word(const char *word) { while (*word) { if (ao_cmd_lex_c != *word) { @@ -321,16 +321,16 @@ version(void) #define NUM_CMDS 11 #endif -static __code struct ao_cmds *__xdata (ao_cmds[NUM_CMDS]); -static __pdata uint8_t ao_ncmds; +static const struct ao_cmds *(ao_cmds[NUM_CMDS]); +static uint8_t ao_ncmds; static void help(void) { - __pdata uint8_t cmds; - __pdata uint8_t cmd; - __code struct ao_cmds * __pdata cs; - __code const char *h; + uint8_t cmds; + uint8_t cmd; + const struct ao_cmds * cs; + const char *h; uint8_t e; for (cmds = 0; cmds < ao_ncmds; cmds++) { @@ -363,7 +363,7 @@ report(void) } void -ao_cmd_register(__code struct ao_cmds *cmds) +ao_cmd_register(const struct ao_cmds *cmds) { if (ao_ncmds >= NUM_CMDS) ao_panic(AO_PANIC_CMD); @@ -373,10 +373,10 @@ ao_cmd_register(__code struct ao_cmds *cmds) void ao_cmd(void) { - __pdata char c; + char c; uint8_t cmd, cmds; - __code struct ao_cmds * __xdata cs; - void (*__xdata func)(void); + const struct ao_cmds * cs; + void (*func)(void); for (;;) { ao_cmd_readline(); @@ -424,10 +424,10 @@ ao_loader(void) #endif #if HAS_TASK -__xdata struct ao_task ao_cmd_task; +struct ao_task ao_cmd_task; #endif -__code struct ao_cmds ao_base_cmds[] = { +const struct ao_cmds ao_base_cmds[] = { { help, "?\0Help" }, #if HAS_TASK_INFO && HAS_TASK { ao_task_info, "T\0Tasks" }, diff --git a/src/kernel/ao_companion.h b/src/kernel/ao_companion.h index 4c161455..bd702fe3 100644 --- a/src/kernel/ao_companion.h +++ b/src/kernel/ao_companion.h @@ -44,11 +44,11 @@ struct ao_companion_setup { uint8_t channels; }; -extern __pdata uint8_t ao_companion_running; -extern __xdata uint8_t ao_companion_mutex; -extern __xdata struct ao_companion_command ao_companion_command; -extern __xdata struct ao_companion_setup ao_companion_setup; -extern __xdata uint16_t ao_companion_data[AO_COMPANION_MAX_CHANNELS]; +extern uint8_t ao_companion_running; +extern uint8_t ao_companion_mutex; +extern struct ao_companion_command ao_companion_command; +extern struct ao_companion_setup ao_companion_setup; +extern uint16_t ao_companion_data[AO_COMPANION_MAX_CHANNELS]; void ao_companion_init(void); diff --git a/src/kernel/ao_config.c b/src/kernel/ao_config.c index 10a67116..277dddd9 100644 --- a/src/kernel/ao_config.c +++ b/src/kernel/ao_config.c @@ -30,13 +30,13 @@ #include #endif -__xdata struct ao_config ao_config; -__pdata uint8_t ao_config_loaded; -__pdata uint8_t ao_config_dirty; -__xdata uint8_t ao_config_mutex; +struct ao_config ao_config; +uint8_t ao_config_loaded; +uint8_t ao_config_dirty; +uint8_t ao_config_mutex; #if HAS_FORCE_FREQ -__xdata uint8_t ao_force_freq; +uint8_t ao_force_freq; #endif #ifndef AO_CONFIG_DEFAULT_APRS_INTERVAL @@ -100,7 +100,7 @@ ao_config_put(void) #if HAS_RADIO #if HAS_RADIO_FORWARD -__xdata uint32_t ao_send_radio_setting; +uint32_t ao_send_radio_setting; #endif void @@ -283,10 +283,10 @@ ao_config_callsign_show(void) } void -ao_config_callsign_set(void) __reentrant +ao_config_callsign_set(void) { uint8_t c; - static __xdata char callsign[AO_MAX_CALLSIGN + 1]; + static char callsign[AO_MAX_CALLSIGN + 1]; ao_xmemset(callsign, '\0', sizeof callsign); ao_cmd_white(); @@ -309,14 +309,14 @@ ao_config_callsign_set(void) __reentrant #if HAS_RADIO void -ao_config_frequency_show(void) __reentrant +ao_config_frequency_show(void) { printf("Frequency: %ld\n", ao_config.frequency); } void -ao_config_frequency_set(void) __reentrant +ao_config_frequency_set(void) { ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) @@ -334,14 +334,14 @@ ao_config_frequency_set(void) __reentrant #if HAS_RADIO_FORWARD void -ao_config_send_frequency_show(void) __reentrant +ao_config_send_frequency_show(void) { printf("Send frequency: %ld\n", ao_config.send_frequency); } void -ao_config_send_frequency_set(void) __reentrant +ao_config_send_frequency_set(void) { ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) @@ -360,14 +360,14 @@ ao_config_send_frequency_set(void) __reentrant #if HAS_FLIGHT void -ao_config_main_deploy_show(void) __reentrant +ao_config_main_deploy_show(void) { printf("Main deploy: %d meters\n", ao_config.main_deploy); } void -ao_config_main_deploy_set(void) __reentrant +ao_config_main_deploy_set(void) { ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) @@ -379,7 +379,7 @@ ao_config_main_deploy_set(void) __reentrant #if HAS_ACCEL void -ao_config_accel_calibrate_show(void) __reentrant +ao_config_accel_calibrate_show(void) { printf("Accel cal +1g: %d -1g: %d\n", ao_config.accel_plus_g, ao_config.accel_minus_g); @@ -401,7 +401,7 @@ static int16_t accel_cal_through; #endif static int16_t -ao_config_accel_calibrate_auto(char *orientation) __reentrant +ao_config_accel_calibrate_auto(char *orientation) { uint16_t i; int32_t accel_total; @@ -442,7 +442,7 @@ ao_config_accel_calibrate_auto(char *orientation) __reentrant } void -ao_config_accel_calibrate_set(void) __reentrant +ao_config_accel_calibrate_set(void) { int16_t up, down; #if HAS_GYRO @@ -494,14 +494,14 @@ ao_config_accel_calibrate_set(void) __reentrant #endif /* HAS_ACCEL */ void -ao_config_apogee_delay_show(void) __reentrant +ao_config_apogee_delay_show(void) { printf("Apogee delay: %d seconds\n", ao_config.apogee_delay); } void -ao_config_apogee_delay_set(void) __reentrant +ao_config_apogee_delay_set(void) { ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) @@ -512,14 +512,14 @@ ao_config_apogee_delay_set(void) __reentrant } void -ao_config_apogee_lockout_show(void) __reentrant +ao_config_apogee_lockout_show(void) { printf ("Apogee lockout: %d seconds\n", ao_config.apogee_lockout); } void -ao_config_apogee_lockout_set(void) __reentrant +ao_config_apogee_lockout_set(void) { ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) @@ -533,13 +533,13 @@ ao_config_apogee_lockout_set(void) __reentrant #if HAS_RADIO void -ao_config_radio_cal_show(void) __reentrant +ao_config_radio_cal_show(void) { printf("Radio cal: %ld\n", ao_config.radio_cal); } void -ao_config_radio_cal_set(void) __reentrant +ao_config_radio_cal_set(void) { ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) @@ -558,13 +558,13 @@ ao_config_radio_cal_set(void) __reentrant #endif void -ao_config_radio_rate_show(void) __reentrant +ao_config_radio_rate_show(void) { printf("Telemetry rate: %d\n", ao_config.radio_rate); } void -ao_config_radio_rate_set(void) __reentrant +ao_config_radio_rate_set(void) { ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) @@ -588,7 +588,7 @@ ao_config_radio_rate_set(void) __reentrant #if HAS_LOG void -ao_config_log_show(void) __reentrant +ao_config_log_show(void) { printf("Max flight log: %d kB\n", (int16_t) (ao_config.flight_log_max >> 10)); #if FLIGHT_LOG_APPEND @@ -611,7 +611,7 @@ ao_config_log_fix_append(void) #endif void -ao_config_log_set(void) __reentrant +ao_config_log_set(void) { #if FLIGHT_LOG_APPEND printf("Flight log fixed size %d kB\n", ao_storage_log_max >> 10); @@ -639,13 +639,13 @@ ao_config_log_set(void) __reentrant #if HAS_IGNITE void -ao_config_ignite_mode_show(void) __reentrant +ao_config_ignite_mode_show(void) { printf("Ignite mode: %d\n", ao_config.ignite_mode); } void -ao_config_ignite_mode_set(void) __reentrant +ao_config_ignite_mode_set(void) { ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) @@ -658,7 +658,7 @@ ao_config_ignite_mode_set(void) __reentrant #if HAS_ACCEL void -ao_config_pad_orientation_show(void) __reentrant +ao_config_pad_orientation_show(void) { printf("Pad orientation: %d\n", ao_config.pad_orientation); } @@ -668,7 +668,7 @@ ao_config_pad_orientation_show(void) __reentrant #endif void -ao_config_pad_orientation_set(void) __reentrant +ao_config_pad_orientation_set(void) { ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) @@ -688,13 +688,13 @@ ao_config_pad_orientation_set(void) __reentrant #if HAS_RADIO void -ao_config_radio_enable_show(void) __reentrant +ao_config_radio_enable_show(void) { printf("Radio enable: %d\n", ao_config.radio_enable); } void -ao_config_radio_enable_set(void) __reentrant +ao_config_radio_enable_set(void) { ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) @@ -710,10 +710,10 @@ ao_config_radio_enable_set(void) __reentrant #if HAS_AES -__xdata uint8_t ao_config_aes_seq = 1; +uint8_t ao_config_aes_seq = 1; void -ao_config_key_show(void) __reentrant +ao_config_key_show(void) { uint8_t i; printf("AES key: "); @@ -723,7 +723,7 @@ ao_config_key_show(void) __reentrant } void -ao_config_key_set(void) __reentrant +ao_config_key_set(void) { uint8_t i; @@ -950,23 +950,23 @@ ao_config_pad_idle_set(void) #endif struct ao_config_var { - __code char *str; - void (*set)(void) __reentrant; - void (*show)(void) __reentrant; + const char *str; + void (*set)(void); + void (*show)(void); }; static void -ao_config_help(void) __reentrant; +ao_config_help(void); static void -ao_config_show(void) __reentrant; +ao_config_show(void); #if HAS_EEPROM static void -ao_config_save(void) __reentrant; +ao_config_save(void); #endif -__code struct ao_config_var ao_config_vars[] = { +const struct ao_config_var ao_config_vars[] = { #if HAS_FLIGHT { "m \0Main deploy (m)", ao_config_main_deploy_set, ao_config_main_deploy_show, }, @@ -1078,7 +1078,7 @@ ao_config_set(void) } static void -ao_config_help(void) __reentrant +ao_config_help(void) { uint8_t cmd; for (cmd = 0; ao_config_vars[cmd].str != NULL; cmd++) @@ -1089,7 +1089,7 @@ ao_config_help(void) __reentrant } static void -ao_config_show(void) __reentrant +ao_config_show(void) { uint8_t cmd; ao_config_get(); @@ -1105,7 +1105,7 @@ ao_config_show(void) __reentrant #if HAS_EEPROM static void -ao_config_save(void) __reentrant +ao_config_save(void) { uint8_t saved = 0; ao_mutex_get(&ao_config_mutex); @@ -1122,7 +1122,7 @@ ao_config_save(void) __reentrant } #endif -__code struct ao_cmds ao_config_cmds[] = { +const struct ao_cmds ao_config_cmds[] = { { ao_config_set, "c \0Set config (? for help, s to show)" }, { 0, NULL }, }; diff --git a/src/kernel/ao_config.h b/src/kernel/ao_config.h index f730c73c..41aafcca 100644 --- a/src/kernel/ao_config.h +++ b/src/kernel/ao_config.h @@ -62,7 +62,7 @@ #define AO_AES_LEN 16 -extern __xdata uint8_t ao_config_aes_seq; +extern uint8_t ao_config_aes_seq; struct ao_config { uint8_t major; @@ -130,7 +130,7 @@ struct ao_config { #define AO_CONFIG_DEFAULT_APRS_FORMAT AO_APRS_FORMAT_COMPRESSED #if HAS_RADIO_FORWARD -extern __xdata uint32_t ao_send_radio_setting; +extern uint32_t ao_send_radio_setting; #endif #define AO_IGNITE_MODE_DUAL 0 @@ -151,8 +151,8 @@ extern __xdata uint32_t ao_send_radio_setting; /* Make sure AO_CONFIG_MAX_SIZE is big enough */ typedef uint8_t config_check_space[(int) (AO_CONFIG_MAX_SIZE - sizeof (struct ao_config))]; -extern __xdata struct ao_config ao_config; -extern __pdata uint8_t ao_config_loaded; +extern struct ao_config ao_config; +extern uint8_t ao_config_loaded; void _ao_config_edit_start(void); diff --git a/src/kernel/ao_convert.c b/src/kernel/ao_convert.c index 1cd62345..f3e523ec 100644 --- a/src/kernel/ao_convert.c +++ b/src/kernel/ao_convert.c @@ -30,7 +30,7 @@ static const ao_v_t altitude_table[] = { #define ALT_FRAC_MASK (ALT_FRAC_SCALE - 1) ao_v_t -ao_pres_to_altitude(int16_t pres) __reentrant +ao_pres_to_altitude(int16_t pres) { uint8_t o; int16_t part; @@ -46,7 +46,7 @@ ao_pres_to_altitude(int16_t pres) __reentrant #if AO_NEED_ALTITUDE_TO_PRES int16_t -ao_altitude_to_pres(ao_v_t alt) __reentrant +ao_altitude_to_pres(ao_v_t alt) { ao_v_t span, sub_span; uint8_t l, h, m; @@ -74,7 +74,7 @@ ao_altitude_to_pres(ao_v_t alt) __reentrant #if 0 int16_t -ao_temp_to_dC(int16_t temp) __reentrant +ao_temp_to_dC(int16_t temp) { int16_t ret; diff --git a/src/kernel/ao_data.c b/src/kernel/ao_data.c index 35d42b8f..536ffa2b 100644 --- a/src/kernel/ao_data.c +++ b/src/kernel/ao_data.c @@ -19,13 +19,13 @@ #include #include -volatile __xdata struct ao_data ao_data_ring[AO_DATA_RING]; -volatile __data uint8_t ao_data_head; -volatile __data uint8_t ao_data_present; +volatile struct ao_data ao_data_ring[AO_DATA_RING]; +volatile uint8_t ao_data_head; +volatile uint8_t ao_data_present; #ifndef ao_data_count void -ao_data_get(__xdata struct ao_data *packet) +ao_data_get(struct ao_data *packet) { #if HAS_FLIGHT uint8_t i = ao_data_ring_prev(ao_sample_data); diff --git a/src/kernel/ao_data.h b/src/kernel/ao_data.h index 30616ef0..f88b30c9 100644 --- a/src/kernel/ao_data.h +++ b/src/kernel/ao_data.h @@ -97,12 +97,12 @@ struct ao_data { /* Get a copy of the last complete sample set */ void -ao_data_get(__xdata struct ao_data *packet); +ao_data_get(struct ao_data *packet); -extern volatile __xdata struct ao_data ao_data_ring[AO_DATA_RING]; -extern volatile __data uint8_t ao_data_head; -extern volatile __data uint8_t ao_data_present; -extern volatile __data uint8_t ao_data_count; +extern volatile struct ao_data ao_data_ring[AO_DATA_RING]; +extern volatile uint8_t ao_data_head; +extern volatile uint8_t ao_data_present; +extern volatile uint8_t ao_data_count; /* * Mark a section of data as ready, check for data complete diff --git a/src/kernel/ao_ee_fake.c b/src/kernel/ao_ee_fake.c index 84c13000..cef0a438 100644 --- a/src/kernel/ao_ee_fake.c +++ b/src/kernel/ao_ee_fake.c @@ -23,7 +23,7 @@ * wants to call these functions */ uint8_t -ao_ee_write_config(uint8_t *buf, uint16_t len) __reentrant +ao_ee_write_config(uint8_t *buf, uint16_t len) { (void) buf; (void) len; @@ -31,7 +31,7 @@ ao_ee_write_config(uint8_t *buf, uint16_t len) __reentrant } uint8_t -ao_ee_read_config(uint8_t *buf, uint16_t len) __reentrant +ao_ee_read_config(uint8_t *buf, uint16_t len) { ao_xmemset(buf, '\0', len); return 1; diff --git a/src/kernel/ao_eeprom.h b/src/kernel/ao_eeprom.h index bd8b6725..f258c48c 100644 --- a/src/kernel/ao_eeprom.h +++ b/src/kernel/ao_eeprom.h @@ -26,13 +26,13 @@ extern const ao_pos_t ao_eeprom_total; */ uint8_t -ao_eeprom_write(ao_pos_t pos32, __xdata void *v, uint16_t len); +ao_eeprom_write(ao_pos_t pos32, void *v, uint16_t len); /* * Read from eeprom */ uint8_t -ao_eeprom_read(ao_pos_t pos, __xdata void *v, uint16_t len); +ao_eeprom_read(ao_pos_t pos, void *v, uint16_t len); /* * Initialize eeprom diff --git a/src/kernel/ao_flight.c b/src/kernel/ao_flight.c index 170396ff..f72efa06 100644 --- a/src/kernel/ao_flight.c +++ b/src/kernel/ao_flight.c @@ -47,28 +47,28 @@ /* Main flight thread. */ -__pdata enum ao_flight_state ao_flight_state; /* current flight state */ -__pdata uint16_t ao_boost_tick; /* time of most recent boost detect */ -__pdata uint16_t ao_launch_tick; /* time of first boost detect */ -__pdata uint16_t ao_motor_number; /* number of motors burned so far */ +enum ao_flight_state ao_flight_state; /* current flight state */ +uint16_t ao_boost_tick; /* time of most recent boost detect */ +uint16_t ao_launch_tick; /* time of first boost detect */ +uint16_t ao_motor_number; /* number of motors burned so far */ #if HAS_SENSOR_ERRORS /* Any sensor can set this to mark the flight computer as 'broken' */ -__xdata uint8_t ao_sensor_errors; +uint8_t ao_sensor_errors; #endif /* * track min/max data over a long interval to detect * resting */ -static __data uint16_t ao_interval_end; -static __data ao_v_t ao_interval_min_height; -static __data ao_v_t ao_interval_max_height; +static uint16_t ao_interval_end; +static ao_v_t ao_interval_min_height; +static ao_v_t ao_interval_max_height; #if HAS_ACCEL -static __data ao_v_t ao_coast_avg_accel; +static ao_v_t ao_coast_avg_accel; #endif -__pdata uint8_t ao_flight_force_idle; +uint8_t ao_flight_force_idle; /* We also have a clock, which can be used to sanity check things in * case of other failures @@ -463,7 +463,7 @@ ao_orient_test_select(void) ao_orient_test = !ao_orient_test; } -__code struct ao_cmds ao_flight_cmds[] = { +const struct ao_cmds ao_flight_cmds[] = { { ao_flight_dump, "F\0Dump flight status" }, { ao_gyro_test, "G\0Test gyro code" }, { ao_orient_test_select,"O\0Test orientation code" }, @@ -471,7 +471,7 @@ __code struct ao_cmds ao_flight_cmds[] = { }; #endif -static __xdata struct ao_task flight_task; +static struct ao_task flight_task; void ao_flight_init(void) diff --git a/src/kernel/ao_flight.h b/src/kernel/ao_flight.h index 005c7e84..af6b0c55 100644 --- a/src/kernel/ao_flight.h +++ b/src/kernel/ao_flight.h @@ -38,21 +38,21 @@ enum ao_flight_state { ao_flight_test = 10 }; -extern __pdata enum ao_flight_state ao_flight_state; -extern __pdata uint16_t ao_boost_tick; -extern __pdata uint16_t ao_launch_tick; -extern __pdata uint16_t ao_motor_number; +extern enum ao_flight_state ao_flight_state; +extern uint16_t ao_boost_tick; +extern uint16_t ao_launch_tick; +extern uint16_t ao_motor_number; #if HAS_IMU || HAS_MMA655X #define HAS_SENSOR_ERRORS 1 #endif #if HAS_SENSOR_ERRORS -extern __xdata uint8_t ao_sensor_errors; +extern uint8_t ao_sensor_errors; #endif -extern __pdata uint16_t ao_launch_time; -extern __pdata uint8_t ao_flight_force_idle; +extern uint16_t ao_launch_time; +extern uint8_t ao_flight_force_idle; /* Flight thread */ void diff --git a/src/kernel/ao_flight_nano.c b/src/kernel/ao_flight_nano.c index 797ea344..96d47fac 100644 --- a/src/kernel/ao_flight_nano.c +++ b/src/kernel/ao_flight_nano.c @@ -20,18 +20,18 @@ /* Main flight thread. */ -__pdata enum ao_flight_state ao_flight_state; /* current flight state */ -__pdata uint16_t ao_launch_tick; /* time of launch detect */ +enum ao_flight_state ao_flight_state; /* current flight state */ +uint16_t ao_launch_tick; /* time of launch detect */ /* * track min/max data over a long interval to detect * resting */ -__pdata uint16_t ao_interval_end; -__pdata alt_t ao_interval_min_height; -__pdata alt_t ao_interval_max_height; +uint16_t ao_interval_end; +alt_t ao_interval_min_height; +alt_t ao_interval_max_height; -__pdata uint8_t ao_flight_force_idle; +uint8_t ao_flight_force_idle; /* Landing is detected by getting constant readings from both pressure and accelerometer * for a fairly long time (AO_INTERVAL_TICKS) @@ -111,7 +111,7 @@ ao_flight_nano(void) } } -static __xdata struct ao_task flight_task; +static struct ao_task flight_task; void ao_flight_nano_init(void) diff --git a/src/kernel/ao_forward.c b/src/kernel/ao_forward.c index b1ab3f54..6f664b60 100644 --- a/src/kernel/ao_forward.c +++ b/src/kernel/ao_forward.c @@ -23,7 +23,7 @@ static void ao_monitor_forward(void) { uint32_t recv_radio_setting; - static __xdata struct ao_telemetry_all_recv packet; + static struct ao_telemetry_all_recv packet; for (;;) { while (ao_monitoring) @@ -40,10 +40,10 @@ ao_monitor_forward(void) } } -static __xdata struct ao_task ao_monitor_forward_task; +static struct ao_task ao_monitor_forward_task; void -ao_monitor_forward_init(void) __reentrant +ao_monitor_forward_init(void) { ao_add_task(&ao_monitor_forward_task, ao_monitor_forward, "monitor_forward"); } diff --git a/src/kernel/ao_forward.h b/src/kernel/ao_forward.h index 2fe28f66..5b21bf3c 100644 --- a/src/kernel/ao_forward.h +++ b/src/kernel/ao_forward.h @@ -20,6 +20,6 @@ #define _AO_FORWARD_H_ void -ao_monitor_forward_init(void) __reentrant; +ao_monitor_forward_init(void); #endif /* _AO_FORWARD_H_ */ diff --git a/src/kernel/ao_freq.c b/src/kernel/ao_freq.c index 6478dae2..81640ce8 100644 --- a/src/kernel/ao_freq.c +++ b/src/kernel/ao_freq.c @@ -26,11 +26,11 @@ * frequency, and updating the radio setting along the way */ -int32_t ao_freq_to_set(int32_t freq, int32_t cal) __reentrant +int32_t ao_freq_to_set(int32_t freq, int32_t cal) { - static __pdata int32_t set; - static __pdata uint8_t neg; - static __pdata int32_t error; + static int32_t set; + static uint8_t neg; + static int32_t error; set = 0; neg = 0; diff --git a/src/kernel/ao_gps_print.c b/src/kernel/ao_gps_print.c index b1183bad..6dfd1bdd 100644 --- a/src/kernel/ao_gps_print.c +++ b/src/kernel/ao_gps_print.c @@ -26,7 +26,7 @@ #endif void -ao_gps_print(__xdata struct ao_gps_orig *gps_data) __reentrant +ao_gps_print(struct ao_gps_orig *gps_data) { char state; @@ -82,10 +82,10 @@ ao_gps_print(__xdata struct ao_gps_orig *gps_data) __reentrant } void -ao_gps_tracking_print(__xdata struct ao_gps_tracking_orig *gps_tracking_data) __reentrant +ao_gps_tracking_print(struct ao_gps_tracking_orig *gps_tracking_data) { uint8_t c, n, v; - __xdata struct ao_gps_sat_orig *sat; + struct ao_gps_sat_orig *sat; n = gps_tracking_data->channels; if (n == 0) diff --git a/src/kernel/ao_gps_report.c b/src/kernel/ao_gps_report.c index 75c2f367..0ef9a725 100644 --- a/src/kernel/ao_gps_report.c +++ b/src/kernel/ao_gps_report.c @@ -21,9 +21,9 @@ void ao_gps_report(void) { - static __xdata struct ao_log_record gps_log; - static __xdata struct ao_telemetry_location gps_data; - static __xdata struct ao_telemetry_satellite gps_tracking_data; + static struct ao_log_record gps_log; + static struct ao_telemetry_location gps_data; + static struct ao_telemetry_satellite gps_tracking_data; uint8_t date_reported = 0; uint8_t new; @@ -85,7 +85,7 @@ ao_gps_report(void) } } -__xdata struct ao_task ao_gps_report_task; +struct ao_task ao_gps_report_task; void ao_gps_report_init(void) diff --git a/src/kernel/ao_gps_report_mega.c b/src/kernel/ao_gps_report_mega.c index 85614b85..37f1beaa 100644 --- a/src/kernel/ao_gps_report_mega.c +++ b/src/kernel/ao_gps_report_mega.c @@ -59,9 +59,9 @@ ao_gps_sparse_should_log(int32_t lat, int32_t lon, int16_t alt) void ao_gps_report_mega(void) { - static __xdata struct ao_log_mega gps_log; - static __xdata struct ao_telemetry_location gps_data; - static __xdata struct ao_telemetry_satellite gps_tracking_data; + static struct ao_log_mega gps_log; + static struct ao_telemetry_location gps_data; + static struct ao_telemetry_satellite gps_tracking_data; uint8_t new; uint8_t c, n, i; @@ -125,7 +125,7 @@ ao_gps_report_mega(void) } } -__xdata struct ao_task ao_gps_report_mega_task; +struct ao_task ao_gps_report_mega_task; void ao_gps_report_mega_init(void) diff --git a/src/kernel/ao_gps_report_metrum.c b/src/kernel/ao_gps_report_metrum.c index 523fb17f..06863fe4 100644 --- a/src/kernel/ao_gps_report_metrum.c +++ b/src/kernel/ao_gps_report_metrum.c @@ -22,9 +22,9 @@ void ao_gps_report_metrum(void) { - static __xdata struct ao_log_metrum gps_log; - static __xdata struct ao_telemetry_location gps_data; - static __xdata struct ao_telemetry_satellite gps_tracking_data; + static struct ao_log_metrum gps_log; + static struct ao_telemetry_location gps_data; + static struct ao_telemetry_satellite gps_tracking_data; uint8_t c, n, i; uint8_t svid; uint8_t new; @@ -88,7 +88,7 @@ ao_gps_report_metrum(void) } } -__xdata struct ao_task ao_gps_report_metrum_task; +struct ao_task ao_gps_report_metrum_task; void ao_gps_report_metrum_init(void) diff --git a/src/kernel/ao_gps_show.c b/src/kernel/ao_gps_show.c index ec197769..ab29e5e5 100644 --- a/src/kernel/ao_gps_show.c +++ b/src/kernel/ao_gps_show.c @@ -23,7 +23,7 @@ #include void -ao_gps_show(void) __reentrant +ao_gps_show(void) { uint8_t i; ao_mutex_get(&ao_gps_mutex); diff --git a/src/kernel/ao_host.h b/src/kernel/ao_host.h index 638dba99..592de54c 100644 --- a/src/kernel/ao_host.h +++ b/src/kernel/ao_host.h @@ -41,11 +41,7 @@ struct ao_adc { int16_t sense_m; /* main continuity sense */ }; -#define __pdata -#define __data -#define __xdata -#define __code -#define __reentrant +#define const #define a (a) #define a (a) diff --git a/src/kernel/ao_ignite.c b/src/kernel/ao_ignite.c index 52d9d77e..5f41c552 100644 --- a/src/kernel/ao_ignite.c +++ b/src/kernel/ao_ignite.c @@ -23,7 +23,7 @@ #endif #if HAS_IGNITE -__xdata struct ao_ignition ao_ignition[2]; +struct ao_ignition ao_ignition[2]; void ao_ignite(enum ao_igniter igniter) @@ -42,9 +42,9 @@ ao_ignite(enum ao_igniter igniter) enum ao_igniter_status ao_igniter_status(enum ao_igniter igniter) { - __xdata struct ao_data packet; - __pdata int16_t value; - __pdata uint8_t request, firing, fired; + struct ao_data packet; + int16_t value; + uint8_t request, firing, fired; ao_arch_critical( ao_data_get(&packet); @@ -141,7 +141,7 @@ ao_igniter_fire(enum ao_igniter igniter) void ao_igniter(void) { - __xdata enum ao_igniter igniter; + enum ao_igniter igniter; ao_config_get(); for (;;) { @@ -187,13 +187,13 @@ ao_ignite_manual(void) ao_cmd_status = ao_cmd_syntax_error; } -__code char * __code ao_igniter_status_names[] = { +const char * const ao_igniter_status_names[] = { "unknown", "ready", "active", "open" }; #if HAS_IGNITE void -ao_ignite_print_status(enum ao_igniter igniter, __code char *name) __reentrant +ao_ignite_print_status(enum ao_igniter igniter, const char *name) { enum ao_igniter_status status = ao_igniter_status(igniter); printf("Igniter: %6s Status: %s\n", @@ -214,14 +214,14 @@ ao_ignite_test(void) #endif } -__code struct ao_cmds ao_ignite_cmds[] = { +const struct ao_cmds ao_ignite_cmds[] = { { ao_ignite_manual, "i {main|drogue}\0Fire igniter. is doit with D&I" }, { ao_ignite_test, "t\0Test igniter" }, { 0, NULL }, }; #if HAS_IGNITE -__xdata struct ao_task ao_igniter_task; +struct ao_task ao_igniter_task; void ao_ignite_set_pins(void) diff --git a/src/kernel/ao_int64.c b/src/kernel/ao_int64.c index fdea61c0..dffb8556 100644 --- a/src/kernel/ao_int64.c +++ b/src/kernel/ao_int64.c @@ -18,7 +18,7 @@ #include -void ao_plus64(__pdata ao_int64_t *r, __pdata ao_int64_t *a, __pdata ao_int64_t *b) __FATTR { +void ao_plus64(ao_int64_t *r, ao_int64_t *a, ao_int64_t *b) __FATTR { __LOCAL uint32_t t; r->high = a->high + b->high; @@ -28,7 +28,7 @@ void ao_plus64(__pdata ao_int64_t *r, __pdata ao_int64_t *a, __pdata ao_int64_t r->low = t; } -void ao_minus64(__pdata ao_int64_t *r, __pdata ao_int64_t *a, __pdata ao_int64_t *b) __FATTR { +void ao_minus64(ao_int64_t *r, ao_int64_t *a, ao_int64_t *b) __FATTR { __LOCAL uint32_t t; r->high = a->high - b->high; @@ -38,7 +38,7 @@ void ao_minus64(__pdata ao_int64_t *r, __pdata ao_int64_t *a, __pdata ao_int64_t r->low = t; } -void ao_rshift64(__pdata ao_int64_t *r, __pdata ao_int64_t *a, uint8_t d) __FATTR { +void ao_rshift64(ao_int64_t *r, ao_int64_t *a, uint8_t d) __FATTR { if (d < 32) { r->low = a->low >> d; if (d) @@ -51,7 +51,7 @@ void ao_rshift64(__pdata ao_int64_t *r, __pdata ao_int64_t *a, uint8_t d) __FATT } } -void ao_lshift64(__pdata ao_int64_t *r, __pdata ao_int64_t *a, uint8_t d) __FATTR { +void ao_lshift64(ao_int64_t *r, ao_int64_t *a, uint8_t d) __FATTR { if (d < 32) { r->high = a->high << d; if (d) @@ -64,7 +64,7 @@ void ao_lshift64(__pdata ao_int64_t *r, __pdata ao_int64_t *a, uint8_t d) __FATT } } -static void ao_umul64_32_32(__ARG ao_int64_t *r, uint32_t a, uint32_t b) __reentrant { +static void ao_umul64_32_32(__ARG ao_int64_t *r, uint32_t a, uint32_t b) { __LOCAL uint32_t s; __LOCAL ao_int64_t t; r->low = (uint32_t) (uint16_t) a * (uint16_t) b; @@ -83,7 +83,7 @@ static void ao_umul64_32_32(__ARG ao_int64_t *r, uint32_t a, uint32_t b) __reent ao_plus64(r, r, &t); } -void ao_neg64(__pdata ao_int64_t *r, __pdata ao_int64_t *a) __FATTR { +void ao_neg64(ao_int64_t *r, ao_int64_t *a) __FATTR { r->high = ~a->high; if (!(r->low = ~a->low + 1)) r->high++; @@ -105,7 +105,7 @@ void ao_mul64_32_32(__ARG ao_int64_t *r, int32_t a, int32_t b) __FATTR { ao_neg64(r, r); } -static void ao_umul64(__ARG ao_int64_t *r, __ARG ao_int64_t *a, __ARG ao_int64_t *b) __reentrant { +static void ao_umul64(__ARG ao_int64_t *r, __ARG ao_int64_t *a, __ARG ao_int64_t *b) { __LOCAL ao_int64_t r2, r3; ao_umul64_32_32(&r2, a->high, b->low); @@ -135,7 +135,7 @@ void ao_mul64(__ARG ao_int64_t *r, __ARG ao_int64_t *a, __ARG ao_int64_t *b) __F ao_neg64(r, r); } -static void ao_umul64_64_16(__ARG ao_int64_t *r, __ARG ao_int64_t *a, uint16_t b) __reentrant { +static void ao_umul64_64_16(__ARG ao_int64_t *r, __ARG ao_int64_t *a, uint16_t b) { __LOCAL uint32_t h; h = a->high * b; diff --git a/src/kernel/ao_int64.h b/src/kernel/ao_int64.h index 11c16404..3014182a 100644 --- a/src/kernel/ao_int64.h +++ b/src/kernel/ao_int64.h @@ -27,14 +27,14 @@ typedef struct { } ao_int64_t; #define __FATTR -#define __ARG __pdata -#define __LOCAL static __pdata - -void ao_plus64(__pdata ao_int64_t *ao_64r, __pdata ao_int64_t *ao_64a, __pdata ao_int64_t *ao_64b) __FATTR; -void ao_minus64(__pdata ao_int64_t *ao_64r, __pdata ao_int64_t *ao_64a, __pdata ao_int64_t *ao_64b) __FATTR; -void ao_neg64(__pdata ao_int64_t *ao_64r, __pdata ao_int64_t *ao_64a) __FATTR; -void ao_rshift64(__pdata ao_int64_t *ao_64r, __pdata ao_int64_t *ao_64a, uint8_t d) __FATTR; -void ao_lshift64(__pdata ao_int64_t *ao_64r, __pdata ao_int64_t *ao_64a, uint8_t d) __FATTR; +#define __ARG +#define __LOCAL static + +void ao_plus64(ao_int64_t *ao_64r, ao_int64_t *ao_64a, ao_int64_t *ao_64b) __FATTR; +void ao_minus64(ao_int64_t *ao_64r, ao_int64_t *ao_64a, ao_int64_t *ao_64b) __FATTR; +void ao_neg64(ao_int64_t *ao_64r, ao_int64_t *ao_64a) __FATTR; +void ao_rshift64(ao_int64_t *ao_64r, ao_int64_t *ao_64a, uint8_t d) __FATTR; +void ao_lshift64(ao_int64_t *ao_64r, ao_int64_t *ao_64a, uint8_t d) __FATTR; void ao_mul64_32_32(__ARG ao_int64_t *r, __ARG int32_t a, __ARG int32_t b) __FATTR; void ao_mul64_64_16(__ARG ao_int64_t *r, __ARG ao_int64_t *a, __ARG uint16_t b) __FATTR; void ao_mul64(__ARG ao_int64_t * __ARG r, __ARG ao_int64_t * __ARG a, __ARG ao_int64_t *__ARG b) __FATTR; diff --git a/src/kernel/ao_kalman.c b/src/kernel/ao_kalman.c index e4cc6d4b..4f4ffe8f 100644 --- a/src/kernel/ao_kalman.c +++ b/src/kernel/ao_kalman.c @@ -24,9 +24,9 @@ #include "ao_sample.h" #include "ao_kalman.h" -static __pdata ao_k_t ao_k_height; -static __pdata ao_k_t ao_k_speed; -static __pdata ao_k_t ao_k_accel; +static ao_k_t ao_k_height; +static ao_k_t ao_k_speed; +static ao_k_t ao_k_accel; #define AO_K_STEP_100 to_fix_v(0.01) #define AO_K_STEP_2_2_100 to_fix_v(0.00005) @@ -37,24 +37,24 @@ static __pdata ao_k_t ao_k_accel; #define AO_K_STEP_1 to_fix_v(1) #define AO_K_STEP_2_2_1 to_fix_v(0.5) -__pdata ao_v_t ao_height; -__pdata ao_v_t ao_speed; -__pdata ao_v_t ao_accel; -__xdata ao_v_t ao_max_height; -static __pdata ao_k_t ao_avg_height_scaled; -__xdata ao_v_t ao_avg_height; +ao_v_t ao_height; +ao_v_t ao_speed; +ao_v_t ao_accel; +ao_v_t ao_max_height; +static ao_k_t ao_avg_height_scaled; +ao_v_t ao_avg_height; -__pdata ao_v_t ao_error_h; +ao_v_t ao_error_h; #if !HAS_ACCEL || AO_FLIGHT_TEST #define AO_ERROR_H_SQ_AVG 1 #endif #if AO_ERROR_H_SQ_AVG -__pdata ao_v_t ao_error_h_sq_avg; +ao_v_t ao_error_h_sq_avg; #endif #if HAS_ACCEL -__pdata ao_v_t ao_error_a; +ao_v_t ao_error_a; #endif static void diff --git a/src/kernel/ao_led.h b/src/kernel/ao_led.h index 7de09237..803f85b3 100644 --- a/src/kernel/ao_led.h +++ b/src/kernel/ao_led.h @@ -51,7 +51,7 @@ ao_led_toggle(AO_LED_TYPE colors); /* Turn on the specified LEDs for the indicated interval */ void -ao_led_for(AO_LED_TYPE colors, uint16_t ticks) __reentrant; +ao_led_for(AO_LED_TYPE colors, uint16_t ticks); /* Initialize the LEDs */ void diff --git a/src/kernel/ao_log.c b/src/kernel/ao_log.c index 5fb086ce..1119cce4 100644 --- a/src/kernel/ao_log.c +++ b/src/kernel/ao_log.c @@ -23,13 +23,13 @@ #include #endif -__xdata uint8_t ao_log_mutex; -__pdata uint32_t ao_log_current_pos; -__pdata uint32_t ao_log_end_pos; -__pdata uint32_t ao_log_start_pos; -__xdata uint8_t ao_log_running; -__pdata enum ao_flight_state ao_log_state; -__xdata int16_t ao_flight_number; +uint8_t ao_log_mutex; +uint32_t ao_log_current_pos; +uint32_t ao_log_end_pos; +uint32_t ao_log_start_pos; +uint8_t ao_log_running; +enum ao_flight_state ao_log_state; +int16_t ao_flight_number; void ao_log_flush(void) @@ -47,7 +47,7 @@ struct ao_log_erase { uint16_t flight; }; -static __xdata struct ao_log_erase erase; +static struct ao_log_erase erase; #ifndef LOG_MAX_ERASE #define LOG_MAX_ERASE 16 @@ -117,10 +117,10 @@ ao_log_erase_mark(void) * structure. */ -__xdata ao_log_type ao_log_data; +ao_log_type ao_log_data; static uint8_t -ao_log_csum(__xdata uint8_t *b) __reentrant +ao_log_csum(uint8_t *b) { uint8_t sum = 0x5a; uint8_t i; @@ -131,12 +131,12 @@ ao_log_csum(__xdata uint8_t *b) __reentrant } uint8_t -ao_log_write(__xdata ao_log_type *log) __reentrant +ao_log_write(ao_log_type *log) { uint8_t wrote = 0; /* set checksum */ log->csum = 0; - log->csum = ao_log_csum((__xdata uint8_t *) log); + log->csum = ao_log_csum((uint8_t *) log); ao_mutex_get(&ao_log_mutex); { if (ao_log_current_pos >= ao_log_end_pos && ao_log_running) ao_log_stop(); @@ -223,7 +223,7 @@ ao_log_max_flight(void) } static void -ao_log_erase(uint8_t slot) __reentrant +ao_log_erase(uint8_t slot) { uint32_t log_current_pos, log_end_pos; @@ -232,7 +232,7 @@ ao_log_erase(uint8_t slot) __reentrant log_end_pos = log_current_pos + ao_config.flight_log_max; while (log_current_pos < log_end_pos) { uint8_t i; - static __xdata uint8_t b; + static uint8_t b; /* * Check to see if we've reached the end of @@ -252,7 +252,7 @@ ao_log_erase(uint8_t slot) __reentrant } static void -ao_log_find_max_erase_flight(void) __reentrant +ao_log_find_max_erase_flight(void) { uint8_t log_slot; @@ -273,7 +273,7 @@ ao_log_find_max_erase_flight(void) __reentrant } uint8_t -ao_log_scan(void) __reentrant +ao_log_scan(void) { uint8_t log_slot; uint8_t log_slots; @@ -402,11 +402,11 @@ ao_log_full(void) #endif #if LOG_ADC -static __xdata struct ao_task ao_log_task; +static struct ao_task ao_log_task; #endif void -ao_log_list(void) __reentrant +ao_log_list(void) { uint8_t slot; uint8_t slots; @@ -426,7 +426,7 @@ ao_log_list(void) __reentrant } void -ao_log_delete(void) __reentrant +ao_log_delete(void) { uint8_t slot; uint8_t slots; @@ -462,7 +462,7 @@ ao_log_delete(void) __reentrant printf("No such flight: %d\n", cmd_flight); } -__code struct ao_cmds ao_log_cmds[] = { +const struct ao_cmds ao_log_cmds[] = { { ao_log_list, "l\0List logs" }, { ao_log_delete, "d \0Delete flight" }, { 0, NULL }, diff --git a/src/kernel/ao_log.h b/src/kernel/ao_log.h index e2f1e0e4..a9715962 100644 --- a/src/kernel/ao_log.h +++ b/src/kernel/ao_log.h @@ -29,13 +29,13 @@ * the log. Tasks may wait for this to be initialized * by sleeping on this variable. */ -extern __xdata int16_t ao_flight_number; -extern __xdata uint8_t ao_log_mutex; -extern __pdata uint32_t ao_log_current_pos; -extern __pdata uint32_t ao_log_end_pos; -extern __pdata uint32_t ao_log_start_pos; -extern __xdata uint8_t ao_log_running; -extern __pdata enum ao_flight_state ao_log_state; +extern int16_t ao_flight_number; +extern uint8_t ao_log_mutex; +extern uint32_t ao_log_current_pos; +extern uint32_t ao_log_end_pos; +extern uint32_t ao_log_start_pos; +extern uint8_t ao_log_running; +extern enum ao_flight_state ao_log_state; /* required functions from the underlying log system */ @@ -90,7 +90,7 @@ ao_log(void); /* Figure out the current flight number */ uint8_t -ao_log_scan(void) __reentrant; +ao_log_scan(void); /* Return the position of the start of the given log slot */ uint32_t @@ -507,14 +507,14 @@ typedef struct ao_log_record ao_log_type; #endif #ifndef AO_LOG_UNCOMMON -extern __xdata ao_log_type ao_log_data; +extern ao_log_type ao_log_data; #define AO_LOG_SIZE sizeof(ao_log_type) /* Write a record to the eeprom log */ uint8_t -ao_log_write(__xdata ao_log_type *log) __reentrant; +ao_log_write(ao_log_type *log); #endif void diff --git a/src/kernel/ao_log_big.c b/src/kernel/ao_log_big.c index 7d7332e9..2a8cd63d 100644 --- a/src/kernel/ao_log_big.c +++ b/src/kernel/ao_log_big.c @@ -18,7 +18,7 @@ #include "ao.h" -static __data uint8_t ao_log_data_pos; +static uint8_t ao_log_data_pos; /* a hack to make sure that ao_log_records fill the eeprom block in even units */ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_record))] ; @@ -32,7 +32,7 @@ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_record))] ; void ao_log(void) { - __pdata uint16_t next_sensor, next_other; + uint16_t next_sensor, next_other; ao_storage_setup(); diff --git a/src/kernel/ao_log_fireone.c b/src/kernel/ao_log_fireone.c index 1a82673d..3dd52a16 100644 --- a/src/kernel/ao_log_fireone.c +++ b/src/kernel/ao_log_fireone.c @@ -21,12 +21,12 @@ #include #include -static __xdata struct ao_log_firetwo log; +static struct ao_log_firetwo log; -__code uint8_t ao_log_format = AO_LOG_FORMAT_TELEFIRETWO; +const uint8_t ao_log_format = AO_LOG_FORMAT_TELEFIRETWO; static uint8_t -ao_log_csum(__xdata uint8_t *b) __reentrant +ao_log_csum(uint8_t *b) { uint8_t sum = 0x5a; uint8_t i; @@ -37,12 +37,12 @@ ao_log_csum(__xdata uint8_t *b) __reentrant } uint8_t -ao_log_firetwo(__xdata struct ao_log_firetwo *log) __reentrant +ao_log_firetwo(struct ao_log_firetwo *log) { uint8_t wrote = 0; /* set checksum */ log->csum = 0; - log->csum = ao_log_csum((__xdata uint8_t *) log); + log->csum = ao_log_csum((uint8_t *) log); ao_mutex_get(&ao_log_mutex); { if (ao_log_current_pos >= ao_log_end_pos && ao_log_running) ao_log_stop(); @@ -66,7 +66,7 @@ ao_log_dump_check_data(void) } #if HAS_ADC -static __data uint8_t ao_log_data_pos; +static uint8_t ao_log_data_pos; /* a hack to make sure that ao_log_metrums fill the eeprom block in even units */ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_firetwo))] ; diff --git a/src/kernel/ao_log_mega.c b/src/kernel/ao_log_mega.c index 0ae4e536..341ff715 100644 --- a/src/kernel/ao_log_mega.c +++ b/src/kernel/ao_log_mega.c @@ -22,7 +22,7 @@ #include #if HAS_FLIGHT -static __data uint8_t ao_log_data_pos; +static uint8_t ao_log_data_pos; /* a hack to make sure that ao_log_megas fill the eeprom block in even units */ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_mega))] ; @@ -36,7 +36,7 @@ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_mega))] ; void ao_log(void) { - __pdata uint16_t next_sensor, next_other; + uint16_t next_sensor, next_other; uint8_t i; ao_storage_setup(); diff --git a/src/kernel/ao_log_metrum.c b/src/kernel/ao_log_metrum.c index 34729070..18fb9ffb 100644 --- a/src/kernel/ao_log_metrum.c +++ b/src/kernel/ao_log_metrum.c @@ -22,7 +22,7 @@ #include #if HAS_ADC -static __data uint8_t ao_log_data_pos; +static uint8_t ao_log_data_pos; /* a hack to make sure that ao_log_metrums fill the eeprom block in even units */ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_metrum))] ; @@ -36,7 +36,7 @@ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_metrum))] ; void ao_log(void) { - __pdata uint16_t next_sensor, next_other; + uint16_t next_sensor, next_other; ao_storage_setup(); diff --git a/src/kernel/ao_log_mini.c b/src/kernel/ao_log_mini.c index 12c5d6bb..03bf2265 100644 --- a/src/kernel/ao_log_mini.c +++ b/src/kernel/ao_log_mini.c @@ -21,7 +21,7 @@ #include #include -static __data uint8_t ao_log_data_pos; +static uint8_t ao_log_data_pos; /* a hack to make sure that ao_log_minis fill the eeprom block in even units */ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_mini))] ; @@ -34,7 +34,7 @@ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_mini))] ; void ao_log(void) { - __pdata uint16_t next_sensor; + uint16_t next_sensor; ao_storage_setup(); diff --git a/src/kernel/ao_log_single.c b/src/kernel/ao_log_single.c index 63768e1a..da627387 100644 --- a/src/kernel/ao_log_single.c +++ b/src/kernel/ao_log_single.c @@ -26,16 +26,16 @@ #include "ao.h" #include "ao_product.h" -static __xdata struct ao_task ao_log_single_task; +static struct ao_task ao_log_single_task; -__xdata uint8_t ao_log_running; -__xdata uint8_t ao_log_mutex; -__pdata uint32_t ao_log_start_pos; -__pdata uint32_t ao_log_end_pos; -__pdata uint32_t ao_log_current_pos; +uint8_t ao_log_running; +uint8_t ao_log_mutex; +uint32_t ao_log_start_pos; +uint32_t ao_log_end_pos; +uint32_t ao_log_current_pos; -__xdata union ao_log_single ao_log_single_write_data; -__xdata union ao_log_single ao_log_single_read_data; +union ao_log_single ao_log_single_write_data; +union ao_log_single ao_log_single_read_data; uint8_t ao_log_single_write(void) @@ -59,7 +59,7 @@ ao_log_single_write(void) static uint8_t ao_log_single_valid(void) { - __xdata uint8_t *d = ao_log_single_read_data.bytes; + uint8_t *d = ao_log_single_read_data.bytes; uint8_t i; for (i = 0; i < AO_LOG_SINGLE_SIZE; i++) if (*d++ != 0xff) diff --git a/src/kernel/ao_log_telem.c b/src/kernel/ao_log_telem.c index 8969e029..8c0b88e4 100644 --- a/src/kernel/ao_log_telem.c +++ b/src/kernel/ao_log_telem.c @@ -20,13 +20,13 @@ #include #include -__code uint8_t ao_log_format = AO_LOG_FORMAT_TELEMETRY; +const uint8_t ao_log_format = AO_LOG_FORMAT_TELEMETRY; -static __data uint8_t ao_log_monitor_pos; -__pdata enum ao_flight_state ao_flight_state; -__xdata int16_t ao_max_height; /* max of ao_height */ -__pdata int16_t sense_d, sense_m; -__pdata uint8_t ao_igniter_present; +static uint8_t ao_log_monitor_pos; +enum ao_flight_state ao_flight_state; +int16_t ao_max_height; /* max of ao_height */ +int16_t sense_d, sense_m; +uint8_t ao_igniter_present; static void ao_log_telem_track() { diff --git a/src/kernel/ao_log_telescience.c b/src/kernel/ao_log_telescience.c index 3f514f18..a21af71d 100644 --- a/src/kernel/ao_log_telescience.c +++ b/src/kernel/ao_log_telescience.c @@ -23,12 +23,12 @@ static uint8_t ao_log_data_pos; -__code uint8_t ao_log_format = AO_LOG_FORMAT_TELESCIENCE; +const uint8_t ao_log_format = AO_LOG_FORMAT_TELESCIENCE; static void -ao_log_telescience_csum(void) __reentrant +ao_log_telescience_csum(void) { - __xdata uint8_t *b = ao_log_single_write_data.bytes; + uint8_t *b = ao_log_single_write_data.bytes; uint8_t sum = 0x5a; uint8_t i; diff --git a/src/kernel/ao_log_tiny.c b/src/kernel/ao_log_tiny.c index 046b7b20..53003111 100644 --- a/src/kernel/ao_log_tiny.c +++ b/src/kernel/ao_log_tiny.c @@ -18,7 +18,7 @@ #include "ao.h" -static __data uint16_t ao_log_tiny_interval; +static uint16_t ao_log_tiny_interval; #define AO_LOG_TINY_INTERVAL_DEFAULT AO_MS_TO_TICKS(1000) #if USE_FAST_ASCENT_LOG @@ -46,8 +46,8 @@ static void ao_log_tiny_data(uint16_t d) } } -static __xdata uint16_t ao_log_pad_ring[AO_PAD_RING]; -static __pdata uint8_t ao_log_pad_ring_pos; +static uint16_t ao_log_pad_ring[AO_PAD_RING]; +static uint8_t ao_log_pad_ring_pos; #define ao_pad_ring_next(n) (((n) + 1) & (AO_PAD_RING - 1)) @@ -150,7 +150,7 @@ ao_log(void) int16_t ao_log_flight(uint8_t slot) { - static __xdata uint16_t flight; + static uint16_t flight; (void) slot; ao_storage_read(0, &flight, 2); diff --git a/src/kernel/ao_monitor.c b/src/kernel/ao_monitor.c index b9a39bfc..b6b8d888 100644 --- a/src/kernel/ao_monitor.c +++ b/src/kernel/ao_monitor.c @@ -36,15 +36,15 @@ #error Must define AO_MONITOR_LED #endif -__xdata uint8_t ao_monitoring_mutex; -__data uint8_t ao_monitoring; -static __data uint8_t ao_monitor_disabled; -static __data uint8_t ao_internal_monitoring; -static __data uint8_t ao_external_monitoring; +uint8_t ao_monitoring_mutex; +uint8_t ao_monitoring; +static uint8_t ao_monitor_disabled; +static uint8_t ao_internal_monitoring; +static uint8_t ao_external_monitoring; -__xdata union ao_monitor ao_monitor_ring[AO_MONITOR_RING]; +union ao_monitor ao_monitor_ring[AO_MONITOR_RING]; -__data uint8_t ao_monitor_head; +uint8_t ao_monitor_head; static void _ao_monitor_adjust(void) @@ -91,7 +91,7 @@ ao_monitor_get(void) } #if AO_MONITOR_LED -__xdata struct ao_task ao_monitor_blink_task; +struct ao_task ao_monitor_blink_task; void ao_monitor_blink(void) @@ -125,7 +125,7 @@ void ao_monitor_put(void) { #if LEGACY_MONITOR - __xdata char callsign[AO_MAX_CALLSIGN+1]; + char callsign[AO_MAX_CALLSIGN+1]; #endif #if LEGACY_MONITOR || HAS_RSSI int16_t rssi; @@ -133,7 +133,7 @@ ao_monitor_put(void) uint8_t ao_monitor_tail; uint8_t state; uint8_t sum, byte; - __xdata union ao_monitor *m; + union ao_monitor *m; #define recv_raw ((m->raw)) #define recv_orig ((m->orig)) @@ -266,10 +266,10 @@ ao_monitor_put(void) } } -__xdata struct ao_task ao_monitor_put_task; +struct ao_task ao_monitor_put_task; #endif -__xdata struct ao_task ao_monitor_get_task; +struct ao_task ao_monitor_get_task; void ao_monitor_set(uint8_t monitoring) @@ -303,14 +303,14 @@ set_monitor(void) _ao_monitor_adjust(); } -__code struct ao_cmds ao_monitor_cmds[] = { +const struct ao_cmds ao_monitor_cmds[] = { { set_monitor, "m <0 off, 1 old, 20 std>\0Set radio monitoring" }, { 0, NULL }, }; #endif void -ao_monitor_init(void) __reentrant +ao_monitor_init(void) { #if HAS_MONITOR_PUT ao_cmd_register(&ao_monitor_cmds[0]); diff --git a/src/kernel/ao_mutex.c b/src/kernel/ao_mutex.c index ff73e3bc..4ef1a9ba 100644 --- a/src/kernel/ao_mutex.c +++ b/src/kernel/ao_mutex.c @@ -25,7 +25,7 @@ #if HAS_MUTEX_TRY uint8_t -ao_mutex_try(__xdata uint8_t *mutex, uint8_t task_id) __reentrant +ao_mutex_try(uint8_t *mutex, uint8_t task_id) { uint8_t ret; if (*mutex == task_id) @@ -42,7 +42,7 @@ ao_mutex_try(__xdata uint8_t *mutex, uint8_t task_id) __reentrant #endif void -ao_mutex_get(__xdata uint8_t *mutex) __reentrant +ao_mutex_get(uint8_t *mutex) { if (*mutex == ao_cur_task->task_id) ao_panic(AO_PANIC_MUTEX); @@ -54,7 +54,7 @@ ao_mutex_get(__xdata uint8_t *mutex) __reentrant } void -ao_mutex_put(__xdata uint8_t *mutex) __reentrant +ao_mutex_put(uint8_t *mutex) { if (*mutex != ao_cur_task->task_id) ao_panic(AO_PANIC_MUTEX); diff --git a/src/kernel/ao_notask.c b/src/kernel/ao_notask.c index 7207353a..a5bdc8a7 100644 --- a/src/kernel/ao_notask.c +++ b/src/kernel/ao_notask.c @@ -21,7 +21,7 @@ static volatile void *ao_wchan; uint8_t -ao_sleep(__xdata void *wchan) +ao_sleep(void *wchan) { #if 1 ao_wchan = wchan; @@ -55,7 +55,7 @@ ao_delay(uint16_t ticks) #endif void -ao_wakeup(__xdata void *wchan) +ao_wakeup(void *wchan) { (void) wchan; ao_wchan = 0; diff --git a/src/kernel/ao_notask.h b/src/kernel/ao_notask.h index a4446726..ce622b63 100644 --- a/src/kernel/ao_notask.h +++ b/src/kernel/ao_notask.h @@ -20,9 +20,9 @@ #define _AO_NOTASK_H_ uint8_t -ao_sleep(__xdata void *wchan); +ao_sleep(void *wchan); void -ao_wakeup(__xdata void *wchan); +ao_wakeup(void *wchan); #endif /* _AO_NOTASK_H_ */ diff --git a/src/kernel/ao_packet.h b/src/kernel/ao_packet.h index 9d99b0e6..24cd7b13 100644 --- a/src/kernel/ao_packet.h +++ b/src/kernel/ao_packet.h @@ -43,13 +43,13 @@ struct ao_packet_recv { uint8_t status; }; -extern __xdata struct ao_packet_recv ao_rx_packet; -extern __xdata struct ao_packet ao_tx_packet; -extern __xdata struct ao_task ao_packet_task; -extern __xdata uint8_t ao_packet_enable; -extern __xdata uint8_t ao_packet_master_sleeping; -extern __pdata uint8_t ao_packet_rx_len, ao_packet_rx_used, ao_packet_tx_used; -extern __xdata uint8_t ao_packet_restart; +extern struct ao_packet_recv ao_rx_packet; +extern struct ao_packet ao_tx_packet; +extern struct ao_task ao_packet_task; +extern uint8_t ao_packet_enable; +extern uint8_t ao_packet_master_sleeping; +extern uint8_t ao_packet_rx_len, ao_packet_rx_used, ao_packet_tx_used; +extern uint8_t ao_packet_restart; void ao_packet_send(void); @@ -61,7 +61,7 @@ void ao_packet_flush(void); void -ao_packet_putchar(char c) __reentrant; +ao_packet_putchar(char c); int _ao_packet_pollchar(void); @@ -69,7 +69,7 @@ _ao_packet_pollchar(void); #if PACKET_HAS_MASTER /* ao_packet_master.c */ -extern __xdata int8_t ao_packet_last_rssi; +extern int8_t ao_packet_last_rssi; void ao_packet_master_init(void); diff --git a/src/kernel/ao_pyro.c b/src/kernel/ao_pyro.c index 527112ac..e24ab46b 100644 --- a/src/kernel/ao_pyro.c +++ b/src/kernel/ao_pyro.c @@ -38,8 +38,8 @@ enum ao_igniter_status ao_pyro_status(uint8_t p) { - __xdata struct ao_data packet; - __pdata int16_t value; + struct ao_data packet; + int16_t value; ao_arch_critical( ao_data_get(&packet); @@ -404,7 +404,7 @@ ao_pyro(void) ao_exit(); } -__xdata struct ao_task ao_pyro_task; +struct ao_task ao_pyro_task; static void diff --git a/src/kernel/ao_radio_cmac.c b/src/kernel/ao_radio_cmac.c index 92b365a2..155fce35 100644 --- a/src/kernel/ao_radio_cmac.c +++ b/src/kernel/ao_radio_cmac.c @@ -19,9 +19,9 @@ #include #include -static __xdata uint8_t ao_radio_cmac_mutex; -__pdata int8_t ao_radio_cmac_rssi; -static __xdata uint8_t cmac_data[AO_CMAC_MAX_LEN + AO_CMAC_KEY_LEN + 2 + AO_CMAC_KEY_LEN]; +static uint8_t ao_radio_cmac_mutex; +int8_t ao_radio_cmac_rssi; +static uint8_t cmac_data[AO_CMAC_MAX_LEN + AO_CMAC_KEY_LEN + 2 + AO_CMAC_KEY_LEN]; static uint8_t round_len(uint8_t len) @@ -45,7 +45,7 @@ round_len(uint8_t len) * Sign and deliver the data sitting in the cmac buffer */ static void -radio_cmac_send(uint8_t len) __reentrant +radio_cmac_send(uint8_t len) { uint8_t i; @@ -77,7 +77,7 @@ radio_cmac_send(uint8_t len) __reentrant */ static int8_t -radio_cmac_recv(uint8_t len, uint16_t timeout) __reentrant +radio_cmac_recv(uint8_t len, uint16_t timeout) { uint8_t i; @@ -127,7 +127,7 @@ radio_cmac_recv(uint8_t len, uint16_t timeout) __reentrant } int8_t -ao_radio_cmac_send(__xdata void *packet, uint8_t len) __reentrant +ao_radio_cmac_send(void *packet, uint8_t len) { if (len > AO_CMAC_MAX_LEN) return AO_RADIO_CMAC_LEN_ERROR; @@ -145,7 +145,7 @@ ao_radio_cmac_send(__xdata void *packet, uint8_t len) __reentrant } int8_t -ao_radio_cmac_recv(__xdata void *packet, uint8_t len, uint16_t timeout) __reentrant +ao_radio_cmac_recv(void *packet, uint8_t len, uint16_t timeout) { int8_t i; if (len > AO_CMAC_MAX_LEN) diff --git a/src/kernel/ao_radio_cmac.h b/src/kernel/ao_radio_cmac.h index 74fe8c60..5fd6e105 100644 --- a/src/kernel/ao_radio_cmac.h +++ b/src/kernel/ao_radio_cmac.h @@ -24,10 +24,10 @@ #define AO_CMAC_KEY_LEN AO_AES_LEN #define AO_CMAC_MAX_LEN (128 - AO_CMAC_KEY_LEN) -extern __pdata int8_t ao_radio_cmac_rssi; +extern int8_t ao_radio_cmac_rssi; int8_t -ao_radio_cmac_send(__xdata void *packet, uint8_t len) __reentrant; +ao_radio_cmac_send(void *packet, uint8_t len); #define AO_RADIO_CMAC_OK 0 #define AO_RADIO_CMAC_LEN_ERROR -1 @@ -36,7 +36,7 @@ ao_radio_cmac_send(__xdata void *packet, uint8_t len) __reentrant; #define AO_RADIO_CMAC_TIMEOUT -4 int8_t -ao_radio_cmac_recv(__xdata void *packet, uint8_t len, uint16_t timeout) __reentrant; +ao_radio_cmac_recv(void *packet, uint8_t len, uint16_t timeout); void ao_radio_cmac_init(void); diff --git a/src/kernel/ao_radio_cmac_cmd.c b/src/kernel/ao_radio_cmac_cmd.c index 6d29f392..e5b4ffdf 100644 --- a/src/kernel/ao_radio_cmac_cmd.c +++ b/src/kernel/ao_radio_cmac_cmd.c @@ -20,7 +20,7 @@ #include #include -static __xdata uint8_t cmac_data[AO_CMAC_MAX_LEN]; +static uint8_t cmac_data[AO_CMAC_MAX_LEN]; static uint8_t getnibble(void) @@ -45,7 +45,7 @@ getbyte(void) } static void -radio_cmac_send_cmd(void) __reentrant +radio_cmac_send_cmd(void) { uint8_t i; uint8_t len; @@ -69,7 +69,7 @@ radio_cmac_send_cmd(void) __reentrant } static void -radio_cmac_recv_cmd(void) __reentrant +radio_cmac_recv_cmd(void) { uint8_t len, i; uint16_t timeout; @@ -92,7 +92,7 @@ radio_cmac_recv_cmd(void) __reentrant printf ("ERROR %d %d\n", i, ao_radio_cmac_rssi); } -static __code struct ao_cmds ao_radio_cmac_cmds[] = { +static const struct ao_cmds ao_radio_cmac_cmds[] = { { radio_cmac_send_cmd, "s \0Send AES-CMAC packet. Bytes to send follow on next line" }, { radio_cmac_recv_cmd, "S \0Receive AES-CMAC packet. Timeout in ms" }, { 0, NULL }, diff --git a/src/kernel/ao_report.c b/src/kernel/ao_report.c index 73f87cdd..08967af8 100644 --- a/src/kernel/ao_report.c +++ b/src/kernel/ao_report.c @@ -58,7 +58,7 @@ static const uint8_t flight_reports[] = { #endif #define pause(time) ao_delay(time) -static __pdata enum ao_flight_state ao_report_state; +static enum ao_flight_state ao_report_state; /* * Farnsworth spacing @@ -115,7 +115,7 @@ static __pdata enum ao_flight_state ao_report_state; */ static void -ao_report_beep(void) __reentrant +ao_report_beep(void) { uint8_t r = flight_reports[ao_flight_state]; uint8_t l = r & 7; @@ -134,7 +134,7 @@ ao_report_beep(void) __reentrant } static void -ao_report_digit(uint8_t digit) __reentrant +ao_report_digit(uint8_t digit) { if (!digit) { mid(AO_MS_TO_TICKS(500)); @@ -151,8 +151,8 @@ ao_report_digit(uint8_t digit) __reentrant static void ao_report_number(int16_t n) { - __xdata uint8_t digits[10]; - __pdata uint8_t ndigits, i; + uint8_t digits[10]; + uint8_t ndigits, i; if (n < 0) n = 0; @@ -178,7 +178,7 @@ ao_report_altitude(void) static void ao_report_battery(void) { - __xdata struct ao_data packet; + struct ao_data packet; for (;;) { ao_data_get(&packet); if (packet.adc.v_batt != 0) @@ -204,7 +204,7 @@ ao_report_igniter(void) } static void -ao_report_continuity(void) __reentrant +ao_report_continuity(void) { uint8_t c; @@ -285,7 +285,7 @@ ao_report(void) } } -static __xdata struct ao_task ao_report_task; +static struct ao_task ao_report_task; void ao_report_init(void) diff --git a/src/kernel/ao_report_micro.c b/src/kernel/ao_report_micro.c index 9c7afdc5..efada54b 100644 --- a/src/kernel/ao_report_micro.c +++ b/src/kernel/ao_report_micro.c @@ -23,7 +23,7 @@ #define pause(time) ao_delay(time) static void -ao_report_digit(uint8_t digit) __reentrant +ao_report_digit(uint8_t digit) { if (!digit) { mid(AO_MS_TO_TICKS(1000)); @@ -40,9 +40,9 @@ ao_report_digit(uint8_t digit) __reentrant void ao_report_altitude(void) { - __pdata alt_t agl = ao_max_height; - static __xdata uint8_t digits[11]; - __pdata uint8_t ndigits, i; + alt_t agl = ao_max_height; + static uint8_t digits[11]; + uint8_t ndigits, i; if (agl < 0) agl = 0; diff --git a/src/kernel/ao_rssi.c b/src/kernel/ao_rssi.c index 66fb8b57..aacc38b2 100644 --- a/src/kernel/ao_rssi.c +++ b/src/kernel/ao_rssi.c @@ -18,9 +18,9 @@ #include "ao.h" -static __xdata uint16_t ao_rssi_time; -static __pdata uint16_t ao_rssi_delay; -static __pdata AO_LED_TYPE ao_rssi_led; +static uint16_t ao_rssi_time; +static uint16_t ao_rssi_delay; +static AO_LED_TYPE ao_rssi_led; void ao_rssi(void) @@ -43,7 +43,7 @@ ao_rssi_set(int16_t rssi_value) ao_wakeup(&ao_rssi_time); } -__xdata struct ao_task ao_rssi_task; +struct ao_task ao_rssi_task; void ao_rssi_init(AO_LED_TYPE rssi_led) diff --git a/src/kernel/ao_sample.c b/src/kernel/ao_sample.c index 9f5082bb..115eae80 100644 --- a/src/kernel/ao_sample.c +++ b/src/kernel/ao_sample.c @@ -35,63 +35,63 @@ #define ACCEL_TYPE int16_t #endif -__pdata uint16_t ao_sample_tick; /* time of last data */ -__pdata pres_t ao_sample_pres; -__pdata alt_t ao_sample_alt; -__pdata alt_t ao_sample_height; +uint16_t ao_sample_tick; /* time of last data */ +pres_t ao_sample_pres; +alt_t ao_sample_alt; +alt_t ao_sample_height; #if HAS_ACCEL -__pdata accel_t ao_sample_accel; +accel_t ao_sample_accel; #endif #if HAS_GYRO -__pdata accel_t ao_sample_accel_along; -__pdata accel_t ao_sample_accel_across; -__pdata accel_t ao_sample_accel_through; -__pdata gyro_t ao_sample_roll; -__pdata gyro_t ao_sample_pitch; -__pdata gyro_t ao_sample_yaw; -__pdata angle_t ao_sample_orient; -__pdata angle_t ao_sample_orients[AO_NUM_ORIENT]; -__pdata uint8_t ao_sample_orient_pos; +accel_t ao_sample_accel_along; +accel_t ao_sample_accel_across; +accel_t ao_sample_accel_through; +gyro_t ao_sample_roll; +gyro_t ao_sample_pitch; +gyro_t ao_sample_yaw; +angle_t ao_sample_orient; +angle_t ao_sample_orients[AO_NUM_ORIENT]; +uint8_t ao_sample_orient_pos; #endif -__data uint8_t ao_sample_data; +uint8_t ao_sample_data; /* * Sensor calibration values */ -__pdata pres_t ao_ground_pres; /* startup pressure */ -__pdata alt_t ao_ground_height; /* MSL of ao_ground_pres */ +pres_t ao_ground_pres; /* startup pressure */ +alt_t ao_ground_height; /* MSL of ao_ground_pres */ #if HAS_ACCEL -__pdata accel_t ao_ground_accel; /* startup acceleration */ -__pdata accel_t ao_accel_2g; /* factory accel calibration */ -__pdata int32_t ao_accel_scale; /* sensor to m/s² conversion */ +accel_t ao_ground_accel; /* startup acceleration */ +accel_t ao_accel_2g; /* factory accel calibration */ +int32_t ao_accel_scale; /* sensor to m/s² conversion */ #endif #if HAS_GYRO -__pdata accel_t ao_ground_accel_along; -__pdata accel_t ao_ground_accel_across; -__pdata accel_t ao_ground_accel_through; -__pdata int32_t ao_ground_pitch; -__pdata int32_t ao_ground_yaw; -__pdata int32_t ao_ground_roll; +accel_t ao_ground_accel_along; +accel_t ao_ground_accel_across; +accel_t ao_ground_accel_through; +int32_t ao_ground_pitch; +int32_t ao_ground_yaw; +int32_t ao_ground_roll; #endif -static __pdata uint8_t ao_preflight; /* in preflight mode */ +static uint8_t ao_preflight; /* in preflight mode */ -static __pdata uint16_t nsamples; -__pdata int32_t ao_sample_pres_sum; +static uint16_t nsamples; +int32_t ao_sample_pres_sum; #if HAS_ACCEL -__pdata int32_t ao_sample_accel_sum; +int32_t ao_sample_accel_sum; #endif #if HAS_GYRO -__pdata int32_t ao_sample_accel_along_sum; -__pdata int32_t ao_sample_accel_across_sum; -__pdata int32_t ao_sample_accel_through_sum; -__pdata int32_t ao_sample_pitch_sum; -__pdata int32_t ao_sample_yaw_sum; -__pdata int32_t ao_sample_roll_sum; +int32_t ao_sample_accel_along_sum; +int32_t ao_sample_accel_across_sum; +int32_t ao_sample_accel_through_sum; +int32_t ao_sample_pitch_sum; +int32_t ao_sample_yaw_sum; +int32_t ao_sample_roll_sum; static struct ao_quaternion ao_rotation; #endif @@ -324,7 +324,7 @@ ao_sample(void) ao_wakeup(&ao_sample_data); ao_sleep((void *) &ao_data_head); while (ao_sample_data != ao_data_head) { - __xdata struct ao_data *ao_data; + struct ao_data *ao_data; /* Capture a sample */ ao_data = (struct ao_data *) &ao_data_ring[ao_sample_data]; diff --git a/src/kernel/ao_sample.h b/src/kernel/ao_sample.h index 5ae389be..af6eca4e 100644 --- a/src/kernel/ao_sample.h +++ b/src/kernel/ao_sample.h @@ -115,41 +115,41 @@ typedef int16_t ao_v_t; #define AO_MS_TO_SPEED(ms) ((ao_v_t) ((ms) * 16)) #define AO_MSS_TO_ACCEL(mss) ((ao_v_t) ((mss) * 16)) -extern __pdata uint16_t ao_sample_tick; /* time of last data */ -extern __data uint8_t ao_sample_adc; /* Ring position of last processed sample */ -extern __data uint8_t ao_sample_data; /* Ring position of last processed sample */ +extern uint16_t ao_sample_tick; /* time of last data */ +extern uint8_t ao_sample_adc; /* Ring position of last processed sample */ +extern uint8_t ao_sample_data; /* Ring position of last processed sample */ #if HAS_BARO -extern __pdata pres_t ao_sample_pres; /* most recent pressure sensor reading */ -extern __pdata alt_t ao_sample_alt; /* MSL of ao_sample_pres */ -extern __pdata alt_t ao_sample_height; /* AGL of ao_sample_pres */ -extern __pdata pres_t ao_ground_pres; /* startup pressure */ -extern __pdata alt_t ao_ground_height; /* MSL of ao_ground_pres */ +extern pres_t ao_sample_pres; /* most recent pressure sensor reading */ +extern alt_t ao_sample_alt; /* MSL of ao_sample_pres */ +extern alt_t ao_sample_height; /* AGL of ao_sample_pres */ +extern pres_t ao_ground_pres; /* startup pressure */ +extern alt_t ao_ground_height; /* MSL of ao_ground_pres */ #endif #if HAS_ACCEL -extern __pdata accel_t ao_sample_accel; /* most recent accel sensor reading */ -extern __pdata accel_t ao_ground_accel; /* startup acceleration */ -extern __pdata accel_t ao_accel_2g; /* factory accel calibration */ -extern __pdata int32_t ao_accel_scale; /* sensor to m/s² conversion */ +extern accel_t ao_sample_accel; /* most recent accel sensor reading */ +extern accel_t ao_ground_accel; /* startup acceleration */ +extern accel_t ao_accel_2g; /* factory accel calibration */ +extern int32_t ao_accel_scale; /* sensor to m/s² conversion */ #endif #if HAS_GYRO -extern __pdata accel_t ao_ground_accel_along; -extern __pdata accel_t ao_ground_accel_across; -extern __pdata accel_t ao_ground_accel_through; -extern __pdata int32_t ao_ground_pitch; /* * 512 */ -extern __pdata int32_t ao_ground_yaw; /* * 512 */ -extern __pdata int32_t ao_ground_roll; /* * 512 */ -extern __pdata accel_t ao_sample_accel_along; -extern __pdata accel_t ao_sample_accel_across; -extern __pdata accel_t ao_sample_accel_through; -extern __pdata gyro_t ao_sample_roll; -extern __pdata gyro_t ao_sample_pitch; -extern __pdata gyro_t ao_sample_yaw; +extern accel_t ao_ground_accel_along; +extern accel_t ao_ground_accel_across; +extern accel_t ao_ground_accel_through; +extern int32_t ao_ground_pitch; /* * 512 */ +extern int32_t ao_ground_yaw; /* * 512 */ +extern int32_t ao_ground_roll; /* * 512 */ +extern accel_t ao_sample_accel_along; +extern accel_t ao_sample_accel_across; +extern accel_t ao_sample_accel_through; +extern gyro_t ao_sample_roll; +extern gyro_t ao_sample_pitch; +extern gyro_t ao_sample_yaw; #define AO_NUM_ORIENT 64 -extern __pdata angle_t ao_sample_orient; -extern __pdata angle_t ao_sample_orients[AO_NUM_ORIENT]; -extern __pdata uint8_t ao_sample_orient_pos; +extern angle_t ao_sample_orient; +extern angle_t ao_sample_orients[AO_NUM_ORIENT]; +extern uint8_t ao_sample_orient_pos; #endif void ao_sample_init(void); @@ -176,19 +176,19 @@ uint8_t ao_sample(void); #define from_fix(x) ((x) >> 16) -extern __pdata ao_v_t ao_height; /* meters */ -extern __pdata ao_v_t ao_speed; /* m/s * 16 */ -extern __pdata ao_v_t ao_accel; /* m/s² * 16 */ -extern __xdata ao_v_t ao_max_height; /* max of ao_height */ -extern __xdata ao_v_t ao_avg_height; /* running average of height */ +extern ao_v_t ao_height; /* meters */ +extern ao_v_t ao_speed; /* m/s * 16 */ +extern ao_v_t ao_accel; /* m/s² * 16 */ +extern ao_v_t ao_max_height; /* max of ao_height */ +extern ao_v_t ao_avg_height; /* running average of height */ -extern __pdata ao_v_t ao_error_h; +extern ao_v_t ao_error_h; #if !HAS_ACCEL -extern __pdata ao_v_t ao_error_h_sq_avg; +extern ao_v_t ao_error_h_sq_avg; #endif #if HAS_ACCEL -extern __pdata ao_v_t ao_error_a; +extern ao_v_t ao_error_a; #endif #endif diff --git a/src/kernel/ao_sample_profile.c b/src/kernel/ao_sample_profile.c index 4819a161..b9d0e07f 100644 --- a/src/kernel/ao_sample_profile.c +++ b/src/kernel/ao_sample_profile.c @@ -160,7 +160,7 @@ ao_sample_profile_cmd(void) } } -static __code struct ao_cmds ao_sample_profile_cmds[] = { +static const struct ao_cmds ao_sample_profile_cmds[] = { { ao_sample_profile_cmd, "S <1 start,0 stop, d dump,c clear>\0Sample profile" }, { 0, NULL } }; diff --git a/src/kernel/ao_send_packet.c b/src/kernel/ao_send_packet.c index c8a1d46e..3206b2d6 100644 --- a/src/kernel/ao_send_packet.c +++ b/src/kernel/ao_send_packet.c @@ -20,14 +20,14 @@ #define AO_MAX_SEND 128 -static __xdata uint8_t ao_send[AO_MAX_SEND]; +static uint8_t ao_send[AO_MAX_SEND]; static void ao_send_packet(void) { - __pdata uint16_t count; + uint16_t count; uint8_t b; - __pdata uint8_t i; + uint8_t i; ao_cmd_hex(); count = ao_cmd_lex_i; @@ -47,7 +47,7 @@ ao_send_packet(void) ao_radio_send(ao_send, count); } -static __code struct ao_cmds ao_send_packet_cmds[] = { +static const struct ao_cmds ao_send_packet_cmds[] = { { ao_send_packet, "S \0Send packet. Data on next line" }, { 0, NULL } }; diff --git a/src/kernel/ao_serial.h b/src/kernel/ao_serial.h index ef3e93d7..440b562b 100644 --- a/src/kernel/ao_serial.h +++ b/src/kernel/ao_serial.h @@ -26,8 +26,8 @@ #define AO_SERIAL_SPEED_115200 4 #if HAS_SERIAL_0 -extern volatile __xdata struct ao_fifo ao_serial0_rx_fifo; -extern volatile __xdata struct ao_fifo ao_serial0_tx_fifo; +extern volatile struct ao_fifo ao_serial0_rx_fifo; +extern volatile struct ao_fifo ao_serial0_tx_fifo; char ao_serial0_getchar(void); @@ -49,8 +49,8 @@ ao_serial0_set_speed(uint8_t speed); #endif #if HAS_SERIAL_1 -extern volatile __xdata struct ao_fifo ao_serial1_rx_fifo; -extern volatile __xdata struct ao_fifo ao_serial1_tx_fifo; +extern volatile struct ao_fifo ao_serial1_rx_fifo; +extern volatile struct ao_fifo ao_serial1_tx_fifo; char ao_serial1_getchar(void); @@ -72,8 +72,8 @@ ao_serial1_set_speed(uint8_t speed); #endif #if HAS_SERIAL_2 -extern volatile __xdata struct ao_fifo ao_serial2_rx_fifo; -extern volatile __xdata struct ao_fifo ao_serial2_tx_fifo; +extern volatile struct ao_fifo ao_serial2_rx_fifo; +extern volatile struct ao_fifo ao_serial2_tx_fifo; char ao_serial2_getchar(void); @@ -95,8 +95,8 @@ ao_serial2_set_speed(uint8_t speed); #endif #if HAS_SERIAL_3 -extern volatile __xdata struct ao_fifo ao_serial3_rx_fifo; -extern volatile __xdata struct ao_fifo ao_serial3_tx_fifo; +extern volatile struct ao_fifo ao_serial3_rx_fifo; +extern volatile struct ao_fifo ao_serial3_tx_fifo; char ao_serial3_getchar(void); diff --git a/src/kernel/ao_stdio.c b/src/kernel/ao_stdio.c index 227499c8..c3b51d12 100644 --- a/src/kernel/ao_stdio.c +++ b/src/kernel/ao_stdio.c @@ -72,13 +72,13 @@ #define AO_NUM_STDIOS (HAS_USB + PACKET_HAS_SLAVE + USE_SERIAL_STDIN + CONSOLE_STDIN) -__xdata struct ao_stdio ao_stdios[AO_NUM_STDIOS]; +struct ao_stdio ao_stdios[AO_NUM_STDIOS]; #if AO_NUM_STDIOS > 1 -__pdata int8_t ao_cur_stdio; -__pdata int8_t ao_num_stdios; +int8_t ao_cur_stdio; +int8_t ao_num_stdios; #else -__pdata int8_t ao_cur_stdio; +int8_t ao_cur_stdio; #define ao_cur_stdio 0 #define ao_num_stdios 0 #endif @@ -108,10 +108,10 @@ flush(void) ao_stdios[ao_cur_stdio].flush(); } -__xdata uint8_t ao_stdin_ready; +uint8_t ao_stdin_ready; char -ao_getchar(void) __reentrant +ao_getchar(void) { int c; int8_t stdio; @@ -145,7 +145,7 @@ ao_echo(void) int8_t ao_add_stdio(int (*_pollchar)(void), void (*putchar)(char), - void (*flush)(void)) __reentrant + void (*flush)(void)) { if (ao_num_stdios == AO_NUM_STDIOS) ao_panic(AO_PANIC_STDIO); diff --git a/src/kernel/ao_storage.c b/src/kernel/ao_storage.c index 400751de..5292e120 100644 --- a/src/kernel/ao_storage.c +++ b/src/kernel/ao_storage.c @@ -20,7 +20,7 @@ #include uint8_t -ao_storage_read(ao_pos_t pos, __xdata void *buf, uint16_t len) __reentrant +ao_storage_read(ao_pos_t pos, void *buf, uint16_t len) { #ifdef CC1111 return ao_storage_device_read(pos, buf, len); @@ -54,7 +54,7 @@ ao_storage_read(ao_pos_t pos, __xdata void *buf, uint16_t len) __reentrant } uint8_t -ao_storage_write(ao_pos_t pos, __xdata void *buf, uint16_t len) __reentrant +ao_storage_write(ao_pos_t pos, void *buf, uint16_t len) { #ifdef CC1111 return ao_storage_device_write(pos, buf, len); @@ -87,10 +87,10 @@ ao_storage_write(ao_pos_t pos, __xdata void *buf, uint16_t len) __reentrant #endif } -static __xdata uint8_t storage_data[128]; +static uint8_t storage_data[128]; static void -ao_storage_dump(void) __reentrant +ao_storage_dump(void) { uint8_t i, j; @@ -118,12 +118,12 @@ ao_storage_dump(void) __reentrant /* not enough space for this today */ static void -ao_storage_store(void) __reentrant +ao_storage_store(void) { uint16_t block; uint8_t i; uint16_t len; - static __xdata uint8_t b; + static uint8_t b; uint32_t addr; ao_cmd_hex(); @@ -147,7 +147,7 @@ ao_storage_store(void) __reentrant #endif void -ao_storage_zap(void) __reentrant +ao_storage_zap(void) { ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) @@ -156,7 +156,7 @@ ao_storage_zap(void) __reentrant } void -ao_storage_zapall(void) __reentrant +ao_storage_zapall(void) { uint32_t pos; @@ -272,7 +272,7 @@ ao_storage_incr_check_block(uint32_t pos) } static uint8_t -ao_storage_test_block(uint32_t pos) __reentrant +ao_storage_test_block(uint32_t pos) { ao_storage_erase(pos); printf(" erase"); flush(); @@ -299,7 +299,7 @@ ao_storage_test_block(uint32_t pos) __reentrant } static void -ao_storage_test(void) __reentrant +ao_storage_test(void) { uint32_t pos; @@ -316,7 +316,7 @@ ao_storage_test(void) __reentrant #endif /* AO_STORAGE_TEST */ void -ao_storage_info(void) __reentrant +ao_storage_info(void) { ao_storage_setup(); printf("Storage size: %ld\n", (long) ao_storage_total); @@ -324,7 +324,7 @@ ao_storage_info(void) __reentrant ao_storage_device_info(); } -__code struct ao_cmds ao_storage_cmds[] = { +const struct ao_cmds ao_storage_cmds[] = { { ao_storage_info, "f\0Show storage" }, { ao_storage_dump, "e \0Dump flash" }, #if HAS_STORAGE_DEBUG diff --git a/src/kernel/ao_storage.h b/src/kernel/ao_storage.h index 59b137ad..cf37a824 100644 --- a/src/kernel/ao_storage.h +++ b/src/kernel/ao_storage.h @@ -31,10 +31,10 @@ typedef ao_storage_pos_t ao_pos_t; /* Total bytes of available storage */ -extern __pdata ao_pos_t ao_storage_total; +extern ao_pos_t ao_storage_total; /* Block size - device is erased in these units. At least 256 bytes */ -extern __pdata ao_pos_t ao_storage_block; +extern ao_pos_t ao_storage_block; #ifndef USE_STORAGE_CONFIG #define USE_STORAGE_CONFIG 1 @@ -42,7 +42,7 @@ extern __pdata ao_pos_t ao_storage_block; #if USE_STORAGE_CONFIG /* Byte offset of config block. Will be ao_storage_block bytes long */ -extern __pdata ao_pos_t ao_storage_config; +extern ao_pos_t ao_storage_config; #define ao_storage_log_max ao_storage_config #else @@ -50,27 +50,27 @@ extern __pdata ao_pos_t ao_storage_config; #endif /* Storage unit size - device reads and writes must be within blocks of this size. Usually 256 bytes. */ -extern __pdata uint16_t ao_storage_unit; +extern uint16_t ao_storage_unit; /* Initialize above values. Can only be called once the OS is running */ void -ao_storage_setup(void) __reentrant; +ao_storage_setup(void); /* Write data. Returns 0 on failure, 1 on success */ uint8_t -ao_storage_write(ao_pos_t pos, __xdata void *buf, uint16_t len) __reentrant; +ao_storage_write(ao_pos_t pos, void *buf, uint16_t len); /* Read data. Returns 0 on failure, 1 on success */ uint8_t -ao_storage_read(ao_pos_t pos, __xdata void *buf, uint16_t len) __reentrant; +ao_storage_read(ao_pos_t pos, void *buf, uint16_t len); /* Erase a block of storage. This always clears ao_storage_block bytes */ uint8_t -ao_storage_erase(ao_pos_t pos) __reentrant; +ao_storage_erase(ao_pos_t pos); /* Flush any pending writes to stable storage */ void -ao_storage_flush(void) __reentrant; +ao_storage_flush(void); /* Initialize the storage code */ void @@ -82,11 +82,11 @@ ao_storage_init(void); /* Read data within a storage unit */ uint8_t -ao_storage_device_read(ao_pos_t pos, __xdata void *buf, uint16_t len) __reentrant; +ao_storage_device_read(ao_pos_t pos, void *buf, uint16_t len); /* Write data within a storage unit */ uint8_t -ao_storage_device_write(ao_pos_t pos, __xdata void *buf, uint16_t len) __reentrant; +ao_storage_device_write(ao_pos_t pos, void *buf, uint16_t len); /* Initialize low-level device bits */ void @@ -94,6 +94,6 @@ ao_storage_device_init(void); /* Print out information about flash chips */ void -ao_storage_device_info(void) __reentrant; +ao_storage_device_info(void); #endif /* _AO_STORAGE_H_ */ diff --git a/src/kernel/ao_task.c b/src/kernel/ao_task.c index de23ea02..4f7072cb 100644 --- a/src/kernel/ao_task.c +++ b/src/kernel/ao_task.c @@ -29,12 +29,12 @@ #define AO_NO_TASK_INDEX 0xff -__xdata struct ao_task * __xdata ao_tasks[AO_NUM_TASKS]; -__data uint8_t ao_num_tasks; -__xdata struct ao_task *__data ao_cur_task; +struct ao_task * ao_tasks[AO_NUM_TASKS]; +uint8_t ao_num_tasks; +struct ao_task *ao_cur_task; #if !HAS_TASK_QUEUE -static __data uint8_t ao_cur_task_index; +static uint8_t ao_cur_task_index; #endif #ifdef ao_arch_task_globals @@ -290,7 +290,7 @@ ao_task_validate(void) #endif /* HAS_TASK_QUEUE */ void -ao_add_task(__xdata struct ao_task * task, void (*start)(void), __code char *name) __reentrant +ao_add_task(struct ao_task * task, void (*start)(void), const char *name) { uint8_t task_id; uint8_t t; @@ -321,7 +321,7 @@ ao_add_task(__xdata struct ao_task * task, void (*start)(void), __code char *nam ); } -__data uint8_t ao_task_minimize_latency; +uint8_t ao_task_minimize_latency; /* Task switching function. This must not use any stack variables */ void @@ -382,7 +382,7 @@ ao_yield(void) ao_arch_naked_define ao_cur_task = ao_list_first_entry(&run_queue, struct ao_task, queue); #else { - __pdata uint8_t ao_last_task_index = ao_cur_task_index; + uint8_t ao_last_task_index = ao_cur_task_index; for (;;) { ++ao_cur_task_index; if (ao_cur_task_index == ao_num_tasks) @@ -418,7 +418,7 @@ ao_yield(void) ao_arch_naked_define } uint8_t -ao_sleep(__xdata void *wchan) +ao_sleep(void *wchan) { #if HAS_TASK_QUEUE uint32_t flags; @@ -439,7 +439,7 @@ ao_sleep(__xdata void *wchan) } void -ao_wakeup(__xdata void *wchan) __reentrant +ao_wakeup(void *wchan) { ao_validate_cur_stack(); #if HAS_TASK_QUEUE @@ -470,7 +470,7 @@ ao_wakeup(__xdata void *wchan) __reentrant } uint8_t -ao_sleep_for(__xdata void *wchan, uint16_t timeout) +ao_sleep_for(void *wchan, uint16_t timeout) { uint8_t ret; if (timeout) { @@ -504,7 +504,7 @@ ao_sleep_for(__xdata void *wchan, uint16_t timeout) return ret; } -static __xdata uint8_t ao_forever; +static uint8_t ao_forever; void ao_delay(uint16_t ticks) @@ -541,7 +541,7 @@ void ao_task_info(void) { uint8_t i; - __xdata struct ao_task *task; + struct ao_task *task; uint16_t now = ao_time(); for (i = 0; i < ao_num_tasks; i++) { diff --git a/src/kernel/ao_task.h b/src/kernel/ao_task.h index 7549b598..ffeb7313 100644 --- a/src/kernel/ao_task.h +++ b/src/kernel/ao_task.h @@ -39,11 +39,11 @@ /* An AltOS task */ struct ao_task { - __xdata void *wchan; /* current wait channel (NULL if running) */ + void *wchan; /* current wait channel (NULL if running) */ uint16_t alarm; /* abort ao_sleep time */ ao_arch_task_members /* any architecture-specific fields */ uint8_t task_id; /* unique id */ - __code char *name; /* task name */ + const char *name; /* task name */ #ifdef NEWLIB int __errno; /* storage for errno in newlib libc */ #endif @@ -66,10 +66,10 @@ struct ao_task { #define AO_NO_TASK 0 /* no task id */ -extern __xdata struct ao_task * __xdata ao_tasks[AO_NUM_TASKS]; -extern __data uint8_t ao_num_tasks; -extern __xdata struct ao_task *__data ao_cur_task; -extern __data uint8_t ao_task_minimize_latency; /* Reduce IRQ latency */ +extern struct ao_task * ao_tasks[AO_NUM_TASKS]; +extern uint8_t ao_num_tasks; +extern struct ao_task *ao_cur_task; +extern uint8_t ao_task_minimize_latency; /* Reduce IRQ latency */ #ifndef HAS_ARCH_VALIDATE_CUR_STACK #define ao_validate_cur_stack() @@ -85,7 +85,7 @@ extern __data uint8_t ao_task_minimize_latency; /* Reduce IRQ latency */ * 1 on alarm */ uint8_t -ao_sleep(__xdata void *wchan); +ao_sleep(void *wchan); /* Suspend the current task until wchan is awoken or the timeout * expires. returns: @@ -93,11 +93,11 @@ ao_sleep(__xdata void *wchan); * 1 on alarm */ uint8_t -ao_sleep_for(__xdata void *wchan, uint16_t timeout); +ao_sleep_for(void *wchan, uint16_t timeout); /* Wake all tasks sleeping on wchan */ void -ao_wakeup(__xdata void *wchan) __reentrant; +ao_wakeup(void *wchan); #if 0 /* set an alarm to go off in 'delay' ticks */ @@ -115,7 +115,7 @@ ao_yield(void) ao_arch_naked_declare; /* Add a task to the run queue */ void -ao_add_task(__xdata struct ao_task * task, void (*start)(void), __code char *name) __reentrant; +ao_add_task(struct ao_task * task, void (*start)(void), const char *name); #if HAS_TASK_QUEUE /* Called on timer interrupt to check alarms */ diff --git a/src/kernel/ao_telemetry.c b/src/kernel/ao_telemetry.c index 8ff28fde..9e1304f7 100644 --- a/src/kernel/ao_telemetry.c +++ b/src/kernel/ao_telemetry.c @@ -20,10 +20,10 @@ #include "ao_log.h" #include "ao_product.h" -static __pdata uint16_t ao_telemetry_interval; +static uint16_t ao_telemetry_interval; #if HAS_RADIO_RATE -static __xdata uint16_t ao_telemetry_desired_interval; +static uint16_t ao_telemetry_desired_interval; #endif /* TeleMetrum v1.0 just doesn't have enough space to @@ -37,10 +37,10 @@ static __xdata uint16_t ao_telemetry_desired_interval; #ifdef SIMPLIFY #define ao_telemetry_time time -#define RDF_SPACE __pdata +#define RDF_SPACE #else -#define RDF_SPACE __xdata -static __pdata uint16_t ao_telemetry_time; +#define RDF_SPACE +static uint16_t ao_telemetry_time; #endif #if HAS_RDF @@ -49,7 +49,7 @@ static RDF_SPACE uint16_t ao_rdf_time; #endif #if HAS_APRS -static __pdata uint16_t ao_aprs_time; +static uint16_t ao_aprs_time; #include #endif @@ -74,7 +74,7 @@ static __pdata uint16_t ao_aprs_time; #define AO_TELEMETRY_SENSOR AO_TELEMETRY_SENSOR_TELENANO #endif -static __xdata union ao_telemetry_all telemetry; +static union ao_telemetry_all telemetry; static void ao_telemetry_send(void) @@ -88,7 +88,7 @@ ao_telemetry_send(void) static void ao_send_sensor(void) { - __xdata struct ao_data *packet = (__xdata struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)]; + struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)]; telemetry.generic.tick = packet->tick; telemetry.generic.type = AO_TELEMETRY_SENSOR; @@ -136,7 +136,7 @@ ao_send_sensor(void) static void ao_send_mega_sensor(void) { - __xdata struct ao_data *packet = (__xdata struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)]; + struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)]; telemetry.generic.tick = packet->tick; telemetry.generic.type = AO_TELEMETRY_MEGA_SENSOR; @@ -181,15 +181,15 @@ ao_send_mega_sensor(void) ao_telemetry_send(); } -static __pdata int8_t ao_telemetry_mega_data_max; -static __pdata int8_t ao_telemetry_mega_data_cur; +static int8_t ao_telemetry_mega_data_max; +static int8_t ao_telemetry_mega_data_cur; /* Send mega data packet */ static void ao_send_mega_data(void) { if (--ao_telemetry_mega_data_cur <= 0) { - __xdata struct ao_data *packet = (__xdata struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)]; + struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)]; uint8_t i; telemetry.generic.tick = packet->tick; @@ -223,7 +223,7 @@ ao_send_mega_data(void) static void ao_send_metrum_sensor(void) { - __xdata struct ao_data *packet = (__xdata struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)]; + struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)]; telemetry.generic.tick = packet->tick; telemetry.generic.type = AO_TELEMETRY_METRUM_SENSOR; @@ -246,15 +246,15 @@ ao_send_metrum_sensor(void) ao_telemetry_send(); } -static __pdata int8_t ao_telemetry_metrum_data_max; -static __pdata int8_t ao_telemetry_metrum_data_cur; +static int8_t ao_telemetry_metrum_data_max; +static int8_t ao_telemetry_metrum_data_cur; /* Send telemetrum data packet */ static void ao_send_metrum_data(void) { if (--ao_telemetry_metrum_data_cur <= 0) { - __xdata struct ao_data *packet = (__xdata struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)]; + struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)]; telemetry.generic.tick = packet->tick; telemetry.generic.type = AO_TELEMETRY_METRUM_DATA; @@ -281,7 +281,7 @@ ao_send_metrum_data(void) static void ao_send_mini(void) { - __xdata struct ao_data *packet = (__xdata struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)]; + struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)]; telemetry.generic.tick = packet->tick; telemetry.generic.type = AO_SEND_MINI; @@ -306,9 +306,9 @@ ao_send_mini(void) #endif /* AO_SEND_MINI */ -static __pdata int8_t ao_telemetry_config_max; -static __pdata int8_t ao_telemetry_config_cur; -static __pdata uint16_t ao_telemetry_flight_number; +static int8_t ao_telemetry_config_max; +static int8_t ao_telemetry_config_cur; +static uint16_t ao_telemetry_flight_number; #ifndef ao_telemetry_battery_convert #define ao_telemetry_battery_convert(a) (a) @@ -346,9 +346,9 @@ ao_send_configuration(void) #if HAS_GPS -static __pdata int8_t ao_telemetry_gps_max; -static __pdata int8_t ao_telemetry_loc_cur; -static __pdata int8_t ao_telemetry_sat_cur; +static int8_t ao_telemetry_gps_max; +static int8_t ao_telemetry_loc_cur; +static int8_t ao_telemetry_sat_cur; static void ao_send_location(void) @@ -387,8 +387,8 @@ ao_send_satellite(void) #if HAS_COMPANION -static __pdata int8_t ao_telemetry_companion_max; -static __pdata int8_t ao_telemetry_companion_cur; +static int8_t ao_telemetry_companion_max; +static int8_t ao_telemetry_companion_cur; static void ao_send_companion(void) @@ -536,7 +536,7 @@ ao_telemetry_set_interval(uint16_t interval) #if HAS_RADIO_RATE /* Limit max telemetry rate based on available radio bandwidth. */ - static __xdata const uint16_t min_interval[] = { + static const uint16_t min_interval[] = { /* [AO_RADIO_RATE_38400] = */ AO_MS_TO_TICKS(100), /* [AO_RADIO_RATE_9600] = */ AO_MS_TO_TICKS(500), /* [AO_RADIO_RATE_2400] = */ AO_MS_TO_TICKS(1000) @@ -613,7 +613,7 @@ ao_rdf_set(uint8_t rdf) } #endif -__xdata struct ao_task ao_telemetry_task; +struct ao_task ao_telemetry_task; void ao_telemetry_init() diff --git a/src/kernel/ao_usb.h b/src/kernel/ao_usb.h index 40516de1..7992c806 100644 --- a/src/kernel/ao_usb.h +++ b/src/kernel/ao_usb.h @@ -69,7 +69,7 @@ ao_usb_disable(void); void ao_usb_init(void); -extern __code __at (0x00aa) uint8_t ao_usb_descriptors []; +extern const __at (0x00aa) uint8_t ao_usb_descriptors []; #define AO_USB_SETUP_DIR_MASK (0x01 << 7) #define AO_USB_SETUP_TYPE_MASK (0x03 << 5) @@ -176,8 +176,8 @@ struct ao_usb_line_coding { uint8_t data_bits; } ; -extern __xdata struct ao_usb_line_coding ao_usb_line_coding; +extern struct ao_usb_line_coding ao_usb_line_coding; -extern __pdata uint8_t ao_usb_running; +extern uint8_t ao_usb_running; #endif /* _AO_USB_H_ */ diff --git a/src/lpc/altos-loader.ld b/src/lpc/altos-loader.ld index 84d7610c..be4f115d 100644 --- a/src/lpc/altos-loader.ld +++ b/src/lpc/altos-loader.ld @@ -61,9 +61,9 @@ SECTIONS { /* Data -- relocated to RAM, but written to ROM */ .data : { - __data_start__ = .; + _start__ = .; *(.data*) /* initialized data */ - __data_end__ = .; + _end__ = .; } >ram AT>rom diff --git a/src/lpc/altos-standalone.ld b/src/lpc/altos-standalone.ld index db53dcaf..99d10149 100644 --- a/src/lpc/altos-standalone.ld +++ b/src/lpc/altos-standalone.ld @@ -65,9 +65,9 @@ SECTIONS { /* Data -- relocated to RAM, but written to ROM */ .data ORIGIN(ram) : AT (ADDR(.ARM.exidx) + SIZEOF (.ARM.exidx)) { - __data_start__ = .; + _start__ = .; *(.data) /* initialized data */ - __data_end__ = .; + _end__ = .; __bss_start__ = .; } >ram diff --git a/src/lpc/altos.ld b/src/lpc/altos.ld index e6a6a7ed..028ad775 100644 --- a/src/lpc/altos.ld +++ b/src/lpc/altos.ld @@ -69,9 +69,9 @@ SECTIONS { /* Data -- relocated to RAM, but written to ROM */ .data : AT (ADDR(.ARM.exidx) + SIZEOF (.ARM.exidx)) { - __data_start__ = .; + _start__ = .; *(.data) /* initialized data */ - __data_end__ = .; + _end__ = .; __bss_start__ = .; } >ram diff --git a/src/lpc/ao_adc_lpc.c b/src/lpc/ao_adc_lpc.c index 26a5ea08..6743c1f4 100644 --- a/src/lpc/ao_adc_lpc.c +++ b/src/lpc/ao_adc_lpc.c @@ -147,7 +147,7 @@ ao_adc_poll(void) } static void -ao_adc_dump(void) __reentrant +ao_adc_dump(void) { struct ao_data packet; #ifndef AO_ADC_DUMP @@ -167,7 +167,7 @@ ao_adc_dump(void) __reentrant #endif } -__code struct ao_cmds ao_adc_cmds[] = { +const struct ao_cmds ao_adc_cmds[] = { { ao_adc_dump, "a\0Display current ADC values" }, { 0, NULL }, }; diff --git a/src/lpc/ao_arch.h b/src/lpc/ao_arch.h index f1df14eb..889be53e 100644 --- a/src/lpc/ao_arch.h +++ b/src/lpc/ao_arch.h @@ -42,11 +42,6 @@ #define ao_arch_naked_declare __attribute__((naked)) #define ao_arch_naked_define -#define __pdata -#define __data -#define __xdata -#define __code const -#define __reentrant #define __interrupt(n) #define __at(n) diff --git a/src/lpc/ao_beep_lpc.c b/src/lpc/ao_beep_lpc.c index b1211752..eab86ee6 100644 --- a/src/lpc/ao_beep_lpc.c +++ b/src/lpc/ao_beep_lpc.c @@ -59,7 +59,7 @@ ao_beep(uint8_t beep) } void -ao_beep_for(uint8_t beep, uint16_t ticks) __reentrant +ao_beep_for(uint8_t beep, uint16_t ticks) { ao_beep(beep); ao_delay(ticks); diff --git a/src/lpc/ao_interrupt.c b/src/lpc/ao_interrupt.c index 3e0119c6..8d71f43f 100644 --- a/src/lpc/ao_interrupt.c +++ b/src/lpc/ao_interrupt.c @@ -32,7 +32,7 @@ extern void main(void); extern char __stack__; extern char __text_start__, __text_end__; -extern char __data_start__, __data_end__; +extern char _start__, _end__; extern char __bss_start__, __bss_end__; #if RELOCATE_INTERRUPT extern char __interrupt_rom__, __interrupt_start__, __interrupt_end__; @@ -61,7 +61,7 @@ void start(void) { memcpy(&__interrupt_start__, &__interrupt_rom__, &__interrupt_end__ - &__interrupt_start__); lpc_scb.sysmemremap = LPC_SCB_SYSMEMREMAP_MAP_RAM << LPC_SCB_SYSMEMREMAP_MAP; #endif - memcpy(&__data_start__, &__text_end__, &__data_end__ - &__data_start__); + memcpy(&_start__, &__text_end__, &_end__ - &_start__); memset(&__bss_start__, '\0', &__bss_end__ - &__bss_start__); main(); } diff --git a/src/lpc/ao_led_lpc.c b/src/lpc/ao_led_lpc.c index 2d2c3972..5fc726c0 100644 --- a/src/lpc/ao_led_lpc.c +++ b/src/lpc/ao_led_lpc.c @@ -18,7 +18,7 @@ #include -__pdata AO_PORT_TYPE ao_led_enable; +AO_PORT_TYPE ao_led_enable; void ao_led_on(AO_PORT_TYPE colors) @@ -49,7 +49,7 @@ ao_led_toggle(AO_PORT_TYPE colors) } void -ao_led_for(AO_PORT_TYPE colors, uint16_t ticks) __reentrant +ao_led_for(AO_PORT_TYPE colors, uint16_t ticks) { ao_led_on(colors); ao_delay(ticks); diff --git a/src/lpc/ao_timer_lpc.c b/src/lpc/ao_timer_lpc.c index 166e2f15..8999c7ac 100644 --- a/src/lpc/ao_timer_lpc.c +++ b/src/lpc/ao_timer_lpc.c @@ -18,7 +18,7 @@ #include -volatile __data AO_TICK_TYPE ao_tick_count; +volatile AO_TICK_TYPE ao_tick_count; uint16_t ao_time(void) @@ -27,8 +27,8 @@ ao_time(void) } #if AO_DATA_ALL -volatile __data uint8_t ao_data_interval = 1; -volatile __data uint8_t ao_data_count; +volatile uint8_t ao_data_interval = 1; +volatile uint8_t ao_data_count; #endif void lpc_systick_isr(void) diff --git a/src/lpc/ao_usb_lpc.c b/src/lpc/ao_usb_lpc.c index d26a1437..5cd7aa59 100644 --- a/src/lpc/ao_usb_lpc.c +++ b/src/lpc/ao_usb_lpc.c @@ -1003,7 +1003,7 @@ ao_usb_irq(void) control_count, out_count, in_count, int_count, reset_count); } -__code struct ao_cmds ao_usb_cmds[] = { +const struct ao_cmds ao_usb_cmds[] = { { ao_usb_irq, "I\0Show USB interrupt counts" }, { 0, NULL } }; diff --git a/src/micropeak-v2.0/micropeak.ld b/src/micropeak-v2.0/micropeak.ld index baeae5b8..a73d4c1d 100644 --- a/src/micropeak-v2.0/micropeak.ld +++ b/src/micropeak-v2.0/micropeak.ld @@ -90,7 +90,7 @@ SECTIONS { */ .textram BLOCK(8): { - __data_start__ = .; + _start__ = .; *(.ramtext) } >ram AT>rom @@ -99,7 +99,7 @@ SECTIONS { */ .data BLOCK(8): { *(.data) /* initialized data */ - __data_end__ = .; + _end__ = .; } >ram AT>rom .bss : { diff --git a/src/nucleao-32/load.ld b/src/nucleao-32/load.ld index 02a23a95..945f7c60 100644 --- a/src/nucleao-32/load.ld +++ b/src/nucleao-32/load.ld @@ -82,10 +82,10 @@ SECTIONS { /* Data -- relocated to RAM, but written to ROM */ .data : { - __data_start__ = .; + _start__ = .; *(.data) /* initialized data */ . = ALIGN(4); - __data_end__ = .; + _end__ = .; } >ram AT>rom .bss : { diff --git a/src/pnpservo-v1/lambda.ld b/src/pnpservo-v1/lambda.ld index 5de65eb5..d3edbe9f 100644 --- a/src/pnpservo-v1/lambda.ld +++ b/src/pnpservo-v1/lambda.ld @@ -85,7 +85,7 @@ SECTIONS { */ .textram BLOCK(8): { - __data_start__ = .; + _start__ = .; __text_ram_start__ = .; *(.ramtext) __text_ram_end = .; @@ -96,7 +96,7 @@ SECTIONS { .data : { *(.data) /* initialized data */ . = ALIGN(4); - __data_end__ = .; + _end__ = .; } >ram AT>rom .bss : { diff --git a/src/product/ao_flash_task.c b/src/product/ao_flash_task.c index 1f0edb05..a680ca18 100644 --- a/src/product/ao_flash_task.c +++ b/src/product/ao_flash_task.c @@ -29,7 +29,7 @@ ao_panic(uint8_t reason) } void -ao_put_string(__code char *s) +ao_put_string(const char *s) { char c; while ((c = *s++)) { diff --git a/src/product/ao_terraui.c b/src/product/ao_terraui.c index f8f23a0f..3a989f5a 100644 --- a/src/product/ao_terraui.c +++ b/src/product/ao_terraui.c @@ -20,15 +20,15 @@ #include #include -static __xdata struct ao_telemetry_sensor ao_tel_sensor; -static __xdata struct ao_telemetry_location ao_tel_location; -static __xdata struct ao_telemetry_configuration ao_tel_config; -static __xdata int16_t ao_tel_max_speed; -static __xdata int16_t ao_tel_max_height; +static struct ao_telemetry_sensor ao_tel_sensor; +static struct ao_telemetry_location ao_tel_location; +static struct ao_telemetry_configuration ao_tel_config; +static int16_t ao_tel_max_speed; +static int16_t ao_tel_max_height; static int8_t ao_tel_rssi; -static __xdata char ao_lcd_line[17]; -static __xdata char ao_state_name[] = "SIPBFCDMLI"; +static char ao_lcd_line[17]; +static char ao_state_name[] = "SIPBFCDMLI"; static void ao_terraui_line(uint8_t addr) @@ -85,7 +85,7 @@ ao_terraui_logging(void) return '-'; } -static __code char ao_progress[4] = { '\011', '\012', '\014', '\013' }; +static const char ao_progress[4] = { '\011', '\012', '\014', '\013' }; static uint8_t ao_telem_progress; static uint8_t ao_gps_progress; @@ -165,7 +165,7 @@ static int16_t mag(int32_t d) static int32_t dist(int32_t d) { - __pdata uint32_t m; + uint32_t m; uint8_t neg = 0; if (d < 0) { @@ -184,7 +184,7 @@ dist(int32_t d) return d; } -static __code uint8_t cos_table[] = { +static const uint8_t cos_table[] = { 0, /* 0 */ 0, /* 1 */ 0, /* 2 */ @@ -242,7 +242,7 @@ static __code uint8_t cos_table[] = { 1, /* 54 */ }; -static __code uint8_t tan_table[] = { +static const uint8_t tan_table[] = { 0, /* 0 */ 4, /* 1 */ 9, /* 2 */ @@ -290,7 +290,7 @@ static __code uint8_t tan_table[] = { 247, /* 44 */ }; -int16_t ao_atan2(int32_t dy, int32_t dx) __reentrant +int16_t ao_atan2(int32_t dy, int32_t dx) { int8_t m = 1; int16_t a = 0; @@ -334,10 +334,10 @@ int16_t ao_atan2(int32_t dy, int32_t dx) __reentrant return t * m + a; } -static __pdata int32_t lon_dist, lat_dist; -static __pdata uint32_t ground_dist, range; -static __pdata uint8_t dist_in_km; -static __pdata int16_t bearing, elevation; +static int32_t lon_dist, lat_dist; +static uint32_t ground_dist, range; +static uint8_t dist_in_km; +static int16_t bearing, elevation; static void ao_terraui_lat_dist(void) @@ -346,7 +346,7 @@ ao_terraui_lat_dist(void) } static void -ao_terraui_lon_dist(void) __reentrant +ao_terraui_lon_dist(void) { uint8_t c = cos_table[ao_gps_data.latitude >> 24]; lon_dist = ao_tel_location.longitude; @@ -418,7 +418,7 @@ ao_terraui_recover(void) } static void -ao_terraui_coord(int32_t c, char plus, char minus, char extra) __reentrant +ao_terraui_coord(int32_t c, char plus, char minus, char extra) { uint16_t d; uint8_t m; @@ -448,7 +448,7 @@ ao_terraui_remote(void) } static void -ao_terraui_local(void) __reentrant +ao_terraui_local(void) { ao_terraui_coord(ao_gps_data.latitude, 'n', 's', ao_terraui_local_gps()); @@ -457,11 +457,11 @@ ao_terraui_local(void) __reentrant ao_terraui_line(AO_LCD_ADDR(1,0)); } -static __pdata uint8_t ao_set_freq; -static __pdata uint32_t ao_set_freq_orig; +static uint8_t ao_set_freq; +static uint32_t ao_set_freq_orig; static void -ao_terraui_freq(void) __reentrant +ao_terraui_freq(void) { uint16_t MHz; uint16_t frac; @@ -508,7 +508,7 @@ ao_terraui_freq_button(char b) { ao_radio_recv_abort(); } -static __code void (*__code ao_terraui_page[])(void) = { +static const void (*const ao_terraui_page[])(void) = { ao_terraui_startup, ao_terraui_info, ao_terraui_pad, @@ -521,8 +521,8 @@ static __code void (*__code ao_terraui_page[])(void) = { #define NUM_PAGE (sizeof (ao_terraui_page)/sizeof (ao_terraui_page[0])) -static __pdata uint8_t ao_current_page = 0; -static __pdata uint8_t ao_shown_about = 3; +static uint8_t ao_current_page = 0; +static uint8_t ao_shown_about = 3; static void ao_terraui(void) @@ -575,7 +575,7 @@ ao_terraui(void) } } -__xdata static struct ao_task ao_terraui_task; +static struct ao_task ao_terraui_task; static void ao_terramonitor(void) @@ -619,7 +619,7 @@ ao_terramonitor(void) } } -__xdata static struct ao_task ao_terramonitor_task; +static struct ao_task ao_terramonitor_task; static void ao_terragps(void) @@ -634,7 +634,7 @@ ao_terragps(void) } } -__xdata static struct ao_task ao_terragps_task; +static struct ao_task ao_terragps_task; void ao_terraui_init(void) diff --git a/src/product/ao_test.c b/src/product/ao_test.c index d1c60804..5db36293 100644 --- a/src/product/ao_test.c +++ b/src/product/ao_test.c @@ -18,13 +18,13 @@ #include "ao.h" -struct ao_task __xdata blink_0_task; -struct ao_task __xdata blink_1_task; -struct ao_task __xdata wakeup_task; -struct ao_task __xdata beep_task; -struct ao_task __xdata echo_task; +struct ao_task blink_0_task; +struct ao_task blink_1_task; +struct ao_task wakeup_task; +struct ao_task beep_task; +struct ao_task echo_task; -void delay(int n) __reentrant +void delay(int n) { uint8_t j = 0; while (--n) @@ -32,7 +32,7 @@ void delay(int n) __reentrant ao_yield(); } -static __xdata uint8_t blink_chan; +static uint8_t blink_chan; void blink_0(void) @@ -51,7 +51,7 @@ blink_0(void) void blink_1(void) { - static __xdata struct ao_adc adc; + static struct ao_adc adc; for (;;) { ao_sleep(&ao_adc_head); @@ -75,7 +75,7 @@ wakeup(void) void beep(void) { - static __xdata struct ao_adc adc; + static struct ao_adc adc; for (;;) { ao_delay(AO_SEC_TO_TICKS(1)); diff --git a/src/stm-bringup/bringup.ld b/src/stm-bringup/bringup.ld index dcdcf073..71039598 100644 --- a/src/stm-bringup/bringup.ld +++ b/src/stm-bringup/bringup.ld @@ -44,13 +44,13 @@ SECTIONS { } > rom . = ORIGIN(ram); - __data_start__ = .; + _start__ = .; /* Data -- relocated to RAM, but written to ROM */ .data : AT (ADDR(.ARM.exidx) + SIZEOF (.ARM.exidx)) { *(.data) /* initialized data */ - __data_end__ = .; + _end__ = .; __bss_start__ = .; } >ram diff --git a/src/stm-demo/ao_demo.c b/src/stm-demo/ao_demo.c index f6c8e3df..b0d03840 100644 --- a/src/stm-demo/ao_demo.c +++ b/src/stm-demo/ao_demo.c @@ -197,7 +197,7 @@ ao_blink_toggle(void) } -__code struct ao_cmds ao_demo_cmds[] = { +const struct ao_cmds ao_demo_cmds[] = { { ao_dma_test, "D\0DMA test" }, { ao_spi_write, "W\0SPI write" }, { ao_spi_read, "R\0SPI read" }, diff --git a/src/stm-scheme-newlib/ao_demo.c b/src/stm-scheme-newlib/ao_demo.c index 13a31288..cb8e10e8 100644 --- a/src/stm-scheme-newlib/ao_demo.c +++ b/src/stm-scheme-newlib/ao_demo.c @@ -26,7 +26,7 @@ static void scheme_cmd() { } -__code struct ao_cmds ao_demo_cmds[] = { +const struct ao_cmds ao_demo_cmds[] = { { scheme_cmd, "l\0Run scheme interpreter" }, { 0, NULL } }; diff --git a/src/stm-vga/ao_demo.c b/src/stm-vga/ao_demo.c index 1b443b1f..63740f8e 100644 --- a/src/stm-vga/ao_demo.c +++ b/src/stm-vga/ao_demo.c @@ -198,7 +198,7 @@ ao_console_send(void) } } -__code struct ao_cmds ao_demo_cmds[] = { +const struct ao_cmds ao_demo_cmds[] = { { ao_video_toggle, "V\0Toggle video" }, { ao_ball_toggle, "B\0Toggle ball" }, { ao_ps2_read_keys, "K\0Read keys from keyboard" }, diff --git a/src/stm/altos-512.ld b/src/stm/altos-512.ld index 78c41685..97a9c437 100644 --- a/src/stm/altos-512.ld +++ b/src/stm/altos-512.ld @@ -74,10 +74,10 @@ SECTIONS { /* Data -- relocated to RAM, but written to ROM */ .data : { - __data_start__ = .; + _start__ = .; *(.data) /* initialized data */ . = ALIGN(4); - __data_end__ = .; + _end__ = .; } >ram AT>rom .bss : { diff --git a/src/stm/altos-loader.ld b/src/stm/altos-loader.ld index 806b4842..1ebbc7a2 100644 --- a/src/stm/altos-loader.ld +++ b/src/stm/altos-loader.ld @@ -65,7 +65,7 @@ SECTIONS { */ .textram BLOCK(8): { - __data_start__ = .; + _start__ = .; __text_ram_start__ = .; *(.ramtext) __text_ram_end = .; @@ -76,7 +76,7 @@ SECTIONS { */ .data BLOCK(8): { *(.data) /* initialized data */ - __data_end__ = .; + _end__ = .; } >ram AT>rom diff --git a/src/stm/altos-ram.ld b/src/stm/altos-ram.ld index 098454e1..d8f072a7 100644 --- a/src/stm/altos-ram.ld +++ b/src/stm/altos-ram.ld @@ -42,13 +42,13 @@ SECTIONS { __text_end__ = .; } > ram - __data_start__ = .; + _start__ = .; /* Data -- relocated to RAM, but written to ROM */ .data : AT (ADDR(.ARM.exidx) + SIZEOF (.ARM.exidx)) { *(.data) /* initialized data */ - __data_end__ = .; + _end__ = .; __bss_start__ = .; } >ram diff --git a/src/stm/altos.ld b/src/stm/altos.ld index 6a8c7113..e352ed36 100644 --- a/src/stm/altos.ld +++ b/src/stm/altos.ld @@ -74,10 +74,10 @@ SECTIONS { /* Data -- relocated to RAM, but written to ROM */ .data : { - __data_start__ = .; + _start__ = .; *(.data) /* initialized data */ . = ALIGN(4); - __data_end__ = .; + _end__ = .; } >ram AT>rom .bss : { diff --git a/src/stm/ao_adc_single_stm.c b/src/stm/ao_adc_single_stm.c index 8a7fda4a..5737cd50 100644 --- a/src/stm/ao_adc_single_stm.c +++ b/src/stm/ao_adc_single_stm.c @@ -95,7 +95,7 @@ ao_adc_dump(void) AO_ADC_DUMP(&packet); } -__code struct ao_cmds ao_adc_cmds[] = { +const struct ao_cmds ao_adc_cmds[] = { { ao_adc_dump, "a\0Display current ADC values" }, { 0, NULL }, }; diff --git a/src/stm/ao_adc_stm.c b/src/stm/ao_adc_stm.c index 24912bb2..2399e6a2 100644 --- a/src/stm/ao_adc_stm.c +++ b/src/stm/ao_adc_stm.c @@ -100,7 +100,7 @@ ao_adc_poll(void) * Fetch a copy of the most recent ADC data */ void -ao_adc_get(__xdata struct ao_adc *packet) +ao_adc_get(struct ao_adc *packet) { #if HAS_FLIGHT uint8_t i = ao_data_ring_prev(ao_sample_data); @@ -177,7 +177,7 @@ static const char *ao_adc_name[AO_NUM_ADC] = { #endif static void -ao_adc_dump(void) __reentrant +ao_adc_dump(void) { struct ao_data packet; #ifndef AO_ADC_DUMP @@ -203,7 +203,7 @@ ao_adc_dump(void) __reentrant #endif } -__code struct ao_cmds ao_adc_cmds[] = { +const struct ao_cmds ao_adc_cmds[] = { { ao_adc_dump, "a\0Display current ADC values" }, { 0, NULL }, }; diff --git a/src/stm/ao_arch.h b/src/stm/ao_arch.h index 7b08b891..aee9df3c 100644 --- a/src/stm/ao_arch.h +++ b/src/stm/ao_arch.h @@ -41,11 +41,6 @@ #define ao_arch_naked_declare __attribute__((naked)) #define ao_arch_naked_define -#define __pdata -#define __data -#define __xdata -#define __code const -#define __reentrant #define __interrupt(n) #define __at(n) diff --git a/src/stm/ao_beep_stm.c b/src/stm/ao_beep_stm.c index 0b4e6012..f9fa14c2 100644 --- a/src/stm/ao_beep_stm.c +++ b/src/stm/ao_beep_stm.c @@ -132,7 +132,7 @@ ao_beep(uint8_t beep) } void -ao_beep_for(uint8_t beep, uint16_t ticks) __reentrant +ao_beep_for(uint8_t beep, uint16_t ticks) { ao_beep(beep); ao_delay(ticks); diff --git a/src/stm/ao_eeprom_stm.c b/src/stm/ao_eeprom_stm.c index 4f477122..d3e3338d 100644 --- a/src/stm/ao_eeprom_stm.c +++ b/src/stm/ao_eeprom_stm.c @@ -117,10 +117,10 @@ ao_intflash_read(uint16_t pos) */ uint8_t -ao_eeprom_write(ao_pos_t pos32, __xdata void *v, uint16_t len) +ao_eeprom_write(ao_pos_t pos32, void *v, uint16_t len) { uint16_t pos = pos32; - __xdata uint8_t *d = v; + uint8_t *d = v; if (pos >= ao_eeprom_total || pos + len > ao_eeprom_total) return 0; @@ -151,7 +151,7 @@ ao_eeprom_write(ao_pos_t pos32, __xdata void *v, uint16_t len) * Read from eeprom */ uint8_t -ao_eeprom_read(ao_pos_t pos, __xdata void *v, uint16_t len) +ao_eeprom_read(ao_pos_t pos, void *v, uint16_t len) { uint8_t *d = v; diff --git a/src/stm/ao_interrupt.c b/src/stm/ao_interrupt.c index eb1ed0b5..d8be3667 100644 --- a/src/stm/ao_interrupt.c +++ b/src/stm/ao_interrupt.c @@ -24,7 +24,7 @@ extern void main(void); extern char __stack__; extern char __text_start__, __text_end__; -extern char __data_start__, __data_end__; +extern char _start__, _end__; extern char __bss_start__, __bss_end__; /* Interrupt functions */ @@ -83,7 +83,7 @@ void start(void) #endif /* Set interrupt vector table offset */ stm_nvic.vto = (uint32_t) &stm_interrupt_vector; - memcpy(&__data_start__, &__text_end__, &__data_end__ - &__data_start__); + memcpy(&_start__, &__text_end__, &_end__ - &_start__); memset(&__bss_start__, '\0', &__bss_end__ - &__bss_start__); main(); } diff --git a/src/stm/ao_led.c b/src/stm/ao_led.c index a7033dbb..bd83f4e4 100644 --- a/src/stm/ao_led.c +++ b/src/stm/ao_led.c @@ -153,7 +153,7 @@ ao_led_toggle(AO_LED_TYPE colors) } void -ao_led_for(AO_LED_TYPE colors, AO_LED_TYPE ticks) __reentrant +ao_led_for(AO_LED_TYPE colors, AO_LED_TYPE ticks) { ao_led_on(colors); ao_delay(ticks); diff --git a/src/stm/ao_timer.c b/src/stm/ao_timer.c index 9d118b72..9e9436cf 100644 --- a/src/stm/ao_timer.c +++ b/src/stm/ao_timer.c @@ -39,8 +39,8 @@ ao_time(void) #endif #if AO_DATA_ALL -volatile __data uint8_t ao_data_interval = 1; -volatile __data uint8_t ao_data_count; +volatile uint8_t ao_data_interval = 1; +volatile uint8_t ao_data_count; #endif void stm_systick_isr(void) diff --git a/src/stm/ao_usb_stm.c b/src/stm/ao_usb_stm.c index b06814d2..d7cbd5b7 100644 --- a/src/stm/ao_usb_stm.c +++ b/src/stm/ao_usb_stm.c @@ -1079,7 +1079,7 @@ ao_usb_irq(void) control_count, out_count, in_count, int_count, reset_count); } -__code struct ao_cmds ao_usb_cmds[] = { +const struct ao_cmds ao_usb_cmds[] = { { ao_usb_irq, "I\0Show USB interrupt counts" }, { 0, NULL } }; diff --git a/src/stmf0/altos-loader.ld b/src/stmf0/altos-loader.ld index 05887d0e..4d9b81ae 100644 --- a/src/stmf0/altos-loader.ld +++ b/src/stmf0/altos-loader.ld @@ -66,7 +66,7 @@ SECTIONS { */ .textram BLOCK(8): { - __data_start__ = .; + _start__ = .; __text_ram_start__ = .; *(.ramtext) __text_ram_end = .; @@ -77,7 +77,7 @@ SECTIONS { */ .data BLOCK(8): { *(.data) /* initialized data */ - __data_end__ = .; + _end__ = .; } >ram AT>rom diff --git a/src/stmf0/altos-raw.ld b/src/stmf0/altos-raw.ld index eb285e07..90c42ad2 100644 --- a/src/stmf0/altos-raw.ld +++ b/src/stmf0/altos-raw.ld @@ -61,10 +61,10 @@ SECTIONS { /* Data -- relocated to RAM, but written to ROM */ .data : { - __data_start__ = .; + _start__ = .; *(.data) /* initialized data */ . = ALIGN(4); - __data_end__ = .; + _end__ = .; } >ram AT>rom .bss : { diff --git a/src/stmf0/altos.ld b/src/stmf0/altos.ld index 74fdf3ea..64e1d00c 100644 --- a/src/stmf0/altos.ld +++ b/src/stmf0/altos.ld @@ -81,10 +81,10 @@ SECTIONS { /* Data -- relocated to RAM, but written to ROM */ .data : { - __data_start__ = .; + _start__ = .; *(.data) /* initialized data */ . = ALIGN(4); - __data_end__ = .; + _end__ = .; } >ram AT>rom .bss : { diff --git a/src/stmf0/ao_adc_stm.c b/src/stmf0/ao_adc_stm.c index 2b23dc50..571830bb 100644 --- a/src/stmf0/ao_adc_stm.c +++ b/src/stmf0/ao_adc_stm.c @@ -180,7 +180,7 @@ ao_adc_one(void) } #endif -__code struct ao_cmds ao_adc_cmds[] = { +const struct ao_cmds ao_adc_cmds[] = { { ao_adc_dump, "a\0Display current ADC values" }, #if AO_ADC_DEBUG { ao_adc_one, "A ch\0Display one ADC channel" }, diff --git a/src/stmf0/ao_arch.h b/src/stmf0/ao_arch.h index db6324cb..15642951 100644 --- a/src/stmf0/ao_arch.h +++ b/src/stmf0/ao_arch.h @@ -43,11 +43,6 @@ #define ao_arch_naked_declare __attribute__((naked)) #define ao_arch_naked_define -#define __pdata -#define __data -#define __xdata -#define __code const -#define __reentrant #define __interrupt(n) #define __at(n) diff --git a/src/stmf0/ao_beep_stm.c b/src/stmf0/ao_beep_stm.c index 15137230..abcc116c 100644 --- a/src/stmf0/ao_beep_stm.c +++ b/src/stmf0/ao_beep_stm.c @@ -376,7 +376,7 @@ ao_beep(uint8_t beep) } void -ao_beep_for(uint8_t beep, uint16_t ticks) __reentrant +ao_beep_for(uint8_t beep, uint16_t ticks) { ao_beep(beep); ao_delay(ticks); diff --git a/src/stmf0/ao_interrupt.c b/src/stmf0/ao_interrupt.c index a67f6f1a..81878d89 100644 --- a/src/stmf0/ao_interrupt.c +++ b/src/stmf0/ao_interrupt.c @@ -35,7 +35,7 @@ extern void main(void); extern char __stack__; extern char __text_start__, __text_end__; -extern char __data_start__, __data_end__; +extern char _start__, _end__; extern char __bss_start__, __bss_end__; #if RELOCATE_INTERRUPT extern char __interrupt_rom__, __interrupt_start__, __interrupt_end__; @@ -88,7 +88,7 @@ void start(void) stm_syscfg.cfgr1 = (stm_syscfg.cfgr1 & ~(STM_SYSCFG_CFGR1_MEM_MODE_MASK << STM_SYSCFG_CFGR1_MEM_MODE)) | (STM_SYSCFG_CFGR1_MEM_MODE_MAIN_FLASH << STM_SYSCFG_CFGR1_MEM_MODE); #endif - memcpy(&__data_start__, &__text_end__, &__data_end__ - &__data_start__); + memcpy(&_start__, &__text_end__, &_end__ - &_start__); memset(&__bss_start__, '\0', &__bss_end__ - &__bss_start__); main(); } diff --git a/src/stmf0/ao_led.c b/src/stmf0/ao_led.c index 0f39befb..a162932a 100644 --- a/src/stmf0/ao_led.c +++ b/src/stmf0/ao_led.c @@ -18,7 +18,7 @@ #include "ao.h" -__pdata uint16_t ao_led_enable; +uint16_t ao_led_enable; void ao_led_on(uint16_t colors) @@ -76,7 +76,7 @@ ao_led_toggle(uint16_t colors) } void -ao_led_for(uint16_t colors, uint16_t ticks) __reentrant +ao_led_for(uint16_t colors, uint16_t ticks) { ao_led_on(colors); ao_delay(ticks); diff --git a/src/stmf0/ao_storage_stm.c b/src/stmf0/ao_storage_stm.c index 1a6198a7..17c934a5 100644 --- a/src/stmf0/ao_storage_stm.c +++ b/src/stmf0/ao_storage_stm.c @@ -157,7 +157,7 @@ ao_storage_device_write(uint32_t pos, void *v, uint16_t len) } uint8_t -ao_storage_device_read(uint32_t pos, __xdata void *d, uint16_t len) __reentrant +ao_storage_device_read(uint32_t pos, void *d, uint16_t len) { if (pos >= ao_storage_total || pos + len > ao_storage_total) return 0; @@ -166,7 +166,7 @@ ao_storage_device_read(uint32_t pos, __xdata void *d, uint16_t len) __reentrant } void -ao_storage_flush(void) __reentrant +ao_storage_flush(void) { } @@ -179,7 +179,7 @@ ao_storage_setup(void) } void -ao_storage_device_info(void) __reentrant +ao_storage_device_info(void) { printf ("Using internal flash, page %d bytes, total %d bytes\n", ao_storage_block, ao_storage_total); diff --git a/src/stmf0/ao_timer.c b/src/stmf0/ao_timer.c index 50fd67b8..1def5f69 100644 --- a/src/stmf0/ao_timer.c +++ b/src/stmf0/ao_timer.c @@ -36,8 +36,8 @@ ao_time(void) } #if AO_DATA_ALL -volatile __data uint8_t ao_data_interval = 1; -volatile __data uint8_t ao_data_count; +volatile uint8_t ao_data_interval = 1; +volatile uint8_t ao_data_count; #endif void stm_systick_isr(void) diff --git a/src/stmf0/ao_usb_stm.c b/src/stmf0/ao_usb_stm.c index c4860d8e..ff294849 100644 --- a/src/stmf0/ao_usb_stm.c +++ b/src/stmf0/ao_usb_stm.c @@ -1626,7 +1626,7 @@ ao_usb_irq(void) control_count, out_count, in_count, int_count, reset_count); } -__code struct ao_cmds ao_usb_cmds[] = { +const struct ao_cmds ao_usb_cmds[] = { { ao_usb_irq, "I\0Show USB interrupt counts" }, { 0, NULL } }; diff --git a/src/telefireone-v1.0/ao_telefireone.c b/src/telefireone-v1.0/ao_telefireone.c index 115b3e91..790d7a41 100644 --- a/src/telefireone-v1.0/ao_telefireone.c +++ b/src/telefireone-v1.0/ao_telefireone.c @@ -31,7 +31,7 @@ set_logging(void) ao_wakeup(&ao_log_running); } -__code struct ao_cmds ao_firetwo_cmds[] = { +const struct ao_cmds ao_firetwo_cmds[] = { { set_logging, "L <0 off, 1 on>\0Log sensors to flash" }, { 0, NULL }, }; diff --git a/src/telelco-v2.0/ao_lco_v2.c b/src/telelco-v2.0/ao_lco_v2.c index a9933d59..428b1a7c 100644 --- a/src/telelco-v2.0/ao_lco_v2.c +++ b/src/telelco-v2.0/ao_lco_v2.c @@ -287,7 +287,7 @@ ao_lco_set_debug(void) ao_lco_debug = ao_cmd_lex_i != 0; } -__code struct ao_cmds ao_lco_cmds[] = { +const struct ao_cmds ao_lco_cmds[] = { { ao_lco_set_debug, "D <0 off, 1 on>\0Debug" }, { ao_lco_search, "s\0Search for pad boxes" }, { 0, NULL } diff --git a/src/test/ao_aes_test.c b/src/test/ao_aes_test.c index 135c6f1a..e1ed5728 100644 --- a/src/test/ao_aes_test.c +++ b/src/test/ao_aes_test.c @@ -16,11 +16,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#define __pdata -#define __data -#define __xdata -#define __code -#define __reentrant +#define const #include #include diff --git a/src/test/ao_eeprom_read.h b/src/test/ao_eeprom_read.h index 03c327ca..afaadb1e 100644 --- a/src/test/ao_eeprom_read.h +++ b/src/test/ao_eeprom_read.h @@ -15,11 +15,7 @@ #ifndef _AO_EEPROM_READ_H_ #define _AO_EEPROM_READ_H_ -#define __pdata -#define __data -#define __xdata -#define __code -#define __reentrant +#define const #include #include diff --git a/src/test/ao_flight_test.c b/src/test/ao_flight_test.c index 0913e7ba..a171930e 100644 --- a/src/test/ao_flight_test.c +++ b/src/test/ao_flight_test.c @@ -119,11 +119,7 @@ struct ao_adc { #endif -#define __pdata -#define __data -#define __xdata -#define __code -#define __reentrant +#define const #define HAS_FLIGHT 1 #define HAS_IGNITE 1 diff --git a/src/test/ao_gps_test_skytraq.c b/src/test/ao_gps_test_skytraq.c index 61e7905a..11c54601 100644 --- a/src/test/ao_gps_test_skytraq.c +++ b/src/test/ao_gps_test_skytraq.c @@ -83,8 +83,8 @@ struct ao_gps_tracking_orig { #define ao_telemetry_satellite ao_gps_tracking_orig #define ao_telemetry_satellite_info ao_gps_sat_orig -extern __xdata struct ao_telemetry_location ao_gps_data; -extern __xdata struct ao_telemetry_satellite ao_gps_tracking_data; +extern struct ao_telemetry_location ao_gps_data; +extern struct ao_telemetry_satellite ao_gps_tracking_data; uint8_t ao_gps_mutex; diff --git a/src/test/ao_gps_test_ublox.c b/src/test/ao_gps_test_ublox.c index 05334bbf..0833e4f6 100644 --- a/src/test/ao_gps_test_ublox.c +++ b/src/test/ao_gps_test_ublox.c @@ -89,8 +89,8 @@ struct ao_telemetry_satellite { #define ao_gps_tracking_orig ao_telemetry_satellite #define ao_gps_sat_orig ao_telemetry_satellite_info -extern __xdata struct ao_telemetry_location ao_gps_data; -extern __xdata struct ao_telemetry_satellite ao_gps_tracking_data; +extern struct ao_telemetry_location ao_gps_data; +extern struct ao_telemetry_satellite ao_gps_tracking_data; uint8_t ao_gps_mutex; diff --git a/src/test/ao_int64_test.c b/src/test/ao_int64_test.c index d329f67b..c7a4891f 100644 --- a/src/test/ao_int64_test.c +++ b/src/test/ao_int64_test.c @@ -16,10 +16,6 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#define __data -#define __pdata -#define __xdata -#define __reentrant #include #include diff --git a/src/test/ao_ms5607_convert_test.c b/src/test/ao_ms5607_convert_test.c index 4876d21e..7708c331 100644 --- a/src/test/ao_ms5607_convert_test.c +++ b/src/test/ao_ms5607_convert_test.c @@ -16,10 +16,6 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#define __xdata -#define __data -#define __pdata -#define __reentrant #include #include diff --git a/src/usbrelay-v0.1/ao_usbrelay.c b/src/usbrelay-v0.1/ao_usbrelay.c index d908f4db..0eacdf5a 100644 --- a/src/usbrelay-v0.1/ao_usbrelay.c +++ b/src/usbrelay-v0.1/ao_usbrelay.c @@ -45,7 +45,7 @@ ao_relay_control(uint8_t output) } static void -ao_relay_select(void) __reentrant +ao_relay_select(void) { uint8_t output; @@ -59,7 +59,7 @@ ao_relay_select(void) __reentrant ao_relay_control(output); } -static __code struct ao_cmds ao_relay_cmds[] = { +static const struct ao_cmds ao_relay_cmds[] = { { ao_relay_select, "R \0Select relay output" }, { 0, NULL } }; -- cgit v1.2.3 From c417ab1de2a083b5fcff2e081e4feb2a65887903 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 15 Aug 2018 19:13:45 -0700 Subject: altos: Make cmd number parsing functions return value Don't use a global variable to hold the result. Signed-off-by: Keith Packard --- src/cortexelf-v1/ao_cortexelf.c | 15 ++--- src/drivers/ao_btm.c | 19 +++--- src/drivers/ao_cc1120.c | 3 +- src/drivers/ao_cc115l.c | 6 +- src/drivers/ao_cc1200.c | 22 +++---- src/drivers/ao_gps_ublox.c | 4 +- src/drivers/ao_lco.c | 4 +- src/drivers/ao_lco_cmd.c | 12 ++-- src/drivers/ao_lco_two.c | 4 +- src/drivers/ao_mpu9250.c | 18 ++---- src/drivers/ao_pad.c | 18 +++--- src/drivers/ao_pca9922.c | 6 +- src/drivers/ao_quadrature.c | 3 +- src/drivers/ao_seven_segment.c | 6 +- src/drivers/ao_watchdog.c | 4 +- src/kernel/ao.h | 8 +-- src/kernel/ao_cmd.c | 56 ++++++++--------- src/kernel/ao_config.c | 111 +++++++++++++++++----------------- src/kernel/ao_fake_flight.c | 6 +- src/kernel/ao_log.c | 3 +- src/kernel/ao_log_single.c | 14 ++--- src/kernel/ao_monitor.c | 3 +- src/kernel/ao_pyro.c | 17 +++--- src/kernel/ao_radio_cmac_cmd.c | 10 +-- src/kernel/ao_send_packet.c | 3 +- src/kernel/ao_storage.c | 27 ++++----- src/kernel/ao_tracker.c | 4 +- src/stm-vga/ao_demo.c | 9 ++- src/stm/ao_lcd_stm.c | 9 +-- src/stm/ao_pwm_stm.c | 6 +- src/stmf0/ao_adc_stm.c | 3 +- src/telefireone-v1.0/ao_telefireone.c | 3 +- src/telelco-v2.0/ao_lco_v2.c | 4 +- src/usbrelay-v0.1/ao_usbrelay.c | 3 +- src/vidtime/ao_vidtime.c | 4 +- 35 files changed, 195 insertions(+), 252 deletions(-) (limited to 'src/kernel') diff --git a/src/cortexelf-v1/ao_cortexelf.c b/src/cortexelf-v1/ao_cortexelf.c index 6bc2624f..1c30cd85 100644 --- a/src/cortexelf-v1/ao_cortexelf.c +++ b/src/cortexelf-v1/ao_cortexelf.c @@ -149,17 +149,16 @@ ao_fb_init(void) static void ao_video_toggle(void) { - ao_cmd_decimal(); - if (ao_cmd_lex_i) + uint16_t r = ao_cmd_decimal(); + if (r) ao_fb_init(); - ao_vga_enable(ao_cmd_lex_i); + ao_vga_enable(r) } static void ao_ball_toggle(void) { - ao_cmd_decimal(); - ball_enable = ao_cmd_lex_i; + ball_enable = ao_cmd_decimal(); ao_wakeup(&ball_enable); } @@ -208,11 +207,9 @@ led_cmd(void) { uint8_t start; uint8_t value; - ao_cmd_decimal(); - start = ao_cmd_lex_i; - ao_cmd_hex(); - value = ao_cmd_lex_i; + start = ao_cmd_decimal(); + value = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) return; ao_as1107_write_8(start, value); diff --git a/src/drivers/ao_btm.c b/src/drivers/ao_btm.c index 3591f8f2..2930d00e 100644 --- a/src/drivers/ao_btm.c +++ b/src/drivers/ao_btm.c @@ -32,7 +32,7 @@ int8_t ao_btm_stdio; uint8_t ao_btm_connected; -#define BT_DEBUG 0 +#define BT_DEBUG 1 #if BT_DEBUG char ao_btm_buffer[256]; @@ -76,6 +76,7 @@ ao_btm_dump(void) { int i; char c; + uint16_t r; for (i = 0; i < ao_btm_ptr; i++) { c = ao_btm_buffer[i]; @@ -85,8 +86,8 @@ ao_btm_dump(void) putchar(ao_btm_buffer[i]); } putchar('\n'); - ao_cmd_decimal(); - if (ao_cmd_status == ao_cmd_success && ao_cmd_lex_i) + r = ao_cmd_decimal(); + if (ao_cmd_status == ao_cmd_success && r) ao_btm_ptr = 0; ao_cmd_status = ao_cmd_success; } @@ -94,13 +95,17 @@ ao_btm_dump(void) static void ao_btm_speed(void) { - ao_cmd_decimal(); - if (ao_cmd_lex_u32 == 57600) + switch (ao_cmd_decimal()) { + case 57600: ao_serial_btm_set_speed(AO_SERIAL_SPEED_57600); - else if (ao_cmd_lex_u32 == 19200) + break; + case 19200: ao_serial_btm_set_speed(AO_SERIAL_SPEED_19200); - else + break; + default: ao_cmd_status = ao_cmd_syntax_error; + break; + } } static uint8_t ao_btm_enable; diff --git a/src/drivers/ao_cc1120.c b/src/drivers/ao_cc1120.c index d581c246..aea0a3fe 100644 --- a/src/drivers/ao_cc1120.c +++ b/src/drivers/ao_cc1120.c @@ -805,8 +805,7 @@ ao_radio_test_cmd(void) static uint8_t radio_on; ao_cmd_white(); if (ao_cmd_lex_c != '\n') { - ao_cmd_decimal(); - mode = (uint8_t) ao_cmd_lex_u32; + mode = ao_cmd_decimal(); } mode++; if ((mode & 2) && !radio_on) { diff --git a/src/drivers/ao_cc115l.c b/src/drivers/ao_cc115l.c index c1c21e0d..a8f2c4f5 100644 --- a/src/drivers/ao_cc115l.c +++ b/src/drivers/ao_cc115l.c @@ -700,10 +700,8 @@ ao_radio_test_cmd(void) uint8_t mode = 2; static uint8_t radio_on; ao_cmd_white(); - if (ao_cmd_lex_c != '\n') { - ao_cmd_decimal(); - mode = (uint8_t) ao_cmd_lex_u32; - } + if (ao_cmd_lex_c != '\n') + mode = ao_cmd_decimal(); mode++; if ((mode & 2) && !radio_on) { #if HAS_MONITOR diff --git a/src/drivers/ao_cc1200.c b/src/drivers/ao_cc1200.c index f2f9c372..45f5711e 100644 --- a/src/drivers/ao_cc1200.c +++ b/src/drivers/ao_cc1200.c @@ -858,10 +858,8 @@ ao_radio_test_cmd(void) { uint8_t mode = 2; ao_cmd_white(); - if (ao_cmd_lex_c != '\n') { - ao_cmd_decimal(); - mode = (uint8_t) ao_cmd_lex_u32; - } + if (ao_cmd_lex_c != '\n') + mode = ao_cmd_decimal(); mode++; if ((mode & 2)) ao_radio_test_on(); @@ -1362,14 +1360,15 @@ ao_radio_aprs(void) static void ao_radio_strobe_test(void) { + uint8_t addr; uint8_t r; - ao_cmd_hex(); + addr = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) return; - r = ao_radio_strobe(ao_cmd_lex_i); + r = ao_radio_strobe(addr); printf ("Strobe %02x -> %02x (rdy %d state %d)\n", - ao_cmd_lex_i, + addr, r, r >> 7, (r >> 4) & 0x7); @@ -1381,14 +1380,12 @@ ao_radio_write_test(void) uint16_t addr; uint8_t data; - ao_cmd_hex(); + addr = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) return; - addr = ao_cmd_lex_i; - ao_cmd_hex(); + data = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) return; - data = ao_cmd_lex_i; printf ("Write %04x = %02x\n", addr, data); ao_radio_reg_write(addr, data); } @@ -1399,10 +1396,9 @@ ao_radio_read_test(void) uint16_t addr; uint8_t data; - ao_cmd_hex(); + addr = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) return; - addr = ao_cmd_lex_i; data = ao_radio_reg_read(addr); printf ("Read %04x = %02x\n", addr, data); } diff --git a/src/drivers/ao_gps_ublox.c b/src/drivers/ao_gps_ublox.c index f5268aa7..a6d93083 100644 --- a/src/drivers/ao_gps_ublox.c +++ b/src/drivers/ao_gps_ublox.c @@ -783,12 +783,12 @@ ao_gps(void) #if AO_UBLOX_DEBUG static void ao_gps_option(void) { - ao_cmd_hex(); + uint16_t r = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) { ao_cmd_status = ao_cmd_success; ao_gps_show(); } else { - ao_gps_dbg_enable = ao_cmd_lex_i; + ao_gps_dbg_enable = r; printf ("gps debug set to %d\n", ao_gps_dbg_enable); } } diff --git a/src/drivers/ao_lco.c b/src/drivers/ao_lco.c index 86635200..5f5db572 100644 --- a/src/drivers/ao_lco.c +++ b/src/drivers/ao_lco.c @@ -319,9 +319,9 @@ ao_lco_main(void) void ao_lco_set_debug(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status == ao_cmd_success) - ao_lco_debug = ao_cmd_lex_i != 0; + ao_lco_debug = r != 0; } const struct ao_cmds ao_lco_cmds[] = { diff --git a/src/drivers/ao_lco_cmd.c b/src/drivers/ao_lco_cmd.c index 3fcdc859..6f195e55 100644 --- a/src/drivers/ao_lco_cmd.c +++ b/src/drivers/ao_lco_cmd.c @@ -33,10 +33,8 @@ static uint16_t tick_offset; static void lco_args(void) { - ao_cmd_decimal(); - lco_box = ao_cmd_lex_i; - ao_cmd_hex(); - lco_channels = ao_cmd_lex_i; + lco_box = ao_cmd_decimal(); + lco_channels = ao_cmd_hex(); } static struct ao_pad_query ao_pad_query; @@ -129,8 +127,7 @@ lco_fire_cmd(void) int8_t r; lco_args(); - ao_cmd_decimal(); - secs = ao_cmd_lex_i; + secs = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; r = lco_query(); @@ -163,8 +160,7 @@ lco_static_cmd(void) int8_t r; lco_args(); - ao_cmd_decimal(); - secs = ao_cmd_lex_i; + secs = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; r = lco_query(); diff --git a/src/drivers/ao_lco_two.c b/src/drivers/ao_lco_two.c index 12c02e88..49ea1236 100644 --- a/src/drivers/ao_lco_two.c +++ b/src/drivers/ao_lco_two.c @@ -124,9 +124,9 @@ ao_lco_main(void) void ao_lco_set_debug(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status == ao_cmd_success) - ao_lco_debug = ao_cmd_lex_i; + ao_lco_debug = r; } const struct ao_cmds ao_lco_cmds[] = { diff --git a/src/drivers/ao_mpu9250.c b/src/drivers/ao_mpu9250.c index ae8dacd0..9dce9f1a 100644 --- a/src/drivers/ao_mpu9250.c +++ b/src/drivers/ao_mpu9250.c @@ -472,10 +472,9 @@ ao_mpu9250_read(void) uint8_t addr; uint8_t val; - ao_cmd_hex(); + addr = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) return; - addr = ao_cmd_lex_i; ao_mpu9250_spi_get(); val = _ao_mpu9250_reg_read(addr); ao_mpu9250_spi_put(); @@ -488,14 +487,12 @@ ao_mpu9250_write(void) uint8_t addr; uint8_t val; - ao_cmd_hex(); + addr = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) return; - addr = ao_cmd_lex_i; - ao_cmd_hex(); + val = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) return; - val = ao_cmd_lex_i; printf("Addr %02x val %02x\n", addr, val); ao_mpu9250_spi_get(); _ao_mpu9250_reg_write(addr, val); @@ -508,10 +505,9 @@ ao_mpu9250_mag_read(void) uint8_t addr; uint8_t val; - ao_cmd_hex(); + addr = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) return; - addr = ao_cmd_lex_i; ao_mpu9250_spi_get(); val = _ao_mpu9250_mag_reg_read(addr); ao_mpu9250_spi_put(); @@ -524,14 +520,12 @@ ao_mpu9250_mag_write(void) uint8_t addr; uint8_t val; - ao_cmd_hex(); + addr = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) return; - addr = ao_cmd_lex_i; - ao_cmd_hex(); + val = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) return; - val = ao_cmd_lex_i; printf("Addr %02x val %02x\n", addr, val); ao_mpu9250_spi_get(); _ao_mpu9250_mag_reg_write(addr, val); diff --git a/src/drivers/ao_pad.c b/src/drivers/ao_pad.c index 7e139c78..c08798ac 100644 --- a/src/drivers/ao_pad.c +++ b/src/drivers/ao_pad.c @@ -509,16 +509,14 @@ ao_pad_manual(void) ao_cmd_white(); if (!ao_match_word("DoIt")) return; - ao_cmd_decimal(); + ignite = 1 << ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - ignite = 1 << ao_cmd_lex_i; - ao_cmd_decimal(); + repeat = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) { repeat = 1; ao_cmd_status = ao_cmd_success; - } else - repeat = ao_cmd_lex_i; + } while (repeat-- > 0) { ao_pad_ignite = ignite; ao_wakeup(&ao_pad_ignite); @@ -534,9 +532,9 @@ static struct ao_task ao_pad_monitor_task; void ao_pad_set_debug(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status == ao_cmd_success) - ao_pad_debug = ao_cmd_lex_i != 0; + ao_pad_debug = r != 0; } @@ -544,14 +542,12 @@ static void ao_pad_alarm_debug(void) { uint8_t which, value; - ao_cmd_decimal(); + which = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - which = ao_cmd_lex_i; - ao_cmd_decimal(); + value = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - value = ao_cmd_lex_i; printf ("Set %s to %d\n", which ? "siren" : "strobe", value); if (which) ao_siren(value); diff --git a/src/drivers/ao_pca9922.c b/src/drivers/ao_pca9922.c index 3516f03a..91d62026 100644 --- a/src/drivers/ao_pca9922.c +++ b/src/drivers/ao_pca9922.c @@ -72,11 +72,11 @@ ao_led_set_mask(uint8_t colors, uint8_t mask) static void ao_led_test(void) { - ao_cmd_hexbyte(); + AO_LED_TYPE r = ao_cmd_hexbyte(); if (ao_cmd_status != ao_cmd_success) return; - ao_led_set(ao_cmd_lex_i); - printf("LEDs set to %02x\n", ao_cmd_lex_i); + ao_led_set(r); + printf("LEDs set to %x\n", r); } static const struct ao_cmds ao_led_cmds[] = { diff --git a/src/drivers/ao_quadrature.c b/src/drivers/ao_quadrature.c index 20781c40..a5fbd1da 100644 --- a/src/drivers/ao_quadrature.c +++ b/src/drivers/ao_quadrature.c @@ -170,8 +170,7 @@ ao_quadrature_test(void) int8_t t = 0; #endif - ao_cmd_decimal(); - q = ao_cmd_lex_i; + q = ao_cmd_decimal(); if (q >= AO_QUADRATURE_COUNT) ao_cmd_status = ao_cmd_syntax_error; if (ao_cmd_status != ao_cmd_success) diff --git a/src/drivers/ao_seven_segment.c b/src/drivers/ao_seven_segment.c index d2e1248f..1be305e5 100644 --- a/src/drivers/ao_seven_segment.c +++ b/src/drivers/ao_seven_segment.c @@ -209,10 +209,8 @@ static void ao_seven_segment_show(void) { uint8_t digit, value; - ao_cmd_decimal(); - digit = ao_cmd_lex_i; - ao_cmd_decimal(); - value = ao_cmd_lex_i; + digit = ao_cmd_decimal(); + value = ao_cmd_decimal(); ao_seven_segment_set(digit, value); } diff --git a/src/drivers/ao_watchdog.c b/src/drivers/ao_watchdog.c index 01c3cd0e..c0582c12 100644 --- a/src/drivers/ao_watchdog.c +++ b/src/drivers/ao_watchdog.c @@ -38,9 +38,9 @@ ao_watchdog(void) static void ao_watchdog_set(void) { - ao_cmd_hex(); + uint32_t r = ao_cmd_hex(); if (ao_cmd_status == ao_cmd_success) { - ao_watchdog_enabled = ao_cmd_lex_i != 0; + ao_watchdog_enabled = r != 0; ao_wakeup(&ao_watchdog_enabled); } } diff --git a/src/kernel/ao.h b/src/kernel/ao.h index fd1d1276..3beeb880 100644 --- a/src/kernel/ao.h +++ b/src/kernel/ao.h @@ -160,8 +160,6 @@ enum ao_cmd_status { ao_cmd_syntax_error = 2, }; -extern uint16_t ao_cmd_lex_i; -extern uint32_t ao_cmd_lex_u32; extern char ao_cmd_lex_c; extern enum ao_cmd_status ao_cmd_status; @@ -189,13 +187,13 @@ ao_cmd_white(void); int8_t ao_cmd_hexchar(char c); -void +uint8_t ao_cmd_hexbyte(void); -void +uint32_t ao_cmd_hex(void); -void +uint32_t ao_cmd_decimal(void); /* Read a single hex nibble off stdin. */ diff --git a/src/kernel/ao_cmd.c b/src/kernel/ao_cmd.c index d28db5b7..a72192f4 100644 --- a/src/kernel/ao_cmd.c +++ b/src/kernel/ao_cmd.c @@ -19,8 +19,6 @@ #include "ao.h" #include "ao_task.h" -uint16_t ao_cmd_lex_i; -uint32_t ao_cmd_lex_u32; char ao_cmd_lex_c; enum ao_cmd_status ao_cmd_status; @@ -174,55 +172,49 @@ ao_cmd_hexchar(char c) return -1; } -void -ao_cmd_hexbyte(void) +static +uint32_t +_ao_cmd_hex(uint8_t lim) { + uint32_t result = 0; uint8_t i; - int8_t n; - ao_cmd_lex_i = 0; ao_cmd_white(); - for (i = 0; i < 2; i++) { - n = ao_cmd_hexchar(ao_cmd_lex_c); + for (i = 0; i < lim; i++) { + int8_t n = ao_cmd_hexchar(ao_cmd_lex_c); if (n < 0) { - ao_cmd_status = ao_cmd_syntax_error; + if (i == 0 || lim != 0xff) + ao_cmd_status = ao_cmd_lex_error; break; } - ao_cmd_lex_i = (ao_cmd_lex_i << 4) | n; + result = (result << 4) | n; ao_cmd_lex(); } + return result; } -void -ao_cmd_hex(void) +uint8_t +ao_cmd_hexbyte(void) { - uint8_t r = ao_cmd_lex_error; - int8_t n; + return _ao_cmd_hex(2); +} - ao_cmd_lex_i = 0; - ao_cmd_white(); - for(;;) { - n = ao_cmd_hexchar(ao_cmd_lex_c); - if (n < 0) - break; - ao_cmd_lex_i = (ao_cmd_lex_i << 4) | n; - r = ao_cmd_success; - ao_cmd_lex(); - } - if (r != ao_cmd_success) - ao_cmd_status = r; +uint32_t +ao_cmd_hex(void) +{ + return _ao_cmd_hex(0xff); } -void +uint32_t ao_cmd_decimal(void) { + uint32_t result = 0; uint8_t r = ao_cmd_lex_error; - ao_cmd_lex_u32 = 0; ao_cmd_white(); for(;;) { if ('0' <= ao_cmd_lex_c && ao_cmd_lex_c <= '9') - ao_cmd_lex_u32 = (ao_cmd_lex_u32 * 10) + (ao_cmd_lex_c - '0'); + result = result * 10 + (ao_cmd_lex_c - '0'); else break; r = ao_cmd_success; @@ -230,7 +222,7 @@ ao_cmd_decimal(void) } if (r != ao_cmd_success) ao_cmd_status = r; - ao_cmd_lex_i = (uint16_t) ao_cmd_lex_u32; + return result; } uint8_t @@ -250,9 +242,9 @@ ao_match_word(const char *word) static void echo(void) { - ao_cmd_hex(); + uint32_t v = ao_cmd_hex(); if (ao_cmd_status == ao_cmd_success) - ao_stdios[ao_cur_stdio].echo = ao_cmd_lex_i != 0; + ao_stdios[ao_cur_stdio].echo = v != 0; } static void diff --git a/src/kernel/ao_config.c b/src/kernel/ao_config.c index 277dddd9..596a0410 100644 --- a/src/kernel/ao_config.c +++ b/src/kernel/ao_config.c @@ -318,11 +318,11 @@ ao_config_frequency_show(void) void ao_config_frequency_set(void) { - ao_cmd_decimal(); + uint32_t r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; _ao_config_edit_start(); - ao_config.frequency = ao_cmd_lex_u32; + ao_config.frequency = r; ao_config_set_radio(); _ao_config_edit_finish(); #if HAS_RADIO_RECV @@ -369,11 +369,11 @@ ao_config_main_deploy_show(void) void ao_config_main_deploy_set(void) { - ao_cmd_decimal(); + uint32_t r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; _ao_config_edit_start(); - ao_config.main_deploy = ao_cmd_lex_i; + ao_config.main_deploy = r; _ao_config_edit_finish(); } @@ -445,16 +445,17 @@ void ao_config_accel_calibrate_set(void) { int16_t up, down; + uint16_t r; #if HAS_GYRO int16_t accel_along_up = 0, accel_along_down = 0; int16_t accel_across_up = 0, accel_across_down = 0; int16_t accel_through_up = 0, accel_through_down = 0; #endif - ao_cmd_decimal(); + r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - if (ao_cmd_lex_i == 0) { + if (r == 0) { up = ao_config_accel_calibrate_auto("up"); #if HAS_GYRO accel_along_up = accel_cal_along; @@ -468,11 +469,11 @@ ao_config_accel_calibrate_set(void) accel_through_down = accel_cal_through; #endif } else { - up = ao_cmd_lex_i; - ao_cmd_decimal(); + up = r; + r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - down = ao_cmd_lex_i; + down = r; } if (up >= down) { printf("Invalid accel: up (%d) down (%d)\n", @@ -483,7 +484,7 @@ ao_config_accel_calibrate_set(void) ao_config.accel_plus_g = up; ao_config.accel_minus_g = down; #if HAS_GYRO - if (ao_cmd_lex_i == 0) { + if (r == 0) { ao_config.accel_zero_along = (accel_along_up + accel_along_down) / 2; ao_config.accel_zero_across = (accel_across_up + accel_across_down) / 2; ao_config.accel_zero_through = (accel_through_up + accel_through_down) / 2; @@ -503,11 +504,11 @@ ao_config_apogee_delay_show(void) void ao_config_apogee_delay_set(void) { - ao_cmd_decimal(); + uint32_t r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; _ao_config_edit_start(); - ao_config.apogee_delay = ao_cmd_lex_i; + ao_config.apogee_delay = r; _ao_config_edit_finish(); } @@ -521,11 +522,11 @@ ao_config_apogee_lockout_show(void) void ao_config_apogee_lockout_set(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; _ao_config_edit_start(); - ao_config.apogee_lockout = ao_cmd_lex_i; + ao_config.apogee_lockout = r; _ao_config_edit_finish(); } @@ -541,11 +542,11 @@ ao_config_radio_cal_show(void) void ao_config_radio_cal_set(void) { - ao_cmd_decimal(); + uint32_t r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; _ao_config_edit_start(); - ao_config.radio_cal = ao_cmd_lex_u32; + ao_config.radio_cal = r; ao_config_set_radio(); _ao_config_edit_finish(); } @@ -566,15 +567,15 @@ ao_config_radio_rate_show(void) void ao_config_radio_rate_set(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - if (AO_RADIO_RATE_MAX < ao_cmd_lex_i) { + if (AO_RADIO_RATE_MAX < r) { ao_cmd_status = ao_cmd_lex_error; return; } _ao_config_edit_start(); - ao_config.radio_rate = ao_cmd_lex_i; + ao_config.radio_rate = r; _ao_config_edit_finish(); #if HAS_TELEMETRY ao_telemetry_reset_interval(); @@ -618,19 +619,20 @@ ao_config_log_set(void) #else uint16_t block = (uint16_t) (ao_storage_block >> 10); uint16_t log_max = (uint16_t) (ao_storage_log_max >> 10); + uint32_t r; - ao_cmd_decimal(); + r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; if (ao_log_present()) printf("Storage must be empty before changing log size\n"); - else if (block > 1024 && (ao_cmd_lex_i & (block - 1))) + else if (block > 1024 && (r & (block - 1))) printf("Flight log size must be multiple of %d kB\n", block); - else if (ao_cmd_lex_i > log_max) + else if (r > log_max) printf("Flight log max %d kB\n", log_max); else { _ao_config_edit_start(); - ao_config.flight_log_max = (uint32_t) ao_cmd_lex_i << 10; + ao_config.flight_log_max = r << 10; _ao_config_edit_finish(); } #endif @@ -647,11 +649,11 @@ ao_config_ignite_mode_show(void) void ao_config_ignite_mode_set(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; _ao_config_edit_start(); - ao_config.ignite_mode = ao_cmd_lex_i; + ao_config.ignite_mode = r; _ao_config_edit_finish(); } #endif @@ -670,18 +672,17 @@ ao_config_pad_orientation_show(void) void ao_config_pad_orientation_set(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal() & 1; if (ao_cmd_status != ao_cmd_success) return; _ao_config_edit_start(); - ao_cmd_lex_i &= 1; - if (ao_config.pad_orientation != ao_cmd_lex_i) { + if (ao_config.pad_orientation != r) { int16_t t; t = ao_config.accel_plus_g; ao_config.accel_plus_g = AO_ACCEL_INVERT - ao_config.accel_minus_g; ao_config.accel_minus_g = AO_ACCEL_INVERT - t; } - ao_config.pad_orientation = ao_cmd_lex_i; + ao_config.pad_orientation = r; _ao_config_edit_finish(); } #endif @@ -696,11 +697,11 @@ ao_config_radio_enable_show(void) void ao_config_radio_enable_set(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; _ao_config_edit_start(); - ao_config.radio_enable = ao_cmd_lex_i; + ao_config.radio_enable = r; _ao_config_edit_finish(); #if HAS_TELEMETRY && HAS_RADIO_RATE ao_telemetry_reset_interval(); @@ -729,10 +730,10 @@ ao_config_key_set(void) _ao_config_edit_start(); for (i = 0; i < AO_AES_LEN; i++) { - ao_cmd_hexbyte(); + uint8_t b = ao_cmd_hexbyte(); if (ao_cmd_status != ao_cmd_success) break; - ao_config.aes_key[i] = ao_cmd_lex_i; + ao_config.aes_key[i] = b; } ++ao_config_aes_seq; _ao_config_edit_finish(); @@ -750,11 +751,11 @@ ao_config_aprs_show(void) void ao_config_aprs_set(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; _ao_config_edit_start(); - ao_config.aprs_interval = ao_cmd_lex_i; + ao_config.aprs_interval = r; _ao_config_edit_finish(); ao_telemetry_reset_interval(); } @@ -772,11 +773,11 @@ ao_config_radio_amp_show(void) void ao_config_radio_amp_set(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; _ao_config_edit_start(); - ao_config.radio_amp = ao_cmd_lex_i; + ao_config.radio_amp = r; _ao_config_edit_finish(); } @@ -793,11 +794,11 @@ ao_config_radio_power_show(void) void ao_config_radio_power_set(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; _ao_config_edit_start(); - ao_config.radio_power = ao_cmd_lex_i; + ao_config.radio_power = r; _ao_config_edit_finish(); } @@ -813,11 +814,11 @@ ao_config_beep_show(void) void ao_config_beep_set(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; _ao_config_edit_start(); - ao_config.mid_beep = ao_cmd_lex_i; + ao_config.mid_beep = r; _ao_config_edit_finish(); } #endif @@ -835,14 +836,12 @@ void ao_config_tracker_set(void) { uint16_t m, i; - ao_cmd_decimal(); + m = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - m = ao_cmd_lex_i; - ao_cmd_decimal(); + i = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - i = ao_cmd_lex_i; _ao_config_edit_start(); ao_config.tracker_motion = m; ao_config.tracker_interval = i; @@ -863,11 +862,11 @@ ao_config_pyro_time_show(void) void ao_config_pyro_time_set(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; _ao_config_edit_start(); - ao_config.pyro_time = ao_cmd_lex_i; + ao_config.pyro_time = r; _ao_config_edit_finish(); } #endif @@ -883,26 +882,26 @@ ao_config_aprs_ssid_show(void) void ao_config_aprs_ssid_set(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - if (15 < ao_cmd_lex_i) { + if (15 < r) { ao_cmd_status = ao_cmd_lex_error; return; } _ao_config_edit_start(); - ao_config.aprs_ssid = ao_cmd_lex_i; + ao_config.aprs_ssid = r; _ao_config_edit_finish(); } void ao_config_aprs_format_set(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; _ao_config_edit_start(); - ao_config.aprs_format = ao_cmd_lex_i != 0; + ao_config.aprs_format = r != 0; _ao_config_edit_finish(); } @@ -923,11 +922,11 @@ ao_config_pad_box_show(void) void ao_config_pad_box_set(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; _ao_config_edit_start(); - ao_config.pad_box = ao_cmd_lex_i; + ao_config.pad_box = r; _ao_config_edit_finish(); } @@ -940,11 +939,11 @@ ao_config_pad_idle_show(void) void ao_config_pad_idle_set(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; _ao_config_edit_start(); - ao_config.pad_idle = ao_cmd_lex_i; + ao_config.pad_idle = r; _ao_config_edit_finish(); } #endif diff --git a/src/kernel/ao_fake_flight.c b/src/kernel/ao_fake_flight.c index 5880cf2b..8da0141c 100644 --- a/src/kernel/ao_fake_flight.c +++ b/src/kernel/ao_fake_flight.c @@ -133,14 +133,12 @@ ao_fake_flight(void) enum ao_flight_state my_state = ao_flight_invalid; int i; - ao_cmd_hex(); + calib_size = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) return; - calib_size = ao_cmd_lex_i; - ao_cmd_hex(); + data_size = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) return; - data_size = ao_cmd_lex_i; if ((unsigned) calib_size != sizeof (struct ao_fake_calib)) { printf ("calib size %d larger than actual size %d\n", calib_size, sizeof (struct ao_fake_calib)); diff --git a/src/kernel/ao_log.c b/src/kernel/ao_log.c index 1119cce4..fac211cf 100644 --- a/src/kernel/ao_log.c +++ b/src/kernel/ao_log.c @@ -437,10 +437,9 @@ ao_log_delete(void) cmd_flight = -1; ao_cmd_lex(); } - ao_cmd_decimal(); + cmd_flight *= ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - cmd_flight *= (int16_t) ao_cmd_lex_i; slots = ao_log_slots(); /* Look for the flight log matching the requested flight */ diff --git a/src/kernel/ao_log_single.c b/src/kernel/ao_log_single.c index da627387..a2b63c8d 100644 --- a/src/kernel/ao_log_single.c +++ b/src/kernel/ao_log_single.c @@ -118,10 +118,11 @@ ao_log_single_restart(void) void ao_log_single_set(void) { + uint16_t r; printf("Logging currently %s\n", ao_log_running ? "on" : "off"); - ao_cmd_hex(); + r = ao_cmd_hex(); if (ao_cmd_status == ao_cmd_success) { - if (ao_cmd_lex_i) { + if (r) { printf("Logging from %ld to %ld\n", ao_log_current_pos, ao_log_end_pos); ao_log_single_start(); } else { @@ -136,13 +137,12 @@ void ao_log_single_delete(void) { uint32_t pos; - - ao_cmd_hex(); + uint16_t r = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) return; - if (ao_cmd_lex_i != 1) { + if (r != 1) { ao_cmd_status = ao_cmd_syntax_error; - printf("No such flight: %d\n", ao_cmd_lex_i); + printf("No such flight: %d\n", r); return; } ao_log_single_stop(); @@ -153,7 +153,7 @@ ao_log_single_delete(void) } ao_log_current_pos = ao_log_start_pos = 0; if (pos == 0) - printf("No such flight: %d\n", ao_cmd_lex_i); + printf("No such flight: %d\n", r); else printf ("Erased\n"); } diff --git a/src/kernel/ao_monitor.c b/src/kernel/ao_monitor.c index b6b8d888..3f1ff217 100644 --- a/src/kernel/ao_monitor.c +++ b/src/kernel/ao_monitor.c @@ -296,8 +296,7 @@ ao_monitor_enable(void) static void set_monitor(void) { - ao_cmd_hex(); - ao_external_monitoring = ao_cmd_lex_i; + ao_external_monitoring = ao_cmd_hex(); ao_wakeup(&ao_external_monitoring); ao_wakeup(&ao_monitor_head); _ao_monitor_adjust(); diff --git a/src/kernel/ao_pyro.c b/src/kernel/ao_pyro.c index e24ab46b..173cf8a3 100644 --- a/src/kernel/ao_pyro.c +++ b/src/kernel/ao_pyro.c @@ -484,10 +484,9 @@ ao_pyro_set(void) } #endif - ao_cmd_decimal(); + p = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - p = ao_cmd_lex_i; if (AO_PYRO_NUM <= p) { printf ("invalid pyro channel %d\n", p); return; @@ -516,25 +515,23 @@ ao_pyro_set(void) } pyro_tmp.flags |= ao_pyro_values[v].flag; if (ao_pyro_values[v].offset != NO_VALUE) { - uint8_t negative = 0; + int16_t r = 1; ao_cmd_white(); if (ao_cmd_lex_c == '-') { - negative = 1; + r = -1; ao_cmd_lex(); } - ao_cmd_decimal(); + r *= ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; if (ao_pyro_values[v].flag & AO_PYRO_8_BIT_VALUE) { - if (negative) { + if (r < 0) { ao_cmd_status = ao_cmd_syntax_error; return; } - *((uint8_t *) ((char *) &pyro_tmp + ao_pyro_values[v].offset)) = ao_cmd_lex_i; + *((uint8_t *) ((char *) &pyro_tmp + ao_pyro_values[v].offset)) = r; } else { - if (negative) - ao_cmd_lex_i = -ao_cmd_lex_i; - *((int16_t *) (void *) ((char *) &pyro_tmp + ao_pyro_values[v].offset)) = ao_cmd_lex_i; + *((int16_t *) (void *) ((char *) &pyro_tmp + ao_pyro_values[v].offset)) = r; } } } diff --git a/src/kernel/ao_radio_cmac_cmd.c b/src/kernel/ao_radio_cmac_cmd.c index e5b4ffdf..1433e96d 100644 --- a/src/kernel/ao_radio_cmac_cmd.c +++ b/src/kernel/ao_radio_cmac_cmd.c @@ -50,16 +50,14 @@ radio_cmac_send_cmd(void) uint8_t i; uint8_t len; - ao_cmd_decimal(); + len = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - len = ao_cmd_lex_i; if (len > AO_CMAC_MAX_LEN) { ao_cmd_status = ao_cmd_syntax_error; return; } flush(); - len = ao_cmd_lex_i; for (i = 0; i < len; i++) { cmac_data[i] = getbyte(); if (ao_cmd_status != ao_cmd_success) @@ -74,14 +72,12 @@ radio_cmac_recv_cmd(void) uint8_t len, i; uint16_t timeout; - ao_cmd_decimal(); + len = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - len = ao_cmd_lex_i; - ao_cmd_decimal(); + timeout = AO_MS_TO_TICKS(ao_cmd_decimal()); if (ao_cmd_status != ao_cmd_success) return; - timeout = AO_MS_TO_TICKS(ao_cmd_lex_i); i = ao_radio_cmac_recv(cmac_data, len, timeout); if (i == AO_RADIO_CMAC_OK) { printf ("PACKET "); diff --git a/src/kernel/ao_send_packet.c b/src/kernel/ao_send_packet.c index 3206b2d6..cae25151 100644 --- a/src/kernel/ao_send_packet.c +++ b/src/kernel/ao_send_packet.c @@ -29,8 +29,7 @@ ao_send_packet(void) uint8_t b; uint8_t i; - ao_cmd_hex(); - count = ao_cmd_lex_i; + count = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) return; if (count > AO_MAX_SEND - 2) { diff --git a/src/kernel/ao_storage.c b/src/kernel/ao_storage.c index 5292e120..890bdcae 100644 --- a/src/kernel/ao_storage.c +++ b/src/kernel/ao_storage.c @@ -92,15 +92,16 @@ static uint8_t storage_data[128]; static void ao_storage_dump(void) { + uint32_t block; uint8_t i, j; - ao_cmd_hex(); + block = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) return; for (i = 0; ; i += 8) { - if (ao_storage_read(((uint32_t) (ao_cmd_lex_i) << 8) + i, - storage_data, - 8)) { + if (ao_storage_read((block << 8) + i, + storage_data, + 8)) { ao_cmd_put16((uint16_t) i); for (j = 0; j < 8; j++) { putchar(' '); @@ -123,23 +124,19 @@ ao_storage_store(void) uint16_t block; uint8_t i; uint16_t len; - static uint8_t b; + uint8_t b; uint32_t addr; - ao_cmd_hex(); - block = ao_cmd_lex_i; - ao_cmd_hex(); - i = ao_cmd_lex_i; + block = ao_cmd_hex(); + i = ao_cmd_hex(); addr = ((uint32_t) block << 8) | i; - ao_cmd_hex(); - len = ao_cmd_lex_i; + len = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) return; while (len--) { - ao_cmd_hex(); + b = ao_cmd_hexbyte(); if (ao_cmd_status != ao_cmd_success) return; - b = ao_cmd_lex_i; ao_storage_write(addr, &b, 1); addr++; } @@ -149,10 +146,10 @@ ao_storage_store(void) void ao_storage_zap(void) { - ao_cmd_hex(); + uint32_t v = ao_cmd_hex(); if (ao_cmd_status != ao_cmd_success) return; - ao_storage_erase((uint32_t) ao_cmd_lex_i << 8); + ao_storage_erase((uint32_t) v << 8); } void diff --git a/src/kernel/ao_tracker.c b/src/kernel/ao_tracker.c index 46278530..f79bd18a 100644 --- a/src/kernel/ao_tracker.c +++ b/src/kernel/ao_tracker.c @@ -211,9 +211,9 @@ static struct ao_task ao_tracker_task; static void ao_tracker_set_telem(void) { - ao_cmd_hex(); + uint16_t r = ao_cmd_hex(); if (ao_cmd_status == ao_cmd_success) - ao_tracker_force_telem = ao_cmd_lex_i; + ao_tracker_force_telem = r; ao_cmd_status = ao_cmd_success; printf ("flight: %d\n", ao_flight_number); printf ("force_telem: %d\n", ao_tracker_force_telem); diff --git a/src/stm-vga/ao_demo.c b/src/stm-vga/ao_demo.c index 63740f8e..593a8743 100644 --- a/src/stm-vga/ao_demo.c +++ b/src/stm-vga/ao_demo.c @@ -159,17 +159,16 @@ ao_fb_init(void) static void ao_video_toggle(void) { - ao_cmd_decimal(); - if (ao_cmd_lex_i) + uint16_t r = ao_cmd_decimal(); + if (r) ao_fb_init(); - ao_vga_enable(ao_cmd_lex_i); + ao_vga_enable(r); } static void ao_ball_toggle(void) { - ao_cmd_decimal(); - ball_enable = ao_cmd_lex_i; + ball_enable = ao_cmd_decimal(); ao_wakeup(&ball_enable); } diff --git a/src/stm/ao_lcd_stm.c b/src/stm/ao_lcd_stm.c index 10d5d620..1947012b 100644 --- a/src/stm/ao_lcd_stm.c +++ b/src/stm/ao_lcd_stm.c @@ -326,12 +326,9 @@ ao_lcd_stm_seg_set(void) { int com, seg, val; int n, bit; - ao_cmd_decimal(); - com = ao_cmd_lex_i; - ao_cmd_decimal(); - seg = ao_cmd_lex_u32; - ao_cmd_decimal(); - val = ao_cmd_lex_i; + com = ao_cmd_decimal(); + seg = ao_cmd_decimal(); + val = ao_cmd_decimal(); printf ("com: %d seg: %d val: %d\n", com, seg, val); ao_lcd_set(com, seg, val); ao_lcd_flush(); diff --git a/src/stm/ao_pwm_stm.c b/src/stm/ao_pwm_stm.c index 53000a17..341f8887 100644 --- a/src/stm/ao_pwm_stm.c +++ b/src/stm/ao_pwm_stm.c @@ -107,10 +107,8 @@ ao_pwm_cmd(void) uint8_t ch; uint16_t val; - ao_cmd_decimal(); - ch = ao_cmd_lex_u32; - ao_cmd_decimal(); - val = ao_cmd_lex_u32; + ch = ao_cmd_decimal(); + val = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; diff --git a/src/stmf0/ao_adc_stm.c b/src/stmf0/ao_adc_stm.c index 571830bb..e62bb16e 100644 --- a/src/stmf0/ao_adc_stm.c +++ b/src/stmf0/ao_adc_stm.c @@ -103,10 +103,9 @@ ao_adc_one(void) int ch; uint16_t value; - ao_cmd_decimal(); + ch = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - ch = ao_cmd_lex_i; if (ch < 0 || AO_NUM_ADC <= ch) { ao_cmd_status = ao_cmd_syntax_error; return; diff --git a/src/telefireone-v1.0/ao_telefireone.c b/src/telefireone-v1.0/ao_telefireone.c index 790d7a41..6506235a 100644 --- a/src/telefireone-v1.0/ao_telefireone.c +++ b/src/telefireone-v1.0/ao_telefireone.c @@ -26,8 +26,7 @@ static void set_logging(void) { - ao_cmd_hex(); - ao_log_running = ao_cmd_lex_i; + ao_log_running = ao_cmd_hex(); ao_wakeup(&ao_log_running); } diff --git a/src/telelco-v2.0/ao_lco_v2.c b/src/telelco-v2.0/ao_lco_v2.c index 428b1a7c..90324cc8 100644 --- a/src/telelco-v2.0/ao_lco_v2.c +++ b/src/telelco-v2.0/ao_lco_v2.c @@ -282,9 +282,9 @@ ao_lco_main(void) void ao_lco_set_debug(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status == ao_cmd_success) - ao_lco_debug = ao_cmd_lex_i != 0; + ao_lco_debug = r != 0; } const struct ao_cmds ao_lco_cmds[] = { diff --git a/src/usbrelay-v0.1/ao_usbrelay.c b/src/usbrelay-v0.1/ao_usbrelay.c index 0eacdf5a..946f4b12 100644 --- a/src/usbrelay-v0.1/ao_usbrelay.c +++ b/src/usbrelay-v0.1/ao_usbrelay.c @@ -49,10 +49,9 @@ ao_relay_select(void) { uint8_t output; - ao_cmd_decimal(); + output = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - output = ao_cmd_lex_i; if (output > 1) printf ("Invalid relay position %u\n", output); else diff --git a/src/vidtime/ao_vidtime.c b/src/vidtime/ao_vidtime.c index 1b9b9e1c..e9f8b218 100644 --- a/src/vidtime/ao_vidtime.c +++ b/src/vidtime/ao_vidtime.c @@ -63,9 +63,9 @@ ao_init_vidtime(void) static void ao_set_vidtime(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status == ao_cmd_success) { - vidtime_monitor = ao_cmd_lex_i != 0; + vidtime_monitor = r != 0; ao_wakeup(&vidtime_monitor); } } -- cgit v1.2.3 From 684741765117611b7d666efbdfafd87c6199752c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 15 Aug 2018 19:17:19 -0700 Subject: altos: Use stdbool true/false instead of TRUE/FALSE Signed-off-by: Keith Packard --- src/draw/ao_line.c | 16 ++++++++-------- src/drivers/ao_fat.c | 2 +- src/drivers/ao_hmc5883.c | 8 ++++---- src/drivers/ao_lco.h | 2 +- src/drivers/ao_mpu6000.c | 10 +++++----- src/drivers/ao_mpu9250.c | 10 +++++----- src/drivers/ao_packet_slave.c | 2 +- src/drivers/ao_trng_send.c | 4 ++-- src/drivers/ao_watchdog.c | 2 +- src/kernel/ao.h | 4 +--- src/kernel/ao_fake_flight.c | 8 ++++---- src/kernel/ao_power.c | 4 ++-- src/kernel/ao_pyro.c | 4 ++-- src/kernel/ao_sample.c | 4 ++-- src/kernel/ao_sample.h | 2 +- src/product/ao_telemetrum.c | 2 +- src/product/ao_telemini.c | 2 +- src/product/ao_telenano.c | 2 +- src/product/ao_teleterra.c | 2 +- src/stm-demo/ao_demo.c | 2 +- src/stm/ao_i2c_stm.c | 6 +++--- src/teleballoon-v2.0/ao_teleballoon.c | 2 +- src/telemega-v0.1/ao_telemega.c | 2 +- src/telemega-v1.0/ao_telemega.c | 2 +- src/telemega-v2.0/ao_telemega.c | 2 +- src/telemega-v3.0/ao_telemega.c | 2 +- src/telemetrum-v2.0/ao_telemetrum.c | 2 +- src/telemetrum-v3.0/ao_telemetrum.c | 2 +- src/telemini-v3.0/ao_telemini.c | 2 +- src/test/ao_flight_test.c | 4 ++-- 30 files changed, 58 insertions(+), 60 deletions(-) (limited to 'src/kernel') diff --git a/src/draw/ao_line.c b/src/draw/ao_line.c index ed1fc21c..742b3aa3 100644 --- a/src/draw/ao_line.c +++ b/src/draw/ao_line.c @@ -159,28 +159,28 @@ ao_clip_line(struct ao_cc *c, struct ao_cbox *b) /* Clip major axis */ if (c->major < b->maj1) { if (c->sign_major <= 0) - return FALSE; + return false; adjust_major = b->maj1 - c->major; } else if (c->major >= b->maj2) { if (c->sign_major >= 0) - return FALSE; + return false; adjust_major = c->major - (b->maj2-1); } /* Clip minor axis */ if (c->minor < b->min1) { if (c->sign_minor <= 0) - return FALSE; + return false; adjust_minor = b->min1 - c->minor; } else if (c->minor >= b->min2) { if (c->sign_minor >= 0) - return FALSE; + return false; adjust_minor = c->minor - (b->min2-1); } /* If unclipped, we're done */ if (adjust_major == 0 && adjust_minor == 0) - return TRUE; + return true; /* See how much minor adjustment would happen during * a major clip. This is a bit tricky because line drawing @@ -208,7 +208,7 @@ ao_clip_line(struct ao_cc *c, struct ao_cbox *b) c->major += c->sign_major * adjust_major; c->minor += c->sign_minor * adjust_minor; - return TRUE; + return true; } void @@ -276,8 +276,8 @@ ao_line(const struct ao_bitmap *dst, e3 = e2 - e1; e = e - e1; - clip_1.first = TRUE; - clip_2.first = FALSE; + clip_1.first = true; + clip_2.first = false; clip_2.e = clip_1.e = e; clip_2.e1 = clip_1.e1 = e1; clip_2.e3 = clip_1.e3 = e3; diff --git a/src/drivers/ao_fat.c b/src/drivers/ao_fat.c index 43e7df23..e9ff2789 100644 --- a/src/drivers/ao_fat.c +++ b/src/drivers/ao_fat.c @@ -990,7 +990,7 @@ ao_fat_sync(void) /* * ao_fat_full * - * Returns TRUE if the filesystem cannot take + * Returns true if the filesystem cannot take * more data */ diff --git a/src/drivers/ao_hmc5883.c b/src/drivers/ao_hmc5883.c index c33aa536..f4705708 100644 --- a/src/drivers/ao_hmc5883.c +++ b/src/drivers/ao_hmc5883.c @@ -35,7 +35,7 @@ ao_hmc5883_reg_write(uint8_t addr, uint8_t data) d[1] = data; ao_i2c_get(AO_HMC5883_I2C_INDEX); ao_i2c_start(AO_HMC5883_I2C_INDEX, HMC5883_ADDR_WRITE); - ao_i2c_send(d, 2, AO_HMC5883_I2C_INDEX, TRUE); + ao_i2c_send(d, 2, AO_HMC5883_I2C_INDEX, true); ao_i2c_put(AO_HMC5883_I2C_INDEX); ao_hmc5883_addr = addr + 1; } @@ -46,10 +46,10 @@ ao_hmc5883_read(uint8_t addr, uint8_t *data, uint8_t len) ao_i2c_get(AO_HMC5883_I2C_INDEX); if (addr != ao_hmc5883_addr) { ao_i2c_start(AO_HMC5883_I2C_INDEX, HMC5883_ADDR_WRITE); - ao_i2c_send(&addr, 1, AO_HMC5883_I2C_INDEX, FALSE); + ao_i2c_send(&addr, 1, AO_HMC5883_I2C_INDEX, false); } ao_i2c_start(AO_HMC5883_I2C_INDEX, HMC5883_ADDR_READ); - ao_i2c_recv(data, len, AO_HMC5883_I2C_INDEX, TRUE); + ao_i2c_recv(data, len, AO_HMC5883_I2C_INDEX, true); ao_i2c_put(AO_HMC5883_I2C_INDEX); ao_hmc5883_addr = 0xff; } @@ -103,7 +103,7 @@ ao_hmc5883_setup(void) ao_i2c_get(AO_HMC5883_I2C_INDEX); present = ao_i2c_start(AO_HMC5883_I2C_INDEX, HMC5883_ADDR_READ); - ao_i2c_recv(&d, 1, AO_HMC5883_I2C_INDEX, TRUE); + ao_i2c_recv(&d, 1, AO_HMC5883_I2C_INDEX, true); ao_i2c_put(AO_HMC5883_I2C_INDEX); if (!present) diff --git a/src/drivers/ao_lco.h b/src/drivers/ao_lco.h index 2958fbcc..cdc19d3d 100644 --- a/src/drivers/ao_lco.h +++ b/src/drivers/ao_lco.h @@ -35,7 +35,7 @@ extern uint8_t ao_lco_debug; #endif #if AO_LCO_DRAG -extern uint8_t ao_lco_drag_race; /* TRUE when drag race mode enabled */ +extern uint8_t ao_lco_drag_race; /* true when drag race mode enabled */ #endif extern uint8_t ao_lco_pad; /* Currently selected pad */ diff --git a/src/drivers/ao_mpu6000.c b/src/drivers/ao_mpu6000.c index 81d3c16c..8c85ab01 100644 --- a/src/drivers/ao_mpu6000.c +++ b/src/drivers/ao_mpu6000.c @@ -55,7 +55,7 @@ _ao_mpu6000_reg_write(uint8_t addr, uint8_t value) #else ao_i2c_get(AO_MPU6000_I2C_INDEX); ao_i2c_start(AO_MPU6000_I2C_INDEX, MPU6000_ADDR_WRITE); - ao_i2c_send(d, 2, AO_MPU6000_I2C_INDEX, TRUE); + ao_i2c_send(d, 2, AO_MPU6000_I2C_INDEX, true); ao_i2c_put(AO_MPU6000_I2C_INDEX); #endif } @@ -72,9 +72,9 @@ _ao_mpu6000_read(uint8_t addr, void *data, uint8_t len) #else ao_i2c_get(AO_MPU6000_I2C_INDEX); ao_i2c_start(AO_MPU6000_I2C_INDEX, MPU6000_ADDR_WRITE); - ao_i2c_send(&addr, 1, AO_MPU6000_I2C_INDEX, FALSE); + ao_i2c_send(&addr, 1, AO_MPU6000_I2C_INDEX, false); ao_i2c_start(AO_MPU6000_I2C_INDEX, MPU6000_ADDR_READ); - ao_i2c_recv(data, len, AO_MPU6000_I2C_INDEX, TRUE); + ao_i2c_recv(data, len, AO_MPU6000_I2C_INDEX, true); ao_i2c_put(AO_MPU6000_I2C_INDEX); #endif } @@ -92,9 +92,9 @@ _ao_mpu6000_reg_read(uint8_t addr) #else ao_i2c_get(AO_MPU6000_I2C_INDEX); ao_i2c_start(AO_MPU6000_I2C_INDEX, MPU6000_ADDR_WRITE); - ao_i2c_send(&addr, 1, AO_MPU6000_I2C_INDEX, FALSE); + ao_i2c_send(&addr, 1, AO_MPU6000_I2C_INDEX, false); ao_i2c_start(AO_MPU6000_I2C_INDEX, MPU6000_ADDR_READ); - ao_i2c_recv(&value, 1, AO_MPU6000_I2C_INDEX, TRUE); + ao_i2c_recv(&value, 1, AO_MPU6000_I2C_INDEX, true); ao_i2c_put(AO_MPU6000_I2C_INDEX); #endif return value; diff --git a/src/drivers/ao_mpu9250.c b/src/drivers/ao_mpu9250.c index 9dce9f1a..74e444a9 100644 --- a/src/drivers/ao_mpu9250.c +++ b/src/drivers/ao_mpu9250.c @@ -63,7 +63,7 @@ _ao_mpu9250_reg_write(uint8_t addr, uint8_t value) #else ao_i2c_get(AO_MPU9250_I2C_INDEX); ao_i2c_start(AO_MPU9250_I2C_INDEX, MPU9250_ADDR_WRITE); - ao_i2c_send(d, 2, AO_MPU9250_I2C_INDEX, TRUE); + ao_i2c_send(d, 2, AO_MPU9250_I2C_INDEX, true); ao_i2c_put(AO_MPU9250_I2C_INDEX); #endif } @@ -80,9 +80,9 @@ _ao_mpu9250_read(uint8_t addr, void *data, uint8_t len) #else ao_i2c_get(AO_MPU9250_I2C_INDEX); ao_i2c_start(AO_MPU9250_I2C_INDEX, MPU9250_ADDR_WRITE); - ao_i2c_send(&addr, 1, AO_MPU9250_I2C_INDEX, FALSE); + ao_i2c_send(&addr, 1, AO_MPU9250_I2C_INDEX, false); ao_i2c_start(AO_MPU9250_I2C_INDEX, MPU9250_ADDR_READ); - ao_i2c_recv(data, len, AO_MPU9250_I2C_INDEX, TRUE); + ao_i2c_recv(data, len, AO_MPU9250_I2C_INDEX, true); ao_i2c_put(AO_MPU9250_I2C_INDEX); #endif } @@ -100,9 +100,9 @@ _ao_mpu9250_reg_read(uint8_t addr) #else ao_i2c_get(AO_MPU9250_I2C_INDEX); ao_i2c_start(AO_MPU9250_I2C_INDEX, MPU9250_ADDR_WRITE); - ao_i2c_send(&addr, 1, AO_MPU9250_I2C_INDEX, FALSE); + ao_i2c_send(&addr, 1, AO_MPU9250_I2C_INDEX, false); ao_i2c_start(AO_MPU9250_I2C_INDEX, MPU9250_ADDR_READ); - ao_i2c_recv(&value, 1, AO_MPU9250_I2C_INDEX, TRUE); + ao_i2c_recv(&value, 1, AO_MPU9250_I2C_INDEX, true); ao_i2c_put(AO_MPU9250_I2C_INDEX); #endif return value; diff --git a/src/drivers/ao_packet_slave.c b/src/drivers/ao_packet_slave.c index b877128a..3ae1138c 100644 --- a/src/drivers/ao_packet_slave.c +++ b/src/drivers/ao_packet_slave.c @@ -28,7 +28,7 @@ ao_packet_slave(void) if (ao_packet_recv(0)) { ao_xmemcpy(&ao_tx_packet.callsign, &ao_rx_packet.packet.callsign, AO_MAX_CALLSIGN); #if HAS_FLIGHT - ao_flight_force_idle = TRUE; + ao_flight_force_idle = true; #endif ao_packet_send(); } diff --git a/src/drivers/ao_trng_send.c b/src/drivers/ao_trng_send.c index 4e02c0ce..e8df4cea 100644 --- a/src/drivers/ao_trng_send.c +++ b/src/drivers/ao_trng_send.c @@ -48,7 +48,7 @@ ao_trng_start(void) * aren't of poor quality */ ao_delay(delay); - trng_running = TRUE; + trng_running = true; } ao_mutex_put(&random_mutex); } @@ -213,7 +213,7 @@ static void ao_trng_suspend(void *arg) #ifdef AO_TRNG_ENABLE_PORT ao_gpio_set(AO_TRNG_ENABLE_PORT, AO_TRNG_ENABLE_BIT, AO_TRNG_ENABLE_PIN, 0); #endif - trng_running = FALSE; + trng_running = false; } static void ao_trng_resume(void *arg) diff --git a/src/drivers/ao_watchdog.c b/src/drivers/ao_watchdog.c index c0582c12..4d774c3a 100644 --- a/src/drivers/ao_watchdog.c +++ b/src/drivers/ao_watchdog.c @@ -18,7 +18,7 @@ #include -static int ao_watchdog_enabled = TRUE; +static int ao_watchdog_enabled = true; static void ao_watchdog(void) diff --git a/src/kernel/ao.h b/src/kernel/ao.h index 3beeb880..cdcdadc3 100644 --- a/src/kernel/ao.h +++ b/src/kernel/ao.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -35,9 +36,6 @@ extern int ao_putchar(char c); extern char ao_getchar(void); -#define TRUE 1 -#define FALSE 0 - #ifndef HAS_TASK #define HAS_TASK 1 #endif diff --git a/src/kernel/ao_fake_flight.c b/src/kernel/ao_fake_flight.c index 8da0141c..ec8691e9 100644 --- a/src/kernel/ao_fake_flight.c +++ b/src/kernel/ao_fake_flight.c @@ -54,7 +54,7 @@ ao_fake_data_read(void) uint8_t *d = (void *) &ao_fake_next; if (getchar() == 0) - return FALSE; + return false; for (i = 0; i < sizeof (struct ao_data); i++) *d++ = getchar(); if (!ao_fake_has_offset) { @@ -64,7 +64,7 @@ ao_fake_data_read(void) } else ao_fake_next.tick += ao_fake_tick_offset; ao_fake_has_next = 1; - return TRUE; + return true; } static void @@ -118,10 +118,10 @@ ao_fake_calib_read(void) ) { printf ("Calibration data major version mismatch %d.%d <= %d.%d\n", ao_calib.major, ao_calib.minor, AO_FAKE_CALIB_MAJOR, AO_FAKE_CALIB_MINOR); - return FALSE; + return false; } ao_fake_calib_set(&ao_calib); - return TRUE; + return true; } static void diff --git a/src/kernel/ao_power.c b/src/kernel/ao_power.c index bf59ab53..8c490604 100644 --- a/src/kernel/ao_power.c +++ b/src/kernel/ao_power.c @@ -26,7 +26,7 @@ ao_power_register(struct ao_power *power) { if (power->registered) return; - power->registered = TRUE; + power->registered = true; if (tail) { tail->next = power; power->prev = tail; @@ -44,7 +44,7 @@ ao_power_unregister(struct ao_power *power) { if (!power->registered) return; - power->registered = FALSE; + power->registered = false; if (power->prev) power->prev->next = power->next; else diff --git a/src/kernel/ao_pyro.c b/src/kernel/ao_pyro.c index 173cf8a3..c01c9512 100644 --- a/src/kernel/ao_pyro.c +++ b/src/kernel/ao_pyro.c @@ -205,9 +205,9 @@ ao_pyro_ready(struct ao_pyro *pyro) default: continue; } - return FALSE; + return false; } - return TRUE; + return true; } #ifndef AO_FLIGHT_TEST diff --git a/src/kernel/ao_sample.c b/src/kernel/ao_sample.c index 115eae80..9cba36c1 100644 --- a/src/kernel/ao_sample.c +++ b/src/kernel/ao_sample.c @@ -277,7 +277,7 @@ ao_sample_preflight(void) ao_accel_scale = to_fix_32(GRAVITY * 2 * 16) / ao_accel_2g; #endif ao_sample_preflight_set(); - ao_preflight = FALSE; + ao_preflight = false; } } @@ -398,5 +398,5 @@ ao_sample_init(void) ao_sample_set_all_orients(); #endif ao_sample_data = ao_data_head; - ao_preflight = TRUE; + ao_preflight = true; } diff --git a/src/kernel/ao_sample.h b/src/kernel/ao_sample.h index af6eca4e..4c51a58c 100644 --- a/src/kernel/ao_sample.h +++ b/src/kernel/ao_sample.h @@ -154,7 +154,7 @@ extern uint8_t ao_sample_orient_pos; void ao_sample_init(void); -/* returns FALSE in preflight mode, TRUE in flight mode */ +/* returns false in preflight mode, true in flight mode */ uint8_t ao_sample(void); /* diff --git a/src/product/ao_telemetrum.c b/src/product/ao_telemetrum.c index a10cb384..1266fee7 100644 --- a/src/product/ao_telemetrum.c +++ b/src/product/ao_telemetrum.c @@ -60,7 +60,7 @@ main(void) ao_gps_report_init(); ao_telemetry_init(); ao_radio_init(); - ao_packet_slave_init(FALSE); + ao_packet_slave_init(false); ao_igniter_init(); #if HAS_DBG ao_dbg_init(); diff --git a/src/product/ao_telemini.c b/src/product/ao_telemini.c index 14414a48..d9cb676b 100644 --- a/src/product/ao_telemini.c +++ b/src/product/ao_telemini.c @@ -56,7 +56,7 @@ main(void) ao_report_init(); ao_telemetry_init(); ao_radio_init(); - ao_packet_slave_init(TRUE); + ao_packet_slave_init(true); ao_igniter_init(); ao_config_init(); ao_start_scheduler(); diff --git a/src/product/ao_telenano.c b/src/product/ao_telenano.c index ac08979f..1b04edc5 100644 --- a/src/product/ao_telenano.c +++ b/src/product/ao_telenano.c @@ -40,7 +40,7 @@ main(void) ao_report_init(); ao_telemetry_init(); ao_radio_init(); - ao_packet_slave_init(TRUE); + ao_packet_slave_init(true); ao_config_init(); ao_start_scheduler(); } diff --git a/src/product/ao_teleterra.c b/src/product/ao_teleterra.c index 0142f9e3..ae129233 100644 --- a/src/product/ao_teleterra.c +++ b/src/product/ao_teleterra.c @@ -34,7 +34,7 @@ main(void) ao_cmd_init(); ao_usb_init(); ao_serial_init(); - ao_monitor_init(AO_LED_GREEN, TRUE); + ao_monitor_init(AO_LED_GREEN, true); ao_radio_init(); ao_config_init(); ao_start_scheduler(); diff --git a/src/stm-demo/ao_demo.c b/src/stm-demo/ao_demo.c index b0d03840..4b963e42 100644 --- a/src/stm-demo/ao_demo.c +++ b/src/stm-demo/ao_demo.c @@ -125,7 +125,7 @@ ao_i2c_write(void) { for (i = 0; i < 10; i++) { ao_i2c_get(0); if (ao_i2c_start(0, 0x55)) - ao_i2c_send(data, 4, 0, TRUE); + ao_i2c_send(data, 4, 0, true); else { printf ("i2c start failed\n"); ao_i2c_put(0); diff --git a/src/stm/ao_i2c_stm.c b/src/stm/ao_i2c_stm.c index 59cad495..23805aa8 100644 --- a/src/stm/ao_i2c_stm.c +++ b/src/stm/ao_i2c_stm.c @@ -275,7 +275,7 @@ ao_i2c_send(void *block, uint16_t len, uint8_t index, uint8_t stop) stm_i2c->cr1 = AO_STM_I2C_CR1 | (1 << STM_I2C_CR1_STOP); ao_i2c_wait_stop(index); } - return TRUE; + return true; } void @@ -300,10 +300,10 @@ uint8_t ao_i2c_recv(void *block, uint16_t len, uint8_t index, uint8_t stop) { struct stm_i2c *stm_i2c = ao_i2c_stm_info[index].stm_i2c; - uint8_t ret = TRUE; + uint8_t ret = true; if (len == 0) - return TRUE; + return true; if (len == 1) { ao_i2c_recv_data[index] = block; ao_i2c_recv_len[index] = 1; diff --git a/src/teleballoon-v2.0/ao_teleballoon.c b/src/teleballoon-v2.0/ao_teleballoon.c index 2432c272..acb11f44 100644 --- a/src/teleballoon-v2.0/ao_teleballoon.c +++ b/src/teleballoon-v2.0/ao_teleballoon.c @@ -77,7 +77,7 @@ main(void) ao_gps_report_metrum_init(); ao_telemetry_init(); ao_radio_init(); - ao_packet_slave_init(FALSE); + ao_packet_slave_init(false); ao_companion_init(); ao_config_init(); diff --git a/src/telemega-v0.1/ao_telemega.c b/src/telemega-v0.1/ao_telemega.c index 3cfc9b44..f8b7ecfa 100644 --- a/src/telemega-v0.1/ao_telemega.c +++ b/src/telemega-v0.1/ao_telemega.c @@ -85,7 +85,7 @@ main(void) ao_gps_report_mega_init(); ao_telemetry_init(); ao_radio_init(); - ao_packet_slave_init(FALSE); + ao_packet_slave_init(false); ao_igniter_init(); ao_companion_init(); ao_pyro_init(); diff --git a/src/telemega-v1.0/ao_telemega.c b/src/telemega-v1.0/ao_telemega.c index 2deb852e..50428b61 100644 --- a/src/telemega-v1.0/ao_telemega.c +++ b/src/telemega-v1.0/ao_telemega.c @@ -85,7 +85,7 @@ main(void) ao_gps_report_mega_init(); ao_telemetry_init(); ao_radio_init(); - ao_packet_slave_init(FALSE); + ao_packet_slave_init(false); ao_igniter_init(); ao_companion_init(); ao_pyro_init(); diff --git a/src/telemega-v2.0/ao_telemega.c b/src/telemega-v2.0/ao_telemega.c index 7a1c46ae..6a58547e 100644 --- a/src/telemega-v2.0/ao_telemega.c +++ b/src/telemega-v2.0/ao_telemega.c @@ -86,7 +86,7 @@ main(void) ao_gps_report_mega_init(); ao_telemetry_init(); ao_radio_init(); - ao_packet_slave_init(FALSE); + ao_packet_slave_init(false); ao_igniter_init(); ao_companion_init(); ao_pyro_init(); diff --git a/src/telemega-v3.0/ao_telemega.c b/src/telemega-v3.0/ao_telemega.c index 2259c751..2577f90c 100644 --- a/src/telemega-v3.0/ao_telemega.c +++ b/src/telemega-v3.0/ao_telemega.c @@ -82,7 +82,7 @@ main(void) ao_gps_report_mega_init(); ao_telemetry_init(); ao_radio_init(); - ao_packet_slave_init(FALSE); + ao_packet_slave_init(false); ao_igniter_init(); ao_companion_init(); ao_pyro_init(); diff --git a/src/telemetrum-v2.0/ao_telemetrum.c b/src/telemetrum-v2.0/ao_telemetrum.c index 5cf42a8d..65f9be2c 100644 --- a/src/telemetrum-v2.0/ao_telemetrum.c +++ b/src/telemetrum-v2.0/ao_telemetrum.c @@ -77,7 +77,7 @@ main(void) ao_gps_report_metrum_init(); ao_telemetry_init(); ao_radio_init(); - ao_packet_slave_init(FALSE); + ao_packet_slave_init(false); ao_igniter_init(); ao_companion_init(); diff --git a/src/telemetrum-v3.0/ao_telemetrum.c b/src/telemetrum-v3.0/ao_telemetrum.c index 6349d188..2bb5192a 100644 --- a/src/telemetrum-v3.0/ao_telemetrum.c +++ b/src/telemetrum-v3.0/ao_telemetrum.c @@ -77,7 +77,7 @@ main(void) ao_gps_report_metrum_init(); ao_telemetry_init(); ao_radio_init(); - ao_packet_slave_init(FALSE); + ao_packet_slave_init(false); ao_igniter_init(); ao_companion_init(); diff --git a/src/telemini-v3.0/ao_telemini.c b/src/telemini-v3.0/ao_telemini.c index a50268b9..a2c0a598 100644 --- a/src/telemini-v3.0/ao_telemini.c +++ b/src/telemini-v3.0/ao_telemini.c @@ -68,7 +68,7 @@ main(void) ao_report_init(); ao_telemetry_init(); ao_radio_init(); - ao_packet_slave_init(TRUE); + ao_packet_slave_init(true); ao_igniter_init(); ao_config_init(); diff --git a/src/test/ao_flight_test.c b/src/test/ao_flight_test.c index a171930e..6d007575 100644 --- a/src/test/ao_flight_test.c +++ b/src/test/ao_flight_test.c @@ -227,8 +227,8 @@ ao_gps_angle(void) extern enum ao_flight_state ao_flight_state; -#define FALSE 0 -#define TRUE 1 +#define false 0 +#define true 1 volatile struct ao_data ao_data_ring[AO_DATA_RING]; volatile uint8_t ao_data_head; -- cgit v1.2.3 From a76829a4a840261e33869c40b3366fff3b691069 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 15 Aug 2018 22:44:17 -0700 Subject: altos: Allow application-specific prompts for ao_cmd_readline Lets other readline users specify alternate prompts. Signed-off-by: Keith Packard --- src/kernel/ao.h | 2 +- src/kernel/ao_cmd.c | 27 +++++++++++---------------- 2 files changed, 12 insertions(+), 17 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/ao.h b/src/kernel/ao.h index cdcdadc3..08e90839 100644 --- a/src/kernel/ao.h +++ b/src/kernel/ao.h @@ -165,7 +165,7 @@ void ao_put_string(const char *s); void -ao_cmd_readline(void); +ao_cmd_readline(const char *prompt); char ao_cmd_lex(void); diff --git a/src/kernel/ao_cmd.c b/src/kernel/ao_cmd.c index a72192f4..d1c049ac 100644 --- a/src/kernel/ao_cmd.c +++ b/src/kernel/ao_cmd.c @@ -34,6 +34,8 @@ static char cmd_line[AO_CMD_LEN]; static uint8_t cmd_len; static uint8_t cmd_i; +static const char backspace[] = "\010 \010"; + void ao_put_string(const char *s) { @@ -42,18 +44,12 @@ ao_put_string(const char *s) putchar(c); } -static void -backspace(void) -{ - ao_put_string ("\010 \010"); -} - void -ao_cmd_readline(void) +ao_cmd_readline(const char *prompt) { char c; if (ao_echo()) - ao_put_string("> "); + ao_put_string(prompt); cmd_len = 0; for (;;) { flush(); @@ -62,7 +58,7 @@ ao_cmd_readline(void) if (c == '\010' || c == '\177') { if (cmd_len != 0) { if (ao_echo()) - backspace(); + ao_put_string(backspace); --cmd_len; } continue; @@ -72,7 +68,7 @@ ao_cmd_readline(void) if (c == '\025') { while (cmd_len != 0) { if (ao_echo()) - backspace(); + ao_put_string(backspace); --cmd_len; } continue; @@ -172,9 +168,8 @@ ao_cmd_hexchar(char c) return -1; } -static -uint32_t -_ao_cmd_hex(uint8_t lim) +static uint32_t +get_hex(uint8_t lim) { uint32_t result = 0; uint8_t i; @@ -196,13 +191,13 @@ _ao_cmd_hex(uint8_t lim) uint8_t ao_cmd_hexbyte(void) { - return _ao_cmd_hex(2); + return get_hex(2); } uint32_t ao_cmd_hex(void) { - return _ao_cmd_hex(0xff); + return get_hex(0xff); } uint32_t @@ -371,7 +366,7 @@ ao_cmd(void) void (*func)(void); for (;;) { - ao_cmd_readline(); + ao_cmd_readline("> "); ao_cmd_lex(); ao_cmd_white(); c = ao_cmd_lex_c; -- cgit v1.2.3 From b8e607960f2f399fd6ba92a8c97ab72e19812d3f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 11 Sep 2018 00:05:38 -0700 Subject: altos: Delete random 8051 ISR declarations Signed-off-by: Keith Packard --- src/kernel/ao.h | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/ao.h b/src/kernel/ao.h index 08e90839..9c0c8604 100644 --- a/src/kernel/ao.h +++ b/src/kernel/ao.h @@ -111,10 +111,6 @@ ao_delay(uint16_t ticks); void ao_timer_set_adc_interval(uint8_t interval); -/* Timer interrupt */ -void -ao_timer_isr(void) ao_arch_interrupt(9); - /* Initialize the timer */ void ao_timer_init(void); @@ -581,9 +577,6 @@ extern int8_t ao_radio_rssi; #define HAS_RADIO_RATE HAS_RADIO #endif -void -ao_radio_general_isr(void) ao_arch_interrupt(16); - #if HAS_RADIO_XMIT void ao_radio_send(const void *d, uint8_t size); @@ -944,9 +937,6 @@ ao_terraui_init(void); */ #ifdef BATTERY_PIN -void -ao_battery_isr(void) ao_arch_interrupt(1); - uint16_t ao_battery_get(void); -- cgit v1.2.3 From f037d0091a4b31c631d64e71441953eb9b3b21ce Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 2 Oct 2018 12:47:00 -0700 Subject: altos: Remove 8051-ism from ao_usb.h __at doesn't exist for non-8051 Signed-off-by: Keith Packard --- src/kernel/ao_usb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/kernel') diff --git a/src/kernel/ao_usb.h b/src/kernel/ao_usb.h index 7992c806..6c74a042 100644 --- a/src/kernel/ao_usb.h +++ b/src/kernel/ao_usb.h @@ -69,7 +69,7 @@ ao_usb_disable(void); void ao_usb_init(void); -extern const __at (0x00aa) uint8_t ao_usb_descriptors []; +extern const uint8_t ao_usb_descriptors []; #define AO_USB_SETUP_DIR_MASK (0x01 << 7) #define AO_USB_SETUP_TYPE_MASK (0x03 << 5) -- 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/kernel') 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/kernel') 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 23075d174d2bff8ff3f3deef3c3d90b83da6bd2e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 11 Sep 2018 18:46:52 -0700 Subject: altos/stm32f4: Align stack to 8 bytes This makes sure that doubles are aligned properly when passed on the stack. Signed-off-by: Keith Packard --- src/kernel/ao_task.h | 6 ++---- src/stm32f4/ao_arch.h | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/ao_task.h b/src/kernel/ao_task.h index f3789fa2..709e10c6 100644 --- a/src/kernel/ao_task.h +++ b/src/kernel/ao_task.h @@ -27,14 +27,12 @@ #endif /* arm stacks must be 32-bit aligned */ +#ifndef AO_STACK_ALIGNMENT #ifdef __arm__ #define AO_STACK_ALIGNMENT __attribute__ ((aligned(4))) -#endif -#ifdef SDCC +#else #define AO_STACK_ALIGNMENT #endif -#ifdef __AVR__ -#define AO_STACK_ALIGNMENT #endif /* An AltOS task */ diff --git a/src/stm32f4/ao_arch.h b/src/stm32f4/ao_arch.h index 73eb793f..d4c78f60 100644 --- a/src/stm32f4/ao_arch.h +++ b/src/stm32f4/ao_arch.h @@ -19,9 +19,11 @@ #include #ifndef AO_STACK_SIZE -#define AO_STACK_SIZE 512 +#define AO_STACK_SIZE 1024 #endif +#define AO_STACK_ALIGNMENT __attribute__ ((aligned(8))) + #define AO_PORT_TYPE uint16_t #define ao_arch_nop() asm("nop") -- cgit v1.2.3 From 44ae8b9317fa4aaccabbe9d07b5972f7dfd3baa2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 11 Sep 2018 18:53:15 -0700 Subject: altos: Clean up AO_ROMCONFIG bits Remove address parameter (doesn't work with gcc), create shared ao_romconfig in kernel. Signed-off-by: Keith Packard --- src/attiny/ao_arch.h | 2 ++ src/avr/ao_romconfig.c | 21 --------------------- src/kernel/ao.h | 13 +++++++++++++ src/kernel/ao_product.c | 2 +- src/kernel/ao_romconfig.c | 26 ++++++++++++++++++++++++++ src/lpc/ao_arch.h | 9 +-------- src/lpc/ao_romconfig.c | 26 -------------------------- src/stm/ao_arch.h | 9 +-------- src/stm/ao_romconfig.c | 29 ----------------------------- src/stm32f4/ao_arch.h | 6 ++++++ src/stmf0/ao_arch.h | 4 +--- src/stmf0/ao_romconfig.c | 28 ---------------------------- 12 files changed, 51 insertions(+), 124 deletions(-) delete mode 100644 src/avr/ao_romconfig.c create mode 100644 src/kernel/ao_romconfig.c delete mode 100644 src/lpc/ao_romconfig.c delete mode 100644 src/stm/ao_romconfig.c delete mode 100644 src/stmf0/ao_romconfig.c (limited to 'src/kernel') diff --git a/src/attiny/ao_arch.h b/src/attiny/ao_arch.h index a9c450fc..dfd41afe 100644 --- a/src/attiny/ao_arch.h +++ b/src/attiny/ao_arch.h @@ -49,6 +49,8 @@ #define ao_arch_interrupt(n) /* nothing */ +#define AO_ROMCONFIG_SYMBOL __attribute__((section(".romconfig"))) const + #undef putchar #undef getchar #define putchar(c) ao_putchar(c) diff --git a/src/avr/ao_romconfig.c b/src/avr/ao_romconfig.c deleted file mode 100644 index 4acfc1c8..00000000 --- a/src/avr/ao_romconfig.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright © 2011 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" - -AO_ROMCONFIG_SYMBOL (0) uint16_t ao_serial_number = 0; diff --git a/src/kernel/ao.h b/src/kernel/ao.h index 1b269d73..9baae8b4 100644 --- a/src/kernel/ao.h +++ b/src/kernel/ao.h @@ -81,6 +81,19 @@ typedef AO_PORT_TYPE ao_port_t; void ao_panic(uint8_t reason); +/* + * ao_romconfig.c + */ + +#define AO_ROMCONFIG_VERSION 2 + +extern AO_ROMCONFIG_SYMBOL uint16_t ao_romconfig_version; +extern AO_ROMCONFIG_SYMBOL uint16_t ao_romconfig_check; +extern AO_ROMCONFIG_SYMBOL uint16_t ao_serial_number; +#if HAS_RADIO +extern AO_ROMCONFIG_SYMBOL uint32_t ao_radio_cal; +#endif + /* * ao_timer.c */ diff --git a/src/kernel/ao_product.c b/src/kernel/ao_product.c index 4c2d83ef..72488654 100644 --- a/src/kernel/ao_product.c +++ b/src/kernel/ao_product.c @@ -61,7 +61,7 @@ const char ao_product[] = AO_iProduct_STRING; #define NUM_INTERFACES (AO_USB_HAS_INT + 1) /* USB descriptors in one giant block of bytes */ -AO_ROMCONFIG_SYMBOL(0x00aa) uint8_t ao_usb_descriptors [] = +AO_ROMCONFIG_SYMBOL uint8_t ao_usb_descriptors [] = { /* Device descriptor */ 0x12, diff --git a/src/kernel/ao_romconfig.c b/src/kernel/ao_romconfig.c new file mode 100644 index 00000000..b75142f5 --- /dev/null +++ b/src/kernel/ao_romconfig.c @@ -0,0 +1,26 @@ +/* + * Copyright © 2011 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" + +AO_ROMCONFIG_SYMBOL uint16_t ao_romconfig_version = AO_ROMCONFIG_VERSION; +AO_ROMCONFIG_SYMBOL uint16_t ao_romconfig_check = ~AO_ROMCONFIG_VERSION; +AO_ROMCONFIG_SYMBOL uint16_t ao_serial_number = 0; +#if HAS_RADIO +AO_ROMCONFIG_SYMBOL uint32_t ao_radio_cal = AO_RADIO_CAL_DEFAULT; +#endif diff --git a/src/lpc/ao_arch.h b/src/lpc/ao_arch.h index 889be53e..35dcc9de 100644 --- a/src/lpc/ao_arch.h +++ b/src/lpc/ao_arch.h @@ -58,14 +58,7 @@ * ao_romconfig.c */ -#define AO_ROMCONFIG_VERSION 2 - -#define AO_ROMCONFIG_SYMBOL(a) __attribute__((section(".romconfig"))) const - -extern const uint16_t ao_romconfig_version; -extern const uint16_t ao_romconfig_check; -extern const uint16_t ao_serial_number; -extern const uint32_t ao_radio_cal; +#define AO_ROMCONFIG_SYMBOL __attribute__((section(".romconfig"))) const #define ao_arch_task_members\ uint32_t *sp; /* saved stack pointer */ diff --git a/src/lpc/ao_romconfig.c b/src/lpc/ao_romconfig.c deleted file mode 100644 index 4e7bab8d..00000000 --- a/src/lpc/ao_romconfig.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright © 2011 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" - -AO_ROMCONFIG_SYMBOL (0) uint16_t ao_romconfig_version = AO_ROMCONFIG_VERSION; -AO_ROMCONFIG_SYMBOL (0) uint16_t ao_romconfig_check = ~AO_ROMCONFIG_VERSION; -AO_ROMCONFIG_SYMBOL (0) uint16_t ao_serial_number = 0; -#ifdef AO_RADIO_CAL_DEFAULT -AO_ROMCONFIG_SYMBOL (0) uint32_t ao_radio_cal = AO_RADIO_CAL_DEFAULT; -#endif diff --git a/src/stm/ao_arch.h b/src/stm/ao_arch.h index aee9df3c..e56375ca 100644 --- a/src/stm/ao_arch.h +++ b/src/stm/ao_arch.h @@ -56,14 +56,7 @@ * ao_romconfig.c */ -#define AO_ROMCONFIG_VERSION 2 - -#define AO_ROMCONFIG_SYMBOL(a) __attribute__((section(".romconfig"))) const - -extern const uint16_t ao_romconfig_version; -extern const uint16_t ao_romconfig_check; -extern const uint16_t ao_serial_number; -extern const uint32_t ao_radio_cal; +#define AO_ROMCONFIG_SYMBOL __attribute__((section(".romconfig"))) const #define ao_arch_task_members\ uint32_t *sp; /* saved stack pointer */ diff --git a/src/stm/ao_romconfig.c b/src/stm/ao_romconfig.c deleted file mode 100644 index 63a48bec..00000000 --- a/src/stm/ao_romconfig.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright © 2011 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" - -AO_ROMCONFIG_SYMBOL (0) uint16_t ao_romconfig_version = AO_ROMCONFIG_VERSION; -AO_ROMCONFIG_SYMBOL (0) uint16_t ao_romconfig_check = ~AO_ROMCONFIG_VERSION; -AO_ROMCONFIG_SYMBOL (0) uint16_t ao_serial_number = 0; -#ifndef AO_RADIO_CAL_DEFAULT -#define AO_RADIO_CAL_DEFAULT 0x01020304 -#endif -#if HAS_RADIO -AO_ROMCONFIG_SYMBOL (0) uint32_t ao_radio_cal = AO_RADIO_CAL_DEFAULT; -#endif diff --git a/src/stm32f4/ao_arch.h b/src/stm32f4/ao_arch.h index 083a4e5b..4e9bdeb6 100644 --- a/src/stm32f4/ao_arch.h +++ b/src/stm32f4/ao_arch.h @@ -26,8 +26,14 @@ #define AO_PORT_TYPE uint16_t +#define ao_arch_reboot() \ + (stm_scb.aircr = ((STM_SCB_AIRCR_VECTKEY_KEY << STM_SCB_AIRCR_VECTKEY) | \ + (1 << STM_SCB_AIRCR_SYSRESETREQ))) + #define ao_arch_nop() asm("nop") +#define AO_ROMCONFIG_SYMBOL __attribute__((section(".romconfig"))) const + #define ao_arch_task_members\ uint32_t *sp; /* saved stack pointer */ diff --git a/src/stmf0/ao_arch.h b/src/stmf0/ao_arch.h index 15642951..22e706b2 100644 --- a/src/stmf0/ao_arch.h +++ b/src/stmf0/ao_arch.h @@ -58,9 +58,7 @@ * ao_romconfig.c */ -#define AO_ROMCONFIG_VERSION 2 - -#define AO_ROMCONFIG_SYMBOL(a) __attribute__((section(".romconfig"))) const +#define AO_ROMCONFIG_SYMBOL __attribute__((section(".romconfig"))) const extern const uint16_t ao_romconfig_version; extern const uint16_t ao_romconfig_check; diff --git a/src/stmf0/ao_romconfig.c b/src/stmf0/ao_romconfig.c deleted file mode 100644 index 9d5fd6fb..00000000 --- a/src/stmf0/ao_romconfig.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright © 2011 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" - -AO_ROMCONFIG_SYMBOL (0) uint16_t ao_romconfig_version = AO_ROMCONFIG_VERSION; -AO_ROMCONFIG_SYMBOL (0) uint16_t ao_romconfig_check = ~AO_ROMCONFIG_VERSION; -AO_ROMCONFIG_SYMBOL (0) uint16_t ao_serial_number = 0; -#ifndef AO_RADIO_CAL_DEFAULT -#define AO_RADIO_CAL_DEFAULT 0x01020304 -#endif -AO_ROMCONFIG_SYMBOL (0) uint32_t ao_radio_cal = AO_RADIO_CAL_DEFAULT; - -- cgit v1.2.3 From 80affca535c5c43a5d9963dfafc74f9675c9b155 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 19 Oct 2018 08:12:22 -0700 Subject: altos: Create ao_data_fill shared function This fills a data ring entry with all of the current sensor values other than the ADC. It is used in all of the adc completion functions. Signed-off-by: Keith Packard --- src/kernel/ao_data.h | 28 ++++++++++++++++++++++++++++ src/lpc/ao_adc_lpc.c | 18 +----------------- src/stm/ao_adc_stm.c | 21 +-------------------- src/stmf0/ao_adc_stm.c | 18 +----------------- 4 files changed, 31 insertions(+), 54 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/ao_data.h b/src/kernel/ao_data.h index f88b30c9..97f7e06e 100644 --- a/src/kernel/ao_data.h +++ b/src/kernel/ao_data.h @@ -400,4 +400,32 @@ typedef int16_t ao_mag_t; /* in raw sample units */ #endif +#ifdef AO_DATA_RING + +static inline void +ao_data_fill(int head) { + if (ao_data_present == AO_DATA_ALL) { +#if HAS_MS5607 + ao_data_ring[head].ms5607_raw = ao_ms5607_current; +#endif +#if HAS_MMA655X + ao_data_ring[head].mma655x = ao_mma655x_current; +#endif +#if HAS_HMC5883 + ao_data_ring[head].hmc5883 = ao_hmc5883_current; +#endif +#if HAS_MPU6000 + ao_data_ring[head].mpu6000 = ao_mpu6000_current; +#endif +#if HAS_MPU9250 + ao_data_ring[head].mpu9250 = ao_mpu9250_current; +#endif + ao_data_ring[head].tick = ao_tick_count; + ao_data_head = ao_data_ring_next(head); + ao_wakeup((void *) &ao_data_head); + } +} + +#endif + #endif /* _AO_DATA_H_ */ diff --git a/src/lpc/ao_adc_lpc.c b/src/lpc/ao_adc_lpc.c index 6743c1f4..63241559 100644 --- a/src/lpc/ao_adc_lpc.c +++ b/src/lpc/ao_adc_lpc.c @@ -112,23 +112,7 @@ void lpc_adc_isr(void) } AO_DATA_PRESENT(AO_DATA_ADC); - if (ao_data_present == AO_DATA_ALL) { -#if HAS_MS5607 - ao_data_ring[ao_data_head].ms5607_raw = ao_ms5607_current; -#endif -#if HAS_MMA655X - ao_data_ring[ao_data_head].mma655x = ao_mma655x_current; -#endif -#if HAS_HMC5883 - ao_data_ring[ao_data_head].hmc5883 = ao_hmc5883_current; -#endif -#if HAS_MPU6000 - ao_data_ring[ao_data_head].mpu6000 = ao_mpu6000_current; -#endif - ao_data_ring[ao_data_head].tick = ao_tick_count; - ao_data_head = ao_data_ring_next(ao_data_head); - ao_wakeup((void *) &ao_data_head); - } + ao_data_fill(ao_data_head); ao_adc_ready = 1; } diff --git a/src/stm/ao_adc_stm.c b/src/stm/ao_adc_stm.c index 2399e6a2..ffdcccc0 100644 --- a/src/stm/ao_adc_stm.c +++ b/src/stm/ao_adc_stm.c @@ -45,26 +45,7 @@ static void ao_adc_done(int index) (void) index; AO_DATA_PRESENT(AO_DATA_ADC); ao_dma_done_transfer(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC1)); - if (ao_data_present == AO_DATA_ALL) { -#if HAS_MS5607 - ao_data_ring[ao_data_head].ms5607_raw = ao_ms5607_current; -#endif -#if HAS_MMA655X - ao_data_ring[ao_data_head].mma655x = ao_mma655x_current; -#endif -#if HAS_HMC5883 - ao_data_ring[ao_data_head].hmc5883 = ao_hmc5883_current; -#endif -#if HAS_MPU6000 - ao_data_ring[ao_data_head].mpu6000 = ao_mpu6000_current; -#endif -#if HAS_MPU9250 - ao_data_ring[ao_data_head].mpu9250 = ao_mpu9250_current; -#endif - ao_data_ring[ao_data_head].tick = ao_tick_count; - ao_data_head = ao_data_ring_next(ao_data_head); - ao_wakeup((void *) &ao_data_head); - } + ao_data_fill(ao_data_head); ao_adc_ready = 1; } diff --git a/src/stmf0/ao_adc_stm.c b/src/stmf0/ao_adc_stm.c index e62bb16e..d48726a1 100644 --- a/src/stmf0/ao_adc_stm.c +++ b/src/stmf0/ao_adc_stm.c @@ -38,23 +38,7 @@ static void ao_adc_done(int index) AO_DATA_PRESENT(AO_DATA_ADC); ao_dma_done_transfer(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC_1)); - if (ao_data_present == AO_DATA_ALL) { -#if HAS_MS5607 - ao_data_ring[ao_data_head].ms5607_raw = ao_ms5607_current; -#endif -#if HAS_MMA655X - ao_data_ring[ao_data_head].mma655x = ao_mma655x_current; -#endif -#if HAS_HMC5883 - ao_data_ring[ao_data_head].hmc5883 = ao_hmc5883_current; -#endif -#if HAS_MPU6000 - ao_data_ring[ao_data_head].mpu6000 = ao_mpu6000_current; -#endif - ao_data_ring[ao_data_head].tick = ao_tick_count; - ao_data_head = ao_data_ring_next(ao_data_head); - ao_wakeup((void *) &ao_data_head); - } + ao_data_fill(ao_data_head); ao_adc_ready = 1; } -- cgit v1.2.3 From 30e4e286eec31e69ad1e69a44cf00d4549a09f88 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 13 Oct 2018 09:41:31 -0700 Subject: altos: Add ADXL375 driver [v2] Includes self-test code and multi-byte mode operation for reading sample registers. Signed-off-by: Keith Packard --- src/drivers/ao_adxl375.c | 263 +++++++++++++++++++++++++++++++++++++++++++++++ src/drivers/ao_adxl375.h | 107 +++++++++++++++++++ src/kernel/ao_data.h | 36 ++++++- 3 files changed, 405 insertions(+), 1 deletion(-) create mode 100644 src/drivers/ao_adxl375.c create mode 100644 src/drivers/ao_adxl375.h (limited to 'src/kernel') diff --git a/src/drivers/ao_adxl375.c b/src/drivers/ao_adxl375.c new file mode 100644 index 00000000..e0d094f2 --- /dev/null +++ b/src/drivers/ao_adxl375.c @@ -0,0 +1,263 @@ +/* + * 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. + */ + +#include +#include "ao_adxl375.h" + +#define DEBUG_LOW 1 +#define DEBUG_HIGH 2 + +#define DEBUG 0 + +#if DEBUG +#define PRINTD(l, ...) do { if (DEBUG & (l)) { printf ("\r%5u %s: ", ao_tick_count, __func__); printf(__VA_ARGS__); flush(); } } while(0) +#else +#define PRINTD(l,...) +#endif + +struct ao_adxl375_sample ao_adxl375_current; + +static void +ao_adxl375_start(void) { + ao_spi_get_bit(AO_ADXL375_CS_PORT, + AO_ADXL375_CS_PIN, + AO_ADXL375_SPI_INDEX, + AO_ADXL375_SPI_SPEED); +} + +static void +ao_adxl375_stop(void) { + ao_spi_put_bit(AO_ADXL375_CS_PORT, + AO_ADXL375_CS_PIN, + AO_ADXL375_SPI_INDEX); +} + +static uint8_t +ao_adxl375_reg_read(uint8_t addr) +{ + uint8_t d[2]; + + d[0] = addr | AO_ADXL375_READ; + ao_adxl375_start(); + ao_spi_duplex(d, d, 2, AO_ADXL375_SPI_INDEX); + ao_adxl375_stop(); + + PRINTD(DEBUG_LOW, "read %x = %x\n", addr, d); + + return d[1]; +} + +static void +ao_adxl375_reg_write(uint8_t addr, uint8_t value) +{ + uint8_t d[2]; + + PRINTD(DEBUG_LOW, "write %x %x\n", addr, value); + d[0] = addr; + d[1] = value; + ao_adxl375_start(); + ao_spi_send(d, 2, AO_ADXL375_SPI_INDEX); + ao_adxl375_stop(); + +#if DEBUG & DEBUG_LOW + d[0] = addr | AO_ADXL375_READ + d[1] = 0; + ao_adxl375_start(); + ao_spi_duplex(d, d, 2, AO_ADXL375_SPI_INDEX); + ao_adxl375_stop(); + PRINTD(DEBUG_LOW, "readback %x %x\n", d[0], d[1]); +#endif +} + +static void +ao_adxl375_value(struct ao_adxl375_sample *value) +{ + uint8_t d[7]; + + d[0] = AO_ADXL375_DATAX0 | AO_ADXL375_READ | AO_ADXL375_MULTI_BYTE; + ao_adxl375_start(); + ao_spi_duplex(d, d, 7, AO_ADXL375_SPI_INDEX); + ao_adxl375_stop(); + memcpy(value, &d[1], 6); +} + +struct ao_adxl375_total { + int32_t x; + int32_t y; + int32_t z; +}; + +#define AO_ADXL375_SELF_TEST_SAMPLES 16 +#define AO_ADXL375_SELF_TEST_SETTLE 6 + +#define MIN_LSB_G 18.4 +#define MAX_LSB_G 22.6 +#define SELF_TEST_MIN_G 6.0 +#define SELF_TEST_MAX_G 6.8 + +#define MIN_SELF_TEST ((int32_t) (MIN_LSB_G * SELF_TEST_MIN_G * AO_ADXL375_SELF_TEST_SAMPLES + 0.5)) +#define MAX_SELF_TEST ((int32_t) (MAX_LSB_G * SELF_TEST_MAX_G * AO_ADXL375_SELF_TEST_SAMPLES + 0.5)) + +static const int32_t min_self_test = MIN_SELF_TEST; +static const int32_t max_self_test = MAX_SELF_TEST; + +static void +ao_adxl375_total_value(struct ao_adxl375_total *total, int samples) +{ + struct ao_adxl375_sample value; + + *total = (struct ao_adxl375_total) { 0, 0, 0 }; + for (int i = 0; i < samples; i++) { + ao_adxl375_value(&value); + total->x += value.x; + total->y += value.y; + total->z += value.z; + ao_delay(AO_MS_TO_TICKS(10)); + } +} + +#define AO_ADXL375_DATA_FORMAT_SETTINGS(self_test) ( \ + AO_ADXL375_DATA_FORMAT_FIXED | \ + (self_test << AO_ADXL375_DATA_FORMAT_SELF_TEST) | \ + (AO_ADXL375_DATA_FORMAT_SPI_4_WIRE << AO_ADXL375_DATA_FORMAT_SPI_4_WIRE) | \ + (0 << AO_ADXL375_DATA_FORMAT_INT_INVERT) | \ + (0 << AO_ADXL375_DATA_FORMAT_JUSTIFY)) + +static int32_t self_test_value; + +static void +ao_adxl375_setup(void) +{ + /* Get the device into 4-wire SPI mode before proceeding */ + ao_adxl375_reg_write(AO_ADXL375_DATA_FORMAT, + AO_ADXL375_DATA_FORMAT_SETTINGS(0)); + + + uint8_t devid = ao_adxl375_reg_read(AO_ADXL375_DEVID); + if (devid != AO_ADXL375_DEVID_ID) + ao_sensor_errors = 1; + + /* Set the data rate */ + ao_adxl375_reg_write(AO_ADXL375_BW_RATE, + (0 << AO_ADXL375_BW_RATE_LOW_POWER) | + (AO_ADXL375_BW_RATE_RATE_200 << AO_ADXL375_BW_RATE_RATE)); + + /* Set the offsets all to zero */ + ao_adxl375_reg_write(AO_ADXL375_OFSX, 0); + ao_adxl375_reg_write(AO_ADXL375_OFSY, 0); + ao_adxl375_reg_write(AO_ADXL375_OFSZ, 0); + + /* Clear interrupts */ + ao_adxl375_reg_write(AO_ADXL375_INT_ENABLE, 0); + + /* Configure FIFO (disable) */ + ao_adxl375_reg_write(AO_ADXL375_FIFO_CTL, + (AO_ADXL375_FIFO_CTL_FIFO_MODE_BYPASS << AO_ADXL375_FIFO_CTL_FIFO_MODE) | + (0 << AO_ADXL375_FIFO_CTL_TRIGGER) | + (0 << AO_ADXL375_FIFO_CTL_SAMPLES)); + + /* Place part in measurement mode */ + ao_adxl375_reg_write(AO_ADXL375_POWER_CTL, + (0 << AO_ADXL375_POWER_CTL_LINK) | + (0 << AO_ADXL375_POWER_CTL_AUTO_SLEEP) | + (1 << AO_ADXL375_POWER_CTL_MEASURE) | + (0 << AO_ADXL375_POWER_CTL_SLEEP) | + (AO_ADXL375_POWER_CTL_WAKEUP_8 << AO_ADXL375_POWER_CTL_WAKEUP)); + + (void) ao_adxl375_total_value; + /* Perform self-test */ + +#define AO_ADXL375_SELF_TEST_SAMPLES 16 +#define AO_ADXL375_SELF_TEST_SETTLE 6 + + struct ao_adxl375_total self_test_off, self_test_on; + + /* Discard some samples to let it settle down */ + ao_adxl375_total_value(&self_test_off, AO_ADXL375_SELF_TEST_SETTLE); + + /* Get regular values */ + ao_adxl375_total_value(&self_test_off, AO_ADXL375_SELF_TEST_SAMPLES); + + /* Turn on self test */ + ao_adxl375_reg_write(AO_ADXL375_DATA_FORMAT, + AO_ADXL375_DATA_FORMAT_SETTINGS(1)); + + /* Discard at least 4 samples to let the device settle */ + ao_adxl375_total_value(&self_test_on, AO_ADXL375_SELF_TEST_SETTLE); + + /* Read self test samples */ + ao_adxl375_total_value(&self_test_on, AO_ADXL375_SELF_TEST_SAMPLES); + + /* Reset back to normal mode */ + + ao_adxl375_reg_write(AO_ADXL375_DATA_FORMAT, + AO_ADXL375_DATA_FORMAT_SETTINGS(0)); + + /* Verify Z axis value is in range */ + + int32_t z_change = self_test_on.z - self_test_off.z; + + self_test_value = z_change; + + if (z_change < min_self_test || max_self_test < z_change) + ao_sensor_errors = 1; + + /* Discard some samples to let it settle down */ + ao_adxl375_total_value(&self_test_off, AO_ADXL375_SELF_TEST_SETTLE); +} + +static int adxl375_count; + +static void +ao_adxl375(void) +{ + ao_adxl375_setup(); + for (;;) { + ao_adxl375_value(&ao_adxl375_current); + ++adxl375_count; + ao_arch_critical( + AO_DATA_PRESENT(AO_DATA_ADXL375); + AO_DATA_WAIT(); + ); + } +} + +static struct ao_task ao_adxl375_task; + +static void +ao_adxl375_dump(void) +{ + printf ("ADXL375 value %d %d %d count %d self test %d min %d max %d\n", + ao_adxl375_current.x, + ao_adxl375_current.y, + ao_adxl375_current.z, + adxl375_count, + self_test_value, + MIN_SELF_TEST, + MAX_SELF_TEST); +} + +const struct ao_cmds ao_adxl375_cmds[] = { + { ao_adxl375_dump, "A\0Display ADXL375 data" }, + { 0, NULL }, +}; + +void +ao_adxl375_init(void) +{ + ao_cmd_register(ao_adxl375_cmds); + ao_spi_init_cs(AO_ADXL375_CS_PORT, (1 << AO_ADXL375_CS_PIN)); + + ao_add_task(&ao_adxl375_task, ao_adxl375, "adxl375"); +} diff --git a/src/drivers/ao_adxl375.h b/src/drivers/ao_adxl375.h new file mode 100644 index 00000000..a1ed216d --- /dev/null +++ b/src/drivers/ao_adxl375.h @@ -0,0 +1,107 @@ +/* + * 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. + */ + +#ifndef _AO_ADXL375_H_ +#define _AO_ADXL375_H_ + +#define AO_ADXL375_READ 0x80 /* read mode */ +#define AO_ADXL375_MULTI_BYTE 0x40 /* multi-byte mode */ + +#define AO_ADXL375_DEVID 0x00 +#define AO_ADXL375_DEVID_ID 0xe5 +#define AO_ADXL375_THRESH_SHOCK 0x1d +#define AO_ADXL375_OFSX 0x1e +#define AO_ADXL375_OFSY 0x1f +#define AO_ADXL375_OFSZ 0x20 +#define AO_ADXL375_DUR 0x21 +#define AO_ADXL375_LATENT 0x22 +#define AO_ADXL375_WINDOW 0x23 +#define AO_ADXL375_THRESH_ACT 0x24 +#define AO_ADXL375_THRESH_INACT 0x25 +#define AO_ADXL375_TIME_INACT 0x26 +#define AO_ADXL375_ACT_INACT_CTL 0x27 +#define AO_ADXL375_SHOCK_AXES 0x2a +#define AO_ADXL375_ACT_SHOCK_STATUS 0x2b +#define AO_ADXL375_BW_RATE 0x2c + +#define AO_ADXL375_BW_RATE_LOW_POWER 4 +#define AO_ADXL375_BW_RATE_RATE 0 +#define AO_ADXL375_BW_RATE_RATE_3200 0xf +#define AO_ADXL375_BW_RATE_RATE_1600 0xe +#define AO_ADXL375_BW_RATE_RATE_800 0xd +#define AO_ADXL375_BW_RATE_RATE_400 0xc +#define AO_ADXL375_BW_RATE_RATE_200 0xb +#define AO_ADXL375_BW_RATE_RATE_100 0xa +#define AO_ADXL375_BW_RATE_RATE_50 0x9 +#define AO_ADXL375_BW_RATE_RATE_25 0x8 +#define AO_ADXL375_BW_RATE_RATE_12_5 0x7 +#define AO_ADXL375_BW_RATE_RATE_6_25 0x6 +#define AO_ADXL375_BW_RATE_RATE_3_13 0x5 +#define AO_ADXL375_BW_RATE_RATE_1_56 0x4 +#define AO_ADXL375_BW_RATE_RATE_0_78 0x3 +#define AO_ADXL375_BW_RATE_RATE_0_39 0x2 +#define AO_ADXL375_BW_RATE_RATE_0_20 0x1 +#define AO_ADXL375_BW_RATE_RATE_0_10 0x0 + +#define AO_ADXL375_POWER_CTL 0x2d +#define AO_ADXL375_POWER_CTL_LINK 5 +#define AO_ADXL375_POWER_CTL_AUTO_SLEEP 4 +#define AO_ADXL375_POWER_CTL_MEASURE 3 +#define AO_ADXL375_POWER_CTL_SLEEP 2 +#define AO_ADXL375_POWER_CTL_WAKEUP 0 +#define AO_ADXL375_POWER_CTL_WAKEUP_8 0 +#define AO_ADXL375_POWER_CTL_WAKEUP_4 1 +#define AO_ADXL375_POWER_CTL_WAKEUP_2 2 +#define AO_ADXL375_POWER_CTL_WAKEUP_1 3 + +#define AO_ADXL375_INT_ENABLE 0x2e +#define AO_ADXL375_INT_MAP 0x2f +#define AO_ADXL375_INT_SOURCE 0x30 +#define AO_ADXL375_DATA_FORMAT 0x31 +# define AO_ADXL375_DATA_FORMAT_FIXED 0x0b /* these bits must be set to 1 */ +# define AO_ADXL375_DATA_FORMAT_SELF_TEST 7 +# define AO_ADXL375_DATA_FORMAT_SPI 6 +# define AO_ADXL375_DATA_FORMAT_SPI_3_WIRE 0 +# define AO_ADXL375_DATA_FORMAT_SPI_4_WIRE 1 +# define AO_ADXL375_DATA_FORMAT_INT_INVERT 5 +# define AO_ADXL375_DATA_FORMAT_JUSTIFY 2 +#define AO_ADXL375_DATAX0 0x32 +#define AO_ADXL375_DATAX1 0x33 +#define AO_ADXL375_DATAY0 0x34 +#define AO_ADXL375_DATAY1 0x35 +#define AO_ADXL375_DATAZ0 0x36 +#define AO_ADXL375_DATAZ1 0x37 +#define AO_ADXL375_FIFO_CTL 0x38 +#define AO_ADXL375_FIFO_CTL_FIFO_MODE 6 +#define AO_ADXL375_FIFO_CTL_FIFO_MODE_BYPASS 0 +#define AO_ADXL375_FIFO_CTL_FIFO_MODE_FIFO 1 +#define AO_ADXL375_FIFO_CTL_FIFO_MODE_STREAM 2 +#define AO_ADXL375_FIFO_CTL_FIFO_MODE_TRIGGER 3 +#define AO_ADXL375_FIFO_CTL_TRIGGER 5 +#define AO_ADXL375_FIFO_CTL_SAMPLES 0 + +#define AO_ADXL375_FIFO_STATUS 0x39 + +struct ao_adxl375_sample { + int16_t x; + int16_t y; + int16_t z; +}; + +extern struct ao_adxl375_sample ao_adxl375_current; + +void +ao_adxl375_init(void); + +#endif /* _AO_ADXL375_H_ */ diff --git a/src/kernel/ao_data.h b/src/kernel/ao_data.h index 97f7e06e..3918f4e0 100644 --- a/src/kernel/ao_data.h +++ b/src/kernel/ao_data.h @@ -62,9 +62,16 @@ #define AO_DATA_MMA655X 0 #endif +#if HAS_ADXL375 +#include +#define AO_DATA_ADXL375 (1 << 4) +#else +#define AO_DATA_ADXL375 0 +#endif + #ifdef AO_DATA_RING -#define AO_DATA_ALL (AO_DATA_ADC|AO_DATA_MS5607|AO_DATA_MPU6000|AO_DATA_HMC5883|AO_DATA_MMA655X|AO_DATA_MPU9250) +#define AO_DATA_ALL (AO_DATA_ADC|AO_DATA_MS5607|AO_DATA_MPU6000|AO_DATA_HMC5883|AO_DATA_MMA655X|AO_DATA_MPU9250|AO_DATA_ADXL375) struct ao_data { uint16_t tick; @@ -90,6 +97,9 @@ struct ao_data { #if HAS_MMA655X uint16_t mma655x; #endif +#if HAS_ADXL375 + struct ao_adxl375_sample adxl375; +#endif }; #define ao_data_ring_next(n) (((n) + 1) & (AO_DATA_RING - 1)) @@ -293,6 +303,27 @@ typedef int16_t accel_t; #endif +#if !HAS_ACCEL && HAS_ADXL375 + +#define HAS_ACCEL 1 + +typedef int16_t accel_t; + +#ifndef AO_ADXL375_INVERT +#error AO_ADXL375_INVERT not defined +#endif + +#define ao_data_accel(packet) ((packet)->adxl375.AO_ADXL375_AXIS) +#if AO_ADXL375_INVERT +#define ao_data_accel_cook(packet) (-ao_data_accel(packet)) +#else +#define ao_data_accel_cook(packet) ao_data_accel(packet) +#endif +#define ao_data_set_accel(packet, accel) (ao_data_accel(packet) = (accel)) +#define ao_data_accel_invert(accel) (-(accel)) + +#endif /* HAS_ADXL375 */ + #if !HAS_ACCEL && HAS_MPU6000 #define HAS_ACCEL 1 @@ -419,6 +450,9 @@ ao_data_fill(int head) { #endif #if HAS_MPU9250 ao_data_ring[head].mpu9250 = ao_mpu9250_current; +#endif +#if HAS_ADXL375 + ao_data_ring[head].adxl375 = ao_adxl375_current; #endif ao_data_ring[head].tick = ao_tick_count; ao_data_head = ao_data_ring_next(head); -- cgit v1.2.3