From 6028c0765fc305b6652f6c1295236618d4c12c5b Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Fri, 18 Apr 2014 18:00:11 +0100 Subject: [PATCH] Don't hardcode min and max TX power values --- cpu/cc2538/dev/cc2538-rf.c | 12 ++++++++---- cpu/cc2538/dev/cc2538-rf.h | 2 -- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cpu/cc2538/dev/cc2538-rf.c b/cpu/cc2538/dev/cc2538-rf.c index bedd92168..88a740a8c 100644 --- a/cpu/cc2538/dev/cc2538-rf.c +++ b/cpu/cc2538/dev/cc2538-rf.c @@ -150,6 +150,10 @@ static const output_config_t output_power[] = { }; #define OUTPUT_CONFIG_COUNT (sizeof(output_power) / sizeof(output_config_t)) + +/* Max and Min Output Power in dBm */ +#define OUTPUT_POWER_MIN (output_power[OUTPUT_CONFIG_COUNT - 1].power) +#define OUTPUT_POWER_MAX (output_power[0].power) /*---------------------------------------------------------------------------*/ PROCESS(cc2538_rf_process, "cc2538 RF driver"); /*---------------------------------------------------------------------------*/ @@ -280,7 +284,7 @@ get_tx_power(void) return output_power[i].power; } } - return CC2538_RF_TX_POWER_MIN; + return OUTPUT_POWER_MIN; } /*---------------------------------------------------------------------------*/ /* @@ -797,10 +801,10 @@ get_value(radio_param_t param, radio_value_t *value) *value = CC2538_RF_CHANNEL_MAX; return RADIO_RESULT_OK; case RADIO_CONST_TXPOWER_MIN: - *value = CC2538_RF_TX_POWER_MIN; + *value = OUTPUT_POWER_MIN; return RADIO_RESULT_OK; case RADIO_CONST_TXPOWER_MAX: - *value = CC2538_RF_TX_POWER_MAX; + *value = OUTPUT_POWER_MAX; return RADIO_RESULT_OK; default: return RADIO_RESULT_NOT_SUPPORTED; @@ -847,7 +851,7 @@ set_value(radio_param_t param, radio_value_t value) return RADIO_RESULT_OK; case RADIO_PARAM_TXPOWER: - if(value < CC2538_RF_TX_POWER_MIN || value > CC2538_RF_TX_POWER_MAX) { + if(value < OUTPUT_POWER_MIN || value > OUTPUT_POWER_MAX) { return RADIO_RESULT_INVALID_VALUE; } diff --git a/cpu/cc2538/dev/cc2538-rf.h b/cpu/cc2538/dev/cc2538-rf.h index 3606ce78f..5edb478ba 100644 --- a/cpu/cc2538/dev/cc2538-rf.h +++ b/cpu/cc2538/dev/cc2538-rf.h @@ -61,8 +61,6 @@ #define CC2538_RF_MIN_PACKET_LEN 4 #define CC2538_RF_CCA_CLEAR 1 #define CC2538_RF_CCA_BUSY 0 -#define CC2538_RF_TX_POWER_MIN -24 -#define CC2538_RF_TX_POWER_MAX 7 /*---------------------------------------------------------------------------*/ #ifdef CC2538_RF_CONF_TX_POWER #define CC2538_RF_TX_POWER CC2538_RF_CONF_TX_POWER