/**
******************************************************************************
* @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 @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 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 @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_
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
通用同步异步收发器(Universal Synchronous Asynchronous Receiver and Transmitter)是一个串行通信设备,可以灵活地与外部设备进行全双工数据交换。有别于USART还有一个UART(Universal Asynchronous Receiver and Transmitter),它是在USART基础上裁剪掉了同步通信功能,只有异步通信。简单区分同步和异步就是看通信时需不需要对外提供时钟输出,我们平时用的串口通信基本都是UART。 串行通信一般是以帧格式传输数据,即是一帧一帧的传输,每帧包含有起始信号、数据信息、停止信息,可能还有校验信息。USART就是对这些传输参数有具体规定,当然也不是只有唯一一个参数值,很多参数值都可以自定义设置,只是增强它的兼容性。 USART满足外部设备对工业标准NRZ异步串行数据格式的要求,并且使用了小数波特率发生器,可以提供多种波特率,使得它的应用更加广泛。USART支持同步单向通信和半双工单线通信;还支持局域互连网络LIN、智能卡(SmartCard)协议与lrDA(红外线数据协会)
资源推荐
资源详情
资源评论
收起资源包目录
06-UART发送字符串.rar (168个子文件)
Template.uvguix.Administrator 92KB
keilkilll.bat 399B
stm32f1xx_hal_i2c.c 234KB
stm32f1xx_hal_tim.c 213KB
stm32f1xx_hal_spi.c 125KB
stm32f1xx_hal_uart.c 110KB
stm32f1xx_hal_sd.c 100KB
stm32f1xx_hal_usart.c 100KB
stm32f1xx_hal_irda.c 95KB
stm32f1xx_hal_adc.c 92KB
stm32f1xx_hal_mmc.c 91KB
stm32f1xx_hal_smartcard.c 85KB
stm32f1xx_hal_can.c 81KB
stm32f1xx_hal_eth.c 79KB
stm32f1xx_hal_nand.c 73KB
stm32f1xx_ll_usb.c 73KB
stm32f1xx_hal_tim_ex.c 64KB
stm32f1xx_hal_i2s.c 61KB
stm32f1xx_hal_pcd.c 60KB
stm32f1xx_hal_rtc.c 59KB
stm32f1xx_hal_can.c 57KB
stm32f1xx_hal_adc_ex.c 52KB
stm32f1xx_hal_rcc.c 49KB
stm32f1xx_ll_sdmmc.c 49KB
stm32f1xx_hal_dac.c 48KB
stm32f1xx_hal_hcd.c 46KB
stm32f1xx_ll_tim.c 45KB
stm32f1xx_ll_adc.c 41KB
stm32f1xx_hal_nor.c 40KB
stm32f1xx_ll_fsmc.c 38KB
stm32f1xx_hal_flash_ex.c 36KB
stm32f1xx_hal_sram.c 33KB
stm32f1xx_hal_cec.c 31KB
stm32f1xx_hal_rcc_ex.c 30KB
stm32f1xx_hal_pccard.c 30KB
stm32f1xx_hal_flash.c 30KB
stm32f1xx_hal_dma.c 28KB
stm32f1xx_ll_utils.c 23KB
stm32f1xx_hal_pwr.c 21KB
stm32f1xx_hal_gpio.c 21KB
stm32f1xx_hal.c 20KB
stm32f1xx_ll_spi.c 20KB
stm32f1xx_hal_cortex.c 19KB
stm32f1xx_ll_usart.c 18KB
stm32f1xx_ll_rtc.c 17KB
stm32f1xx_hal_rtc_ex.c 16KB
stm32f1xx_hal_exti.c 15KB
stm32f1xx_hal_dac_ex.c 15KB
system_stm32f1xx.c 15KB
stm32f1xx_ll_rcc.c 14KB
stm32f1xx_hal_wwdg.c 14KB
stm32f1xx_ll_dma.c 13KB
stm32f1xx_ll_dac.c 12KB
stm32f1xx_hal_timebase_rtc_alarm_template.c 10KB
stm32f1xx_hal_crc.c 10KB
stm32f1xx_hal_iwdg.c 9KB
stm32f1xx_ll_gpio.c 8KB
stm32f1xx_hal_pcd_ex.c 8KB
delay.c 7KB
stm32f1xx_ll_i2c.c 7KB
stm32f1xx_ll_exti.c 7KB
usart.c 6KB
stm32f1xx_hal_timebase_tim_template.c 5KB
stm32f1xx_it.c 4KB
stm32f1xx_hal_gpio_ex.c 4KB
stm32f1xx_ll_crc.c 3KB
sys.c 2KB
stm32f1xx_ll_pwr.c 2KB
stm32f1xx_hal_msp_template.c 2KB
stm32f1xx_hal_msp.c 2KB
uart1.c 2KB
key.c 1KB
led.c 1KB
buzzer.c 618B
main.c 361B
Template_STM32F103ZE_1.0.0.dbgconf 2KB
Target_1_STM32F103ZE_1.0.0.dbgconf 2KB
stm32f103xe.h 951KB
stm32f1xx_ll_adc.h 227KB
stm32_hal_legacy.h 200KB
stm32f1xx_ll_tim.h 162KB
stm32f1xx_hal_tim.h 113KB
core_cm3.h 109KB
stm32f1xx_hal_eth.h 103KB
stm32f1xx_ll_usart.h 99KB
stm32f1xx_hal_rcc_ex.h 99KB
stm32f1xx_ll_gpio.h 88KB
stm32f1xx_ll_rcc.h 84KB
stm32f1xx_ll_dma.h 77KB
stm32f1xx_hal_rcc.h 67KB
stm32f1xx_ll_i2c.h 63KB
stm32f1xx_ll_spi.h 63KB
stm32f1xx_ll_dac.h 62KB
stm32f1xx_ll_sdmmc.h 60KB
cmsis_armclang.h 55KB
stm32f1xx_hal_adc.h 52KB
stm32f1xx_hal_adc_ex.h 47KB
stm32f1xx_ll_bus.h 45KB
stm32f1xx_hal_can.h 43KB
stm32f1xx_hal_uart.h 42KB
共 168 条
- 1
- 2
资源评论
沧海一笑-dj
- 粉丝: 4w+
- 资源: 357
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- TypeScript 和 Vue 的入门模板,带有详细的 README,描述了如何将两者结合使用 .zip
- The Net Ninja YouTube 频道上的 Vue.js 2 播放列表的课程文件.zip
- TDesign 的 Vue3.x UI 组件库 .zip
- AndroidStudio导入Cordova项目中文最新版本
- Muse Vue Ant Design 仪表板 - 免费且开源的 Ant Design Vue 仪表板.zip
- Laravel-Vue SPA 入门套件 .zip
- 非机动车未带安全帽检测数据集VOC+YOLO格式1000张4类别.zip
- Geist 的 Vue 实现.zip
- Electron + Vue仿网易云音乐windows客户端.zip
- Dropzone.js 的 Vue.js 组件 - 带有图像预览的拖放文件上传实用程序.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功