AT86RF233 PHY implementation.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
#include <stdbool.h>
#include "phy.h"
#include "sal.h"
#include "trx_access.h"
#include "delay.h"
#include "at86rf233.h"
Macros | |
#define | PHY_CRC_SIZE 2 |
Enumerations | |
enum | PhyState_t { PHY_STATE_INITIAL, PHY_STATE_IDLE, PHY_STATE_SLEEP, PHY_STATE_TX_WAIT_END } |
Functions | |
void | PHY_DataReq (uint8_t *data) |
int8_t | PHY_EdReq (void) |
void | PHY_EncryptReq (uint8_t *text, uint8_t *key) |
void | PHY_Init (void) |
uint16_t | PHY_RandomReq (void) |
void | PHY_SetChannel (uint8_t channel) |
void | PHY_SetIEEEAddr (uint8_t *ieee_addr) |
void | PHY_SetPanId (uint16_t panId) |
void | PHY_SetRxState (bool rx) |
void | PHY_SetShortAddr (uint16_t addr) |
void | PHY_SetTxPower (uint8_t txPower) |
void | PHY_Sleep (void) |
void | PHY_TaskHandler (void) |
void | PHY_Wakeup (void) |
static uint8_t | phyReadRegister (uint8_t reg) |
static void | phySetRxState (void) |
static void | phyTrxSetState (uint8_t state) |
static void | phyWaitState (uint8_t state) |
static void | phyWriteRegister (uint8_t reg, uint8_t value) |
Variables | |
static uint8_t | phyRxBuffer [128] |
static bool | phyRxState |
static PhyState_t | phyState = PHY_STATE_INITIAL |
#define PHY_CRC_SIZE 2 |
Referenced by PHY_TaskHandler().
enum PhyState_t |
void PHY_DataReq | ( | uint8_t * | data | ) |
References IRQ_STATUS_REG, PHY_STATE_TX_WAIT_END, phyReadRegister(), phyState, phyTrxSetState(), TRX_CMD_TX_ARET_ON, trx_frame_write(), TRX_SLP_TR_HIGH, TRX_SLP_TR_LOW, and TRX_TRIG_DELAY.
Referenced by nwkTxTaskHandler().
int8_t PHY_EdReq | ( | void | ) |
void PHY_EncryptReq | ( | uint8_t * | text, |
uint8_t * | key | ||
) |
References AES_DIR_ENCRYPT, AES_MODE_ECB, sal_aes_exec(), sal_aes_read(), sal_aes_setup(), and sal_aes_wrrd().
Referenced by SYS_EncryptReq().
void PHY_Init | ( | void | ) |
References IRQ_MASK_MODE, OQPSK_SCRAM_EN, PHY_STATE_IDLE, phyReadRegister(), PhyReset(), phyRxState, phyState, phyWriteRegister(), RX_SAFE_MODE, SPI_CMD_MODE, TRX_CMD_TRX_OFF, TRX_CTRL_1_REG, TRX_CTRL_2_REG, trx_spi_init(), TRX_STATE_REG, TRX_STATUS_MASK, TRX_STATUS_REG, TRX_STATUS_TRX_OFF, and TX_AUTO_CRC_ON.
Referenced by SYS_Init().
uint16_t PHY_RandomReq | ( | void | ) |
References delay_us, PHY_RSSI_REG, phyReadRegister(), phySetRxState(), phyTrxSetState(), RANDOM_NUMBER_UPDATE_INTERVAL, RND_VALUE, and TRX_CMD_RX_ON.
Referenced by appInit().
void PHY_SetChannel | ( | uint8_t | channel | ) |
References PHY_CC_CCA_REG, phyReadRegister(), and phyWriteRegister().
Referenced by appInit().
void PHY_SetIEEEAddr | ( | uint8_t * | ieee_addr | ) |
References IEEE_ADDR_0_REG, and trx_reg_write().
void PHY_SetPanId | ( | uint16_t | panId | ) |
References PAN_ID_0_REG, PAN_ID_1_REG, and phyWriteRegister().
Referenced by NWK_SetPanId().
void PHY_SetRxState | ( | bool | rx | ) |
References phyRxState, and phySetRxState().
Referenced by appInit().
void PHY_SetShortAddr | ( | uint16_t | addr | ) |
References CSMA_SEED_0_REG, phyWriteRegister(), SHORT_ADDR_0_REG, and SHORT_ADDR_1_REG.
Referenced by NWK_SetAddr().
void PHY_SetTxPower | ( | uint8_t | txPower | ) |
References PHY_TX_PWR_REG, phyReadRegister(), and phyWriteRegister().
void PHY_Sleep | ( | void | ) |
References PHY_STATE_SLEEP, phyState, phyTrxSetState(), TRX_CMD_TRX_OFF, and TRX_SLP_TR_HIGH.
Referenced by NWK_SleepReq().
void PHY_TaskHandler | ( | void | ) |
References PHY_DataInd_t::data, IRQ_STATUS_REG, PHY_DataInd_t::lqi, PHY_CRC_SIZE, PHY_DataConf(), PHY_DataInd(), PHY_ED_LEVEL_REG, PHY_RSSI_BASE_VAL, PHY_STATE_IDLE, PHY_STATE_SLEEP, PHY_STATE_TX_WAIT_END, PHY_STATUS_CHANNEL_ACCESS_FAILURE, PHY_STATUS_ERROR, PHY_STATUS_NO_ACK, PHY_STATUS_SUCCESS, phyReadRegister(), phyRxBuffer, phySetRxState(), phyState, phyWaitState(), PHY_DataInd_t::rssi, PHY_DataInd_t::size, TRAC_STATUS, TRAC_STATUS_CHANNEL_ACCESS_FAILURE, TRAC_STATUS_NO_ACK, TRAC_STATUS_SUCCESS, TRX_END, trx_frame_read(), TRX_STATE_REG, and TRX_STATUS_RX_AACK_ON.
Referenced by SYS_TaskHandler().
void PHY_Wakeup | ( | void | ) |
References PHY_STATE_IDLE, phySetRxState(), phyState, and TRX_SLP_TR_LOW.
Referenced by NWK_WakeupReq().
|
static |
References trx_reg_read().
Referenced by PHY_DataReq(), PHY_EdReq(), PHY_Init(), PHY_RandomReq(), PHY_SetChannel(), PHY_SetTxPower(), PHY_TaskHandler(), phySetRxState(), phyTrxSetState(), and phyWaitState().
|
static |
References IRQ_STATUS_REG, phyReadRegister(), phyRxState, phyTrxSetState(), TRX_CMD_RX_AACK_ON, and TRX_CMD_TRX_OFF.
Referenced by PHY_EdReq(), PHY_RandomReq(), PHY_SetRxState(), PHY_TaskHandler(), and PHY_Wakeup().
|
static |
References phyReadRegister(), phyWriteRegister(), TRX_CMD_FORCE_TRX_OFF, TRX_STATE_REG, TRX_STATUS_MASK, TRX_STATUS_REG, and TRX_STATUS_TRX_OFF.
Referenced by PHY_DataReq(), PHY_EdReq(), PHY_RandomReq(), PHY_Sleep(), and phySetRxState().
|
static |
References phyReadRegister(), TRX_STATUS_MASK, and TRX_STATUS_REG.
Referenced by PHY_TaskHandler().
|
static |
References trx_reg_write().
Referenced by PHY_EdReq(), PHY_Init(), PHY_SetChannel(), PHY_SetPanId(), PHY_SetShortAddr(), PHY_SetTxPower(), and phyTrxSetState().
|
static |
Referenced by PHY_TaskHandler().
|
static |
Referenced by PHY_Init(), PHY_SetRxState(), and phySetRxState().
|
static |
Referenced by PHY_DataReq(), PHY_Init(), PHY_Sleep(), PHY_TaskHandler(), and PHY_Wakeup().