1. HAL_RCC_GPIO
GPIO引脚常用函数
"GPIOx: GPIO引脚的端口,“如GPIOA” "
"GPIO_Pin: GPIO引脚的编号,如“GPIO_PIN_9” "
"PinState: 只能为“GPIO_PIN_SET”(高电平)或“GPIO_PIN_RESET(低电平)” "
能读就行
"GPIO初始化"
HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
"GPIO取消初始化"
HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin)
"GPIO电平状态锁定"
HAL_GPIO_LockPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
"GPIO外部中断服务函数"
HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin)
"GPIO中断回调函数,用于写逻辑"
HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
必须会写
"GPIO引脚电平读取"
HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
"如 HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_9),返回“0”或“1”。"
"GPIO写状态"
HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
"如 HAL_GPIO_WritePin(GPIOF, GPIO_PIN_9,GPIO_PIN_RESET) "
"GPIO电平反转"
HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
2. HAL_TIM_
"htim:TIM_HandleTypeDef,如“htim2” "
"pdata:原缓冲区地址"
"Length:从内存传输到外设的数据长度"
能读就行
"初始化定时器"
HAL_TIM_Base_Init(TIM_HandleTypeDef *htim);
"取消初始化定时器"
HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim);
"中断模式下启动定时器"
HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim);
"中断模式下停止定时器"
HAL_TIM_Base_Stop_IT(TIM_HandleTypeDef *htim);
"DMA模式下启动定时器"
HAL_TIM_Base_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
"DMA模式下停止定时器"
HAL_TIM_Base_Stop_DMA(TIM_HandleTypeDef *htim);
必须会写
"启动定时器"
HAL_TIM_Base_Start(TIM_HandleTypeDef *htim);
"停止定时器"
HAL_TIM_Base_Stop(TIM_HandleTypeDef *htim);
2.1 TIM_PWM
PWM常与TIM连用
"htim:TIM_HandleTypeDef,如“htim2” "
"__HANDLE__: TIM_HandleTypeDef,如“htim2” "
"Channel: TIM通道,如 “TIM_CHANNEL_1” "
"__CHANNEL__: TIM通道,如 “TIM_CHANNEL_1” "
"pData : 缓冲区"
"Length :数据长度"
"__AUTORELOAD__: 重装值(计数值)"
"__COMPARE__: 比较值(占空比)"
能读就行
"配置通道"
HAL_TIM_PWM_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OC_InitTypeDef* sConfig, uint32_t Channel)
"PWM初始化"
HAL_TIM_PWM_Init(TIM_HandleTypeDef *htim);
"取消初始化"
HAL_TIM_PWM_DeInit(TIM_HandleTypeDef *htim);
"中断模式下PWM信号"
"开启"
HAL_TIM_PWM_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
"关闭"
HAL_TIM_PWM_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
"DMA模式下PWM信号"
"开启"
HAL_TIM_PWM_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
"关闭"
HAL_TIM_PWM_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
必须会写
"启动PWM信号"
HAL_TIM_PWM_Start(TIM_HandleTypeDef *htim, uint32_t Channel) ;
"关闭pwm,参数与开启时一样"
HAL_TIM_PWM_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
"动态修改,每类都有两种写法,两种写法无区别"
"重装ARR寄存器,修改重装值(计数值)"
__HAL_TIM_SET_AUTORELOAD(__HANDLE__, __AUTORELOAD__);
__HAL_TIM_SetAutoreload(__HANDLE__, __CHANNEL__, __AUTORELOAD__);
"重装CCR寄存器,修改比较值(占空比)"
__HAL_TIM_SET_COMPARE(__HANDLE__, __CHANNEL__, __COMPARE__);
__HAL_TIM_SetCompare(__HANDLE__, __CHANNEL__, __COMPARE__);
3. HAL_USART
"huart:句柄"
"pData:要发送或保存的指针或数组"
"Size: 要发送或保存的数据量"
"Timeout:超时时间"
能读就行
"串口初始化(还有好几个初始化模式,一般用不到)"
HAL_UART_Init(UART_HandleTypeDef *huart)
"取消串口初始化"
HAL_UART_DeInit(UART_HandleTypeDef*huart);
"中断模式发送"
HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
"中断模式接收"
HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
"DMA模式发送"
HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
"DMA模式接收"
HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
"暂停DMA发送"
HAL_UART_DMAPause(UART_HandleTypeDef *huart);
"恢复DMA发送"
HAL_UART_DMAResume(UART_HandleTypeDef *huart);
"停止DMA发送"
HAL_UART_DMAStop(UART_HandleTypeDef *huart);
"几个不常用的终止正在进行的传输"
"阻塞模式"
HAL_UART_Abort(UART_HandleTypeDef *huart);
HAL_UART_AbortTransmit(UART_HandleTypeDef *huart);
HAL_UART_AbortReceive(UART_HandleTypeDef *huart);
"中断模式"
HAL_UART_Abort_IT(UART_HandleTypeDef *huart);
HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart);
HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart);
"处理中断请求"
HAL_UART_IRQHandler(UART_HandleTypeDef *huart);
"发送回调函数"
HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);
"接收回调函数"
HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);
必须会写
"串口发送"
HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
"串口接收"
HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
"串口返回状态"
HAL_UART_GetState(UART_HandleTypeDef *huart);
4.HAL基本函数
"Delay: 毫秒"
"延迟函数"
HAL_Delay(uint32_t Delay)