altos: Replace ao_xmem functions with direct mem calls
authorKeith Packard <keithp@keithp.com>
Mon, 16 Sep 2019 00:09:26 +0000 (17:09 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 16 Sep 2019 00:09:26 +0000 (17:09 -0700)
We no longer need to wrap these functions

Signed-off-by: Keith Packard <keithp@keithp.com>
21 files changed:
src/drivers/ao_25lc1024.c
src/drivers/ao_at45db161d.c
src/drivers/ao_gps_skytraq.c
src/drivers/ao_packet.c
src/drivers/ao_packet_master.c
src/drivers/ao_packet_slave.c
src/drivers/ao_radio_master.c
src/drivers/ao_radio_slave.c
src/kernel/ao.h
src/kernel/ao_config.c
src/kernel/ao_ee_fake.c
src/kernel/ao_gps_report.c
src/kernel/ao_gps_report_mega.c
src/kernel/ao_gps_report_metrum.c
src/kernel/ao_host.h
src/kernel/ao_log_telem.c
src/kernel/ao_monitor.c
src/kernel/ao_radio_cmac.c
src/kernel/ao_telemetry.c
src/product/ao_terraui.c
src/test/ao_flight_test.c

index c73f54d..2139dad 100644 (file)
@@ -169,7 +169,7 @@ ao_storage_device_write(uint32_t pos, void *buf, uint16_t len)
                        ao_ee_flush_internal();
                        ao_ee_block = block;
                }
-               ao_xmemcpy(ao_ee_data + (uint16_t) (pos & 0xff), buf, len);
+               memcpy(ao_ee_data + (uint16_t) (pos & 0xff), buf, len);
                ao_ee_block_dirty = 1;
        } ao_mutex_put(&ao_ee_mutex);
        return 1;
@@ -183,7 +183,7 @@ ao_storage_device_read(uint32_t pos, void *buf, uint16_t len)
        /* Transfer the data */
        ao_mutex_get(&ao_ee_mutex); {
                ao_ee_fill(block);
-               ao_xmemcpy(buf, ao_ee_data + (uint16_t) (pos & 0xff), len);
+               memcpy(buf, ao_ee_data + (uint16_t) (pos & 0xff), len);
        } ao_mutex_put(&ao_ee_mutex);
        return 1;
 }
@@ -202,7 +202,7 @@ ao_storage_erase(uint32_t pos)
        ao_mutex_get(&ao_ee_mutex); {
                ao_ee_flush_internal();
                ao_ee_block = (uint16_t) (pos >> EE_BLOCK_SHIFT);
-               ao_xmemset(ao_ee_data, 0xff, EE_BLOCK_SIZE);
+               memset(ao_ee_data, 0xff, EE_BLOCK_SIZE);
                ao_ee_block_dirty = 1;
        } ao_mutex_put(&ao_ee_mutex);
        return 1;
index 516811b..e04baaf 100644 (file)
@@ -246,7 +246,7 @@ ao_storage_device_write(uint32_t pos, void *buf, uint16_t len)
                        ao_flash_flush_internal();
                        ao_flash_block = block;
                }
-               ao_xmemcpy(ao_flash_data + (uint16_t) (pos & ao_flash_block_mask),
+               memcpy(ao_flash_data + (uint16_t) (pos & ao_flash_block_mask),
                       buf,
                       len);
                ao_flash_block_dirty = 1;
@@ -262,7 +262,7 @@ ao_storage_device_read(uint32_t pos, void *buf, uint16_t len)
        /* Transfer the data */
        ao_mutex_get(&ao_flash_mutex); {
                ao_flash_fill(block);
-               ao_xmemcpy(buf,
+               memcpy(buf,
                       ao_flash_data + (uint16_t) (pos & ao_flash_block_mask),
                       len);
        } ao_mutex_put(&ao_flash_mutex);
@@ -283,7 +283,7 @@ ao_storage_erase(uint32_t pos)
        ao_mutex_get(&ao_flash_mutex); {
                ao_flash_flush_internal();
                ao_flash_block = (uint16_t) (pos >> ao_flash_block_shift);
-               ao_xmemset(ao_flash_data, 0xff, ao_flash_block_size);
+               memset(ao_flash_data, 0xff, ao_flash_block_size);
                ao_flash_block_dirty = 1;
        } ao_mutex_put(&ao_flash_mutex);
        return 1;
index f767118..3b4a62e 100644 (file)
@@ -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, &ao_gps_next, sizeof (ao_gps_data));
+               memcpy(&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, &ao_gps_tracking_next, sizeof(ao_gps_tracking_data));
+               memcpy(&ao_gps_tracking_data, &ao_gps_tracking_next, sizeof(ao_gps_tracking_data));
                ao_mutex_put(&ao_gps_mutex);
                ao_wakeup(&ao_gps_new);
        }
index b5a0a4b..b9331c4 100644 (file)
@@ -42,7 +42,7 @@ ao_packet_send(void)
 #endif
        /* If any tx data is pending then copy it into the tx packet */
        if (ao_packet_tx_used && ao_tx_packet.len == 0) {
-               ao_xmemcpy(&ao_tx_packet.d, tx_data, ao_packet_tx_used);
+               memcpy(&ao_tx_packet.d, tx_data, ao_packet_tx_used);
                ao_tx_packet.len = ao_packet_tx_used;
                ao_tx_packet.seq++;
                ao_packet_tx_used = 0;
@@ -88,10 +88,10 @@ ao_packet_recv(uint16_t timeout)
        /* Accept packets with matching call signs, or any packet if
         * our callsign hasn't been configured
         */
-       if (ao_xmemcmp(ao_rx_packet.packet.callsign,
+       if (memcmp(ao_rx_packet.packet.callsign,
                       ao_config.callsign,
                       AO_MAX_CALLSIGN) != 0 &&
-           ao_xmemcmp(ao_config.callsign, "N0CALL", 7) != 0)
+           memcmp(ao_config.callsign, "N0CALL", 7) != 0)
                return 0;
 
        /* SYN packets carry no data */
@@ -111,7 +111,7 @@ ao_packet_recv(uint16_t timeout)
                        /* Copy data to the receive data buffer and set up the
                         * offsets
                         */
-                       ao_xmemcpy(rx_data, ao_rx_packet.packet.d, ao_rx_packet.packet.len);
+                       memcpy(rx_data, ao_rx_packet.packet.d, ao_rx_packet.packet.len);
                        ao_packet_rx_used = 0;
                        ao_packet_rx_len = ao_rx_packet.packet.len;
 
index e67dd27..a44b34c 100644 (file)
@@ -93,7 +93,7 @@ ao_packet_master(void)
        ao_packet_master_delay = AO_PACKET_MASTER_DELAY_SHORT;
        while (ao_packet_enable) {
                uint8_t r;
-               ao_xmemcpy(ao_tx_packet.callsign, ao_config.callsign, AO_MAX_CALLSIGN);
+               memcpy(ao_tx_packet.callsign, ao_config.callsign, AO_MAX_CALLSIGN);
                ao_packet_send();
                if (ao_tx_packet.len)
                        ao_packet_master_busy();
index a583479..314ce14 100644 (file)
@@ -26,7 +26,7 @@ ao_packet_slave(void)
        ao_packet_restart = 1;
        while (ao_packet_enable) {
                if (ao_packet_recv(0)) {
-                       ao_xmemcpy(&ao_tx_packet.callsign, &ao_rx_packet.packet.callsign, AO_MAX_CALLSIGN);
+                       memcpy(&ao_tx_packet.callsign, &ao_rx_packet.packet.callsign, AO_MAX_CALLSIGN);
 #if HAS_FLIGHT
                        ao_flight_force_idle = true;
 #endif
index 8b62a4d..b229bd6 100644 (file)
@@ -134,7 +134,7 @@ ao_radio_get_data(void *d, uint8_t size)
                    AO_RADIO_SPI_REPLY_HEADER_LEN + size,
                    AO_RADIO_SPI_BUS);
        ao_radio_master_stop();
-       ao_xmemcpy(d, ao_radio_spi_reply.payload, size);
+       memcpy(d, ao_radio_spi_reply.payload, size);
        PRINTD ("fetched %d\n", size);
 }
 
@@ -150,7 +150,7 @@ void
 ao_radio_send(const void *d, uint8_t size)
 {
        ao_radio_get(AO_RADIO_SPI_SEND, size);
-       ao_xmemcpy(&ao_radio_spi_request.payload, d, size);
+       memcpy(&ao_radio_spi_request.payload, d, size);
        ao_radio_master_send();
        ao_radio_put();
 }
@@ -190,7 +190,7 @@ ao_radio_cmac_set_key(void)
         */
        PRINTD ("set key\n");
        ao_radio_get(AO_RADIO_SPI_CMAC_KEY, AO_AES_LEN);
-       ao_xmemcpy(&ao_radio_spi_request.payload, &ao_config.aes_key, AO_AES_LEN);
+       memcpy(&ao_radio_spi_request.payload, &ao_config.aes_key, AO_AES_LEN);
        ao_radio_master_send();
        ao_radio_put();
        PRINTD ("key set\n");
@@ -212,7 +212,7 @@ ao_radio_cmac_send(void *packet, uint8_t len)
        
        PRINTD ("sending packet\n");
        ao_radio_get(AO_RADIO_SPI_CMAC_SEND, len);
-       ao_xmemcpy(&ao_radio_spi_request.payload, packet, len);
+       memcpy(&ao_radio_spi_request.payload, packet, len);
        ao_radio_master_send();
        ao_radio_put();
        PRINTD ("packet sent\n");
index 7859d6b..e047093 100644 (file)
@@ -107,7 +107,7 @@ ao_radio_slave_spi(void)
                        break;
                        
                case AO_RADIO_SPI_CMAC_KEY:
-                       ao_xmemcpy(&ao_config.aes_key, ao_radio_spi_request.payload, AO_AES_LEN);
+                       memcpy(&ao_config.aes_key, ao_radio_spi_request.payload, AO_AES_LEN);
                        break;
 
                case AO_RADIO_SPI_TEST_ON:
index dddcd9c..21ab274 100644 (file)
@@ -937,12 +937,6 @@ ao_log_single(void);
 
 #define AO_TELEPYRO_NUM_ADC    9
 
-#ifndef ao_xmemcpy
-#define ao_xmemcpy(d,s,c) memcpy(d,s,c)
-#define ao_xmemset(d,v,c) memset(d,v,c)
-#define ao_xmemcmp(d,s,c) memcmp(d,s,c)
-#endif
-
 /*
  * ao_terraui.c
  */
index f7c79e7..9f329f1 100644 (file)
@@ -138,8 +138,8 @@ _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, AO_CONFIG_DEFAULT_CALLSIGN,
+               memset(&ao_config.callsign, '\0', sizeof (ao_config.callsign));
+               memcpy(&ao_config.callsign, AO_CONFIG_DEFAULT_CALLSIGN,
                       sizeof(AO_CONFIG_DEFAULT_CALLSIGN) - 1);
                ao_config._legacy_radio_channel = 0;
        }
@@ -171,7 +171,7 @@ _ao_config_get(void)
                if (minor < 8)
                        ao_config.radio_enable = AO_RADIO_ENABLE_CORE;
                if (minor < 9)
-                       ao_xmemset(&ao_config.aes_key, '\0', AO_AES_LEN);
+                       memset(&ao_config.aes_key, '\0', AO_AES_LEN);
                if (minor < 10)
                        ao_config.frequency = 434550 + ao_config._legacy_radio_channel * 100;
                if (minor < 11)
@@ -250,7 +250,7 @@ _ao_config_get(void)
 #if HAS_RADIO_RATE
                ao_config.radio_rate = AO_CONFIG_DEFAULT_RADIO_RATE;
 #endif
-               ao_xmemcpy(&ao_config.callsign, AO_CONFIG_DEFAULT_CALLSIGN,
+               memcpy(&ao_config.callsign, AO_CONFIG_DEFAULT_CALLSIGN,
                       sizeof(AO_CONFIG_DEFAULT_CALLSIGN) - 1);
        }
 #endif
@@ -294,7 +294,7 @@ ao_config_callsign_set(void)
        uint8_t c;
        static char callsign[AO_MAX_CALLSIGN + 1];
 
-       ao_xmemset(callsign, '\0', sizeof callsign);
+       memset(callsign, '\0', sizeof callsign);
        ao_cmd_white();
        c = 0;
        while (ao_cmd_lex_c != '\n') {
@@ -307,7 +307,7 @@ ao_config_callsign_set(void)
        if (ao_cmd_status != ao_cmd_success)
                return;
        _ao_config_edit_start();
-       ao_xmemcpy(&ao_config.callsign, &callsign,
+       memcpy(&ao_config.callsign, &callsign,
               AO_MAX_CALLSIGN + 1);
        _ao_config_edit_finish();
 }
index cef0a43..f5e195a 100644 (file)
@@ -33,6 +33,6 @@ ao_ee_write_config(uint8_t *buf, uint16_t len)
 uint8_t
 ao_ee_read_config(uint8_t *buf, uint16_t len) 
 {
-       ao_xmemset(buf, '\0', len);
+       memset(buf, '\0', len);
        return 1;
 }
index 0ef9a72..01226ba 100644 (file)
@@ -32,9 +32,9 @@ ao_gps_report(void)
                        ao_sleep(&ao_gps_new);
                ao_mutex_get(&ao_gps_mutex);
                if (new & AO_GPS_NEW_DATA)
-                       ao_xmemcpy(&gps_data, &ao_gps_data, sizeof (ao_gps_data));
+                       memcpy(&gps_data, &ao_gps_data, sizeof (ao_gps_data));
                if (new & AO_GPS_NEW_TRACKING)
-                       ao_xmemcpy(&gps_tracking_data, &ao_gps_tracking_data, sizeof (ao_gps_tracking_data));
+                       memcpy(&gps_tracking_data, &ao_gps_tracking_data, sizeof (ao_gps_tracking_data));
                ao_gps_new = 0;
                ao_mutex_put(&ao_gps_mutex);
 
index 37f1bea..0cba972 100644 (file)
@@ -70,9 +70,9 @@ ao_gps_report_mega(void)
                        ao_sleep(&ao_gps_new);
                ao_mutex_get(&ao_gps_mutex);
                if (new & AO_GPS_NEW_DATA)
-                       ao_xmemcpy(&gps_data, &ao_gps_data, sizeof (ao_gps_data));
+                       memcpy(&gps_data, &ao_gps_data, sizeof (ao_gps_data));
                if (new & AO_GPS_NEW_TRACKING)
-                       ao_xmemcpy(&gps_tracking_data, &ao_gps_tracking_data, sizeof (ao_gps_tracking_data));
+                       memcpy(&gps_tracking_data, &ao_gps_tracking_data, sizeof (ao_gps_tracking_data));
                ao_gps_new = 0;
                ao_mutex_put(&ao_gps_mutex);
 
index e5839b3..b5f5889 100644 (file)
@@ -34,9 +34,9 @@ ao_gps_report_metrum(void)
                        ao_sleep(&ao_gps_new);
                ao_mutex_get(&ao_gps_mutex);
                if (new & AO_GPS_NEW_DATA)
-                       ao_xmemcpy(&gps_data, &ao_gps_data, sizeof (ao_gps_data));
+                       memcpy(&gps_data, &ao_gps_data, sizeof (ao_gps_data));
                if (new & AO_GPS_NEW_TRACKING)
-                       ao_xmemcpy(&gps_tracking_data, &ao_gps_tracking_data, sizeof (ao_gps_tracking_data));
+                       memcpy(&gps_tracking_data, &ao_gps_tracking_data, sizeof (ao_gps_tracking_data));
                ao_gps_new = 0;
                ao_mutex_put(&ao_gps_mutex);
 
index 592de54..f322182 100644 (file)
@@ -127,6 +127,6 @@ struct ao_config {
 
 struct ao_config ao_config = { 250, 16000 };
 
-#define ao_xmemcpy(d,s,c) memcpy(d,s,c)
-#define ao_xmemset(d,v,c) memset(d,v,c)
-#define ao_xmemcmp(d,s,c) memcmp(d,s,c)
+#define memcpy(d,s,c) memcpy(d,s,c)
+#define memset(d,v,c) memset(d,v,c)
+#define memcmp(d,s,c) memcmp(d,s,c)
index 8c0b88e..f985417 100644 (file)
@@ -103,7 +103,7 @@ ao_log_single(void)
                while (ao_log_running) {
                        /* Write samples to EEPROM */
                        while (ao_log_monitor_pos != ao_monitor_head) {
-                               ao_xmemcpy(&ao_log_single_write_data.telemetry,
+                               memcpy(&ao_log_single_write_data.telemetry,
                                           &ao_monitor_ring[ao_log_monitor_pos],
                                           AO_LOG_SINGLE_SIZE);
                                ao_log_single_write();
index 400ae4d..cd51169 100644 (file)
@@ -157,7 +157,7 @@ ao_monitor_put(void)
                        state = recv_orig.telemetry_orig.flight_state;
 
                        rssi = (int16_t) AO_RSSI_FROM_RADIO(recv_orig.rssi);
-                       ao_xmemcpy(callsign, recv_orig.telemetry_orig.callsign, AO_MAX_CALLSIGN);
+                       memcpy(callsign, recv_orig.telemetry_orig.callsign, AO_MAX_CALLSIGN);
                        if (state > ao_flight_invalid)
                                state = ao_flight_invalid;
                        if (recv_orig.status & PKT_APPEND_STATUS_1_CRC_OK) {
index 155fce3..c7b48e0 100644 (file)
@@ -132,7 +132,7 @@ ao_radio_cmac_send(void *packet, uint8_t len)
        if (len > AO_CMAC_MAX_LEN)
                return AO_RADIO_CMAC_LEN_ERROR;
        ao_mutex_get(&ao_radio_cmac_mutex);
-       ao_xmemcpy(cmac_data, packet, len);
+       memcpy(cmac_data, packet, len);
 #if AO_LED_TX
        ao_led_on(AO_LED_TX);
 #endif
@@ -159,7 +159,7 @@ ao_radio_cmac_recv(void *packet, uint8_t len, uint16_t timeout)
        ao_led_off(AO_LED_RX);
 #endif
        if (i == AO_RADIO_CMAC_OK)
-               ao_xmemcpy(packet, cmac_data, len);
+               memcpy(packet, cmac_data, len);
        ao_mutex_put(&ao_radio_cmac_mutex);
        return i;
 }
index ae33173..99fc453 100644 (file)
@@ -333,12 +333,12 @@ ao_send_configuration(void)
 #endif
 
                telemetry.configuration.flight_log_max = ao_config.flight_log_max >> 10;
-               ao_xmemcpy (telemetry.configuration.callsign,
-                           ao_config.callsign,
-                           AO_MAX_CALLSIGN);
-               ao_xmemcpy (telemetry.configuration.version,
-                           ao_version,
-                           AO_MAX_VERSION);
+               memcpy (telemetry.configuration.callsign,
+                       ao_config.callsign,
+                       AO_MAX_CALLSIGN);
+               memcpy (telemetry.configuration.version,
+                       ao_version,
+                       AO_MAX_VERSION);
                ao_telemetry_config_cur = ao_telemetry_config_max;
                ao_telemetry_send();
        }
@@ -350,6 +350,18 @@ static int8_t ao_telemetry_gps_max;
 static int8_t ao_telemetry_loc_cur;
 static int8_t ao_telemetry_sat_cur;
 
+static inline void *
+telemetry_bits(struct ao_telemetry_location *l)
+{
+       return ((uint8_t *) l) + offsetof(struct ao_telemetry_location, flags);
+}
+
+static inline int
+telemetry_size(void)
+{
+       return sizeof(struct ao_telemetry_location) - offsetof(struct ao_telemetry_location, flags);
+}
+
 static void
 ao_send_location(void)
 {
@@ -357,9 +369,9 @@ ao_send_location(void)
        {
                telemetry.generic.type = AO_TELEMETRY_LOCATION;
                ao_mutex_get(&ao_gps_mutex);
-               ao_xmemcpy(&telemetry.location.flags,
-                      &ao_gps_data.flags,
-                      27);
+               memcpy(telemetry_bits(&telemetry.location),
+                      telemetry_bits(&ao_gps_data),
+                      telemetry_size());
                telemetry.location.tick = ao_gps_tick;
                ao_mutex_put(&ao_gps_mutex);
                ao_telemetry_loc_cur = ao_telemetry_gps_max;
@@ -375,7 +387,7 @@ ao_send_satellite(void)
                telemetry.generic.type = AO_TELEMETRY_SATELLITE;
                ao_mutex_get(&ao_gps_mutex);
                telemetry.satellite.channels = ao_gps_tracking_data.channels;
-               ao_xmemcpy(&telemetry.satellite.sats,
+               memcpy(&telemetry.satellite.sats,
                       &ao_gps_tracking_data.sats,
                       AO_MAX_GPS_TRACKING * sizeof (struct ao_telemetry_satellite_info));
                ao_mutex_put(&ao_gps_mutex);
@@ -399,7 +411,7 @@ ao_send_companion(void)
                telemetry.companion.update_period = ao_companion_setup.update_period;
                telemetry.companion.channels = ao_companion_setup.channels;
                ao_mutex_get(&ao_companion_mutex);
-               ao_xmemcpy(&telemetry.companion.companion_data,
+               memcpy(&telemetry.companion.companion_data,
                       ao_companion_data,
                       ao_companion_setup.channels * 2);
                ao_mutex_put(&ao_companion_mutex);
index 3a989f5..102abb9 100644 (file)
@@ -598,7 +598,7 @@ ao_terramonitor(void)
                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,10 +611,10 @@ 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));
                }
        }
 }
index 6d00757..35e0da3 100644 (file)
@@ -331,10 +331,6 @@ struct ao_cmds {
        const char      *help;
 };
 
-#define ao_xmemcpy(d,s,c) memcpy(d,s,c)
-#define ao_xmemset(d,v,c) memset(d,v,c)
-#define ao_xmemcmp(d,s,c) memcmp(d,s,c)
-
 #define AO_NEED_ALTITUDE_TO_PRES 1
 #if TELEMEGA || TELEMETRUM_V2 || EASYMINI
 #include "ao_convert_pa.c"
@@ -358,9 +354,6 @@ struct ao_ms5607_prom       ao_ms5607_prom;
 
 struct ao_config ao_config;
 
-#define x (x)
-
-
 extern int16_t ao_ground_accel, ao_flight_accel;
 extern int16_t ao_accel_2g;