diff --git a/board/msb-430-common/Jamfile b/board/msb-430-common/Jamfile index 97c2be0f30..6cc5f8f1e3 100644 --- a/board/msb-430-common/Jamfile +++ b/board/msb-430-common/Jamfile @@ -27,7 +27,7 @@ SubDir TOP board msb-430-common ; -Module board : board_init.c debug_uart.c ; +Module board : board_init.c debug_uart.c config.c ; UseModule board ; SubInclude TOP cpu $(CPU) ; diff --git a/board/msb-430-common/Jamrules.msb-430-common b/board/msb-430-common/Jamrules.msb-430-common index bfe5a1a6f8..af4e671c17 100644 --- a/board/msb-430-common/Jamrules.msb-430-common +++ b/board/msb-430-common/Jamrules.msb-430-common @@ -28,7 +28,7 @@ CPU = msp430 ; MCU = msp430x1612 ; -FLASH_PORT ?= /dev/ttyUSB0 ; +FLASH_PORT ?= "$(PORT)" ; FLASHER ?= mspdebug ; FLASHFLAGS ?= -d $(FLASH_PORT) -j uif ; diff --git a/board/msb-430-common/config.c b/board/msb-430-common/config.c new file mode 100644 index 0000000000..f8d169e2a2 --- /dev/null +++ b/board/msb-430-common/config.c @@ -0,0 +1,6 @@ +#include +#include + +uint8_t config_save(void) { + return 1; +} diff --git a/board/msba2/board_init.c b/board/msba2/board_init.c index aea2c5093d..de730c33b6 100644 --- a/board/msba2/board_init.c +++ b/board/msba2/board_init.c @@ -51,12 +51,6 @@ and the mailinglist (subscription via web site) #define PCRTC BIT9 #define CL_CPU_DIV 4 -config_t sysconfig = { - 0, ///< default ID - 0, ///< default radio address - 0, ///< default radio channel -}; - /*---------------------------------------------------------------------------*/ /** * @brief Enabling MAM and setting number of clocks used for Flash memory fetch diff --git a/core/include/kernel.h b/core/include/kernel.h index 7aeac5ada1..54c7d51e6c 100644 --- a/core/include/kernel.h +++ b/core/include/kernel.h @@ -22,6 +22,7 @@ */ #include +#include #include "tcb.h" #include "cpu.h" #include "flags.h" @@ -85,5 +86,7 @@ int inISR(void); extern volatile int lpm_prevent_sleep; +extern config_t sysconfig; + /** @} */ #endif /* KERNEL_H_ */ diff --git a/core/kernel_init.c b/core/kernel_init.c index b38d5a9662..30be1e68d9 100644 --- a/core/kernel_init.c +++ b/core/kernel_init.c @@ -26,6 +26,7 @@ #include #include #include +#include #ifdef MODULE_AUTO_INIT #include @@ -41,6 +42,12 @@ volatile int lpm_prevent_sleep = 0; extern void main(void); extern void cpu_switch_context_exit(void); +config_t sysconfig = { + 0, ///< default ID + 0, ///< default radio address + 0, ///< default radio channel +}; + static void idle_thread(void) { while(1) { if (lpm_prevent_sleep) { diff --git a/core/oneway_malloc.c b/core/oneway_malloc.c index 10c76c9c38..d10e23b960 100644 --- a/core/oneway_malloc.c +++ b/core/oneway_malloc.c @@ -17,6 +17,8 @@ #include #include +#include +#include #define ENABLE_DEBUG #include diff --git a/cpu/lpc2387/include/cpu-conf.h b/cpu/lpc2387/include/cpu-conf.h index fd9ecb10b2..9e6a2dde94 100644 --- a/cpu/lpc2387/include/cpu-conf.h +++ b/cpu/lpc2387/include/cpu-conf.h @@ -84,5 +84,8 @@ and the mailinglist (subscription via web site) #define CC_CONF_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) /** @} */ +#define TRANSCEIVER_BUFFER_SIZE (10) +#define RX_BUF_SIZE (10) + /** @} */ #endif /* CPUCONF_H_ */ diff --git a/cpu/msp430/include/cpu-conf.h b/cpu/msp430/include/cpu-conf.h index 62958016e5..9f9e114f17 100644 --- a/cpu/msp430/include/cpu-conf.h +++ b/cpu/msp430/include/cpu-conf.h @@ -37,6 +37,9 @@ and the mailinglist (subscription via web site) #define KERNEL_CONF_STACKSIZE_IDLE 64 #define MSP430_ISR_STACK_SIZE 256 + +#define RX_BUF_SIZE (4) +#define TRANSCEIVER_BUFFER_SIZE (4) /** @} */ #endif /* CPUCONF_H_ */ diff --git a/drivers/cc110x_ng/Jamfile b/drivers/cc110x_ng/Jamfile index 55995d823d..039d0f4bda 100755 --- a/drivers/cc110x_ng/Jamfile +++ b/drivers/cc110x_ng/Jamfile @@ -29,5 +29,5 @@ SubDir TOP drivers cc110x_ng ; HDRS += $(TOP)/drivers/cc110x_ng ; -Module cc110x_ng : cc1100.c cc1100-rx.c cc1100-tx.c cc1100-defaultSettings.c cc1100_spi.c : board_cc1100 swtimer gpioint ; +Module cc110x_ng : cc1100.c cc1100-rx.c cc1100-tx.c cc1100-defaultSettings.c cc1100_spi.c : board_cc1100 swtimer ; diff --git a/drivers/cc110x_ng/cc1100-rx.c b/drivers/cc110x_ng/cc1100-rx.c index de8f615575..275f4d00fa 100644 --- a/drivers/cc110x_ng/cc1100-rx.c +++ b/drivers/cc110x_ng/cc1100-rx.c @@ -8,6 +8,7 @@ #include #include +#include #include static uint8_t receive_packet_variable(uint8_t *rxBuffer, uint8_t length); @@ -96,7 +97,8 @@ static uint8_t receive_packet_variable(uint8_t *rxBuffer, uint8_t length) { /* Any bytes available in RX FIFO? */ if ((cc1100_spi_read_status(CC1100_RXBYTES) & BYTES_IN_RXFIFO)) { - LED_GREEN_TOGGLE; + //LED_GREEN_TOGGLE; + LED_RED_TOGGLE; // Read length byte (first byte in RX FIFO) packetLength = cc1100_spi_read_reg(CC1100_RXFIFO); // Read data from RX FIFO and store in rxBuffer diff --git a/drivers/cc110x_ng/cc1100-tx.c b/drivers/cc110x_ng/cc1100-tx.c index 47ce43a6ac..ff98676049 100644 --- a/drivers/cc110x_ng/cc1100-tx.c +++ b/drivers/cc110x_ng/cc1100-tx.c @@ -60,7 +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; + //LED_GREEN_TOGGLE; // Experimental - TOF Measurement cc1100_after_send(); diff --git a/drivers/cc110x_ng/cc1100_ng.h b/drivers/cc110x_ng/cc1100_ng.h index 3431f2e7b0..b126a42fab 100644 --- a/drivers/cc110x_ng/cc1100_ng.h +++ b/drivers/cc110x_ng/cc1100_ng.h @@ -6,8 +6,6 @@ #include #include -#define RX_BUF_SIZE (10) - #define CC1100_MAX_DATA_LENGTH (58) #define CC1100_HEADER_LENGTH (3) ///< Header covers SRC, DST and FLAGS diff --git a/projects/cc110x/main.c b/projects/cc110x/main.c index 4847b47cb3..c552a7939f 100644 --- a/projects/cc110x/main.c +++ b/projects/cc110x/main.c @@ -68,12 +68,12 @@ int main(void) cc1100_set_address(2); - while(1) { +// while(1) { puts("."); int result = cc1100_send_csmaca(1, 4, 2, i, sizeof(i)); printf("%i\n", result); hwtimer_wait(1000 * 1000); - } +// } #else cc1100_set_address(1); while(1) { diff --git a/projects/msb430_cc110x_ng/Jamfile b/projects/msb430_cc110x_ng/Jamfile new file mode 100644 index 0000000000..031c604291 --- /dev/null +++ b/projects/msb430_cc110x_ng/Jamfile @@ -0,0 +1,5 @@ +SubDir TOP projects msb430_cc110x_ng ; + +Module msb430_cc110x_ng : main.c : cc110x_ng transceiver ps posix_io uart0 auto_init ; + +UseModule msb430_cc110x_ng ; diff --git a/projects/msb430_cc110x_ng/main.c b/projects/msb430_cc110x_ng/main.c new file mode 100644 index 0000000000..a25070219d --- /dev/null +++ b/projects/msb430_cc110x_ng/main.c @@ -0,0 +1,119 @@ +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define RADIO_STACK_SIZE (1024) + +#define SND_BUFFER_SIZE (3) +#define RCV_BUFFER_SIZE (4) + +#define SENDING_DELAY (5 * 1000) + +char radio_stack_buffer[RADIO_STACK_SIZE]; + +uint8_t snd_buffer[SND_BUFFER_SIZE][CC1100_MAX_DATA_LENGTH]; + +msg msg_q[RCV_BUFFER_SIZE]; + +static msg mesg; +static transceiver_command_t tcmd; +static radio_packet_t p; + +void sender(char *count); +void print_buffer(char *unused); + +void sender(char *count) { + unsigned int c = 3; + unsigned int i; + + mesg.type = SND_PKT; + mesg.content.ptr = (char*) &tcmd; + + tcmd.transceivers = TRANSCEIVER_CC1100; + tcmd.data = &p; + + p.length = CC1100_MAX_DATA_LENGTH; + p.dst = 0; + + for (i = 0; i < c; i++) { + puts("."); + p.data = snd_buffer[i % SND_BUFFER_SIZE]; + msg_send(&mesg, transceiver_pid, 1); + swtimer_usleep(SENDING_DELAY); + } +} + +void print_buffer(char *unused) { + uint8_t i; + extern radio_packet_t transceiver_buffer[]; + for (i = 0; i < TRANSCEIVER_BUFFER_SIZE; i++) { + printf("[%u] %u # %u # %u\n", i, transceiver_buffer[i].processing, transceiver_buffer[i].length, transceiver_buffer[i].data[i]); + } + extern rx_buffer_t cc1100_rx_buffer[]; + for (i = 0; i < TRANSCEIVER_BUFFER_SIZE; i++) { + printf("[%u] %u # %u \n", i, cc1100_rx_buffer[i].packet.length, cc1100_rx_buffer[i].packet.data[i]); + } +} + +void radio(void) { + msg m; + radio_packet_t *p; + uint8_t i; + + msg_init_queue(msg_q, RCV_BUFFER_SIZE); + + while (1) { + msg_receive(&m); + if (m.type == PKT_PENDING) { + p = (radio_packet_t*) m.content.ptr; + printf("Packet waiting, process %p...\n", p); + printf("\tLength:\t%u\n", p->length); + printf("\tSrc:\t%u\n", p->src); + printf("\tDst:\t%u\n", p->dst); + printf("\tLQI:\t%u\n", p->lqi); + printf("\tRSSI:\t%u\n", p->rssi); + + for (i = 0; i < p->length; i++) { + printf("%02X ", p->data[i]); + } + p->processing--; + printf("\n"); + } + else if (m.type == ENOBUFFER) { + puts("Transceiver buffer full"); + } + else { + puts("Unknown packet received"); + } + } +} + +int main(void) { + int radio_pid; + uint8_t i; + for (i = 0; i < SND_BUFFER_SIZE; i++) { + memset(snd_buffer[i], i, CC1100_MAX_DATA_LENGTH); + } + radio_pid = thread_create(radio_stack_buffer, RADIO_STACK_SIZE, PRIORITY_MAIN-2, CREATE_STACKTEST, radio, "radio"); + transceiver_init(TRANSCEIVER_CC1100); + transceiver_start(); + transceiver_register(TRANSCEIVER_CC1100, radio_pid); + sender(NULL); + + while (1) { + extern void thread_print_all(void); + thread_print_all(); + print_buffer(NULL); + swtimer_usleep(10000000); + } +} diff --git a/projects/msb430_cc110x_ng/tests/hello-world b/projects/msb430_cc110x_ng/tests/hello-world new file mode 100755 index 0000000000..acde8265fe --- /dev/null +++ b/projects/msb430_cc110x_ng/tests/hello-world @@ -0,0 +1,13 @@ +#!/usr/bin/expect + +set timeout 5 + +spawn pseudoterm $env(PORT) + +expect { + "Hello World!" {} + timeout { exit 1 } +} + +puts "\nTest successful!\n" + diff --git a/projects/test_cc110x_ng/Jamfile b/projects/test_cc110x_ng/Jamfile index 28bf8b6f1a..108b3c1414 100644 --- a/projects/test_cc110x_ng/Jamfile +++ b/projects/test_cc110x_ng/Jamfile @@ -1,5 +1,5 @@ SubDir TOP projects test_cc110x_ng ; -Module test_cc110x_ng : main.c : cc110x_ng shell shell_commands transceiver ps rtc posix_io uart0 auto_init ; +Module test_cc110x_ng : main.c : cc110x_ng shell shell_commands transceiver ps rtc posix_io uart0 auto_init gpioint ; UseModule test_cc110x_ng ; diff --git a/sys/auto_init.c b/sys/auto_init.c index c92b2b0176..cbb7db9141 100644 --- a/sys/auto_init.c +++ b/sys/auto_init.c @@ -1,7 +1,9 @@ #include #include #include +#ifdef MODULE_RTC #include +#endif #include #define ENABLE_DEBUG diff --git a/sys/include/transceiver.h b/sys/include/transceiver.h index a31876bd7f..eddd4314db 100644 --- a/sys/include/transceiver.h +++ b/sys/include/transceiver.h @@ -3,17 +3,15 @@ #include -/* Packets to buffer */ -#define TRANSCEIVER_BUFFER_SIZE (10) /* Stack size for transceiver thread */ -#define TRANSCEIVER_STACK_SIZE (2048) +#define TRANSCEIVER_STACK_SIZE (512) /* The maximum of threads to register */ -#define TRANSCEIVER_MAX_REGISTERED (10) +#define TRANSCEIVER_MAX_REGISTERED (4) /* The size of the message queue between driver and transceiver (must be power * of two */ -#define TRANSCEIVER_MSG_BUFFER_SIZE (64) +#define TRANSCEIVER_MSG_BUFFER_SIZE (32) /** * @brief Message types for transceiver interface diff --git a/sys/transceiver.c b/sys/transceiver.c index d0d5920e5f..13de0a6fad 100644 --- a/sys/transceiver.c +++ b/sys/transceiver.c @@ -20,6 +20,10 @@ #endif //#define ENABLE_DEBUG (1) +#ifdef ENABLE_DEBUG +#undef TRANSCEIVER_BUFFER_SIZE +#define TRANSCEIVER_BUFFER_SIZE (2048) +#endif #include /*------------------------------------------------------------------------------------*/