f0 working (one fixme)
need scan mode upstream?
This commit is contained in:
parent
c522c29dca
commit
19a85ae45b
6 changed files with 146 additions and 3 deletions
34
shared/usart_stdio.c
Normal file
34
shared/usart_stdio.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* support for stdio output to a usart
|
||||
* Karl Palsson, 2015 <karlp@tweak.net.au>
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <libopencm3/stm32/usart.h>
|
||||
|
||||
#ifndef STDIO_USART
|
||||
#define STDIO_USART USART1
|
||||
#endif
|
||||
|
||||
int _write(int file, char *ptr, int len);
|
||||
int _write(int file, char *ptr, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (file == STDOUT_FILENO || file == STDERR_FILENO) {
|
||||
for (i = 0; i < len; i++) {
|
||||
if (ptr[i] == '\n') {
|
||||
usart_send_blocking(STDIO_USART, '\r');
|
||||
}
|
||||
usart_send_blocking(STDIO_USART, ptr[i]);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue