Contiki-NG
Modules | Files | Data Structures | Typedefs | Functions

Different flavours of chips of the CC13xx/CC26xx family have different radio capability. More...

Modules

 CC13xx Prop mode driver
 
 CC13xx/CC26xx BLE driver
 
 CC13xx/CC26xx IEEE mode driver
 
 IEEE 802.15.4g Frequency Bands and Modes
 
 RF Switch
 Header file for RF switch support.
 

Files

file  rf-core.c
 Implementation of the CC13xx/CC26xx RF core driver.
 
file  rf-core.h
 Header file for the CC13xx/CC26xx RF core driver.
 

Data Structures

struct  rf_core_primary_mode_s
 A data strcuture representing the radio's primary mode of operation. More...
 

Typedefs

typedef struct rf_core_primary_mode_s rf_core_primary_mode_t
 A data strcuture representing the radio's primary mode of operation. More...
 

Functions

uint8_t rf_core_is_accessible (void)
 Check whether the RF core is accessible. More...
 
uint_fast8_t rf_core_send_cmd (uint32_t cmd, uint32_t *status)
 Sends a command to the RF core. More...
 
uint_fast8_t rf_core_wait_cmd_done (void *cmd)
 Block and wait for a Radio op to complete. More...
 
int rf_core_power_up (void)
 Turn on power to the RFC and boot it. More...
 
uint8_t rf_core_start_rat (void)
 Start the CM0 RAT. More...
 
uint8_t rf_core_stop_rat (void)
 Stop the CM0 RAT synchronously. More...
 
void rf_core_power_down (void)
 Disable RFCORE clock domain in the MCU VD and turn off the RFCORE PD.
 
uint8_t rf_core_set_modesel (void)
 Initialise RF APIs in the RF core. More...
 
uint8_t rf_core_boot (void)
 Boot the RF Core. More...
 
uint8_t rf_core_restart_rat (void)
 Restart the CM0 RAT. More...
 
void rf_core_setup_interrupts (void)
 Setup RF core interrupts.
 
void rf_core_cmd_done_en (bool fg)
 Enable interrupt on command done. More...
 
void rf_core_cmd_done_dis (void)
 Disable the LAST_CMD_DONE and LAST_FG_CMD_DONE interrupts. More...
 
rfc_radioOp_t * rf_core_get_last_radio_op (void)
 Returns a pointer to the most recent proto-dependent Radio Op. More...
 
void rf_core_init_radio_op (rfc_radioOp_t *buf, uint16_t len, uint16_t command)
 Prepare a buffer to host a Radio Op. More...
 
void rf_core_primary_mode_register (const rf_core_primary_mode_t *mode)
 Register a primary mode for radio operation. More...
 
void rf_core_primary_mode_abort (void)
 Abort the currently running primary radio op.
 
uint8_t rf_core_primary_mode_restore (void)
 Abort the currently running primary radio op.
 
uint8_t rf_core_rat_init (void)
 Initialize the RAT to RTC conversion machinery.
 
uint8_t rf_core_check_rat_overflow (void)
 Check if RAT overflow has occured and increment the overflow counter if so.
 
uint32_t rf_core_convert_rat_to_rtimer (uint32_t rat_timestamp)
 Convert from RAT timestamp to rtimer ticks.
 

Detailed Description

Different flavours of chips of the CC13xx/CC26xx family have different radio capability.

For example, the CC2650 can operate in IEEE 802.15.4 mode at 2.4GHz, but it can also operate in BLE mode. The CC1310 only supports sub-ghz mode.

However, there are many radio functionalities that are identical across all chips. The rf-core driver provides support for this common functionality

Typedef Documentation

◆ rf_core_primary_mode_t

A data strcuture representing the radio's primary mode of operation.

The CC13xx / CC26xx radio supports up to potentially 3 modes: IEEE, Prop and BLE. Within Contiki, we assume that the radio is by default in one of IEEE or Prop in order to support standard 6LoWPAN / .15.4 operation. The BLE mode interrupts this so called "primary" mode in order to send BLE adv messages. Once BLE is done advertising, we need to be able to restore the previous .15.4 mode. Unfortunately, the only way this can be done with NETSTACK_RADIO API is by fully power-cycling the radio, which is something we do not want to do.

Thus, we declare a secondary data structure for primary mode drivers (IEEE or Prop). We use this data structure to issue "soft off" and "back on" commands. Soft off in this context means stopping RX (e.g. the respective IEEE RX operation), but without shutting down the RF core (which is what NETSTACK_RADIO.off() would have done). We then remember what mode we were using in order to be able to re-enter RX mode for this mode.

A NETSTACK_RADIO driver will declare those two functions somewhere within its module of implementation. During its init() routine, it will notify the RF core module so that the latter can abort and restore operations.

Function Documentation

◆ rf_core_boot()

uint8_t rf_core_boot ( void  )

Boot the RF Core.

Returns
RF_CORE_CMD_OK or RF_CORE_CMD_ERROR

This function will perform the CM0 boot sequence. It will first power it up and then start the RAT. If a patch is required, then the mode driver must not call this function and perform the sequence manually, applying patches after boot and before calling rf_core_start_rat().

The function will return RF_CORE_CMD_ERROR if any of those steps fails. If the boot sequence fails to complete, the RF Core will be powered down.

Definition at line 438 of file rf-core.c.

References rf_core_power_up().

◆ rf_core_cmd_done_dis()

void rf_core_cmd_done_dis ( void  )

Disable the LAST_CMD_DONE and LAST_FG_CMD_DONE interrupts.

This is used within TX routines after TX has completed

See also
rf_core_cmd_done_en()

Definition at line 527 of file rf-core.c.

◆ rf_core_cmd_done_en()

void rf_core_cmd_done_en ( bool  fg)

Enable interrupt on command done.

Parameters
fgset true to enable irq on foreground command done and false for background commands or if not in ieee mode.

This is used within TX routines in order to be able to sleep the CM3 and wake up after TX has finished

See also
rf_core_cmd_done_dis()

Definition at line 513 of file rf-core.c.

◆ rf_core_get_last_radio_op()

rfc_radioOp_t * rf_core_get_last_radio_op ( void  )

Returns a pointer to the most recent proto-dependent Radio Op.

Returns
The pointer

The RF Core driver will remember the most recent proto-dependent Radio OP issued, so that other modules can inspect its type and state at a subsequent stage. The assumption is that those commands will be issued by a function that will then return. The following commands will be "remembered"

  • All BLE Radio Ops (0x18nn)
  • All Prop Radio Ops (0x38nn)
  • IEEE BG Radio Ops (0x28nn)

The following commands are assumed to be executed synchronously and will thus not be remembered by the core and not returned by this function:

  • Direct commands
  • Proto-independent commands (including Radio Ops and Immediate ones)
  • IEEE FG Radio Ops (0x2Cxx)

This assumes that all commands will be sent to the radio using rf_core_send_cmd()

Definition at line 534 of file rf-core.c.

◆ rf_core_init_radio_op()

void rf_core_init_radio_op ( rfc_radioOp_t *  buf,
uint16_t  len,
uint16_t  command 
)

Prepare a buffer to host a Radio Op.

Parameters
bufA pointer to the buffer that will host the Radio Op
lenThe buffer's length
commandThe command ID

The caller is responsible to allocate the buffer

This function will not check whether the buffer is large enough to hold the command. This is the caller's responsibility

This function will wipe out the buffer's contents.

Definition at line 540 of file rf-core.c.

Referenced by rf_core_start_rat(), and rf_core_stop_rat().

◆ rf_core_is_accessible()

uint8_t rf_core_is_accessible ( void  )

Check whether the RF core is accessible.

Return values
RF_CORE_ACCESSIBLEThe core is powered and ready for access
RF_CORE_NOT_ACCESSIBLEThe core is not ready

If this function returns RF_CORE_NOT_ACCESSIBLE, rf_core_power_up() must be called before any attempt to access the core.

Definition at line 145 of file rf-core.c.

Referenced by rf_is_on().

◆ rf_core_power_up()

int rf_core_power_up ( void  )

Turn on power to the RFC and boot it.

Returns
RF_CORE_CMD_OK or RF_CORE_CMD_ERROR

Definition at line 263 of file rf-core.c.

Referenced by rf_core_boot().

◆ rf_core_primary_mode_register()

void rf_core_primary_mode_register ( const rf_core_primary_mode_t mode)

Register a primary mode for radio operation.

Parameters
modeA pointer to the struct representing the mode

A normal NESTACK_RADIO driver will normally register itself by calling this function during its own init().

See also
rf_core_primary_mode_t

Definition at line 549 of file rf-core.c.

◆ rf_core_restart_rat()

uint8_t rf_core_restart_rat ( void  )

Restart the CM0 RAT.

Returns
RF_CORE_CMD_OK or RF_CORE_CMD_ERROR

This function restarts the CM0 RAT and therefore resynchornizes it with RTC. To achieve good timing accuracy, it should be called periodically.

Definition at line 460 of file rf-core.c.

References rf_core_stop_rat().

◆ rf_core_send_cmd()

uint_fast8_t rf_core_send_cmd ( uint32_t  cmd,
uint32_t *  status 
)

Sends a command to the RF core.

Parameters
cmdThe command value or a pointer to a command buffer
statusA pointer to a variable which will hold the status
Returns
RF_CORE_CMD_OK or RF_CORE_CMD_ERROR

This function supports all three types of command (Radio OP, immediate and direct)

For immediate and Radio OPs, cmd is a pointer to the data structure containing the command and its parameters. This data structure must be 4-byte aligned.

For direct commands, cmd contains the value of the command alongside its parameters. This value will be written to CMDSTA verbatim, so the command ID must be in the 16 high bits, and the 2 LS bits must be set to 01 by the caller.

The caller is responsible of allocating and populating cmd for Radio OP and immediate commands

The caller is responsible for allocating status

For immediate commands and radio Ops, this function will set the command's status field to RF_CORE_RADIO_OP_STATUS_IDLE before sending it to the RF

Definition at line 154 of file rf-core.c.

Referenced by rf_cmd_ieee_rx(), and rf_core_stop_rat().

◆ rf_core_set_modesel()

uint8_t rf_core_set_modesel ( void  )

Initialise RF APIs in the RF core.

Returns
RF_CORE_CMD_OK or RF_CORE_CMD_ERROR

Depending on chip family and capability, this function will set the correct value to PRCM.RFCMODESEL

Definition at line 410 of file rf-core.c.

◆ rf_core_start_rat()

uint8_t rf_core_start_rat ( void  )

Start the CM0 RAT.

Returns
RF_CORE_CMD_OK or RF_CORE_CMD_ERROR

This function must be called each time the CM0 boots. The boot sequence can be performed automatically by calling rf_core_boot() if patches are not required. If patches are required then the patches must be applied after power up and before calling this function.

Definition at line 312 of file rf-core.c.

References rf_core_init_radio_op().

◆ rf_core_stop_rat()

uint8_t rf_core_stop_rat ( void  )

Stop the CM0 RAT synchronously.

Returns
RF_CORE_CMD_OK or RF_CORE_CMD_ERROR

This function is not strictly necessary, but through calling it it's possibly to learn the RAT / RTC offset, which useful to get accurate radio timestamps.

Definition at line 340 of file rf-core.c.

References rf_core_init_radio_op(), and rf_core_send_cmd().

Referenced by rf_core_restart_rat().

◆ rf_core_wait_cmd_done()

uint_fast8_t rf_core_wait_cmd_done ( void *  cmd)

Block and wait for a Radio op to complete.

Parameters
cmdA pointer to any command's structure
Return values
RF_CORE_CMD_OKthe command completed with status _DONE_OK
RF_CORE_CMD_ERRORTimeout exceeded or the command completed with status _DONE_xxx (e.g. RF_CORE_RADIO_OP_STATUS_DONE_TIMEOUT)

Definition at line 220 of file rf-core.c.