projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos: fix cc1120 radio test - state wasn't made static
[fw/altos]
/
src
/
drivers
/
ao_cc1120.c
diff --git
a/src/drivers/ao_cc1120.c
b/src/drivers/ao_cc1120.c
index 569df3b7c80ad92416130ac6391dda1130f42f18..f27958f96ae397776248f17a64f1f687da780b0b 100644
(file)
--- a/
src/drivers/ao_cc1120.c
+++ b/
src/drivers/ao_cc1120.c
@@
-21,6
+21,9
@@
#include <ao_fec.h>
#include <ao_packet.h>
#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;
uint8_t ao_radio_wake;
uint8_t ao_radio_mutex;
uint8_t ao_radio_abort;
@@
-29,7
+32,7
@@
uint8_t ao_radio_in_recv;
#define CC1120_DEBUG AO_FEC_DEBUG
#define CC1120_TRACE 0
#define CC1120_DEBUG AO_FEC_DEBUG
#define CC1120_TRACE 0
-
const uint32_t ao_radio_cal = 0x6ca333
;
+
extern const uint32_t ao_radio_cal
;
#define FOSC 32000000
#define FOSC 32000000
@@
-466,10
+469,10
@@
ao_rdf_run(void)
{
ao_radio_start_tx();
{
ao_radio_start_tx();
-
cli
();
+
ao_arch_block_interrupts
();
while (!ao_radio_wake && !ao_radio_abort)
ao_sleep(&ao_radio_wake);
while (!ao_radio_wake && !ao_radio_abort)
ao_sleep(&ao_radio_wake);
-
sei
();
+
ao_arch_release_interrupts
();
if (!ao_radio_wake)
ao_radio_idle();
ao_radio_put();
if (!ao_radio_wake)
ao_radio_idle();
ao_radio_put();
@@
-515,10
+518,10
@@
ao_radio_rdf_abort(void)
}
static void
}
static void
-ao_radio_test(void)
+ao_radio_test
_cmd
(void)
{
uint8_t mode = 2;
{
uint8_t mode = 2;
- uint8_t radio_on;
+
static
uint8_t radio_on;
ao_cmd_white();
if (ao_cmd_lex_c != '\n') {
ao_cmd_decimal();
ao_cmd_white();
if (ao_cmd_lex_c != '\n') {
ao_cmd_decimal();
@@
-559,18
+562,19
@@
ao_radio_test(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;
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;
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);
ao_radio_get(encode_len);
@@
-599,10
+603,10
@@
ao_radio_send(const void *d, uint8_t size)
do {
ao_radio_wake = 0;
do {
ao_radio_wake = 0;
-
cli
();
+
ao_arch_block_interrupts
();
while (!ao_radio_wake)
ao_sleep(&ao_radio_wake);
while (!ao_radio_wake)
ao_sleep(&ao_radio_wake);
-
sei
();
+
ao_arch_release_interrupts
();
if (!encode_len)
break;
fifo_space = ao_radio_tx_fifo_space();
if (!encode_len)
break;
fifo_space = ao_radio_tx_fifo_space();
@@
-611,8
+615,6
@@
ao_radio_send(const void *d, uint8_t size)
ao_radio_put();
}
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;
static uint8_t rx_data[(AO_RADIO_MAX_RECV + 4) * 2 * 8];
static uint16_t rx_data_count;
static uint16_t rx_data_consumed;
@@
-658,14
+660,14
@@
ao_radio_rx_isr(void)
static uint16_t
ao_radio_rx_wait(void)
{
static uint16_t
ao_radio_rx_wait(void)
{
-
cli
();
+
ao_arch_block_interrupts
();
rx_waiting = 1;
while (rx_data_cur - rx_data_consumed < AO_FEC_DECODE_BLOCK &&
!ao_radio_abort) {
ao_sleep(&ao_radio_wake);
}
rx_waiting = 0;
rx_waiting = 1;
while (rx_data_cur - rx_data_consumed < AO_FEC_DECODE_BLOCK &&
!ao_radio_abort) {
ao_sleep(&ao_radio_wake);
}
rx_waiting = 0;
-
sei
();
+
ao_arch_release_interrupts
();
if (ao_radio_abort)
return 0;
rx_data_consumed += AO_FEC_DECODE_BLOCK;
if (ao_radio_abort)
return 0;
rx_data_consumed += AO_FEC_DECODE_BLOCK;
@@
-1008,7
+1010,7
@@
ao_radio_test_recv()
#endif
static const struct ao_cmds ao_radio_cmds[] = {
#endif
static const struct ao_cmds ao_radio_cmds[] = {
- { ao_radio_test
,
"C <1 start, 0 stop, none both>\0Radio carrier test" },
+ { ao_radio_test
_cmd,
"C <1 start, 0 stop, none both>\0Radio carrier test" },
#if CC1120_DEBUG
{ ao_radio_show, "R\0Show CC1120 status" },
{ ao_radio_beep, "b\0Emit an RDF beacon" },
#if CC1120_DEBUG
{ ao_radio_show, "R\0Show CC1120 status" },
{ ao_radio_beep, "b\0Emit an RDF beacon" },
@@
-1026,14
+1028,16
@@
ao_radio_init(void)
ao_radio_configured = 0;
ao_spi_init_cs (AO_CC1120_SPI_CS_PORT, (1 << AO_CC1120_SPI_CS_PIN));
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++) {
AO_CC1120_SPI_CS_PORT->bsrr = ((uint32_t) (1 << AO_CC1120_SPI_CS_PIN));
for (i = 0; i < 10000; i++) {
- if ((SPI_2_
GPIO->idr & (1 << SPI_2_MISO
)) == 0)
+ if ((SPI_2_
PORT->idr & (1 << SPI_2_MISO_PIN
)) == 0)
break;
}
AO_CC1120_SPI_CS_PORT->bsrr = (1 << AO_CC1120_SPI_CS_PIN);
if (i == 10000)
break;
}
AO_CC1120_SPI_CS_PORT->bsrr = (1 << AO_CC1120_SPI_CS_PIN);
if (i == 10000)
- ao_panic(AO_PANIC_SELF_TEST);
+ ao_panic(AO_PANIC_SELF_TEST_CC1120);
+#endif
/* Enable the EXTI interrupt for the appropriate pin */
ao_enable_port(AO_CC1120_INT_PORT);
/* Enable the EXTI interrupt for the appropriate pin */
ao_enable_port(AO_CC1120_INT_PORT);