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