/**
******************************************************************************
* @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
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
随言: 只实现了USB播放音频功能,至于USB录音和控制音量等功能,找到了相关资料,但是个人没时间往下折腾。 官方程序X-CUBE-USB-AUDIO:https://www.st.com/zh/embedded-software/x-cube-usb-audio.html 文档《UM2195 User manual USB device audio streaming Expansion Package for STM32Cube》:https://www.stmcu.org.cn/document/detail/index/id-219223 本手册与补充STM32Cube™固件库的X-CUBE-USB-AUDIO扩展包相关联,它描述了X-CUBE-USB-AUDIO固件库以及使用方法。 文档和程序要相互配合着看。
资源推荐
资源详情
资源评论
收起资源包目录
USB Slave Audio.rar (246个子文件)
USB Slave Audio.bin 39KB
stm32f4xx_hal_i2c.c 233KB
stm32f4xx_hal_tim.c 213KB
stm32f4xx_hal_rcc_ex.c 154KB
stm32f4xx_hal_uart.c 111KB
stm32f4xx_hal_i2s.c 70KB
stm32f4xx_hal_tim_ex.c 66KB
stm32f4xx_hal_pcd.c 60KB
stm32f4xx_ll_usb.c 59KB
stm32f4xx_hal_flash_ex.c 51KB
stm32f4xx_hal_rcc.c 42KB
stm32f4xx_hal_dma.c 40KB
stm32f4xx_hal_i2s_ex.c 39KB
system_stm32f4xx.c 26KB
usbd_audio.c 26KB
stm32f4xx_hal_flash.c 24KB
stm32f4xx_hal_pwr_ex.c 23KB
usbd_ctlreq.c 20KB
stm32f4xx_hal_pwr.c 20KB
stm32f4xx_hal.c 19KB
stm32f4xx_hal_gpio.c 19KB
stm32f4xx_hal_cortex.c 19KB
usbd_conf.c 19KB
stm32f4xx_hal_exti.c 15KB
usbd_core.c 14KB
usbd_desc.c 12KB
stm32f4xx_hal_pcd_ex.c 11KB
stm32f4xx_hal_dma_ex.c 11KB
stm32f4xx_hal_msp.c 9KB
main.c 9KB
usbd_audio_if.c 7KB
stm32f4xx_hal_flash_ramfunc.c 6KB
stm32f4xx_it.c 6KB
stm32f4xx_hal_i2c_ex.c 6KB
usbd_ioreq.c 5KB
audio_player.c 3KB
syscalls.c 3KB
usb_device.c 3KB
wm8978.c 2KB
sysmem.c 1KB
.cproject 27KB
usb_device.d 5KB
usbd_audio_if.d 5KB
usbd_audio.d 5KB
audio_player.d 5KB
usbd_ctlreq.d 5KB
usbd_desc.d 5KB
usbd_conf.d 5KB
usbd_ioreq.d 5KB
usbd_core.d 5KB
main.d 4KB
stm32f4xx_it.d 4KB
stm32f4xx_hal_flash_ramfunc.d 4KB
wm8978.d 4KB
stm32f4xx_hal_flash_ex.d 4KB
stm32f4xx_hal_rcc_ex.d 4KB
stm32f4xx_hal_i2s_ex.d 4KB
stm32f4xx_hal_pwr_ex.d 4KB
stm32f4xx_hal_i2c_ex.d 4KB
stm32f4xx_hal_dma_ex.d 4KB
stm32f4xx_hal_cortex.d 4KB
stm32f4xx_hal_tim_ex.d 4KB
stm32f4xx_hal_pcd_ex.d 4KB
stm32f4xx_hal_flash.d 4KB
stm32f4xx_hal_uart.d 4KB
stm32f4xx_hal_exti.d 4KB
stm32f4xx_hal_gpio.d 4KB
stm32f4xx_hal_pcd.d 4KB
stm32f4xx_hal_rcc.d 4KB
stm32f4xx_hal_pwr.d 4KB
stm32f4xx_hal_i2s.d 4KB
stm32f4xx_hal_tim.d 4KB
stm32f4xx_hal_i2c.d 4KB
stm32f4xx_hal_dma.d 4KB
stm32f4xx_ll_usb.d 4KB
stm32f4xx_hal.d 4KB
stm32f4xx_hal_msp.d 4KB
system_stm32f4xx.d 4KB
syscalls.d 45B
sysmem.d 41B
USB Slave Audio.elf 1.33MB
stm32f407xx.h 1.29MB
stm32f4xx_hal_rcc_ex.h 432KB
stm32_hal_legacy.h 208KB
core_cm33.h 171KB
core_armv8mml.h 165KB
core_cm7.h 145KB
core_cm4.h 121KB
stm32f4xx_hal_tim.h 113KB
core_cm3.h 109KB
core_sc300.h 108KB
core_cm23.h 102KB
core_armv8mbl.h 96KB
stm32f4xx_hal_gpio_ex.h 81KB
stm32f4xx_hal_rcc.h 74KB
stm32f4xx_hal_flash_ex.h 64KB
cmsis_gcc.h 61KB
cmsis_armclang.h 55KB
core_cm0plus.h 49KB
core_sc000.h 46KB
共 246 条
- 1
- 2
- 3
资源评论
- 云淡风沁2021-12-08间隔4秒左右,声音出现一点杂音,知道是什么原因吗?谢谢
sudaroot
- 粉丝: 2w+
- 资源: 42
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功