Compare commits
6 Commits
v0.0.3.1
...
7dcdbbadf1
| Author | SHA1 | Date | |
|---|---|---|---|
| 7dcdbbadf1 | |||
| 334295e1cd | |||
| 89cd1e00d0 | |||
| 591a96cf6d | |||
| 2be0f0370e | |||
| 58c4b66f34 |
+1
-1
@@ -52,7 +52,7 @@ extern "C" {
|
||||
#include <stdio.h>
|
||||
#define DEBUG_PRINT(...) printf(__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_PRINT(...)
|
||||
#define DEBUG_PRINT(...) uart_printf(__VA_ARGS__)
|
||||
#endif
|
||||
/* USER CODE END EM */
|
||||
|
||||
|
||||
@@ -20,11 +20,46 @@
|
||||
#include "main.h"
|
||||
#include "cmsis_os.h"
|
||||
#include "canlog.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "cmsis_os.h"
|
||||
#include "stm32f4xx.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
extern UART_HandleTypeDef huart1;
|
||||
extern osSemaphoreId_t xUARTDMASemaphore;
|
||||
extern osMessageQueueId_t xUARTQueue;
|
||||
extern UART_HandleTypeDef huart1;
|
||||
extern osSemaphoreId_t xUARTDMASemaphore;
|
||||
|
||||
/* BEGIN uart_printf */
|
||||
/**
|
||||
* @brief Implementation of a simple print to UART.
|
||||
* @param arguments: strings to print
|
||||
* @retval None
|
||||
*/
|
||||
void uart_printf(const char *fmt, ...)
|
||||
{
|
||||
static char buf[128];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
int len = vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
if (osKernelGetState() == osKernelRunning && __get_IPSR() == 0)
|
||||
{
|
||||
if (osSemaphoreAcquire(xUARTDMASemaphore, osWaitForever) == osOK)
|
||||
{
|
||||
if (HAL_UART_Transmit_DMA(&huart1, (uint8_t*)buf, len) != HAL_OK) osSemaphoreRelease(xUARTDMASemaphore);
|
||||
else osSemaphoreAcquire(xUARTDMASemaphore, osWaitForever);
|
||||
}
|
||||
}
|
||||
else HAL_UART_Transmit(&huart1, (uint8_t*)buf, len, HAL_MAX_DELAY);
|
||||
}
|
||||
}
|
||||
/* END uart_printf */
|
||||
|
||||
/* BEGIN format_can_message */
|
||||
/**
|
||||
|
||||
+6
-7
@@ -95,7 +95,6 @@ int _write(int file, char *ptr, int len)
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
if (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk)
|
||||
{
|
||||
@@ -145,12 +144,12 @@ int main(void)
|
||||
/* USER CODE BEGIN RTOS_TASKS */
|
||||
const osThreadAttr_t CAN1rxAttributes = {
|
||||
.name = "CAN1rx",
|
||||
.stack_size = 128 * 4,
|
||||
.stack_size = 512 * 4,
|
||||
.priority = (osPriority_t) osPriorityRealtime1,
|
||||
};
|
||||
const osThreadAttr_t CAN2rxAttributes = {
|
||||
.name = "CAN2rx",
|
||||
.stack_size = 128 * 4,
|
||||
.stack_size = 512 * 4,
|
||||
.priority = (osPriority_t) osPriorityRealtime,
|
||||
};
|
||||
const osThreadAttr_t UartLoggerAttributes = {
|
||||
@@ -280,7 +279,7 @@ static void MX_CAN1_Init(void)
|
||||
|
||||
/* USER CODE END CAN1_Init 1 */
|
||||
hcan1.Instance = CAN1;
|
||||
hcan1.Init.Prescaler = 8;
|
||||
hcan1.Init.Prescaler = 4;
|
||||
hcan1.Init.Mode = CAN_MODE_SILENT;
|
||||
hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ;
|
||||
hcan1.Init.TimeSeg1 = CAN_BS1_16TQ;
|
||||
@@ -317,7 +316,7 @@ static void MX_CAN2_Init(void)
|
||||
|
||||
/* USER CODE END CAN2_Init 1 */
|
||||
hcan2.Instance = CAN2;
|
||||
hcan2.Init.Prescaler = 16;
|
||||
hcan2.Init.Prescaler = 8;
|
||||
hcan2.Init.Mode = CAN_MODE_SILENT;
|
||||
hcan2.Init.SyncJumpWidth = CAN_SJW_1TQ;
|
||||
hcan2.Init.TimeSeg1 = CAN_BS1_16TQ;
|
||||
@@ -390,11 +389,11 @@ static void MX_USART1_UART_Init(void)
|
||||
|
||||
/* USER CODE END USART1_Init 1 */
|
||||
huart1.Instance = USART1;
|
||||
huart1.Init.BaudRate = 115200;
|
||||
huart1.Init.BaudRate = 1152000;
|
||||
huart1.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
huart1.Init.StopBits = UART_STOPBITS_1;
|
||||
huart1.Init.Parity = UART_PARITY_NONE;
|
||||
huart1.Init.Mode = UART_MODE_TX_RX;
|
||||
huart1.Init.Mode = UART_MODE_TX;
|
||||
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||
if (HAL_UART_Init(&huart1) != HAL_OK)
|
||||
|
||||
Reference in New Issue
Block a user