Move CAN bus related tasks and definition to canlog.h
This commit was merged in pull request #4.
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
#ifndef CANLOG_H
|
||||||
|
#define CANLOG_H
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initializes the CAN logger modules, OS threads, queues, and hardware.
|
||||||
|
* @param hcan1 Pointer to the CAN1 handle
|
||||||
|
* @param hcan2 Pointer to the CAN2 handle
|
||||||
|
*/
|
||||||
|
void CAN_Logger_Init(CAN_HandleTypeDef *hcan1, CAN_HandleTypeDef *hcan2);
|
||||||
|
|
||||||
|
#endif /* CANLOG_H */
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#include "canlog.h"
|
||||||
|
#include "cmsis_os.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* Definitions for canBus1Listen */
|
||||||
|
osThreadId_t canBus1ListenHandle;
|
||||||
|
const osThreadAttr_t canBus1Listen_attributes = {
|
||||||
|
.name = "canBus1Listen",
|
||||||
|
.stack_size = 128 * 4,
|
||||||
|
.priority = (osPriority_t) osPriorityRealtime1,
|
||||||
|
};
|
||||||
|
/* Definitions for canBus2Listen */
|
||||||
|
osThreadId_t canBus2ListenHandle;
|
||||||
|
const osThreadAttr_t canBus2Listen_attributes = {
|
||||||
|
.name = "canBus2Listen",
|
||||||
|
.stack_size = 128 * 4,
|
||||||
|
.priority = (osPriority_t) osPriorityRealtime,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
void CAN_Logger_Init(CAN_HandleTypeDef *hcan1, CAN_HandleTypeDef *hcan2){}
|
||||||
|
static void CAN_Listen(void *argument){}
|
||||||
|
|
||||||
|
/* BEGIN Header_CAN_Listen */
|
||||||
|
/**
|
||||||
|
* @brief Function implementing the canBus0Listen thread.
|
||||||
|
* @param argument: Not used
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
/* END Header_CAN_Listen */
|
||||||
|
void CAN_Listen(void *argument)
|
||||||
|
{
|
||||||
|
/* CODE BEGIN */
|
||||||
|
/* Infinite loop */
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
osDelay(1);
|
||||||
|
}
|
||||||
|
/* CODE END */
|
||||||
|
}
|
||||||
+5
-39
@@ -18,6 +18,7 @@
|
|||||||
/* USER CODE END Header */
|
/* USER CODE END Header */
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "canlog.h"
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
|
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
@@ -48,20 +49,6 @@ SD_HandleTypeDef hsd;
|
|||||||
DMA_HandleTypeDef hdma_sdio_rx;
|
DMA_HandleTypeDef hdma_sdio_rx;
|
||||||
DMA_HandleTypeDef hdma_sdio_tx;
|
DMA_HandleTypeDef hdma_sdio_tx;
|
||||||
|
|
||||||
/* Definitions for canBus1Listen */
|
|
||||||
osThreadId_t canBus1ListenHandle;
|
|
||||||
const osThreadAttr_t canBus1Listen_attributes = {
|
|
||||||
.name = "canBus1Listen",
|
|
||||||
.stack_size = 128 * 4,
|
|
||||||
.priority = (osPriority_t) osPriorityRealtime1,
|
|
||||||
};
|
|
||||||
/* Definitions for canBus2Listen */
|
|
||||||
osThreadId_t canBus2ListenHandle;
|
|
||||||
const osThreadAttr_t canBus2Listen_attributes = {
|
|
||||||
.name = "canBus2Listen",
|
|
||||||
.stack_size = 128 * 4,
|
|
||||||
.priority = (osPriority_t) osPriorityRealtime,
|
|
||||||
};
|
|
||||||
/* USER CODE BEGIN PV */
|
/* USER CODE BEGIN PV */
|
||||||
|
|
||||||
/* USER CODE END PV */
|
/* USER CODE END PV */
|
||||||
@@ -73,7 +60,6 @@ static void MX_DMA_Init(void);
|
|||||||
static void MX_CAN1_Init(void);
|
static void MX_CAN1_Init(void);
|
||||||
static void MX_CAN2_Init(void);
|
static void MX_CAN2_Init(void);
|
||||||
static void MX_SDIO_SD_Init(void);
|
static void MX_SDIO_SD_Init(void);
|
||||||
void can_listen(void *argument);
|
|
||||||
|
|
||||||
/* USER CODE BEGIN PFP */
|
/* USER CODE BEGIN PFP */
|
||||||
|
|
||||||
@@ -119,6 +105,9 @@ int main(void)
|
|||||||
MX_SDIO_SD_Init();
|
MX_SDIO_SD_Init();
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
|
// Initialize CAN1 and CAN2
|
||||||
|
CAN_Logger_Init(&hcan1, &hcan2);
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
/* Init scheduler */
|
/* Init scheduler */
|
||||||
@@ -140,13 +129,6 @@ int main(void)
|
|||||||
/* add queues, ... */
|
/* add queues, ... */
|
||||||
/* USER CODE END RTOS_QUEUES */
|
/* USER CODE END RTOS_QUEUES */
|
||||||
|
|
||||||
/* Create the thread(s) */
|
|
||||||
/* creation of canBus1Listen */
|
|
||||||
canBus1ListenHandle = osThreadNew(can_listen, (void*) &hcan1, &canBus1Listen_attributes);
|
|
||||||
|
|
||||||
/* creation of canBus2Listen */
|
|
||||||
canBus2ListenHandle = osThreadNew(can_listen, (void*) &hcan2, &canBus2Listen_attributes);
|
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_THREADS */
|
/* USER CODE BEGIN RTOS_THREADS */
|
||||||
/* add threads, ... */
|
/* add threads, ... */
|
||||||
/* USER CODE END RTOS_THREADS */
|
/* USER CODE END RTOS_THREADS */
|
||||||
@@ -422,23 +404,7 @@ static void MX_GPIO_Init(void)
|
|||||||
|
|
||||||
/* USER CODE END 4 */
|
/* USER CODE END 4 */
|
||||||
|
|
||||||
/* USER CODE BEGIN Header_can_listen */
|
|
||||||
/**
|
|
||||||
* @brief Function implementing the canBus0Listen thread.
|
|
||||||
* @param argument: Not used
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
/* USER CODE END Header_can_listen */
|
|
||||||
void can_listen(void *argument)
|
|
||||||
{
|
|
||||||
/* USER CODE BEGIN 5 */
|
|
||||||
/* Infinite loop */
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
osDelay(1);
|
|
||||||
}
|
|
||||||
/* USER CODE END 5 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Period elapsed callback in non blocking mode
|
* @brief Period elapsed callback in non blocking mode
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ Dma.SDIO_TX.1.Priority=DMA_PRIORITY_LOW
|
|||||||
Dma.SDIO_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst
|
Dma.SDIO_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst
|
||||||
FREERTOS.FootprintOK=true
|
FREERTOS.FootprintOK=true
|
||||||
FREERTOS.IPParameters=Tasks01,configUSE_NEWLIB_REENTRANT,FootprintOK
|
FREERTOS.IPParameters=Tasks01,configUSE_NEWLIB_REENTRANT,FootprintOK
|
||||||
FREERTOS.Tasks01=canBus1Listen,49,128,can_listen,Default,&hcan1,Dynamic,NULL,NULL;canBus2Listen,48,128,can_listen,Default,&hcan2,Dynamic,NULL,NULL
|
FREERTOS.Tasks01=DefaultTask,49,128,can_listen,Default,NULL,Dynamic,NULL,NULL
|
||||||
FREERTOS.configUSE_NEWLIB_REENTRANT=1
|
FREERTOS.configUSE_NEWLIB_REENTRANT=1
|
||||||
File.Version=6
|
File.Version=6
|
||||||
GPIO.groupedBy=
|
GPIO.groupedBy=
|
||||||
|
|||||||
Reference in New Issue
Block a user