/**
@page SMBUS_PMBUS_Test STM32L4 SMBus and PMBus example and simple test
@verbatim
******************** (C) COPYRIGHT 2018 STMicroelectronics *******************
* @file SMBUS/readme.txt
* @author MCD Application Team
* @brief Description of the SMBus example.
******************************************************************************
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
@endverbatim
@par Example Description
This example guides you through the different configuration steps by mean of HAL API
to ensure SMBus and PMBus transmission and reception using Interrupt.
The communication is done with 2 Boards through I2C.
At the beginning of the main program the HAL_Init() function is called to reset
all the peripherals, initialize the Flash interface and the systick.
Then the SystemClock_Config() function is used to configure the system
clock (SYSCLK) to run at 80 MHz.
The I2C peripheral configuration is ensured by the HAL_SMBUS_Init() function.
This later is calling the HAL_SMBUS_MspInit()function which core is implementing
the configuration of the needed I2C resources according to the used hardware (CLOCK,
GPIO and NVIC). You may update this function to change I2C configuration.
Example then configures the LED and User Button to control and visualize the test
progress.
The communication is then initiated.
@par HW setup
To get the example working properly two Discovery boards are needed, one to perform
as host and the other to perform as device.
Connect with wires SCL and SDA pins of the two boards. In case of the STM32L476G
Discovery that is PB6 (PIN15 P1) and PB7 (PIN16 P1) for I2C1 and PB10 and PB11
for I2C2. Use pull-up resistors or make sure the host side has the internal
pull-up configured.
It is not advisable to have internal pull-up configured on more devices. To test
the alert capability, interconnect the PB5 (PA8) pins as well.
___ Host BOARD _____ _____VDD _____ _____ Device Board _____
| ______________| | | |______________ |
| |I2C1(I2C2) | | | | I2C1(I2C2) | |
| | | R (4.7K) R | | |
| | SCL |____|_________|______| SCL | |
| | | | | | |
| | | | | | |
| | SDA |______________|______| SDA | |
| |______________| |______________| |
| | | |
| GND|_____________________|GND |
|__ STM32 Discovery ___| |__ STM32 Discovery ___|
@par Configuring the example
Various features and working modes of the example FW can be configured using following
preprocessor defines on the host board:
HOST1 define to configure I2C1 as the bus host. If ARP is defined as well, the host
will wait for ARP notify host command from a device. Otherwise the host will
immediately attempt to send loop of test commands to the device on address that goes
first in the device list (address 0x1A by default).
TEST2 replaces the default test command with a PMBus group command test.
TEST3 replaces the initial 4 test cases with PMBus extended command tests.
TEST4 - TEST 4 must be defined on both sides simultaneously in order to work, it also
requires DENSE_CMD_TBL active and it's setting prevent it from working with ARP.
The test uses selected commands from PMBUS command table. Also the bar toggling on Host
may be different that one on recieving device.
TEST5 - a routine for quick non-regression test of the Zone capability. Requires PMBUS13
Device side specific preprocessor defines:
DEV_PSA Device has a persistent address.
SMB1 define to configure I2C1 to SMBus (Port B)
SMB2 define to configure I2C2 to SMBus (Port A)
Also, following preprocessor define switches influence not only the example but the
stack itself:
DEV_DIS Device is discoverable reacts to general ARP calls on default address.
ARP define to enable the automatic address resolution protocol execution in the code
startup. Push user button then to proceed to regular tests. To test ARP successfully,
DEV_DIS must be active on the device side.
USE_PEC - Defined when ARP is defined, but usable without ARP. Forces use of packet error
checking in communication.
PMBUS12 - Define to include PMBus 1.2 new commands.
PMBUS13 - Define to include PMBus 1.3(.1) new commands.
DENSE_CMD_TBL - Switches between two methods of locating command code, the fast and
the thorough. Either the command code is directly the index to the table, or a search
is done.
ALERT Enables alert signal. Must be defined on both master and slave.
@par Example operation
The host-configured discovery board flashes a LED light as transmitting commands.
The device receiving commands flashes LED (LED that flashes changes according to command
code if more LED are present, same led except TEST4) for regular command or simply quietly
replies in case of receive byte command of default test.
User can use the host mounted blue button to cycle between commands (test cases) and
device mounted blue button to send alert or notify.
Examples of working test configurations:
- Host configured with HOST1, TEST2, device configured with DEV_PSA, SMB1
- Host configured with HOST1, TEST4, device with TEST4, DENSE_CMD_TBL, SMB1
- Host configured with HOST1, ARP, device with DEV_DIS, ARP, SMB1 (and/or SMB2)
( UDID must be manually configured to unique numbers )
Address resolution protocol (ARP) demo requires the device to send notify to the host
to get the address assigned. Then the host button is used to progress in further steps.
In case of communication error the board detecting the LED blink will stop.
Depending on speed settings, the LED may appear quite dim as a result of short duty
cycle.
@par Directory contents
- SMBUS/Inc/stm32l4xx_hal_conf.h HAL configuration file
- SMBUS/Inc/stm32l4xx_it.h I2C interrupt handlers header file
- SMBUS/Inc/main.h Header for main.c module
- SMBUS/Src/stm32l4xx_it.c
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
The X-CUBE-SMBUS Expansion Package contains the SMBus/PMBus stack implementation for STM32Cube. The SMBus stack is built on STM32Cube HAL drivers to implement the transport layer. Middleware also includes the template for further expansion and personalization of PMBus support. The strict usage of STM32Cube ensures high portability across STM32 microcontrollers. X-CUBE-SMBUS is provided with example and basic functionality tests for the main board in the P-NUCLEO-WB55 pack, and for boards NUCLEO
资源详情
资源评论
资源推荐
收起资源包目录
stm32官方关于SMBUS的例程
SMBus 3.0 transfers:
Quick command
Read/write (1883个子文件)
main.c.bak 28KB
main.c.bak.bak 24KB
main.c.bak 0B
stm32g4xx_hal_hrtim.c 391KB
stm32f3xx_hal_adc_ex.c 311KB
stm32f3xx_hal_hrtim.c 298KB
stm32h7xx_hal_hrtim.c 288KB
stm32g4xx_hal_tim.c 233KB
stm32l4xx_hal_i2c.c 217KB
stm32g4xx_hal_i2c.c 216KB
stm32l0xx_hal_i2c.c 216KB
stm32wbxx_hal_i2c.c 215KB
stm32wbxx_hal_tim.c 209KB
stm32l4xx_hal_tim.c 207KB
stm32l0xx_hal_tim.c 202KB
stm32h7xx_hal_tim.c 184KB
stm32g4xx_hal_cryp.c 180KB
stm32f3xx_hal_tim.c 174KB
stm32f0xx_hal_tim.c 170KB
stm32h7xx_hal_fdcan.c 166KB
stm32wbxx_hal_cryp.c 162KB
stm32f3xx_hal_i2c.c 161KB
stm32f0xx_hal_i2c.c 160KB
stm32h7xx_hal_i2c.c 158KB
stm32g4xx_hal_adc.c 147KB
stm32l4xx_hal_adc.c 146KB
stm32l4xx_hal_spi.c 138KB
stm32wbxx_hal_uart.c 138KB
stm32l4xx_hal_uart.c 137KB
stm32wbxx_hal_spi.c 137KB
stm32g4xx_hal_spi.c 137KB
stm32g4xx_hal_uart.c 133KB
stm32l4xx_hal_sd.c 130KB
stm32wbxx_hal_adc.c 130KB
stm32l4xx_hal_dfsdm.c 129KB
stm32wbxx_hal_usart.c 129KB
stm32h7xx_hal_adc.c 129KB
stm32l4xx_hal_smartcard.c 127KB
stm32h7xx_hal_cryp.c 127KB
stm32l4xx_hal_usart.c 127KB
stm32l4xx_hal_rcc_ex.c 127KB
stm32f0xx_hal_spi.c 124KB
stm32l0xx_hal_uart.c 124KB
stm32l0xx_hal_spi.c 123KB
stm32h7xx_hal_jpeg.c 123KB
stm32f3xx_hal_spi.c 122KB
stm32g4xx_hal_usart.c 121KB
stm32g4xx_hal_fdcan.c 121KB
stm32wbxx_hal_smartcard.c 121KB
stm32g4xx_hal_smartcard.c 121KB
stm32g4xx_hal_tim_ex.c 119KB
stm32l4xx_hal_cryp_ex.c 118KB
stm32l4xx_hal_hash.c 114KB
stm32l0xx_hal_smartcard.c 109KB
stm32l0xx_hal_usart.c 108KB
stm32h7xx_hal_dfsdm.c 108KB
stm32wbxx_hal_irda.c 106KB
stm32l4xx_hal_irda.c 106KB
stm32l4xx_hal_ospi.c 106KB
stm32l0xx_hal_irda.c 105KB
stm32h7xx_hal_hash.c 102KB
stm32g4xx_hal_irda.c 101KB
stm32h7xx_hal_spi.c 100KB
stm32f3xx_ll_adc.c 100KB
stm32h7xx_hal_adc_ex.c 99KB
font20epd.c 99KB
stm32f0xx_hal_uart.c 98KB
stm32h7xx_hal_uart.c 97KB
stm32l4xx_hal_smbus.c 96KB
stm32f3xx_hal_tim_ex.c 96KB
stm32f3xx_hal_uart.c 95KB
stm32wbxx_hal_smbus.c 95KB
stm32g4xx_hal_smbus.c 95KB
stm32l0xx_hal_smbus.c 95KB
stm32l0xx_hal_adc.c 95KB
stm32l4xx_hal_qspi.c 94KB
stm32l4xx_hal_adc_ex.c 94KB
stm32g4xx_hal_adc_ex.c 94KB
stm32l4xx_hal_sai.c 93KB
stm32h7xx_hal_smartcard.c 93KB
stm32h7xx_hal_rcc_ex.c 93KB
stm32h7xx_hal_sd.c 92KB
stm32h7xx_hal_eth.c 92KB
stm32g4xx_hal_qspi.c 92KB
stm32f0xx_hal_smartcard.c 91KB
stm32f3xx_hal_smartcard.c 90KB
stm32wbxx_hal_qspi.c 90KB
stm32h7xx_hal_mmc.c 90KB
stm32f0xx_hal_usart.c 89KB
stm32g4xx_hal_fmac.c 89KB
stm32g4xx_hal_sai.c 88KB
stm32f3xx_hal_sdadc.c 88KB
stm32wbxx_hal_sai.c 88KB
stm32f0xx_hal_irda.c 87KB
stm32l4xx_hal_dsi.c 86KB
stm32f0xx_hal_adc.c 84KB
stm32wbxx_hal_pka.c 83KB
stm32l4xx_hal_tim_ex.c 83KB
stm32l4xx_hal_can.c 82KB
stm32f3xx_hal_irda.c 82KB
共 1883 条
- 1
- 2
- 3
- 4
- 5
- 6
- 19
lhp0777
- 粉丝: 2
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0