X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fproduct%2Fao_terraui.c;h=102abb910a3d8e1050e8823aa2b3450aa1f5a843;hp=8875ff487b7438040a9f8dd9478f8428e1f2bb61;hb=99525a748e00406424b98a0952f0156437b30b6c;hpb=d35c4df12a3d8e2dab5d41f8d918ff4237f91e46 diff --git a/src/product/ao_terraui.c b/src/product/ao_terraui.c index 8875ff48..102abb91 100644 --- a/src/product/ao_terraui.c +++ b/src/product/ao_terraui.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -16,17 +17,18 @@ */ #include "ao.h" +#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) @@ -83,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; @@ -163,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) { @@ -182,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 */ @@ -240,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 */ @@ -288,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; @@ -332,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) @@ -344,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; @@ -416,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; @@ -446,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()); @@ -455,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; @@ -506,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, @@ -519,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) @@ -538,9 +540,7 @@ ao_terraui(void) else ao_terraui_page[ao_current_page](); - ao_alarm(AO_SEC_TO_TICKS(1)); - b = ao_button_get(); - ao_clear_alarm(); + b = ao_button_get(AO_SEC_TO_TICKS(1)); if (b > 0) { ao_beep_for(AO_BEEP_HIGH, AO_MS_TO_TICKS(10)); @@ -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) @@ -588,17 +588,17 @@ 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)) continue; - ao_tel_rssi = (ao_monitor_ring[monitor].all.rssi >> 1) - 74; + ao_tel_rssi = AO_RSSI_FROM_RADIO(ao_monitor_ring[monitor].all.rssi); switch (ao_monitor_ring[monitor].all.telemetry.generic.type) { case AO_TELEMETRY_SENSOR_TELEMETRUM: case AO_TELEMETRY_SENSOR_TELEMINI: case AO_TELEMETRY_SENSOR_TELENANO: - ao_xmemcpy(&ao_tel_sensor, &ao_monitor_ring[monitor], sizeof (ao_tel_sensor)); + memcpy(&ao_tel_sensor, &ao_monitor_ring[monitor], sizeof (ao_tel_sensor)); if (ao_tel_sensor.state < ao_flight_boost) { ao_tel_max_speed = 0; ao_tel_max_height = 0; @@ -611,15 +611,15 @@ ao_terramonitor(void) ao_telem_progress = (ao_telem_progress + 1) & 0x3; break; case AO_TELEMETRY_LOCATION: - ao_xmemcpy(&ao_tel_location, &ao_monitor_ring[monitor], sizeof (ao_tel_location)); + memcpy(&ao_tel_location, &ao_monitor_ring[monitor], sizeof (ao_tel_location)); break; case AO_TELEMETRY_CONFIGURATION: - ao_xmemcpy(&ao_tel_config, &ao_monitor_ring[monitor], sizeof (ao_tel_config)); + memcpy(&ao_tel_config, &ao_monitor_ring[monitor], sizeof (ao_tel_config)); } } } -__xdata static struct ao_task ao_terramonitor_task; +static struct ao_task ao_terramonitor_task; static void ao_terragps(void) @@ -628,13 +628,13 @@ ao_terragps(void) for (;;) { while (ao_gps_tick == gps_tick) - ao_sleep(&ao_gps_data); + ao_sleep(&ao_gps_new); gps_tick = ao_gps_tick; ao_gps_progress = (ao_gps_progress + 1) & 3; } } -__xdata static struct ao_task ao_terragps_task; +static struct ao_task ao_terragps_task; void ao_terraui_init(void)