Skip to content

Commit

Permalink
fixed bug in log files (all files updated because of changes in ioc...)
Browse files Browse the repository at this point in the history
  • Loading branch information
IDV7 committed Feb 22, 2024
1 parent 8438b63 commit f321811
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 9 deletions.
1 change: 0 additions & 1 deletion software/Core/Inc/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ typedef enum {
} type_color_t;

void log_init(log_level_t log_level, bool color);
void log_msg(log_level_t log_level, const uint8_t *format, ...);
void LOGD(const uint8_t *format, ...);
void LOGI(const uint8_t *format, ...);
void LOGW(const uint8_t *format, ...);
Expand Down
1 change: 1 addition & 0 deletions software/Core/Inc/stm32f7xx_it.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
void USART2_IRQHandler(void);
/* USER CODE BEGIN EFP */

/* USER CODE END EFP */
Expand Down
7 changes: 1 addition & 6 deletions software/Core/Src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,11 @@ uint8_t * get_log_level_color_attr(log_level_t log_level) {
}
}

void log_msg(log_level_t log_level, const uint8_t *format, ...) {
void log_msg(log_level_t log_level, const uint8_t *format, va_list args) {
if (log_level < logging.level) {
return;
}

va_list args;
va_start(args, format);

printf("%s", get_log_level_color_attr(log_level));
switch (log_level) {
case LOG_LEVEL_DEBUG:
Expand All @@ -61,8 +58,6 @@ void log_msg(log_level_t log_level, const uint8_t *format, ...) {
}
vprintf((char*)format, args);
printf("%s\r\n", ANSI_COLOR(COLOR_RESET));

va_end(args);
}

void LOGD(const uint8_t *format, ...) {
Expand Down
4 changes: 3 additions & 1 deletion software/Core/Src/mymain.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ void myinit(void)
void mymain(void)
{
while (1) {
printf("Hello World!\n");
uint32_t brr_value = huart2.Instance->BRR;
LOGD("BRR: %d\n", brr_value);
LOGD("Test value: %d\n", 1234);
HAL_Delay(1000);
LED_toggle();
}
Expand Down
5 changes: 5 additions & 0 deletions software/Core/Src/stm32f7xx_hal_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

/* USART2 interrupt Init */
HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(USART2_IRQn);
/* USER CODE BEGIN USART2_MspInit 1 */

/* USER CODE END USART2_MspInit 1 */
Expand Down Expand Up @@ -447,6 +450,8 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
*/
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);

/* USART2 interrupt DeInit */
HAL_NVIC_DisableIRQ(USART2_IRQn);
/* USER CODE BEGIN USART2_MspDeInit 1 */

/* USER CODE END USART2_MspDeInit 1 */
Expand Down
16 changes: 15 additions & 1 deletion software/Core/Src/stm32f7xx_it.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
/* USER CODE END 0 */

/* External variables --------------------------------------------------------*/

extern UART_HandleTypeDef huart2;
/* USER CODE BEGIN EV */

/* USER CODE END EV */
Expand Down Expand Up @@ -198,6 +198,20 @@ void SysTick_Handler(void)
/* please refer to the startup file (startup_stm32f7xx.s). */
/******************************************************************************/

/**
* @brief This function handles USART2 global interrupt.
*/
void USART2_IRQHandler(void)
{
/* USER CODE BEGIN USART2_IRQn 0 */

/* USER CODE END USART2_IRQn 0 */
HAL_UART_IRQHandler(&huart2);
/* USER CODE BEGIN USART2_IRQn 1 */

/* USER CODE END USART2_IRQn 1 */
}

/* USER CODE BEGIN 1 */

/* USER CODE END 1 */
1 change: 1 addition & 0 deletions software/betterflight.ioc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
NVIC.USART2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
PA0-WKUP.Mode=Asynchronous
PA0-WKUP.Signal=UART4_TX
Expand Down

0 comments on commit f321811

Please sign in to comment.