50 lines
1.5 KiB
C
50 lines
1.5 KiB
C
|
/*******************
|
||
|
*
|
||
|
* 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>
|
||
|
#include "main.h"
|
||
|
#include "cmsis_os.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) {
|
||
|
if (buffer == 0) {
|
||
|
/*
|
||
|
* This means that we should flush internal buffers. Since we
|
||
|
* don't we just return. (Remember, "handle" == -1 means that all
|
||
|
* handles should be flushed.)
|
||
|
*/
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
HAL_UART_Transmit(&DEBUG_UART, (uint8_t*)buffer, (uint16_t)size, HAL_MAX_DELAY);
|
||
|
|
||
|
return (int)size;
|
||
|
}
|