![]() |
Contiki-NG
|
Driver implementation for the cc2538 RF transceiver. More...
Files | |
| file | arch/cpu/cc2538/dev/cc2538-rf.c |
| Implementation of the cc2538 RF driver. | |
| file | arch/cpu/cc2538/dev/cc2538-rf.h |
| Header file for the cc2538 RF driver. | |
Functions | |
| static int | on (void) |
| static int | off (void) |
| static uint8_t | get_channel () |
| Get the current operating channel. | |
| static void | set_channel (uint8_t channel) |
| Set the current operating channel. | |
| static radio_value_t | get_pan_id (void) |
| static void | set_pan_id (uint16_t pan) |
| static radio_value_t | get_short_addr (void) |
| static void | set_short_addr (uint16_t addr) |
| static radio_value_t | get_rssi (void) |
| Reads the current signal strength (RSSI). | |
| static void | get_iq_lsbs (radio_value_t *value) |
| Reads the current I/Q data of the received signal. | |
| static void | mac_timer_init (void) |
| static void | set_poll_mode (uint8_t enable) |
| static uint32_t | get_sfd_timestamp (void) |
| static void | set_test_mode (uint8_t enable, uint8_t modulated) |
| static int | init (void) |
| static int | prepare (const void *payload, unsigned short payload_len) |
| static int | transmit (unsigned short transmit_len) |
| static int | read (void *buf, unsigned short bufsize) |
| static radio_result_t | get_object (radio_param_t param, void *dest, size_t size) |
| static radio_result_t | set_object (radio_param_t param, const void *src, size_t size) |
| PROCESS_THREAD (cc2538_rf_process, ev, data) | |
| Implementation of the cc2538 RF driver process. | |
| void | cc2538_rf_rx_tx_isr (void) |
| The cc2538 RF RX/TX ISR. | |
| void | cc2538_rf_err_isr (void) |
| The cc2538 RF Error ISR. | |
| void | cc2538_rf_set_addr (uint16_t pan) |
| Sets addresses and PAN identifier to the relevant RF hardware registers. | |
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.
< RF error interrupt flags
< RF error interrupt flags
< RX FIFO overflowed
< RF error interrupt flags
Definition at line 1232 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.
< RF interrupt flags
Definition at line 1205 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.
|
static |
Get the current operating channel.
Definition at line 167 of file cc2538-rf.c.
|
static |
Reads the current I/Q data of the received signal.
| value | The least significant bit (LSB) of the I coordinate and the LSB of the Q coordinate are concatenated and stored here. |
If not done already, this function first enables the RX mode and waits for the RSSI_VALID bit to go high. Hence, this function should only be called at start up or by the MAC protocol to avoid conflicts.
Definition at line 270 of file cc2538-rf.c.
References off(), on(), RFCORE_XREG_FSMSTAT0, RFCORE_XREG_FSMSTAT0_FSM_FFCTRL_STATE, RFCORE_XREG_RFRND, RFCORE_XREG_RFRND_IRND, RFCORE_XREG_RFRND_QRND, RFCORE_XREG_RSSISTAT, RFCORE_XREG_RSSISTAT_RSSI_VALID, and value().
|
static |
< Local address information
Definition at line 1069 of file cc2538-rf.c.
References get_sfd_timestamp(), RADIO_PARAM_64BIT_ADDR, RADIO_PARAM_LAST_PACKET_TIMESTAMP, RADIO_RESULT_INVALID_VALUE, RADIO_RESULT_NOT_SUPPORTED, RADIO_RESULT_OK, RFCORE_FFSM_EXT_ADDR0, and tsch_timeslot_timing_us_10000.
|
static |
< Local address information
< Local address information
Definition at line 202 of file cc2538-rf.c.
References RFCORE_FFSM_PAN_ID0, and RFCORE_FFSM_PAN_ID1.
|
static |
Reads the current signal strength (RSSI).
This function reads the current RSSI on the currently configured channel.
Definition at line 235 of file cc2538-rf.c.
References off(), on(), RFCORE_XREG_FSMSTAT0, RFCORE_XREG_FSMSTAT0_FSM_FFCTRL_STATE, and RFCORE_XREG_RSSI.
|
static |
< MAC Timer multiplex select
< MAC Timer multiplex select
< MTM register select
< MAC Timer control register
< OVF counter latch mode
< MAC Timer MUX register 0
< Register[7:0]
< MAC Timer MUX register 1
< Register[15:8]
< MAC Timer multiplex select
< MAC Timer multiplex select
< MTMOVF register select
< MAC Timer MUX overflow 0
< Register[7:0]
< MAC Timer MUX overflow 1
< Register[15:8]
< MAC Timer MUX overflow 2
< Register[23:16]
< MAC Timer multiplex select
< MAC Timer multiplex select
< MTM register select
< MAC Timer control register
< OVF counter latch mode
< MAC Timer MUX register 0
< Register[7:0]
< MAC Timer MUX register 1
< Register[15:8]
< MAC Timer multiplex select
< MAC Timer multiplex select
< MTMOVF register select
< MAC Timer MUX overflow 0
< Register[7:0]
< MAC Timer MUX overflow 1
< Register[15:8]
< MAC Timer MUX overflow 2
< Register[23:16]
Definition at line 414 of file cc2538-rf.c.
References RFCORE_SFR_MTCTRL, RFCORE_SFR_MTCTRL_LATCH_MODE, 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, and RTIMER_NOW.
Referenced by get_object().
|
static |
< Local address information
< Local address information
Definition at line 215 of file cc2538-rf.c.
References RFCORE_FFSM_SHORT_ADDR0, and RFCORE_FFSM_SHORT_ADDR1.
|
static |
TX anti-aliasing filter bandwidth
AGC target value
Bias currents
Tune frequency calibration
< TX/RX FIFO data
< TX/RX FIFO data
Definition at line 556 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, iq_seeder_seed(), process_start(), RADIO_SHR_SEARCH_EN, RF_ERR_IRQn, 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_FSCAL1, RFCORE_XREG_RFERRM, RFCORE_XREG_RFERRM_RFERRM, RFCORE_XREG_SRCMATCH, RFCORE_XREG_TXFILTCFG, RFCORE_XREG_TXPOWER, set_channel(), set_poll_mode(), SYS_CTRL_DCGCRFC, SYS_CTRL_RCGCRFC, SYS_CTRL_SCGCRFC, udma_channel_mask_set(), udma_set_channel_dst(), and udma_set_channel_src().
Referenced by PROCESS_THREAD(), resolv_query(), and uip_nameserver_update().
|
static |
< MAC Timer control register
< Timer start/stop timing
< MAC Timer control register
< Timer start/stop
< MAC Timer control register
< State of MAC Timer
< MAC Timer control register
< Timer start/stop
< MAC Timer control register
< State of MAC Timer
< MAC Timer control register
< Timer start/stop timing
< MAC Timer control register
< Timer start/stop
< MAC Timer control register
< State of MAC Timer
Definition at line 368 of file cc2538-rf.c.
References RFCORE_SFR_MTCTRL, RFCORE_SFR_MTCTRL_RUN, RFCORE_SFR_MTCTRL_STATE, and RFCORE_SFR_MTCTRL_SYNC.
Referenced by set_poll_mode().
|
static |
< RF CSMA-CA/strobe processor
< RF CSMA-CA/strobe processor
Definition at line 533 of file cc2538-rf.c.
References CC2538_RF_CSP_ISFLUSHRX, CC2538_RF_CSP_ISRFOFF, RFCORE_XREG_FSMSTAT1, RFCORE_XREG_FSMSTAT1_FIFOP, RFCORE_XREG_FSMSTAT1_TX_ACTIVE, and RFCORE_XREG_RXENABLE.
Referenced by get_iq_lsbs(), get_rssi(), get_rssi(), PROCESS_THREAD(), set_channel(), set_test_mode(), and transmit().
|
static |
< RF CSMA-CA/strobe processor
< RF CSMA-CA/strobe processor
Definition at line 517 of file cc2538-rf.c.
References CC2538_RF_CSP_ISFLUSHRX, and CC2538_RF_CSP_ISRXON.
Referenced by get_iq_lsbs(), get_rssi(), get_rssi(), prepare(), PROCESS_THREAD(), set_channel(), set_test_mode(), and transmit().
|
static |
< RF CSMA-CA/strobe processor
< TX/RX FIFO data
< Arbitration size 128 Transfers
< Auto-Request
< Source size 8 bit
< Destination size 8 bit
< Source address increment 8 bit
< Dst address no increment
< TX/RX FIFO data
Definition at line 648 of file cc2538-rf.c.
References CC2538_RF_CONF_TX_DMA_CHAN, CC2538_RF_CONF_TX_USE_DMA, CC2538_RF_CSP_ISFLUSHTX, on(), RADIO_TX_ERR, RFCORE_SFR_RFDATA, RFCORE_XREG_FSMSTAT1, RFCORE_XREG_FSMSTAT1_TX_ACTIVE, udma_channel_enable(), udma_channel_sw_request(), udma_set_channel_control_word(), udma_set_channel_src(), and udma_xfer_size.
| 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 1155 of file cc2538-rf.c.
References init(), off(), on(), packetbuf_clear(), packetbuf_dataptr(), packetbuf_set_datalen(), PACKETBUF_SIZE, PROCESS_BEGIN, PROCESS_END, PROCESS_YIELD_UNTIL, read(), RFCORE_XREG_FSMSTAT0, and RFCORE_XREG_FSMSTAT0_FSM_FFCTRL_STATE.
|
static |
< TX/RX FIFO data
< RF CSMA-CA/strobe processor
< RF CSMA-CA/strobe processor
< RF CSMA-CA/strobe processor
< Arbitration size 128 Transfers
< Auto-Request
< Source size 8 bit
< Destination size 8 bit
< Source address no increment
< Dst address increment 8 bit
< TX/RX FIFO data
< TX/RX FIFO data
< TX/RX FIFO data
< RF CSMA-CA/strobe processor
< RF CSMA-CA/strobe processor
Definition at line 779 of file cc2538-rf.c.
References CC2538_RF_CONF_RX_DMA_CHAN, CC2538_RF_CONF_RX_USE_DMA, CC2538_RF_CSP_ISFLUSHRX, process_poll(), RFCORE_SFR_RFDATA, RFCORE_XREG_FSMSTAT1, RFCORE_XREG_FSMSTAT1_FIFO, RFCORE_XREG_FSMSTAT1_FIFOP, udma_channel_enable(), udma_channel_get_mode(), udma_channel_sw_request(), udma_set_channel_control_word(), udma_set_channel_dst(), and udma_xfer_size.
Referenced by cfs_read(), and PROCESS_THREAD().
|
static |
Set the current operating channel.
| channel | The desired channel as a value in [11,26] |
Definition at line 177 of file cc2538-rf.c.
References off(), on(), RFCORE_XREG_FREQCTRL, RFCORE_XREG_FSMSTAT0, and RFCORE_XREG_FSMSTAT0_FSM_FFCTRL_STATE.
Referenced by init().
|
static |
< Local address information
Definition at line 1110 of file cc2538-rf.c.
References RADIO_PARAM_64BIT_ADDR, RADIO_RESULT_INVALID_VALUE, RADIO_RESULT_NOT_SUPPORTED, RADIO_RESULT_OK, and RFCORE_FFSM_EXT_ADDR0.
|
static |
< Local address information
< Local address information
Definition at line 208 of file cc2538-rf.c.
References RFCORE_FFSM_PAN_ID0, and RFCORE_FFSM_PAN_ID1.
|
static |
< RF interrupt flags
< RX FIFO exceeded threshold
Definition at line 382 of file cc2538-rf.c.
References mac_timer_init(), RF_TX_RX_IRQn, RFCORE_SFR_RFIRQF0, RFCORE_SFR_RFIRQF0_FIFOP, RFCORE_XREG_RFIRQM0, and RFCORE_XREG_RFIRQM0_FIFOP.
Referenced by init().
|
static |
< Local address information
< Local address information
Definition at line 221 of file cc2538-rf.c.
References addr, RFCORE_FFSM_SHORT_ADDR0, and RFCORE_FFSM_SHORT_ADDR1.
|
static |
< RF CSMA-CA/strobe processor
< RF CSMA-CA/strobe processor
Definition at line 448 of file cc2538-rf.c.
References CC2538_RF_CSP_ISRFOFF, CC2538_RF_CSP_ISTXON, off(), on(), RADIO_PARAM_POWER_MODE, RADIO_POWER_MODE_CARRIER_ON, RADIO_POWER_MODE_ON, RFCORE_XREG_FRMCTRL0, and RFCORE_XREG_MDMTEST1.
|
static |
< RF CSMA-CA/strobe processor
< RF CSMA-CA/strobe processor
Definition at line 708 of file cc2538-rf.c.
References CC2538_RF_CSP_ISFLUSHTX, CC2538_RF_CSP_ISTXON, clock_delay_usec(), off(), on(), RADIO_TX_COLLISION, RADIO_TX_ERR, RADIO_TX_OK, RFCORE_XREG_FSMSTAT1, RFCORE_XREG_FSMSTAT1_SFD, RFCORE_XREG_FSMSTAT1_TX_ACTIVE, and RTIMER_NOW.
Referenced by compower_accumulate().