calib-gui
Ondřej Hruška 2 years ago
parent 7e99e2cc6c
commit 8376f0b5eb
  1. 2
      Core/Inc/FreeRTOSConfig.h
  2. 4
      Core/Inc/main.h
  3. 8
      Core/Src/app_main.c
  4. 52
      Core/Src/uart_stdout.c
  5. 8
      Core/Src/uart_stdout.h
  6. 31
      Core/Src/usart.c
  7. 4
      Lib/snprintf/snprintf.c
  8. 5
      Lib/snprintf/snprintf.h
  9. 1
      Makefile
  10. 10
      STM32F103C8Tx_FLASH.ld

@ -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

@ -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 -------------------------------------*/

@ -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;

@ -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;
}

@ -0,0 +1,8 @@
/**
* TODO file description
*/
#ifndef BLUEPILLTROUBA_UART_STDOUT_H
#define BLUEPILLTROUBA_UART_STDOUT_H
#endif //BLUEPILLTROUBA_UART_STDOUT_H

@ -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 BEGIN 1 */
/* USER CODE END 1 */

@ -831,11 +831,13 @@ int vasprintf(char **ptr, const char *format, va_list ap)
{
int ret;
va_list ap_copy;
va_copy(ap_copy, ap);
ret = vsnprintf((char *) NULL, 0, format, ap);
if (ret + 1 <= 1) { return ret; } /* pts: bit of old unsigned trick... */
if (NULL == (*ptr = (char *) my_malloc(ret + 1))) { return -1; }
ret = vsnprintf(*ptr, ret + 1, format, ap);
ret = vsnprintf(*ptr, ret + 1, format, ap_copy);
return ret;
}

@ -26,6 +26,11 @@ int fixup_vprintf(const char *format, va_list ap);
#define PRINTF(...) fixup_printf(__VA_ARGS__)
#define VPRINTF(...) fixup_vprintf(__VA_ARGS__)
// for debug
//#include <stdio.h>
//#define PRINTF(...) printf(__VA_ARGS__)
//#define SPRINTF(...) sprintf(__VA_ARGS__)
// extern
extern void stdout_puts(const char *s);

@ -52,6 +52,7 @@ Core/Src/app_temp.c \
Core/Src/app_knob.c \
Core/Src/app_buzzer.c \
Core/Src/app_heater.c \
Core/Src/uart_stdout.c \
Core/Src/stm32f1xx_it.c \
Core/Src/system_stm32f1xx.c \
Middlewares/Third_Party/FreeRTOS/Source/croutine.c \

@ -62,8 +62,8 @@ _Min_Stack_Size = 0x400; /* required amount of stack */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 48K
EEPROM_EMU (rx) : ORIGIN = ORIGIN(FLASH) + LENGTH(FLASH), LENGTH = 16K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 56K
EEPROM_EMU (rx) : ORIGIN = ORIGIN(FLASH) + LENGTH(FLASH), LENGTH = 8K
}
/* Define output sections */
@ -135,7 +135,7 @@ SECTIONS
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
@ -146,7 +146,7 @@ SECTIONS
_edata = .; /* define a global symbol at data end */
} >RAM AT> FLASH
/* Uninitialized data section */
. = ALIGN(4);
.bss :
@ -174,7 +174,7 @@ SECTIONS
. = ALIGN(8);
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ :

Loading…
Cancel
Save