Skip to content

Commit

Permalink
cleaning up radio and adding clear bool func
Browse files Browse the repository at this point in the history
  • Loading branch information
anroOfCode committed Jan 12, 2013
1 parent 60686e1 commit 0231e3d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 33 deletions.
38 changes: 5 additions & 33 deletions radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,37 +100,13 @@ void cc2520_radio_lock(int state)
spin_unlock(&radio_sl);
}

int cc2520_radio_try_lock(int state)
{
spin_lock(&radio_sl);
if (radio_state != CC2520_RADIO_STATE_IDLE) {
spin_unlock(&radio_sl);
return -1;
}
radio_state = state;
spin_unlock(&radio_sl);
return 0;
}

void cc2520_radio_unlock(void)
{
spin_lock(&radio_sl);
radio_state = CC2520_RADIO_STATE_IDLE;
spin_unlock(&radio_sl);
}

int cc2520_radio_idle_lock(int state)
{
spin_lock(&radio_sl);
if (radio_state == CC2520_RADIO_STATE_IDLE) {
radio_state = state;
spin_unlock(&radio_sl);
return 1;
}
spin_unlock(&radio_sl);
return 0;
}

int cc2520_radio_tx_unlock_spi(void)
{
spin_lock(&radio_sl);
Expand Down Expand Up @@ -165,15 +141,6 @@ int cc2520_radio_tx_unlock_sfd(void)
return 0;
}

int cc2520_radio_lock_status(void)
{
int status;
spin_lock(&radio_sl);
status = radio_state;
spin_unlock(&radio_sl);
return status;
}

//////////////////////////////
// Initialization & On/Off
/////////////////////////////
Expand Down Expand Up @@ -350,6 +317,11 @@ void cc2520_radio_off()
// Configuration Commands
/////////////////////////////

bool cc2520_radio_is_clear()
{
return gpio_get_value(CC2520_CCA) == 1;
}

void cc2520_radio_set_channel(int channel)
{
cc2520_freqctrl_t freqctrl;
Expand Down
2 changes: 2 additions & 0 deletions radio.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ void cc2520_radio_set_channel(int channel);
void cc2520_radio_set_address(u16 short_addr, u64 extended_addr, u16 pan_id);
void cc2520_radio_set_txpower(u8 power);

bool cc2520_radio_is_clear(void);

// Radio Interrupt Callbacks
void cc2520_radio_sfd_occurred(u64 nano_timestamp, u8 is_high);
void cc2520_radio_fifop_occurred(void);
Expand Down

0 comments on commit 0231e3d

Please sign in to comment.