Skip to content

Commit

Permalink
Uncrustify and static check
Browse files Browse the repository at this point in the history
  • Loading branch information
bergzand committed Jan 11, 2017
1 parent b6ff23d commit a491dd0
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 102 deletions.
16 changes: 4 additions & 12 deletions drivers/include/mrf24j40.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ extern "C" {
/** @} */


#define MRF24J40_TASK_TX_DONE (0x01)
#define MRF24J40_TASK_TX_READY (0x02)
#define MRF24J40_TASK_RX_READY (0x04)
#define MRF24J40_TASK_TX_DONE (0x01) /**< TX operation is done */
#define MRF24J40_TASK_TX_READY (0x02) /**< TX operation results ready for processing */
#define MRF24J40_TASK_RX_READY (0x04) /**< RX processing needed */

#define MRF24J40_MAX_FRAME_RETRIES (3U)
#define MRF24J40_MAX_FRAME_RETRIES (3U) /**< Number of frame retries (fixed) */

/**
* @brief struct holding all params needed for device initialization
Expand Down Expand Up @@ -447,14 +447,6 @@ size_t mrf24j40_tx_load(mrf24j40_t *dev, uint8_t *data, size_t len,
*/
void mrf24j40_tx_exec(mrf24j40_t *dev);

/**
* @brief Initialize the MRF24J40 Interrupt / Port and Pin of uC
*
* @param dev device to read from
*/
void init_mrf24j40_int(void);


#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion drivers/mrf24j40/Makefile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include $(RIOTBASE)/Makefile.base
include $(RIOTBASE)/Makefile.base
8 changes: 8 additions & 0 deletions drivers/mrf24j40/include/mrf24j40_internal.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright (C) 2017 Koen Zandberg <[email protected]>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup drivers_mrf24j40
* @{
Expand Down
17 changes: 12 additions & 5 deletions drivers/mrf24j40/include/mrf24j40_registers.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright (C) 2017 Koen Zandberg <[email protected]>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup drivers_mrf24j40
* @{
Expand All @@ -18,7 +26,7 @@ extern "C" {

/**
* @brief SPI access specifiers
****@{
*****@{
*/
#define MRF24J40_SHORT_ADDR_TRANS (0x00)
#define MRF24J40_LONG_ADDR_TRANS (0x80)
Expand All @@ -30,7 +38,7 @@ extern "C" {

/**
* @brief FIFO-Address-Map
***@{
****@{
*/
#define MRF24J40_TX_NORMAL_FIFO (0x000)
#define MRF24J40_TX_BEACON_FIFO (0x080)
Expand All @@ -41,7 +49,7 @@ extern "C" {

/**
* @brief Short-Register addresses
****@{
*****@{
*/
#define MRF24J40_REG_RXMCR (0x00)
#define MRF24J40_REG_PANIDL (0x01)
Expand Down Expand Up @@ -105,7 +113,7 @@ extern "C" {

/**
* @brief Long-Register addresses
****@{
*****@{
*/
#define MRF24J40_REG_RFCON0 (0x200)
#define MRF24J40_REG_RFCON1 (0x201)
Expand Down Expand Up @@ -436,4 +444,3 @@ extern "C" {

#endif /* MRF24J40_REGISTERS_H */
/** @} */

9 changes: 4 additions & 5 deletions drivers/mrf24j40/mrf24j40.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void mrf24j40_tx_prepare(mrf24j40_t *dev)

do {
mrf24j40_update_tasks(dev);
} while(!(dev->pending & MRF24J40_TASK_TX_DONE));
} while (!(dev->pending & MRF24J40_TASK_TX_DONE));
mrf24j40_assert_awake(dev);
dev->pending &= ~(MRF24J40_TASK_TX_DONE);
dev->tx_frame_len = IEEE802154_FCS_LEN;
Expand Down Expand Up @@ -185,11 +185,10 @@ void mrf24j40_tx_exec(mrf24j40_t *dev)
mrf24j40_reg_write_long(dev, MRF24J40_TX_NORMAL_FIFO, dev->header_len);

if (dev->netdev.flags & NETDEV2_IEEE802154_ACK_REQ) {
mrf24j40_reg_write_short(dev, MRF24J40_REG_TXNCON, MRF24J40_TXNCON_TXNACKREQ|MRF24J40_TXNCON_TXNTRIG);
mrf24j40_reg_write_short(dev, MRF24J40_REG_TXNCON, MRF24J40_TXNCON_TXNACKREQ | MRF24J40_TXNCON_TXNTRIG);
}
else
{
mrf24j40_reg_write_short(dev, MRF24J40_REG_TXNCON, MRF24J40_TXNCON_TXNTRIG);
else {
mrf24j40_reg_write_short(dev, MRF24J40_REG_TXNCON, MRF24J40_TXNCON_TXNTRIG);
}
if (netdev->event_callback && (dev->netdev.flags & MRF24J40_OPT_TELL_TX_START)) {
netdev->event_callback(netdev, NETDEV2_EVENT_TX_STARTED);
Expand Down
69 changes: 35 additions & 34 deletions drivers/mrf24j40/mrf24j40_getset.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,37 +73,37 @@ static const uint8_t dbm_to_tx_pow[] = { 0x00, 0x10, 0x18, 0x20, 0x28, 0x30, 0x3

/* take a look onto datasheet table 3-8 */
static const int8_t dBm_value[] = { 95, 89, 88, 88, 87, 87, 87, 87, \
86, 86, 86, 86, 85, 85, 85, 85, \
84, 84, 84, 84, 84, 84, 83, 83, \
83, 83, 82, 82, 82, 82, 81, 81, \
81, 81, 81, 80, 80, 80, 80, 80, \
80, 79, 79, 79, 79, 79, 78, 78, \
78, 78, 78, 77, 77, 77, 77, 77, \
76, 76, 76, 76, 76, 75, 75, 75, \
75, 75, 75, 74, 74, 74, 74, 73, \
73, 73, 73, 73, 72, 72, 72, 72, \
72, 71, 71, 71, 71, 71, 70, 70, \
70, 70, 70, 70, 70, 69, 69, 69, \
69, 69, 68, 68, 68, 68, 68, 68, \
68, 67, 67, 67, 67, 66, 66, 66, \
66, 66, 66, 65, 65, 65, 65, 65, \
64, 64, 64, 64, 63, 63, 63, 63, \
62, 62, 62, 62, 61, 61, 61, 61, \
60, 60, 60, 60, 60, 59, 59, 59, \
59, 59, 58, 58, 58, 58, 58, 57, \
57, 57, 57, 57, 57, 56, 56, 56, \
56, 56, 56, 56, 55, 55, 55, 55, \
54, 54, 54, 54, 54, 54, 53, 53, \
53, 53, 53, 53, 53, 52, 52, 52, \
52, 52, 52, 51, 51, 51, 51, 51, \
50, 50, 50, 50, 50, 49, 49, 49, \
49, 49, 48, 48, 48, 48, 47, 47, \
47, 47, 47, 46, 46, 46, 46, 45, \
45, 45, 45, 44, 44, 44, 44, 44, \
43, 43, 43, 42, 42, 42, 42, 41, \
41, 41, 41, 41, 41, 40, 40, 40, \
40, 40, 39, 39, 39, 39, 39, 38, \
38, 38, 38, 37, 37, 37, 36, 30 };
86, 86, 86, 86, 85, 85, 85, 85, \
84, 84, 84, 84, 84, 84, 83, 83, \
83, 83, 82, 82, 82, 82, 81, 81, \
81, 81, 81, 80, 80, 80, 80, 80, \
80, 79, 79, 79, 79, 79, 78, 78, \
78, 78, 78, 77, 77, 77, 77, 77, \
76, 76, 76, 76, 76, 75, 75, 75, \
75, 75, 75, 74, 74, 74, 74, 73, \
73, 73, 73, 73, 72, 72, 72, 72, \
72, 71, 71, 71, 71, 71, 70, 70, \
70, 70, 70, 70, 70, 69, 69, 69, \
69, 69, 68, 68, 68, 68, 68, 68, \
68, 67, 67, 67, 67, 66, 66, 66, \
66, 66, 66, 65, 65, 65, 65, 65, \
64, 64, 64, 64, 63, 63, 63, 63, \
62, 62, 62, 62, 61, 61, 61, 61, \
60, 60, 60, 60, 60, 59, 59, 59, \
59, 59, 58, 58, 58, 58, 58, 57, \
57, 57, 57, 57, 57, 56, 56, 56, \
56, 56, 56, 56, 55, 55, 55, 55, \
54, 54, 54, 54, 54, 54, 53, 53, \
53, 53, 53, 53, 53, 52, 52, 52, \
52, 52, 52, 51, 51, 51, 51, 51, \
50, 50, 50, 50, 50, 49, 49, 49, \
49, 49, 48, 48, 48, 48, 47, 47, \
47, 47, 47, 46, 46, 46, 46, 45, \
45, 45, 45, 44, 44, 44, 44, 44, \
43, 43, 43, 42, 42, 42, 42, 41, \
41, 41, 41, 41, 41, 40, 40, 40, \
40, 40, 39, 39, 39, 39, 39, 38, \
38, 38, 38, 37, 37, 37, 36, 30 };

/* take a look onto datasheet table 3-8 */
static const uint8_t RSSI_value[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
Expand Down Expand Up @@ -268,6 +268,7 @@ int16_t mrf24j40_get_txpower(mrf24j40_t *dev)
void mrf24j40_set_txpower(mrf24j40_t *dev, int16_t txpower)
{
uint8_t txpower_reg_value;

/* positive values are better with a conversion array */
txpower = (txpower < 0) ? -1 * txpower : txpower;
txpower = (txpower > 36) ? 36 : txpower;
Expand All @@ -294,6 +295,7 @@ uint8_t mrf24j40_get_csma_max_retries(mrf24j40_t *dev)
void mrf24j40_set_csma_max_retries(mrf24j40_t *dev, int8_t retries)
{
uint8_t tmp;

/* get current register settings */
tmp = mrf24j40_reg_read_short(dev, MRF24J40_REG_TXMCR);
/* clear csma bits */
Expand All @@ -311,7 +313,7 @@ int8_t mrf24j40_get_cca_threshold(mrf24j40_t *dev)
{
int8_t tmp;

tmp = mrf24j40_reg_read_short(dev, MRF24J40_REG_CCAEDTH); /* Energy detection threshold */
tmp = mrf24j40_reg_read_short(dev, MRF24J40_REG_CCAEDTH); /* Energy detection threshold */

return(dBm_value[tmp]); /* in dBm */
}
Expand Down Expand Up @@ -477,6 +479,7 @@ void mrf24j40_assert_awake(mrf24j40_t *dev)
void mrf24j40_reset_state_machine(mrf24j40_t *dev)
{
uint8_t rfstate;

mrf24j40_reg_write_short(dev, MRF24J40_REG_RFCTL, MRF24J40_RFCTL_RFRST);
mrf24j40_reg_write_short(dev, MRF24J40_REG_RFCTL, 0x00);
xtimer_usleep(MRF24J40_STATE_RESET_DELAY); /* Delay at least 192us */
Expand All @@ -494,5 +497,3 @@ void mrf24j40_software_reset(mrf24j40_t *dev)
softrst = mrf24j40_reg_read_short(dev, MRF24J40_REG_SOFTRST);
} while (softrst != 0); /* wait until soft-reset has finished */
}


47 changes: 29 additions & 18 deletions drivers/mrf24j40/mrf24j40_internal.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright (C) 2017 Koen Zandberg <[email protected]>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup drivers_mrf24j40
* @{
Expand All @@ -22,6 +30,7 @@ void mrf24j40_init(mrf24j40_t *dev)
{
uint8_t softrst;
uint8_t order;

mrf24j40_hardware_reset(dev);
/* do a soft reset */
mrf24j40_reg_write_short(dev, MRF24J40_REG_SOFTRST, 0x7); // from manual
Expand All @@ -38,21 +47,21 @@ void mrf24j40_init(mrf24j40_t *dev)
mrf24j40_reg_write_short(dev, MRF24J40_REG_RXFLUSH, MRF24J40_RXFLUSH_RXFLUSH);

/* Here starts init-process as described on MRF24J40 Manual Chap. 3.2 */
mrf24j40_reg_write_short(dev, MRF24J40_REG_PACON2, ( MRF24J40_PACON2_TXONTS2 |
MRF24J40_PACON2_TXONTS1 |
MRF24J40_PACON2_FIFOEN) );
mrf24j40_reg_write_short(dev, MRF24J40_REG_TXSTBL, ( MRF24J40_TXSTBL_RFSTBL3 |
MRF24J40_TXSTBL_RFSTBL0 |
MRF24J40_TXSTBL_MSIFS2 |
MRF24J40_TXSTBL_MSIFS0 ));
mrf24j40_reg_write_short(dev, MRF24J40_REG_PACON2, (MRF24J40_PACON2_TXONTS2 |
MRF24J40_PACON2_TXONTS1 |
MRF24J40_PACON2_FIFOEN));
mrf24j40_reg_write_short(dev, MRF24J40_REG_TXSTBL, (MRF24J40_TXSTBL_RFSTBL3 |
MRF24J40_TXSTBL_RFSTBL0 |
MRF24J40_TXSTBL_MSIFS2 |
MRF24J40_TXSTBL_MSIFS0));
mrf24j40_reg_write_long(dev, MRF24J40_REG_RFCON1, MRF24J40_RFCON1_VCOOPT1);
mrf24j40_reg_write_long(dev, MRF24J40_REG_RFCON2, MRF24J40_RFCON2_PLLEN);
mrf24j40_reg_write_long(dev, MRF24J40_REG_RFCON6, ( MRF24J40_RFCON6_TXFIL |
MRF24J40_RFCON6_20MRECVR ));
mrf24j40_reg_write_long(dev, MRF24J40_REG_RFCON6, (MRF24J40_RFCON6_TXFIL |
MRF24J40_RFCON6_20MRECVR));
mrf24j40_reg_write_long(dev, MRF24J40_REG_RFCON7, MRF24J40_RFCON7_SLPCLKSEL1 );
mrf24j40_reg_write_long(dev, MRF24J40_REG_RFCON8, MRF24J40_RFCON8_RFVCO );
mrf24j40_reg_write_long(dev, MRF24J40_REG_SLPCON1, ( MRF24J40_SLPCON1_CLKOUTEN |
MRF24J40_SLPCON1_SLPCLKDIV0 ));
mrf24j40_reg_write_long(dev, MRF24J40_REG_SLPCON1, (MRF24J40_SLPCON1_CLKOUTEN |
MRF24J40_SLPCON1_SLPCLKDIV0));
mrf24j40_reg_write_short(dev, MRF24J40_REG_BBREG2, MRF25J40_BBREG2_CCAMODE1 );
mrf24j40_reg_write_short(dev, MRF24J40_REG_CCAEDTH, 0x60);
mrf24j40_reg_write_short(dev, MRF24J40_REG_BBREG6, MRF24J40_BBREG6_RSSIMODE2 );
Expand All @@ -69,7 +78,7 @@ void mrf24j40_init(mrf24j40_t *dev)
mrf24j40_reg_read_short(dev, MRF24J40_REG_INTSTAT);

/* mrf24j40_set_interrupts */
mrf24j40_reg_write_short(dev, MRF24J40_REG_INTCON, ~( MRF24J40_INTCON_RXIE | MRF24J40_INTCON_TXNIE ));
mrf24j40_reg_write_short(dev, MRF24J40_REG_INTCON, ~(MRF24J40_INTCON_RXIE | MRF24J40_INTCON_TXNIE));
//Wait until the RFSTATE machine indicates RX state
}

Expand Down Expand Up @@ -200,18 +209,20 @@ void mrf24j40_reset_tasks(mrf24j40_t *dev)

void mrf24j40_update_tasks(mrf24j40_t *dev)
{
uint8_t instat = 0;
uint8_t newpending = 0;
if(dev->irq_flag){

if (dev->irq_flag) {
uint8_t newpending = 0;
uint8_t instat = 0;

dev->irq_flag = 0;
instat = mrf24j40_reg_read_short(dev, MRF24J40_REG_INTSTAT);
/* check if TX done */
if(instat & MRF24J40_INTSTAT_TXNIF){
newpending |= MRF24J40_TASK_TX_DONE |MRF24J40_TASK_TX_READY;
if (instat & MRF24J40_INTSTAT_TXNIF) {
newpending |= MRF24J40_TASK_TX_DONE | MRF24J40_TASK_TX_READY;
/* transmit done, returning to configured idle state */
mrf24j40_assert_sleep(dev);
}
if(instat & MRF24J40_INTSTAT_RXIF){
if (instat & MRF24J40_INTSTAT_RXIF) {
newpending |= MRF24J40_TASK_RX_READY;
}
/* check if RX pending */
Expand Down
Loading

0 comments on commit a491dd0

Please sign in to comment.