L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
i2c.h
Go to the documentation of this file.
1/* USER CODE BEGIN Header */
2/**
3 ******************************************************************************
4 * @file i2c.h
5 * @brief This file contains all the function prototypes for
6 * the i2c.c file
7 ******************************************************************************
8 * @attention
9 *
10 * Copyright (c) 2025 STMicroelectronics.
11 * All rights reserved.
12 *
13 * This software is licensed under terms that can be found in the LICENSE file
14 * in the root directory of this software component.
15 * If no LICENSE file comes with this software, it is provided AS-IS.
16 *
17 ******************************************************************************
18 */
19/* USER CODE END Header */
20/* Define to prevent recursive inclusion -------------------------------------*/
21#ifndef __I2C_H__
22#define __I2C_H__
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/* Includes ------------------------------------------------------------------*/
29#include "main.h"
30
31/* USER CODE BEGIN Includes */
32
33/* USER CODE END Includes */
34
35extern I2C_HandleTypeDef hi2c2;
36
37/* USER CODE BEGIN Private defines */
38
39/* USER CODE END Private defines */
40
41/**
42 * @brief Initialise the I2C2 peripheral (hi2c2) as configured by STM32CubeMX.
43 * Sets clock speed, addressing mode, and timing registers for
44 * communication with all I2C-connected sensors (SHT45, TSL2591,
45 * ILPS22QS, BMP585, SCD41, SPS30, ST25DV16KC NFC tag).
46 */
47void MX_I2C2_Init(void);
48
49/* USER CODE BEGIN Prototypes */
50
51/**
52 * @brief Deinitialise the I2C2 peripheral to reduce current consumption in low-power mode.
53 * Call before entering STOP or OFF mode; call MX_I2C2_Init() again after wakeup.
54 */
55void MX_I2C2_DeInit(void);
56
57/**
58 * @brief Wrapper around HAL_I2C_IsDeviceReady() that recovers from a busy bus.
59 * If the HAL I2C bus is in a BUSY error state, the function resets the
60 * peripheral (DeInit / Init cycle) before retrying the device poll.
61 * @param hi2c Pointer to the I2C handle.
62 * @param DevAddress 7-bit or 10-bit device address (left-shifted by 1 for HAL).
63 * @param Trials Number of consecutive ACK attempts before giving up.
64 * @param Timeout Timeout in milliseconds for each trial.
65 * @retval HAL_OK – device acknowledged within the given number of trials.
66 * @retval HAL_ERROR – device not present or bus error after recovery attempt.
67 * @retval HAL_TIMEOUT – device did not acknowledge within the timeout.
68 */
69HAL_StatusTypeDef I2C_IsDeviceReadyMT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout);
70
71
72/* USER CODE END Prototypes */
73
74#ifdef __cplusplus
75}
76#endif
77
78#endif /* __I2C_H__ */
79
void MX_I2C2_Init(void)
Initialise the I2C2 peripheral (hi2c2) as configured by STM32CubeMX. Sets clock speed,...
Definition i2c.c:30
HAL_StatusTypeDef I2C_IsDeviceReadyMT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout)
Wrapper around HAL_I2C_IsDeviceReady() that recovers from a busy bus. If the HAL I2C bus is in a BUSY...
Definition i2c.c:158
I2C_HandleTypeDef hi2c2
Definition i2c.c:27
void MX_I2C2_DeInit(void)
Deinitialise the I2C2 peripheral to reduce current consumption in low-power mode. Call before enterin...
Definition i2c.c:150
: Header for main.c file. This file contains the common defines of the application.