[board msba2-common] [sys chardev_thread] [sys shell] [driver cc110x_ng] [core msg]

* some cosmetics and cleanups
dev/timer
Oliver Hahm 12 years ago
parent 64e0c5b246
commit 0d6d3e2c43

@ -202,7 +202,6 @@ bl_uart_init(void)
/* irq */
install_irq(UART0_INT, UART0_IRQHandler, 6);
// U0IER |= BIT0 | BIT1; // enable RX+TX irq
U0IER |= BIT0; // enable only RX irq
return 1;
}

@ -105,7 +105,7 @@ int msg_send_int(msg_t* m, unsigned int target_pid) {
tcb_t *target = (tcb_t*)sched_threads[target_pid];
if (target->status == STATUS_RECEIVE_BLOCKED) {
DEBUG("msg_send_int: direct msg copy.\n");
DEBUG("msg_send_int: direct msg copy from %i to %i.\n", thread_getpid(), target_pid);
m->sender_pid = target_pid;

@ -14,10 +14,11 @@
#ifdef DBG_IGNORE
#include <stdio.h>
#include <string.h>
#define IGN_MAX (10)
uint8_t ignored_addr[IGN_MAX];
static uint8_t is_ignored(uint8_t addr);
radio_address_t ignored_addr[IGN_MAX];
static uint8_t is_ignored(radio_address_t addr);
#endif
static uint8_t receive_packet_variable(uint8_t *rxBuffer, uint8_t length);
@ -60,6 +61,7 @@ void cc110x_rx_handler(void) {
#ifdef DBG_IGNORE
if (is_ignored(cc110x_rx_buffer[rx_buffer_next].packet.phy_src)) {
LED_RED_TOGGLE;
return;
}
#endif
@ -114,8 +116,6 @@ static uint8_t receive_packet_variable(uint8_t *rxBuffer, uint8_t length) {
/* Any bytes available in RX FIFO? */
if ((cc110x_read_status(CC1100_RXBYTES) & BYTES_IN_RXFIFO)) {
//LED_GREEN_TOGGLE;
//LED_RED_TOGGLE;
// Read length byte (first byte in RX FIFO)
cc110x_read_fifo((char*) &packetLength, 1);
// Read data from RX FIFO and store in rxBuffer
@ -153,7 +153,6 @@ static uint8_t receive_packet_variable(uint8_t *rxBuffer, uint8_t length) {
}
/* no bytes in RX FIFO */
else {
//LED_RED_TOGGLE;
// RX FIFO get automatically flushed if return value is false
return 0;
}
@ -172,28 +171,23 @@ static uint8_t receive_packet(uint8_t *rxBuffer, uint8_t length) {
#ifdef DBG_IGNORE
void cc110x_init_ignore(void) {
uint8_t i;
for (i = 0; i < IGN_MAX; i++) {
ignored_addr[i] = 0;
}
memset(ignored_addr, 0, IGN_MAX*sizeof(radio_address_t));
}
uint8_t cc110x_add_ignored(uint8_t addr) {
uint8_t cc110x_add_ignored(radio_address_t addr) {
uint8_t i = 0;
while ((i < IGN_MAX) && ignored_addr[i++]) {
printf("i: %hu\n", i);
}
printf("Adding %hu to ignore list at position %hu\n", addr, i);
if (i >= IGN_MAX) {
if (i > IGN_MAX) {
return 0;
}
ignored_addr[i-1] = addr;
return 1;
}
static uint8_t is_ignored(uint8_t addr) {
static uint8_t is_ignored(radio_address_t addr) {
uint8_t i;
for (i = 0; i < IGN_MAX; i++) {

@ -145,7 +145,7 @@ void cc110x_init_ignore(void);
* @return 0 if list is full, 1 otherwise
*
*/
uint8_t cc110x_add_ignored(uint8_t addr);
uint8_t cc110x_add_ignored(radio_address_t addr);
#endif

@ -29,14 +29,16 @@ void chardev_loop(ringbuffer_t *rb) {
while (1) {
msg_receive(&m);
if (m.sender_pid == pid) {
} else {
if (m.sender_pid != pid) {
DEBUG("Receiving message from another thread");
switch (m.type) {
case OPEN:
if (reader_pid == -1) {
reader_pid = m.sender_pid;
m.content.value = 0; // no error
} else {
/* no error */
m.content.value = 0;
}
else {
m.content.value = -EBUSY;
}
msg_reply(&m,&m);
@ -44,8 +46,10 @@ void chardev_loop(ringbuffer_t *rb) {
case READ:
if (m.sender_pid != reader_pid) {
m.content.value = -EINVAL;
r = NULL;
msg_reply(&m, &m);
} else {
}
else {
r = (struct posix_iop_t *)m.content.ptr;
}
break;
@ -55,7 +59,8 @@ void chardev_loop(ringbuffer_t *rb) {
reader_pid = -1;
r = NULL;
m.content.value = 0;
} else {
}
else {
m.content.value = -EINVAL;
}
msg_reply(&m,&m);
@ -69,7 +74,7 @@ void chardev_loop(ringbuffer_t *rb) {
if (rb->avail && (r != NULL)) {
int state = disableIRQ();
int nbytes = min(r->nbytes, rb->avail);
DEBUG("uart0_thread: sending %i bytes to pid %i\n", nbytes, reader_pid);
DEBUG("uart0_thread [%i]: sending %i bytes received from %i to pid %i\n", pid, nbytes, m.sender_pid, reader_pid);
rb_get_elements(rb, r->buffer, nbytes);
r->nbytes = nbytes;
@ -78,7 +83,6 @@ void chardev_loop(ringbuffer_t *rb) {
m.content.ptr = (char*)r;
msg_reply(&m, &m);
// DEBUG("uart0_thread: sending res=%i\n", res);
r = NULL;
restoreIRQ(state);

@ -136,7 +136,8 @@ int readline(shell_t *shell, char* buf, int size) {
if (c == 10) {
*line_buf_ptr = '\0';
return 0;
} else {
}
else {
*line_buf_ptr++ = c;
}
}

Loading…
Cancel
Save