Contiki-NG
|
Driver implementation for the cc2538 RF transceiver. More...
Files | |
file | cc2538-rf.c |
Implementation of the cc2538 RF driver. | |
file | cc2538-rf.h |
Header file for the cc2538 RF driver. | |
Macros | |
#define | CC2538_RF_CSP_ISRXON() do { REG(RFCORE_SFR_RFST) = CC2538_RF_CSP_OP_ISRXON; } while(0) |
Send an RX ON command strobe to the CSP. | |
#define | CC2538_RF_CSP_ISTXON() do { REG(RFCORE_SFR_RFST) = CC2538_RF_CSP_OP_ISTXON; } while(0) |
Send a TX ON command strobe to the CSP. | |
#define | CC2538_RF_CSP_ISRFOFF() do { REG(RFCORE_SFR_RFST) = CC2538_RF_CSP_OP_ISRFOFF; } while(0) |
Send a RF OFF command strobe to the CSP. | |
#define | CC2538_RF_CSP_ISFLUSHRX() |
Flush the RX FIFO. | |
#define | CC2538_RF_CSP_ISFLUSHTX() |
Flush the TX FIFO. | |
Functions | |
static uint8_t | get_channel () |
Get the current operating channel. More... | |
static int8_t | set_channel (uint8_t channel) |
Set the current operating channel. More... | |
static radio_value_t | get_rssi (void) |
Reads the current signal strength (RSSI) More... | |
static int | init (void) |
PROCESS_THREAD (cc2538_rf_process, ev, data) | |
Implementation of the cc2538 RF driver process. More... | |
void | cc2538_rf_rx_tx_isr (void) |
The cc2538 RF RX/TX ISR. More... | |
void | cc2538_rf_err_isr (void) |
The cc2538 RF Error ISR. More... | |
void | cc2538_rf_set_promiscous_mode (char p) |
Turn promiscous mode on or off. More... | |
void | cc2538_rf_set_addr (uint16_t pan) |
Sets addresses and PAN identifier to the relevant RF hardware registers. More... | |
Variables | |
const struct radio_driver | cc2538_rf_driver |
The NETSTACK data structure for the cc2538 RF driver. | |
const struct radio_driver | cc2538_rf_driver |
The NETSTACK data structure for the cc2538 RF driver. | |
Driver implementation for the cc2538 RF transceiver.
void cc2538_rf_err_isr | ( | void | ) |
The cc2538 RF Error ISR.
This is the interrupt service routine for all RF errors. We acknowledge every error type and instead of trying to be smart and act differently depending on error condition, we simply reset the transceiver. RX FIFO overflow is an exception, we ignore this error since read() handles it anyway.
However, we don't want to reset within this ISR. If the error occurs while we are reading a frame out of the FIFO, trashing the FIFO in the middle of read(), would result in further errors (RX underflows).
Instead, we set a flag and poll the driver process. The process will reset the transceiver without any undesirable consequences.
Definition at line 1086 of file cc2538-rf.c.
References process_poll(), RFCORE_SFR_RFERRF, and RFCORE_SFR_RFERRF_RXOVERF.
void cc2538_rf_rx_tx_isr | ( | void | ) |
The cc2538 RF RX/TX ISR.
This is the interrupt service routine for all RF interrupts relating to RX and TX. Error conditions are handled by cc2538_rf_err_isr(). Currently, we only acknowledge the FIFOP interrupt source.
Definition at line 1059 of file cc2538-rf.c.
References process_poll(), and RFCORE_SFR_RFIRQF0.
void cc2538_rf_set_addr | ( | uint16_t | pan | ) |
Sets addresses and PAN identifier to the relevant RF hardware registers.
pan | The PAN Identifier |
Values for short and extended addresses are not needed as parameters since they exist in the linkaddr buffer in the contiki core. They are thus simply copied over from there.
void cc2538_rf_set_promiscous_mode | ( | char | p | ) |
Turn promiscous mode on or off.
p | If promiscous mode should be on (1) or off (0) |
This function turns promiscous mode on or off. In promiscous mode, every received frame is returned from the RF core. In non-promiscous mode, only broadcast frames or frames with our address as the receive address are returned from the RF core.
Definition at line 1101 of file cc2538-rf.c.
|
static |
Get the current operating channel.
Definition at line 157 of file cc2538-rf.c.
References RFCORE_XREG_FREQCTRL, and RFCORE_XREG_FREQCTRL_FREQ.
Referenced by init().
|
static |
Reads the current signal strength (RSSI)
This function reads the current RSSI on the currently configured channel.
Definition at line 236 of file cc2538-rf.c.
References CC2538_RF_CSP_ISFLUSHRX, CC2538_RF_CSP_ISRFOFF, CC2538_RF_CSP_ISRXON, NVIC_DisableIRQ(), NVIC_EnableIRQ(), RF_TX_RX_IRQn, RFCORE_SFR_MTCTRL, RFCORE_SFR_MTCTRL_LATCH_MODE, RFCORE_SFR_MTCTRL_RUN, RFCORE_SFR_MTCTRL_STATE, RFCORE_SFR_MTCTRL_SYNC, RFCORE_SFR_MTM0, RFCORE_SFR_MTM0_MTM0, RFCORE_SFR_MTM1, RFCORE_SFR_MTM1_MTM1, RFCORE_SFR_MTMOVF0, RFCORE_SFR_MTMOVF0_MTMOVF0, RFCORE_SFR_MTMOVF1, RFCORE_SFR_MTMOVF1_MTMOVF1, RFCORE_SFR_MTMOVF2, RFCORE_SFR_MTMOVF2_MTMOVF2, RFCORE_SFR_MTMSEL, RFCORE_SFR_MTMSEL_MTMOVFSEL, RFCORE_SFR_MTMSEL_MTMSEL, RFCORE_SFR_RFIRQF0, RFCORE_SFR_RFIRQF0_FIFOP, RFCORE_XREG_CCACTRL0, RFCORE_XREG_CCACTRL0_CCA_THR, RFCORE_XREG_FRMCTRL0, RFCORE_XREG_FRMCTRL0_AUTOACK, RFCORE_XREG_FRMFILT0, RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN, RFCORE_XREG_FSMSTAT0, RFCORE_XREG_FSMSTAT0_FSM_FFCTRL_STATE, RFCORE_XREG_FSMSTAT1, RFCORE_XREG_FSMSTAT1_CCA, RFCORE_XREG_FSMSTAT1_FIFOP, RFCORE_XREG_FSMSTAT1_TX_ACTIVE, RFCORE_XREG_RFIRQM0, RFCORE_XREG_RFIRQM0_FIFOP, RFCORE_XREG_RSSI, RFCORE_XREG_RSSI_RSSI_VAL, RFCORE_XREG_RSSISTAT, RFCORE_XREG_RSSISTAT_RSSI_VALID, RFCORE_XREG_RXENABLE, RFCORE_XREG_TXPOWER, and RTIMER_NOW.
Referenced by init().
|
static |
TX anti-aliasing filter bandwidth
AGC target value
Bias currents
Definition at line 471 of file cc2538-rf.c.
References CC2538_RF_CONF_RX_DMA_CHAN, CC2538_RF_CONF_RX_USE_DMA, CC2538_RF_CONF_TX_DMA_CHAN, CC2538_RF_CONF_TX_USE_DMA, CC2538_RF_CSP_ISFLUSHRX, CC2538_RF_CSP_ISFLUSHTX, CC2538_RF_CSP_ISTXON, clock_delay_usec(), get_channel(), get_rssi(), NVIC_EnableIRQ(), process_poll(), process_start(), RADIO_RX_MODE_ADDRESS_FILTER, RADIO_TX_MODE_SEND_ON_CCA, RF_ERR_IRQn, RFCORE_FFSM_EXT_ADDR0, RFCORE_SFR_RFDATA, RFCORE_XREG_AGCCTRL1, RFCORE_XREG_CCACTRL0, RFCORE_XREG_FIFOPCTRL, RFCORE_XREG_FRMCTRL0, RFCORE_XREG_FRMCTRL0_AUTOACK, RFCORE_XREG_FRMCTRL0_AUTOCRC, RFCORE_XREG_FRMFILT0, RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN, RFCORE_XREG_FSMSTAT1, RFCORE_XREG_FSMSTAT1_FIFO, RFCORE_XREG_FSMSTAT1_FIFOP, RFCORE_XREG_FSMSTAT1_SFD, RFCORE_XREG_FSMSTAT1_TX_ACTIVE, RFCORE_XREG_RFERRM, RFCORE_XREG_RFERRM_RFERRM, RFCORE_XREG_RXENABLE, RFCORE_XREG_RXENABLE_RXENMASK, RFCORE_XREG_SRCMATCH, RFCORE_XREG_TXFILTCFG, RFCORE_XREG_TXPOWER, RTIMER_NOW, set_channel(), SYS_CTRL_DCGCRFC, SYS_CTRL_RCGCRFC, SYS_CTRL_SCGCRFC, udma_channel_enable(), udma_channel_get_mode(), udma_channel_mask_set(), udma_channel_sw_request(), udma_set_channel_control_word(), udma_set_channel_dst(), udma_set_channel_src(), and udma_xfer_size.
Referenced by PROCESS_THREAD().
PROCESS_THREAD | ( | cc2538_rf_process | , |
ev | , | ||
data | |||
) |
Implementation of the cc2538 RF driver process.
This process is started by init(). It simply sits there waiting for an event. Upon frame reception, the RX ISR will poll this process. Subsequently, the contiki core will generate an event which will call this process so that the received frame can be picked up from the RF RX FIFO
Definition at line 1008 of file cc2538-rf.c.
References init(), mac_driver::input, radio_driver::off, radio_driver::on, packetbuf_clear(), packetbuf_dataptr(), packetbuf_set_datalen(), PACKETBUF_SIZE, PROCESS_BEGIN, PROCESS_END, PROCESS_YIELD_UNTIL, radio_driver::read, RFCORE_XREG_FSMSTAT0, and RFCORE_XREG_FSMSTAT0_FSM_FFCTRL_STATE.
Referenced by ble_mac_ipsp_evt_handler_irq(), button_hal_init(), cc2420_interrupt(), coap_sendto(), resolv_get_hostname(), rf_ble_beacon_single(), rf_core_primary_mode_restore(), rtcc_date_increment_seconds(), serial_line_input_byte(), simple_udp_register(), slip_send(), soc_trng_rand_asynchronous(), stack_check_get_reserved_size(), tcpip_poll_tcp(), tsch_disassociate(), and usb_serial_writeb().
|
static |
Set the current operating channel.
channel | The desired channel as a value in [11,26] |
Definition at line 172 of file cc2538-rf.c.
References addr, RFCORE_FFSM_PAN_ID0, RFCORE_FFSM_PAN_ID1, RFCORE_FFSM_SHORT_ADDR0, RFCORE_FFSM_SHORT_ADDR1, RFCORE_XREG_FREQCTRL, RFCORE_XREG_FSMSTAT0, and RFCORE_XREG_FSMSTAT0_FSM_FFCTRL_STATE.
Referenced by init().