Implement ring buffer and auxiliary functions
This commit is contained in:
23
src/main.c
23
src/main.c
@@ -1,22 +1,12 @@
|
||||
#include "common.h"
|
||||
#include "serial.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#define MAX_CMDBUF 256
|
||||
|
||||
int main(void)
|
||||
{
|
||||
unsigned long i;
|
||||
char buf[128];
|
||||
char *cmd;
|
||||
|
||||
// UART command buffer
|
||||
cmd = malloc(MAX_CMDBUF);
|
||||
if (cmd == NULL) {
|
||||
return 1;
|
||||
}
|
||||
char ch;
|
||||
|
||||
// Handle USART_RXC interrupt
|
||||
UCSRB |= (1 << RXCIE);
|
||||
@@ -27,13 +17,10 @@ int main(void)
|
||||
for (i = 1;; i++) {
|
||||
if (i >= 99999) i = 1;
|
||||
|
||||
sprintf(buf, "[CORE] Fetching sensors #%05lu...\r\n", i);
|
||||
USART_Write(buf);
|
||||
USART_Update();
|
||||
|
||||
// USART_Read(&cmd, MAX_CMDBUF);
|
||||
// sprintf(buf, "[CORE] Checking cmdbuf=\"%s\"\r\n", cmd);
|
||||
// USART_Write(buf);
|
||||
ch = USART_GetChar();
|
||||
USART_Printf("[CORE] Fetching sensors #%05lu...\r\n", i);
|
||||
USART_Printf("[CORE] USART_GetChar() = '%c'\r\n",
|
||||
(ch) ? ch : ' ');
|
||||
|
||||
Sleep(3000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user