Skip to content

Commit

Permalink
fixed atomq storage stride bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Riddle committed Jul 13, 2012
1 parent 6a8b6b4 commit 5a0119c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions atomq.c
Expand Up @@ -40,7 +40,7 @@ bool atomq_enqueue_nb(volatile struct atomq *queue, void *src) {
return false;
}

memcpy((void *)&(queue->storage[queue->headOffset]), src, queue->slotSize);
memcpy((void *)&(queue->storage[queue->headOffset * queue->slotSize]), src, queue->slotSize);

queue->headOffset++;
queue->headOffset %= queue->numSlots;
Expand Down Expand Up @@ -82,7 +82,7 @@ bool atomq_dequeue_nb(volatile struct atomq *queue, void *dest) {
return false;
}

memcpy(dest, (void *)&(queue->storage[queue->tailOffset]), queue->slotSize);
memcpy(dest, (void *)&(queue->storage[queue->tailOffset * queue->slotSize]), queue->slotSize);

queue->tailOffset++;
queue->tailOffset %= queue->numSlots;
Expand Down
2 changes: 1 addition & 1 deletion fault.c
Expand Up @@ -30,7 +30,7 @@ void fault_fatal(uint8_t faultNum) {
_delay_ms(50);
}

_delay_ms(500);
_delay_ms(1000);

for(i = 0; i < faultNum; i++) {
led_on();
Expand Down
2 changes: 1 addition & 1 deletion faultlist.h
Expand Up @@ -10,7 +10,7 @@

#define _FAULT_NONE 1
#define FAULT_TEST 3

#define FAULT_MAINLOOP_DID_EXIT 4
#define FAULT_IOPORT_INVALID_PORT_SPECIFIED 5
#define FAULT_ATOMQ_ALLOC_FAILED 6
#define FAULT_UART_BUFFER_NB_WOULD_BLOCK 7
Expand Down
15 changes: 6 additions & 9 deletions main.c
Expand Up @@ -23,15 +23,12 @@ void main_init(void) {
uart_init();
}

int main(void) {
main_init();

void main_run(void) {
sei();
}

printf("What's up, Doc? ");

while(1) {
volatile static int i = 0;
i++;
}
int main(void) {
main_init();
main_run();
fault_fatal(FAULT_MAINLOOP_DID_EXIT);
}

0 comments on commit 5a0119c

Please sign in to comment.