/**
******************************************************************************
* @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 @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 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 @ref HAL_I2C_Init(), configures also the low level Hardware
(GPIO, CLOCK, NVIC...etc) by calling the customized @ref HAL_I2C_MspInit(&hi2c) 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()
(+) Discard a slave I2C process communication using @ref __HAL_I2C_GENERATE_NACK() macro.
This action will inform Master to generate a Stop condition to discard the communication.
*** 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 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
没有合适的资源?快使用搜索试试~ 我知道了~
STM32L051C8T6_USART1.zip
共155个文件
h:45个
o:24个
d:24个
1星 需积分: 49 118 下载量 105 浏览量
2020-04-16
12:09:13
上传
评论 1
收藏 5.57MB ZIP 举报
温馨提示
采用HAL库生成的工程文件实现STM32L051C8T6的USART1控制,实现简单的数据收发过程代码。
资源推荐
资源详情
资源评论
收起资源包目录
STM32L051C8T6_USART1.zip (155个子文件)
STM32L051C8T6_USART1.uvguix.Administrator 92KB
STM32L051C8T6_USART1.axf 379KB
stm32l0xx_hal_i2c.c 216KB
stm32l0xx_hal_tim.c 202KB
stm32l0xx_hal_uart.c 124KB
stm32l0xx_hal_rcc.c 54KB
stm32l0xx_hal_flash_ex.c 42KB
stm32l0xx_hal_rcc_ex.c 40KB
stm32l0xx_hal_dma.c 27KB
stm32l0xx_hal_pwr.c 27KB
stm32l0xx_hal_flash.c 25KB
stm32l0xx_hal_tim_ex.c 19KB
stm32l0xx_hal_gpio.c 19KB
stm32l0xx_hal.c 19KB
stm32l0xx_hal_flash_ramfunc.c 18KB
stm32l0xx_hal_uart_ex.c 17KB
stm32l0xx_hal_cortex.c 14KB
stm32l0xx_hal_i2c_ex.c 11KB
system_stm32l0xx.c 9KB
main.c 6KB
stm32l0xx_hal_pwr_ex.c 5KB
stm32l0xx_it.c 5KB
usart.c 4KB
stm32l0xx_hal_msp.c 2KB
gpio.c 2KB
stm32l0xx_hal_i2c.crf 441KB
stm32l0xx_hal_uart.crf 413KB
stm32l0xx_hal_rcc.crf 404KB
stm32l0xx_hal_flash_ex.crf 397KB
usart.crf 396KB
main.crf 396KB
stm32l0xx_hal_dma.crf 396KB
stm32l0xx_hal_rcc_ex.crf 396KB
stm32l0xx_hal_flash.crf 395KB
stm32l0xx_hal_gpio.crf 393KB
stm32l0xx_hal_pwr.crf 393KB
stm32l0xx_hal_flash_ramfunc.crf 392KB
stm32l0xx_hal_uart_ex.crf 392KB
stm32l0xx_hal.crf 392KB
stm32l0xx_hal_i2c_ex.crf 392KB
stm32l0xx_hal_cortex.crf 391KB
system_stm32l0xx.crf 391KB
gpio.crf 391KB
stm32l0xx_hal_pwr_ex.crf 391KB
stm32l0xx_it.crf 391KB
stm32l0xx_hal_msp.crf 390KB
stm32l0xx_hal_tim_ex.crf 390KB
stm32l0xx_hal_tim.crf 390KB
stm32l0xx_hal_flash_ramfunc.d 3KB
stm32l0xx_hal_flash_ex.d 3KB
stm32l0xx_hal_uart_ex.d 3KB
stm32l0xx_hal_pwr_ex.d 3KB
stm32l0xx_hal_cortex.d 3KB
stm32l0xx_hal_tim_ex.d 3KB
stm32l0xx_hal_rcc_ex.d 3KB
stm32l0xx_hal_i2c_ex.d 3KB
stm32l0xx_hal_flash.d 3KB
stm32l0xx_hal_uart.d 3KB
stm32l0xx_hal_gpio.d 3KB
stm32l0xx_hal_msp.d 3KB
stm32l0xx_hal_pwr.d 3KB
stm32l0xx_hal_i2c.d 3KB
stm32l0xx_hal_rcc.d 3KB
stm32l0xx_hal_dma.d 3KB
stm32l0xx_hal_tim.d 3KB
system_stm32l0xx.d 3KB
stm32l0xx_it.d 3KB
stm32l0xx_hal.d 3KB
main.d 3KB
usart.d 3KB
gpio.d 2KB
startup_stm32l051xx.d 67B
STM32L051C8T6_USART1_STM32L051C8Tx.dbgconf 2KB
STM32L051C8T6_USART1_STM32L051C8T6_USART1.dep 61KB
stm32l051xx.h 470KB
arm_math.h 246KB
stm32_hal_legacy.h 188KB
core_cm7.h 136KB
stm32l0xx_hal_gpio_ex.h 123KB
core_cm4.h 112KB
stm32l0xx_hal_rcc_ex.h 110KB
core_cm3.h 101KB
core_sc300.h 100KB
stm32l0xx_hal_tim.h 95KB
stm32l0xx_hal_rcc.h 86KB
stm32l0xx_hal_uart.h 74KB
cmsis_armcc_V6.h 54KB
core_sc000.h 44KB
core_cm0plus.h 44KB
cmsis_gcc.h 40KB
stm32l0xx_hal_flash_ex.h 39KB
stm32l0xx_hal_i2c.h 37KB
core_cm0.h 36KB
stm32l0xx_hal_dma.h 29KB
cmsis_armcc.h 24KB
stm32l0xx_hal_uart_ex.h 22KB
stm32l0xx_hal_pwr.h 17KB
stm32l0xx_hal.h 16KB
stm32l0xx_hal_cortex.h 15KB
stm32l0xx_hal_gpio.h 13KB
共 155 条
- 1
- 2
资源评论
- weixin_434984732021-08-02只是用CubeMX初始化了一下串口,没什么参考价值
皮克斯之旅
- 粉丝: 112
- 资源: 19
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功