All registers in the AT86RF212 are 8 bit wide and they can be accessed with a single SPI command (see section 4.3 (SPI Protocol) of the AT86RF212 datasheet). An overview of all registers can be found in chapter 12 (Register Reference) of the AT86RF212 datasheet.
The functions trx_reg_read() and trx_reg_write() implement the SPI packet structure for reading and writing the radio transceiver registers.
Additionaly, the RG_<XYZ> macros contain the addresses of all registers.
SPI packet structure for trx_reg_read()
SPI packet structure for trx_reg_write()
uint64_t var;
uint8_t var_7_0 = var & 0xff // bit 7:0
uint8_t var_15_8 = (var >> 8) & 0xff // bit 15:8
uint8_t var_23_16 = (var >> 16) & 0xff // bit 23:16
uint8_t var_31_24 = (var >> 24) & 0xff // bit 31:24
uint8_t var_39_32 = (var >> 32) & 0xff // bit 39:32
uint8_t var_47_40 = (var >> 40) & 0xff // bit 47:40
uint8_t var_55_48 = (var >> 48) & 0xff // bit 55:48
uint8_t var_63_56 = (var >> 56) & 0xff // bit 63:56
For some of the sub registers, there exist predefined constants which assign symbolic names to numeric values (e.g. TRX_OFF, PLL_ON, RX_ON and SLEEP as state names for the sub register SR_TRX_STATUS).
#define SR_TRX_STATUS 0x01, 0x1f, 0
-------------------------------
| Register 0x01: RG_TRX_STATUS |
--- --- --- --- --- --- --- ---
| | | | v v v v v |
--- --- --- --- --- --- --- ---
7 6 5 4 3 2 1 0
[===================]---> SR_TRX_STATUS
offset = 0x01
mask = 0x1f
shift = 0
#define SR_TX_AUTO_CRC_ON 0x04, 0x20, 5
-------------------------------
| Register 0x04: RG_TRX_CTRL_1 |
--- --- --- --- --- --- --- ---
| | | v | | | | | |
--- --- --- --- --- --- --- ---
7 6 5 4 3 2 1 0
--------[===]-----------------------> SR_TX_AUTO_CRC_ON
offset = 0x04
mask = 0x20
shift = 5
SPI packet structure for trx_frame_read()
SPI packet structure for trx_frame_write()
+------ ------ ~~~~~~ ------+------ ------+------ ------ ~~~~~~ ------ ------+
| 0x00 | 0x01 | | 0x7F | 0x80 | 0x81 | 0x82 | 0x83 | | 0x93 | 0x94 |
+------ ------ ~~~~~~ ------+------ ------+------ ------ ~~~~~~ ------ ------+
| Frame Buffer (1) | reserved | AES Block (1,2) |
+------ ------ ~~~~~~ ------+------ ------+------ ------ ~~~~~~ ------ ------+
The different blocks are accessed with different SPI packet structures.
SPI packet structure for trx_sram_read()
SPI packet structure for trx_sram_write()
The fast SRAM access, described in function trx_aes_wrrd(), can only be used for the AES block. This mode allows simultaneously writing new data and reading data from previously processed data within the same SPI transfer.
SPI packet structure for trx_aes_wrrd()
1.5.6