Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 64ce38fa15 |
+84
-74
@@ -1,74 +1,84 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file : main.h
|
||||
* @brief : Header for main.c file.
|
||||
* This file contains the common defines of the application.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2026 STMicroelectronics.
|
||||
* Copyright (c) 2026 Erick Ahmed.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __MAIN_H
|
||||
#define __MAIN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f4xx_hal.h"
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include <stdint.h>
|
||||
#include "canlog.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
#define DEBUG
|
||||
#ifdef DEBUG
|
||||
#include <stdio.h>
|
||||
#define DEBUG_PRINT(...) printf(__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_PRINT(...)
|
||||
#endif
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
void Error_Handler(void);
|
||||
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __MAIN_H */
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file : main.h
|
||||
* @brief : Header for main.c file.
|
||||
* This file contains the common defines of the application.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2026 STMicroelectronics.
|
||||
* Copyright (c) 2026 Erick Ahmed.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __MAIN_H
|
||||
#define __MAIN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f4xx_hal.h"
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include <stdint.h>
|
||||
#include "canlog.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
#define DEBUG
|
||||
#ifdef DEBUG
|
||||
static inline void ITM_Print(const char *str) {
|
||||
while (*str) {
|
||||
uint32_t timeout = 1000;
|
||||
while ((ITM->PORT[0].u32 == 0) && (timeout-- > 0));
|
||||
|
||||
if (timeout > 0) {
|
||||
ITM->PORT[0].u8 = (uint8_t)(*str);
|
||||
}
|
||||
str++;
|
||||
}
|
||||
}
|
||||
#define DEBUG_PRINT(x) ITM_Print(x)
|
||||
#else
|
||||
#define DEBUG_PRINT(x)
|
||||
#endif
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
void Error_Handler(void);
|
||||
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __MAIN_H */
|
||||
|
||||
+2
-5
@@ -32,7 +32,7 @@ extern osMessageQueueId_t xUARTQueue;
|
||||
* @param arguments: buffer, source, message
|
||||
* @retval None
|
||||
*/
|
||||
static int format_can_message(char *buf, uint8_t source, const CanMessage_t *message)
|
||||
static void format_can_message(char *buf, uint8_t source, const CanMessage_t *message)
|
||||
{
|
||||
const char hex[] = "0123456789ABCDEF";
|
||||
|
||||
@@ -72,9 +72,6 @@ static int format_can_message(char *buf, uint8_t source, const CanMessage_t *mes
|
||||
|
||||
buf[idx++] = '\r';
|
||||
buf[idx++] = '\n';
|
||||
buf[idx] = '\0';
|
||||
|
||||
return idx;
|
||||
}
|
||||
/* END format_can_message */
|
||||
|
||||
@@ -111,7 +108,7 @@ void vUARTLogger(void *argument)
|
||||
{
|
||||
DEBUG_PRINT("CAN frame detected\r\n");
|
||||
format_can_message(tx_buffer, message.source, &message);
|
||||
HAL_UART_Transmit_DMA(&huart1, (uint8_t*)tx_buffer, len);
|
||||
HAL_UART_Transmit_DMA(&huart1, (uint8_t*)tx_buffer, 44);
|
||||
osSemaphoreAcquire(xUARTDMASemaphore, osWaitForever);
|
||||
DEBUG_PRINT("CAN frame sent via UART\r\n");
|
||||
}
|
||||
|
||||
+16
-24
@@ -48,9 +48,9 @@ DMA_HandleTypeDef hdma_sdio_tx;
|
||||
UART_HandleTypeDef huart1;
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
LED_Config led_can1 = {GPIOB, GPIO_PIN_5};
|
||||
LED_Config led_can2 = {GPIOB, GPIO_PIN_6};
|
||||
LED_Config led_error = {GPIOB, GPIO_PIN_7};
|
||||
LED_Config led_can1 = {GPIOB, GPIO_PIN_2};
|
||||
LED_Config led_can2 = {GPIOB, GPIO_PIN_5};
|
||||
LED_Config led_error = {GPIOB, GPIO_PIN_3};
|
||||
|
||||
osThreadId_t xCAN1rxTask;
|
||||
osThreadId_t xCAN2rxTask;
|
||||
@@ -76,12 +76,6 @@ static void MX_SDIO_SD_Init(void);
|
||||
static void MX_USART1_UART_Init(void);
|
||||
|
||||
/* USER CODE BEGIN PFP */
|
||||
int _write(int file, char *ptr, int len) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
ITM_SendChar((*ptr++));
|
||||
}
|
||||
return len;
|
||||
}
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
@@ -356,16 +350,16 @@ static void MX_SDIO_SD_Init(void)
|
||||
hsd.Init.BusWide = SDIO_BUS_WIDE_1B;
|
||||
hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
|
||||
hsd.Init.ClockDiv = 0;
|
||||
//if (HAL_SD_Init(&hsd) != HAL_OK)
|
||||
//{
|
||||
// Error_Handler();
|
||||
//}
|
||||
//if (HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B) != HAL_OK)
|
||||
//{
|
||||
// Error_Handler();
|
||||
//}
|
||||
if (HAL_SD_Init(&hsd) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN SDIO_Init 2 */
|
||||
//DEBUG_PRINT("SDIO initialized!\r\n");
|
||||
DEBUG_PRINT("SDIO initialized!\r\n");
|
||||
/* USER CODE END SDIO_Init 2 */
|
||||
|
||||
}
|
||||
@@ -465,20 +459,18 @@ static void MX_GPIO_Init(void)
|
||||
|
||||
/*Configure GPIO pins : PA0 PA1 PA2 PA3
|
||||
PA4 PA5 PA6 PA7
|
||||
PA8 PA11 PA12 PA15 */
|
||||
PA8 PA11 PA12 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|
||||
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7
|
||||
|GPIO_PIN_8|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_15;
|
||||
|GPIO_PIN_8|GPIO_PIN_11|GPIO_PIN_12;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PB0 PB1 PB2 PB10
|
||||
PB11 PB14 PB15 PB3
|
||||
PB4 */
|
||||
PB11 PB14 PB15 PB4 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_10
|
||||
|GPIO_PIN_11|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_3
|
||||
|GPIO_PIN_4;
|
||||
|GPIO_PIN_11|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_4;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
+20
-14
@@ -70,24 +70,26 @@ Mcu.Name=STM32F405RGTx
|
||||
Mcu.Package=LQFP64
|
||||
Mcu.Pin0=PB12
|
||||
Mcu.Pin1=PB13
|
||||
Mcu.Pin10=PC12
|
||||
Mcu.Pin11=PD2
|
||||
Mcu.Pin12=PB5
|
||||
Mcu.Pin13=PB6
|
||||
Mcu.Pin14=PB7
|
||||
Mcu.Pin15=PB8
|
||||
Mcu.Pin16=PB9
|
||||
Mcu.Pin17=VP_FREERTOS_VS_CMSIS_V2
|
||||
Mcu.Pin18=VP_SYS_VS_tim6
|
||||
Mcu.Pin10=PC11
|
||||
Mcu.Pin11=PC12
|
||||
Mcu.Pin12=PD2
|
||||
Mcu.Pin13=PB3
|
||||
Mcu.Pin14=PB5
|
||||
Mcu.Pin15=PB6
|
||||
Mcu.Pin16=PB7
|
||||
Mcu.Pin17=PB8
|
||||
Mcu.Pin18=PB9
|
||||
Mcu.Pin19=VP_FREERTOS_VS_CMSIS_V2
|
||||
Mcu.Pin2=PC8
|
||||
Mcu.Pin20=VP_SYS_VS_tim6
|
||||
Mcu.Pin3=PC9
|
||||
Mcu.Pin4=PA9
|
||||
Mcu.Pin5=PA10
|
||||
Mcu.Pin6=PA13
|
||||
Mcu.Pin7=PA14
|
||||
Mcu.Pin8=PC10
|
||||
Mcu.Pin9=PC11
|
||||
Mcu.PinsNb=19
|
||||
Mcu.Pin8=PA15
|
||||
Mcu.Pin9=PC10
|
||||
Mcu.PinsNb=21
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32F405RGTx
|
||||
@@ -115,16 +117,20 @@ NVIC.TimeBaseIP=TIM6
|
||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||
PA10.Mode=Asynchronous
|
||||
PA10.Signal=USART1_RX
|
||||
PA13.Mode=Serial_Wire
|
||||
PA13.Mode=JTAG_4_pins
|
||||
PA13.Signal=SYS_JTMS-SWDIO
|
||||
PA14.Mode=Serial_Wire
|
||||
PA14.Mode=JTAG_4_pins
|
||||
PA14.Signal=SYS_JTCK-SWCLK
|
||||
PA15.Mode=JTAG_4_pins
|
||||
PA15.Signal=SYS_JTDI
|
||||
PA9.Mode=Asynchronous
|
||||
PA9.Signal=USART1_TX
|
||||
PB12.Mode=CAN_Activate
|
||||
PB12.Signal=CAN2_RX
|
||||
PB13.Mode=CAN_Activate
|
||||
PB13.Signal=CAN2_TX
|
||||
PB3.Mode=JTAG_4_pins
|
||||
PB3.Signal=SYS_JTDO-SWO
|
||||
PB5.Locked=true
|
||||
PB5.Signal=GPIO_Output
|
||||
PB6.Locked=true
|
||||
|
||||
Reference in New Issue
Block a user