projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge remote-tracking branch 'origin/master'
[fw/altos]
/
src
/
cc1111
/
ao_radio.c
diff --git
a/src/cc1111/ao_radio.c
b/src/cc1111/ao_radio.c
index 2071c47a432cae2c4f8d3c628fea19e8578a9c34..190647ce0dbe432f6a0b4ee5f8428b686110cf69 100644
(file)
--- a/
src/cc1111/ao_radio.c
+++ b/
src/cc1111/ao_radio.c
@@
-16,6
+16,9
@@
*/
#include "ao.h"
*/
#include "ao.h"
+#if HAS_PAD
+#include <ao_pad.h>
+#endif
/* Values from SmartRF® Studio for:
*
/* Values from SmartRF® Studio for:
*
@@
-184,7
+187,7
@@
static __code uint8_t radio_setup[] = {
RF_BSCFG_BS_POST_KI_PRE_KI|
RF_BSCFG_BS_POST_KP_PRE_KP|
RF_BSCFG_BS_LIMIT_0),
RF_BSCFG_BS_POST_KI_PRE_KI|
RF_BSCFG_BS_POST_KP_PRE_KP|
RF_BSCFG_BS_LIMIT_0),
- RF_AGCCTRL2_OFF, 0x
4
3,
+ RF_AGCCTRL2_OFF, 0x
0
3,
RF_AGCCTRL1_OFF, 0x40,
RF_AGCCTRL0_OFF, 0x91,
RF_AGCCTRL1_OFF, 0x40,
RF_AGCCTRL0_OFF, 0x91,
@@
-246,6
+249,18
@@
__xdata uint8_t ao_radio_done;
__xdata uint8_t ao_radio_abort;
__xdata uint8_t ao_radio_mutex;
__xdata uint8_t ao_radio_abort;
__xdata uint8_t ao_radio_mutex;
+#if PACKET_HAS_MASTER || HAS_AES
+#define NEED_RADIO_RSSI 1
+#endif
+
+#ifndef NEED_RADIO_RSSI
+#define NEED_RADIO_RSSI 0
+#endif
+
+#if NEED_RADIO_RSSI
+__xdata int8_t ao_radio_rssi;
+#endif
+
void
ao_radio_general_isr(void) __interrupt 16
{
void
ao_radio_general_isr(void) __interrupt 16
{
@@
-319,7
+334,7
@@
ao_radio_send(__xdata void *packet, uint8_t size) __reentrant
}
uint8_t
}
uint8_t
-ao_radio_recv(__xdata void *packet, uint8_t size) __reentrant
+ao_radio_recv(__xdata void *packet, uint8_t size
, uint8_t timeout
) __reentrant
{
ao_radio_abort = 0;
ao_radio_get(size - 2);
{
ao_radio_abort = 0;
ao_radio_get(size - 2);
@@
-339,9
+354,13
@@
ao_radio_recv(__xdata void *packet, uint8_t size) __reentrant
/* Wait for DMA to be done, for the radio receive process to
* get aborted or for a receive timeout to fire
*/
/* Wait for DMA to be done, for the radio receive process to
* get aborted or for a receive timeout to fire
*/
+ if (timeout)
+ ao_alarm(timeout);
__critical while (!ao_radio_dma_done && !ao_radio_abort)
if (ao_sleep(&ao_radio_dma_done))
break;
__critical while (!ao_radio_dma_done && !ao_radio_abort)
if (ao_sleep(&ao_radio_dma_done))
break;
+ if (timeout)
+ ao_clear_alarm();
/* If recv was aborted, clean up by stopping the DMA engine
* and idling the radio
/* If recv was aborted, clean up by stopping the DMA engine
* and idling the radio
@@
-349,7
+368,14
@@
ao_radio_recv(__xdata void *packet, uint8_t size) __reentrant
if (!ao_radio_dma_done) {
ao_dma_abort(ao_radio_dma);
ao_radio_idle();
if (!ao_radio_dma_done) {
ao_dma_abort(ao_radio_dma);
ao_radio_idle();
+#if NEED_RADIO_RSSI
+ ao_radio_rssi = 0;
+#endif
}
}
+#if NEED_RADIO_RSSI
+ else
+ ao_radio_rssi = AO_RSSI_FROM_RADIO(((uint8_t *)packet)[size - 2]);
+#endif
ao_radio_put();
return ao_radio_dma_done;
}
ao_radio_put();
return ao_radio_dma_done;
}
@@
-467,8
+493,44
@@
ao_radio_rdf_abort(void)
/* Output carrier */
/* Output carrier */
+
+static __xdata ao_radio_test_on;
+
void
void
-ao_radio_test(void)
+ao_radio_test(uint8_t on)
+{
+ if (on) {
+ if (!ao_radio_test_on) {
+#if HAS_MONITOR
+ ao_monitor_disable();
+#endif
+#if PACKET_HAS_SLAVE
+ ao_packet_slave_stop();
+#endif
+#if HAS_PAD
+ ao_pad_disable();
+#endif
+ ao_radio_get(0xff);
+ RFST = RFST_STX;
+ ao_radio_test_on = 1;
+ }
+ } else {
+ if (ao_radio_test_on) {
+ ao_radio_idle();
+ ao_radio_put();
+ ao_radio_test_on = 0;
+#if HAS_MONITOR
+ ao_monitor_enable();
+#endif
+#if HAS_PAD
+ ao_pad_enable();
+#endif
+ }
+ }
+}
+
+static void
+ao_radio_test_cmd(void)
{
uint8_t mode = 2;
static __xdata radio_on;
{
uint8_t mode = 2;
static __xdata radio_on;
@@
-478,34
+540,19
@@
ao_radio_test(void)
mode = (uint8_t) ao_cmd_lex_u32;
}
mode++;
mode = (uint8_t) ao_cmd_lex_u32;
}
mode++;
- if ((mode & 2) && !radio_on) {
-#if HAS_MONITOR
- ao_monitor_disable();
-#endif
-#if PACKET_HAS_SLAVE
- ao_packet_slave_stop();
-#endif
- ao_radio_get(0xff);
- RFST = RFST_STX;
- radio_on = 1;
- }
+ if ((mode & 2))
+ ao_radio_test(1);
if (mode == 3) {
printf ("Hit a character to stop..."); flush();
getchar();
putchar('\n');
}
if (mode == 3) {
printf ("Hit a character to stop..."); flush();
getchar();
putchar('\n');
}
- if ((mode & 1) && radio_on) {
- ao_radio_idle();
- ao_radio_put();
- radio_on = 0;
-#if HAS_MONITOR
- ao_monitor_enable();
-#endif
- }
+ if ((mode & 1))
+ ao_radio_test(0);
}
__code struct ao_cmds ao_radio_cmds[] = {
}
__code 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" },
{ 0, NULL },
};
{ 0, NULL },
};