summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/ao_btm.c24
-rw-r--r--src/drivers/ao_cc1120.c14
-rw-r--r--src/drivers/ao_ms5607.c8
-rw-r--r--src/drivers/ao_packet.c13
-rw-r--r--src/drivers/ao_packet_master.c2
-rw-r--r--src/drivers/ao_packet_slave.c1
6 files changed, 42 insertions, 20 deletions
diff --git a/src/drivers/ao_btm.c b/src/drivers/ao_btm.c
index f193ac8e..f3816047 100644
--- a/src/drivers/ao_btm.c
+++ b/src/drivers/ao_btm.c
@@ -312,18 +312,20 @@ __xdata struct ao_task ao_btm_task;
#endif
void
-ao_btm_check_link() __critical
+ao_btm_check_link()
{
- /* Check the pin and configure the interrupt detector to wait for the
- * pin to flip the other way
- */
- if (BT_LINK_PIN) {
- ao_btm_connected = 0;
- PICTL |= BT_PICTL_ICON;
- } else {
- ao_btm_connected = 1;
- PICTL &= ~BT_PICTL_ICON;
- }
+ ao_arch_critical(
+ /* Check the pin and configure the interrupt detector to wait for the
+ * pin to flip the other way
+ */
+ if (BT_LINK_PIN) {
+ ao_btm_connected = 0;
+ PICTL |= BT_PICTL_ICON;
+ } else {
+ ao_btm_connected = 1;
+ PICTL &= ~BT_PICTL_ICON;
+ }
+ );
}
void
diff --git a/src/drivers/ao_cc1120.c b/src/drivers/ao_cc1120.c
index 2f9c296f..7428bead 100644
--- a/src/drivers/ao_cc1120.c
+++ b/src/drivers/ao_cc1120.c
@@ -21,6 +21,9 @@
#include <ao_fec.h>
#include <ao_packet.h>
+#define AO_RADIO_MAX_RECV sizeof(struct ao_packet)
+#define AO_RADIO_MAX_SEND sizeof(struct ao_packet)
+
uint8_t ao_radio_wake;
uint8_t ao_radio_mutex;
uint8_t ao_radio_abort;
@@ -559,18 +562,19 @@ ao_radio_test_cmd(void)
}
}
+static uint8_t tx_data[(AO_RADIO_MAX_SEND + 4) * 2];
+
void
ao_radio_send(const void *d, uint8_t size)
{
uint8_t marc_status;
- static uint8_t encode[256];
- uint8_t *e = encode;
+ uint8_t *e = tx_data;
uint8_t encode_len;
uint8_t this_len;
uint8_t started = 0;
uint8_t fifo_space;
- encode_len = ao_fec_encode(d, size, encode);
+ encode_len = ao_fec_encode(d, size, tx_data);
ao_radio_get(encode_len);
@@ -611,8 +615,6 @@ ao_radio_send(const void *d, uint8_t size)
ao_radio_put();
}
-#define AO_RADIO_MAX_RECV 90
-
static uint8_t rx_data[(AO_RADIO_MAX_RECV + 4) * 2 * 8];
static uint16_t rx_data_count;
static uint16_t rx_data_consumed;
@@ -1026,6 +1028,7 @@ ao_radio_init(void)
ao_radio_configured = 0;
ao_spi_init_cs (AO_CC1120_SPI_CS_PORT, (1 << AO_CC1120_SPI_CS_PIN));
+#if 0
AO_CC1120_SPI_CS_PORT->bsrr = ((uint32_t) (1 << AO_CC1120_SPI_CS_PIN));
for (i = 0; i < 10000; i++) {
if ((SPI_2_PORT->idr & (1 << SPI_2_MISO_PIN)) == 0)
@@ -1034,6 +1037,7 @@ ao_radio_init(void)
AO_CC1120_SPI_CS_PORT->bsrr = (1 << AO_CC1120_SPI_CS_PIN);
if (i == 10000)
ao_panic(AO_PANIC_SELF_TEST_CC1120);
+#endif
/* Enable the EXTI interrupt for the appropriate pin */
ao_enable_port(AO_CC1120_INT_PORT);
diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c
index 077a40e6..ce0bcf4b 100644
--- a/src/drivers/ao_ms5607.c
+++ b/src/drivers/ao_ms5607.c
@@ -130,6 +130,7 @@ static uint32_t
ao_ms5607_get_sample(uint8_t cmd) {
uint8_t reply[3];
uint8_t read;
+ uint32_t loops;
ao_ms5607_done = 0;
@@ -141,10 +142,15 @@ ao_ms5607_get_sample(uint8_t cmd) {
#if AO_MS5607_PRIVATE_PINS
ao_spi_put(AO_MS5607_SPI_INDEX);
#endif
+// loops = 0;
cli();
- while (!ao_ms5607_done)
+ while (!ao_ms5607_done) {
+// loops++;
ao_sleep((void *) &ao_ms5607_done);
+ }
sei();
+// if (loops > 1)
+// printf ("ms5607 loops %d\n", loops);
#if AO_MS5607_PRIVATE_PINS
stm_gpio_set(AO_MS5607_CS_PORT, AO_MS5607_CS_PIN, 1);
#else
diff --git a/src/drivers/ao_packet.c b/src/drivers/ao_packet.c
index d813b25f..3c1e7a18 100644
--- a/src/drivers/ao_packet.c
+++ b/src/drivers/ao_packet.c
@@ -27,6 +27,7 @@ static __pdata uint8_t rx_seq;
__xdata struct ao_task ao_packet_task;
__xdata uint8_t ao_packet_enable;
+__xdata uint8_t ao_packet_restart;
#if PACKET_HAS_MASTER
__xdata uint8_t ao_packet_master_sleeping;
@@ -106,7 +107,8 @@ ao_packet_recv(void)
/* Check for incoming data at the next sequence and
* for an empty data buffer
*/
- if (ao_rx_packet.packet.seq == (uint8_t) (rx_seq + (uint8_t) 1) &&
+ if ((ao_rx_packet.packet.seq == (uint8_t) (rx_seq + (uint8_t) 1) ||
+ ao_packet_restart) &&
ao_packet_rx_used == ao_packet_rx_len) {
/* Copy data to the receive data buffer and set up the
@@ -126,6 +128,7 @@ ao_packet_recv(void)
ao_wakeup(&ao_stdin_ready);
}
}
+ ao_packet_restart = 0;
/* If the other side has seen the latest data we queued,
* wake up any task waiting to send data and let them go again
@@ -152,6 +155,9 @@ ao_packet_flush(void)
void
ao_packet_putchar(char c) __reentrant
{
+ /* No need to block interrupts, all variables here
+ * are only manipulated in task context
+ */
while (ao_packet_tx_used == AO_PACKET_MAX && ao_packet_enable) {
#if PACKET_HAS_MASTER
ao_packet_flush();
@@ -164,8 +170,11 @@ ao_packet_putchar(char c) __reentrant
}
char
-ao_packet_pollchar(void) __critical
+ao_packet_pollchar(void)
{
+ /* No need to block interrupts, all variables here
+ * are only manipulated in task context
+ */
if (!ao_packet_enable)
return AO_READ_AGAIN;
diff --git a/src/drivers/ao_packet_master.c b/src/drivers/ao_packet_master.c
index e97a6648..481232df 100644
--- a/src/drivers/ao_packet_master.c
+++ b/src/drivers/ao_packet_master.c
@@ -18,7 +18,7 @@
#include "ao.h"
static char
-ao_packet_getchar(void) __critical
+ao_packet_getchar(void)
{
char c;
while ((c = ao_packet_pollchar()) == AO_READ_AGAIN) {
diff --git a/src/drivers/ao_packet_slave.c b/src/drivers/ao_packet_slave.c
index fd5d443e..e45775cb 100644
--- a/src/drivers/ao_packet_slave.c
+++ b/src/drivers/ao_packet_slave.c
@@ -22,6 +22,7 @@ ao_packet_slave(void)
{
ao_tx_packet.addr = ao_serial_number;
ao_tx_packet.len = AO_PACKET_SYN;
+ ao_packet_restart = 1;
while (ao_packet_enable) {
if (ao_packet_recv()) {
ao_xmemcpy(&ao_tx_packet.callsign, &ao_rx_packet.packet.callsign, AO_MAX_CALLSIGN);