5 Commits

Author SHA1 Message Date
eeeck 4afa6702fb Return exact length 2026-06-17 20:33:38 +02:00
eeeck 907c0b170d Move to PFP block in main.c and use more standard logic 2026-06-17 20:33:22 +02:00
eeeck 60849ebb78 Testing: SDIO stuff deactivated until implemented
- Goes into error handling
2026-06-17 20:32:36 +02:00
eeeck aeb553994c Update LED struct 2026-06-17 20:14:56 +02:00
eeeck 5e28758a5e Use serial mode instad of JTAG 2026-06-17 20:09:45 +02:00
4 changed files with 671 additions and 683 deletions
+74 -85
View File
@@ -1,85 +1,74 @@
/* USER CODE BEGIN Header */ /* USER CODE BEGIN Header */
/** /**
****************************************************************************** ******************************************************************************
* @file : main.h * @file : main.h
* @brief : Header for main.c file. * @brief : Header for main.c file.
* This file contains the common defines of the application. * This file contains the common defines of the application.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* Copyright (c) 2026 STMicroelectronics. * Copyright (c) 2026 STMicroelectronics.
* Copyright (c) 2026 Erick Ahmed. * Copyright (c) 2026 Erick Ahmed.
* *
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* *
****************************************************************************** ******************************************************************************
*/ */
/* USER CODE END Header */ /* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/ /* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H #ifndef __MAIN_H
#define __MAIN_H #define __MAIN_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_hal.h" #include "stm32f4xx_hal.h"
/* Private includes ----------------------------------------------------------*/
/* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */
/* USER CODE BEGIN Includes */ #include <stdint.h>
#include <stdint.h> #include "canlog.h"
#include "canlog.h" /* USER CODE END Includes */
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/ /* USER CODE BEGIN ET */
/* USER CODE BEGIN ET */
/* USER CODE END ET */
/* USER CODE END ET */
/* Exported constants --------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/ /* USER CODE BEGIN EC */
/* USER CODE BEGIN EC */
/* USER CODE END EC */
/* USER CODE END EC */
/* Exported macro ------------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/ /* USER CODE BEGIN EM */
/* USER CODE BEGIN EM */ #define DEBUG
#define DEBUG #ifdef DEBUG
#ifdef DEBUG #include <stdio.h>
static inline void ITM_Print(const char *str) { #define DEBUG_PRINT(...) printf(__VA_ARGS__)
while (*str) { #else
uint32_t timeout = 1000; #define DEBUG_PRINT(...)
while ((ITM->PORT[0].u32 == 0) && (timeout-- > 0)); #endif
/* USER CODE END EM */
if (timeout > 0) {
ITM->PORT[0].u8 = (uint8_t)(*str); /* Exported functions prototypes ---------------------------------------------*/
} void Error_Handler(void);
str++;
} /* USER CODE BEGIN EFP */
}
#define DEBUG_PRINT(x) ITM_Print(x) /* USER CODE END EFP */
#else
#define DEBUG_PRINT(x) /* Private defines -----------------------------------------------------------*/
#endif
/* USER CODE END EM */ /* USER CODE BEGIN Private defines */
/* Exported functions prototypes ---------------------------------------------*/ /* USER CODE END Private defines */
void Error_Handler(void);
#ifdef __cplusplus
/* USER CODE BEGIN EFP */ }
#endif
/* USER CODE END EFP */
#endif /* __MAIN_H */
/* Private defines -----------------------------------------------------------*/
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
#ifdef __cplusplus
}
#endif
#endif /* __MAIN_H */
+5 -2
View File
@@ -32,7 +32,7 @@ extern osMessageQueueId_t xUARTQueue;
* @param arguments: buffer, source, message * @param arguments: buffer, source, message
* @retval None * @retval None
*/ */
static void format_can_message(char *buf, uint8_t source, const CanMessage_t *message) static int format_can_message(char *buf, uint8_t source, const CanMessage_t *message)
{ {
const char hex[] = "0123456789ABCDEF"; const char hex[] = "0123456789ABCDEF";
@@ -72,6 +72,9 @@ static void format_can_message(char *buf, uint8_t source, const CanMessage_t *me
buf[idx++] = '\r'; buf[idx++] = '\r';
buf[idx++] = '\n'; buf[idx++] = '\n';
buf[idx] = '\0';
return idx;
} }
/* END format_can_message */ /* END format_can_message */
@@ -108,7 +111,7 @@ void vUARTLogger(void *argument)
{ {
DEBUG_PRINT("CAN frame detected\r\n"); DEBUG_PRINT("CAN frame detected\r\n");
format_can_message(tx_buffer, message.source, &message); format_can_message(tx_buffer, message.source, &message);
HAL_UART_Transmit_DMA(&huart1, (uint8_t*)tx_buffer, 44); HAL_UART_Transmit_DMA(&huart1, (uint8_t*)tx_buffer, len);
osSemaphoreAcquire(xUARTDMASemaphore, osWaitForever); osSemaphoreAcquire(xUARTDMASemaphore, osWaitForever);
DEBUG_PRINT("CAN frame sent via UART\r\n"); DEBUG_PRINT("CAN frame sent via UART\r\n");
} }
+570 -562
View File
File diff suppressed because it is too large Load Diff
+22 -34
View File
@@ -68,30 +68,26 @@ Mcu.IP8=USART1
Mcu.IPNb=9 Mcu.IPNb=9
Mcu.Name=STM32F405RGTx Mcu.Name=STM32F405RGTx
Mcu.Package=LQFP64 Mcu.Package=LQFP64
Mcu.Pin0=PA0-WKUP Mcu.Pin0=PB12
Mcu.Pin1=PB12 Mcu.Pin1=PB13
Mcu.Pin10=PC10 Mcu.Pin10=PC12
Mcu.Pin11=PC11 Mcu.Pin11=PD2
Mcu.Pin12=PC12 Mcu.Pin12=PB5
Mcu.Pin13=PD2 Mcu.Pin13=PB6
Mcu.Pin14=PB3 Mcu.Pin14=PB7
Mcu.Pin15=PB4 Mcu.Pin15=PB8
Mcu.Pin16=PB5 Mcu.Pin16=PB9
Mcu.Pin17=PB6 Mcu.Pin17=VP_FREERTOS_VS_CMSIS_V2
Mcu.Pin18=PB7 Mcu.Pin18=VP_SYS_VS_tim6
Mcu.Pin19=PB8 Mcu.Pin2=PC8
Mcu.Pin2=PB13 Mcu.Pin3=PC9
Mcu.Pin20=PB9 Mcu.Pin4=PA9
Mcu.Pin21=VP_FREERTOS_VS_CMSIS_V2 Mcu.Pin5=PA10
Mcu.Pin22=VP_SYS_VS_tim6 Mcu.Pin6=PA13
Mcu.Pin3=PC8 Mcu.Pin7=PA14
Mcu.Pin4=PC9 Mcu.Pin8=PC10
Mcu.Pin5=PA9 Mcu.Pin9=PC11
Mcu.Pin6=PA10 Mcu.PinsNb=19
Mcu.Pin7=PA13
Mcu.Pin8=PA14
Mcu.Pin9=PA15
Mcu.PinsNb=23
Mcu.ThirdPartyNb=0 Mcu.ThirdPartyNb=0
Mcu.UserConstants= Mcu.UserConstants=
Mcu.UserName=STM32F405RGTx Mcu.UserName=STM32F405RGTx
@@ -117,26 +113,18 @@ NVIC.TIM6_DAC_IRQn=true\:15\:0\:false\:false\:true\:false\:false\:true\:true
NVIC.TimeBase=TIM6_DAC_IRQn NVIC.TimeBase=TIM6_DAC_IRQn
NVIC.TimeBaseIP=TIM6 NVIC.TimeBaseIP=TIM6
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
PA0-WKUP.Mode=SYS_WakeUp0
PA0-WKUP.Signal=SYS_WKUP
PA10.Mode=Asynchronous PA10.Mode=Asynchronous
PA10.Signal=USART1_RX PA10.Signal=USART1_RX
PA13.Mode=JTAG_5_pins PA13.Mode=Serial_Wire
PA13.Signal=SYS_JTMS-SWDIO PA13.Signal=SYS_JTMS-SWDIO
PA14.Mode=JTAG_5_pins PA14.Mode=Serial_Wire
PA14.Signal=SYS_JTCK-SWCLK PA14.Signal=SYS_JTCK-SWCLK
PA15.Mode=JTAG_5_pins
PA15.Signal=SYS_JTDI
PA9.Mode=Asynchronous PA9.Mode=Asynchronous
PA9.Signal=USART1_TX PA9.Signal=USART1_TX
PB12.Mode=CAN_Activate PB12.Mode=CAN_Activate
PB12.Signal=CAN2_RX PB12.Signal=CAN2_RX
PB13.Mode=CAN_Activate PB13.Mode=CAN_Activate
PB13.Signal=CAN2_TX PB13.Signal=CAN2_TX
PB3.Mode=JTAG_5_pins
PB3.Signal=SYS_JTDO-SWO
PB4.Mode=JTAG_5_pins
PB4.Signal=SYS_JTRST
PB5.Locked=true PB5.Locked=true
PB5.Signal=GPIO_Output PB5.Signal=GPIO_Output
PB6.Locked=true PB6.Locked=true