Reincarnate the sensinode/cc2430 port
This commit is contained in:
parent
c78b5bad5c
commit
b7674c3636
114 changed files with 10044 additions and 3068 deletions
|
@ -2,11 +2,12 @@
|
|||
* \file
|
||||
* CC2430 RF driver
|
||||
* \author
|
||||
* Zach Shelby <zach@sensinode.com>
|
||||
* Zach Shelby <zach@sensinode.com> (Original)
|
||||
* George Oikonomou - <oikonomou@users.sourceforge.net>
|
||||
* (recent updates for the contiki cc2430 port)
|
||||
*
|
||||
* Non-bankable code for cc2430 rf driver.
|
||||
* Interrupt routine and code called through function pointers
|
||||
* must be placed into the HOME bank.
|
||||
* Interrupt routines must be placed into the HOME bank.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -23,6 +24,7 @@
|
|||
|
||||
#include "net/packetbuf.h"
|
||||
#include "net/rime/rimestats.h"
|
||||
#include "net/netstack.h"
|
||||
#define DEBUG 0
|
||||
#if DEBUG
|
||||
#define PRINTF(...) printf(__VA_ARGS__)
|
||||
|
@ -46,10 +48,9 @@
|
|||
uint8_t rf_error = 0;
|
||||
#endif
|
||||
|
||||
PROCESS_NAME(cc2430_rf_process);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(cc2430_rf_process, "CC2430 RF driver");
|
||||
|
||||
#if !SHORTCUTS_CONF_NETSTACK
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* RF interrupt service routine.
|
||||
|
@ -59,29 +60,27 @@ void
|
|||
cc2430_rf_ISR( void ) __interrupt (RF_VECTOR)
|
||||
{
|
||||
EA = 0;
|
||||
if(RFIF & IRQ_TXDONE) {
|
||||
RF_TX_LED_OFF();
|
||||
RFIF &= ~IRQ_TXDONE;
|
||||
cc2430_rf_command(ISFLUSHTX);
|
||||
}
|
||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||
/*
|
||||
* We only vector here if RFSTATUS.FIFOP goes high.
|
||||
* Just double check the flag.
|
||||
*/
|
||||
if(RFIF & IRQ_FIFOP) {
|
||||
if(RFSTATUS & FIFO) {
|
||||
RF_RX_LED_ON();
|
||||
/* Poll the RF process which calls cc2430_rf_read() */
|
||||
process_poll(&cc2430_rf_process);
|
||||
} else {
|
||||
cc2430_rf_command(ISFLUSHRX);
|
||||
cc2430_rf_command(ISFLUSHRX);
|
||||
RFIF &= ~IRQ_FIFOP;
|
||||
}
|
||||
}
|
||||
S1CON &= ~(RFIF_0 | RFIF_1);
|
||||
|
||||
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
|
||||
EA = 1;
|
||||
}
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if CC2430_RFERR_INTERRUPT
|
||||
/**
|
||||
* RF error interrupt service routine.
|
||||
*
|
||||
* Turned off by default, can be turned on in contiki-conf.h
|
||||
*/
|
||||
void
|
||||
cc2430_rf_error_ISR( void ) __interrupt (RFERR_VECTOR)
|
||||
|
@ -99,57 +98,5 @@ cc2430_rf_error_ISR( void ) __interrupt (RFERR_VECTOR)
|
|||
RF_TX_LED_OFF();
|
||||
EA = 1;
|
||||
}
|
||||
|
||||
void (* receiver_callback)(const struct radio_driver *);
|
||||
|
||||
void
|
||||
cc2430_rf_set_receiver(void (* recv)(const struct radio_driver *))
|
||||
{
|
||||
receiver_callback = recv;
|
||||
}
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* non-banked functions called through function pointers then call banked code
|
||||
*/
|
||||
int
|
||||
cc2430_rf_off(void)
|
||||
{
|
||||
return cc2430_rf_rx_disable();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
cc2430_rf_on(void)
|
||||
{
|
||||
return cc2430_rf_rx_enable();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
cc2430_rf_send(void *payload, unsigned short payload_len)
|
||||
{
|
||||
return cc2430_rf_send_b(payload, payload_len);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
cc2430_rf_read(void *buf, unsigned short bufsize)
|
||||
{
|
||||
return cc2430_rf_read_banked(buf, bufsize);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(cc2430_rf_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
while(1) {
|
||||
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
|
||||
|
||||
if(receiver_callback != NULL) {
|
||||
PRINTF("cc2430_rf_process: calling receiver callback\n");
|
||||
receiver_callback(&cc2430_rf_driver);
|
||||
} else {
|
||||
PRINTF("cc2430_rf_process: no receiver callback\n");
|
||||
cc2430_rf_command(ISFLUSHRX);
|
||||
}
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue