Shrink the logger

* Move _write function to the log.c
* Change the way to setup the logger
* Update the readme
* Add terminal commands
This commit is contained in:
2023-10-31 21:14:02 +01:00
parent c9df2dee99
commit 11eba9dd84
4 changed files with 130 additions and 181 deletions

View File

@@ -22,8 +22,7 @@
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <errno.h>
#include <sys/unistd.h>
#include "log.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@@ -431,24 +430,6 @@ static void MX_GPIO_Init(void)
}
/* USER CODE BEGIN 4 */
int _write(int file, char *data, int len) {
HAL_StatusTypeDef status;
switch (file) {
case STDOUT_FILENO:
case STDERR_FILENO:
status = HAL_UART_Transmit(&huart1, (uint8_t*)data, len, HAL_MAX_DELAY);
if (status != HAL_OK) {
errno = EIO;
return -1;
}
break;
default:
errno = EBADF;
return -1;
}
return len;
}
/* USER CODE END 4 */
/**