/**
******************************************************************************
* @file stm32l0xx_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 and Errors 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 Clock Timing, Own Address1, Master Addressing mode, Dual Addressing mode,
Own Address2, Own Address2 Mask, 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()
(+) Discard a slave I2C process communication using __HAL_I2C_GENERATE_NACK() macro.
This action will inform Master to generate a Stop condition to discard the communication.
*** 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_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_Sequential_Transmit_IT() then HAL_I2C_Master_Sequential_Transmit_IT())
(++) 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 maste
没有合适的资源?快使用搜索试试~ 我知道了~
STM32 L0 hal库
共144个文件
h:77个
c:65个
html:1个
需积分: 9 24 下载量 51 浏览量
2018-03-07
15:41:07
上传
评论
收藏 12.6MB RAR 举报
温馨提示
官网介绍说,hal(hardware abstract layer)是一层硬件的抽象,看到这里,我非常激动,看来st终于意识到原来标准库的问题了,原来的标准库非常依赖于具体硬件细节,很难体现出使用库的优势,而且很难移植。同时我也非常好奇,st到底是如何把不同系列mcu的操作给封装起来的,是不是足够抽象,方便移植 作者:logic_wei 链接:https://www.jianshu.com/p/c6809c2bcb4f 來源:简书 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
资源推荐
资源详情
资源评论
收起资源包目录
STM32 L0 hal库 (144个子文件)
stm32l0xx_hal_i2c.c 159KB
stm32l0xx_hal_tim.c 158KB
stm32l0xx_hal_uart.c 97KB
stm32l0xx_hal_smartcard.c 90KB
stm32l0xx_hal_irda.c 85KB
stm32l0xx_hal_adc.c 84KB
stm32l0xx_hal_usart.c 83KB
stm32l0xx_hal_spi.c 79KB
stm32l0xx_hal_smbus.c 77KB
stm32l0xx_hal_cryp.c 71KB
stm32l0xx_hal_rtc_ex.c 66KB
stm32l0xx_hal_rcc.c 56KB
stm32l0xx_hal_lptim.c 52KB
stm32l0xx_hal_rtc.c 51KB
stm32l0xx_hal_i2s.c 48KB
stm32l0xx_hal_flash_ex.c 42KB
stm32l0xx_hal_rcc_ex.c 40KB
stm32l0xx_hal_pcd.c 39KB
stm32l0xx_hal_dac_ex.c 37KB
stm32l0xx_ll_rtc.c 33KB
stm32l0xx_ll_tim.c 32KB
stm32l0xx_hal_comp.c 30KB
stm32l0xx_ll_adc.c 29KB
stm32l0xx_hal_pwr.c 28KB
stm32l0xx_hal_dac.c 27KB
stm32l0xx_hal_dma.c 26KB
stm32l0xx_hal_tsc.c 25KB
stm32l0xx_hal_flash.c 25KB
stm32l0xx_hal_tim_ex.c 23KB
stm32l0xx_ll_utils.c 23KB
stm32l0xx_hal_lcd.c 21KB
stm32l0xx_ll_spi.c 21KB
stm32l0xx_ll_rcc.c 21KB
stm32l0xx_hal_gpio.c 21KB
stm32l0xx_hal_flash_ramfunc.c 19KB
stm32l0xx_hal_crc.c 18KB
stm32l0xx_hal_uart_ex.c 18KB
stm32l0xx_hal.c 18KB
stm32l0xx_ll_usart.c 18KB
stm32l0xx_ll_dma.c 17KB
stm32l0xx_hal_rng.c 16KB
stm32l0xx_hal_cortex.c 15KB
stm32l0xx_ll_comp.c 13KB
stm32l0xx_hal_adc_ex.c 13KB
stm32l0xx_hal_wwdg.c 13KB
stm32l0xx_hal_firewall.c 12KB
stm32l0xx_ll_dac.c 12KB
stm32l0xx_hal_i2c_ex.c 12KB
stm32l0xx_ll_lpuart.c 11KB
stm32l0xx_hal_iwdg.c 11KB
stm32l0xx_ll_gpio.c 10KB
stm32l0xx_hal_pcd_ex.c 10KB
stm32l0xx_ll_i2c.c 9KB
stm32l0xx_hal_crc_ex.c 9KB
stm32l0xx_ll_exti.c 9KB
stm32l0xx_ll_lptim.c 8KB
stm32l0xx_hal_smartcard_ex.c 8KB
stm32l0xx_hal_pwr_ex.c 6KB
stm32l0xx_hal_comp_ex.c 6KB
stm32l0xx_hal_cryp_ex.c 5KB
stm32l0xx_hal_msp_template.c 4KB
stm32l0xx_ll_crc.c 4KB
stm32l0xx_ll_rng.c 4KB
stm32l0xx_ll_pwr.c 4KB
stm32l0xx_ll_crs.c 3KB
STM32L073xx_User_Manual.chm 11.89MB
stm32l0xx_ll_adc.h 219KB
stm32_hal_legacy.h 178KB
stm32l0xx_ll_rtc.h 146KB
stm32l0xx_ll_usart.h 145KB
stm32l0xx_ll_tim.h 142KB
stm32l0xx_hal_gpio_ex.h 127KB
stm32l0xx_hal_rcc_ex.h 109KB
stm32l0xx_hal_rcc.h 88KB
stm32l0xx_ll_dma.h 85KB
stm32l0xx_ll_i2c.h 84KB
stm32l0xx_ll_rcc.h 83KB
stm32l0xx_ll_lpuart.h 76KB
stm32l0xx_hal_uart.h 73KB
stm32l0xx_ll_dac.h 68KB
stm32l0xx_hal_tim.h 68KB
stm32l0xx_ll_spi.h 67KB
stm32l0xx_hal_rtc_ex.h 65KB
stm32l0xx_hal_adc.h 62KB
stm32l0xx_hal_smartcard.h 54KB
stm32l0xx_ll_lptim.h 52KB
stm32l0xx_ll_bus.h 52KB
stm32l0xx_ll_system.h 43KB
stm32l0xx_hal_rtc.h 40KB
stm32l0xx_hal_flash_ex.h 40KB
stm32l0xx_hal_lcd.h 39KB
stm32l0xx_hal_irda.h 39KB
stm32l0xx_ll_exti.h 38KB
stm32l0xx_ll_gpio.h 37KB
stm32l0xx_hal_usart.h 33KB
stm32l0xx_hal_smbus.h 32KB
stm32l0xx_hal_i2c.h 32KB
stm32l0xx_hal_dma.h 31KB
stm32l0xx_ll_comp.h 31KB
stm32l0xx_hal_lptim.h 31KB
共 144 条
- 1
- 2
资源评论
hwenli
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功