1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

[drivers/cc110x_ng sys/transceiver]

* updated interface to switch transceiver off and back to rx mode
* removed some debugging stuff
This commit is contained in:
Oliver Hahm 2010-12-02 15:38:28 +01:00
parent 0b515b4063
commit 4a2c58bbba
10 changed files with 361 additions and 289 deletions

View File

@ -167,7 +167,6 @@ void bl_config_init(void) {
extern char configmem[];
if (*((uint16_t*) configmem) == CONFIG_KEY) {
memcpy(&sysconfig, (configmem + sizeof(CONFIG_KEY)), sizeof(sysconfig));
LED_GREEN_TOGGLE;
}
else {
config_save();

View File

@ -9,7 +9,7 @@
#include <flashrom.h>
#include <lpc2387.h>
#define ENABLE_DEBUG
//#define ENABLE_DEBUG
#include <debug.h>
/* pointer to reserved flash rom section for configuration data */

View File

@ -1,6 +1,8 @@
#ifndef CC1100_CONFIG_H
#define CC1100_CONFIG_H
#include <timex.h>
/** CC1100 register configuration */
typedef struct {
uint8_t IOCFG2;
@ -56,6 +58,7 @@ typedef struct {
typedef struct
{
uint32_t TOF; ///< Time of flight of the last packet and last ACK
timex_t TOA; ///< Time of packet arriveal
uint32_t TCP; ///< Time to compute packet
unsigned RPS : 16; ///< Raw packets sent to transmit last packet
unsigned RTC : 8; ///< Retransmission count of last send packet
@ -82,10 +85,8 @@ typedef struct cc1100_statistic {
uint32_t packets_in_dups;
uint32_t packets_in_up;
uint32_t packets_out;
uint32_t packets_out_acked;
uint32_t packets_out_broadcast;
uint32_t raw_packets_out;
uint32_t raw_packets_out_acked;
uint32_t acks_send;
uint32_t rx_buffer_max;
uint32_t watch_dog_resets;

View File

@ -60,6 +60,7 @@ uint8_t cc1100_send(cc1100_packet_t *packet) {
restoreIRQ(cpsr);
// Wait for GDO2 to be cleared -> end of packet
while (cc1100_get_gdo2() != 0);
LED_GREEN_TOGGLE;
// Experimental - TOF Measurement
cc1100_after_send();

View File

@ -202,14 +202,14 @@ char* cc1100_state_to_text(uint8_t state) {
}
}
void cc1100_print_config(void) {
printf("Current radio state: %s\r\n", cc1100_state_to_text(radio_state));
printf("Current MARC state: %s\r\n", cc1100_get_marc_state());
printf("Current channel number: %u\r\n", sysconfig.radio_channel);
}
void switch_to_pwd(void) {
void cc1100_switch_to_pwd(void) {
DEBUG("[cc110x_ng] switching to powerdown\n");
cc1100_wakeup_from_rx();
cc1100_spi_strobe(CC1100_SPWD);
radio_state = RADIO_PWD;

View File

@ -1,5 +1,5 @@
SubDir TOP projects laser ;
Module laser : main.c : sht11 swtimer auto_init ;
Module laser : main.c : sht11 ltc4150 swtimer auto_init ;
UseModule laser ;

View File

@ -18,7 +18,7 @@
#define SND_BUFFER_SIZE (100)
#define RCV_BUFFER_SIZE (64)
#define SENDING_DELAY (1000)
#define SENDING_DELAY (5 * 1000)
char shell_stack_buffer[SHELL_STACK_SIZE];
char radio_stack_buffer[RADIO_STACK_SIZE];
@ -31,12 +31,20 @@ static msg mesg;
static transceiver_command_t tcmd;
static radio_packet_t p;
static uint32_t sending_delay = SENDING_DELAY;
void sender(char *count);
void print_buffer(char *unused);
void switch2rx(char *unused);
void powerdown(char *unused);
void set_delay(char *delay);
shell_t shell;
const shell_command_t sc[] = {
{"on", "", switch2rx},
{"off", "", powerdown},
{"snd", "", sender},
{"delay", "", set_delay},
{"buffer", "", print_buffer},
{NULL, NULL, NULL}};
@ -63,7 +71,7 @@ void sender(char *count) {
puts(".");
p.data = snd_buffer[i % SND_BUFFER_SIZE];
msg_send(&mesg, transceiver_pid, 1);
swtimer_usleep(SENDING_DELAY);
swtimer_usleep(sending_delay);
}
}
@ -79,6 +87,39 @@ void print_buffer(char *unused) {
}
}
void switch2rx(char *unused) {
mesg.type = SWITCH_RX;
mesg.content.ptr = (char*) &tcmd;
tcmd.transceivers = TRANSCEIVER_CC1100;
puts("Turning transceiver on");
if (msg_send(&mesg, transceiver_pid, 1)) {
puts("\tsuccess");
}
}
void powerdown(char *unused) {
mesg.type = POWERDOWN;
mesg.content.ptr = (char*) &tcmd;
tcmd.transceivers = TRANSCEIVER_CC1100;
puts("Turning transceiver off");
if (msg_send(&mesg, transceiver_pid, 1)) {
puts("\tsuccess");
}
}
void set_delay(char *delay) {
uint32_t d;
if (sscanf(delay, "delay %lu", &d) == 1) {
sending_delay = d;
}
else {
puts("Usage:\tdelay <µs>");
}
}
void radio(void) {
msg m;
radio_packet_t *p;

View File

@ -40,6 +40,7 @@ and the mailinglist (subscription via web site)
#include <stdint.h>
#include <stdbool.h>
#include <timex.h>
typedef uint8_t protocol_t; ///< Packet protocol type
typedef uint16_t radio_address_t; ///< Radio layer address type
@ -83,6 +84,7 @@ typedef struct __attribute__ ((packed)) {
uint16_t dst; ///< Radio destination address
uint8_t rssi; ///< Radio Signal Strength Indication
uint8_t lqi; ///< Link Quality Indicator
timex_t toa; ///< Time of Arrival
uint8_t length; ///< Length of payload
uint8_t *data; ///< Payload
} radio_packet_t;

View File

@ -82,5 +82,3 @@ void _cc1100_ng_monitor_handler(char *mode) {
puts("Usage:\nmonitor <MODE>");
}
}

View File

@ -19,7 +19,7 @@
#endif
#endif
#define ENABLE_DEBUG (1)
//#define ENABLE_DEBUG (1)
#include <debug.h>
/*------------------------------------------------------------------------------------*/
@ -57,6 +57,8 @@ static int16_t set_channel(transceiver_type_t t, void *channel);
static int16_t get_address(transceiver_type_t t);
static int16_t set_address(transceiver_type_t t, void *address);
static void set_monitor(transceiver_type_t t, void *mode);
static void powerdown(transceiver_type_t t);
static void switch_to_rx(transceiver_type_t t);
/*------------------------------------------------------------------------------------*/
/* Transceiver init */
@ -122,6 +124,7 @@ void run(void) {
msg_receive(&m);
/* only makes sense for messages for upper layers */
cmd = (transceiver_command_t*) m.content.ptr;
DEBUG("Transceiver: Message received\n");
switch (m.type) {
case RCV_PKT_CC1020:
@ -152,6 +155,12 @@ void run(void) {
case SET_MONITOR:
set_monitor(cmd->transceivers, cmd->data);
break;
case POWERDOWN:
powerdown(cmd->transceivers);
break;
case SWITCH_RX:
switch_to_rx(cmd->transceivers);
break;
default:
DEBUG("Unknown message received\n");
break;
@ -219,7 +228,7 @@ static void receive_packet(uint16_t type, uint8_t pos) {
if (reg[i].transceivers & t) {
m.content.ptr = (char*) &(transceiver_buffer[transceiver_buffer_pos]);
DEBUG("Notify thread %i\n", reg[i].pid);
if (msg_send(&m, reg[i].pid, false)) {
if (msg_send(&m, reg[i].pid, false) && (m.type != ENOBUFFER)) {
transceiver_buffer[transceiver_buffer_pos].processing++;
}
}
@ -364,3 +373,24 @@ static void set_monitor(transceiver_type_t t, void *mode) {
break;
}
}
/*------------------------------------------------------------------------------------*/
static void powerdown(transceiver_type_t t) {
switch (t) {
case TRANSCEIVER_CC1100:
cc1100_switch_to_pwd();
break;
default:
break;
}
}
/*------------------------------------------------------------------------------------*/
static void switch_to_rx(transceiver_type_t t) {
switch (t) {
case TRANSCEIVER_CC1100:
cc1100_switch_to_rx();
break;
default:
break;
}
}