Skip to content

Commit

Permalink
drivers/kw2xrf: cleanup defines in main header file
Browse files Browse the repository at this point in the history
  • Loading branch information
smlng committed Feb 2, 2017
1 parent 751515d commit 1ea06a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 27 deletions.
32 changes: 10 additions & 22 deletions drivers/include/kw2xrf.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
*
* @author Johann Fischer <j.fischer@phytec.de>
* @author Jonas Remmert <j.remmert@phytec.de>
* @author Sebastian Meiling <s@mlng.net>
*/

#ifndef MKW2XDRF_H
#define MKW2XDRF_H
#ifndef KW2XDRF_H
#define KW2XDRF_H

#include <stdint.h>

Expand All @@ -38,33 +39,20 @@ extern "C" {
/**
* @brief Maximum packet length
*/
#define KW2XRF_MAX_PKT_LENGTH (IEEE802154_FRAME_LEN_MAX)

/**
* @brief Default short address used after initialization
*/
#define KW2XRF_DEFAULT_SHORT_ADDR (0x0042)

/**
* @brief Default short address used after initialization
*/
#define KW2XRF_DEFAULT_ADDR_LONG (0x0000000DEADCAB1E)
#define KW2XRF_MAX_PKT_LENGTH (IEEE802154_FRAME_LEN_MAX)

/**
* @brief Default PAN ID used after initialization
*/
#define KW2XRF_DEFAULT_PANID (IEEE802154_DEFAULT_PANID)
#define KW2XRF_DEFAULT_PANID (IEEE802154_DEFAULT_PANID)

/**
* @brief Default channel used after initialization
*
* @{
*/
#ifdef DEFAULT_CHANNEL
#define KW2XRF_DEFAULT_CHANNEL (DEFAULT_CHANNEL)
#endif
#ifndef KW2XRF_DEFAULT_CHANNEL
#define KW2XRF_DEFAULT_CHANNEL (IEEE802154_DEFAULT_CHANNEL)
#define KW2XRF_DEFAULT_CHANNEL (IEEE802154_DEFAULT_CHANNEL)
#endif
/** @} */

Expand All @@ -80,17 +68,17 @@ extern "C" {
/**
* @brief Default TX_POWER in dbm used after initialization
*/
#define KW2XRF_DEFAULT_TX_POWER (IEEE802154_DEFAULT_TXPOWER)
#define KW2XRF_DEFAULT_TX_POWER (IEEE802154_DEFAULT_TXPOWER)

/**
* @brief Maximum output power of the kw2x device in dBm
*/
#define MKW2XDRF_OUTPUT_POWER_MAX (8)
#define KW2XDRF_OUTPUT_POWER_MAX (8)

/**
* @brief Minimum output power of the kw2x device in dBm
*/
#define MKW2XDRF_OUTPUT_POWER_MIN (-35)
#define KW2XDRF_OUTPUT_POWER_MIN (-35)

/**
* @brief Internal device option flags
Expand Down Expand Up @@ -182,5 +170,5 @@ void kw2xrf_reset_phy(kw2xrf_t *dev);
}
#endif

#endif /* MKW2XDRF_H */
#endif /* KW2XDRF_H */
/** @} */
10 changes: 5 additions & 5 deletions drivers/kw2xrf/kw2xrf_getset.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ static const uint8_t pow_lt[44] = {

void kw2xrf_set_tx_power(kw2xrf_t *dev, int16_t txpower)
{
if (txpower > MKW2XDRF_OUTPUT_POWER_MAX) {
txpower = MKW2XDRF_OUTPUT_POWER_MAX;
if (txpower > KW2XDRF_OUTPUT_POWER_MAX) {
txpower = KW2XDRF_OUTPUT_POWER_MAX;
}

if (txpower < MKW2XDRF_OUTPUT_POWER_MIN) {
txpower = MKW2XDRF_OUTPUT_POWER_MIN;
if (txpower < KW2XDRF_OUTPUT_POWER_MIN) {
txpower = KW2XDRF_OUTPUT_POWER_MIN;
}

uint8_t level = pow_lt[txpower - MKW2XDRF_OUTPUT_POWER_MIN];
uint8_t level = pow_lt[txpower - KW2XDRF_OUTPUT_POWER_MIN];
kw2xrf_write_dreg(dev, MKW2XDM_PA_PWR, MKW2XDM_PA_PWR(level));
dev->tx_power = txpower;
}
Expand Down

0 comments on commit 1ea06a8

Please sign in to comment.