STM32Cube BSP FW for STM32F769I-Discovery

Dependents:   mbed-os-example-blinky-5 DISCO-F769NI_TOUCHSCREEN_demo_custom_1 Datarecorder2 DISCO-F769NI_TOUCHSCREEN_demo ... more

Committer:
Jerome Coutant
Date:
Thu Feb 23 14:14:08 2017 +0100
Revision:
1:3e58f8a39705
Parent:
0:c0f3bbab73d2
Child:
3:145e714557cf
STM32Cube_FW_F7_V1.6.0 BSP_DISCO_F769NI

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jerome Coutant 0:c0f3bbab73d2 1 /**
Jerome Coutant 0:c0f3bbab73d2 2 ******************************************************************************
Jerome Coutant 0:c0f3bbab73d2 3 * @file stm32f769i_discovery.c
Jerome Coutant 0:c0f3bbab73d2 4 * @author MCD Application Team
Jerome Coutant 1:3e58f8a39705 5 * @version V2.0.0
Jerome Coutant 1:3e58f8a39705 6 * @date 30-December-2016
Jerome Coutant 0:c0f3bbab73d2 7 * @brief This file provides a set of firmware functions to manage LEDs,
Jerome Coutant 0:c0f3bbab73d2 8 * push-buttons, external SDRAM, external QSPI Flash, RF EEPROM,
Jerome Coutant 0:c0f3bbab73d2 9 * available on STM32F769I-Discovery board (MB1225) from
Jerome Coutant 0:c0f3bbab73d2 10 * STMicroelectronics.
Jerome Coutant 0:c0f3bbab73d2 11 ******************************************************************************
Jerome Coutant 0:c0f3bbab73d2 12 * @attention
Jerome Coutant 0:c0f3bbab73d2 13 *
Jerome Coutant 0:c0f3bbab73d2 14 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Jerome Coutant 0:c0f3bbab73d2 15 *
Jerome Coutant 0:c0f3bbab73d2 16 * Redistribution and use in source and binary forms, with or without modification,
Jerome Coutant 0:c0f3bbab73d2 17 * are permitted provided that the following conditions are met:
Jerome Coutant 0:c0f3bbab73d2 18 * 1. Redistributions of source code must retain the above copyright notice,
Jerome Coutant 0:c0f3bbab73d2 19 * this list of conditions and the following disclaimer.
Jerome Coutant 0:c0f3bbab73d2 20 * 2. Redistributions in binary form must reproduce the above copyright notice,
Jerome Coutant 0:c0f3bbab73d2 21 * this list of conditions and the following disclaimer in the documentation
Jerome Coutant 0:c0f3bbab73d2 22 * and/or other materials provided with the distribution.
Jerome Coutant 0:c0f3bbab73d2 23 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Jerome Coutant 0:c0f3bbab73d2 24 * may be used to endorse or promote products derived from this software
Jerome Coutant 0:c0f3bbab73d2 25 * without specific prior written permission.
Jerome Coutant 0:c0f3bbab73d2 26 *
Jerome Coutant 0:c0f3bbab73d2 27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Jerome Coutant 0:c0f3bbab73d2 28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Jerome Coutant 0:c0f3bbab73d2 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Jerome Coutant 0:c0f3bbab73d2 30 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Jerome Coutant 0:c0f3bbab73d2 31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Jerome Coutant 0:c0f3bbab73d2 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Jerome Coutant 0:c0f3bbab73d2 33 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Jerome Coutant 0:c0f3bbab73d2 34 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Jerome Coutant 0:c0f3bbab73d2 35 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Jerome Coutant 0:c0f3bbab73d2 36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Jerome Coutant 0:c0f3bbab73d2 37 *
Jerome Coutant 0:c0f3bbab73d2 38 ******************************************************************************
Jerome Coutant 0:c0f3bbab73d2 39 */
Jerome Coutant 0:c0f3bbab73d2 40
Jerome Coutant 0:c0f3bbab73d2 41 /* Includes ------------------------------------------------------------------*/
Jerome Coutant 0:c0f3bbab73d2 42 #include "stm32f769i_discovery.h"
Jerome Coutant 0:c0f3bbab73d2 43
Jerome Coutant 0:c0f3bbab73d2 44 /** @addtogroup BSP
Jerome Coutant 0:c0f3bbab73d2 45 * @{
Jerome Coutant 0:c0f3bbab73d2 46 */
Jerome Coutant 0:c0f3bbab73d2 47
Jerome Coutant 1:3e58f8a39705 48 /** @addtogroup STM32F769I_DISCOVERY
Jerome Coutant 0:c0f3bbab73d2 49 * @{
Jerome Coutant 0:c0f3bbab73d2 50 */
Jerome Coutant 0:c0f3bbab73d2 51
Jerome Coutant 1:3e58f8a39705 52 /** @defgroup STM32F769I_DISCOVERY_LOW_LEVEL STM32F769I_DISCOVERY LOW LEVEL
Jerome Coutant 0:c0f3bbab73d2 53 * @{
Jerome Coutant 0:c0f3bbab73d2 54 */
Jerome Coutant 0:c0f3bbab73d2 55
Jerome Coutant 1:3e58f8a39705 56 /** @defgroup STM32F769I_DISCOVERY_LOW_LEVEL_Private_TypesDefinitions STM32F769I Discovery Low Level Private Typedef
Jerome Coutant 0:c0f3bbab73d2 57 * @{
Jerome Coutant 0:c0f3bbab73d2 58 */
Jerome Coutant 0:c0f3bbab73d2 59 /**
Jerome Coutant 0:c0f3bbab73d2 60 * @}
Jerome Coutant 0:c0f3bbab73d2 61 */
Jerome Coutant 0:c0f3bbab73d2 62
Jerome Coutant 1:3e58f8a39705 63 /** @defgroup STM32F769I_DISCOVERY_LOW_LEVEL_Private_Defines LOW_LEVEL Private Defines
Jerome Coutant 0:c0f3bbab73d2 64 * @{
Jerome Coutant 0:c0f3bbab73d2 65 */
Jerome Coutant 0:c0f3bbab73d2 66 /**
Jerome Coutant 1:3e58f8a39705 67 * @brief STM32F769I Discovery BSP Driver version number V2.0.0
Jerome Coutant 0:c0f3bbab73d2 68 */
Jerome Coutant 1:3e58f8a39705 69 #define __STM32F769I_DISCOVERY_BSP_VERSION_MAIN (0x02) /*!< [31:24] main version */
Jerome Coutant 1:3e58f8a39705 70 #define __STM32F769I_DISCOVERY_BSP_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */
Jerome Coutant 0:c0f3bbab73d2 71 #define __STM32F769I_DISCOVERY_BSP_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
Jerome Coutant 0:c0f3bbab73d2 72 #define __STM32F769I_DISCOVERY_BSP_VERSION_RC (0x00) /*!< [7:0] release candidate */
Jerome Coutant 0:c0f3bbab73d2 73 #define __STM32F769I_DISCOVERY_BSP_VERSION ((__STM32F769I_DISCOVERY_BSP_VERSION_MAIN << 24)\
Jerome Coutant 0:c0f3bbab73d2 74 |(__STM32F769I_DISCOVERY_BSP_VERSION_SUB1 << 16)\
Jerome Coutant 0:c0f3bbab73d2 75 |(__STM32F769I_DISCOVERY_BSP_VERSION_SUB2 << 8 )\
Jerome Coutant 0:c0f3bbab73d2 76 |(__STM32F769I_DISCOVERY_BSP_VERSION_RC))
Jerome Coutant 0:c0f3bbab73d2 77 /**
Jerome Coutant 0:c0f3bbab73d2 78 * @}
Jerome Coutant 0:c0f3bbab73d2 79 */
Jerome Coutant 0:c0f3bbab73d2 80
Jerome Coutant 1:3e58f8a39705 81 /** @defgroup STM32F769I_DISCOVERY_LOW_LEVEL_Private_Macros LOW_LEVEL Private Macros
Jerome Coutant 0:c0f3bbab73d2 82 * @{
Jerome Coutant 0:c0f3bbab73d2 83 */
Jerome Coutant 0:c0f3bbab73d2 84 /**
Jerome Coutant 0:c0f3bbab73d2 85 * @}
Jerome Coutant 0:c0f3bbab73d2 86 */
Jerome Coutant 0:c0f3bbab73d2 87
Jerome Coutant 1:3e58f8a39705 88 /** @defgroup STM32F769I_DISCOVERY_LOW_LEVEL_Private_Variables LOW_LEVEL Private Variables
Jerome Coutant 0:c0f3bbab73d2 89 * @{
Jerome Coutant 0:c0f3bbab73d2 90 */
Jerome Coutant 0:c0f3bbab73d2 91 uint32_t GPIO_PIN[LEDn] = {LED1_PIN,
Jerome Coutant 0:c0f3bbab73d2 92 LED2_PIN};
Jerome Coutant 0:c0f3bbab73d2 93
Jerome Coutant 0:c0f3bbab73d2 94 GPIO_TypeDef* GPIO_PORT[LEDn] = {LED1_GPIO_PORT,
Jerome Coutant 0:c0f3bbab73d2 95 LED2_GPIO_PORT};
Jerome Coutant 0:c0f3bbab73d2 96
Jerome Coutant 0:c0f3bbab73d2 97 GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {WAKEUP_BUTTON_GPIO_PORT };
Jerome Coutant 0:c0f3bbab73d2 98
Jerome Coutant 0:c0f3bbab73d2 99 const uint16_t BUTTON_PIN[BUTTONn] = {WAKEUP_BUTTON_PIN };
Jerome Coutant 0:c0f3bbab73d2 100
Jerome Coutant 0:c0f3bbab73d2 101 const uint16_t BUTTON_IRQn[BUTTONn] = {WAKEUP_BUTTON_EXTI_IRQn };
Jerome Coutant 0:c0f3bbab73d2 102
Jerome Coutant 0:c0f3bbab73d2 103
Jerome Coutant 0:c0f3bbab73d2 104 static I2C_HandleTypeDef hI2cAudioHandler = {0};
Jerome Coutant 0:c0f3bbab73d2 105 static I2C_HandleTypeDef hI2cExtHandler = {0};
Jerome Coutant 0:c0f3bbab73d2 106
Jerome Coutant 0:c0f3bbab73d2 107 /**
Jerome Coutant 0:c0f3bbab73d2 108 * @}
Jerome Coutant 0:c0f3bbab73d2 109 */
Jerome Coutant 0:c0f3bbab73d2 110
Jerome Coutant 1:3e58f8a39705 111 /** @defgroup STM32F769I_DISCOVERY_LOW_LEVEL_Private_FunctionPrototypes LOW_LEVEL Private FunctionPrototypes
Jerome Coutant 0:c0f3bbab73d2 112 * @{
Jerome Coutant 0:c0f3bbab73d2 113 */
Jerome Coutant 0:c0f3bbab73d2 114 static void I2Cx_MspInit(I2C_HandleTypeDef *i2c_handler);
Jerome Coutant 0:c0f3bbab73d2 115 static void I2Cx_Init(I2C_HandleTypeDef *i2c_handler);
Jerome Coutant 0:c0f3bbab73d2 116
Jerome Coutant 0:c0f3bbab73d2 117 static HAL_StatusTypeDef I2Cx_ReadMultiple(I2C_HandleTypeDef *i2c_handler, uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length);
Jerome Coutant 0:c0f3bbab73d2 118 static HAL_StatusTypeDef I2Cx_WriteMultiple(I2C_HandleTypeDef *i2c_handler, uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length);
Jerome Coutant 0:c0f3bbab73d2 119 static HAL_StatusTypeDef I2Cx_IsDeviceReady(I2C_HandleTypeDef *i2c_handler, uint16_t DevAddress, uint32_t Trials);
Jerome Coutant 0:c0f3bbab73d2 120 static void I2Cx_Error(I2C_HandleTypeDef *i2c_handler, uint8_t Addr);
Jerome Coutant 0:c0f3bbab73d2 121
Jerome Coutant 0:c0f3bbab73d2 122 /* AUDIO IO functions */
Jerome Coutant 0:c0f3bbab73d2 123 void AUDIO_IO_Init(void);
Jerome Coutant 0:c0f3bbab73d2 124 void AUDIO_IO_DeInit(void);
Jerome Coutant 0:c0f3bbab73d2 125 void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value);
Jerome Coutant 0:c0f3bbab73d2 126 uint16_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg);
Jerome Coutant 0:c0f3bbab73d2 127 void AUDIO_IO_Delay(uint32_t Delay);
Jerome Coutant 0:c0f3bbab73d2 128
Jerome Coutant 0:c0f3bbab73d2 129 /* HDMI IO functions */
Jerome Coutant 0:c0f3bbab73d2 130 void HDMI_IO_Init(void);
Jerome Coutant 0:c0f3bbab73d2 131 void HDMI_IO_Delay(uint32_t Delay);
Jerome Coutant 0:c0f3bbab73d2 132 void HDMI_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
Jerome Coutant 0:c0f3bbab73d2 133 uint8_t HDMI_IO_Read(uint8_t Addr, uint8_t Reg);
Jerome Coutant 0:c0f3bbab73d2 134
Jerome Coutant 0:c0f3bbab73d2 135 /* I2C EEPROM IO function */
Jerome Coutant 0:c0f3bbab73d2 136 void EEPROM_IO_Init(void);
Jerome Coutant 0:c0f3bbab73d2 137 HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize);
Jerome Coutant 0:c0f3bbab73d2 138 HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize);
Jerome Coutant 0:c0f3bbab73d2 139 HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials);
Jerome Coutant 0:c0f3bbab73d2 140
Jerome Coutant 0:c0f3bbab73d2 141 /* TouchScreen (TS) IO functions */
Jerome Coutant 0:c0f3bbab73d2 142 void TS_IO_Init(void);
Jerome Coutant 0:c0f3bbab73d2 143 void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
Jerome Coutant 0:c0f3bbab73d2 144 uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg);
Jerome Coutant 0:c0f3bbab73d2 145 uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
Jerome Coutant 0:c0f3bbab73d2 146 void TS_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
Jerome Coutant 0:c0f3bbab73d2 147 void TS_IO_Delay(uint32_t Delay);
Jerome Coutant 0:c0f3bbab73d2 148
Jerome Coutant 0:c0f3bbab73d2 149 /* LCD Display IO functions */
Jerome Coutant 0:c0f3bbab73d2 150 void OTM8009A_IO_Delay(uint32_t Delay);
Jerome Coutant 0:c0f3bbab73d2 151 /**
Jerome Coutant 0:c0f3bbab73d2 152 * @}
Jerome Coutant 0:c0f3bbab73d2 153 */
Jerome Coutant 0:c0f3bbab73d2 154
Jerome Coutant 1:3e58f8a39705 155 /** @defgroup STM32F769I_DISCOVERY_BSP_Public_Functions BSP Public Functions
Jerome Coutant 0:c0f3bbab73d2 156 * @{
Jerome Coutant 0:c0f3bbab73d2 157 */
Jerome Coutant 0:c0f3bbab73d2 158
Jerome Coutant 0:c0f3bbab73d2 159 /**
Jerome Coutant 0:c0f3bbab73d2 160 * @brief This method returns the STM32F769I Discovery BSP Driver revision
Jerome Coutant 0:c0f3bbab73d2 161 * @retval version: 0xXYZR (8bits for each decimal, R for RC)
Jerome Coutant 0:c0f3bbab73d2 162 */
Jerome Coutant 0:c0f3bbab73d2 163 uint32_t BSP_GetVersion(void)
Jerome Coutant 0:c0f3bbab73d2 164 {
Jerome Coutant 0:c0f3bbab73d2 165 return __STM32F769I_DISCOVERY_BSP_VERSION;
Jerome Coutant 0:c0f3bbab73d2 166 }
Jerome Coutant 0:c0f3bbab73d2 167
Jerome Coutant 0:c0f3bbab73d2 168 /**
Jerome Coutant 0:c0f3bbab73d2 169 * @brief Configures LED GPIO.
Jerome Coutant 0:c0f3bbab73d2 170 * @param Led: LED to be configured.
Jerome Coutant 0:c0f3bbab73d2 171 * This parameter can be one of the following values:
Jerome Coutant 0:c0f3bbab73d2 172 * @arg LED1
Jerome Coutant 0:c0f3bbab73d2 173 * @arg LED2
Jerome Coutant 0:c0f3bbab73d2 174 * @retval None
Jerome Coutant 0:c0f3bbab73d2 175 */
Jerome Coutant 0:c0f3bbab73d2 176 void BSP_LED_Init(Led_TypeDef Led)
Jerome Coutant 0:c0f3bbab73d2 177 {
Jerome Coutant 0:c0f3bbab73d2 178 GPIO_InitTypeDef gpio_init_structure;
Jerome Coutant 0:c0f3bbab73d2 179
Jerome Coutant 0:c0f3bbab73d2 180 LEDx_GPIO_CLK_ENABLE();
Jerome Coutant 0:c0f3bbab73d2 181 /* Configure the GPIO_LED pin */
Jerome Coutant 0:c0f3bbab73d2 182 gpio_init_structure.Pin = GPIO_PIN[Led];
Jerome Coutant 0:c0f3bbab73d2 183 gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
Jerome Coutant 0:c0f3bbab73d2 184 gpio_init_structure.Pull = GPIO_PULLUP;
Jerome Coutant 0:c0f3bbab73d2 185 gpio_init_structure.Speed = GPIO_SPEED_HIGH;
Jerome Coutant 0:c0f3bbab73d2 186
Jerome Coutant 0:c0f3bbab73d2 187 HAL_GPIO_Init(GPIO_PORT[Led], &gpio_init_structure);
Jerome Coutant 0:c0f3bbab73d2 188
Jerome Coutant 0:c0f3bbab73d2 189 }
Jerome Coutant 0:c0f3bbab73d2 190
Jerome Coutant 0:c0f3bbab73d2 191
Jerome Coutant 0:c0f3bbab73d2 192 /**
Jerome Coutant 0:c0f3bbab73d2 193 * @brief DeInit LEDs.
Jerome Coutant 0:c0f3bbab73d2 194 * @param Led: LED to be configured.
Jerome Coutant 0:c0f3bbab73d2 195 * This parameter can be one of the following values:
Jerome Coutant 0:c0f3bbab73d2 196 * @arg LED1
Jerome Coutant 0:c0f3bbab73d2 197 * @arg LED2
Jerome Coutant 0:c0f3bbab73d2 198 * @note Led DeInit does not disable the GPIO clock
Jerome Coutant 0:c0f3bbab73d2 199 * @retval None
Jerome Coutant 0:c0f3bbab73d2 200 */
Jerome Coutant 0:c0f3bbab73d2 201 void BSP_LED_DeInit(Led_TypeDef Led)
Jerome Coutant 0:c0f3bbab73d2 202 {
Jerome Coutant 0:c0f3bbab73d2 203 GPIO_InitTypeDef gpio_init_structure;
Jerome Coutant 0:c0f3bbab73d2 204
Jerome Coutant 0:c0f3bbab73d2 205 /* DeInit the GPIO_LED pin */
Jerome Coutant 0:c0f3bbab73d2 206 gpio_init_structure.Pin = GPIO_PIN[Led];
Jerome Coutant 0:c0f3bbab73d2 207
Jerome Coutant 0:c0f3bbab73d2 208 /* Turn off LED */
Jerome Coutant 0:c0f3bbab73d2 209 HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_RESET);
Jerome Coutant 0:c0f3bbab73d2 210 HAL_GPIO_DeInit(GPIO_PORT[Led], gpio_init_structure.Pin);
Jerome Coutant 0:c0f3bbab73d2 211 }
Jerome Coutant 0:c0f3bbab73d2 212
Jerome Coutant 0:c0f3bbab73d2 213 /**
Jerome Coutant 0:c0f3bbab73d2 214 * @brief Turns selected LED On.
Jerome Coutant 0:c0f3bbab73d2 215 * @param Led: LED to be set on
Jerome Coutant 0:c0f3bbab73d2 216 * This parameter can be one of the following values:
Jerome Coutant 0:c0f3bbab73d2 217 * @arg LED1
Jerome Coutant 0:c0f3bbab73d2 218 * @arg LED2
Jerome Coutant 0:c0f3bbab73d2 219 * @retval None
Jerome Coutant 0:c0f3bbab73d2 220 */
Jerome Coutant 0:c0f3bbab73d2 221 void BSP_LED_On(Led_TypeDef Led)
Jerome Coutant 0:c0f3bbab73d2 222 {
Jerome Coutant 0:c0f3bbab73d2 223 HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_SET);
Jerome Coutant 0:c0f3bbab73d2 224 }
Jerome Coutant 0:c0f3bbab73d2 225
Jerome Coutant 0:c0f3bbab73d2 226 /**
Jerome Coutant 0:c0f3bbab73d2 227 * @brief Turns selected LED Off.
Jerome Coutant 0:c0f3bbab73d2 228 * @param Led: LED to be set off
Jerome Coutant 0:c0f3bbab73d2 229 * This parameter can be one of the following values:
Jerome Coutant 0:c0f3bbab73d2 230 * @arg LED1
Jerome Coutant 0:c0f3bbab73d2 231 * @arg LED2
Jerome Coutant 0:c0f3bbab73d2 232 * @retval None
Jerome Coutant 0:c0f3bbab73d2 233 */
Jerome Coutant 0:c0f3bbab73d2 234 void BSP_LED_Off(Led_TypeDef Led)
Jerome Coutant 0:c0f3bbab73d2 235 {
Jerome Coutant 0:c0f3bbab73d2 236 HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_RESET);
Jerome Coutant 0:c0f3bbab73d2 237 }
Jerome Coutant 0:c0f3bbab73d2 238
Jerome Coutant 0:c0f3bbab73d2 239 /**
Jerome Coutant 0:c0f3bbab73d2 240 * @brief Toggles the selected LED.
Jerome Coutant 0:c0f3bbab73d2 241 * @param Led: LED to be toggled
Jerome Coutant 0:c0f3bbab73d2 242 * This parameter can be one of the following values:
Jerome Coutant 0:c0f3bbab73d2 243 * @arg LED1
Jerome Coutant 0:c0f3bbab73d2 244 * @arg LED2
Jerome Coutant 0:c0f3bbab73d2 245 * @retval None
Jerome Coutant 0:c0f3bbab73d2 246 */
Jerome Coutant 0:c0f3bbab73d2 247 void BSP_LED_Toggle(Led_TypeDef Led)
Jerome Coutant 0:c0f3bbab73d2 248 {
Jerome Coutant 0:c0f3bbab73d2 249 HAL_GPIO_TogglePin(GPIO_PORT[Led], GPIO_PIN[Led]);
Jerome Coutant 0:c0f3bbab73d2 250 }
Jerome Coutant 0:c0f3bbab73d2 251
Jerome Coutant 0:c0f3bbab73d2 252 /**
Jerome Coutant 0:c0f3bbab73d2 253 * @brief Configures button GPIO and EXTI Line.
Jerome Coutant 0:c0f3bbab73d2 254 * @param Button: Button to be configured
Jerome Coutant 0:c0f3bbab73d2 255 * This parameter can be one of the following values:
Jerome Coutant 0:c0f3bbab73d2 256 * @arg BUTTON_WAKEUP: Wakeup Push Button
Jerome Coutant 0:c0f3bbab73d2 257 * @arg BUTTON_USER: User Push Button
Jerome Coutant 0:c0f3bbab73d2 258 * @param Button_Mode: Button mode
Jerome Coutant 0:c0f3bbab73d2 259 * This parameter can be one of the following values:
Jerome Coutant 0:c0f3bbab73d2 260 * @arg BUTTON_MODE_GPIO: Button will be used as simple IO
Jerome Coutant 0:c0f3bbab73d2 261 * @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line
Jerome Coutant 0:c0f3bbab73d2 262 * with interrupt generation capability
Jerome Coutant 0:c0f3bbab73d2 263 * @retval None
Jerome Coutant 0:c0f3bbab73d2 264 */
Jerome Coutant 0:c0f3bbab73d2 265 void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode)
Jerome Coutant 0:c0f3bbab73d2 266 {
Jerome Coutant 0:c0f3bbab73d2 267 GPIO_InitTypeDef gpio_init_structure;
Jerome Coutant 0:c0f3bbab73d2 268
Jerome Coutant 0:c0f3bbab73d2 269 /* Enable the BUTTON clock */
Jerome Coutant 0:c0f3bbab73d2 270 BUTTON_GPIO_CLK_ENABLE();
Jerome Coutant 0:c0f3bbab73d2 271
Jerome Coutant 0:c0f3bbab73d2 272 if(Button_Mode == BUTTON_MODE_GPIO)
Jerome Coutant 0:c0f3bbab73d2 273 {
Jerome Coutant 0:c0f3bbab73d2 274 /* Configure Button pin as input */
Jerome Coutant 0:c0f3bbab73d2 275 gpio_init_structure.Pin = BUTTON_PIN[Button];
Jerome Coutant 0:c0f3bbab73d2 276 gpio_init_structure.Mode = GPIO_MODE_INPUT;
Jerome Coutant 0:c0f3bbab73d2 277 gpio_init_structure.Pull = GPIO_NOPULL;
Jerome Coutant 0:c0f3bbab73d2 278 gpio_init_structure.Speed = GPIO_SPEED_FAST;
Jerome Coutant 0:c0f3bbab73d2 279 HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
Jerome Coutant 0:c0f3bbab73d2 280 }
Jerome Coutant 0:c0f3bbab73d2 281
Jerome Coutant 0:c0f3bbab73d2 282 if(Button_Mode == BUTTON_MODE_EXTI)
Jerome Coutant 0:c0f3bbab73d2 283 {
Jerome Coutant 0:c0f3bbab73d2 284 /* Configure Button pin as input with External interrupt */
Jerome Coutant 0:c0f3bbab73d2 285 gpio_init_structure.Pin = BUTTON_PIN[Button];
Jerome Coutant 0:c0f3bbab73d2 286 gpio_init_structure.Pull = GPIO_NOPULL;
Jerome Coutant 0:c0f3bbab73d2 287 gpio_init_structure.Speed = GPIO_SPEED_FAST;
Jerome Coutant 0:c0f3bbab73d2 288
Jerome Coutant 0:c0f3bbab73d2 289 gpio_init_structure.Mode = GPIO_MODE_IT_RISING;
Jerome Coutant 0:c0f3bbab73d2 290
Jerome Coutant 0:c0f3bbab73d2 291 HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
Jerome Coutant 0:c0f3bbab73d2 292
Jerome Coutant 0:c0f3bbab73d2 293 /* Enable and set Button EXTI Interrupt to the lowest priority */
Jerome Coutant 0:c0f3bbab73d2 294 HAL_NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x0F, 0x00);
Jerome Coutant 0:c0f3bbab73d2 295 HAL_NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));
Jerome Coutant 0:c0f3bbab73d2 296 }
Jerome Coutant 0:c0f3bbab73d2 297 }
Jerome Coutant 0:c0f3bbab73d2 298
Jerome Coutant 0:c0f3bbab73d2 299 /**
Jerome Coutant 0:c0f3bbab73d2 300 * @brief Push Button DeInit.
Jerome Coutant 0:c0f3bbab73d2 301 * @param Button: Button to be configured
Jerome Coutant 0:c0f3bbab73d2 302 * This parameter can be one of the following values:
Jerome Coutant 0:c0f3bbab73d2 303 * @arg BUTTON_WAKEUP: Wakeup Push Button
Jerome Coutant 0:c0f3bbab73d2 304 * @arg BUTTON_USER: User Push Button
Jerome Coutant 0:c0f3bbab73d2 305 * @note PB DeInit does not disable the GPIO clock
Jerome Coutant 0:c0f3bbab73d2 306 * @retval None
Jerome Coutant 0:c0f3bbab73d2 307 */
Jerome Coutant 0:c0f3bbab73d2 308 void BSP_PB_DeInit(Button_TypeDef Button)
Jerome Coutant 0:c0f3bbab73d2 309 {
Jerome Coutant 0:c0f3bbab73d2 310 GPIO_InitTypeDef gpio_init_structure;
Jerome Coutant 0:c0f3bbab73d2 311
Jerome Coutant 0:c0f3bbab73d2 312 gpio_init_structure.Pin = BUTTON_PIN[Button];
Jerome Coutant 0:c0f3bbab73d2 313 HAL_NVIC_DisableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));
Jerome Coutant 0:c0f3bbab73d2 314 HAL_GPIO_DeInit(BUTTON_PORT[Button], gpio_init_structure.Pin);
Jerome Coutant 0:c0f3bbab73d2 315 }
Jerome Coutant 0:c0f3bbab73d2 316
Jerome Coutant 0:c0f3bbab73d2 317
Jerome Coutant 0:c0f3bbab73d2 318 /**
Jerome Coutant 0:c0f3bbab73d2 319 * @brief Returns the selected button state.
Jerome Coutant 0:c0f3bbab73d2 320 * @param Button: Button to be checked
Jerome Coutant 0:c0f3bbab73d2 321 * This parameter can be one of the following values:
Jerome Coutant 0:c0f3bbab73d2 322 * @arg BUTTON_WAKEUP: Wakeup Push Button
Jerome Coutant 0:c0f3bbab73d2 323 * @arg BUTTON_USER: User Push Button
Jerome Coutant 0:c0f3bbab73d2 324 * @retval The Button GPIO pin value
Jerome Coutant 0:c0f3bbab73d2 325 */
Jerome Coutant 0:c0f3bbab73d2 326 uint32_t BSP_PB_GetState(Button_TypeDef Button)
Jerome Coutant 0:c0f3bbab73d2 327 {
Jerome Coutant 0:c0f3bbab73d2 328 return HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]);
Jerome Coutant 0:c0f3bbab73d2 329 }
Jerome Coutant 0:c0f3bbab73d2 330
Jerome Coutant 0:c0f3bbab73d2 331 /**
Jerome Coutant 0:c0f3bbab73d2 332 * @}
Jerome Coutant 0:c0f3bbab73d2 333 */
Jerome Coutant 0:c0f3bbab73d2 334
Jerome Coutant 1:3e58f8a39705 335 /** @defgroup STM32F769I_DISCOVERY_LOW_LEVEL_Private_Functions STM32F769I_DISCOVERY_LOW_LEVEL Private Functions
Jerome Coutant 0:c0f3bbab73d2 336 * @{
Jerome Coutant 0:c0f3bbab73d2 337 */
Jerome Coutant 0:c0f3bbab73d2 338
Jerome Coutant 0:c0f3bbab73d2 339
Jerome Coutant 0:c0f3bbab73d2 340 /*******************************************************************************
Jerome Coutant 0:c0f3bbab73d2 341 BUS OPERATIONS
Jerome Coutant 0:c0f3bbab73d2 342 *******************************************************************************/
Jerome Coutant 0:c0f3bbab73d2 343
Jerome Coutant 0:c0f3bbab73d2 344 /******************************* I2C Routines *********************************/
Jerome Coutant 0:c0f3bbab73d2 345 /**
Jerome Coutant 0:c0f3bbab73d2 346 * @brief Initializes I2C MSP.
Jerome Coutant 0:c0f3bbab73d2 347 * @param i2c_handler : I2C handler
Jerome Coutant 0:c0f3bbab73d2 348 * @retval None
Jerome Coutant 0:c0f3bbab73d2 349 */
Jerome Coutant 0:c0f3bbab73d2 350 static void I2Cx_MspInit(I2C_HandleTypeDef *i2c_handler)
Jerome Coutant 0:c0f3bbab73d2 351 {
Jerome Coutant 0:c0f3bbab73d2 352 GPIO_InitTypeDef gpio_init_structure;
Jerome Coutant 0:c0f3bbab73d2 353
Jerome Coutant 0:c0f3bbab73d2 354 if (i2c_handler == (I2C_HandleTypeDef*)(&hI2cAudioHandler))
Jerome Coutant 0:c0f3bbab73d2 355 {
Jerome Coutant 0:c0f3bbab73d2 356 /*** Configure the GPIOs ***/
Jerome Coutant 0:c0f3bbab73d2 357 /* Enable GPIO clock */
Jerome Coutant 0:c0f3bbab73d2 358 DISCOVERY_AUDIO_I2Cx_SCL_GPIO_CLK_ENABLE();
Jerome Coutant 0:c0f3bbab73d2 359 DISCOVERY_AUDIO_I2Cx_SDA_GPIO_CLK_ENABLE();
Jerome Coutant 0:c0f3bbab73d2 360 /* Configure I2C Tx as alternate function */
Jerome Coutant 0:c0f3bbab73d2 361 gpio_init_structure.Pin = DISCOVERY_AUDIO_I2Cx_SCL_PIN;
Jerome Coutant 0:c0f3bbab73d2 362 gpio_init_structure.Mode = GPIO_MODE_AF_OD;
Jerome Coutant 0:c0f3bbab73d2 363 gpio_init_structure.Pull = GPIO_NOPULL;
Jerome Coutant 0:c0f3bbab73d2 364 gpio_init_structure.Speed = GPIO_SPEED_FAST;
Jerome Coutant 0:c0f3bbab73d2 365 gpio_init_structure.Alternate = DISCOVERY_AUDIO_I2Cx_SCL_AF;
Jerome Coutant 0:c0f3bbab73d2 366 HAL_GPIO_Init(DISCOVERY_AUDIO_I2Cx_SCL_GPIO_PORT, &gpio_init_structure);
Jerome Coutant 0:c0f3bbab73d2 367
Jerome Coutant 0:c0f3bbab73d2 368 /* Configure I2C Rx as alternate function */
Jerome Coutant 0:c0f3bbab73d2 369 gpio_init_structure.Pin = DISCOVERY_AUDIO_I2Cx_SDA_PIN;
Jerome Coutant 0:c0f3bbab73d2 370 gpio_init_structure.Alternate = DISCOVERY_AUDIO_I2Cx_SDA_AF;
Jerome Coutant 0:c0f3bbab73d2 371 HAL_GPIO_Init(DISCOVERY_AUDIO_I2Cx_SDA_GPIO_PORT, &gpio_init_structure);
Jerome Coutant 0:c0f3bbab73d2 372
Jerome Coutant 0:c0f3bbab73d2 373 /*** Configure the I2C peripheral ***/
Jerome Coutant 0:c0f3bbab73d2 374 /* Enable I2C clock */
Jerome Coutant 0:c0f3bbab73d2 375 DISCOVERY_AUDIO_I2Cx_CLK_ENABLE();
Jerome Coutant 0:c0f3bbab73d2 376
Jerome Coutant 0:c0f3bbab73d2 377 /* Force the I2C peripheral clock reset */
Jerome Coutant 0:c0f3bbab73d2 378 DISCOVERY_AUDIO_I2Cx_FORCE_RESET();
Jerome Coutant 0:c0f3bbab73d2 379
Jerome Coutant 0:c0f3bbab73d2 380 /* Release the I2C peripheral clock reset */
Jerome Coutant 0:c0f3bbab73d2 381 DISCOVERY_AUDIO_I2Cx_RELEASE_RESET();
Jerome Coutant 0:c0f3bbab73d2 382
Jerome Coutant 0:c0f3bbab73d2 383 /* Enable and set I2C1 Interrupt to a lower priority */
Jerome Coutant 0:c0f3bbab73d2 384 HAL_NVIC_SetPriority(DISCOVERY_AUDIO_I2Cx_EV_IRQn, 0x0F, 0);
Jerome Coutant 0:c0f3bbab73d2 385 HAL_NVIC_EnableIRQ(DISCOVERY_AUDIO_I2Cx_EV_IRQn);
Jerome Coutant 0:c0f3bbab73d2 386
Jerome Coutant 0:c0f3bbab73d2 387 /* Enable and set I2C1 Interrupt to a lower priority */
Jerome Coutant 0:c0f3bbab73d2 388 HAL_NVIC_SetPriority(DISCOVERY_AUDIO_I2Cx_ER_IRQn, 0x0F, 0);
Jerome Coutant 0:c0f3bbab73d2 389 HAL_NVIC_EnableIRQ(DISCOVERY_AUDIO_I2Cx_ER_IRQn);
Jerome Coutant 0:c0f3bbab73d2 390
Jerome Coutant 0:c0f3bbab73d2 391 }
Jerome Coutant 0:c0f3bbab73d2 392 else
Jerome Coutant 0:c0f3bbab73d2 393 {
Jerome Coutant 0:c0f3bbab73d2 394 /*** Configure the GPIOs ***/
Jerome Coutant 0:c0f3bbab73d2 395 /* Enable GPIO clock */
Jerome Coutant 0:c0f3bbab73d2 396 DISCOVERY_EXT_I2Cx_SCL_SDA_GPIO_CLK_ENABLE();
Jerome Coutant 0:c0f3bbab73d2 397
Jerome Coutant 0:c0f3bbab73d2 398 /* Configure I2C Tx as alternate function */
Jerome Coutant 0:c0f3bbab73d2 399 gpio_init_structure.Pin = DISCOVERY_EXT_I2Cx_SCL_PIN;
Jerome Coutant 0:c0f3bbab73d2 400 gpio_init_structure.Mode = GPIO_MODE_AF_OD;
Jerome Coutant 0:c0f3bbab73d2 401 gpio_init_structure.Pull = GPIO_NOPULL;
Jerome Coutant 0:c0f3bbab73d2 402 gpio_init_structure.Speed = GPIO_SPEED_FAST;
Jerome Coutant 0:c0f3bbab73d2 403 gpio_init_structure.Alternate = DISCOVERY_EXT_I2Cx_SCL_SDA_AF;
Jerome Coutant 0:c0f3bbab73d2 404 HAL_GPIO_Init(DISCOVERY_EXT_I2Cx_SCL_SDA_GPIO_PORT, &gpio_init_structure);
Jerome Coutant 0:c0f3bbab73d2 405
Jerome Coutant 0:c0f3bbab73d2 406 /* Configure I2C Rx as alternate function */
Jerome Coutant 0:c0f3bbab73d2 407 gpio_init_structure.Pin = DISCOVERY_EXT_I2Cx_SDA_PIN;
Jerome Coutant 0:c0f3bbab73d2 408 HAL_GPIO_Init(DISCOVERY_EXT_I2Cx_SCL_SDA_GPIO_PORT, &gpio_init_structure);
Jerome Coutant 0:c0f3bbab73d2 409
Jerome Coutant 0:c0f3bbab73d2 410 /*** Configure the I2C peripheral ***/
Jerome Coutant 0:c0f3bbab73d2 411 /* Enable I2C clock */
Jerome Coutant 0:c0f3bbab73d2 412 DISCOVERY_EXT_I2Cx_CLK_ENABLE();
Jerome Coutant 0:c0f3bbab73d2 413
Jerome Coutant 0:c0f3bbab73d2 414 /* Force the I2C peripheral clock reset */
Jerome Coutant 0:c0f3bbab73d2 415 DISCOVERY_EXT_I2Cx_FORCE_RESET();
Jerome Coutant 0:c0f3bbab73d2 416
Jerome Coutant 0:c0f3bbab73d2 417 /* Release the I2C peripheral clock reset */
Jerome Coutant 0:c0f3bbab73d2 418 DISCOVERY_EXT_I2Cx_RELEASE_RESET();
Jerome Coutant 0:c0f3bbab73d2 419
Jerome Coutant 0:c0f3bbab73d2 420 /* Enable and set I2C1 Interrupt to a lower priority */
Jerome Coutant 0:c0f3bbab73d2 421 HAL_NVIC_SetPriority(DISCOVERY_EXT_I2Cx_EV_IRQn, 0x0F, 0);
Jerome Coutant 0:c0f3bbab73d2 422 HAL_NVIC_EnableIRQ(DISCOVERY_EXT_I2Cx_EV_IRQn);
Jerome Coutant 0:c0f3bbab73d2 423
Jerome Coutant 0:c0f3bbab73d2 424 /* Enable and set I2C1 Interrupt to a lower priority */
Jerome Coutant 0:c0f3bbab73d2 425 HAL_NVIC_SetPriority(DISCOVERY_EXT_I2Cx_ER_IRQn, 0x0F, 0);
Jerome Coutant 0:c0f3bbab73d2 426 HAL_NVIC_EnableIRQ(DISCOVERY_EXT_I2Cx_ER_IRQn);
Jerome Coutant 0:c0f3bbab73d2 427 }
Jerome Coutant 0:c0f3bbab73d2 428 }
Jerome Coutant 0:c0f3bbab73d2 429
Jerome Coutant 0:c0f3bbab73d2 430 /**
Jerome Coutant 0:c0f3bbab73d2 431 * @brief Initializes I2C HAL.
Jerome Coutant 0:c0f3bbab73d2 432 * @param i2c_handler : I2C handler
Jerome Coutant 0:c0f3bbab73d2 433 * @retval None
Jerome Coutant 0:c0f3bbab73d2 434 */
Jerome Coutant 0:c0f3bbab73d2 435 static void I2Cx_Init(I2C_HandleTypeDef *i2c_handler)
Jerome Coutant 0:c0f3bbab73d2 436 {
Jerome Coutant 0:c0f3bbab73d2 437 if(HAL_I2C_GetState(i2c_handler) == HAL_I2C_STATE_RESET)
Jerome Coutant 0:c0f3bbab73d2 438 {
Jerome Coutant 0:c0f3bbab73d2 439 if (i2c_handler == (I2C_HandleTypeDef*)(&hI2cAudioHandler))
Jerome Coutant 0:c0f3bbab73d2 440 {
Jerome Coutant 0:c0f3bbab73d2 441 /* Audio and LCD I2C configuration */
Jerome Coutant 0:c0f3bbab73d2 442 i2c_handler->Instance = DISCOVERY_AUDIO_I2Cx;
Jerome Coutant 0:c0f3bbab73d2 443 }
Jerome Coutant 0:c0f3bbab73d2 444 else
Jerome Coutant 0:c0f3bbab73d2 445 {
Jerome Coutant 0:c0f3bbab73d2 446 /* External, camera and Arduino connector I2C configuration */
Jerome Coutant 0:c0f3bbab73d2 447 i2c_handler->Instance = DISCOVERY_EXT_I2Cx;
Jerome Coutant 0:c0f3bbab73d2 448 }
Jerome Coutant 0:c0f3bbab73d2 449 i2c_handler->Init.Timing = DISCOVERY_I2Cx_TIMING;
Jerome Coutant 0:c0f3bbab73d2 450 i2c_handler->Init.OwnAddress1 = 0;
Jerome Coutant 0:c0f3bbab73d2 451 i2c_handler->Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
Jerome Coutant 0:c0f3bbab73d2 452 i2c_handler->Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
Jerome Coutant 0:c0f3bbab73d2 453 i2c_handler->Init.OwnAddress2 = 0;
Jerome Coutant 0:c0f3bbab73d2 454 i2c_handler->Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
Jerome Coutant 0:c0f3bbab73d2 455 i2c_handler->Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
Jerome Coutant 0:c0f3bbab73d2 456
Jerome Coutant 0:c0f3bbab73d2 457 /* Init the I2C */
Jerome Coutant 0:c0f3bbab73d2 458 I2Cx_MspInit(i2c_handler);
Jerome Coutant 0:c0f3bbab73d2 459 HAL_I2C_Init(i2c_handler);
Jerome Coutant 0:c0f3bbab73d2 460 }
Jerome Coutant 0:c0f3bbab73d2 461 }
Jerome Coutant 0:c0f3bbab73d2 462
Jerome Coutant 0:c0f3bbab73d2 463 /**
Jerome Coutant 0:c0f3bbab73d2 464 * @brief Reads multiple data.
Jerome Coutant 0:c0f3bbab73d2 465 * @param i2c_handler : I2C handler
Jerome Coutant 0:c0f3bbab73d2 466 * @param Addr: I2C address
Jerome Coutant 0:c0f3bbab73d2 467 * @param Reg: Reg address
Jerome Coutant 0:c0f3bbab73d2 468 * @param MemAddress: memory address
Jerome Coutant 0:c0f3bbab73d2 469 * @param Buffer: Pointer to data buffer
Jerome Coutant 0:c0f3bbab73d2 470 * @param Length: Length of the data
Jerome Coutant 0:c0f3bbab73d2 471 * @retval HAL status
Jerome Coutant 0:c0f3bbab73d2 472 */
Jerome Coutant 0:c0f3bbab73d2 473 static HAL_StatusTypeDef I2Cx_ReadMultiple(I2C_HandleTypeDef *i2c_handler, uint8_t Addr, uint16_t Reg, uint16_t MemAddress, uint8_t *Buffer, uint16_t Length)
Jerome Coutant 0:c0f3bbab73d2 474 {
Jerome Coutant 0:c0f3bbab73d2 475 HAL_StatusTypeDef status = HAL_OK;
Jerome Coutant 0:c0f3bbab73d2 476
Jerome Coutant 0:c0f3bbab73d2 477 status = HAL_I2C_Mem_Read(i2c_handler, Addr, (uint16_t)Reg, MemAddress, Buffer, Length, 1000);
Jerome Coutant 0:c0f3bbab73d2 478
Jerome Coutant 0:c0f3bbab73d2 479 /* Check the communication status */
Jerome Coutant 0:c0f3bbab73d2 480 if(status != HAL_OK)
Jerome Coutant 0:c0f3bbab73d2 481 {
Jerome Coutant 0:c0f3bbab73d2 482 /* I2C error occured */
Jerome Coutant 0:c0f3bbab73d2 483 I2Cx_Error(i2c_handler, Addr);
Jerome Coutant 0:c0f3bbab73d2 484 }
Jerome Coutant 0:c0f3bbab73d2 485 return status;
Jerome Coutant 0:c0f3bbab73d2 486 }
Jerome Coutant 0:c0f3bbab73d2 487
Jerome Coutant 0:c0f3bbab73d2 488
Jerome Coutant 0:c0f3bbab73d2 489 /**
Jerome Coutant 0:c0f3bbab73d2 490 * @brief Writes a value in a register of the device through BUS in using DMA mode.
Jerome Coutant 0:c0f3bbab73d2 491 * @param i2c_handler : I2C handler
Jerome Coutant 0:c0f3bbab73d2 492 * @param Addr: Device address on BUS Bus.
Jerome Coutant 0:c0f3bbab73d2 493 * @param Reg: The target register address to write
Jerome Coutant 0:c0f3bbab73d2 494 * @param MemAddress: memory address
Jerome Coutant 0:c0f3bbab73d2 495 * @param Buffer: The target register value to be written
Jerome Coutant 0:c0f3bbab73d2 496 * @param Length: buffer size to be written
Jerome Coutant 0:c0f3bbab73d2 497 * @retval HAL status
Jerome Coutant 0:c0f3bbab73d2 498 */
Jerome Coutant 0:c0f3bbab73d2 499 static HAL_StatusTypeDef I2Cx_WriteMultiple(I2C_HandleTypeDef *i2c_handler, uint8_t Addr, uint16_t Reg, uint16_t MemAddress, uint8_t *Buffer, uint16_t Length)
Jerome Coutant 0:c0f3bbab73d2 500 {
Jerome Coutant 0:c0f3bbab73d2 501 HAL_StatusTypeDef status = HAL_OK;
Jerome Coutant 0:c0f3bbab73d2 502
Jerome Coutant 0:c0f3bbab73d2 503 status = HAL_I2C_Mem_Write(i2c_handler, Addr, (uint16_t)Reg, MemAddress, Buffer, Length, 1000);
Jerome Coutant 0:c0f3bbab73d2 504
Jerome Coutant 0:c0f3bbab73d2 505 /* Check the communication status */
Jerome Coutant 0:c0f3bbab73d2 506 if(status != HAL_OK)
Jerome Coutant 0:c0f3bbab73d2 507 {
Jerome Coutant 0:c0f3bbab73d2 508 /* Re-Initiaize the I2C Bus */
Jerome Coutant 0:c0f3bbab73d2 509 I2Cx_Error(i2c_handler, Addr);
Jerome Coutant 0:c0f3bbab73d2 510 }
Jerome Coutant 0:c0f3bbab73d2 511 return status;
Jerome Coutant 0:c0f3bbab73d2 512 }
Jerome Coutant 0:c0f3bbab73d2 513
Jerome Coutant 0:c0f3bbab73d2 514 /**
Jerome Coutant 0:c0f3bbab73d2 515 * @brief Checks if target device is ready for communication.
Jerome Coutant 0:c0f3bbab73d2 516 * @note This function is used with Memory devices
Jerome Coutant 0:c0f3bbab73d2 517 * @param i2c_handler : I2C handler
Jerome Coutant 0:c0f3bbab73d2 518 * @param DevAddress: Target device address
Jerome Coutant 0:c0f3bbab73d2 519 * @param Trials: Number of trials
Jerome Coutant 0:c0f3bbab73d2 520 * @retval HAL status
Jerome Coutant 0:c0f3bbab73d2 521 */
Jerome Coutant 0:c0f3bbab73d2 522 static HAL_StatusTypeDef I2Cx_IsDeviceReady(I2C_HandleTypeDef *i2c_handler, uint16_t DevAddress, uint32_t Trials)
Jerome Coutant 0:c0f3bbab73d2 523 {
Jerome Coutant 0:c0f3bbab73d2 524 return (HAL_I2C_IsDeviceReady(i2c_handler, DevAddress, Trials, 1000));
Jerome Coutant 0:c0f3bbab73d2 525 }
Jerome Coutant 0:c0f3bbab73d2 526
Jerome Coutant 0:c0f3bbab73d2 527 /**
Jerome Coutant 0:c0f3bbab73d2 528 * @brief Manages error callback by re-initializing I2C.
Jerome Coutant 0:c0f3bbab73d2 529 * @param i2c_handler : I2C handler
Jerome Coutant 0:c0f3bbab73d2 530 * @param Addr: I2C Address
Jerome Coutant 0:c0f3bbab73d2 531 * @retval None
Jerome Coutant 0:c0f3bbab73d2 532 */
Jerome Coutant 0:c0f3bbab73d2 533 static void I2Cx_Error(I2C_HandleTypeDef *i2c_handler, uint8_t Addr)
Jerome Coutant 0:c0f3bbab73d2 534 {
Jerome Coutant 0:c0f3bbab73d2 535 /* De-initialize the I2C communication bus */
Jerome Coutant 0:c0f3bbab73d2 536 HAL_I2C_DeInit(i2c_handler);
Jerome Coutant 0:c0f3bbab73d2 537
Jerome Coutant 0:c0f3bbab73d2 538 /* Re-Initialize the I2C communication bus */
Jerome Coutant 0:c0f3bbab73d2 539 I2Cx_Init(i2c_handler);
Jerome Coutant 0:c0f3bbab73d2 540 }
Jerome Coutant 0:c0f3bbab73d2 541
Jerome Coutant 0:c0f3bbab73d2 542 /**
Jerome Coutant 0:c0f3bbab73d2 543 * @}
Jerome Coutant 0:c0f3bbab73d2 544 */
Jerome Coutant 0:c0f3bbab73d2 545
Jerome Coutant 0:c0f3bbab73d2 546 /*******************************************************************************
Jerome Coutant 0:c0f3bbab73d2 547 LINK OPERATIONS
Jerome Coutant 0:c0f3bbab73d2 548 *******************************************************************************/
Jerome Coutant 0:c0f3bbab73d2 549
Jerome Coutant 0:c0f3bbab73d2 550 /********************************* LINK AUDIO *********************************/
Jerome Coutant 0:c0f3bbab73d2 551
Jerome Coutant 0:c0f3bbab73d2 552 /**
Jerome Coutant 0:c0f3bbab73d2 553 * @brief Initializes Audio low level.
Jerome Coutant 0:c0f3bbab73d2 554 */
Jerome Coutant 0:c0f3bbab73d2 555 void AUDIO_IO_Init(void)
Jerome Coutant 0:c0f3bbab73d2 556 {
Jerome Coutant 0:c0f3bbab73d2 557 I2Cx_Init(&hI2cAudioHandler);
Jerome Coutant 0:c0f3bbab73d2 558 }
Jerome Coutant 0:c0f3bbab73d2 559
Jerome Coutant 0:c0f3bbab73d2 560 /**
Jerome Coutant 0:c0f3bbab73d2 561 * @brief DeInitializes Audio low level.
Jerome Coutant 0:c0f3bbab73d2 562 */
Jerome Coutant 0:c0f3bbab73d2 563 void AUDIO_IO_DeInit(void)
Jerome Coutant 0:c0f3bbab73d2 564 {
Jerome Coutant 0:c0f3bbab73d2 565
Jerome Coutant 0:c0f3bbab73d2 566 }
Jerome Coutant 0:c0f3bbab73d2 567
Jerome Coutant 0:c0f3bbab73d2 568 /**
Jerome Coutant 0:c0f3bbab73d2 569 * @brief Writes a single data.
Jerome Coutant 0:c0f3bbab73d2 570 * @param Addr: I2C address
Jerome Coutant 0:c0f3bbab73d2 571 * @param Reg: Reg address
Jerome Coutant 0:c0f3bbab73d2 572 * @param Value: Data to be written
Jerome Coutant 0:c0f3bbab73d2 573 * @retval None
Jerome Coutant 0:c0f3bbab73d2 574 */
Jerome Coutant 0:c0f3bbab73d2 575 void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value)
Jerome Coutant 0:c0f3bbab73d2 576 {
Jerome Coutant 0:c0f3bbab73d2 577 uint16_t tmp = Value;
Jerome Coutant 0:c0f3bbab73d2 578
Jerome Coutant 0:c0f3bbab73d2 579 Value = ((uint16_t)(tmp >> 8) & 0x00FF);
Jerome Coutant 0:c0f3bbab73d2 580
Jerome Coutant 0:c0f3bbab73d2 581 Value |= ((uint16_t)(tmp << 8)& 0xFF00);
Jerome Coutant 0:c0f3bbab73d2 582
Jerome Coutant 0:c0f3bbab73d2 583 I2Cx_WriteMultiple(&hI2cAudioHandler, Addr, Reg, I2C_MEMADD_SIZE_16BIT,(uint8_t*)&Value, 2);
Jerome Coutant 0:c0f3bbab73d2 584 }
Jerome Coutant 0:c0f3bbab73d2 585
Jerome Coutant 0:c0f3bbab73d2 586 /**
Jerome Coutant 0:c0f3bbab73d2 587 * @brief Reads a single data.
Jerome Coutant 0:c0f3bbab73d2 588 * @param Addr: I2C address
Jerome Coutant 0:c0f3bbab73d2 589 * @param Reg: Reg address
Jerome Coutant 0:c0f3bbab73d2 590 * @retval Data to be read
Jerome Coutant 0:c0f3bbab73d2 591 */
Jerome Coutant 0:c0f3bbab73d2 592 uint16_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg)
Jerome Coutant 0:c0f3bbab73d2 593 {
Jerome Coutant 0:c0f3bbab73d2 594 uint16_t read_value = 0, tmp = 0;
Jerome Coutant 0:c0f3bbab73d2 595
Jerome Coutant 0:c0f3bbab73d2 596 I2Cx_ReadMultiple(&hI2cAudioHandler, Addr, Reg, I2C_MEMADD_SIZE_16BIT, (uint8_t*)&read_value, 2);
Jerome Coutant 0:c0f3bbab73d2 597
Jerome Coutant 0:c0f3bbab73d2 598 tmp = ((uint16_t)(read_value >> 8) & 0x00FF);
Jerome Coutant 0:c0f3bbab73d2 599
Jerome Coutant 0:c0f3bbab73d2 600 tmp |= ((uint16_t)(read_value << 8)& 0xFF00);
Jerome Coutant 0:c0f3bbab73d2 601
Jerome Coutant 0:c0f3bbab73d2 602 read_value = tmp;
Jerome Coutant 0:c0f3bbab73d2 603
Jerome Coutant 0:c0f3bbab73d2 604 return read_value;
Jerome Coutant 0:c0f3bbab73d2 605 }
Jerome Coutant 0:c0f3bbab73d2 606
Jerome Coutant 0:c0f3bbab73d2 607 /**
Jerome Coutant 0:c0f3bbab73d2 608 * @brief AUDIO Codec delay
Jerome Coutant 0:c0f3bbab73d2 609 * @param Delay: Delay in ms
Jerome Coutant 0:c0f3bbab73d2 610 */
Jerome Coutant 0:c0f3bbab73d2 611 void AUDIO_IO_Delay(uint32_t Delay)
Jerome Coutant 0:c0f3bbab73d2 612 {
Jerome Coutant 0:c0f3bbab73d2 613 HAL_Delay(Delay);
Jerome Coutant 0:c0f3bbab73d2 614 }
Jerome Coutant 0:c0f3bbab73d2 615
Jerome Coutant 0:c0f3bbab73d2 616 /******************************** LINK I2C EEPROM *****************************/
Jerome Coutant 0:c0f3bbab73d2 617
Jerome Coutant 0:c0f3bbab73d2 618 /**
Jerome Coutant 0:c0f3bbab73d2 619 * @brief Initializes peripherals used by the I2C EEPROM driver.
Jerome Coutant 0:c0f3bbab73d2 620 */
Jerome Coutant 0:c0f3bbab73d2 621 void EEPROM_IO_Init(void)
Jerome Coutant 0:c0f3bbab73d2 622 {
Jerome Coutant 0:c0f3bbab73d2 623 I2Cx_Init(&hI2cExtHandler);
Jerome Coutant 0:c0f3bbab73d2 624 }
Jerome Coutant 0:c0f3bbab73d2 625
Jerome Coutant 0:c0f3bbab73d2 626 /**
Jerome Coutant 0:c0f3bbab73d2 627 * @brief Write data to I2C EEPROM driver in using DMA channel.
Jerome Coutant 0:c0f3bbab73d2 628 * @param DevAddress: Target device address
Jerome Coutant 0:c0f3bbab73d2 629 * @param MemAddress: Internal memory address
Jerome Coutant 0:c0f3bbab73d2 630 * @param pBuffer: Pointer to data buffer
Jerome Coutant 0:c0f3bbab73d2 631 * @param BufferSize: Amount of data to be sent
Jerome Coutant 0:c0f3bbab73d2 632 * @retval HAL status
Jerome Coutant 0:c0f3bbab73d2 633 */
Jerome Coutant 0:c0f3bbab73d2 634 HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize)
Jerome Coutant 0:c0f3bbab73d2 635 {
Jerome Coutant 0:c0f3bbab73d2 636 return (I2Cx_WriteMultiple(&hI2cExtHandler, DevAddress, MemAddress, I2C_MEMADD_SIZE_16BIT, pBuffer, BufferSize));
Jerome Coutant 0:c0f3bbab73d2 637 }
Jerome Coutant 0:c0f3bbab73d2 638
Jerome Coutant 0:c0f3bbab73d2 639 /**
Jerome Coutant 0:c0f3bbab73d2 640 * @brief Read data from I2C EEPROM driver in using DMA channel.
Jerome Coutant 0:c0f3bbab73d2 641 * @param DevAddress: Target device address
Jerome Coutant 0:c0f3bbab73d2 642 * @param MemAddress: Internal memory address
Jerome Coutant 0:c0f3bbab73d2 643 * @param pBuffer: Pointer to data buffer
Jerome Coutant 0:c0f3bbab73d2 644 * @param BufferSize: Amount of data to be read
Jerome Coutant 0:c0f3bbab73d2 645 * @retval HAL status
Jerome Coutant 0:c0f3bbab73d2 646 */
Jerome Coutant 0:c0f3bbab73d2 647 HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize)
Jerome Coutant 0:c0f3bbab73d2 648 {
Jerome Coutant 0:c0f3bbab73d2 649 return (I2Cx_ReadMultiple(&hI2cExtHandler, DevAddress, MemAddress, I2C_MEMADD_SIZE_16BIT, pBuffer, BufferSize));
Jerome Coutant 0:c0f3bbab73d2 650 }
Jerome Coutant 0:c0f3bbab73d2 651
Jerome Coutant 0:c0f3bbab73d2 652 /**
Jerome Coutant 0:c0f3bbab73d2 653 * @brief Checks if target device is ready for communication.
Jerome Coutant 0:c0f3bbab73d2 654 * @note This function is used with Memory devices
Jerome Coutant 0:c0f3bbab73d2 655 * @param DevAddress: Target device address
Jerome Coutant 0:c0f3bbab73d2 656 * @param Trials: Number of trials
Jerome Coutant 0:c0f3bbab73d2 657 * @retval HAL status
Jerome Coutant 0:c0f3bbab73d2 658 */
Jerome Coutant 0:c0f3bbab73d2 659 HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials)
Jerome Coutant 0:c0f3bbab73d2 660 {
Jerome Coutant 0:c0f3bbab73d2 661 return (I2Cx_IsDeviceReady(&hI2cExtHandler, DevAddress, Trials));
Jerome Coutant 0:c0f3bbab73d2 662 }
Jerome Coutant 0:c0f3bbab73d2 663
Jerome Coutant 0:c0f3bbab73d2 664 /******************************** LINK TS (TouchScreen) ***********************/
Jerome Coutant 0:c0f3bbab73d2 665
Jerome Coutant 0:c0f3bbab73d2 666 /**
Jerome Coutant 0:c0f3bbab73d2 667 * @brief Initializes Touchscreen low level.
Jerome Coutant 0:c0f3bbab73d2 668 * @retval None
Jerome Coutant 0:c0f3bbab73d2 669 */
Jerome Coutant 0:c0f3bbab73d2 670 void TS_IO_Init(void)
Jerome Coutant 0:c0f3bbab73d2 671 {
Jerome Coutant 0:c0f3bbab73d2 672 I2Cx_Init(&hI2cAudioHandler);
Jerome Coutant 0:c0f3bbab73d2 673 }
Jerome Coutant 0:c0f3bbab73d2 674
Jerome Coutant 0:c0f3bbab73d2 675 /**
Jerome Coutant 0:c0f3bbab73d2 676 * @brief Writes a single data.
Jerome Coutant 0:c0f3bbab73d2 677 * @param Addr: I2C address
Jerome Coutant 0:c0f3bbab73d2 678 * @param Reg: Reg address
Jerome Coutant 0:c0f3bbab73d2 679 * @param Value: Data to be written
Jerome Coutant 0:c0f3bbab73d2 680 * @retval None
Jerome Coutant 0:c0f3bbab73d2 681 */
Jerome Coutant 0:c0f3bbab73d2 682 void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value)
Jerome Coutant 0:c0f3bbab73d2 683 {
Jerome Coutant 0:c0f3bbab73d2 684 I2Cx_WriteMultiple(&hI2cAudioHandler, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT,(uint8_t*)&Value, 1);
Jerome Coutant 0:c0f3bbab73d2 685 }
Jerome Coutant 0:c0f3bbab73d2 686
Jerome Coutant 0:c0f3bbab73d2 687 /**
Jerome Coutant 0:c0f3bbab73d2 688 * @brief Reads a single data.
Jerome Coutant 0:c0f3bbab73d2 689 * @param Addr: I2C address
Jerome Coutant 0:c0f3bbab73d2 690 * @param Reg: Reg address
Jerome Coutant 0:c0f3bbab73d2 691 * @retval Data to be read
Jerome Coutant 0:c0f3bbab73d2 692 */
Jerome Coutant 0:c0f3bbab73d2 693 uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg)
Jerome Coutant 0:c0f3bbab73d2 694 {
Jerome Coutant 0:c0f3bbab73d2 695 uint8_t read_value = 0;
Jerome Coutant 0:c0f3bbab73d2 696
Jerome Coutant 0:c0f3bbab73d2 697 I2Cx_ReadMultiple(&hI2cAudioHandler, Addr, Reg, I2C_MEMADD_SIZE_8BIT, (uint8_t*)&read_value, 1);
Jerome Coutant 0:c0f3bbab73d2 698
Jerome Coutant 0:c0f3bbab73d2 699 return read_value;
Jerome Coutant 0:c0f3bbab73d2 700 }
Jerome Coutant 0:c0f3bbab73d2 701
Jerome Coutant 0:c0f3bbab73d2 702 /**
Jerome Coutant 0:c0f3bbab73d2 703 * @brief Reads multiple data with I2C communication
Jerome Coutant 0:c0f3bbab73d2 704 * channel from TouchScreen.
Jerome Coutant 0:c0f3bbab73d2 705 * @param Addr: I2C address
Jerome Coutant 0:c0f3bbab73d2 706 * @param Reg: Register address
Jerome Coutant 0:c0f3bbab73d2 707 * @param Buffer: Pointer to data buffer
Jerome Coutant 0:c0f3bbab73d2 708 * @param Length: Length of the data
Jerome Coutant 0:c0f3bbab73d2 709 * @retval Number of read data
Jerome Coutant 0:c0f3bbab73d2 710 */
Jerome Coutant 0:c0f3bbab73d2 711 uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length)
Jerome Coutant 0:c0f3bbab73d2 712 {
Jerome Coutant 0:c0f3bbab73d2 713 return I2Cx_ReadMultiple(&hI2cAudioHandler, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length);
Jerome Coutant 0:c0f3bbab73d2 714 }
Jerome Coutant 0:c0f3bbab73d2 715
Jerome Coutant 0:c0f3bbab73d2 716 /**
Jerome Coutant 0:c0f3bbab73d2 717 * @brief Writes multiple data with I2C communication
Jerome Coutant 0:c0f3bbab73d2 718 * channel from MCU to TouchScreen.
Jerome Coutant 0:c0f3bbab73d2 719 * @param Addr: I2C address
Jerome Coutant 0:c0f3bbab73d2 720 * @param Reg: Register address
Jerome Coutant 0:c0f3bbab73d2 721 * @param Buffer: Pointer to data buffer
Jerome Coutant 0:c0f3bbab73d2 722 * @param Length: Length of the data
Jerome Coutant 0:c0f3bbab73d2 723 * @retval None
Jerome Coutant 0:c0f3bbab73d2 724 */
Jerome Coutant 0:c0f3bbab73d2 725 void TS_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length)
Jerome Coutant 0:c0f3bbab73d2 726 {
Jerome Coutant 0:c0f3bbab73d2 727 I2Cx_WriteMultiple(&hI2cAudioHandler, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length);
Jerome Coutant 0:c0f3bbab73d2 728 }
Jerome Coutant 0:c0f3bbab73d2 729
Jerome Coutant 0:c0f3bbab73d2 730 /**
Jerome Coutant 0:c0f3bbab73d2 731 * @brief Delay function used in TouchScreen low level driver.
Jerome Coutant 0:c0f3bbab73d2 732 * @param Delay: Delay in ms
Jerome Coutant 0:c0f3bbab73d2 733 * @retval None
Jerome Coutant 0:c0f3bbab73d2 734 */
Jerome Coutant 0:c0f3bbab73d2 735 void TS_IO_Delay(uint32_t Delay)
Jerome Coutant 0:c0f3bbab73d2 736 {
Jerome Coutant 0:c0f3bbab73d2 737 HAL_Delay(Delay);
Jerome Coutant 0:c0f3bbab73d2 738 }
Jerome Coutant 0:c0f3bbab73d2 739
Jerome Coutant 0:c0f3bbab73d2 740 /**************************** LINK OTM8009A (Display driver) ******************/
Jerome Coutant 0:c0f3bbab73d2 741 /**
Jerome Coutant 0:c0f3bbab73d2 742 * @brief OTM8009A delay
Jerome Coutant 0:c0f3bbab73d2 743 * @param Delay: Delay in ms
Jerome Coutant 0:c0f3bbab73d2 744 */
Jerome Coutant 0:c0f3bbab73d2 745 void OTM8009A_IO_Delay(uint32_t Delay)
Jerome Coutant 0:c0f3bbab73d2 746 {
Jerome Coutant 0:c0f3bbab73d2 747 HAL_Delay(Delay);
Jerome Coutant 0:c0f3bbab73d2 748 }
Jerome Coutant 0:c0f3bbab73d2 749
Jerome Coutant 0:c0f3bbab73d2 750 /**************************** LINK ADV7533 DSI-HDMI (Display driver) **********/
Jerome Coutant 0:c0f3bbab73d2 751 /**
Jerome Coutant 0:c0f3bbab73d2 752 * @brief Initializes HDMI IO low level.
Jerome Coutant 0:c0f3bbab73d2 753 * @retval None
Jerome Coutant 0:c0f3bbab73d2 754 */
Jerome Coutant 0:c0f3bbab73d2 755 void HDMI_IO_Init(void)
Jerome Coutant 0:c0f3bbab73d2 756 {
Jerome Coutant 0:c0f3bbab73d2 757 I2Cx_Init(&hI2cAudioHandler);
Jerome Coutant 0:c0f3bbab73d2 758 }
Jerome Coutant 0:c0f3bbab73d2 759
Jerome Coutant 0:c0f3bbab73d2 760 /**
Jerome Coutant 0:c0f3bbab73d2 761 * @brief HDMI writes single data.
Jerome Coutant 0:c0f3bbab73d2 762 * @param Addr: I2C address
Jerome Coutant 0:c0f3bbab73d2 763 * @param Reg: Register address
Jerome Coutant 0:c0f3bbab73d2 764 * @param Value: Data to be written
Jerome Coutant 0:c0f3bbab73d2 765 * @retval None
Jerome Coutant 0:c0f3bbab73d2 766 */
Jerome Coutant 0:c0f3bbab73d2 767 void HDMI_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value)
Jerome Coutant 0:c0f3bbab73d2 768 {
Jerome Coutant 0:c0f3bbab73d2 769 I2Cx_WriteMultiple(&hI2cAudioHandler, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, &Value, 1);
Jerome Coutant 0:c0f3bbab73d2 770 }
Jerome Coutant 0:c0f3bbab73d2 771
Jerome Coutant 0:c0f3bbab73d2 772 /**
Jerome Coutant 0:c0f3bbab73d2 773 * @brief Reads single data with I2C communication
Jerome Coutant 0:c0f3bbab73d2 774 * channel from HDMI bridge.
Jerome Coutant 0:c0f3bbab73d2 775 * @param Addr: I2C address
Jerome Coutant 0:c0f3bbab73d2 776 * @param Reg: Register address
Jerome Coutant 0:c0f3bbab73d2 777 * @retval Read data
Jerome Coutant 0:c0f3bbab73d2 778 */
Jerome Coutant 0:c0f3bbab73d2 779 uint8_t HDMI_IO_Read(uint8_t Addr, uint8_t Reg)
Jerome Coutant 0:c0f3bbab73d2 780 {
Jerome Coutant 0:c0f3bbab73d2 781 uint8_t value = 0x00;
Jerome Coutant 0:c0f3bbab73d2 782
Jerome Coutant 0:c0f3bbab73d2 783 I2Cx_ReadMultiple(&hI2cAudioHandler, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, &value, 1);
Jerome Coutant 0:c0f3bbab73d2 784
Jerome Coutant 0:c0f3bbab73d2 785 return value;
Jerome Coutant 0:c0f3bbab73d2 786 }
Jerome Coutant 0:c0f3bbab73d2 787
Jerome Coutant 0:c0f3bbab73d2 788 /**
Jerome Coutant 0:c0f3bbab73d2 789 * @brief HDMI delay
Jerome Coutant 0:c0f3bbab73d2 790 * @param Delay: Delay in ms
Jerome Coutant 0:c0f3bbab73d2 791 * @retval None
Jerome Coutant 0:c0f3bbab73d2 792 */
Jerome Coutant 0:c0f3bbab73d2 793 void HDMI_IO_Delay(uint32_t Delay)
Jerome Coutant 0:c0f3bbab73d2 794 {
Jerome Coutant 0:c0f3bbab73d2 795 HAL_Delay(Delay);
Jerome Coutant 0:c0f3bbab73d2 796 }
Jerome Coutant 0:c0f3bbab73d2 797 /**
Jerome Coutant 0:c0f3bbab73d2 798 * @}
Jerome Coutant 0:c0f3bbab73d2 799 */
Jerome Coutant 0:c0f3bbab73d2 800
Jerome Coutant 0:c0f3bbab73d2 801 /**
Jerome Coutant 0:c0f3bbab73d2 802 * @}
Jerome Coutant 0:c0f3bbab73d2 803 */
Jerome Coutant 0:c0f3bbab73d2 804
Jerome Coutant 0:c0f3bbab73d2 805 /**
Jerome Coutant 0:c0f3bbab73d2 806 * @}
Jerome Coutant 0:c0f3bbab73d2 807 */
Jerome Coutant 0:c0f3bbab73d2 808
Jerome Coutant 0:c0f3bbab73d2 809 /**
Jerome Coutant 0:c0f3bbab73d2 810 * @}
Jerome Coutant 0:c0f3bbab73d2 811 */
Jerome Coutant 0:c0f3bbab73d2 812
Jerome Coutant 0:c0f3bbab73d2 813 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/