Added stub for extended radio API for CC2520

This commit is contained in:
Niclas Finne 2014-04-01 15:42:35 +02:00
parent 0874165722
commit 9d01fbf735

View file

@ -115,6 +115,70 @@ static int cc2520_cca(void);
signed char cc2520_last_rssi; signed char cc2520_last_rssi;
uint8_t cc2520_last_correlation; uint8_t cc2520_last_correlation;
static uint8_t receive_on;
static int channel;
static radio_result_t
get_value(radio_param_t param, radio_value_t *value)
{
if(!value) {
return RADIO_RESULT_INVALID_VALUE;
}
switch(param) {
case RADIO_PARAM_POWER_MODE:
*value = receive_on ? RADIO_POWER_MODE_ON : RADIO_POWER_MODE_OFF;
return RADIO_RESULT_OK;
case RADIO_PARAM_CHANNEL:
*value = cc2520_get_channel();
return RADIO_RESULT_OK;
case RADIO_CONST_CHANNEL_MIN:
*value = 11;
return RADIO_RESULT_OK;
case RADIO_CONST_CHANNEL_MAX:
*value = 26;
return RADIO_RESULT_OK;
default:
return RADIO_RESULT_NOT_SUPPORTED;
}
}
static radio_result_t
set_value(radio_param_t param, radio_value_t value)
{
switch(param) {
case RADIO_PARAM_POWER_MODE:
if(value == RADIO_POWER_MODE_ON) {
cc2520_on();
return RADIO_RESULT_OK;
}
if(value == RADIO_POWER_MODE_OFF) {
cc2520_off();
return RADIO_RESULT_OK;
}
return RADIO_RESULT_INVALID_VALUE;
case RADIO_PARAM_CHANNEL:
if(value < 11 || value > 26) {
return RADIO_RESULT_INVALID_VALUE;
}
cc2520_set_channel(value);
return RADIO_RESULT_OK;
default:
return RADIO_RESULT_NOT_SUPPORTED;
}
}
static radio_result_t
get_object(radio_param_t param, void *dest, size_t size)
{
return RADIO_RESULT_NOT_SUPPORTED;
}
static radio_result_t
set_object(radio_param_t param, const void *src, size_t size)
{
return RADIO_RESULT_NOT_SUPPORTED;
}
const struct radio_driver cc2520_driver = const struct radio_driver cc2520_driver =
{ {
cc2520_init, cc2520_init,
@ -129,12 +193,12 @@ const struct radio_driver cc2520_driver =
pending_packet, pending_packet,
cc2520_on, cc2520_on,
cc2520_off, cc2520_off,
get_value,
set_value,
get_object,
set_object
}; };
static uint8_t receive_on;
static int channel;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void