1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-26 15:03:53 +01:00

* additionally debug for transceiver receiving functions

* added set_channel function to cc110x_ng
This commit is contained in:
Oliver Hahm 2010-11-24 13:47:31 +01:00
parent d950fbcf81
commit 4ebfaefce1
3 changed files with 15 additions and 1 deletions

View File

@ -77,7 +77,7 @@ void cc1100_init(int tpid) {
rflags.WOR_RST = 0;
/* Set default channel number */
radio_channel = CC1100_DEFAULT_CHANNR;
cc1100_set_channel(CC1100_DEFAULT_CHANNR);
DEBUG("CC1100 initialized and set to channel %i\n", radio_channel);
// Switch to desired mode (WOR or RX)
@ -214,6 +214,15 @@ void switch_to_pwd(void) {
cc1100_spi_strobe(CC1100_SPWD);
radio_state = RADIO_PWD;
}
uint8_t cc1100_set_channel(uint8_t channr) {
if (channr > MAX_CHANNR) {
return 0;
}
write_register(CC1100_CHANNR, channr*10);
radio_channel = channr;
return 1;
}
/*---------------------------------------------------------------------------*/
/* Internal functions */
/*---------------------------------------------------------------------------*/

View File

@ -95,4 +95,5 @@ void cc1100_wakeup_from_rx(void);
void cc1100_switch_to_pwd(void);
void cc1100_disable_interrupts(void);
uint8_t cc1100_set_channel(uint8_t channr);
#endif

View File

@ -120,6 +120,7 @@ static void receive_packet(uint16_t type, uint8_t pos) {
rx_buffer_pos = pos;
msg m;
DEBUG("Packet received\n");
switch (type) {
case RCV_PKT_CC1020:
t = TRANSCEIVER_CC1020;
@ -162,6 +163,7 @@ static void receive_packet(uint16_t type, uint8_t pos) {
while (reg[i].transceivers != TRANSCEIVER_NONE) {
if (reg[i].transceivers & t) {
m.content.value = transceiver_buffer_pos;
DEBUG("Notify thread %i\n", reg[i].pid);
msg_send(&m, reg[i].pid, false);
}
i++;
@ -169,6 +171,7 @@ static void receive_packet(uint16_t type, uint8_t pos) {
}
static void receive_cc1100_packet(radio_packet_t *trans_p) {
DEBUG("Handling CC1100 packet\n");
/* disable interrupts while copying packet */
dINT();
cc1100_packet_t p = cc1100_rx_buffer[rx_buffer_pos].packet;
@ -181,6 +184,7 @@ static void receive_cc1100_packet(radio_packet_t *trans_p) {
memcpy((void*) &(data_buffer[transceiver_buffer_pos]), p.data, CC1100_MAX_DATA_LENGTH);
eINT();
DEBUG("Packet was from %hu to %hu, size: %u\n", trans_p->src, trans_p->dst, trans_p->length);
trans_p->data = (uint8_t*) &(data_buffer[transceiver_buffer_pos * CC1100_MAX_DATA_LENGTH]);
}