This commit is contained in:
2023-03-12 20:05:27 +01:00
parent 7e99e2cc6c
commit 8376f0b5eb
10 changed files with 81 additions and 44 deletions
+1 -1
View File
@@ -138,7 +138,7 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
header file. */
/* USER CODE BEGIN 1 */
#include "snprintf.h"
#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); PRINTF("configASSERT "__FILE__":%d\r\n",__LINE__); for( ;; );}
#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); PRINTF("FreeRTOS assert @ %s:%d\r\n", __FILE__, __LINE__); for( ;; );}
/* USER CODE END 1 */
/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
-4
View File
@@ -16,10 +16,6 @@
*
******************************************************************************
*/
// this is a hack needed for CLion - placed here so cubemx does not overwrite it
#ifndef USE_FULL_LL_DRIVER
#define USE_FULL_LL_DRIVER 1
#endif
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
+5 -3
View File
@@ -33,13 +33,13 @@ static void redraw_display() {
char tmp[100];
PRINTF(tmp, "T=%d°C", (int) s_app.oven_temp);
SPRINTF(tmp, "T=%d°C", (int) s_app.oven_temp);
fb_text(3, 3, tmp, FONT_5X7, 1);
PRINTF(tmp, "Cil=%d°C", s_app.set_temp);
SPRINTF(tmp, "Cil=%d°C", s_app.set_temp);
fb_text(3, 11, tmp, FONT_5X7, 1);
PRINTF(tmp, "Stav=%s", s_app.run ? "ZAP" : "VYP");
SPRINTF(tmp, "Stav=%s", s_app.run ? "ZAP" : "VYP");
fb_text(3, 19, tmp, FONT_5X7, 1);
if (s_app.run) {
@@ -141,6 +141,8 @@ void app_task_main(void *argument)
uint32_t now = osKernelGetTickCount();
if (any_change || (now - last_redraw > pdMS_TO_TICKS(500))) {
PUTS("Cycle\r\n");
PRINTF("test printf\r\n");
last_redraw = now;
redraw_display();
any_change = false;
+52
View File
@@ -0,0 +1,52 @@
/**
* TODO file description
*/
#include <string.h>
#include "uart_stdout.h"
#include "FreeRTOS.h"
#include "main.h"
#define USE_CRITICAL 0
void stdout_putchar(char c) {
#if USE_CRITICAL
portENTER_CRITICAL();
#endif
while (!LL_USART_IsActiveFlag_TXE(USART_DEBUG)) {}
LL_USART_TransmitData8(USART_DEBUG, c);
while (!LL_USART_IsActiveFlag_TC(USART_DEBUG)) {}
#if USE_CRITICAL
portEXIT_CRITICAL();
#endif
}
void stdout_write(const char *pcBuffer, const size_t iLength) {
#if USE_CRITICAL
portENTER_CRITICAL();
#endif
while (!LL_USART_IsActiveFlag_TXE(USART_DEBUG)) {}
int cnt = (int) iLength;
while (cnt-- > 0) {
char c = *pcBuffer++;
LL_USART_TransmitData8(USART_DEBUG, c);
while (!LL_USART_IsActiveFlag_TC(USART_DEBUG)) {}
}
#if USE_CRITICAL
portEXIT_CRITICAL();
#endif
}
void stdout_puts(const char *pcBuffer) {
stdout_write(pcBuffer, strlen(pcBuffer));
}
/**
* @brief Retargets the C library printf function to the USART.
* @param None
* @retval None
*/
int _write(int fd, const char *pcBuffer, const int iLength) {
stdout_write(pcBuffer, iLength);
return iLength;
}
+8
View File
@@ -0,0 +1,8 @@
/**
* TODO file description
*/
#ifndef BLUEPILLTROUBA_UART_STDOUT_H
#define BLUEPILLTROUBA_UART_STDOUT_H
#endif //BLUEPILLTROUBA_UART_STDOUT_H
+1 -30
View File
@@ -21,9 +21,6 @@
#include "usart.h"
/* USER CODE BEGIN 0 */
#include <stddef.h>
#include <string.h>
#include "main.h"
/* USER CODE END 0 */
/* USART1 init function */
@@ -76,32 +73,6 @@ void MX_USART1_UART_Init(void)
}
/* USER CODE BEGIN 1 */
void stdout_write(const char *pcBuffer, const size_t iLength) {
int cnt = (int) iLength;
while (cnt-- > 0) {
while (!LL_USART_IsActiveFlag_TXE(USART_DEBUG)) {}
LL_USART_TransmitData8(USART_DEBUG, *pcBuffer++);
}
}
void stdout_puts(const char *pcBuffer) {
stdout_write(pcBuffer, strlen(pcBuffer));
}
void stdout_putchar(char c) {
while (!LL_USART_IsActiveFlag_TXE(USART_DEBUG)) {}
LL_USART_TransmitData8(USART_DEBUG, c);
}
/**
* @brief Retargets the C library printf function to the USART.
* @param None
* @retval None
*/
int _write(int fd, const char *pcBuffer, const int iLength) {
stdout_write(pcBuffer, iLength);
return iLength;
}
/* USER CODE END 1 */