osThreadId_t canOpenNodeTaskHandle;
const osThreadAttr_t canOpenNodeTask_attributes = {
.name = "task CAN",
.stack_size = 192,
.priority = (osPriority_t) osPriorityHigh,
};
static void MX_CAN1_Init(void);
void startCanOpenNodeTask(void *argument);
canOpenNodeTaskHandle = osThreadNew(startCanOpenNodeTask, NULL, &canOpenNodeTask_attributes);
static void MX_CAN1_Init(void)
{
hcan1.Instance = CAN1;
hcan1.Init.Prescaler = 40;
hcan1.Init.Mode = CAN_MODE_NORMAL;
hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ;
hcan1.Init.TimeSeg1 = CAN_BS1_12TQ;
hcan1.Init.TimeSeg2 = CAN_BS2_4TQ;
hcan1.Init.TimeTriggeredMode = DISABLE;
hcan1.Init.AutoBusOff = DISABLE;
hcan1.Init.AutoWakeUp = DISABLE;
hcan1.Init.AutoRetransmission = DISABLE;
hcan1.Init.ReceiveFifoLocked = DISABLE;
hcan1.Init.TransmitFifoPriority = DISABLE;
if (HAL_CAN_Init(&hcan1) != HAL_OK)
{
Error_Handler();
}
}
__attribute__((noreturn)) void startCanOpenNodeTask(void *argument)
{
CANopenNodeSTM32 canOpenNodeSTM32;
//canOpenNodeSTM32.CANHandle = &hfdcan1;
canOpenNodeSTM32.CANHandle = &hcan1;
// canOpenNodeSTM32.HWInitFunction = MX_FDCAN1_Init;
canOpenNodeSTM32.HWInitFunction = MX_CAN1_Init;
// canOpenNodeSTM32.timerHandle = &htim17;
canOpenNodeSTM32.desiredNodeID = 21;
// canOpenNodeSTM32.baudrate = 125;
canopen_app_init(&canOpenNodeSTM32); // Hard fault
// never makes it to here because the line above Hard faults
for(;;)
{
// it makes no difference what is in here yet, because a Hard fault occurs when executing the above line
}
}