CAN相关HAL库驱动

1.

驱动函数                             关联寄存器                 功能描述

HAL_RCC_CANx_CLK_ENABLE(…)                                  使能CAN时针

HAL_CAN_Init(…)                     MCR / BTR                 初始化CAN

HAL_CAN_ConfigFilter(…)             过滤器寄存器            配置CAN接受过滤器

HAL_CAN_Start(…)                    MCR / MSR             启动CAN设备

HAL_CAN_ActivateNotification(…)         IER                   使能中断

HAL_CAN_ENABLE_IT(…)                IER                    使能CAN中断允许

HAL_CAN_AddTxMessage(…)            TSR                    发送消息

HAL_CAN_GetTxMailboxesFreeLevel(…)   TSR/TIXR/TDTXR/TDLXR/TDHXR   等待发送完成

HAL_CAN_GetRxFifoFillLevel(…)         RFOR/RF1R                   等待接受完成

HAL_CAN_GetRxMessage(…)             RFOR/RF1R/RDLXR/RDHXR     接收消息

2.CAN外设相关重要结构体

CAN_InitTypeDef:

uint32_t Prescaler     /*预分频*/

uint32_t Mode       /*工作模式*/

uint32_t SyncJumpWidth   /*再次同步跳跃宽度*/

uint32_t TimeSegl        /*时间段1(BS1)长度*/

uint32_t TimeSeg2       /*时间段1(BS1)长度*/

uint32_t TimeTriggeredMode    /*时间触发通信模式*/

uint32 t AutoBusOff          /*总线自动关闭*/

uint32 t AutoWakeUp         /*自动唤醒*/

uint32_t AutoRetransmission      /*自动重传*/

uint32_t ReceiveFifoLocked     /*接收FIFO锁定*/

uint32_t TransmitFifoPriority   /*传输FIFO优先级*/

CAN_FilterTypeDef:

uint32_t FilterldHigh     /*ID高字节*/

uint32 t FilterldLow      /*ID低字节*/

uint32_t FilterMaskldHigh    /*掩码高字节*/

uint32 t FilterMaskldLow       /*掩码低字节*/

uint32_t FilterFIFOAssignment   /*过滤器关联FIFO*/ 

uint32 t FilterBank        /*选择过滤器组*/

uint32_t FilterMode         /*过滤器模式*/

uint32 t FilterScale     /*过滤器位宽*/

uint32 t FilterActivation       /*过滤器使能*/

Uint32 t SlaveStartFilterBank    /*从CAN选择启动过过滤器,单CAN没有意义*/

CAN_(T/R)xHeaderTypeDef:

uint32_t Stdld  /*标准标识符*/

uint32_t Extld    /*扩展标识符*/

uint32_tIDE   /*帧格式(标准帧或扩展帧)*/

uint32_t RTR   /*帧类型(数据帧或远程帧)*/

uint32_t DLC   /*数据长度*/

uint32_t TransmitGlobalTime   /*发送时间标记(时间戳)*/

uint32 t Stdld

uint32 t Extld

uint32_tIDE

uint32_t RTR

uint32_t DLC

Uint32_tTimestamp     /*时间戳*/

uint32_tFilterMatchlndex   /*过滤器号*/

你可能感兴趣的:(CAN总线,can协议)