Compare commits
10 Commits
41084eb4d2
...
30b7538e26
| Author | SHA1 | Date | |
|---|---|---|---|
| 30b7538e26 | |||
| c891681b94 | |||
| 770e97ccd9 | |||
| 5d3c8c0ec0 | |||
| 495c9cb377 | |||
| c274be6907 | |||
| b92b26b026 | |||
| bbdb278338 | |||
| a236377784 | |||
| 9f3d681134 |
+1
-1
@@ -20,7 +20,7 @@ extern const osThreadAttr_t vLED_CAN2_Heartbeat_attributes;
|
|||||||
* @param hcan2 Pointer to the CAN2 handle
|
* @param hcan2 Pointer to the CAN2 handle
|
||||||
*/
|
*/
|
||||||
void CAN_Logger_Init(CAN_HandleTypeDef *hcan1, CAN_HandleTypeDef *hcan2);
|
void CAN_Logger_Init(CAN_HandleTypeDef *hcan1, CAN_HandleTypeDef *hcan2);
|
||||||
void vCAN_log(void *argument);
|
void vCAN_Get(void *argument);
|
||||||
void vLED_HeartbeatOnCanRx(void *argument);
|
void vLED_HeartbeatOnCanRx(void *argument);
|
||||||
|
|
||||||
#endif /* CANLOG_H */
|
#endif /* CANLOG_H */
|
||||||
|
|||||||
+21
-11
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
#include "canlog.h"
|
#include "canlog.h"
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -5,8 +6,7 @@
|
|||||||
extern CAN_HandleTypeDef hcan1;
|
extern CAN_HandleTypeDef hcan1;
|
||||||
extern CAN_HandleTypeDef hcan2;
|
extern CAN_HandleTypeDef hcan2;
|
||||||
|
|
||||||
/* FreeRTOS task definitions */
|
/* USER CODE BEGIN RTOS_TASKS */
|
||||||
|
|
||||||
/* Definitions for CAN1rx incoming */
|
/* Definitions for CAN1rx incoming */
|
||||||
osThreadId_t vCAN1_rx;
|
osThreadId_t vCAN1_rx;
|
||||||
const osThreadAttr_t vCAN1_rx_attributes = {
|
const osThreadAttr_t vCAN1_rx_attributes = {
|
||||||
@@ -38,18 +38,20 @@ const osThreadAttr_t vLED_CAN2_Heartbeat_attributes = {
|
|||||||
.stack_size = 128 * 4,
|
.stack_size = 128 * 4,
|
||||||
.priority = (osPriority_t) osPriorityLow,
|
.priority = (osPriority_t) osPriorityLow,
|
||||||
};
|
};
|
||||||
|
/* USER END RTOS_TASKS */
|
||||||
|
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
void CAN_Logger_Init(CAN_HandleTypeDef *hcan1, CAN_HandleTypeDef *hcan2){}
|
void CAN_Logger_Init(CAN_HandleTypeDef *hcan1, CAN_HandleTypeDef *hcan2){}
|
||||||
static void CAN_Listen(void *argument){}
|
static void CAN_Listen(void *argument){}
|
||||||
|
|
||||||
/* BEGIN vCAN_log */
|
/* BEGIN vCAN_Get */
|
||||||
/**
|
/**
|
||||||
* @brief Log incoming CAN bus traffic.
|
* @brief Log incoming CAN bus traffic in FIFO buffer
|
||||||
* @param argument: Not used
|
* @param argument: Not used
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void vCAN_log(void *argument)
|
void vCAN_Get(void *argument)
|
||||||
{
|
{
|
||||||
/* CODE BEGIN */
|
/* CODE BEGIN */
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
@@ -59,23 +61,31 @@ void vCAN_log(void *argument)
|
|||||||
}
|
}
|
||||||
/* CODE END */
|
/* CODE END */
|
||||||
}
|
}
|
||||||
/* END vCAN_log */
|
/* END vCAN_Get */
|
||||||
|
|
||||||
|
|
||||||
/* BEGIN vLED_HeartbeatOnCanRx */
|
/* BEGIN vLED_HeartbeatOnCanRx */
|
||||||
/**
|
/**
|
||||||
* @brief Blink a LED in heartbeat mode when there is CAN traffic detected.
|
* @brief Blink a LED in heartbeat mode when there is CAN traffic detected
|
||||||
* @param argument: Not used
|
* @param argument: LED GPIO (port and pin)
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void vLED_HeartbeatOnCanRx(void *argument)
|
void vLED_HeartbeatOnCanRx(void *argument)
|
||||||
{
|
{
|
||||||
/* CODE BEGIN */
|
/* CODE BEGIN */
|
||||||
/* Infinite loop */
|
LED_Config *led = (LED_Config*)argument;
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
osDelay(1);
|
//HAL_GPIO_WritePin(led->port, led->pin, GPIO_PIN_RESET);
|
||||||
|
// if semaphore for canrx, do the rest
|
||||||
|
|
||||||
|
|
||||||
|
HAL_GPIO_WritePin(led->port, led->pin, GPIO_PIN_SET);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(100));
|
||||||
|
HAL_GPIO_WritePin(led->port, led->pin, GPIO_PIN_RESET);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(100));
|
||||||
}
|
}
|
||||||
/* CODE END */
|
/* CODE END */
|
||||||
}
|
}
|
||||||
/* vLED_HeartbeatOnCanRx */
|
/* END vLED_HeartbeatOnCanRx */
|
||||||
|
|||||||
+8
-18
@@ -19,21 +19,18 @@
|
|||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
#include "canlog.h"
|
|
||||||
|
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
|
#include "canlog.h"
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN PTD */
|
/* USER CODE BEGIN PTD */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GPIO_TypeDef* port;
|
GPIO_TypeDef* port;
|
||||||
uint16_t pin;
|
uint16_t pin;
|
||||||
} LED_Config;
|
} LED_Config;
|
||||||
|
|
||||||
/* USER CODE END PTD */
|
/* USER CODE END PTD */
|
||||||
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
/* Private define ------------------------------------------------------------*/
|
||||||
@@ -55,10 +52,8 @@ DMA_HandleTypeDef hdma_sdio_rx;
|
|||||||
DMA_HandleTypeDef hdma_sdio_tx;
|
DMA_HandleTypeDef hdma_sdio_tx;
|
||||||
|
|
||||||
/* USER CODE BEGIN PV */
|
/* USER CODE BEGIN PV */
|
||||||
|
|
||||||
LED_Config led_can1 = {GPIOB, GPIO_PIN_2};
|
LED_Config led_can1 = {GPIOB, GPIO_PIN_2};
|
||||||
LED_Config led_can2 = {GPIOB, GPIO_PIN_5};
|
LED_Config led_can2 = {GPIOB, GPIO_PIN_5};
|
||||||
|
|
||||||
/* USER CODE END PV */
|
/* USER CODE END PV */
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
@@ -70,10 +65,8 @@ static void MX_CAN2_Init(void);
|
|||||||
static void MX_SDIO_SD_Init(void);
|
static void MX_SDIO_SD_Init(void);
|
||||||
|
|
||||||
/* USER CODE BEGIN PFP */
|
/* USER CODE BEGIN PFP */
|
||||||
|
void vCAN_Get(void *argument);
|
||||||
void vCAN_log(void *argument);
|
|
||||||
void vLED_HeartbeatOnCanRx(void *argument);
|
void vLED_HeartbeatOnCanRx(void *argument);
|
||||||
|
|
||||||
/* USER CODE END PFP */
|
/* USER CODE END PFP */
|
||||||
|
|
||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
@@ -114,11 +107,10 @@ int main(void)
|
|||||||
MX_CAN1_Init();
|
MX_CAN1_Init();
|
||||||
MX_CAN2_Init();
|
MX_CAN2_Init();
|
||||||
MX_SDIO_SD_Init();
|
MX_SDIO_SD_Init();
|
||||||
|
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
/* Initialize CAN1 and CAN2 */
|
||||||
// Initialize CAN1 and CAN2
|
|
||||||
CAN_Logger_Init(&hcan1, &hcan2);
|
CAN_Logger_Init(&hcan1, &hcan2);
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
/* Init scheduler */
|
/* Init scheduler */
|
||||||
@@ -141,12 +133,10 @@ int main(void)
|
|||||||
/* USER CODE END RTOS_QUEUES */
|
/* USER CODE END RTOS_QUEUES */
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_THREADS */
|
/* USER CODE BEGIN RTOS_THREADS */
|
||||||
|
vCAN1_rx = osThreadNew(vCAN_Get, &hcan1, &vCAN1_rx_attributes);
|
||||||
vCAN1_rx = osThreadNew(vCAN_log, (void*)&hcan1, &vCAN1_rx_attributes);
|
vCAN2_rx = osThreadNew(vCAN_Get, &hcan2, &vCAN2_rx_attributes);
|
||||||
vCAN2_rx = osThreadNew(vCAN_log, (void*)&hcan2, &vCAN2_rx_attributes);
|
|
||||||
vLED_CAN1_Heartbeat = osThreadNew(vLED_HeartbeatOnCanRx, &led_can1, &vLED_CAN1_Heartbeat_attributes);
|
vLED_CAN1_Heartbeat = osThreadNew(vLED_HeartbeatOnCanRx, &led_can1, &vLED_CAN1_Heartbeat_attributes);
|
||||||
vLED_CAN2_Heartbeat = osThreadNew(vLED_HeartbeatOnCanRx, &led_can2, &vLED_CAN2_Heartbeat_attributes);
|
vLED_CAN2_Heartbeat = osThreadNew(vLED_HeartbeatOnCanRx, &led_can2, &vLED_CAN2_Heartbeat_attributes);
|
||||||
|
|
||||||
/* USER CODE END RTOS_THREADS */
|
/* USER CODE END RTOS_THREADS */
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_EVENTS */
|
/* USER CODE BEGIN RTOS_EVENTS */
|
||||||
@@ -238,7 +228,7 @@ static void MX_CAN1_Init(void)
|
|||||||
hcan1.Init.TimeSeg2 = CAN_BS2_4TQ;
|
hcan1.Init.TimeSeg2 = CAN_BS2_4TQ;
|
||||||
hcan1.Init.TimeTriggeredMode = DISABLE;
|
hcan1.Init.TimeTriggeredMode = DISABLE;
|
||||||
hcan1.Init.AutoBusOff = DISABLE;
|
hcan1.Init.AutoBusOff = DISABLE;
|
||||||
hcan1.Init.AutoWakeUp = DISABLE;
|
hcan1.Init.AutoWakeUp = ENABLE;
|
||||||
hcan1.Init.AutoRetransmission = DISABLE;
|
hcan1.Init.AutoRetransmission = DISABLE;
|
||||||
hcan1.Init.ReceiveFifoLocked = DISABLE;
|
hcan1.Init.ReceiveFifoLocked = DISABLE;
|
||||||
hcan1.Init.TransmitFifoPriority = DISABLE;
|
hcan1.Init.TransmitFifoPriority = DISABLE;
|
||||||
@@ -275,7 +265,7 @@ static void MX_CAN2_Init(void)
|
|||||||
hcan2.Init.TimeSeg2 = CAN_BS2_4TQ;
|
hcan2.Init.TimeSeg2 = CAN_BS2_4TQ;
|
||||||
hcan2.Init.TimeTriggeredMode = DISABLE;
|
hcan2.Init.TimeTriggeredMode = DISABLE;
|
||||||
hcan2.Init.AutoBusOff = DISABLE;
|
hcan2.Init.AutoBusOff = DISABLE;
|
||||||
hcan2.Init.AutoWakeUp = DISABLE;
|
hcan2.Init.AutoWakeUp = ENABLE;
|
||||||
hcan2.Init.AutoRetransmission = DISABLE;
|
hcan2.Init.AutoRetransmission = DISABLE;
|
||||||
hcan2.Init.ReceiveFifoLocked = DISABLE;
|
hcan2.Init.ReceiveFifoLocked = DISABLE;
|
||||||
hcan2.Init.TransmitFifoPriority = DISABLE;
|
hcan2.Init.TransmitFifoPriority = DISABLE;
|
||||||
|
|||||||
Reference in New Issue
Block a user