WIP target lo

custom debug stream

run docker with project dir, specify dir to makefile

remove unused includes

fix broken F1
This commit is contained in:
aanper
2020-08-17 18:23:28 +03:00
parent 419a7644a4
commit 0980775f01
16 changed files with 320 additions and 45 deletions
+17 -35
View File
@@ -1,39 +1,10 @@
/*******************
*
* Copyright 1998-2010 IAR Systems AB.
*
* This is a template implementation of the "__write" function used by
* the standard library. Replace it with a system-specific
* implementation.
*
* The "__write" function should output "size" number of bytes from
* "buffer" in some application-specific way. It should return the
* number of characters written, or _LLIO_ERROR on failure.
*
* If "buffer" is zero then __write should perform flushing of
* internal buffers, if any. In this case "handle" can be -1 to
* indicate that all handles should be flushed.
*
* The template implementation below assumes that the application
* provides the function "MyLowLevelPutchar". It should return the
* character written, or -1 on failure.
*
********************/
// #include <yfuns.h>
#define _GNU_SOURCE
#include "main.h"
#include "cmsis_os.h"
#include <stdio.h>
extern UART_HandleTypeDef DEBUG_UART;
/*
* If the __write implementation uses internal buffering, uncomment
* the following line to ensure that we are called with "buffer" as 0
* (i.e. flush) when the application terminates.
*/
size_t _write(int handle, const unsigned char * buffer, size_t size) {
ssize_t uart_write(void* cookie, const char * buffer, size_t size) {
if (buffer == 0) {
/*
* This means that we should flush internal buffers. Since we
@@ -43,7 +14,18 @@ size_t _write(int handle, const unsigned char * buffer, size_t size) {
return 0;
}
HAL_UART_Transmit(&DEBUG_UART, (uint8_t*)buffer, (uint16_t)size, HAL_MAX_DELAY);
return (int)size;
return (ssize_t)HAL_UART_Transmit(&DEBUG_UART, (uint8_t*)buffer, (uint16_t)size, HAL_MAX_DELAY);
}
FILE* get_debug() {
FILE* fp = fopencookie(NULL,"w+", (cookie_io_functions_t){
.read = NULL,
.write = uart_write,
.seek = NULL,
.close = NULL
});
setvbuf(fp, NULL, _IONBF, 0);
return fp;
}