mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
* added readc and putc to uart0 library
* allow overwrote of port by argument for pyterm
This commit is contained in:
parent
fb784c6628
commit
ee4b68371c
@ -3,8 +3,11 @@
|
||||
|
||||
extern int uart0_handler_pid;
|
||||
|
||||
void board_uart0_init();
|
||||
void board_uart0_init(void);
|
||||
void uart0_handle_incoming(int c);
|
||||
void uart0_notify_thread();
|
||||
void uart0_notify_thread(void);
|
||||
|
||||
int uart0_readc(void);
|
||||
void uart0_putc(int c);
|
||||
|
||||
#endif /* __BOARD_UART0_H */
|
||||
|
17
sys/uart0.c
17
sys/uart0.c
@ -3,6 +3,7 @@
|
||||
#include <stdio.h>
|
||||
#include <thread.h>
|
||||
#include <msg.h>
|
||||
#include <posix_io.h>
|
||||
|
||||
#include <board_uart0.h>
|
||||
|
||||
@ -16,11 +17,11 @@ static char buffer[UART0_BUFSIZE];
|
||||
|
||||
static char uart0_thread_stack[UART0_STACKSIZE];
|
||||
|
||||
static void uart0_loop() {
|
||||
static void uart0_loop(void) {
|
||||
chardev_loop(&uart0_ringbuffer);
|
||||
}
|
||||
|
||||
void board_uart0_init() {
|
||||
void board_uart0_init(void) {
|
||||
ringbuffer_init(&uart0_ringbuffer, buffer, UART0_BUFSIZE);
|
||||
int pid = thread_create(uart0_thread_stack, sizeof(uart0_thread_stack), PRIORITY_MAIN-1, CREATE_STACKTEST, uart0_loop, "uart0");
|
||||
uart0_handler_pid = pid;
|
||||
@ -31,8 +32,18 @@ void uart0_handle_incoming(int c) {
|
||||
rb_add_element(&uart0_ringbuffer, c);
|
||||
}
|
||||
|
||||
void uart0_notify_thread() {
|
||||
void uart0_notify_thread(void) {
|
||||
msg m;
|
||||
m.type = 0;
|
||||
msg_send_int(&m, uart0_handler_pid);
|
||||
}
|
||||
|
||||
int uart0_readc(void) {
|
||||
char c = 0;
|
||||
posix_read(uart0_handler_pid, &c, 1);
|
||||
return c;
|
||||
}
|
||||
|
||||
void uart0_putc(int c) {
|
||||
putchar(c);
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ class SerCmd(cmd.Cmd):
|
||||
sys.stderr.write("No port specified!\n")
|
||||
sys.exit(-1)
|
||||
self.ser = serial.Serial(port=self.port, baudrate=115200, dsrdtr=0, rtscts=0)
|
||||
self.ser.setDTR(0)
|
||||
self.ser.setRTS(0)
|
||||
#self.ser.setDTR(0)
|
||||
#self.ser.setRTS(0)
|
||||
|
||||
# start serial->console thread
|
||||
receiver_thread = threading.Thread(target=reader, args=(self.ser,))
|
||||
@ -100,7 +100,8 @@ class SerCmd(cmd.Cmd):
|
||||
self.aliases[opt] = self.config.get(sec, opt)
|
||||
else:
|
||||
for opt in self.config.options(sec):
|
||||
self.__dict__[opt] = self.config.get(sec, opt)
|
||||
if not self.__dict__.has_key(opt):
|
||||
self.__dict__[opt] = self.config.get(sec, opt)
|
||||
|
||||
|
||||
def reader(ser):
|
||||
|
Loading…
Reference in New Issue
Block a user