thin printf, but buggy
This commit is contained in:
@@ -66,14 +66,14 @@ void app_heater_set_tuning(float p, float i, float d) {
|
||||
}
|
||||
|
||||
void app_heater_enable(bool enable) {
|
||||
printf("Set heater enabled = %d\r\n", (int) enable);
|
||||
PRINTF("Set heater enabled = %d\r\n", (int) enable);
|
||||
heaterEnterCritical();
|
||||
PID_SetCtlMode(&state.pid, enable ? PID_AUTOMATIC : PID_MANUAL);
|
||||
heaterExitCritical();
|
||||
}
|
||||
|
||||
void app_heater_set_target(float target) {
|
||||
printf("Set heater target = %d\r\n", (int) target);
|
||||
PRINTF("Set heater target = %d\r\n", (int) target);
|
||||
heaterEnterCritical();
|
||||
PID_SetSetpoint(&state.pid, target);
|
||||
heaterExitCritical();
|
||||
@@ -99,7 +99,7 @@ void app_task_heater(void *argument)
|
||||
heaterEnterCritical();
|
||||
PID_Compute(&state.pid, state.oven_temp);
|
||||
if (state.pid.ctlMode == PID_AUTOMATIC) {
|
||||
printf("temp %d, output %d\r\n", (int) state.oven_temp, (int) state.pid.Output);
|
||||
PRINTF("temp %d, output %d\r\n", (int) state.oven_temp, (int) state.pid.Output);
|
||||
heater_pwm_set_perc(state.pid.Output);
|
||||
} else {
|
||||
// turn it off
|
||||
|
||||
+5
-5
@@ -33,13 +33,13 @@ static void redraw_display() {
|
||||
|
||||
char tmp[100];
|
||||
|
||||
sprintf(tmp, "T=%d°C", (int) s_app.oven_temp);
|
||||
PRINTF(tmp, "T=%d°C", (int) s_app.oven_temp);
|
||||
fb_text(3, 3, tmp, FONT_5X7, 1);
|
||||
|
||||
sprintf(tmp, "Cil=%d°C", s_app.set_temp);
|
||||
PRINTF(tmp, "Cil=%d°C", s_app.set_temp);
|
||||
fb_text(3, 11, tmp, FONT_5X7, 1);
|
||||
|
||||
sprintf(tmp, "Stav=%s", s_app.run ? "ZAP" : "VYP");
|
||||
PRINTF(tmp, "Stav=%s", s_app.run ? "ZAP" : "VYP");
|
||||
fb_text(3, 19, tmp, FONT_5X7, 1);
|
||||
|
||||
if (s_app.run) {
|
||||
@@ -83,7 +83,7 @@ static void redraw_display() {
|
||||
|
||||
void app_task_main(void *argument)
|
||||
{
|
||||
printf("Main task\r\n");
|
||||
PUTS("Main task\r\n");
|
||||
app_analog_init();
|
||||
app_buzzer_init();
|
||||
app_knob_init();
|
||||
@@ -98,7 +98,7 @@ void app_task_main(void *argument)
|
||||
bool any_change = true;
|
||||
uint32_t last_redraw = osKernelGetTickCount();
|
||||
|
||||
printf("Loop\r\n");
|
||||
PUTS("Loop\r\n");
|
||||
for (;;) {
|
||||
// sampling is done in the heater loop
|
||||
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ void PID_Compute(struct PID *self, float input)
|
||||
uint32_t now = xTaskGetTickCount();
|
||||
int32_t timeChange = (now - self->lastTime);
|
||||
if (timeChange >= self->SampleTimeTicks) {
|
||||
printf("compute\r\n");
|
||||
PUTS("compute\r\n");
|
||||
/*Compute all the working error variables*/
|
||||
float error = self->Setpoint - input;
|
||||
self->ITerm += (self->ki * error);
|
||||
@@ -35,7 +35,7 @@ void PID_Compute(struct PID *self, float input)
|
||||
float dInput = (input - self->lastInput);
|
||||
|
||||
|
||||
printf("calc x100 %d + %d - %d\r\n",
|
||||
PRINTF("calc x100 %d + %d - %d\r\n",
|
||||
(int) (100 * (self->kp * error)),
|
||||
(int) (100 * (self->ITerm)),
|
||||
(int) (100 * (self->kd * dInput))
|
||||
|
||||
+2
-1
@@ -9,6 +9,7 @@
|
||||
#include <stdio.h>
|
||||
#include "app_temp.h"
|
||||
#include "adc.h"
|
||||
#include "snprintf.h"
|
||||
|
||||
/* DMA dest */
|
||||
static volatile uint16_t adc_values[4];
|
||||
@@ -247,5 +248,5 @@ void app_temp_adc_eos()
|
||||
|
||||
void app_temp_show_buf()
|
||||
{
|
||||
printf("%d,%d,%d,%d\r\n", adc_values[0], adc_values[1], adc_values[2], adc_values[3]);
|
||||
PRINTF("%d,%d,%d,%d\r\n", adc_values[0], adc_values[1], adc_values[2], adc_values[3]);
|
||||
}
|
||||
|
||||
+3
-3
@@ -25,7 +25,7 @@
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include <stdio.h>
|
||||
#include "snprintf.h"
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
@@ -135,7 +135,7 @@ void vApplicationMallocFailedHook(void);
|
||||
/* USER CODE BEGIN 4 */
|
||||
void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName)
|
||||
{
|
||||
printf("vApplicationStackOverflowHook: %s\r\n", pcTaskName);
|
||||
PRINTF("vApplicationStackOverflowHook: %s\r\n", pcTaskName);
|
||||
/* Run time stack overflow checking is performed if
|
||||
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is
|
||||
called if a stack overflow is detected. */
|
||||
@@ -145,7 +145,7 @@ void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName)
|
||||
/* USER CODE BEGIN 5 */
|
||||
void vApplicationMallocFailedHook(void)
|
||||
{
|
||||
printf("vApplicationMallocFailedHook\r\n");
|
||||
PUTS("vApplicationMallocFailedHook\r\n");
|
||||
/* vApplicationMallocFailedHook() will only be called if
|
||||
configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
|
||||
function that will get called if a call to pvPortMalloc() fails.
|
||||
|
||||
+3
-2
@@ -120,7 +120,7 @@ int main(void)
|
||||
MX_SPI2_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
printf("Start.\r\n");
|
||||
PUTS("Start.\r\n");
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Init scheduler */
|
||||
@@ -203,7 +203,7 @@ void Error_Handler(void)
|
||||
/* USER CODE BEGIN Error_Handler_Debug */
|
||||
/* User can add his own implementation to report the HAL error return state */
|
||||
__disable_irq();
|
||||
printf("Error_Handler\r\n");
|
||||
PUTS("Error_Handler\r\n");
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
@@ -221,6 +221,7 @@ void Error_Handler(void)
|
||||
void assert_failed(uint8_t *file, uint32_t line)
|
||||
{
|
||||
/* USER CODE BEGIN 6 */
|
||||
PRINTF("assert_failed %s:%d", (const char *) file, (int) line);
|
||||
/* User can add his own implementation to report the file name and line number,
|
||||
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
||||
/* USER CODE END 6 */
|
||||
|
||||
@@ -88,7 +88,7 @@ void NMI_Handler(void)
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN HardFault_IRQn 0 */
|
||||
printf("HardFault_Handler\r\n");
|
||||
PUTS("HardFault_Handler\r\n");
|
||||
|
||||
/* USER CODE END HardFault_IRQn 0 */
|
||||
while (1)
|
||||
@@ -104,7 +104,7 @@ void HardFault_Handler(void)
|
||||
void MemManage_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
|
||||
printf("MemManage_Handler\r\n");
|
||||
PUTS("MemManage_Handler\r\n");
|
||||
|
||||
/* USER CODE END MemoryManagement_IRQn 0 */
|
||||
while (1)
|
||||
@@ -120,7 +120,7 @@ void MemManage_Handler(void)
|
||||
void BusFault_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN BusFault_IRQn 0 */
|
||||
printf("BusFault_Handler\r\n");
|
||||
PUTS("BusFault_Handler\r\n");
|
||||
|
||||
/* USER CODE END BusFault_IRQn 0 */
|
||||
while (1)
|
||||
@@ -136,7 +136,7 @@ void BusFault_Handler(void)
|
||||
void UsageFault_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN UsageFault_IRQn 0 */
|
||||
printf("UsageFault_Handler\r\n");
|
||||
PUTS("UsageFault_Handler\r\n");
|
||||
|
||||
/* USER CODE END UsageFault_IRQn 0 */
|
||||
while (1)
|
||||
|
||||
+20
-5
@@ -21,6 +21,8 @@
|
||||
#include "usart.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "main.h"
|
||||
/* USER CODE END 0 */
|
||||
|
||||
@@ -75,17 +77,30 @@ 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) {
|
||||
int cnt = iLength;
|
||||
while (cnt-- > 0) {
|
||||
while (!LL_USART_IsActiveFlag_TXE(USART_DEBUG)) {}
|
||||
LL_USART_TransmitData8(USART_DEBUG, *pcBuffer++);
|
||||
}
|
||||
stdout_write(pcBuffer, iLength);
|
||||
return iLength;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user