diff options
Diffstat (limited to 'src/drivers')
50 files changed, 923 insertions, 403 deletions
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_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 <keithp@keithp.com> + * + * 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 <ao.h> +#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 <keithp@keithp.com> + * + * 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/drivers/ao_aprs.c b/src/drivers/ao_aprs.c index a8016673..2f17d044 100644 --- a/src/drivers/ao_aprs.c +++ b/src/drivers/ao_aprs.c @@ -804,10 +804,10 @@ static int tncPositionPacket(void) /* Convert from meters to feet */ alt = (alt * 328 + 50) / 100; - buf += sprintf((char *) tncBuffer, "!%02u%02u.%02u%c/%03u%02u.%02u%c'/A=%06u ", + buf += sprintf((char *) tncBuffer, "!%02u%02u.%02u%c/%03u%02u.%02u%c'/A=%06lu ", lat_deg, lat_min, lat_frac, lat_sign, lon_deg, lon_min, lon_frac, lon_sign, - alt); + (long) alt); break; } } 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..04bf4138 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 +#define BT_DEBUG 1 #if BT_DEBUG -__xdata char ao_btm_buffer[256]; +char ao_btm_buffer[256]; uint16_t ao_btm_ptr; char ao_btm_dir; @@ -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; @@ -137,7 +142,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 +158,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 +257,7 @@ ao_btm_wait_reply(void) } void -ao_btm_string(__code char *cmd) +ao_btm_string(const char *cmd) { char c; @@ -261,7 +266,7 @@ ao_btm_string(__code char *cmd) } uint8_t -ao_btm_cmd(__code char *cmd) +ao_btm_cmd(const char *cmd) { ao_btm_drain(); @@ -342,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; @@ -351,7 +356,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 @@ -450,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 2f091485..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 @@ -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) { @@ -1066,7 +1065,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_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 de282000..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 @@ -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(); @@ -988,7 +986,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; @@ -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_companion.c b/src/drivers/ao_companion.c index f82558a3..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,16 +38,15 @@ #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) -__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) @@ -107,7 +105,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(); @@ -116,7 +114,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,17 +132,17 @@ 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) { - 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_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_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 c483382e..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); @@ -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); } @@ -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..a6d93083 100644 --- a/src/drivers/ao_gps_ublox.c +++ b/src/drivers/ao_gps_ublox.c @@ -26,11 +26,11 @@ #include <stdarg.h> -__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; @@ -783,12 +783,12 @@ ao_gps(void) __reentrant #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); } } @@ -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_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_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..5f5db572 100644 --- a/src/drivers/ao_lco.c +++ b/src/drivers/ao_lco.c @@ -319,12 +319,12 @@ 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; } -__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.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_lco_cmd.c b/src/drivers/ao_lco_cmd.c index dba9a76a..6f195e55 100644 --- a/src/drivers/ao_lco_cmd.c +++ b/src/drivers/ao_lco_cmd.c @@ -26,17 +26,15 @@ #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; - 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; @@ -71,7 +69,7 @@ lco_ignite(uint8_t cmd) } static void -lco_report_cmd(void) __reentrant +lco_report_cmd(void) { int8_t r; uint8_t c; @@ -122,15 +120,14 @@ lco_report_cmd(void) __reentrant } static void -lco_fire_cmd(void) __reentrant +lco_fire_cmd(void) { uint8_t secs; uint8_t i; 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(); @@ -156,15 +153,14 @@ 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; 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(); @@ -190,7 +186,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 +201,7 @@ lco_arm_cmd(void) __reentrant } static void -lco_ignite_cmd(void) __reentrant +lco_ignite_cmd(void) { uint8_t i; lco_args(); @@ -216,13 +212,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 <box> <channel>\0Get remote status" }, { lco_fire_cmd, "F <box> <channel> <secs>\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 <ao_radio_cmac.h> #include <ao_lco_func.h> -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..49ea1236 100644 --- a/src/drivers/ao_lco_two.c +++ b/src/drivers/ao_lco_two.c @@ -124,12 +124,12 @@ 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; } -__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_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 <keithp@keithp.com> + * + * 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/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..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 @@ -259,7 +257,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 +275,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_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 ae8dacd0..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; @@ -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_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 53ed992a..e2327bf4 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 @@ -31,12 +31,12 @@ static __xdata 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 @@ -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(); } @@ -74,7 +74,7 @@ ao_ms5607_crc(uint8_t *prom) return n_rem; } -static int +static bool ao_ms5607_prom_valid(uint8_t *prom) { uint8_t crc; @@ -87,26 +87,26 @@ ao_ms5607_prom_valid(uint8_t *prom) if (*p++ + 1 > 1) break; if (i == 16) - return FALSE; + return false; crc = ao_ms5607_crc(prom); if (crc != (prom[15] & 0xf)) - return FALSE; + return false; - return TRUE; + return true; } 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(); - 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++; @@ -138,25 +138,25 @@ 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; 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); @@ -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(); @@ -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 008af5db..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 @@ -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 */ @@ -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_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_pad.c b/src/drivers/ao_pad.c index c6efc311..85691f5c 100644 --- a/src/drivers/ao_pad.c +++ b/src/drivers/ao_pad.c @@ -22,14 +22,14 @@ #include <ao_74hc165.h> #include <ao_radio_cmac.h> -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 @@ -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 @@ -189,21 +189,21 @@ 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) - ao_sleep((void *) DATA_TO_XDATA(&ao_data_head)); + ao_sleep((void *) &ao_data_head); ); @@ -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); @@ -526,17 +524,17 @@ 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 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); @@ -560,7 +556,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 <key> <n>\0Fire igniter. <key> is doit with D&I" }, #if DEBUG @@ -593,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_pca9922.c b/src/drivers/ao_pca9922.c index 09f52a0e..91d62026 100644 --- a/src/drivers/ao_pca9922.c +++ b/src/drivers/ao_pca9922.c @@ -23,7 +23,7 @@ #include <ao.h> -static __xdata uint8_t ao_led_state; +static uint8_t ao_led_state; static void ao_led_apply(void) @@ -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[] = { @@ -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_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_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..a5fbd1da 100644 --- a/src/drivers/ao_quadrature.c +++ b/src/drivers/ao_quadrature.c @@ -22,7 +22,7 @@ #include <ao_fast_timer.h> #include <ao_event.h> -__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 @@ -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_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 <ao_exti.h> #include <ao_radio_cmac.h> -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 <ao_radio_spi.h> #include <ao_radio_cmac.h> -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_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_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_trng_send.c b/src/drivers/ao_trng_send.c index 4e02c0ce..adeed590 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); } @@ -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,16 +211,16 @@ 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; + trng_running = false; } 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 1a877fcb..612496bc 100644 --- a/src/drivers/ao_watchdog.c +++ b/src/drivers/ao_watchdog.c @@ -18,7 +18,7 @@ #include <ao.h> -static int ao_watchdog_enabled = TRUE; +static int ao_watchdog_enabled = true; static void ao_watchdog(void) @@ -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); } } } @@ -38,15 +38,15 @@ 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); } } -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 }, }; @@ -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"); } |