This is a Hardware Abstraction Layer for IEEE802.15.4 compatible radios. More...
This is a Hardware Abstraction Layer for IEEE802.15.4 compatible radios.
Data Structures | |
struct | ieee802154_csma_be_t |
CSMA-CA exponential backoff parameters. More... | |
struct | ieee802154_rx_info_t |
RX information associated to a frame. More... | |
struct | ieee802154_tx_info_t |
TX information of the last transmitted frame. More... | |
struct | ieee802154_dev |
the IEEE802.15.4 device descriptor More... | |
struct | ieee802154_phy_conf_t |
Holder of the PHY configuration. More... | |
struct | ieee802154_radio_ops |
Radio ops struct declaration. More... | |
Macros | |
#define | IEEE802154_RF_CAPS_PHY_MASK |
Bit-mask for PHY modes capabilities. | |
Typedefs | |
typedef struct ieee802154_radio_ops | ieee802154_radio_ops_t |
Forward declaration of the radio ops structure. | |
typedef struct ieee802154_dev | ieee802154_dev_t |
Forward declaration of the IEEE802.15.4 device descriptor. | |
typedef void(* | ieee802154_cb_t) (ieee802154_dev_t *dev, ieee802154_trx_ev_t status) |
Prototype of the IEEE802.15.4 device event callback. | |
#define IEEE802154_RF_CAPS_PHY_MASK |
Bit-mask for PHY modes capabilities.
typedef void(* ieee802154_cb_t) (ieee802154_dev_t *dev, ieee802154_trx_ev_t status) |
typedef struct ieee802154_dev ieee802154_dev_t |
typedef struct ieee802154_radio_ops ieee802154_radio_ops_t |
enum ieee802154_af_cmd_t |
Address filter command.
Enumerator | |
---|---|
IEEE802154_AF_SHORT_ADDR | Set short IEEE 802.15.4 address (network_uint16_t) |
IEEE802154_AF_EXT_ADDR | Set extended IEEE 802.15.4 address (eui64_t) |
IEEE802154_AF_PANID | Set PAN ID (uint16_t) |
IEEE802154_AF_PAN_COORD | Set device as PAN coordinator (bool) |
IEEE802.15.4 CCA modes.
Frame Filter mode.
Enumerator | |
---|---|
IEEE802154_FILTER_ACCEPT | accept all valid frames that match address filter configuration |
IEEE802154_FILTER_ACK_ONLY | accept only ACK frames
|
IEEE802154_FILTER_PROMISC | accept all valid frames
|
IEEE802154_FILTER_SNIFFER | accept all frames, regardless of FCS
|
enum ieee802154_hal_op_t |
enum ieee802154_rf_caps_t |
IEEE802.15.4 Radio capabilities.
These flags represent the hardware capabilities of a given device.
Enumerator | |
---|---|
IEEE802154_CAP_FRAME_RETRANS | the device supports frame retransmissions with CSMA-CA The device supports sending with CSMA-CA and retransmissions. If the CSMA-CA fails, the device reports a TX_STATUS_MEDIUM_BUSY when calling ieee802154_radio_confirm_transmit. In case CSMA-CA succeeds and the ACK frame is expected, the device reports a TX_STATUS_SUCCESS if the ACK frame is received during any retransmission attempt. Otherwise, it reports a TX_STATUS_NO_ACK ACK frames are not indicated to the upper layer.
|
IEEE802154_CAP_AUTO_CSMA | the device supports Auto CSMA-CA The device supports performing CSMA-CA before transmitting a frame. If CSMA-CA procedure succeeds, the device sends the frame and reports a TX_STATUS_SUCCESS when calling ieee802154_radio_confirm_transmit. If it fails, the device reports TX_STATUS_MEDIUM_BUSY. |
IEEE802154_CAP_IRQ_ACK_TIMEOUT | the device support ACK timeout interrupt The device will automatically attempt to receive and handle the ACK frame if expected. If the ACK frame is not received, the device reports TX_STATUS_NO_ACK when calling ieee802154_radio_confirm_transmit. Otherwise, it reports TX_STATUS_SUCCESS. The ACK frame is not indicated to the upper layer. |
IEEE802154_CAP_24_GHZ | the device supports the IEEE802.15.4 2.4 GHz band It's assumed that IEEE802154_CAP_IRQ_TX_DONE is present. |
IEEE802154_CAP_SUB_GHZ | the device support the IEEE802.15.4 Sub GHz band |
IEEE802154_CAP_IRQ_CRC_ERROR | the device reports reception off frames with invalid CRC. |
IEEE802154_CAP_IRQ_TX_DONE | the device reports when the transmission is done |
IEEE802154_CAP_IRQ_RX_START | the device reports the start of a frame (SFD) when received. |
IEEE802154_CAP_IRQ_TX_START | the device reports the start of a frame (SFD) was sent. |
IEEE802154_CAP_IRQ_CCA_DONE | the device reports the end of the CCA procedure |
IEEE802154_CAP_FRAME_RETRANS_INFO | the device provides the number of retransmissions It's assumed that IEEE802154_CAP_FRAME_RETRANS is present. |
IEEE802154_CAP_REG_RETENTION | the device retains all register values when off. |
IEEE802154_CAP_PHY_BPSK | Binary Phase Shift Keying PHY mode. |
IEEE802154_CAP_PHY_ASK | Amplitude-Shift Keying PHY mode. |
IEEE802154_CAP_PHY_OQPSK | Offset Quadrature Phase-Shift Keying. |
IEEE802154_CAP_PHY_MR_OQPSK | Multi-Rate Offset Quadrature Phase-Shift Keying PHY mode. |
IEEE802154_CAP_PHY_MR_OFDM | Multi-Rate Orthogonal Frequency-Division Multiplexing PHY mode. |
IEEE802154_CAP_PHY_MR_FSK | Multi-Rate Frequency Shift Keying PHY mode. |
IEEE802154_CAP_SRC_ADDR_MATCH | the device supports source address match table. A Source Address Match table contains source addresses with pending data. When a coordinator device receives an IEEE 802.15.4 Data Request command from a child node, the Frame Pending bit of the ACK is set if the source address matches one from the table. |
Source Address Match commands.
Enumerator | |
---|---|
IEEE802154_SRC_MATCH_EN | Enable or disable source address match. Enabling it sets the frame pending to all ACK frames in response to a Data Request command (if the radio doesn't support Source Address Matching) or to a specific address in the Source Address Matching table |
IEEE802154_SRC_MATCH_SHORT_ADD | Add a short address to entry. This command should only be implemented if IEEE802154_CAP_SRC_ADDR_MATCH is available. |
IEEE802154_SRC_MATCH_SHORT_CLEAR | Clear short address from entry. This command should only be implemented if IEEE802154_CAP_SRC_ADDR_MATCH is available. |
IEEE802154_SRC_MATCH_EXT_ADD | Add a extended address to entry. This command should only be implemented if IEEE802154_CAP_SRC_ADDR_MATCH is available. |
IEEE802154_SRC_MATCH_EXT_CLEAR | Clear extended address from entry. This command should only be implemented if IEEE802154_CAP_SRC_ADDR_MATCH is available. |
enum ieee802154_trx_ev_t |
IEEE802.15.4 Radio HAL events.
To follow the IEEE802.15.4 convention, an event that responds to a Request is a confirmation (Confirm). Otherwise an Indication.
Enumerator | |
---|---|
IEEE802154_RADIO_INDICATION_RX_START | the transceiver detected a valid SFD This event is present if radio has IEEE802154_CAP_IRQ_RX_START cap. |
IEEE802154_RADIO_INDICATION_CRC_ERROR | the transceiver received a frame with an invalid crc.
|
IEEE802154_RADIO_INDICATION_TX_START | the transceiver sent out a valid SFD This event is present if radio has IEEE802154_CAP_IRQ_TX_START cap.
|
IEEE802154_RADIO_INDICATION_RX_DONE | the transceiver received a frame and lies in the internal framebuffer. This indication should be generated only if CRC is valid and the frame passes the address matching filter (this includes ACK and Beacon frames). The latter only applies if the radio is not in promiscuous mode. The transceiver or driver MUST handle the ACK reply if the Ack Request bit is set in the received frame and promiscuous mode is disabled. The transceiver might be in a "FB Lock" state where no more frames are received. This is done in order to avoid overwriting the Frame Buffer with new frame arrivals. In order to leave this state, the upper layer must call ieee802154_radio_read
|
IEEE802154_RADIO_CONFIRM_TX_DONE | the transceiver either finished sending a frame, the retransmission procedure or the channel activity detection prior transmission. This event is present if radio has IEEE802154_CAP_IRQ_TX_DONE cap. The upper layer should immediately call ieee802154_radio_confirm_transmit when on this event. |
IEEE802154_RADIO_CONFIRM_CCA | the CCA procedure finished This event is present if radio has IEEE802154_CAP_IRQ_CCA_DONE. |
Transmission status.
Enumerator | |
---|---|
TX_STATUS_SUCCESS | the transceiver successfully sent a frame. Depending of the type of transmissions and available caps, this could mean one of the following: If the device supports IEEE802154_CAP_FRAME_RETRANS or IEEE802154_CAP_IRQ_ACK_TIMEOUT this means either:
Otherwise, this notifies that a frame was sent. |
TX_STATUS_FRAME_PENDING | the transceiver received a valid ACK with the frame pending bit This status is present only if the device supports IEEE802154_CAP_FRAME_RETRANS or IEEE802154_CAP_IRQ_ACK_TIMEOUT. |
TX_STATUS_NO_ACK | the transceiver ran out of retransmission This status is present only if the device supports IEEE802154_CAP_FRAME_RETRANS or IEEE802154_CAP_IRQ_ACK_TIMEOUT. |
TX_STATUS_MEDIUM_BUSY | the CSMA-CA algorithm or CCA failed to measure a clear channel |
|
inlinestatic |
Convert a ieee802154_rf_caps_t to a ieee802154_phy_mode_t value.
parameter
must be one of the PHY capabilities.[in] | cap | The IEEE 802.15.4 capability. |
|
inlinestatic |
Convert a ieee802154_phy_mode_t to a ieee802154_rf_caps_t value.
[in] | phy_mode | PHY mode |
|
inlinestatic |
Perform a Clear Channel Assessment (blocking)
This function will internally call ieee802154_radio_request_cca and poll ieee802154_radio_confirm_cca.
[in] | dev | IEEE802.15.4 device descriptor |
positive | number if the channel is clear |
0 | if the channel is busy |
negative | errno on error |
|
inlinestatic |
Shortcut to ieee802154_radio_ops::config_addr_filter.
[in] | dev | IEEE802.15.4 device descriptor |
[in] | cmd | command for the address filter |
[in] | value | value for cmd . |
|
inlinestatic |
Shortcut to ieee802154_radio_ops::config_phy.
[in] | dev | IEEE802.15.4 device descriptor |
[in] | conf | the PHY configuration |
|
inlinestatic |
Shortcut to ieee802154_radio_ops::config_src_addr_match.
[in] | dev | IEEE802.15.4 device descriptor |
[in] | cmd | command for the source address match configuration |
[in] | value | value associated to cmd . |
|
inlinestatic |
Shortcut to ieee802154_radio_confirm_cca.
This function must be called to finish the CCA procedure. This function should be called on IEEE802154_RADIO_CONFIRM_CCA, If no interrupt is available, this function can be polled.
This functions calls ieee802154_radio_ops::request_op with IEEE802154_HAL_OP_CCA and sets the context to a boolean where the result of the CCA should be store. Setting it to true means the channel is clear.
[in] | dev | IEEE802.15.4 device descriptor |
positive | number if the channel is clear |
0 | if the channel is busy |
-EAGAIN | if the CCA procedure hasn't finished. |
|
inlinestatic |
Shortcut to ieee802154_radio_ops::confirm_on.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Confirmation function for ieee802154_radio_request_set_idle.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Confirmation function for ieee802154_radio_request_set_rx.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Confirmation function for ieee802154_radio_request_transmit This function must be called to finish the transmission procedure and get the transmission status.
This function should be called on IEEE802154_RADIO_CONFIRM_TX_DONE. If no interrupt is available, this function can be polled.
This functions calls ieee802154_radio_ops::confirm_op with IEEE802154_HAL_OP_TRANSMIT and sets the context to info
.
[in] | dev | IEEE802.15.4 device descriptor |
[out] | info | the TX information. Pass NULL if the information is not needed. If the radio supports AutoCCA, the status should indicate transmission done or channel busy. If the radio supports frame retransmissions, the status should indicate if medium was busy, no ACK was received or transmission succeeded. |
whether | the transmission finished or not |
|
inlinestatic |
Get supported PHY modes of the device.
Internally this function reads ieee802154_radio_ops::caps and returns only the bits from IEEE802154_RF_CAPS_PHY_MASK.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Check if the device supports the IEEE802.15.4 2.4 GHz band.
Internally this function reads ieee802154_radio_ops::caps and checks for IEEE802154_CAP_24_GHZ.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Check if the device supports Auto CSMA-CA for transmissions.
Internally this function reads ieee802154_radio_ops::caps and checks for IEEE802154_CAP_AUTO_CSMA.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Check if the device supports frame retransmissions (with CSMA-CA).
Internally this function reads ieee802154_radio_ops::caps and checks for IEEE802154_CAP_FRAME_RETRANS.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Check if the device reports the number of retransmissions of the last TX procedure.
Internally this function reads ieee802154_radio_ops::caps and checks for IEEE802154_CAP_FRAME_RETRANS_INFO.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Check if the device supports ACK timeout.
Internally this function reads ieee802154_radio_ops::caps and checks for IEEE802154_CAP_IRQ_ACK_TIMEOUT.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Check if the device supports CCA done interrupt.
Internally this function reads ieee802154_radio_ops::caps with IEEE802154_CAP_IRQ_CCA_DONE.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Check if the device supports RX start interrupt.
Internally this function reads ieee802154_radio_ops::caps and checks for IEEE802154_CAP_IRQ_RX_START.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Check if the device supports TX done interrupt.
Internally this function reads ieee802154_radio_ops::caps and checks for IEEE802154_CAP_IRQ_TX_DONE.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Check if the device supports TX start interrupt.
Internally this function reads ieee802154_radio_ops::caps and checks for IEEE802154_CAP_IRQ_TX_START.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Check if the device supports the ASK PHY mode.
Internally this function reads ieee802154_radio_ops::caps and checks for IEEE802154_CAP_PHY_ASK.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Check if the device supports the BPSK PHY mode.
Internally this function reads ieee802154_radio_ops::caps and checks for IEEE802154_CAP_PHY_BPSK.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Check if the device supports the MR-FSK PHY mode.
Internally this function reads ieee802154_radio_ops::caps and checks for IEEE802154_CAP_PHY_MR_FSK.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Check if the device supports the MR-OFDM PHY mode.
Internally this function reads ieee802154_radio_ops::caps and checks for IEEE802154_CAP_PHY_MR_OFDM.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Check if the device supports the MR-O-QPSK PHY mode.
Internally this function reads ieee802154_radio_ops::caps and checks for IEEE802154_CAP_PHY_MR_OQPSK.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Check if the device supports the O-QPSK PHY mode.
Internally this function reads ieee802154_radio_ops::caps and checks for IEEE802154_CAP_PHY_OQPSK.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Check if the device supports the IEEE802.15.4 Sub-GHz band.
Internally this function reads ieee802154_radio_ops::caps and checks for IEEE802154_CAP_SUB_GHZ.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Shortcut to ieee802154_radio_ops::len.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Shortcut to ieee802154_radio_ops::off.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Shortcut to ieee802154_radio_ops::read.
[in] | dev | IEEE802.15.4 device descriptor |
[out] | buf | buffer to write the received frame into. |
[in] | size | size of buf |
[in] | info | information of the received frame (LQI, RSSI). Can be NULL if this information is not needed. |
|
inlinestatic |
Request Stand-Alone Clear Channel Assessment.
This functions calls ieee802154_radio_ops::request_op with IEEE802154_HAL_OP_CCA and NULL context.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Shortcut to ieee802154_radio_ops::request_on.
[in] | dev | IEEE802.15.4 device descriptor |
|
inlinestatic |
Request the transceiver state to IDLE.
During IDLE, the radio won't be able to receive frames but it's still responsive to other HAL functions.
This functions calls ieee802154_radio_ops::request_op with IEEE802154_HAL_OP_SET_IDLE and sets the context to force
[in] | dev | IEEE802.15.4 device descriptor |
[in] | force | whether the state transition should be forced or not. If forced, the transceiver aborts any ongoing operation. |
0 | on success |
negative | errno on error |
|
inlinestatic |
Request the transceiver state to RX.
During RX, the radio will listen to incoming frames
This functions calls ieee802154_radio_ops::request_op with IEEE802154_HAL_OP_SET_RX and NULL context.
[in] | dev | IEEE802.15.4 device descriptor |
0 | on success |
negative | errno on error |
|
inlinestatic |
Transmit a preloaded frame.
This functions calls ieee802154_radio_ops::request_op with IEEE802154_HAL_OP_TRANSMIT and NULL context.
0 | on success |
negative | errno on error |
|
inlinestatic |
Shortcut to ieee802154_radio_ops::set_cca_mode.
[in] | dev | IEEE802.15.4 device descriptor |
[in] | mode | the CCA mode |
|
inlinestatic |
Shortcut to ieee802154_radio_ops::set_cca_threshold.
[in] | dev | IEEE802.15.4 device descriptor |
[in] | threshold | the threshold in dBm |
|
inlinestatic |
Shortcut to ieee802154_radio_ops::set_csma_params.
[in] | dev | IEEE802.15.4 device descriptor |
[in] | bd | parameters of the exponential backoff |
[in] | retries | number of CSMA-CA retries. If restries < 0, retransmissions with CSMA-CA are disabled |
|
inlinestatic |
Shortcut to ieee802154_radio_ops::set_frame_filter_mode.
[in] | dev | IEEE802.15.4 device descriptor |
[in] | mode | frame filter mode |
|
inlinestatic |
Shortcut to ieee802154_radio_ops::set_frame_retrans.
[in] | dev | IEEE802.15.4 device descriptor |
[in] | retrans | the number of retransmissions |
|
inlinestatic |
Set transceiver state to IDLE (blocking)
This function will internally call ieee802154_radio_request_set_idle and poll ieee802154_radio_confirm_set_idle.
[in] | dev | IEEE802.15.4 device descriptor |
[in] | force | whether the state transition should be forced or not. If forced, the transceiver aborts any ongoing operation. |
0 | on success |
negative | errno on error |
|
inlinestatic |
Set transceiver state to RX (blocking)
This function will internally call ieee802154_radio_request_set_rx and poll ieee802154_radio_confirm_set_rx.
[in] | dev | IEEE802.15.4 device descriptor |
0 | on success |
negative | errno on error |
|
inlinestatic |
Shortcut to ieee802154_radio_ops::write.
[in] | dev | IEEE802.15.4 device descriptor |
[in] | psdu | PSDU frame to be sent |