vn200 stm project
This commit is contained in:
20
vn200/Converter/Src/canhalal.cpp
Normal file
20
vn200/Converter/Src/canhalal.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include "canhalal.h"
|
||||
|
||||
HAL_StatusTypeDef ftcan_init(CAN_HandleTypeDef *handle) {
|
||||
HAL_StatusTypeDef status = HAL_CAN_ActivateNotification(handle, CAN_IT_RX_FIFO0_MSG_PENDING);
|
||||
if (status != HAL_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return HAL_CAN_Start(handle);
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef ftcan_transmit(CAN_HandleTypeDef *handle, uint16_t id, const uint8_t *data, size_t datalen) {
|
||||
static CAN_TxHeaderTypeDef header;
|
||||
header.StdId = id;
|
||||
header.IDE = CAN_ID_STD;
|
||||
header.RTR = CAN_RTR_DATA;
|
||||
header.DLC = datalen;
|
||||
uint32_t mailbox;
|
||||
return HAL_CAN_AddTxMessage(handle, &header, data, &mailbox);
|
||||
}
|
||||
Reference in New Issue
Block a user