/**
******************************************************************************
* @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
*
******************************************************************************
* @attention
*
* Copyright (c) 2016 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
@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() 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 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 I2C_XferOptions_definition and are listed below:
(++) I2C_FIRST_AND_LAST_FRAME: No sequential usage, functional 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 HAL_I2C_Master_Seq_Transmit_IT() then HAL_I2C_Master_Seq_Transmit_IT()
or HAL_I2C_Master_Seq_Transmit_DMA() then 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
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
嵌入式优质项目,资源经过严格测试可直接运行成功且功能正常的情况才上传,可轻松copy复刻,拿到资料包后可轻松复现出一样的项目。 本人单片机开发经验充足,深耕嵌入式领域,有任何使用问题欢迎随时与我联系,我会及时为你解惑,提供帮助。 【资源内容】:包含完整源码+工程文件+说明,项目具体内容可查看下方的资源详情。 【附带帮助】: 若还需要嵌入式物联网单片机相关领域开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步。 【本人专注嵌入式领域】: 有任何使用问题欢迎随时与我联系,我会及时解答,第一时间为你提供帮助,CSDN博客端可私信,为你解惑,欢迎交流。 【建议小白】: 在所有嵌入式开发中硬件部分若不会画PCB/电路,可选择根据引脚定义将其代替为面包板+杜邦线+外设模块的方式,只需轻松简单连线,下载源码烧录进去便可轻松复刻出一样的项目 【适合场景】: 相关项目设计中,皆可应用在项目开发、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面中 可借鉴此优质项目实现复刻,也可以基于此项目进行扩展来开发出更多功能
资源推荐
资源详情
资源评论
收起资源包目录
基于STM32实现一个IO口控制多个DS18B20(一条总线上多个DS18B20的地址搜索)-皆可应用在毕设/课设/竞赛/项目 (418个子文件)
STM32F103ZET6.uvguix.Administrator 91KB
STM32F103ZET6.uvguix.Administrator 91KB
STM32F103ZET6_HAL.uvguix.Administrator 90KB
STM32F103ZET6_HAL.axf 960KB
STM32F103ZET6.axf 292KB
STM32F103ZET6.axf 51KB
stm32f1xx_hal_i2c.c 239KB
stm32f1xx_hal_tim.c 238KB
stm32f1xx_hal_uart.c 132KB
stm32f1xx_hal_spi.c 125KB
stm32f10x_tim.c 104KB
stm32f1xx_hal_usart.c 98KB
stm32f1xx_hal_mmc.c 97KB
stm32f1xx_hal_sd.c 96KB
stm32f1xx_hal_irda.c 93KB
stm32f1xx_hal_adc.c 89KB
stm32f1xx_hal_smartcard.c 83KB
stm32f1xx_hal_can.c 78KB
stm32f1xx_hal_tim_ex.c 78KB
stm32f1xx_ll_usb.c 77KB
stm32f1xx_hal_eth.c 76KB
stm32f1xx_hal_nand.c 72KB
stm32f1xx_hal_pcd.c 71KB
stm32f1xx_hal_i2s.c 61KB
stm32f10x_flash.c 59KB
stm32f1xx_hal_rtc.c 57KB
stm32f1xx_hal_can.c 54KB
stm32f1xx_hal_adc_ex.c 50KB
stm32f1xx_hal_nor.c 50KB
stm32f1xx_ll_sdmmc.c 49KB
stm32f10x_rcc.c 49KB
stm32f1xx_hal_rcc.c 48KB
stm32f1xx_hal_dac.c 47KB
stm32f1xx_hal_hcd.c 47KB
stm32f10x_adc.c 45KB
stm32f1xx_ll_tim.c 44KB
stm32f10x_i2c.c 43KB
stm32f10x_can.c 43KB
stm32f1xx_ll_adc.c 40KB
stm32f1xx_ll_fsmc.c 38KB
stm32f10x_usart.c 36KB
stm32f1xx_hal_flash_ex.c 35KB
system_stm32f10x.c 35KB
stm32f10x_fsmc.c 34KB
stm32f1xx_hal_sram.c 33KB
stm32f1xx_ll_utils.c 30KB
stm32f1xx_hal_cec.c 29KB
stm32f1xx_hal_rcc_ex.c 29KB
stm32f1xx_hal_pccard.c 29KB
stm32f10x_spi.c 29KB
stm32f1xx_hal_flash.c 28KB
stm32f10x_dma.c 28KB
stm32f10x_sdio.c 27KB
stm32f1xx_hal_dma.c 27KB
stm32f10x_gpio.c 22KB
stm32f1xx_hal_gpio.c 20KB
stm32f1xx_hal_pwr.c 20KB
stm32f1xx_hal.c 20KB
stm32f1xx_ll_spi.c 19KB
stm32f1xx_hal_cortex.c 18KB
stm32f10x_dac.c 18KB
DS18B20.c 17KB
ds18b20.c 17KB
stm32f1xx_ll_usart.c 17KB
stm32f1xx_ll_rtc.c 17KB
DS18B20.c 17KB
stm32f1xx_hal_dac_ex.c 16KB
core_cm3.c 16KB
stm32f1xx_hal_rtc_ex.c 16KB
stm32f1xx_hal_wwdg.c 15KB
sys.c 15KB
stm32f1xx_hal_exti.c 15KB
system_stm32f1xx.c 14KB
system_stm32f1xx.c 14KB
stm32f1xx_ll_rcc.c 14KB
stm32f1xx_ll_dma.c 13KB
stm32f1xx_ll_dac.c 12KB
stm32f10x_cec.c 11KB
stm32f1xx_hal_timebase_rtc_alarm_template.c 10KB
stm32f1xx_hal_crc.c 9KB
stm32f1xx_hal_iwdg.c 9KB
stm32f10x_pwr.c 8KB
stm32f10x_rtc.c 8KB
stm32f10x_bkp.c 8KB
stm32f1xx_ll_gpio.c 8KB
stm32f1xx_hal_pcd_ex.c 7KB
usart.c 7KB
stm32f1xx_ll_i2c.c 7KB
stm32f1xx_ll_exti.c 7KB
misc.c 7KB
stm32f10x_exti.c 7KB
stm32f10x_wwdg.c 5KB
stm32f1xx_hal_timebase_tim_template.c 5KB
stm32f10x_dbgmcu.c 5KB
stm32f10x_iwdg.c 5KB
stm32f1xx_it.c 4KB
usart.c 4KB
stm32f1xx_hal_gpio_ex.c 4KB
usart.c 4KB
sys.c 3KB
共 418 条
- 1
- 2
- 3
- 4
- 5
资源评论
阿齐Archie
- 粉丝: 1w+
- 资源: 2301
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功