2222#include <errno.h>
2323
2424#include "cpu.h"
25- #include "luid.h"
2625#include "nrf_clock.h"
2726
2827#include "net/ieee802154.h"
@@ -207,7 +206,7 @@ static void _disable_blocking(void)
207206
208207static int _request_op (ieee802154_dev_t * dev , ieee802154_hal_op_t op , void * ctx )
209208{
210- (void ) dev ;
209+ (void )dev ;
211210
212211 int res = - EBUSY ;
213212 int state = STATE_IDLE ;
@@ -264,7 +263,7 @@ static int _request_op(ieee802154_dev_t *dev, ieee802154_hal_op_t op, void *ctx)
264263
265264static int _confirm_op (ieee802154_dev_t * dev , ieee802154_hal_op_t op , void * ctx )
266265{
267- (void ) dev ;
266+ (void )dev ;
268267 bool eagain ;
269268 ieee802154_tx_info_t * info = ctx ;
270269 int state = _state ;
@@ -315,46 +314,36 @@ static int _confirm_op(ieee802154_dev_t *dev, ieee802154_hal_op_t op, void *ctx)
315314 return 0 ;
316315}
317316
318- /**
319- * @brief Convert from the internal representation to dBm, when the
320- * radio operates as a IEEE802.15.4 transceiver.
321- */
322- static inline int8_t _hwval_to_ieee802154_dbm (uint8_t hwval )
323- {
324- return (ED_RSSISCALE * hwval ) + ED_RSSIOFFS ;
325- }
326-
327317static int _read (ieee802154_dev_t * dev , void * buf , size_t max_size ,
328318 ieee802154_rx_info_t * info )
329319{
330- (void ) dev ;
320+ (void )dev ;
331321 size_t pktlen = (size_t )rxbuf [0 ] - IEEE802154_FCS_LEN ;
332322 int res = - ENOBUFS ;
333323
334324 if (max_size < pktlen ) {
335325 DEBUG ("[nrf802154] recv: buffer is to small\n" );
336326 return res ;
337327 }
338- else {
339- DEBUG ("[nrf802154] recv: reading packet of length %i\n" , pktlen );
340- if (info != NULL ) {
341- ieee802154_rx_info_t * radio_info = info ;
342- /* Hardware link quality indicator */
343- uint8_t hwlqi = rxbuf [pktlen + 1 ];
344- /* Convert to 802.15.4 LQI (page 319 of product spec v1.1) */
345- radio_info -> lqi = (uint8_t )(hwlqi > UINT8_MAX /ED_RSSISCALE
346- ? UINT8_MAX
347- : hwlqi * ED_RSSISCALE );
348- /* Converting the hardware-provided LQI value back to the
349- original RSSI value is not properly documented in the PS.
350- The linear mapping used here has been found empirically
351- through comparison with the RSSI value provided by NRF_RADIO->RSSISAMPLE
352- after enabling the ADDRESS_RSSISTART short. */
353- int8_t rssi_dbm = hwlqi + ED_RSSIOFFS - 1 ;
354- radio_info -> rssi = ieee802154_dbm_to_rssi (rssi_dbm );
355- }
356- memcpy (buf , & rxbuf [1 ], pktlen );
357- }
328+
329+ DEBUG ("[nrf802154] recv: reading packet of length %i\n" , pktlen );
330+ if (info != NULL ) {
331+ ieee802154_rx_info_t * radio_info = info ;
332+ /* Hardware link quality indicator */
333+ uint8_t hwlqi = rxbuf [pktlen + 1 ];
334+ /* Convert to 802.15.4 LQI (page 319 of product spec v1.1) */
335+ radio_info -> lqi = (uint8_t )(hwlqi > UINT8_MAX /ED_RSSISCALE
336+ ? UINT8_MAX
337+ : hwlqi * ED_RSSISCALE );
338+ /* Converting the hardware-provided LQI value back to the
339+ original RSSI value is not properly documented in the PS.
340+ The linear mapping used here has been found empirically
341+ through comparison with the RSSI value provided by NRF_RADIO->RSSISAMPLE
342+ after enabling the ADDRESS_RSSISTART short. */
343+ int16_t rssi_dbm = hwlqi + ED_RSSIOFFS - 1 ;
344+ radio_info -> rssi = ieee802154_dbm_to_rssi (rssi_dbm );
345+ }
346+ memcpy (buf , & rxbuf [1 ], pktlen );
358347
359348 return pktlen ;
360349}
@@ -370,7 +359,7 @@ static inline uint8_t _dbm_to_ieee802154_hwval(int8_t dbm)
370359
371360static int set_cca_threshold (ieee802154_dev_t * dev , int8_t threshold )
372361{
373- (void ) dev ;
362+ (void )dev ;
374363
375364 if (threshold < ED_RSSIOFFS ) {
376365 return - EINVAL ;
@@ -532,7 +521,7 @@ void isr_radio(void)
532521 bool is_ack = rxbuf [1 ] & IEEE802154_FCF_TYPE_ACK ;
533522 bool ack_req = rxbuf [1 ] & IEEE802154_FCF_ACK_REQ ;
534523
535- /* If radio is in promiscuos mode, indicate packet and
524+ /* If radio is in promiscuous mode, indicate packet and
536525 * don't event think of sending an ACK frame :) */
537526 if (cfg .promisc ) {
538527 DEBUG ("[nrf802154] Promiscuous mode is enabled.\n" );
@@ -594,13 +583,13 @@ void isr_radio(void)
594583
595584static int _confirm_on (ieee802154_dev_t * dev )
596585{
597- (void ) dev ;
586+ (void )dev ;
598587 return 0 ;
599588}
600589
601590static int _request_on (ieee802154_dev_t * dev )
602591{
603- (void ) dev ;
592+ (void )dev ;
604593 _state = STATE_IDLE ;
605594 DEBUG ("[nrf802154]: Request to turn on\n" );
606595 _power_on ();
@@ -641,7 +630,7 @@ static int _request_on(ieee802154_dev_t *dev)
641630
642631static int _config_phy (ieee802154_dev_t * dev , const ieee802154_phy_conf_t * conf )
643632{
644- (void ) dev ;
633+ (void )dev ;
645634 int8_t pow = conf -> pow ;
646635
647636 if (pow < TX_POWER_MIN || pow > TX_POWER_MAX ) {
@@ -666,22 +655,22 @@ static int _config_phy(ieee802154_dev_t *dev, const ieee802154_phy_conf_t *conf)
666655
667656static int _off (ieee802154_dev_t * dev )
668657{
669- (void ) dev ;
658+ (void )dev ;
670659 DEBUG ("[nrf802154] Turning off the radio\n" );
671660 _power_off ();
672661 return 0 ;
673662}
674663
675664int _len (ieee802154_dev_t * dev )
676665{
677- (void ) dev ;
666+ (void )dev ;
678667 DEBUG ("[nrf802154] Length of frame is %i\n" , (size_t )rxbuf [0 ] - IEEE802154_FCS_LEN );
679668 return (size_t )rxbuf [0 ] - IEEE802154_FCS_LEN ;
680669}
681670
682671int _set_cca_mode (ieee802154_dev_t * dev , ieee802154_cca_mode_t mode )
683672{
684- (void ) dev ;
673+ (void )dev ;
685674
686675 NRF_RADIO -> CCACTRL &= RADIO_CCACTRL_CCAMODE_Msk ;
687676 uint8_t tmp = 0 ;
@@ -712,9 +701,9 @@ int _set_cca_mode(ieee802154_dev_t *dev, ieee802154_cca_mode_t mode)
712701
713702static int _config_addr_filter (ieee802154_dev_t * dev , ieee802154_af_cmd_t cmd , const void * value )
714703{
715- (void ) dev ;
704+ (void )dev ;
716705 const uint16_t * pan_id = value ;
717- switch (cmd ) {
706+ switch (cmd ) {
718707 case IEEE802154_AF_SHORT_ADDR :
719708 memcpy (nrf802154_short_addr , value , IEEE802154_SHORT_ADDRESS_LEN );
720709 break ;
@@ -731,10 +720,11 @@ static int _config_addr_filter(ieee802154_dev_t *dev, ieee802154_af_cmd_t cmd, c
731720 return 0 ;
732721}
733722
734- static int _config_src_addr_match (ieee802154_dev_t * dev , ieee802154_src_match_t cmd , const void * value )
723+ static int _config_src_addr_match (ieee802154_dev_t * dev , ieee802154_src_match_t cmd ,
724+ const void * value )
735725{
736- (void ) dev ;
737- switch (cmd ) {
726+ (void )dev ;
727+ switch (cmd ) {
738728 case IEEE802154_SRC_MATCH_EN :
739729 cfg .pending = * ((const bool * ) value );
740730 break ;
@@ -746,7 +736,7 @@ static int _config_src_addr_match(ieee802154_dev_t *dev, ieee802154_src_match_t
746736
747737static int _set_frame_filter_mode (ieee802154_dev_t * dev , ieee802154_filter_mode_t mode )
748738{
749- (void ) dev ;
739+ (void )dev ;
750740
751741 bool ackf = true;
752742 bool _promisc = false;
@@ -773,8 +763,8 @@ static int _set_frame_filter_mode(ieee802154_dev_t *dev, ieee802154_filter_mode_
773763static int _set_csma_params (ieee802154_dev_t * dev , const ieee802154_csma_be_t * bd ,
774764 int8_t retries )
775765{
776- (void ) dev ;
777- (void ) bd ;
766+ (void )dev ;
767+ (void )bd ;
778768
779769 if (retries > 0 ) {
780770 return - ENOTSUP ;
@@ -787,7 +777,7 @@ static int _set_csma_params(ieee802154_dev_t *dev, const ieee802154_csma_be_t *b
787777
788778void nrf802154_setup (nrf802154_t * dev )
789779{
790- (void ) dev ;
780+ (void )dev ;
791781 nrf802154_init ();
792782}
793783
0 commit comments