mirror of https://github.com/ARMmbed/mbed-os.git
Apply astyle suggestions from the CI
parent
7149877c5d
commit
8a31b6a7ca
|
@ -68,9 +68,9 @@ static int8_t rf_extension(phy_extension_type_e extension_type, uint8_t *data_pt
|
|||
static void rf_mac_hw_init(void);
|
||||
static void rf_mac_ed_state_enable(void);
|
||||
static void rf_mac_set_pending(uint8_t status);
|
||||
static void rf_mac_set_shortAddress(uint8_t* valueAddress);
|
||||
static void rf_mac_set_panId(uint8_t* valueAddress);
|
||||
static void rf_mac_set_mac64(const uint8_t* valueAddress);
|
||||
static void rf_mac_set_shortAddress(uint8_t *valueAddress);
|
||||
static void rf_mac_set_panId(uint8_t *valueAddress);
|
||||
static void rf_mac_set_mac64(const uint8_t *valueAddress);
|
||||
static uint8_t rf_convert_energy_level(uint8_t energyLevel);
|
||||
static void rf_abort(void);
|
||||
static void rf_ack_wait_timer_start(uint16_t time);
|
||||
|
@ -109,7 +109,7 @@ static phy_device_driver_s device_driver = {
|
|||
PHY_LAYER_PAYLOAD_DATA_FLOW,
|
||||
MAC64_addr,
|
||||
PHY_MTU_SIZE,
|
||||
(char*)"NXP kw41z",
|
||||
(char *)"NXP kw41z",
|
||||
CRC_LENGTH,
|
||||
PHY_HEADER_LENGTH,
|
||||
&rf_interface_state_control,
|
||||
|
@ -211,8 +211,7 @@ static int8_t rf_interface_state_control(phy_interface_state_e new_state, uint8_
|
|||
{
|
||||
platform_enter_critical();
|
||||
|
||||
switch (new_state)
|
||||
{
|
||||
switch (new_state) {
|
||||
/*Reset PHY driver and set to idle*/
|
||||
case PHY_INTERFACE_RESET:
|
||||
rf_abort();
|
||||
|
@ -294,7 +293,7 @@ static void rf_abort(void)
|
|||
if (ZLL->PHY_CTRL & ZLL_PHY_CTRL_TMRTRIGEN_MASK) {
|
||||
ZLL->PHY_CTRL &= ~ZLL_PHY_CTRL_TMRTRIGEN_MASK;
|
||||
/* give the FSM enough time to start if it was triggered */
|
||||
while( (XCVR_MISC->XCVR_CTRL & XCVR_CTRL_XCVR_STATUS_TSM_COUNT_MASK) == 0) {}
|
||||
while ((XCVR_MISC->XCVR_CTRL & XCVR_CTRL_XCVR_STATUS_TSM_COUNT_MASK) == 0) {}
|
||||
}
|
||||
|
||||
/* If XCVR is not idle, abort current SEQ */
|
||||
|
@ -347,7 +346,7 @@ static int8_t rf_start_cca(uint8_t *data_ptr, uint16_t data_length, uint8_t tx_h
|
|||
need_ack = (*data_ptr & 0x20) == 0x20;
|
||||
|
||||
/* Load data into Packet Buffer */
|
||||
pPB = (uint8_t*)ZLL->PKT_BUFFER_TX;
|
||||
pPB = (uint8_t *)ZLL->PKT_BUFFER_TX;
|
||||
|
||||
tx_len = data_length + 2;
|
||||
*pPB++ = tx_len; /* including 2 bytes of FCS */
|
||||
|
@ -495,7 +494,8 @@ static uint8_t rf_convert_energy_level(uint8_t energyLevel)
|
|||
/**
|
||||
* SET MAC 16 address to Register
|
||||
*/
|
||||
static void rf_mac_set_shortAddress(uint8_t* valueAddress) {
|
||||
static void rf_mac_set_shortAddress(uint8_t *valueAddress)
|
||||
{
|
||||
ZLL->MACSHORTADDRS0 &= ~ZLL_MACSHORTADDRS0_MACSHORTADDRS0_MASK;
|
||||
ZLL->MACSHORTADDRS0 |= ZLL_MACSHORTADDRS0_MACSHORTADDRS0(common_read_16_bit(valueAddress));
|
||||
}
|
||||
|
@ -503,7 +503,8 @@ static void rf_mac_set_shortAddress(uint8_t* valueAddress) {
|
|||
/**
|
||||
* SET PAN-ID to Register
|
||||
*/
|
||||
static void rf_mac_set_panId(uint8_t* valueAddress) {
|
||||
static void rf_mac_set_panId(uint8_t *valueAddress)
|
||||
{
|
||||
ZLL->MACSHORTADDRS0 &= ~ZLL_MACSHORTADDRS0_MACPANID0_MASK;
|
||||
ZLL->MACSHORTADDRS0 |= ZLL_MACSHORTADDRS0_MACPANID0(common_read_16_bit(valueAddress));
|
||||
}
|
||||
|
@ -511,7 +512,8 @@ static void rf_mac_set_panId(uint8_t* valueAddress) {
|
|||
/**
|
||||
* SET MAC64 address to register
|
||||
*/
|
||||
static void rf_mac_set_mac64(const uint8_t* valueAddress) {
|
||||
static void rf_mac_set_mac64(const uint8_t *valueAddress)
|
||||
{
|
||||
ZLL->MACLONGADDRS0_MSB = common_read_32_bit(valueAddress);
|
||||
valueAddress += 4;
|
||||
ZLL->MACLONGADDRS0_LSB = common_read_32_bit(valueAddress);
|
||||
|
@ -544,7 +546,7 @@ static uint8_t PhyPlmeGetPwrLevelRequest(void)
|
|||
|
||||
static uint8_t PhyPlmeSetCurrentChannelRequest(uint8_t channel, uint8_t pan)
|
||||
{
|
||||
if((channel < 11) || (channel > 26)) {
|
||||
if ((channel < 11) || (channel > 26)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -617,8 +619,8 @@ static void PhyIsrTimeoutCleanup(void)
|
|||
/* Mask TMR3 interrupt */
|
||||
irqStatus |= ZLL_IRQSTS_TMR3MSK_MASK;
|
||||
/* Clear transceiver interrupts except TMR1IRQ and TMR4IRQ. */
|
||||
irqStatus &= ~( ZLL_IRQSTS_TMR1IRQ_MASK |
|
||||
ZLL_IRQSTS_TMR4IRQ_MASK );
|
||||
irqStatus &= ~(ZLL_IRQSTS_TMR1IRQ_MASK |
|
||||
ZLL_IRQSTS_TMR4IRQ_MASK);
|
||||
ZLL->IRQSTS = irqStatus;
|
||||
|
||||
/* The packet was transmitted successfully, but no ACK was received */
|
||||
|
@ -944,7 +946,7 @@ static void rf_handle_rx_end(void)
|
|||
rf_rssi = rf_convert_LQI_to_RSSI(rf_lqi);
|
||||
|
||||
/* Load data from Packet Buffer */
|
||||
pPB = (uint8_t*)ZLL->PKT_BUFFER_RX;
|
||||
pPB = (uint8_t *)ZLL->PKT_BUFFER_RX;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
PHYPAYLOAD[i] = *pPB++;
|
||||
|
@ -978,7 +980,7 @@ static void handle_IRQ_events(void)
|
|||
|
||||
} else {
|
||||
/* Rx Watermark IRQ */
|
||||
if((!(ZLL->PHY_CTRL & ZLL_PHY_CTRL_RX_WMRK_MSK_MASK)) &&
|
||||
if ((!(ZLL->PHY_CTRL & ZLL_PHY_CTRL_RX_WMRK_MSK_MASK)) &&
|
||||
(irqStatus & ZLL_IRQSTS_RXWTRMRKIRQ_MASK)) {
|
||||
uint32_t rx_len = (irqStatus & ZLL_IRQSTS_RX_FRAME_LENGTH_MASK) >> ZLL_IRQSTS_RX_FRAME_LENGTH_SHIFT;
|
||||
|
||||
|
@ -1009,8 +1011,7 @@ static void handle_IRQ_events(void)
|
|||
rf_receive();
|
||||
} else {
|
||||
PhyIsrSeqCleanup();
|
||||
switch(xcvseqCopy)
|
||||
{
|
||||
switch (xcvseqCopy) {
|
||||
case gTX_c:
|
||||
if ((ZLL->PHY_CTRL & ZLL_PHY_CTRL_CCABFRTX_MASK) &&
|
||||
(irqStatus & ZLL_IRQSTS_CCA_MASK)) {
|
||||
|
@ -1097,7 +1098,7 @@ void NanostackRfPhyKw41z::get_mac_address(uint8_t *mac)
|
|||
{
|
||||
platform_enter_critical();
|
||||
|
||||
memcpy((void*)mac, (void*)MAC64_addr, sizeof(MAC64_addr));
|
||||
memcpy((void *)mac, (void *)MAC64_addr, sizeof(MAC64_addr));
|
||||
|
||||
platform_exit_critical();
|
||||
}
|
||||
|
@ -1111,7 +1112,7 @@ void NanostackRfPhyKw41z::set_mac_address(uint8_t *mac)
|
|||
platform_exit_critical();
|
||||
return;
|
||||
}
|
||||
memcpy((void*)MAC64_addr, (void*)mac, sizeof(MAC64_addr));
|
||||
memcpy((void *)MAC64_addr, (void *)mac, sizeof(MAC64_addr));
|
||||
|
||||
platform_exit_critical();
|
||||
}
|
||||
|
|
|
@ -84,10 +84,10 @@ static volatile size_t rx_queue_tail = 0;
|
|||
|
||||
/* Silicon Labs headers */
|
||||
extern "C" {
|
||||
#include "rail/rail.h"
|
||||
#include "rail/pa.h"
|
||||
#include "rail/pti.h"
|
||||
#include "rail/ieee802154/rail_ieee802154.h"
|
||||
#include "rail/rail.h"
|
||||
#include "rail/pa.h"
|
||||
#include "rail/pti.h"
|
||||
#include "rail/ieee802154/rail_ieee802154.h"
|
||||
}
|
||||
|
||||
/* RF driver data */
|
||||
|
@ -186,21 +186,21 @@ static const RAIL_ChannelConfig_t channels = {
|
|||
#endif
|
||||
|
||||
#if defined (MBED_CONF_SL_RAIL_HAS_2P4)
|
||||
// Set up the PA for 2.4 GHz operation
|
||||
// Set up the PA for 2.4 GHz operation
|
||||
static const RAIL_TxPowerConfig_t paInit2p4 = {
|
||||
.mode = RAIL_TX_POWER_MODE_2P4_HP,
|
||||
.voltage = 1800,
|
||||
.rampTime = 10,
|
||||
};
|
||||
};
|
||||
#endif
|
||||
|
||||
#if MBED_CONF_SL_RAIL_HAS_SUBGIG
|
||||
// Set up the PA for sub-GHz operation
|
||||
// Set up the PA for sub-GHz operation
|
||||
static const RAIL_TxPowerConfig_t paInitSubGhz = {
|
||||
.mode = RAIL_TX_POWER_MODE_SUBGIG,
|
||||
.voltage = 1800,
|
||||
.rampTime = 10,
|
||||
};
|
||||
};
|
||||
#endif
|
||||
|
||||
static const RAIL_StateTiming_t timings = {
|
||||
|
@ -249,7 +249,7 @@ static uint8_t txFifo[256];
|
|||
static int8_t rf_extension(phy_extension_type_e extension_type, uint8_t *data_ptr);
|
||||
static int8_t rf_interface_state_control(phy_interface_state_e new_state, uint8_t rf_channel);
|
||||
static int8_t rf_address_write(phy_address_type_e address_type, uint8_t *address_ptr);
|
||||
static int8_t rf_start_cca(uint8_t *data_ptr, uint16_t data_length, uint8_t tx_handle, data_protocol_e data_protocol );
|
||||
static int8_t rf_start_cca(uint8_t *data_ptr, uint16_t data_length, uint8_t tx_handle, data_protocol_e data_protocol);
|
||||
|
||||
/* Local function prototypes */
|
||||
static bool rail_checkAndSwitchChannel(uint8_t channel);
|
||||
|
@ -275,8 +275,8 @@ static void rf_thread_loop(const void *arg)
|
|||
platform_enter_critical();
|
||||
|
||||
if (event.value.signals & SL_RX_DONE) {
|
||||
while(rx_queue_tail != rx_queue_head) {
|
||||
uint8_t* packet = (uint8_t*) rx_queue[rx_queue_tail];
|
||||
while (rx_queue_tail != rx_queue_head) {
|
||||
uint8_t *packet = (uint8_t *) rx_queue[rx_queue_tail];
|
||||
SL_DEBUG_PRINT("rPKT %d\n", packet[MAC_PACKET_INFO_LENGTH] - 2);
|
||||
device_driver.phy_rx_cb(
|
||||
&packet[MAC_PACKET_INFO_LENGTH + 1], /* Data payload for Nanostack starts at FCS */
|
||||
|
@ -294,7 +294,7 @@ static void rf_thread_loop(const void *arg)
|
|||
1,
|
||||
1);
|
||||
} else if (event.value.signals & SL_ACK_RECV) {
|
||||
device_driver.phy_tx_done_cb( rf_radio_driver_id,
|
||||
device_driver.phy_tx_done_cb(rf_radio_driver_id,
|
||||
current_tx_handle,
|
||||
(event.value.signals & SL_ACK_PEND) ? PHY_LINK_TX_DONE_PENDING : PHY_LINK_TX_DONE,
|
||||
1,
|
||||
|
@ -306,25 +306,25 @@ static void rf_thread_loop(const void *arg)
|
|||
PHY_LINK_TX_FAIL,
|
||||
1,
|
||||
1);
|
||||
} else if(event.value.signals & SL_TX_ERR) {
|
||||
device_driver.phy_tx_done_cb( rf_radio_driver_id,
|
||||
} else if (event.value.signals & SL_TX_ERR) {
|
||||
device_driver.phy_tx_done_cb(rf_radio_driver_id,
|
||||
current_tx_handle,
|
||||
PHY_LINK_CCA_FAIL,
|
||||
8,
|
||||
1);
|
||||
} else if(event.value.signals & SL_TX_TIMEOUT) {
|
||||
device_driver.phy_tx_done_cb( rf_radio_driver_id,
|
||||
} else if (event.value.signals & SL_TX_TIMEOUT) {
|
||||
device_driver.phy_tx_done_cb(rf_radio_driver_id,
|
||||
current_tx_handle,
|
||||
PHY_LINK_CCA_FAIL,
|
||||
8,
|
||||
1);
|
||||
} else if(event.value.signals & SL_CAL_REQ) {
|
||||
} else if (event.value.signals & SL_CAL_REQ) {
|
||||
SL_DEBUG_PRINT("rf_thread_loop: SL_CAL_REQ signal received (unhandled)\n");
|
||||
} else if(event.value.signals & SL_RXFIFO_ERR) {
|
||||
} else if (event.value.signals & SL_RXFIFO_ERR) {
|
||||
SL_DEBUG_PRINT("rf_thread_loop: SL_RXFIFO_ERR signal received (unhandled)\n");
|
||||
} else if(event.value.signals & SL_TXFIFO_ERR) {
|
||||
} else if (event.value.signals & SL_TXFIFO_ERR) {
|
||||
SL_DEBUG_PRINT("rf_thread_loop: SL_TXFIFO_ERR signal received (unhandled)\n");
|
||||
} else if(event.value.signals & SL_QUEUE_FULL) {
|
||||
} else if (event.value.signals & SL_QUEUE_FULL) {
|
||||
SL_DEBUG_PRINT("rf_thread_loop: SL_QUEUE_FULL signal received (packet dropped)\n");
|
||||
} else {
|
||||
SL_DEBUG_PRINT("rf_thread_loop unhandled event status: %d value: %d\n", event.status, (int)event.value.signals);
|
||||
|
@ -346,7 +346,7 @@ static void rf_thread_loop(const void *arg)
|
|||
static int8_t rf_device_register(void)
|
||||
{
|
||||
// If we already exist, bail.
|
||||
if(radio_state != RADIO_UNINIT) {
|
||||
if (radio_state != RADIO_UNINIT) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -422,12 +422,12 @@ static int8_t rf_device_register(void)
|
|||
|
||||
/* Get real MAC address */
|
||||
/* MAC is stored MSB first */
|
||||
memcpy(MAC_address, (const void*)&DEVINFO->UNIQUEH, 4);
|
||||
memcpy(&MAC_address[4], (const void*)&DEVINFO->UNIQUEL, 4);
|
||||
memcpy(MAC_address, (const void *)&DEVINFO->UNIQUEH, 4);
|
||||
memcpy(&MAC_address[4], (const void *)&DEVINFO->UNIQUEL, 4);
|
||||
|
||||
/*Set pointer to MAC address*/
|
||||
device_driver.PHY_MAC = MAC_address;
|
||||
device_driver.driver_description = (char*)"EFR32_154";
|
||||
device_driver.driver_description = (char *)"EFR32_154";
|
||||
|
||||
/*Type of RF PHY*/
|
||||
#if MBED_CONF_SL_RAIL_BAND == 2400
|
||||
|
@ -462,7 +462,7 @@ static int8_t rf_device_register(void)
|
|||
rf_radio_driver_id = arm_net_phy_register(&device_driver);
|
||||
|
||||
// If the radio hasn't called the ready callback by now, place it in the initing state
|
||||
if(radio_state == RADIO_UNINIT) {
|
||||
if (radio_state == RADIO_UNINIT) {
|
||||
radio_state = RADIO_INITING;
|
||||
}
|
||||
|
||||
|
@ -485,7 +485,7 @@ static int8_t rf_device_register(void)
|
|||
static void rf_device_unregister(void)
|
||||
{
|
||||
arm_net_phy_unregister(rf_radio_driver_id);
|
||||
if(sleep_blocked) {
|
||||
if (sleep_blocked) {
|
||||
sleep_manager_unlock_deep_sleep();
|
||||
sleep_blocked = false;
|
||||
}
|
||||
|
@ -500,9 +500,9 @@ static void rf_device_unregister(void)
|
|||
* \return 0 Success
|
||||
* \return -1 Busy
|
||||
*/
|
||||
static int8_t rf_start_cca(uint8_t *data_ptr, uint16_t data_length, uint8_t tx_handle, data_protocol_e data_protocol )
|
||||
static int8_t rf_start_cca(uint8_t *data_ptr, uint16_t data_length, uint8_t tx_handle, data_protocol_e data_protocol)
|
||||
{
|
||||
switch(radio_state) {
|
||||
switch (radio_state) {
|
||||
case RADIO_UNINIT:
|
||||
SL_DEBUG_PRINT("rf_start_cca: Radio uninit\n");
|
||||
return -1;
|
||||
|
@ -518,8 +518,8 @@ static int8_t rf_start_cca(uint8_t *data_ptr, uint16_t data_length, uint8_t tx_h
|
|||
case RADIO_IDLE:
|
||||
case RADIO_RX:
|
||||
// If we're still waiting for an ACK, don't mess up the internal state
|
||||
if(waiting_for_ack || RAIL_GetRadioState(gRailHandle) == RAIL_RF_STATE_TX) {
|
||||
if((RAIL_GetTime() - last_tx) < 30000) {
|
||||
if (waiting_for_ack || RAIL_GetRadioState(gRailHandle) == RAIL_RF_STATE_TX) {
|
||||
if ((RAIL_GetTime() - last_tx) < 30000) {
|
||||
SL_DEBUG_PRINT("rf_start_cca: Still waiting on previous ACK\n");
|
||||
return -1;
|
||||
} else {
|
||||
|
@ -539,7 +539,7 @@ static int8_t rf_start_cca(uint8_t *data_ptr, uint16_t data_length, uint8_t tx_h
|
|||
|
||||
RAIL_TxOptions_t txOpt = RAIL_TX_OPTIONS_DEFAULT;
|
||||
//Check to see whether we'll be waiting for an ACK
|
||||
if(data_ptr[1] & (1 << 5)) {
|
||||
if (data_ptr[1] & (1 << 5)) {
|
||||
txOpt |= RAIL_TX_OPTION_WAIT_FOR_ACK;
|
||||
waiting_for_ack = true;
|
||||
} else {
|
||||
|
@ -548,7 +548,7 @@ static int8_t rf_start_cca(uint8_t *data_ptr, uint16_t data_length, uint8_t tx_h
|
|||
|
||||
SL_DEBUG_PRINT("rf_start_cca: Called TX, len %d, chan %d, ack %d\n", data_length, channel, waiting_for_ack ? 1 : 0);
|
||||
|
||||
if(RAIL_StartCcaCsmaTx(gRailHandle, channel, txOpt, &csma_config, NULL) == 0) {
|
||||
if (RAIL_StartCcaCsmaTx(gRailHandle, channel, txOpt, &csma_config, NULL) == 0) {
|
||||
//Save packet number and sequence
|
||||
current_tx_handle = tx_handle;
|
||||
current_tx_sequence = data_ptr[3];
|
||||
|
@ -577,13 +577,12 @@ static int8_t rf_start_cca(uint8_t *data_ptr, uint16_t data_length, uint8_t tx_h
|
|||
static int8_t rf_interface_state_control(phy_interface_state_e new_state, uint8_t rf_channel)
|
||||
{
|
||||
int8_t ret_val = 0;
|
||||
switch (new_state)
|
||||
{
|
||||
switch (new_state) {
|
||||
/* Reset PHY driver and set to idle */
|
||||
case PHY_INTERFACE_RESET:
|
||||
RAIL_Idle(gRailHandle, RAIL_IDLE_FORCE_SHUTDOWN_CLEAR_FLAGS, true);
|
||||
radio_state = RADIO_IDLE;
|
||||
if(sleep_blocked) {
|
||||
if (sleep_blocked) {
|
||||
sleep_manager_unlock_deep_sleep();
|
||||
sleep_blocked = false;
|
||||
}
|
||||
|
@ -592,19 +591,19 @@ static int8_t rf_interface_state_control(phy_interface_state_e new_state, uint8_
|
|||
case PHY_INTERFACE_DOWN:
|
||||
RAIL_Idle(gRailHandle, RAIL_IDLE_FORCE_SHUTDOWN_CLEAR_FLAGS, true);
|
||||
radio_state = RADIO_IDLE;
|
||||
if(sleep_blocked) {
|
||||
if (sleep_blocked) {
|
||||
sleep_manager_unlock_deep_sleep();
|
||||
sleep_blocked = false;
|
||||
}
|
||||
break;
|
||||
/* Enable RX */
|
||||
case PHY_INTERFACE_UP:
|
||||
if(rail_checkAndSwitchChannel(rf_channel)) {
|
||||
if (rail_checkAndSwitchChannel(rf_channel)) {
|
||||
RAIL_Idle(gRailHandle, RAIL_IDLE_FORCE_SHUTDOWN_CLEAR_FLAGS, true);
|
||||
RAIL_IEEE802154_SetPromiscuousMode(gRailHandle, false);
|
||||
RAIL_StartRx(gRailHandle, channel, NULL);
|
||||
radio_state = RADIO_RX;
|
||||
if(!sleep_blocked) {
|
||||
if (!sleep_blocked) {
|
||||
/* RX can only happen in EM0/1*/
|
||||
sleep_manager_lock_deep_sleep();
|
||||
sleep_blocked = true;
|
||||
|
@ -620,12 +619,12 @@ static int8_t rf_interface_state_control(phy_interface_state_e new_state, uint8_
|
|||
break;
|
||||
/* Enable RX in promiscuous mode (aka no address filtering) */
|
||||
case PHY_INTERFACE_SNIFFER_STATE:
|
||||
if(rail_checkAndSwitchChannel(rf_channel)) {
|
||||
if (rail_checkAndSwitchChannel(rf_channel)) {
|
||||
RAIL_Idle(gRailHandle, RAIL_IDLE_FORCE_SHUTDOWN_CLEAR_FLAGS, true);
|
||||
RAIL_IEEE802154_SetPromiscuousMode(gRailHandle, true);
|
||||
RAIL_StartRx(gRailHandle, channel, NULL);
|
||||
radio_state = RADIO_RX;
|
||||
if(!sleep_blocked) {
|
||||
if (!sleep_blocked) {
|
||||
/* RX can only happen in EM0/1*/
|
||||
sleep_manager_lock_deep_sleep();
|
||||
sleep_blocked = true;
|
||||
|
@ -648,11 +647,10 @@ static int8_t rf_interface_state_control(phy_interface_state_e new_state, uint8_
|
|||
*/
|
||||
static int8_t rf_extension(phy_extension_type_e extension_type, uint8_t *data_ptr)
|
||||
{
|
||||
switch (extension_type)
|
||||
{
|
||||
switch (extension_type) {
|
||||
/* Control MAC pending bit for Indirect data transmission */
|
||||
case PHY_EXTENSION_CTRL_PENDING_BIT:
|
||||
if(*data_ptr) {
|
||||
if (*data_ptr) {
|
||||
data_pending = true;
|
||||
} else {
|
||||
data_pending = false;
|
||||
|
@ -660,7 +658,7 @@ static int8_t rf_extension(phy_extension_type_e extension_type, uint8_t *data_pt
|
|||
break;
|
||||
/* Return frame pending bit from last received ACK */
|
||||
case PHY_EXTENSION_READ_LAST_ACK_PENDING_STATUS:
|
||||
if(last_ack_pending_bit) {
|
||||
if (last_ack_pending_bit) {
|
||||
*data_ptr = 0xFF;
|
||||
} else {
|
||||
*data_ptr = 0;
|
||||
|
@ -703,8 +701,7 @@ static int8_t rf_extension(phy_extension_type_e extension_type, uint8_t *data_pt
|
|||
static int8_t rf_address_write(phy_address_type_e address_type, uint8_t *address_ptr)
|
||||
{
|
||||
int8_t ret_val = 0;
|
||||
switch (address_type)
|
||||
{
|
||||
switch (address_type) {
|
||||
/*Set 48-bit address*/
|
||||
case PHY_MAC_48BIT:
|
||||
// 15.4 does not support 48-bit addressing
|
||||
|
@ -715,13 +712,13 @@ static int8_t rf_address_write(phy_address_type_e address_type, uint8_t *address
|
|||
/* Store MAC in MSB order */
|
||||
memcpy(MAC_address, address_ptr, 8);
|
||||
SL_DEBUG_PRINT("rf_address_write: MACw ");
|
||||
for(unsigned int i = 0; i < sizeof(MAC_address); i ++) {
|
||||
for (unsigned int i = 0; i < sizeof(MAC_address); i ++) {
|
||||
SL_DEBUG_PRINT("%02x:", MAC_address[i]);
|
||||
}
|
||||
SL_DEBUG_PRINT("\n");
|
||||
/* Pass MAC to the RF driver in LSB order */
|
||||
uint8_t MAC_reversed[8];
|
||||
for(unsigned int i = 0; i < sizeof(MAC_address); i ++) {
|
||||
for (unsigned int i = 0; i < sizeof(MAC_address); i ++) {
|
||||
MAC_reversed[i] = MAC_address[sizeof(MAC_address) - 1 - i];
|
||||
}
|
||||
RAIL_IEEE802154_SetLongAddress(gRailHandle, MAC_reversed, 0);
|
||||
|
@ -841,7 +838,8 @@ uint32_t NanostackRfPhyEfr32::get_driver_version()
|
|||
* Callback that lets the app know when the radio has finished init
|
||||
* and is ready.
|
||||
*/
|
||||
static void RAILCb_RfReady(RAIL_Handle_t handle) {
|
||||
static void RAILCb_RfReady(RAIL_Handle_t handle)
|
||||
{
|
||||
(void) handle;
|
||||
radio_state = RADIO_IDLE;
|
||||
}
|
||||
|
@ -854,20 +852,21 @@ static void RAILCb_RfReady(RAIL_Handle_t handle) {
|
|||
* @return bool True if able to switch to the requested channel
|
||||
*
|
||||
*/
|
||||
static bool rail_checkAndSwitchChannel(uint8_t newChannel) {
|
||||
if(channel == newChannel) {
|
||||
static bool rail_checkAndSwitchChannel(uint8_t newChannel)
|
||||
{
|
||||
if (channel == newChannel) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(newChannel > 0 && newChannel < 11) {
|
||||
if(MBED_CONF_SL_RAIL_BAND == 915) {
|
||||
if (newChannel > 0 && newChannel < 11) {
|
||||
if (MBED_CONF_SL_RAIL_BAND == 915) {
|
||||
channel = newChannel;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if(newChannel >= 11 && newChannel <= 26) {
|
||||
if(MBED_CONF_SL_RAIL_BAND == 2400) {
|
||||
} else if (newChannel >= 11 && newChannel <= 26) {
|
||||
if (MBED_CONF_SL_RAIL_BAND == 2400) {
|
||||
channel = newChannel;
|
||||
return true;
|
||||
} else {
|
||||
|
@ -888,11 +887,12 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
|
|||
/* RAIL_Events_t is a 64-bit event mask, but a thread only supports 32
|
||||
* signal bits. This means we have to convert from a RAIL event mask to
|
||||
* our own custom event mask. */
|
||||
if (railHandle != gRailHandle)
|
||||
if (railHandle != gRailHandle) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef MBED_CONF_RTOS_PRESENT
|
||||
if(rf_thread_id == 0) {
|
||||
if (rf_thread_id == 0) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -900,7 +900,7 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
|
|||
size_t index = 0;
|
||||
do {
|
||||
if (events & 1ull) {
|
||||
switch(index) {
|
||||
switch (index) {
|
||||
/*
|
||||
* Occurs when the AGC averaged RSSI is done.
|
||||
* It occurs in response to RAIL_StartAverageRssi() to indicate that the
|
||||
|
@ -920,12 +920,12 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
|
|||
* ACK is exceeded.
|
||||
*/
|
||||
case RAIL_EVENT_RX_ACK_TIMEOUT_SHIFT:
|
||||
if(waiting_for_ack) {
|
||||
if (waiting_for_ack) {
|
||||
waiting_for_ack = false;
|
||||
#ifdef MBED_CONF_RTOS_PRESENT
|
||||
osSignalSet(rf_thread_id, SL_ACK_TIMEOUT);
|
||||
#else
|
||||
device_driver.phy_tx_done_cb( rf_radio_driver_id,
|
||||
device_driver.phy_tx_done_cb(rf_radio_driver_id,
|
||||
current_tx_handle,
|
||||
PHY_LINK_TX_FAIL,
|
||||
1,
|
||||
|
@ -955,8 +955,7 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
|
|||
* If \ref RAIL_RX_OPTION_IGNORE_CRC_ERRORS is set, this event also occurs
|
||||
* for packets with CRC errors.
|
||||
*/
|
||||
case RAIL_EVENT_RX_PACKET_RECEIVED_SHIFT:
|
||||
{
|
||||
case RAIL_EVENT_RX_PACKET_RECEIVED_SHIFT: {
|
||||
/* Get RX packet that got signaled */
|
||||
RAIL_RxPacketInfo_t rxPacketInfo;
|
||||
RAIL_RxPacketHandle_t rxHandle = RAIL_GetRxPacketInfo(gRailHandle,
|
||||
|
@ -965,12 +964,12 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
|
|||
);
|
||||
|
||||
/* Only process the packet if it had a correct CRC */
|
||||
if(rxPacketInfo.packetStatus == RAIL_RX_PACKET_READY_SUCCESS) {
|
||||
if (rxPacketInfo.packetStatus == RAIL_RX_PACKET_READY_SUCCESS) {
|
||||
uint8_t header[4];
|
||||
RAIL_PeekRxPacket(gRailHandle, rxHandle, header, 4, 0);
|
||||
|
||||
/* If this is an ACK, deal with it early */
|
||||
if( (header[0] == 5) &&
|
||||
if ((header[0] == 5) &&
|
||||
(header[3] == current_tx_sequence) &&
|
||||
waiting_for_ack) {
|
||||
/* Tell the radio to not ACK an ACK */
|
||||
|
@ -985,7 +984,7 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
|
|||
osSignalSet(rf_thread_id, SL_ACK_RECV | (last_ack_pending_bit ? SL_ACK_PEND : 0));
|
||||
#else
|
||||
SL_DEBUG_PRINT("rACK\n");
|
||||
device_driver.phy_tx_done_cb( rf_radio_driver_id,
|
||||
device_driver.phy_tx_done_cb(rf_radio_driver_id,
|
||||
current_tx_handle,
|
||||
last_ack_pending_bit ? PHY_LINK_TX_DONE_PENDING : PHY_LINK_TX_DONE,
|
||||
1,
|
||||
|
@ -1007,7 +1006,7 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
|
|||
}
|
||||
|
||||
/* Copy into queue */
|
||||
uint8_t* packetBuffer = (uint8_t*)rx_queue[rx_queue_head];
|
||||
uint8_t *packetBuffer = (uint8_t *)rx_queue[rx_queue_head];
|
||||
#else
|
||||
/* Packet going temporarily onto stack for bare-metal apps */
|
||||
uint8_t packetBuffer[MAC_PACKET_MAX_LENGTH + MAC_PACKET_INFO_LENGTH];
|
||||
|
@ -1031,7 +1030,7 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
|
|||
* [1] => b[0:2] frame type, b[3] = security enabled, b[4] = frame pending, b[5] = ACKreq, b[6] = intrapan
|
||||
* [2] => b[2:3] destmode, b[4:5] version, b[6:7] srcmode
|
||||
*/
|
||||
if( (packetBuffer[MAC_PACKET_INFO_LENGTH + 1] & (1 << 5)) == 0 ) {
|
||||
if ((packetBuffer[MAC_PACKET_INFO_LENGTH + 1] & (1 << 5)) == 0) {
|
||||
/* Cancel the ACK if the sender did not request one */
|
||||
RAIL_CancelAutoAck(gRailHandle);
|
||||
}
|
||||
|
@ -1109,7 +1108,7 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
|
|||
* packet.
|
||||
*/
|
||||
case RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND_SHIFT:
|
||||
if(data_pending) {
|
||||
if (data_pending) {
|
||||
RAIL_IEEE802154_SetFramePending(gRailHandle);
|
||||
}
|
||||
break;
|
||||
|
@ -1142,8 +1141,8 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
|
|||
#ifdef MBED_CONF_RTOS_PRESENT
|
||||
osSignalSet(rf_thread_id, SL_TX_DONE);
|
||||
#else
|
||||
if(device_driver.phy_tx_done_cb != NULL) {
|
||||
device_driver.phy_tx_done_cb( rf_radio_driver_id,
|
||||
if (device_driver.phy_tx_done_cb != NULL) {
|
||||
device_driver.phy_tx_done_cb(rf_radio_driver_id,
|
||||
current_tx_handle,
|
||||
// Normally we'd switch on ACK requested here, but Nanostack does that for us.
|
||||
PHY_LINK_TX_SUCCESS,
|
||||
|
@ -1272,8 +1271,7 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
|
|||
}
|
||||
events = events >> 1;
|
||||
index += 1;
|
||||
}
|
||||
while (events != 0);
|
||||
} while (events != 0);
|
||||
}
|
||||
|
||||
NanostackRfPhy &NanostackRfPhy::get_default_instance()
|
||||
|
|
Loading…
Reference in New Issue