/**
******************************************************************************
* @file stm32f4xx_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 @ref 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 stream
(+++) Enable the DMAx interface clock using
(+++) Configure the DMA handle parameters
(+++) Configure the DMA Tx or Rx stream
(+++) 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 stream
(#) 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 @ref HAL_I2C_Init(), configures also the low level Hardware
(GPIO, CLOCK, NVIC...etc) by calling the customized @ref HAL_I2C_MspInit() API.
(#) To check if target device is ready for communication, use the function @ref 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 @ref HAL_I2C_Master_Transmit()
(+) Receive in master mode an amount of data in blocking mode using @ref HAL_I2C_Master_Receive()
(+) Transmit in slave mode an amount of data in blocking mode using @ref HAL_I2C_Slave_Transmit()
(+) Receive in slave mode an amount of data in blocking mode using @ref HAL_I2C_Slave_Receive()
*** Polling mode IO MEM operation ***
=====================================
[..]
(+) Write an amount of data in blocking mode to a specific memory address using @ref HAL_I2C_Mem_Write()
(+) Read an amount of data in blocking mode from a specific memory address using @ref HAL_I2C_Mem_Read()
*** Interrupt mode IO operation ***
===================================
[..]
(+) Transmit in master mode an amount of data in non-blocking mode using @ref HAL_I2C_Master_Transmit_IT()
(+) At transmission end of transfer, @ref HAL_I2C_MasterTxCpltCallback() is executed and user can
add his own code by customization of function pointer @ref HAL_I2C_MasterTxCpltCallback()
(+) Receive in master mode an amount of data in non-blocking mode using @ref HAL_I2C_Master_Receive_IT()
(+) At reception end of transfer, @ref HAL_I2C_MasterRxCpltCallback() is executed and user can
add his own code by customization of function pointer @ref HAL_I2C_MasterRxCpltCallback()
(+) Transmit in slave mode an amount of data in non-blocking mode using @ref HAL_I2C_Slave_Transmit_IT()
(+) At transmission end of transfer, @ref HAL_I2C_SlaveTxCpltCallback() is executed and user can
add his own code by customization of function pointer @ref HAL_I2C_SlaveTxCpltCallback()
(+) Receive in slave mode an amount of data in non-blocking mode using @ref HAL_I2C_Slave_Receive_IT()
(+) At reception end of transfer, @ref HAL_I2C_SlaveRxCpltCallback() is executed and user can
add his own code by customization of function pointer @ref HAL_I2C_SlaveRxCpltCallback()
(+) In case of transfer Error, @ref HAL_I2C_ErrorCallback() function is executed and user can
add his own code by customization of function pointer @ref HAL_I2C_ErrorCallback()
(+) Abort a master I2C process communication with Interrupt using @ref HAL_I2C_Master_Abort_IT()
(+) End of abort process, @ref HAL_I2C_AbortCpltCallback() is executed and user can
add his own code by customization of function pointer @ref HAL_I2C_AbortCpltCallback()
*** Interrupt mode or DMA 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_definition 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_FIRST_AND_NEXT_FRAME: Sequential usage (Master only), this option allow to manage a sequence with start condition, address
and data to transfer without a final stop condition, an then permit a call the same master sequential interface
several times (like @ref HAL_I2C_Master_Seq_Transmit_IT() then @ref HAL_I2C_Master_Seq_Transmit_IT()
or @ref HAL_I2C_Master_Seq_Transmit_DMA() then @ref HAL_I2C_Master_Seq_Transmit_DMA())
(++) 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
(++) I2C_LAST_FRAME_NO_STOP: Sequential usage (Master only), this option allow to manage a restart condition after several call of the same master sequential
interface several times (link with option I2C_FIRST_AND_NEXT_FRAME).
Usage can, transfer several bytes one by one using HAL_I2C_Master_Seq_Transmit_IT(option I2C_FIRST_AND_NEXT_FRAME then I2C_NEXT_FRAME)
or HAL_I2C_Master_Seq_Receive_IT(option I2C_FIRST_AND_NEXT_FRAME then I2C_NEXT_FRAME)
or HAL_I2C_Master_Seq_Transmit_DMA(option I2C_FIRST_AND_NEXT_FRAME then I2C_NEXT_FRAME)
or HAL_I2C_Master_Seq_Receive_DMA(option I2C_FIRST_AND_NEXT_FRAME then I2C_NEXT_FRAME).
Then usage of this option I
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【资源说明】 基于stm32非接触式物体尺寸形态测量仪代码+项目说明.zip 基于stm32非接触式物体尺寸形态测量仪代码(本科电赛) 12V直流稳压电源通过5V和3.3.V稳压模块分别向单片机和OpenMV供电;目标物体的水平距离通过激光测距模块读取,并转化为距离数字量传回单片机中;目标物体的几何形状以及坐标通过OpenMV的颜色识别读取,并转化为位置数字量传回单片机中;单片机将激光测距模块读取的距离数据处理后传给OpenMV,OpenMV经比例计算后返回物体边长的数字量;最后单片机将目标物体的形状、边长和距离数据传给OLED显示;进入自动寻找目标时,单片机根据OpenMV传回的坐标数据控制云台舵机转动角度;当测量结果稳定后启动声光提示,表示当前测量任务完成;单片机的电平信号可控制由发光二极管和有源蜂鸣器组成的声光提示部分。 【备注】 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载使用,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可直接用于毕设、课设、作业等。 欢迎下载,沟通交流,互相学习,共同进步!
资源推荐
资源详情
资源评论
收起资源包目录
基于stm32非接触式物体尺寸形态测量仪代码+项目说明.zip (185个子文件)
opmv_f4.uvguix.apple 70KB
opmv_f4.axf 601KB
opmv_f4_sct.Bak 464B
stm32f4xx_hal_i2c.c 230KB
stm32f4xx_hal_tim.c 207KB
stm32f4xx_hal_rcc_ex.c 150KB
stm32f4xx_hal_uart.c 108KB
stm32f4xx_hal_tim_ex.c 64KB
stm32f4xx_hal_flash_ex.c 49KB
stm32f4xx_hal_rcc.c 41KB
stm32f4xx_hal_dma.c 39KB
system_stm32f4xx.c 26KB
stm32f4xx_hal_flash.c 24KB
stm32f4xx_hal_pwr_ex.c 22KB
stm32f4xx_hal_pwr.c 19KB
stm32f4xx_hal.c 19KB
stm32f4xx_hal_gpio.c 19KB
stm32f4xx_hal_cortex.c 18KB
main.c 17KB
stm32f4xx_hal_exti.c 15KB
stm32f4xx_hal_dma_ex.c 10KB
tim.c 7KB
usart.c 7KB
stm32f4xx_it.c 6KB
stm32f4xx_hal_flash_ramfunc.c 6KB
oled.c 6KB
stm32f4xx_hal_i2c_ex.c 5KB
gpio.c 3KB
i2c.c 3KB
stm32f4xx_hal_msp.c 2KB
stm32f4xx_hal_i2c.crf 607KB
stm32f4xx_hal_tim.crf 588KB
stm32f4xx_hal_uart.crf 562KB
stm32f4xx_hal_tim_ex.crf 559KB
main.crf 557KB
stm32f4xx_hal_rcc.crf 555KB
stm32f4xx_hal_dma_ex.crf 555KB
stm32f4xx_hal_dma.crf 552KB
stm32f4xx_hal_flash_ex.crf 549KB
stm32f4xx_hal_rcc_ex.crf 549KB
stm32f4xx_hal_flash.crf 549KB
oled.crf 548KB
stm32f4xx_hal_gpio.crf 547KB
stm32f4xx_hal_exti.crf 547KB
tim.crf 547KB
usart.crf 547KB
stm32f4xx_hal_pwr.crf 546KB
stm32f4xx_hal.crf 546KB
stm32f4xx_hal_pwr_ex.crf 546KB
stm32f4xx_hal_cortex.crf 545KB
gpio.crf 545KB
i2c.crf 545KB
stm32f4xx_it.crf 545KB
stm32f4xx_hal_msp.crf 544KB
system_stm32f4xx.crf 544KB
stm32f4xx_hal_i2c_ex.crf 544KB
stm32f4xx_hal_flash_ramfunc.crf 544KB
stm32f4xx_hal_flash_ramfunc.d 3KB
stm32f4xx_hal_flash_ex.d 3KB
stm32f4xx_hal_i2c_ex.d 3KB
stm32f4xx_hal_cortex.d 3KB
stm32f4xx_hal_rcc_ex.d 3KB
stm32f4xx_hal_pwr_ex.d 3KB
stm32f4xx_hal_tim_ex.d 3KB
stm32f4xx_hal_dma_ex.d 3KB
stm32f4xx_hal_flash.d 3KB
stm32f4xx_hal_uart.d 3KB
stm32f4xx_hal_gpio.d 3KB
stm32f4xx_hal_exti.d 3KB
stm32f4xx_hal_msp.d 3KB
stm32f4xx_hal_tim.d 3KB
stm32f4xx_hal_pwr.d 3KB
stm32f4xx_hal_dma.d 3KB
stm32f4xx_hal_rcc.d 3KB
stm32f4xx_hal_i2c.d 3KB
system_stm32f4xx.d 3KB
stm32f4xx_it.d 3KB
stm32f4xx_hal.d 3KB
main.d 2KB
oled.d 2KB
usart.d 2KB
gpio.d 2KB
i2c.d 2KB
tim.d 2KB
startup_stm32f401xc.d 53B
opmv_f4_STM32F401CCUx.dbgconf 2KB
opmv_f4_opmv_f4.dep 79KB
stm32f401xc.h 697KB
stm32f4xx_hal_rcc_ex.h 425KB
stm32_hal_legacy.h 204KB
core_cm33.h 169KB
core_armv8mml.h 162KB
core_cm7.h 142KB
core_cm4.h 119KB
stm32f4xx_hal_tim.h 111KB
core_cm3.h 107KB
core_sc300.h 106KB
core_cm23.h 100KB
core_armv8mbl.h 94KB
stm32f4xx_hal_gpio_ex.h 79KB
共 185 条
- 1
- 2
资源评论
- 2301_763260322024-01-26资源不错,很实用,内容全面,介绍详细,很好用,谢谢分享。
Make程序设计
- 粉丝: 5732
- 资源: 3570
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- ### 1、项目介绍 本项目Scrapy进行数据爬取,并使用Django框架+PyEcharts实现可视化大屏 效果如下:
- # 微信小程序-健康菜谱 基于微信小程序的一个查找检索菜谱的应用 ### 效果 !动态图(./res/gif/demo
- zabbix-get命令包资源
- 毕业设计,基于PyQt5实现的可视化界面的Python车牌自动识别系统源码
- 26-朴素贝叶斯分类.rar
- 没有安Matlab 也可以 生成FIR抽头系数工具.py
- python烟花代码.rar
- 实验目的: 1.构建基于verilog语言的组合逻辑电路和时序逻辑电路; 2.掌握verilog语言的电路设计技巧 3.完成如
- 扩展卡尔曼滤波matlab仿真
- 3_base.apk.1
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功