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:
Fri Nov 15 14:50:16 2019 +0100
Revision:
8:d13d7c447539
Parent:
4:72a949940ad6
Correct warning

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 adv7533.c
Jerome Coutant 0:c0f3bbab73d2 4 * @author MCD Application Team
Jerome Coutant 0:c0f3bbab73d2 5 * @brief This file provides the ADV7533 DSI to HDMI bridge driver
Jerome Coutant 0:c0f3bbab73d2 6 ******************************************************************************
Jerome Coutant 0:c0f3bbab73d2 7 * @attention
Jerome Coutant 0:c0f3bbab73d2 8 *
Jerome Coutant 0:c0f3bbab73d2 9 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Jerome Coutant 0:c0f3bbab73d2 10 *
Jerome Coutant 0:c0f3bbab73d2 11 * Redistribution and use in source and binary forms, with or without modification,
Jerome Coutant 0:c0f3bbab73d2 12 * are permitted provided that the following conditions are met:
Jerome Coutant 0:c0f3bbab73d2 13 * 1. Redistributions of source code must retain the above copyright notice,
Jerome Coutant 0:c0f3bbab73d2 14 * this list of conditions and the following disclaimer.
Jerome Coutant 0:c0f3bbab73d2 15 * 2. Redistributions in binary form must reproduce the above copyright notice,
Jerome Coutant 0:c0f3bbab73d2 16 * this list of conditions and the following disclaimer in the documentation
Jerome Coutant 0:c0f3bbab73d2 17 * and/or other materials provided with the distribution.
Jerome Coutant 0:c0f3bbab73d2 18 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Jerome Coutant 0:c0f3bbab73d2 19 * may be used to endorse or promote products derived from this software
Jerome Coutant 0:c0f3bbab73d2 20 * without specific prior written permission.
Jerome Coutant 0:c0f3bbab73d2 21 *
Jerome Coutant 0:c0f3bbab73d2 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Jerome Coutant 0:c0f3bbab73d2 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Jerome Coutant 0:c0f3bbab73d2 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Jerome Coutant 0:c0f3bbab73d2 25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Jerome Coutant 0:c0f3bbab73d2 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Jerome Coutant 0:c0f3bbab73d2 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Jerome Coutant 0:c0f3bbab73d2 28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Jerome Coutant 0:c0f3bbab73d2 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Jerome Coutant 0:c0f3bbab73d2 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Jerome Coutant 0:c0f3bbab73d2 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Jerome Coutant 0:c0f3bbab73d2 32 *
Jerome Coutant 0:c0f3bbab73d2 33 ******************************************************************************
Jerome Coutant 0:c0f3bbab73d2 34 */
Jerome Coutant 0:c0f3bbab73d2 35
Jerome Coutant 0:c0f3bbab73d2 36 /* Includes ------------------------------------------------------------------*/
Jerome Coutant 0:c0f3bbab73d2 37 #include "adv7533.h"
Jerome Coutant 0:c0f3bbab73d2 38
Jerome Coutant 0:c0f3bbab73d2 39 /** @addtogroup BSP
Jerome Coutant 0:c0f3bbab73d2 40 * @{
Jerome Coutant 0:c0f3bbab73d2 41 */
Jerome Coutant 0:c0f3bbab73d2 42
Jerome Coutant 0:c0f3bbab73d2 43 /** @addtogroup Components
Jerome Coutant 0:c0f3bbab73d2 44 * @{
Jerome Coutant 0:c0f3bbab73d2 45 */
Jerome Coutant 0:c0f3bbab73d2 46
Jerome Coutant 0:c0f3bbab73d2 47 /** @defgroup ADV7533 ADV7533
Jerome Coutant 0:c0f3bbab73d2 48 * @brief This file provides a set of functions needed to drive the
Jerome Coutant 0:c0f3bbab73d2 49 * adv7533 DSI-HDMI bridge.
Jerome Coutant 0:c0f3bbab73d2 50 * @{
Jerome Coutant 0:c0f3bbab73d2 51 */
Jerome Coutant 0:c0f3bbab73d2 52
Jerome Coutant 0:c0f3bbab73d2 53 /* Private types -------------------------------------------------------------*/
Jerome Coutant 0:c0f3bbab73d2 54 /* Private variables ---------------------------------------------------------*/
Jerome Coutant 0:c0f3bbab73d2 55 /* Private constants ---------------------------------------------------------*/
Jerome Coutant 0:c0f3bbab73d2 56 /** @defgroup ADV7533_Private_Constants ADV7533 Private Constants
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 0:c0f3bbab73d2 63
Jerome Coutant 0:c0f3bbab73d2 64 /* Private macros ------------------------------------------------------------*/
Jerome Coutant 0:c0f3bbab73d2 65 /* Private functions ---------------------------------------------------------*/
Jerome Coutant 0:c0f3bbab73d2 66 /** @defgroup ADV7533_Exported_Variables
Jerome Coutant 0:c0f3bbab73d2 67 * @{
Jerome Coutant 0:c0f3bbab73d2 68 */
Jerome Coutant 0:c0f3bbab73d2 69
Jerome Coutant 0:c0f3bbab73d2 70 AUDIO_DrvTypeDef adv7533_drv =
Jerome Coutant 0:c0f3bbab73d2 71 {
Jerome Coutant 0:c0f3bbab73d2 72 adv7533_AudioInit,
Jerome Coutant 0:c0f3bbab73d2 73 adv7533_DeInit,
Jerome Coutant 0:c0f3bbab73d2 74 adv7533_ReadID,
Jerome Coutant 0:c0f3bbab73d2 75 adv7533_Play,
Jerome Coutant 0:c0f3bbab73d2 76 adv7533_Pause,
Jerome Coutant 0:c0f3bbab73d2 77 adv7533_Resume,
Jerome Coutant 0:c0f3bbab73d2 78 adv7533_Stop,
Jerome Coutant 0:c0f3bbab73d2 79 adv7533_SetFrequency,
Jerome Coutant 1:3e58f8a39705 80 adv7533_SetVolume, /* Not supported, added for compatibility */
Jerome Coutant 0:c0f3bbab73d2 81 adv7533_SetMute,
Jerome Coutant 1:3e58f8a39705 82 adv7533_SetOutputMode, /* Not supported, added for compatibility */
Jerome Coutant 1:3e58f8a39705 83 adv7533_Reset /* Not supported, added for compatibility */
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 0:c0f3bbab73d2 89
Jerome Coutant 0:c0f3bbab73d2 90 /* Exported functions --------------------------------------------------------*/
Jerome Coutant 0:c0f3bbab73d2 91 /** @defgroup ADV7533_Exported_Functions ADV7533 Exported Functions
Jerome Coutant 0:c0f3bbab73d2 92 * @{
Jerome Coutant 0:c0f3bbab73d2 93 */
Jerome Coutant 0:c0f3bbab73d2 94
Jerome Coutant 0:c0f3bbab73d2 95 /**
Jerome Coutant 0:c0f3bbab73d2 96 * @brief Initializes the ADV7533 bridge.
Jerome Coutant 0:c0f3bbab73d2 97 * @param None
Jerome Coutant 0:c0f3bbab73d2 98 * @retval Status
Jerome Coutant 0:c0f3bbab73d2 99 */
Jerome Coutant 0:c0f3bbab73d2 100 uint8_t ADV7533_Init(void)
Jerome Coutant 0:c0f3bbab73d2 101 {
Jerome Coutant 0:c0f3bbab73d2 102 HDMI_IO_Init();
Jerome Coutant 0:c0f3bbab73d2 103
Jerome Coutant 0:c0f3bbab73d2 104 /* Configure the IC2 address for CEC_DSI interface */
Jerome Coutant 0:c0f3bbab73d2 105 HDMI_IO_Write(ADV7533_MAIN_I2C_ADDR, 0xE1, ADV7533_CEC_DSI_I2C_ADDR);
Jerome Coutant 0:c0f3bbab73d2 106
Jerome Coutant 0:c0f3bbab73d2 107 return 0;
Jerome Coutant 0:c0f3bbab73d2 108 }
Jerome Coutant 0:c0f3bbab73d2 109
Jerome Coutant 0:c0f3bbab73d2 110 /**
Jerome Coutant 0:c0f3bbab73d2 111 * @brief Power on the ADV7533 bridge.
Jerome Coutant 0:c0f3bbab73d2 112 * @param None
Jerome Coutant 0:c0f3bbab73d2 113 * @retval None
Jerome Coutant 0:c0f3bbab73d2 114 */
Jerome Coutant 0:c0f3bbab73d2 115 void ADV7533_PowerOn(void)
Jerome Coutant 0:c0f3bbab73d2 116 {
Jerome Coutant 0:c0f3bbab73d2 117 uint8_t tmp;
Jerome Coutant 0:c0f3bbab73d2 118
Jerome Coutant 0:c0f3bbab73d2 119 /* Power on */
Jerome Coutant 0:c0f3bbab73d2 120 tmp = HDMI_IO_Read(ADV7533_MAIN_I2C_ADDR, 0x41);
Jerome Coutant 0:c0f3bbab73d2 121 tmp &= ~0x40;
Jerome Coutant 0:c0f3bbab73d2 122 HDMI_IO_Write(ADV7533_MAIN_I2C_ADDR, 0x41, tmp);
Jerome Coutant 0:c0f3bbab73d2 123 }
Jerome Coutant 0:c0f3bbab73d2 124
Jerome Coutant 0:c0f3bbab73d2 125 /**
Jerome Coutant 0:c0f3bbab73d2 126 * @brief Power off the ADV7533 bridge.
Jerome Coutant 0:c0f3bbab73d2 127 * @param None
Jerome Coutant 0:c0f3bbab73d2 128 * @retval None
Jerome Coutant 0:c0f3bbab73d2 129 */
Jerome Coutant 0:c0f3bbab73d2 130 void ADV7533_PowerDown(void)
Jerome Coutant 0:c0f3bbab73d2 131 {
Jerome Coutant 0:c0f3bbab73d2 132 uint8_t tmp;
Jerome Coutant 0:c0f3bbab73d2 133
Jerome Coutant 0:c0f3bbab73d2 134 /* Power down */
Jerome Coutant 0:c0f3bbab73d2 135 tmp = HDMI_IO_Read(ADV7533_MAIN_I2C_ADDR, 0x41);
Jerome Coutant 0:c0f3bbab73d2 136 tmp |= 0x40;
Jerome Coutant 0:c0f3bbab73d2 137 HDMI_IO_Write(ADV7533_MAIN_I2C_ADDR, 0x41, tmp);
Jerome Coutant 0:c0f3bbab73d2 138 }
Jerome Coutant 0:c0f3bbab73d2 139
Jerome Coutant 0:c0f3bbab73d2 140 /**
Jerome Coutant 0:c0f3bbab73d2 141 * @brief Configure the DSI-HDMI ADV7533 bridge for video.
Jerome Coutant 0:c0f3bbab73d2 142 * @param config : pointer to adv7533ConfigTypeDef that contains the
Jerome Coutant 0:c0f3bbab73d2 143 * video configuration parameters
Jerome Coutant 0:c0f3bbab73d2 144 * @retval None
Jerome Coutant 0:c0f3bbab73d2 145 */
Jerome Coutant 0:c0f3bbab73d2 146 void ADV7533_Configure(adv7533ConfigTypeDef * config)
Jerome Coutant 0:c0f3bbab73d2 147 {
Jerome Coutant 0:c0f3bbab73d2 148 uint8_t tmp;
Jerome Coutant 0:c0f3bbab73d2 149
Jerome Coutant 0:c0f3bbab73d2 150 /* Sequence from Section 3 - Quick Start Guide */
Jerome Coutant 0:c0f3bbab73d2 151
Jerome Coutant 0:c0f3bbab73d2 152 /* ADV7533 Power Settings */
Jerome Coutant 0:c0f3bbab73d2 153 /* Power down */
Jerome Coutant 0:c0f3bbab73d2 154 tmp = HDMI_IO_Read(ADV7533_MAIN_I2C_ADDR, 0x41);
Jerome Coutant 0:c0f3bbab73d2 155 tmp &= ~0x40;
Jerome Coutant 0:c0f3bbab73d2 156 HDMI_IO_Write(ADV7533_MAIN_I2C_ADDR, 0x41, tmp);
Jerome Coutant 0:c0f3bbab73d2 157 /* HPD Override */
Jerome Coutant 0:c0f3bbab73d2 158 tmp = HDMI_IO_Read(ADV7533_MAIN_I2C_ADDR, 0xD6);
Jerome Coutant 0:c0f3bbab73d2 159 tmp |= 0x40;
Jerome Coutant 0:c0f3bbab73d2 160 HDMI_IO_Write(ADV7533_MAIN_I2C_ADDR, 0xD6, tmp);
Jerome Coutant 0:c0f3bbab73d2 161 /* Gate DSI LP Oscillator and DSI Bias Clock Powerdown */
Jerome Coutant 0:c0f3bbab73d2 162 tmp = HDMI_IO_Read(ADV7533_CEC_DSI_I2C_ADDR, 0x03);
Jerome Coutant 0:c0f3bbab73d2 163 tmp &= ~0x02;
Jerome Coutant 0:c0f3bbab73d2 164 HDMI_IO_Write(ADV7533_CEC_DSI_I2C_ADDR, 0x03, tmp);
Jerome Coutant 0:c0f3bbab73d2 165
Jerome Coutant 0:c0f3bbab73d2 166 /* Fixed registers that must be set on power-up */
Jerome Coutant 0:c0f3bbab73d2 167 tmp = HDMI_IO_Read(ADV7533_MAIN_I2C_ADDR, 0x16);
Jerome Coutant 0:c0f3bbab73d2 168 tmp &= ~0x3E;
Jerome Coutant 0:c0f3bbab73d2 169 tmp |= 0x20;
Jerome Coutant 0:c0f3bbab73d2 170 HDMI_IO_Write(ADV7533_MAIN_I2C_ADDR, 0x16, tmp);
Jerome Coutant 0:c0f3bbab73d2 171 HDMI_IO_Write(ADV7533_MAIN_I2C_ADDR, 0x9A, 0xE0);
Jerome Coutant 0:c0f3bbab73d2 172 tmp = HDMI_IO_Read(ADV7533_MAIN_I2C_ADDR, 0xBA);
Jerome Coutant 0:c0f3bbab73d2 173 tmp &= ~0xF8;
Jerome Coutant 0:c0f3bbab73d2 174 tmp |= 0x70;
Jerome Coutant 0:c0f3bbab73d2 175 HDMI_IO_Write(ADV7533_MAIN_I2C_ADDR, 0xBA, tmp);
Jerome Coutant 0:c0f3bbab73d2 176 HDMI_IO_Write(ADV7533_MAIN_I2C_ADDR, 0xDE, 0x82);
Jerome Coutant 0:c0f3bbab73d2 177
Jerome Coutant 0:c0f3bbab73d2 178 tmp = HDMI_IO_Read(ADV7533_MAIN_I2C_ADDR, 0xE4);
Jerome Coutant 0:c0f3bbab73d2 179 tmp |= 0x40;
Jerome Coutant 0:c0f3bbab73d2 180 HDMI_IO_Write(ADV7533_MAIN_I2C_ADDR, 0xE4, tmp);
Jerome Coutant 0:c0f3bbab73d2 181 HDMI_IO_Write(ADV7533_MAIN_I2C_ADDR, 0xE5, 0x80);
Jerome Coutant 0:c0f3bbab73d2 182
Jerome Coutant 0:c0f3bbab73d2 183 tmp = HDMI_IO_Read(ADV7533_CEC_DSI_I2C_ADDR, 0x15);
Jerome Coutant 0:c0f3bbab73d2 184 tmp &= ~0x30;
Jerome Coutant 0:c0f3bbab73d2 185 tmp |= 0x10;
Jerome Coutant 0:c0f3bbab73d2 186 tmp = HDMI_IO_Read(ADV7533_CEC_DSI_I2C_ADDR, 0x17);
Jerome Coutant 0:c0f3bbab73d2 187 tmp &= ~0xF0;
Jerome Coutant 0:c0f3bbab73d2 188 tmp |= 0xD0;
Jerome Coutant 0:c0f3bbab73d2 189 HDMI_IO_Write(ADV7533_CEC_DSI_I2C_ADDR, 0x17, tmp);
Jerome Coutant 0:c0f3bbab73d2 190 tmp = HDMI_IO_Read(ADV7533_CEC_DSI_I2C_ADDR, 0x24);
Jerome Coutant 0:c0f3bbab73d2 191 tmp &= ~0x10;
Jerome Coutant 0:c0f3bbab73d2 192 HDMI_IO_Write(ADV7533_CEC_DSI_I2C_ADDR, 0x24, tmp);
Jerome Coutant 0:c0f3bbab73d2 193 tmp = HDMI_IO_Read(ADV7533_CEC_DSI_I2C_ADDR, 0x57);
Jerome Coutant 0:c0f3bbab73d2 194 tmp |= 0x01;
Jerome Coutant 0:c0f3bbab73d2 195 tmp |= 0x10;
Jerome Coutant 0:c0f3bbab73d2 196 HDMI_IO_Write(ADV7533_CEC_DSI_I2C_ADDR, 0x57, tmp);
Jerome Coutant 0:c0f3bbab73d2 197
Jerome Coutant 0:c0f3bbab73d2 198 /* Configure the number of DSI lanes */
Jerome Coutant 0:c0f3bbab73d2 199 HDMI_IO_Write(ADV7533_CEC_DSI_I2C_ADDR, 0x1C, (config->DSI_LANES << 4));
Jerome Coutant 0:c0f3bbab73d2 200
Jerome Coutant 0:c0f3bbab73d2 201 /* Setup video output mode */
Jerome Coutant 0:c0f3bbab73d2 202 /* Select HDMI mode */
Jerome Coutant 0:c0f3bbab73d2 203 tmp = HDMI_IO_Read(ADV7533_MAIN_I2C_ADDR, 0xAF);
Jerome Coutant 0:c0f3bbab73d2 204 tmp |= 0x02;
Jerome Coutant 0:c0f3bbab73d2 205 HDMI_IO_Write(ADV7533_MAIN_I2C_ADDR, 0xAF, tmp);
Jerome Coutant 0:c0f3bbab73d2 206 /* HDMI Output Enable */
Jerome Coutant 0:c0f3bbab73d2 207 tmp = HDMI_IO_Read(ADV7533_CEC_DSI_I2C_ADDR, 0x03);
Jerome Coutant 0:c0f3bbab73d2 208 tmp |= 0x80;
Jerome Coutant 0:c0f3bbab73d2 209 HDMI_IO_Write(ADV7533_CEC_DSI_I2C_ADDR, 0x03, tmp);
Jerome Coutant 0:c0f3bbab73d2 210
Jerome Coutant 0:c0f3bbab73d2 211 /* GC packet enable */
Jerome Coutant 0:c0f3bbab73d2 212 tmp = HDMI_IO_Read(ADV7533_MAIN_I2C_ADDR, 0x40);
Jerome Coutant 0:c0f3bbab73d2 213 tmp |= 0x80;
Jerome Coutant 0:c0f3bbab73d2 214 HDMI_IO_Write(ADV7533_MAIN_I2C_ADDR, 0x40, tmp);
Jerome Coutant 0:c0f3bbab73d2 215 /* Input color depth 24-bit per pixel */
Jerome Coutant 0:c0f3bbab73d2 216 tmp = HDMI_IO_Read(ADV7533_MAIN_I2C_ADDR, 0x4C);
Jerome Coutant 0:c0f3bbab73d2 217 tmp &= ~0x0F;
Jerome Coutant 0:c0f3bbab73d2 218 tmp |= 0x03;
Jerome Coutant 0:c0f3bbab73d2 219 HDMI_IO_Write(ADV7533_MAIN_I2C_ADDR, 0x4C, tmp);
Jerome Coutant 0:c0f3bbab73d2 220 /* Down dither output color depth */
Jerome Coutant 0:c0f3bbab73d2 221 HDMI_IO_Write(ADV7533_MAIN_I2C_ADDR, 0x49, 0xfc);
Jerome Coutant 0:c0f3bbab73d2 222
Jerome Coutant 0:c0f3bbab73d2 223 /* Internal timing disabled */
Jerome Coutant 0:c0f3bbab73d2 224 tmp = HDMI_IO_Read(ADV7533_CEC_DSI_I2C_ADDR, 0x27);
Jerome Coutant 0:c0f3bbab73d2 225 tmp &= ~0x80;
Jerome Coutant 0:c0f3bbab73d2 226 HDMI_IO_Write(ADV7533_CEC_DSI_I2C_ADDR, 0x27, tmp);
Jerome Coutant 0:c0f3bbab73d2 227 }
Jerome Coutant 0:c0f3bbab73d2 228
Jerome Coutant 0:c0f3bbab73d2 229 /**
Jerome Coutant 0:c0f3bbab73d2 230 * @brief Enable video pattern generation.
Jerome Coutant 0:c0f3bbab73d2 231 * @param None
Jerome Coutant 0:c0f3bbab73d2 232 * @retval None
Jerome Coutant 0:c0f3bbab73d2 233 */
Jerome Coutant 0:c0f3bbab73d2 234 void ADV7533_PatternEnable(void)
Jerome Coutant 0:c0f3bbab73d2 235 {
Jerome Coutant 0:c0f3bbab73d2 236 /* Timing generator enable */
Jerome Coutant 0:c0f3bbab73d2 237 HDMI_IO_Write(ADV7533_CEC_DSI_I2C_ADDR, 0x55, 0x80); /* Color bar */
Jerome Coutant 0:c0f3bbab73d2 238 HDMI_IO_Write(ADV7533_CEC_DSI_I2C_ADDR, 0x55, 0xA0); /* Color ramp */
Jerome Coutant 0:c0f3bbab73d2 239
Jerome Coutant 0:c0f3bbab73d2 240 HDMI_IO_Write(ADV7533_CEC_DSI_I2C_ADDR, 0x03, 0x89);
Jerome Coutant 0:c0f3bbab73d2 241 HDMI_IO_Write(ADV7533_CEC_DSI_I2C_ADDR, 0xAF, 0x16);
Jerome Coutant 0:c0f3bbab73d2 242 }
Jerome Coutant 0:c0f3bbab73d2 243
Jerome Coutant 0:c0f3bbab73d2 244 /**
Jerome Coutant 0:c0f3bbab73d2 245 * @brief Disable video pattern generation.
Jerome Coutant 0:c0f3bbab73d2 246 * @param none
Jerome Coutant 0:c0f3bbab73d2 247 * @retval none
Jerome Coutant 0:c0f3bbab73d2 248 */
Jerome Coutant 0:c0f3bbab73d2 249 void ADV7533_PatternDisable(void)
Jerome Coutant 0:c0f3bbab73d2 250 {
Jerome Coutant 0:c0f3bbab73d2 251 /* Timing generator enable */
Jerome Coutant 0:c0f3bbab73d2 252 HDMI_IO_Write(ADV7533_CEC_DSI_I2C_ADDR, 0x55, 0x00);
Jerome Coutant 0:c0f3bbab73d2 253 }
Jerome Coutant 0:c0f3bbab73d2 254
Jerome Coutant 0:c0f3bbab73d2 255 /**
Jerome Coutant 0:c0f3bbab73d2 256 * @brief Initializes the ADV7533 audio interface.
Jerome Coutant 0:c0f3bbab73d2 257 * @param DeviceAddr: Device address on communication Bus.
Jerome Coutant 0:c0f3bbab73d2 258 * @param OutputDevice: Not used (for compatiblity only).
Jerome Coutant 0:c0f3bbab73d2 259 * @param Volume: Not used (for compatiblity only).
Jerome Coutant 0:c0f3bbab73d2 260 * @param AudioFreq: Audio Frequency
Jerome Coutant 0:c0f3bbab73d2 261 * @retval 0 if correct communication, else wrong communication
Jerome Coutant 0:c0f3bbab73d2 262 */
Jerome Coutant 0:c0f3bbab73d2 263 uint32_t adv7533_AudioInit(uint16_t DeviceAddr, uint16_t OutputDevice, uint8_t Volume,uint32_t AudioFreq)
Jerome Coutant 0:c0f3bbab73d2 264 {
Jerome Coutant 0:c0f3bbab73d2 265 uint32_t val = 4096;
Jerome Coutant 0:c0f3bbab73d2 266 uint8_t tmp = 0;
Jerome Coutant 0:c0f3bbab73d2 267
Jerome Coutant 0:c0f3bbab73d2 268 /* Audio data enable*/
Jerome Coutant 0:c0f3bbab73d2 269 tmp = HDMI_IO_Read(ADV7533_CEC_DSI_I2C_ADDR, 0x05);
Jerome Coutant 0:c0f3bbab73d2 270 tmp &= ~0x20;
Jerome Coutant 0:c0f3bbab73d2 271 HDMI_IO_Write(ADV7533_CEC_DSI_I2C_ADDR, 0x05, tmp);
Jerome Coutant 0:c0f3bbab73d2 272
Jerome Coutant 0:c0f3bbab73d2 273 /* HDMI statup */
Jerome Coutant 0:c0f3bbab73d2 274 tmp= (uint8_t)((val & 0xF0000)>>16);
Jerome Coutant 0:c0f3bbab73d2 275 HDMI_IO_Write(DeviceAddr, 0x01, tmp);
Jerome Coutant 0:c0f3bbab73d2 276
Jerome Coutant 0:c0f3bbab73d2 277 tmp= (uint8_t)((val & 0xFF00)>>8);
Jerome Coutant 0:c0f3bbab73d2 278 HDMI_IO_Write(DeviceAddr, 0x02, tmp);
Jerome Coutant 0:c0f3bbab73d2 279
Jerome Coutant 0:c0f3bbab73d2 280 tmp= (uint8_t)((val & 0xFF));
Jerome Coutant 0:c0f3bbab73d2 281 HDMI_IO_Write(DeviceAddr, 0x03, tmp);
Jerome Coutant 0:c0f3bbab73d2 282
Jerome Coutant 0:c0f3bbab73d2 283 /* Enable spdif */
Jerome Coutant 0:c0f3bbab73d2 284 tmp = HDMI_IO_Read(DeviceAddr, 0x0B);
Jerome Coutant 0:c0f3bbab73d2 285 tmp |= 0x80;
Jerome Coutant 0:c0f3bbab73d2 286 HDMI_IO_Write(DeviceAddr, 0x0B, tmp);
Jerome Coutant 0:c0f3bbab73d2 287
Jerome Coutant 0:c0f3bbab73d2 288 /* Enable I2S */
Jerome Coutant 0:c0f3bbab73d2 289 tmp = HDMI_IO_Read(DeviceAddr, 0x0C);
Jerome Coutant 0:c0f3bbab73d2 290 tmp |=0x04;
Jerome Coutant 0:c0f3bbab73d2 291 HDMI_IO_Write(DeviceAddr, 0x0C, tmp);
Jerome Coutant 0:c0f3bbab73d2 292
Jerome Coutant 0:c0f3bbab73d2 293 /* Set audio sampling frequency */
Jerome Coutant 0:c0f3bbab73d2 294 adv7533_SetFrequency(DeviceAddr, AudioFreq);
Jerome Coutant 0:c0f3bbab73d2 295
Jerome Coutant 0:c0f3bbab73d2 296 /* Select SPDIF is 0x10 , I2S=0x00 */
Jerome Coutant 0:c0f3bbab73d2 297 tmp = HDMI_IO_Read(ADV7533_MAIN_I2C_ADDR, 0x0A);
Jerome Coutant 0:c0f3bbab73d2 298 tmp &=~ 0x10;
Jerome Coutant 0:c0f3bbab73d2 299 HDMI_IO_Write(DeviceAddr, 0x0A, tmp);
Jerome Coutant 0:c0f3bbab73d2 300
Jerome Coutant 0:c0f3bbab73d2 301 /* Set v1P2 enable */
Jerome Coutant 0:c0f3bbab73d2 302 tmp = HDMI_IO_Read(DeviceAddr, 0xE4);
Jerome Coutant 0:c0f3bbab73d2 303 tmp |= 0x80;
Jerome Coutant 0:c0f3bbab73d2 304 HDMI_IO_Write(DeviceAddr, 0xE4, tmp);
Jerome Coutant 0:c0f3bbab73d2 305
Jerome Coutant 0:c0f3bbab73d2 306 return 0;
Jerome Coutant 0:c0f3bbab73d2 307 }
Jerome Coutant 0:c0f3bbab73d2 308
Jerome Coutant 0:c0f3bbab73d2 309 /**
Jerome Coutant 0:c0f3bbab73d2 310 * @brief Deinitializes the adv7533
Jerome Coutant 0:c0f3bbab73d2 311 * @param None
Jerome Coutant 0:c0f3bbab73d2 312 * @retval None
Jerome Coutant 0:c0f3bbab73d2 313 */
Jerome Coutant 0:c0f3bbab73d2 314 void adv7533_DeInit(void)
Jerome Coutant 0:c0f3bbab73d2 315 {
Jerome Coutant 0:c0f3bbab73d2 316 /* Deinitialize Audio adv7533 interface */
Jerome Coutant 0:c0f3bbab73d2 317 AUDIO_IO_DeInit();
Jerome Coutant 0:c0f3bbab73d2 318 }
Jerome Coutant 0:c0f3bbab73d2 319
Jerome Coutant 0:c0f3bbab73d2 320 /**
Jerome Coutant 0:c0f3bbab73d2 321 * @brief Get the adv7533 ID.
Jerome Coutant 0:c0f3bbab73d2 322 * @param DeviceAddr: Device address on communication Bus.
Jerome Coutant 0:c0f3bbab73d2 323 * @retval The adv7533 ID
Jerome Coutant 0:c0f3bbab73d2 324 */
Jerome Coutant 0:c0f3bbab73d2 325 uint32_t adv7533_ReadID(uint16_t DeviceAddr)
Jerome Coutant 0:c0f3bbab73d2 326 {
Jerome Coutant 0:c0f3bbab73d2 327 uint32_t tmp = 0;
Jerome Coutant 0:c0f3bbab73d2 328
Jerome Coutant 0:c0f3bbab73d2 329 tmp = HDMI_IO_Read(DeviceAddr, ADV7533_CHIPID_ADDR0);
Jerome Coutant 0:c0f3bbab73d2 330 tmp = (tmp<<8);
Jerome Coutant 0:c0f3bbab73d2 331 tmp |= HDMI_IO_Read(DeviceAddr, ADV7533_CHIPID_ADDR1);
Jerome Coutant 0:c0f3bbab73d2 332
Jerome Coutant 0:c0f3bbab73d2 333 return(tmp);
Jerome Coutant 0:c0f3bbab73d2 334 }
Jerome Coutant 0:c0f3bbab73d2 335
Jerome Coutant 0:c0f3bbab73d2 336 /**
Jerome Coutant 0:c0f3bbab73d2 337 * @brief Pauses playing on the audio hdmi
Jerome Coutant 0:c0f3bbab73d2 338 * @param DeviceAddr: Device address on communication Bus.
Jerome Coutant 0:c0f3bbab73d2 339 * @retval 0 if correct communication, else wrong communication
Jerome Coutant 0:c0f3bbab73d2 340 */
Jerome Coutant 0:c0f3bbab73d2 341 uint32_t adv7533_Pause(uint16_t DeviceAddr)
Jerome Coutant 0:c0f3bbab73d2 342 {
Jerome Coutant 0:c0f3bbab73d2 343 return(adv7533_SetMute(DeviceAddr,AUDIO_MUTE_ON));
Jerome Coutant 0:c0f3bbab73d2 344 }
Jerome Coutant 0:c0f3bbab73d2 345
Jerome Coutant 0:c0f3bbab73d2 346 /**
Jerome Coutant 0:c0f3bbab73d2 347 * @brief Resumes playing on the audio hdmi.
Jerome Coutant 0:c0f3bbab73d2 348 * @param DeviceAddr: Device address on communication Bus.
Jerome Coutant 0:c0f3bbab73d2 349 * @retval 0 if correct communication, else wrong communication
Jerome Coutant 0:c0f3bbab73d2 350 */
Jerome Coutant 0:c0f3bbab73d2 351 uint32_t adv7533_Resume(uint16_t DeviceAddr)
Jerome Coutant 0:c0f3bbab73d2 352 {
Jerome Coutant 0:c0f3bbab73d2 353 return(adv7533_SetMute(DeviceAddr,AUDIO_MUTE_OFF));
Jerome Coutant 0:c0f3bbab73d2 354 }
Jerome Coutant 0:c0f3bbab73d2 355
Jerome Coutant 0:c0f3bbab73d2 356 /**
Jerome Coutant 0:c0f3bbab73d2 357 * @brief Start the audio hdmi play feature.
Jerome Coutant 0:c0f3bbab73d2 358 * @note For this codec no Play options are required.
Jerome Coutant 0:c0f3bbab73d2 359 * @param DeviceAddr: Device address on communication Bus.
Jerome Coutant 0:c0f3bbab73d2 360 * @retval 0 if correct communication, else wrong communication
Jerome Coutant 0:c0f3bbab73d2 361 */
Jerome Coutant 0:c0f3bbab73d2 362 uint32_t adv7533_Play(uint16_t DeviceAddr ,uint16_t* pBuffer ,uint16_t Size)
Jerome Coutant 0:c0f3bbab73d2 363 {
Jerome Coutant 0:c0f3bbab73d2 364 return(adv7533_SetMute(DeviceAddr,AUDIO_MUTE_OFF));
Jerome Coutant 0:c0f3bbab73d2 365 }
Jerome Coutant 0:c0f3bbab73d2 366
Jerome Coutant 0:c0f3bbab73d2 367 /**
Jerome Coutant 0:c0f3bbab73d2 368 * @brief Stop playing on the audio hdmi
Jerome Coutant 0:c0f3bbab73d2 369 * @param DeviceAddr: Device address on communication Bus.
Jerome Coutant 0:c0f3bbab73d2 370 * @retval 0 if correct communication, else wrong communication
Jerome Coutant 0:c0f3bbab73d2 371 */
Jerome Coutant 0:c0f3bbab73d2 372 uint32_t adv7533_Stop(uint16_t DeviceAddr,uint32_t cmd)
Jerome Coutant 0:c0f3bbab73d2 373 {
Jerome Coutant 0:c0f3bbab73d2 374 return(adv7533_SetMute(DeviceAddr,AUDIO_MUTE_ON));
Jerome Coutant 0:c0f3bbab73d2 375 }
Jerome Coutant 0:c0f3bbab73d2 376
Jerome Coutant 0:c0f3bbab73d2 377 /**
Jerome Coutant 0:c0f3bbab73d2 378 * @brief Enables or disables the mute feature on the audio hdmi.
Jerome Coutant 0:c0f3bbab73d2 379 * @param DeviceAddr: Device address on communication Bus.
Jerome Coutant 0:c0f3bbab73d2 380 * @param Cmd: AUDIO_MUTE_ON to enable the mute or AUDIO_MUTE_OFF to disable the
Jerome Coutant 0:c0f3bbab73d2 381 * mute mode.
Jerome Coutant 0:c0f3bbab73d2 382 * @retval 0 if correct communication, else wrong communication
Jerome Coutant 0:c0f3bbab73d2 383 */
Jerome Coutant 0:c0f3bbab73d2 384 uint32_t adv7533_SetMute(uint16_t DeviceAddr, uint32_t Cmd)
Jerome Coutant 0:c0f3bbab73d2 385 {
Jerome Coutant 0:c0f3bbab73d2 386 uint8_t tmp = 0;
Jerome Coutant 0:c0f3bbab73d2 387
Jerome Coutant 0:c0f3bbab73d2 388 tmp = HDMI_IO_Read(DeviceAddr, 0x0D);
Jerome Coutant 0:c0f3bbab73d2 389 if (Cmd == AUDIO_MUTE_ON)
Jerome Coutant 0:c0f3bbab73d2 390 {
Jerome Coutant 0:c0f3bbab73d2 391 /* enable audio mute*/
Jerome Coutant 0:c0f3bbab73d2 392 tmp |= 0x40;
Jerome Coutant 0:c0f3bbab73d2 393 HDMI_IO_Write(DeviceAddr, 0x0D, tmp);
Jerome Coutant 0:c0f3bbab73d2 394 }
Jerome Coutant 0:c0f3bbab73d2 395 else
Jerome Coutant 0:c0f3bbab73d2 396 {
Jerome Coutant 0:c0f3bbab73d2 397 /*audio mute off disable the mute */
Jerome Coutant 0:c0f3bbab73d2 398 tmp &= ~0x40;
Jerome Coutant 0:c0f3bbab73d2 399 HDMI_IO_Write(DeviceAddr, 0x0D, tmp);
Jerome Coutant 0:c0f3bbab73d2 400 }
Jerome Coutant 0:c0f3bbab73d2 401 return 0;
Jerome Coutant 0:c0f3bbab73d2 402 }
Jerome Coutant 0:c0f3bbab73d2 403
Jerome Coutant 0:c0f3bbab73d2 404 /**
Jerome Coutant 0:c0f3bbab73d2 405 * @brief Sets output mode.
Jerome Coutant 0:c0f3bbab73d2 406 * @param DeviceAddr: Device address on communication Bus.
Jerome Coutant 0:c0f3bbab73d2 407 * @param Output : hdmi output.
Jerome Coutant 0:c0f3bbab73d2 408 * @retval 0 if correct communication, else wrong communication
Jerome Coutant 0:c0f3bbab73d2 409 */
Jerome Coutant 0:c0f3bbab73d2 410 uint32_t adv7533_SetOutputMode(uint16_t DeviceAddr, uint8_t Output)
Jerome Coutant 0:c0f3bbab73d2 411 {
Jerome Coutant 0:c0f3bbab73d2 412 return 0;
Jerome Coutant 0:c0f3bbab73d2 413 }
Jerome Coutant 0:c0f3bbab73d2 414
Jerome Coutant 0:c0f3bbab73d2 415 /**
Jerome Coutant 0:c0f3bbab73d2 416 * @brief Sets volumee.
Jerome Coutant 0:c0f3bbab73d2 417 * @param DeviceAddr: Device address on communication Bus.
Jerome Coutant 0:c0f3bbab73d2 418 * @param Volume : volume value.
Jerome Coutant 0:c0f3bbab73d2 419 * @retval 0 if correct communication, else wrong communication
Jerome Coutant 0:c0f3bbab73d2 420 */
Jerome Coutant 0:c0f3bbab73d2 421 uint32_t adv7533_SetVolume(uint16_t DeviceAddr, uint8_t Volume)
Jerome Coutant 0:c0f3bbab73d2 422 {
Jerome Coutant 0:c0f3bbab73d2 423 return 0;
Jerome Coutant 0:c0f3bbab73d2 424 }
Jerome Coutant 0:c0f3bbab73d2 425
Jerome Coutant 0:c0f3bbab73d2 426 /**
Jerome Coutant 0:c0f3bbab73d2 427 * @brief Resets adv7533 registers.
Jerome Coutant 0:c0f3bbab73d2 428 * @param DeviceAddr: Device address on communication Bus.
Jerome Coutant 0:c0f3bbab73d2 429 * @retval 0 if correct communication, else wrong communication
Jerome Coutant 0:c0f3bbab73d2 430 */
Jerome Coutant 0:c0f3bbab73d2 431 uint32_t adv7533_Reset(uint16_t DeviceAddr)
Jerome Coutant 0:c0f3bbab73d2 432 {
Jerome Coutant 0:c0f3bbab73d2 433 return 0;
Jerome Coutant 0:c0f3bbab73d2 434 }
Jerome Coutant 0:c0f3bbab73d2 435
Jerome Coutant 0:c0f3bbab73d2 436 /**
Jerome Coutant 0:c0f3bbab73d2 437 * @brief Sets new frequency.
Jerome Coutant 0:c0f3bbab73d2 438 * @param DeviceAddr: Device address on communication Bus.
Jerome Coutant 0:c0f3bbab73d2 439 * @param AudioFreq: Audio frequency used to play the audio stream.
Jerome Coutant 0:c0f3bbab73d2 440 * @retval 0 if correct communication, else wrong communication
Jerome Coutant 0:c0f3bbab73d2 441 */
Jerome Coutant 0:c0f3bbab73d2 442 uint32_t adv7533_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq)
Jerome Coutant 0:c0f3bbab73d2 443 {
Jerome Coutant 0:c0f3bbab73d2 444 uint8_t tmp = 0;
Jerome Coutant 0:c0f3bbab73d2 445
Jerome Coutant 0:c0f3bbab73d2 446 tmp = HDMI_IO_Read(DeviceAddr, 0x15);
Jerome Coutant 0:c0f3bbab73d2 447 tmp &= (~0xF0);
Jerome Coutant 0:c0f3bbab73d2 448 /* Clock Configurations */
Jerome Coutant 0:c0f3bbab73d2 449 switch (AudioFreq)
Jerome Coutant 0:c0f3bbab73d2 450 {
Jerome Coutant 0:c0f3bbab73d2 451 case AUDIO_FREQUENCY_32K:
Jerome Coutant 0:c0f3bbab73d2 452 /* Sampling Frequency =32 KHZ*/
Jerome Coutant 0:c0f3bbab73d2 453 tmp |= 0x30;
Jerome Coutant 0:c0f3bbab73d2 454 HDMI_IO_Write(DeviceAddr, 0x15, tmp);
Jerome Coutant 0:c0f3bbab73d2 455 break;
Jerome Coutant 0:c0f3bbab73d2 456 case AUDIO_FREQUENCY_44K:
Jerome Coutant 0:c0f3bbab73d2 457 /* Sampling Frequency =44,1 KHZ*/
Jerome Coutant 0:c0f3bbab73d2 458 tmp |= 0x00;
Jerome Coutant 0:c0f3bbab73d2 459 HDMI_IO_Write(DeviceAddr, 0x15, tmp);
Jerome Coutant 0:c0f3bbab73d2 460 break;
Jerome Coutant 0:c0f3bbab73d2 461
Jerome Coutant 0:c0f3bbab73d2 462 case AUDIO_FREQUENCY_48K:
Jerome Coutant 0:c0f3bbab73d2 463 /* Sampling Frequency =48KHZ*/
Jerome Coutant 0:c0f3bbab73d2 464 tmp |= 0x20;
Jerome Coutant 0:c0f3bbab73d2 465 HDMI_IO_Write(DeviceAddr, 0x15, tmp);
Jerome Coutant 0:c0f3bbab73d2 466 break;
Jerome Coutant 0:c0f3bbab73d2 467
Jerome Coutant 0:c0f3bbab73d2 468 case AUDIO_FREQUENCY_96K:
Jerome Coutant 0:c0f3bbab73d2 469 /* Sampling Frequency =96 KHZ*/
Jerome Coutant 0:c0f3bbab73d2 470 tmp |= 0xA0;
Jerome Coutant 0:c0f3bbab73d2 471 HDMI_IO_Write(DeviceAddr, 0x15, tmp);
Jerome Coutant 0:c0f3bbab73d2 472 break;
Jerome Coutant 0:c0f3bbab73d2 473
Jerome Coutant 0:c0f3bbab73d2 474 case AUDIO_FREQUENCY_88K:
Jerome Coutant 0:c0f3bbab73d2 475 /* Sampling Frequency =88,2 KHZ*/
Jerome Coutant 0:c0f3bbab73d2 476 tmp |= 0x80;
Jerome Coutant 0:c0f3bbab73d2 477 HDMI_IO_Write(DeviceAddr, 0x15, tmp);
Jerome Coutant 0:c0f3bbab73d2 478 break;
Jerome Coutant 0:c0f3bbab73d2 479
Jerome Coutant 0:c0f3bbab73d2 480 case AUDIO_FREQUENCY_176K:
Jerome Coutant 0:c0f3bbab73d2 481 /* Sampling Frequency =176,4 KHZ*/
Jerome Coutant 0:c0f3bbab73d2 482 tmp |= 0xC0;
Jerome Coutant 0:c0f3bbab73d2 483 HDMI_IO_Write(DeviceAddr, 0x15, tmp);
Jerome Coutant 0:c0f3bbab73d2 484 break;
Jerome Coutant 0:c0f3bbab73d2 485
Jerome Coutant 0:c0f3bbab73d2 486 case AUDIO_FREQUENCY_192K:
Jerome Coutant 0:c0f3bbab73d2 487 /* Sampling Frequency =192KHZ*/
Jerome Coutant 0:c0f3bbab73d2 488 tmp |= 0xE0;
Jerome Coutant 0:c0f3bbab73d2 489 HDMI_IO_Write(DeviceAddr, 0x15, tmp);
Jerome Coutant 0:c0f3bbab73d2 490 break;
Jerome Coutant 0:c0f3bbab73d2 491 }
Jerome Coutant 0:c0f3bbab73d2 492 return 0;
Jerome Coutant 0:c0f3bbab73d2 493 }
Jerome Coutant 0:c0f3bbab73d2 494
Jerome Coutant 0:c0f3bbab73d2 495 /**
Jerome Coutant 0:c0f3bbab73d2 496 * @}
Jerome Coutant 0:c0f3bbab73d2 497 */
Jerome Coutant 0:c0f3bbab73d2 498
Jerome Coutant 0:c0f3bbab73d2 499 /**
Jerome Coutant 0:c0f3bbab73d2 500 * @}
Jerome Coutant 0:c0f3bbab73d2 501 */
Jerome Coutant 0:c0f3bbab73d2 502
Jerome Coutant 0:c0f3bbab73d2 503 /**
Jerome Coutant 0:c0f3bbab73d2 504 * @}
Jerome Coutant 0:c0f3bbab73d2 505 */
Jerome Coutant 0:c0f3bbab73d2 506
Jerome Coutant 0:c0f3bbab73d2 507 /**
Jerome Coutant 0:c0f3bbab73d2 508 * @}
Jerome Coutant 0:c0f3bbab73d2 509 */
Jerome Coutant 0:c0f3bbab73d2 510
Jerome Coutant 0:c0f3bbab73d2 511 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/