add buffered rx uart
This commit is contained in:
parent
d86f0ad5a9
commit
a86d9d26bd
@ -33,13 +33,13 @@ ifeq ($(DEBUG),1)
|
|||||||
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o \
|
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o \
|
||||||
main.o usb_bulk.o uart.o fifo.o sram.o crc.o debug.o \
|
main.o usb_bulk.o uart.o fifo.o sram.o crc.o debug.o \
|
||||||
dump.o timer.o watchdog.o rle.c loader.o info.o shared_memory.o \
|
dump.o timer.o watchdog.o rle.c loader.o info.o shared_memory.o \
|
||||||
pwm.o irq.o command.o testing.o
|
pwm.o shell.o irq.o command.o testing.o
|
||||||
else
|
else
|
||||||
LDFLAGS =-Wl,-u
|
LDFLAGS =-Wl,-u
|
||||||
CFLAGS =-Iusbdrv -I. -DDEBUG_LEVEL=0 -DNO_DEBUG -DNO_INFO
|
CFLAGS =-Iusbdrv -I. -DDEBUG_LEVEL=0 -DNO_DEBUG -DNO_INFO
|
||||||
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o usb_bulk.o \
|
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o usb_bulk.o \
|
||||||
uart.o fifo.o sram.o crc.o debug.o dump.o timer.o watchdog.o rle.c loader.o \
|
uart.o fifo.o sram.o crc.o debug.o dump.o timer.o watchdog.o rle.c loader.o \
|
||||||
pwm.o info.o shared_memory.o command.o irq.o
|
pwm.o shell.o info.o shared_memory.o command.o irq.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
|
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
|
||||||
|
|||||||
@ -47,7 +47,7 @@
|
|||||||
#define HW_VERSION "2.6"
|
#define HW_VERSION "2.6"
|
||||||
#define SW_VERSION "1.0"
|
#define SW_VERSION "1.0"
|
||||||
|
|
||||||
#define DO_CRC_CHECK_LOADER 1
|
#define DO_CRC_CHECK_LOADER 0
|
||||||
#define DO_CRC_CHECK 0
|
#define DO_CRC_CHECK 0
|
||||||
#define DO_SHM_SCRATCHPAD 1
|
#define DO_SHM_SCRATCHPAD 1
|
||||||
#define DO_SHM 1
|
#define DO_SHM 1
|
||||||
|
|||||||
65
avr/usbload/shell.c
Normal file
65
avr/usbload/shell.c
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* =====================================================================================
|
||||||
|
*
|
||||||
|
* ________ .__ __ ________ ____ ________
|
||||||
|
* \_____ \ __ __|__| ____ | | __\______ \ _______ _/_ |/ _____/
|
||||||
|
* / / \ \| | \ |/ ___\| |/ / | | \_/ __ \ \/ /| / __ \
|
||||||
|
* / \_/. \ | / \ \___| < | ` \ ___/\ / | \ |__\ \
|
||||||
|
* \_____\ \_/____/|__|\___ >__|_ \/_______ /\___ >\_/ |___|\_____ /
|
||||||
|
* \__> \/ \/ \/ \/ \/
|
||||||
|
*
|
||||||
|
* www.optixx.org
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Version: 1.0
|
||||||
|
* Created: 07/21/2009 03:32:16 PM
|
||||||
|
* Author: david@optixx.org
|
||||||
|
*
|
||||||
|
* =====================================================================================
|
||||||
|
*/
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
|
||||||
|
#include "pwm.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "info.h"
|
||||||
|
#include "sram.h"
|
||||||
|
|
||||||
|
#define RECEIVE_BUF_LEN 40
|
||||||
|
|
||||||
|
uint8_t recv_buf[RECEIVE_BUF_LEN];
|
||||||
|
volatile uint8_t recv_counter = 0;
|
||||||
|
volatile uint8_t cr = 0;
|
||||||
|
|
||||||
|
ISR(USART0_RX_vect) // Interrupt for UART Byte received
|
||||||
|
{
|
||||||
|
UCSR0B &= (255 - (1<<RXCIE0));// Interrupts disable for RxD
|
||||||
|
sei();
|
||||||
|
if(recv_counter == (sizeof(recv_buf)-1)) {
|
||||||
|
cr=1;
|
||||||
|
recv_buf[recv_counter]='\0';
|
||||||
|
recv_counter=0;
|
||||||
|
uart_putc('\n');
|
||||||
|
uart_putc(':');
|
||||||
|
uart_putc('>');
|
||||||
|
}
|
||||||
|
recv_buf[recv_counter] = UDR0;
|
||||||
|
uart_putc(recv_buf[recv_counter]); /* do a echo, maybe should reside not in interrupt */
|
||||||
|
if (recv_buf[recv_counter] == 0x0d) {
|
||||||
|
/* recv_buf[recv_counter] = 0; */
|
||||||
|
cr = 1; // found a CR, so the application should do something
|
||||||
|
recv_buf[++recv_counter]='\0'; // terminate string
|
||||||
|
recv_counter = 0;
|
||||||
|
uart_putc('\n');
|
||||||
|
} else {
|
||||||
|
// we accept backspace or delete
|
||||||
|
if ((recv_buf[recv_counter] == 0x08 || recv_buf[recv_counter] == 0x7f) && recv_counter > 0) {
|
||||||
|
recv_counter--;
|
||||||
|
} else {
|
||||||
|
recv_counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UCSR0B |= (1<<RXCIE0);// Interrupts enable for RxD
|
||||||
|
}
|
||||||
24
avr/usbload/shell.h
Normal file
24
avr/usbload/shell.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* =====================================================================================
|
||||||
|
*
|
||||||
|
* ________ .__ __ ________ ____ ________
|
||||||
|
* \_____ \ __ __|__| ____ | | __\______ \ _______ _/_ |/ _____/
|
||||||
|
* / / \ \| | \ |/ ___\| |/ / | | \_/ __ \ \/ /| / __ \
|
||||||
|
* / \_/. \ | / \ \___| < | ` \ ___/\ / | \ |__\ \
|
||||||
|
* \_____\ \_/____/|__|\___ >__|_ \/_______ /\___ >\_/ |___|\_____ /
|
||||||
|
* \__> \/ \/ \/ \/ \/
|
||||||
|
*
|
||||||
|
* www.optixx.org
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Version: 1.0
|
||||||
|
* Created: 07/21/2009 03:32:16 PM
|
||||||
|
* Author: david@optixx.org
|
||||||
|
*
|
||||||
|
* =====================================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __SHELL_H__
|
||||||
|
#define __SHELL_H__
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -52,7 +52,7 @@ void uart_init(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
ISR(USART0_RX_vect)
|
ISR(USART0_RX_vect)
|
||||||
{
|
{
|
||||||
uint8_t c;
|
uint8_t c;
|
||||||
@ -62,7 +62,7 @@ ISR(USART0_RX_vect)
|
|||||||
intflags.rx_int = 1;
|
intflags.rx_int = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void uart_putc(uint8_t c)
|
void uart_putc(uint8_t c)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user