mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
* some work on rx handling in cc110x_ng
* added first version of cc110x_ng test application * introduced a generic transceiver interface and module
This commit is contained in:
parent
2b498020b1
commit
044616bf19
5
projects/test_cc110x_ng/Jamfile
Normal file
5
projects/test_cc110x_ng/Jamfile
Normal file
@ -0,0 +1,5 @@
|
||||
SubDir TOP projects test_cc110x_ng ;
|
||||
|
||||
Module test_cc110x_ng : main.c : cc110x_ng shell ps rtc posix_io uart0 ;
|
||||
|
||||
UseModule test_cc110x_ng ;
|
28
projects/test_cc110x_ng/main.c
Normal file
28
projects/test_cc110x_ng/main.c
Normal file
@ -0,0 +1,28 @@
|
||||
#include <shell.h>
|
||||
#include <board_uart0.h>
|
||||
#include <posix_io.h>
|
||||
#include <thread.h>
|
||||
#include <board.h>
|
||||
#include <hwtimer.h>
|
||||
|
||||
#define SHELL_STACK_SIZE (4096)
|
||||
|
||||
char shell_stack_buffer[SHELL_STACK_SIZE];
|
||||
|
||||
shell_t shell;
|
||||
const shell_command_t sc[] = {{NULL, NULL, NULL}};
|
||||
|
||||
void shell_runner(void) {
|
||||
shell_init(&shell, sc, uart0_readc, uart0_putc);
|
||||
posix_open(uart0_handler_pid, 0);
|
||||
shell_run(&shell);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
thread_create(shell_stack_buffer, SHELL_STACK_SIZE, PRIORITY_MAIN-1, CREATE_STACKTEST, shell_runner, "shell");
|
||||
|
||||
while (1) {
|
||||
LED_GREEN_TOGGLE;
|
||||
hwtimer_wait(1000 * 1000);
|
||||
}
|
||||
}
|
13
projects/test_cc110x_ng/tests/hello-world
Executable file
13
projects/test_cc110x_ng/tests/hello-world
Executable file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
set timeout 5
|
||||
|
||||
spawn pseudoterm $env(PORT)
|
||||
|
||||
expect {
|
||||
"Hello World!" {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
puts "\nTest successful!\n"
|
||||
|
@ -35,6 +35,8 @@ Module auto_init : auto_init.c ;
|
||||
Module chardev_thread : chardev_thread.c : ringbuffer ;
|
||||
Module uart0 : uart0.c : ringbuffer chardev_thread ;
|
||||
|
||||
Module transceiver : transceiver.c ;
|
||||
|
||||
SubInclude TOP sys net ;
|
||||
SubInclude TOP sys lib ;
|
||||
SubInclude TOP sys shell ;
|
||||
|
@ -73,6 +73,25 @@ typedef struct __attribute__ ((packed)) packet_info_t
|
||||
bool promiscuous; ///< Radio layer: whether network interface is in promiscuous mode
|
||||
} packet_info_t;
|
||||
|
||||
|
||||
typedef struct __attribute__ ((packed)) {
|
||||
uint8_t rssi; ///< Radio layer: RSSI
|
||||
uint8_t lqi; ///< Radio layer: LQI
|
||||
} radio_info_t;
|
||||
|
||||
/**
|
||||
* @brief General link layer packet format
|
||||
*/
|
||||
typedef struct __attribute__ ((packed)) {
|
||||
uint16_t src; ///< Radio source address
|
||||
uint16_t dst; ///< Radio destination address
|
||||
uint8_t rssi; ///< Radio Signal Strength Indication
|
||||
uint8_t lqi; ///< Link Quality Indicator
|
||||
uint8_t length; ///< Length of payload
|
||||
uint8_t *data; ///< Payload
|
||||
} radio_packet_t;
|
||||
|
||||
|
||||
/**
|
||||
* Packet handler (receive function) of all layers.
|
||||
* @param [in/out] payload Pointer to packet payload data
|
||||
|
28
sys/include/transceiver.h
Normal file
28
sys/include/transceiver.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef TRANSCEIVER_H
|
||||
#define TRANSCEIVER_H
|
||||
|
||||
#define TRANSCEIVER_BUFFER_SIZE (10)
|
||||
#define TRANSCEIVER_STACK_SIZE (4096)
|
||||
|
||||
enum transceiver_msg_type_t {
|
||||
RCV_PKT,
|
||||
SND_PKT,
|
||||
SND_ACK,
|
||||
SWITCH_RX,
|
||||
POWERDOWN,
|
||||
};
|
||||
|
||||
enum transceiver_type_t {
|
||||
NONE,
|
||||
CC1100,
|
||||
CC1020
|
||||
};
|
||||
|
||||
void transceiver_init(transceiver_type_t transceiver);
|
||||
|
||||
void transceiver_start(void);
|
||||
|
||||
extern int transceiver_pid;
|
||||
extern void *transceiver_rx_buffer;
|
||||
|
||||
#endif /* TRANSCEIVER_H */
|
78
sys/transceiver.c
Normal file
78
sys/transceiver.c
Normal file
@ -0,0 +1,78 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <transceiver.h>
|
||||
|
||||
/* supported transceivers */
|
||||
#include <cc1100.h>
|
||||
|
||||
transceiver_type_t transceiver = NONE;
|
||||
int transceiver_pid = EINVAL;
|
||||
radio_packet_t transceiver_buffer[TRANSCEIVER_BUFFER_SIZE];
|
||||
|
||||
static volatile uint8_t rx_buffer_pos = 0;
|
||||
static volatile uint8_t transceiver_buffer_pos = 0;
|
||||
|
||||
const char transceiver_stack[TRANSCEIVER_STACK_SIZE];
|
||||
|
||||
void run(void);
|
||||
void receive_packet(void);
|
||||
|
||||
void transceiver_init(transceiver_type_t t) {
|
||||
switch (t) {
|
||||
case CC110:
|
||||
transceiver = t;
|
||||
cc1100_init();
|
||||
break;
|
||||
default:
|
||||
puts("Invalid transceiver type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void transceiver_start(void) {
|
||||
transceiver_pid = thread_create(transceiver_stack, TRANSCEIVER_STACK_SIZE, PRIORITY_MAIN-1, CREATE_STACKTEST | CREATE_SLEEPING, run, "Transceiver");
|
||||
if (transceiver < 0) {
|
||||
puts("Error creating transceiver thread");
|
||||
}
|
||||
}
|
||||
|
||||
void run(void) {
|
||||
msg m;
|
||||
while (1) {
|
||||
msg_receive(&m);
|
||||
switch (m) {
|
||||
case RCV_PKT:
|
||||
receive_packet();
|
||||
break;
|
||||
default:
|
||||
DEBUG("Unknown message received\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void receive_packet(void) {
|
||||
switch (transveiver) {
|
||||
case CC1100:
|
||||
dINT();
|
||||
rx_buffer_pos = cc1100_rx_buffer_next - 1;
|
||||
cc1100_packet_t p = cc1100_rx_buffer[rx_buffer_pos].packet;
|
||||
radio_info_t info = cc1100_rx_buffer[rx_buffer_pos].info;
|
||||
radio_packet_t trans_p = transceiver_buffer[transceiver_buffer_pos];
|
||||
|
||||
trans_p.src = p.phy_src;
|
||||
trans_p.dst = p.address;
|
||||
trans_p.rssi = info.rssi;
|
||||
trans_p.lqi = info.lqi;
|
||||
trans_p.length = p.length;
|
||||
|
||||
/* TODO: copy payload */
|
||||
eINT();
|
||||
break;
|
||||
default:
|
||||
puts("Invalid transceiver type");
|
||||
break;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user