/**
******************************************************************************
* @file stm32f1xx_hal_i2c.c
* @author MCD Application Team
* @brief I2C HAL module driver.
* This file provides firmware functions to manage the following
* functionalities of the Inter Integrated Circuit (I2C) peripheral:
* + Initialization and de-initialization functions
* + IO operation functions
* + Peripheral State, Mode and Error functions
*
@verbatim
==============================================================================
##### How to use this driver #####
==============================================================================
[..]
The I2C HAL driver can be used as follows:
(#) Declare a I2C_HandleTypeDef handle structure, for example:
I2C_HandleTypeDef hi2c;
(#)Initialize the I2C low level resources by implementing the HAL_I2C_MspInit() API:
(##) Enable the I2Cx interface clock
(##) I2C pins configuration
(+++) Enable the clock for the I2C GPIOs
(+++) Configure I2C pins as alternate function open-drain
(##) NVIC configuration if you need to use interrupt process
(+++) Configure the I2Cx interrupt priority
(+++) Enable the NVIC I2C IRQ Channel
(##) DMA Configuration if you need to use DMA process
(+++) Declare a DMA_HandleTypeDef handle structure for the transmit or receive channel
(+++) Enable the DMAx interface clock using
(+++) Configure the DMA handle parameters
(+++) Configure the DMA Tx or Rx channel
(+++) Associate the initialized DMA handle to the hi2c DMA Tx or Rx handle
(+++) Configure the priority and enable the NVIC for the transfer complete interrupt on
the DMA Tx or Rx channel
(#) Configure the Communication Speed, Duty cycle, Addressing mode, Own Address1,
Dual Addressing mode, Own Address2, General call and Nostretch mode in the hi2c Init structure.
(#) Initialize the I2C registers by calling the HAL_I2C_Init(), configures also the low level Hardware
(GPIO, CLOCK, NVIC...etc) by calling the customized HAL_I2C_MspInit(&hi2c) API.
(#) To check if target device is ready for communication, use the function HAL_I2C_IsDeviceReady()
(#) For I2C IO and IO MEM operations, three operation modes are available within this driver :
*** Polling mode IO operation ***
=================================
[..]
(+) Transmit in master mode an amount of data in blocking mode using HAL_I2C_Master_Transmit()
(+) Receive in master mode an amount of data in blocking mode using HAL_I2C_Master_Receive()
(+) Transmit in slave mode an amount of data in blocking mode using HAL_I2C_Slave_Transmit()
(+) Receive in slave mode an amount of data in blocking mode using HAL_I2C_Slave_Receive()
*** Polling mode IO MEM operation ***
=====================================
[..]
(+) Write an amount of data in blocking mode to a specific memory address using HAL_I2C_Mem_Write()
(+) Read an amount of data in blocking mode from a specific memory address using HAL_I2C_Mem_Read()
*** Interrupt mode IO operation ***
===================================
[..]
(+) Transmit in master mode an amount of data in non blocking mode using HAL_I2C_Master_Transmit_IT()
(+) At transmission end of transfer HAL_I2C_MasterTxCpltCallback is executed and user can
add his own code by customization of function pointer HAL_I2C_MasterTxCpltCallback
(+) Receive in master mode an amount of data in non blocking mode using HAL_I2C_Master_Receive_IT()
(+) At reception end of transfer HAL_I2C_MasterRxCpltCallback is executed and user can
add his own code by customization of function pointer HAL_I2C_MasterRxCpltCallback
(+) Transmit in slave mode an amount of data in non blocking mode using HAL_I2C_Slave_Transmit_IT()
(+) At transmission end of transfer HAL_I2C_SlaveTxCpltCallback is executed and user can
add his own code by customization of function pointer HAL_I2C_SlaveTxCpltCallback
(+) Receive in slave mode an amount of data in non blocking mode using HAL_I2C_Slave_Receive_IT()
(+) At reception end of transfer HAL_I2C_SlaveRxCpltCallback is executed and user can
add his own code by customization of function pointer HAL_I2C_SlaveRxCpltCallback
(+) In case of transfer Error, HAL_I2C_ErrorCallback() function is executed and user can
add his own code by customization of function pointer HAL_I2C_ErrorCallback
(+) Abort a master I2C process communication with Interrupt using HAL_I2C_Master_Abort_IT()
(+) End of abort process, HAL_I2C_AbortCpltCallback() is executed and user can
add his own code by customization of function pointer HAL_I2C_AbortCpltCallback()
*** Interrupt mode IO sequential operation ***
==============================================
[..]
(@) These interfaces allow to manage a sequential transfer with a repeated start condition
when a direction change during transfer
[..]
(+) A specific option field manage the different steps of a sequential transfer
(+) Option field values are defined through @ref I2C_XFEROPTIONS and are listed below:
(++) I2C_FIRST_AND_LAST_FRAME: No sequential usage, functionnal is same as associated interfaces in no sequential mode
(++) I2C_FIRST_FRAME: Sequential usage, this option allow to manage a sequence with start condition, address
and data to transfer without a final stop condition
(++) I2C_NEXT_FRAME: Sequential usage, this option allow to manage a sequence with a restart condition, address
and with new data to transfer if the direction change or manage only the new data to transfer
if no direction change and without a final stop condition in both cases
(++) I2C_LAST_FRAME: Sequential usage, this option allow to manage a sequance with a restart condition, address
and with new data to transfer if the direction change or manage only the new data to transfer
if no direction change and with a final stop condition in both cases
(+) Differents sequential I2C interfaces are listed below:
(++) Sequential transmit in master I2C mode an amount of data in non-blocking mode using HAL_I2C_Master_Sequential_Transmit_IT()
(+++) At transmission end of current frame transfer, HAL_I2C_MasterTxCpltCallback() is executed and user can
add his own code by customization of function pointer HAL_I2C_MasterTxCpltCallback()
(++) Sequential receive in master I2C mode an amount of data in non-blocking mode using HAL_I2C_Master_Sequential_Receive_IT()
(+++) At reception end of current frame transfer, HAL_I2C_MasterRxCpltCallback() is executed and user can
add his own code by customization of function pointer HAL_I2C_MasterRxCpltCallback()
(++) Abort a master I2C process communication with Interrupt using HAL_I2C_Master_Abort_IT()
(+++) End of abort process, HAL_I2C_AbortCpltCallback() is executed and user can
add his own code by customization of function pointer HAL_I2C_AbortCpltCallback()
(++) Enable/disable the Address listen mode in slave I2C mode using HAL_I2C_EnableListen_IT() HAL_I2C_DisableListen_IT()
(+++) When address slave I2C match, HAL_I2C_AddrCallback() is executed and user can
add his own code to check the Address Match Code and the transmission direction request by master (Write/Read).
(+++) At Listen mode end HAL_I2C_ListenCp

攻无不克-穿山甲
- 粉丝: 30
- 资源: 36
最新资源
- Python 实现TCN-GRU时间卷积门控循环单元多输入单输出回归预测(含模型描述及示例代码)
- 创新流固耦合模拟煤层塌陷模型:基于fipy与pfc2d联合方法的多功能代码干货分享,创新流固耦合模拟煤层塌陷模型:基于fipy与pfc2d联合方法的多功能代码干货分享,该模型是模拟的煤层塌陷的pfc2
- Python 实现GA-RF遗传算法优化随机森林算法多输入单输出回归预测的详细项目实例(含完整的程序,GUI设计和代码详解)
- 电机模型、PI控制器与PLL锁相环的标幺化处理详解:从理论到实践,采样时间处理全解析,电机模型、PI控制器与PLL锁相环的标幺化处理详解:从理论到实践,采样时间处理全解析,电机标幺化、PI标幺化、锁相
- 基于西门子S7-1200PLC的现代化创新立体车库:传统与未来科技结合的简约程序与仿真图纸及新能源汽车充电解决方案,基于西门子S7-1200PLC的立体车库创新设计:融合新能源汽车充电功能,简约而不简
- Python 实现WOA-BP鲸鱼优化算法优化BP神经网络多输入单输出回归预测的详细项目实例(含完整的程序,GUI设计和代码详解)
- Python 实现SA-BP模拟退火算法优化BP神经网络多输入单输出回归预测的详细项目实例(含完整的程序,GUI设计和代码详解)
- HCIP-Datacom题库.zip
- Python 实现GA-ELM遗传算法优化极限学习机多输入单输出回归预测的详细项目实例(含完整的程序,GUI设计和代码详解)
- MinGW-w64安装指南.pdf
- Python 实现SA-ELM模拟退火算法优化极限学习机多输入单输出回归预测的详细项目实例(含完整的程序,GUI设计和代码详解)
- numpy-2.2.0-cp311-cp311-win_amd64.whl
- Python 实现DRN深度残差网络多输入分类预测的详细项目实例(含完整的程序,GUI设计和代码详解)
- PFC 5.0 流体与固体相互作用-流固耦合模型实战指南(实用干货版),PFC5.0流固耦合模型应用手册:干货满载的水力压裂与达西渗流常用案例集锦,该模型是“PFC2D流固耦合常用案例合集”: 其中
- Python 实现TSO-SVM金枪鱼群算法优化支持向量机多输入单输出回归预测的详细项目实例(含完整的程序,GUI设计和代码详解)
- Yoast SEO Premium v24.6 – WordPress SEO 插件 全功能版-20250306-134428.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


