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 Jul 06 16:48:52 2017 +0200
Revision:
3:145e714557cf
Parent:
1:3e58f8a39705
Child:
4:72a949940ad6
Child:
6:05b81d60cdae
replace HAL_Delay by wait_ms

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