summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/ao_cc1120.c60
-rw-r--r--src/drivers/ao_cc1120.h62
-rw-r--r--src/drivers/ao_cc1120_CC1120.h43
-rw-r--r--src/drivers/ao_fat.c19
-rw-r--r--src/drivers/ao_log_fat.c4
-rw-r--r--src/drivers/ao_packet.c6
-rw-r--r--src/drivers/ao_packet_master.c2
-rw-r--r--src/drivers/ao_radio_master.c3
-rw-r--r--src/drivers/ao_radio_slave.c3
-rw-r--r--src/drivers/ao_seven_segment.c264
10 files changed, 295 insertions, 171 deletions
diff --git a/src/drivers/ao_cc1120.c b/src/drivers/ao_cc1120.c
index a26eccbc..3bef6c90 100644
--- a/src/drivers/ao_cc1120.c
+++ b/src/drivers/ao_cc1120.c
@@ -30,6 +30,9 @@ static uint8_t ao_radio_wake; /* radio ready. Also used as sleep address */
static uint8_t ao_radio_abort; /* radio operation should abort */
static uint8_t ao_radio_mcu_wake; /* MARC status change */
static uint8_t ao_radio_marc_status; /* Last read MARC status value */
+static uint8_t ao_radio_tx_finished; /* MARC status indicates TX finished */
+
+int8_t ao_radio_rssi; /* Last received RSSI value */
#define CC1120_DEBUG AO_FEC_DEBUG
#define CC1120_TRACE 0
@@ -242,6 +245,8 @@ ao_radio_check_marc_status(void)
/* Anyt other than 'tx/rx finished' means an error occurred */
if (ao_radio_marc_status & ~(CC1120_MARC_STATUS1_TX_FINISHED|CC1120_MARC_STATUS1_RX_FINISHED))
ao_radio_abort = 1;
+ if (ao_radio_marc_status & (CC1120_MARC_STATUS1_TX_FINISHED))
+ ao_radio_tx_finished = 1;
}
static void
@@ -258,6 +263,7 @@ ao_radio_start_tx(void)
ao_exti_set_callback(AO_CC1120_INT_PORT, AO_CC1120_INT_PIN, ao_radio_isr);
ao_exti_enable(AO_CC1120_INT_PORT, AO_CC1120_INT_PIN);
ao_exti_enable(AO_CC1120_MCU_WAKEUP_PORT, AO_CC1120_MCU_WAKEUP_PIN);
+ ao_radio_tx_finished = 0;
ao_radio_strobe(CC1120_STX);
}
@@ -268,6 +274,8 @@ ao_radio_idle(void)
uint8_t state = ao_radio_strobe(CC1120_SIDLE);
if ((state >> CC1120_STATUS_STATE) == CC1120_STATUS_STATE_IDLE)
break;
+ if ((state >> CC1120_STATUS_STATE) == CC1120_STATUS_STATE_TX_FIFO_ERROR)
+ ao_radio_strobe(CC1120_SFTX);
}
/* Flush any pending TX bytes */
ao_radio_strobe(CC1120_SFTX);
@@ -546,6 +554,7 @@ ao_radio_get(uint8_t len)
static uint32_t last_radio_setting;
ao_mutex_get(&ao_radio_mutex);
+
if (!ao_radio_configured)
ao_radio_setup();
if (ao_config.radio_setting != last_radio_setting) {
@@ -671,12 +680,17 @@ ao_radio_test_cmd(void)
}
static void
-ao_radio_wait_isr(void)
+ao_radio_wait_isr(uint16_t timeout)
{
+ if (timeout)
+ ao_alarm(timeout);
ao_arch_block_interrupts();
while (!ao_radio_wake && !ao_radio_mcu_wake && !ao_radio_abort)
- ao_sleep(&ao_radio_wake);
+ if (ao_sleep(&ao_radio_wake))
+ ao_radio_abort = 1;
ao_arch_release_interrupts();
+ if (timeout)
+ ao_clear_alarm();
if (ao_radio_mcu_wake)
ao_radio_check_marc_status();
}
@@ -687,7 +701,7 @@ ao_radio_wait_tx(uint8_t wait_fifo)
uint8_t fifo_space = 0;
do {
- ao_radio_wait_isr();
+ ao_radio_wait_isr(0);
if (!wait_fifo)
return 0;
fifo_space = ao_radio_tx_fifo_space();
@@ -706,11 +720,17 @@ ao_radio_send(const void *d, uint8_t size)
uint8_t this_len;
uint8_t started = 0;
uint8_t fifo_space;
+ uint8_t q;
encode_len = ao_fec_encode(d, size, tx_data);
ao_radio_get(encode_len);
+ ao_radio_abort = 0;
+
+ /* Flush any pending TX bytes */
+ ao_radio_strobe(CC1120_SFTX);
+
started = 0;
fifo_space = CC1120_FIFO_SIZE;
while (encode_len) {
@@ -741,6 +761,8 @@ ao_radio_send(const void *d, uint8_t size)
break;
}
}
+ while (started && !ao_radio_abort && !ao_radio_tx_finished)
+ ao_radio_wait_isr(0);
ao_radio_put();
}
@@ -777,7 +799,7 @@ ao_radio_send_aprs(ao_radio_fill_func fill)
/* Wait for some space in the fifo */
while (!ao_radio_abort && (fifo_space = ao_radio_tx_fifo_space()) == 0) {
ao_radio_wake = 0;
- ao_radio_wait_isr();
+ ao_radio_wait_isr(0);
}
if (ao_radio_abort)
break;
@@ -809,7 +831,7 @@ ao_radio_send_aprs(ao_radio_fill_func fill)
}
/* Wait for the transmitter to go idle */
ao_radio_wake = 0;
- ao_radio_wait_isr();
+ ao_radio_wait_isr(0);
}
ao_radio_put();
}
@@ -886,11 +908,12 @@ ao_radio_rx_wait(void)
}
uint8_t
-ao_radio_recv(__xdata void *d, uint8_t size)
+ao_radio_recv(__xdata void *d, uint8_t size, uint8_t timeout)
{
uint8_t len;
uint16_t i;
- uint8_t rssi;
+ uint8_t radio_rssi = 0;
+ uint8_t rssi0;
uint8_t ret;
static int been_here = 0;
@@ -940,9 +963,11 @@ ao_radio_recv(__xdata void *d, uint8_t size)
ao_radio_strobe(CC1120_SRX);
/* Wait for the preamble to appear */
- ao_radio_wait_isr();
- if (ao_radio_abort)
+ ao_radio_wait_isr(timeout);
+ if (ao_radio_abort) {
+ ret = 0;
goto abort;
+ }
ao_radio_reg_write(AO_CC1120_INT_GPIO_IOCFG, CC1120_IOCFG_GPIO_CFG_CLKEN_SOFT);
ao_exti_set_mode(AO_CC1120_INT_PORT, AO_CC1120_INT_PIN,
@@ -958,17 +983,26 @@ ao_radio_recv(__xdata void *d, uint8_t size)
ao_radio_burst_read_stop();
abort:
- ao_radio_strobe(CC1120_SIDLE);
-
/* Convert from 'real' rssi to cc1111-style values */
- rssi = AO_RADIO_FROM_RSSI(ao_radio_reg_read(CC1120_RSSI1));
+ rssi0 = ao_radio_reg_read(CC1120_RSSI0);
+ if (rssi0 & 1) {
+ int8_t rssi = ao_radio_reg_read(CC1120_RSSI1);
+ ao_radio_rssi = rssi;
+
+ /* Bound it to the representable range */
+ if (rssi > -11)
+ rssi = -11;
+ radio_rssi = AO_RADIO_FROM_RSSI (rssi);
+ }
+
+ ao_radio_strobe(CC1120_SIDLE);
ao_radio_put();
/* Store the received RSSI value; the crc-OK byte is already done */
- ((uint8_t *) d)[size] = (uint8_t) rssi;
+ ((uint8_t *) d)[size] = radio_rssi;
#if AO_PROFILE
rx_last_done_tick = rx_done_tick;
diff --git a/src/drivers/ao_cc1120.h b/src/drivers/ao_cc1120.h
index 60b9621e..5d226b64 100644
--- a/src/drivers/ao_cc1120.h
+++ b/src/drivers/ao_cc1120.h
@@ -215,10 +215,72 @@
#define CC1120_AGC_REF 0x17
#define CC1120_AGC_CS_THR 0x18
#define CC1120_AGC_GAIN_ADJUST 0x19
+
#define CC1120_AGC_CFG3 0x1a
+#define CC1120_AGC_CFG3_RSSI_STEP_THR 7
+#define CC1120_AGC_CFG3_AGC_MIN_GAIN 0
+#define CC1120_AGC_CFG3_AGC_MIN_GAIN_MASK 0x1f
+
#define CC1120_AGC_CFG2 0x1b
+#define CC1120_AGC_CFG2_START_PREVIOUS_GAIN_EN 7
+#define CC1120_AGC_CFG2_FE_PERFORMANCE_MODE 5
+#define CC1120_AGC_CFG2_FE_PERFORMANCE_MODE_OPTIMIZE_LINEARITY 0
+#define CC1120_AGC_CFG2_FE_PERFORMANCE_MODE_NORMAL 1
+#define CC1120_AGC_CFG2_FE_PERFORMANCE_MODE_LOW_POWER 2
+#define CC1120_AGC_CFG2_FE_PERFORMANCE_MODE_MASK 3
+#define CC1120_AGC_CFG2_AGC_MAX_GAIN 0
+#define CC1120_AGC_CFG2_AGC_MAX_MASK 0x1f
+
#define CC1120_AGC_CFG1 0x1c
+#define CC1120_AGC_CFG1_AGC_SYNC_BEHAVIOR 5
+#define CC1120_AGC_CFG1_AGC_SYNC_BEHAVIOR_UPDATE_AGC_UPDATE_RSSI 0
+#define CC1120_AGC_CFG1_AGC_SYNC_BEHAVIOR_FREEZE_AGC_UPDATE_RSSI 1
+#define CC1120_AGC_CFG1_AGC_SYNC_BEHAVIOR_UPDATE_AGC_UPDATE_RSSI_SLOW 2
+#define CC1120_AGC_CFG1_AGC_SYNC_BEHAVIOR_FREEZE_AGC_FREEZE_RSSI 3
+#define CC1120_AGC_CFG1_AGC_SYNC_BEHAVIOR_UPDATE_AGC_UPDATE_RSSI_4 4
+#define CC1120_AGC_CFG1_AGC_SYNC_BEHAVIOR_FREEZE_AGC_FREEZE_RSSI_5 5
+#define CC1120_AGC_CFG1_AGC_SYNC_BEHAVIOR_UPDATE_AGC_UPDATE_RSSI_SLOW_6 6
+#define CC1120_AGC_CFG1_AGC_SYNC_BEHAVIOR_FREEZE_AGC_FREEZE_RSSI_7 7
+#define CC1120_AGC_CFG1_AGC_WIN_SIZE 2
+#define CC1120_AGC_CFG1_AGC_WIN_SIZE_8 0
+#define CC1120_AGC_CFG1_AGC_WIN_SIZE_16 1
+#define CC1120_AGC_CFG1_AGC_WIN_SIZE_32 2
+#define CC1120_AGC_CFG1_AGC_WIN_SIZE_64 3
+#define CC1120_AGC_CFG1_AGC_WIN_SIZE_128 4
+#define CC1120_AGC_CFG1_AGC_WIN_SIZE_256 5
+#define CC1120_AGC_CFG1_AGC_WIN_SIZE_MASK 7
+#define CC1120_AGC_CFG1_AGC_SETTLE_WAIT 0
+#define CC1120_AGC_CFG1_AGC_SETTLE_WAIT_24 0
+#define CC1120_AGC_CFG1_AGC_SETTLE_WAIT_32 1
+#define CC1120_AGC_CFG1_AGC_SETTLE_WAIT_40 2
+#define CC1120_AGC_CFG1_AGC_SETTLE_WAIT_48 3
+
#define CC1120_AGC_CFG0 0x1d
+
+#define CC1120_AGC_CFG0_AGC_HYST_LEVEL 6
+#define CC1120_AGC_CFG0_AGC_HYST_LEVEL_2 0
+#define CC1120_AGC_CFG0_AGC_HYST_LEVEL_4 1
+#define CC1120_AGC_CFG0_AGC_HYST_LEVEL_7 2
+#define CC1120_AGC_CFG0_AGC_HYST_LEVEL_10 3
+
+#define CC1120_AGC_CFG0_AGC_SLEWRATE_LIMIT 4
+#define CC1120_AGC_CFG0_AGC_SLEWRATE_LIMIT_60 0
+#define CC1120_AGC_CFG0_AGC_SLEWRATE_LIMIT_30 1
+#define CC1120_AGC_CFG0_AGC_SLEWRATE_LIMIT_18 2
+#define CC1120_AGC_CFG0_AGC_SLEWRATE_LIMIT_9 3
+
+#define CC1120_AGC_CFG0_RSSI_VALID_CNT 2
+#define CC1120_AGC_CFG0_RSSI_VALID_CNT_2 0
+#define CC1120_AGC_CFG0_RSSI_VALID_CNT_3 1
+#define CC1120_AGC_CFG0_RSSI_VALID_CNT_5 2
+#define CC1120_AGC_CFG0_RSSI_VALID_CNT_9 3
+
+#define CC1120_AGC_CFG0_AGC_ASK_DECAY 0
+#define CC1120_AGC_CFG0_AGC_ASK_DECAY_1_16 0
+#define CC1120_AGC_CFG0_AGC_ASK_DECAY_1_32 1
+#define CC1120_AGC_CFG0_AGC_ASK_DECAY_1_64 2
+#define CC1120_AGC_CFG0_AGC_ASK_DECAY_1_128 3
+
#define CC1120_FIFO_CFG 0x1e
#define CC1120_FIFO_CFG_CRC_AUTOFLUSH 7
#define CC1120_FIFO_CFG_FIFO_THR 0
diff --git a/src/drivers/ao_cc1120_CC1120.h b/src/drivers/ao_cc1120_CC1120.h
index 44cca938..399abc4d 100644
--- a/src/drivers/ao_cc1120_CC1120.h
+++ b/src/drivers/ao_cc1120_CC1120.h
@@ -21,6 +21,10 @@
*
***************************************************************/
+#ifndef AO_CC1120_AGC_GAIN_ADJUST
+#define AO_CC1120_AGC_GAIN_ADJUST -80
+#endif
+
CC1120_SYNC3, 0xD3, /* Sync Word Configuration [31:24] */
CC1120_SYNC2, 0x91, /* Sync Word Configuration [23:16] */
CC1120_SYNC1, 0xD3, /* Sync Word Configuration [15:8] */
@@ -53,24 +57,49 @@
(0 << CC1120_MDMCFG1_SINGLE_ADC_EN),
CC1120_MDMCFG0, 0x05, /* General Modem Parameter Configuration */
- CC1120_AGC_REF, 0x20, /* AGC Reference Level Configuration */
- CC1120_AGC_CS_THR, 0x19, /* Carrier Sense Threshold Configuration */
- CC1120_AGC_GAIN_ADJUST, 0x00, /* RSSI Offset Configuration */
- CC1120_AGC_CFG3, 0x91, /* AGC Configuration */
- CC1120_AGC_CFG2, 0x20, /* AGC Configuration */
- CC1120_AGC_CFG1, 0xa9, /* AGC Configuration */
- CC1120_AGC_CFG0, 0xcf, /* AGC Configuration */
+ /* AGC reference = 10 * log10(receive BW) - 4 = 10 * log10(100e3) - 4 = 46 */
+ CC1120_AGC_REF, 46, /* AGC Reference Level Configuration */
+
+ /* Carrier sense threshold - 25dB above the noise */
+ CC1120_AGC_CS_THR, 25, /* Carrier Sense Threshold Configuration */
+ CC1120_AGC_GAIN_ADJUST, /* RSSI Offset Configuration */
+ AO_CC1120_AGC_GAIN_ADJUST,
+
+ CC1120_AGC_CFG3, /* AGC Configuration */
+ (1 << CC1120_AGC_CFG3_RSSI_STEP_THR) |
+ (17 << CC1120_AGC_CFG3_AGC_MIN_GAIN),
+
+ CC1120_AGC_CFG2, /* AGC Configuration */
+ (0 << CC1120_AGC_CFG2_START_PREVIOUS_GAIN_EN) |
+ (CC1120_AGC_CFG2_FE_PERFORMANCE_MODE_NORMAL << CC1120_AGC_CFG2_FE_PERFORMANCE_MODE) |
+ (0 << CC1120_AGC_CFG2_AGC_MAX_GAIN),
+
+ CC1120_AGC_CFG1, /* AGC Configuration */
+ (CC1120_AGC_CFG1_AGC_SYNC_BEHAVIOR_UPDATE_AGC_UPDATE_RSSI_SLOW << CC1120_AGC_CFG1_AGC_SYNC_BEHAVIOR) |
+ (CC1120_AGC_CFG1_AGC_WIN_SIZE_32 << CC1120_AGC_CFG1_AGC_WIN_SIZE) |
+ (CC1120_AGC_CFG1_AGC_SETTLE_WAIT_32 << CC1120_AGC_CFG1_AGC_SETTLE_WAIT),
+
+ CC1120_AGC_CFG0, /* AGC Configuration */
+ (CC1120_AGC_CFG0_AGC_HYST_LEVEL_10 << CC1120_AGC_CFG0_AGC_HYST_LEVEL) |
+ (CC1120_AGC_CFG0_AGC_SLEWRATE_LIMIT_60 << CC1120_AGC_CFG0_AGC_SLEWRATE_LIMIT) |
+ (CC1120_AGC_CFG0_RSSI_VALID_CNT_9 << CC1120_AGC_CFG0_RSSI_VALID_CNT) |
+ (CC1120_AGC_CFG0_AGC_ASK_DECAY_1_128 << CC1120_AGC_CFG0_AGC_ASK_DECAY),
+
CC1120_FIFO_CFG, /* FIFO Configuration */
(0 << CC1120_FIFO_CFG_CRC_AUTOFLUSH) |
(0x40 << CC1120_FIFO_CFG_FIFO_THR),
+
CC1120_DEV_ADDR, 0x00, /* Device Address Configuration */
+
CC1120_SETTLING_CFG, /* Frequency Synthesizer Calibration and Settling Configuration */
(CC1120_SETTLING_CFG_FS_AUTOCAL_IDLE_TO_ON << CC1120_SETTLING_CFG_FS_AUTOCAL) |
(CC1120_SETTLING_CFG_LOCK_TIME_50_20 << CC1120_SETTLING_CFG_LOCK_TIME) |
(CC1120_SETTLING_CFG_FSREG_TIME_60 << CC1120_SETTLING_CFG_FSREG_TIME),
+
CC1120_FS_CFG, /* Frequency Synthesizer Configuration */
(1 << CC1120_FS_CFG_LOCK_EN) |
(CC1120_FS_CFG_FSD_BANDSELECT_410_480 << CC1120_FS_CFG_FSD_BANDSELECT),
+
CC1120_WOR_CFG1, 0x08, /* eWOR Configuration, Reg 1 */
CC1120_WOR_CFG0, 0x21, /* eWOR Configuration, Reg 0 */
CC1120_WOR_EVENT0_MSB, 0x00, /* Event 0 Configuration */
diff --git a/src/drivers/ao_fat.c b/src/drivers/ao_fat.c
index afd645cd..1a1b8eb0 100644
--- a/src/drivers/ao_fat.c
+++ b/src/drivers/ao_fat.c
@@ -1052,7 +1052,7 @@ static int8_t
_ao_fat_open(char name[11], uint8_t mode)
{
uint16_t entry = 0;
- struct ao_fat_dirent dirent;
+ static struct ao_fat_dirent dirent;
int8_t status;
if (_ao_fat_setup() != AO_FAT_FILESYSTEM_SUCCESS)
@@ -1214,12 +1214,11 @@ ao_fat_map_current(struct ao_file *file, int len, cluster_offset_t *offsetp, clu
offset = file->offset & SECTOR_MASK;
sector = _ao_fat_current_sector(file);
if (sector == 0xffffffff) {
- printf ("invalid sector at offset %d\n", file->offset);
return NULL;
}
buf = _ao_fat_sector_get(sector);
if (!buf)
- printf ("sector get failed. Sector %d. Partition end %d\n", sector, partition_end);
+ return NULL;
if (offset + len < SECTOR_SIZE)
*this_time = len;
else
@@ -1259,7 +1258,6 @@ ao_fat_read(int8_t fd, void *dst, int len)
while (len) {
buf = ao_fat_map_current(file, len, &offset, &this_time);
if (!buf) {
- printf ("map_current failed\n");
ret = -AO_FAT_EIO;
break;
}
@@ -1307,7 +1305,6 @@ ao_fat_write(int8_t fd, void *src, int len)
while (len) {
buf = ao_fat_map_current(file, len, &offset, &this_time);
if (!buf) {
- printf ("map_current failed\n");
ret = -AO_FAT_EIO;
break;
}
@@ -1375,7 +1372,7 @@ int8_t
ao_fat_unlink(char name[11])
{
uint16_t entry = 0;
- struct ao_fat_dirent dirent;
+ static struct ao_fat_dirent dirent;
int8_t ret;
ao_mutex_get(&ao_fat_mutex);
@@ -1492,7 +1489,7 @@ static void
ao_fat_list_cmd(void)
{
uint16_t entry = 0;
- struct ao_fat_dirent dirent;
+ static struct ao_fat_dirent dirent;
int i;
int8_t status;
@@ -1535,10 +1532,10 @@ ao_fat_parse_name(char name[11])
static void
ao_fat_dump_cmd(void)
{
- char name[11];
+ static char name[11];
int8_t fd;
int cnt, i;
- char buf[32];
+ static char buf[32];
ao_fat_parse_name(name);
if (name[0] == '\0') {
@@ -1561,10 +1558,10 @@ ao_fat_dump_cmd(void)
static void
ao_fat_write_cmd(void)
{
- char name[11];
+ static char name[11];
int8_t fd;
int cnt, i;
- char buf[64];
+ static char buf[64];
char c;
int status;
diff --git a/src/drivers/ao_log_fat.c b/src/drivers/ao_log_fat.c
index af77401c..45b67012 100644
--- a/src/drivers/ao_log_fat.c
+++ b/src/drivers/ao_log_fat.c
@@ -27,7 +27,7 @@ static uint8_t log_mutex;
static void
ao_log_open(void)
{
- char name[12];
+ static char name[12];
int8_t status;
sprintf(name,"%04d%02d%02dLOG", 2000 + log_year, log_month, log_day);
@@ -38,7 +38,7 @@ ao_log_open(void)
log_open = 1;
} else if (status == -AO_FAT_ENOENT) {
status = ao_fat_creat(name);
- if (status == AO_FAT_SUCCESS) {
+ if (status >= 0) {
log_fd = status;
log_open = 1;
}
diff --git a/src/drivers/ao_packet.c b/src/drivers/ao_packet.c
index 5a507478..8cdf85a9 100644
--- a/src/drivers/ao_packet.c
+++ b/src/drivers/ao_packet.c
@@ -31,7 +31,6 @@ __xdata uint8_t ao_packet_restart;
#if PACKET_HAS_MASTER
__xdata uint8_t ao_packet_master_sleeping;
-__xdata uint8_t ao_packet_last_rssi;
#endif
void
@@ -62,7 +61,7 @@ ao_packet_recv(void)
#ifdef AO_LED_GREEN
ao_led_on(AO_LED_GREEN);
#endif
- dma_done = ao_radio_recv(&ao_rx_packet, sizeof (struct ao_packet_recv));
+ dma_done = ao_radio_recv(&ao_rx_packet, sizeof (struct ao_packet_recv), 0);
#ifdef AO_LED_GREEN
ao_led_off(AO_LED_GREEN);
#endif
@@ -85,9 +84,6 @@ ao_packet_recv(void)
if (!(ao_rx_packet.status & AO_RADIO_STATUS_CRC_OK))
return 0;
-#if PACKET_HAS_MASTER
- ao_packet_last_rssi = ao_rx_packet.rssi;
-#endif
/* Accept packets with matching call signs, or any packet if
* our callsign hasn't been configured
*/
diff --git a/src/drivers/ao_packet_master.c b/src/drivers/ao_packet_master.c
index 4c0dc573..d6c99cbd 100644
--- a/src/drivers/ao_packet_master.c
+++ b/src/drivers/ao_packet_master.c
@@ -145,7 +145,7 @@ ao_packet_forward(void) __reentrant
static void
ao_packet_signal(void)
{
- printf ("RSSI: %d\n", AO_RSSI_FROM_RADIO(ao_packet_last_rssi));
+ printf ("RSSI: %d\n", ao_radio_rssi);
}
__code struct ao_cmds ao_packet_master_cmds[] = {
diff --git a/src/drivers/ao_radio_master.c b/src/drivers/ao_radio_master.c
index 1e0050c8..128fcf32 100644
--- a/src/drivers/ao_radio_master.c
+++ b/src/drivers/ao_radio_master.c
@@ -156,7 +156,7 @@ ao_radio_send(const void *d, uint8_t size)
uint8_t
-ao_radio_recv(__xdata void *d, uint8_t size)
+ao_radio_recv(__xdata void *d, uint8_t size, uint8_t timeout)
{
int8_t ret;
uint8_t recv;
@@ -166,6 +166,7 @@ ao_radio_recv(__xdata void *d, uint8_t size)
ao_radio_get(AO_RADIO_SPI_RECV, 0);
ao_radio_spi_request.recv_len = size;
+ ao_radio_spi_request.timeout = timeout;
recv = ao_radio_master_send();
if (!recv) {
ao_radio_put();
diff --git a/src/drivers/ao_radio_slave.c b/src/drivers/ao_radio_slave.c
index 1d1f16fe..9a0612e5 100644
--- a/src/drivers/ao_radio_slave.c
+++ b/src/drivers/ao_radio_slave.c
@@ -65,7 +65,8 @@ ao_radio_slave_spi(void)
ao_config.radio_setting = ao_radio_spi_request.setting;
ao_led_on(AO_LED_RX);
ao_radio_spi_reply.status = ao_radio_recv(&ao_radio_spi_reply.payload,
- ao_radio_spi_request.recv_len);
+ ao_radio_spi_request.recv_len,
+ ao_radio_spi_request.timeout);
ao_led_off(AO_LED_RX);
ao_radio_spi_reply.rssi = 0;
ao_spi_send(&ao_radio_spi_reply,
diff --git a/src/drivers/ao_seven_segment.c b/src/drivers/ao_seven_segment.c
index b3b5f878..961fbb84 100644
--- a/src/drivers/ao_seven_segment.c
+++ b/src/drivers/ao_seven_segment.c
@@ -34,134 +34,138 @@
*
*/
+#ifndef SEVEN_SEGMENT_DEBUG
+#define SEVEN_SEGMENT_DEBUG 0
+#endif
+
static const uint8_t ao_segments[] = {
- (1 << AO_SEGMENT_0) |
- (1 << AO_SEGMENT_1) |
- (1 << AO_SEGMENT_2) |
- (0 << AO_SEGMENT_3) |
- (1 << AO_SEGMENT_4) |
- (1 << AO_SEGMENT_5) |
- (1 << AO_SEGMENT_6), /* 0 */
-
- (0 << AO_SEGMENT_0) |
- (0 << AO_SEGMENT_1) |
- (1 << AO_SEGMENT_2) |
- (0 << AO_SEGMENT_3) |
- (0 << AO_SEGMENT_4) |
- (1 << AO_SEGMENT_5) |
- (0 << AO_SEGMENT_6), /* 1 */
-
- (1 << AO_SEGMENT_0) |
- (0 << AO_SEGMENT_1) |
- (1 << AO_SEGMENT_2) |
- (1 << AO_SEGMENT_3) |
- (1 << AO_SEGMENT_4) |
- (0 << AO_SEGMENT_5) |
- (1 << AO_SEGMENT_6), /* 2 */
-
- (1 << AO_SEGMENT_0) |
- (0 << AO_SEGMENT_1) |
- (1 << AO_SEGMENT_2) |
- (1 << AO_SEGMENT_3) |
- (0 << AO_SEGMENT_4) |
- (1 << AO_SEGMENT_5) |
- (1 << AO_SEGMENT_6), /* 3 */
-
- (0 << AO_SEGMENT_0) |
- (1 << AO_SEGMENT_1) |
- (1 << AO_SEGMENT_2) |
- (1 << AO_SEGMENT_3) |
- (0 << AO_SEGMENT_4) |
- (1 << AO_SEGMENT_5) |
- (0 << AO_SEGMENT_6), /* 4 */
-
- (1 << AO_SEGMENT_0) |
- (1 << AO_SEGMENT_1) |
- (0 << AO_SEGMENT_2) |
- (1 << AO_SEGMENT_3) |
- (0 << AO_SEGMENT_4) |
- (1 << AO_SEGMENT_5) |
- (1 << AO_SEGMENT_6), /* 5 */
-
- (1 << AO_SEGMENT_0) |
- (1 << AO_SEGMENT_1) |
- (0 << AO_SEGMENT_2) |
- (1 << AO_SEGMENT_3) |
- (1 << AO_SEGMENT_4) |
- (1 << AO_SEGMENT_5) |
- (1 << AO_SEGMENT_6), /* 6 */
-
- (1 << AO_SEGMENT_0) |
- (0 << AO_SEGMENT_1) |
- (1 << AO_SEGMENT_2) |
- (0 << AO_SEGMENT_3) |
- (0 << AO_SEGMENT_4) |
- (1 << AO_SEGMENT_5) |
- (0 << AO_SEGMENT_6), /* 7 */
-
- (1 << AO_SEGMENT_0) |
- (1 << AO_SEGMENT_1) |
- (1 << AO_SEGMENT_2) |
- (1 << AO_SEGMENT_3) |
- (1 << AO_SEGMENT_4) |
- (1 << AO_SEGMENT_5) |
- (1 << AO_SEGMENT_6), /* 8 */
-
- (1 << AO_SEGMENT_0) |
- (1 << AO_SEGMENT_1) |
- (1 << AO_SEGMENT_2) |
- (1 << AO_SEGMENT_3) |
- (0 << AO_SEGMENT_4) |
- (1 << AO_SEGMENT_5) |
- (1 << AO_SEGMENT_6), /* 9 */
-
- (1 << AO_SEGMENT_0) |
- (1 << AO_SEGMENT_1) |
- (1 << AO_SEGMENT_2) |
- (1 << AO_SEGMENT_3) |
- (1 << AO_SEGMENT_4) |
- (1 << AO_SEGMENT_5) |
- (0 << AO_SEGMENT_6), /* A */
-
- (0 << AO_SEGMENT_0) |
- (1 << AO_SEGMENT_1) |
- (0 << AO_SEGMENT_2) |
- (1 << AO_SEGMENT_3) |
- (1 << AO_SEGMENT_4) |
- (1 << AO_SEGMENT_5) |
- (1 << AO_SEGMENT_6), /* b */
-
- (1 << AO_SEGMENT_0) |
- (1 << AO_SEGMENT_1) |
- (0 << AO_SEGMENT_2) |
- (0 << AO_SEGMENT_3) |
- (1 << AO_SEGMENT_4) |
- (0 << AO_SEGMENT_5) |
- (1 << AO_SEGMENT_6), /* c */
-
- (0 << AO_SEGMENT_0) |
- (0 << AO_SEGMENT_1) |
- (1 << AO_SEGMENT_2) |
- (1 << AO_SEGMENT_3) |
- (1 << AO_SEGMENT_4) |
- (1 << AO_SEGMENT_5) |
- (1 << AO_SEGMENT_6), /* d */
-
- (1 << AO_SEGMENT_0) |
- (1 << AO_SEGMENT_1) |
- (0 << AO_SEGMENT_2) |
- (1 << AO_SEGMENT_3) |
- (1 << AO_SEGMENT_4) |
- (0 << AO_SEGMENT_5) |
- (1 << AO_SEGMENT_6), /* E */
-
- (1 << AO_SEGMENT_0) |
- (1 << AO_SEGMENT_1) |
- (0 << AO_SEGMENT_2) |
- (1 << AO_SEGMENT_3) |
- (1 << AO_SEGMENT_4) |
- (0 << AO_SEGMENT_5) |
- (0 << AO_SEGMENT_6), /* F */
+ (1 << 0) |
+ (1 << 1) |
+ (1 << 2) |
+ (0 << 3) |
+ (1 << 4) |
+ (1 << 5) |
+ (1 << 6), /* 0 */
+
+ (0 << 0) |
+ (0 << 1) |
+ (1 << 2) |
+ (0 << 3) |
+ (0 << 4) |
+ (1 << 5) |
+ (0 << 6), /* 1 */
+
+ (1 << 0) |
+ (0 << 1) |
+ (1 << 2) |
+ (1 << 3) |
+ (1 << 4) |
+ (0 << 5) |
+ (1 << 6), /* 2 */
+
+ (1 << 0) |
+ (0 << 1) |
+ (1 << 2) |
+ (1 << 3) |
+ (0 << 4) |
+ (1 << 5) |
+ (1 << 6), /* 3 */
+
+ (0 << 0) |
+ (1 << 1) |
+ (1 << 2) |
+ (1 << 3) |
+ (0 << 4) |
+ (1 << 5) |
+ (0 << 6), /* 4 */
+
+ (1 << 0) |
+ (1 << 1) |
+ (0 << 2) |
+ (1 << 3) |
+ (0 << 4) |
+ (1 << 5) |
+ (1 << 6), /* 5 */
+
+ (1 << 0) |
+ (1 << 1) |
+ (0 << 2) |
+ (1 << 3) |
+ (1 << 4) |
+ (1 << 5) |
+ (1 << 6), /* 6 */
+
+ (1 << 0) |
+ (0 << 1) |
+ (1 << 2) |
+ (0 << 3) |
+ (0 << 4) |
+ (1 << 5) |
+ (0 << 6), /* 7 */
+
+ (1 << 0) |
+ (1 << 1) |
+ (1 << 2) |
+ (1 << 3) |
+ (1 << 4) |
+ (1 << 5) |
+ (1 << 6), /* 8 */
+
+ (1 << 0) |
+ (1 << 1) |
+ (1 << 2) |
+ (1 << 3) |
+ (0 << 4) |
+ (1 << 5) |
+ (1 << 6), /* 9 */
+
+ (1 << 0) |
+ (1 << 1) |
+ (1 << 2) |
+ (1 << 3) |
+ (1 << 4) |
+ (1 << 5) |
+ (0 << 6), /* A */
+
+ (0 << 0) |
+ (1 << 1) |
+ (0 << 2) |
+ (1 << 3) |
+ (1 << 4) |
+ (1 << 5) |
+ (1 << 6), /* b */
+
+ (1 << 0) |
+ (1 << 1) |
+ (0 << 2) |
+ (0 << 3) |
+ (1 << 4) |
+ (0 << 5) |
+ (1 << 6), /* c */
+
+ (0 << 0) |
+ (0 << 1) |
+ (1 << 2) |
+ (1 << 3) |
+ (1 << 4) |
+ (1 << 5) |
+ (1 << 6), /* d */
+
+ (1 << 0) |
+ (1 << 1) |
+ (0 << 2) |
+ (1 << 3) |
+ (1 << 4) |
+ (0 << 5) |
+ (1 << 6), /* E */
+
+ (1 << 0) |
+ (1 << 1) |
+ (0 << 2) |
+ (1 << 3) |
+ (1 << 4) |
+ (0 << 5) |
+ (0 << 6), /* F */
};
void
@@ -177,7 +181,7 @@ ao_seven_segment_set(uint8_t digit, uint8_t value)
/* Check for decimal point */
if (value & 0x10)
- segments |= (1 << AO_SEGMENT_7);
+ segments |= (1 << 7);
}
for (s = 0; s <= 7; s++)
@@ -192,7 +196,7 @@ ao_seven_segment_clear(void)
}
-#if 0
+#if SEVEN_SEGMENT_DEBUG
static void
ao_seven_segment_show(void)
{
@@ -214,7 +218,7 @@ static const struct ao_cmds ao_seven_segment_cmds[] = {
void
ao_seven_segment_init(void)
{
-#if 0
+#if SEVEN_SEGMENT_DEBUG
ao_cmd_register(ao_seven_segment_cmds);
#endif
}