./STM32F4-Discovery BSP User Manual: ./STM32F4-Discovery BSP Drivers

./STM32F4-Discovery BSP User Manual
  • Main Page
  • Modules
  • Files
  • Directories
./STM32F4-Discovery BSP Drivers

BSP Drivers User Manual

This document contains the User Manual (UM) of the ./STM32F4-Discovery BSP peripheral Firmware drivers.

Document tabsheets description:

  • "Modules" : List the different modules.
  • "Files" : List all the files and globals.
  • "Directories" : Firmware Directory hierarchy.

Revision History:

Date | Revision | Author | Development Platform
01/21/2022 | V1.0 |  | ./STM32F4-Discovery Board
Generated on Fri Jan 21 2022 15:09:13 for ./STM32F4-Discovery BSP User Manual by doxygen 1.7.6.1


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY LOW LEVEL Private TypesDefinitions

  • Files
  • Directories
STM32F4 DISCOVERY LOW LEVEL Private TypesDefinitions
STM32F4 DISCOVERY LOW LEVEL


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY LOW LEVEL Private Defines

Defines
STM32F4 DISCOVERY LOW LEVEL Private Defines
STM32F4 DISCOVERY LOW LEVEL

Defines

#define | __STM32F4_DISCO_BSP_VERSION_MAIN (0x02)
STM32F4 DISCO BSP Driver version number V2.1.4.
#define | __STM32F4_DISCO_BSP_VERSION_SUB1 (0x01)
#define | __STM32F4_DISCO_BSP_VERSION_SUB2 (0x04)
#define | __STM32F4_DISCO_BSP_VERSION_RC (0x00)
#define | __STM32F4_DISCO_BSP_VERSION

Define Documentation

#define __STM32F4_DISCO_BSP_VERSION
Value:
((__STM32F4_DISCO_BSP_VERSION_MAIN << 24)\
                                             |(__STM32F4_DISCO_BSP_VERSION_SUB1 << 16)\
                                             |(__STM32F4_DISCO_BSP_VERSION_SUB2 << 8 )\
                                             |(__STM32F4_DISCO_BSP_VERSION_RC))

Definition at line 54 of file stm32f4_discovery.c.

Referenced by BSP_GetVersion().

#define __STM32F4_DISCO_BSP_VERSION_MAIN (0x02)

STM32F4 DISCO BSP Driver version number V2.1.4.

[31:24] main version

Definition at line 50 of file stm32f4_discovery.c.

#define __STM32F4_DISCO_BSP_VERSION_RC (0x00)

[7:0] release candidate

Definition at line 53 of file stm32f4_discovery.c.

#define __STM32F4_DISCO_BSP_VERSION_SUB1 (0x01)

[23:16] sub1 version

Definition at line 51 of file stm32f4_discovery.c.

#define __STM32F4_DISCO_BSP_VERSION_SUB2 (0x04)

[15:8] sub2 version

Definition at line 52 of file stm32f4_discovery.c.


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY LOW LEVEL Private Macros

STM32F4 DISCOVERY LOW LEVEL Private Macros
STM32F4 DISCOVERY LOW LEVEL


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY LOW LEVEL Private Variables

Variables
STM32F4 DISCOVERY LOW LEVEL Private Variables
STM32F4 DISCOVERY LOW LEVEL

Variables

GPIO_TypeDef * | GPIO_PORT [LEDn]
const uint16_t | GPIO_PIN [LEDn]
GPIO_TypeDef * | BUTTON_PORT [BUTTONn] = {KEY_BUTTON_GPIO_PORT}
const uint16_t | BUTTON_PIN [BUTTONn] = {KEY_BUTTON_PIN}
const uint8_t | BUTTON_IRQn [BUTTONn] = {KEY_BUTTON_EXTI_IRQn}
uint32_t | I2cxTimeout = I2Cx_TIMEOUT_MAX
uint32_t | SpixTimeout = SPIx_TIMEOUT_MAX
static SPI_HandleTypeDef | SpiHandle
static I2C_HandleTypeDef | I2cHandle

Variable Documentation

const uint8_t BUTTON_IRQn[BUTTONn] = {KEY_BUTTON_EXTI_IRQn}

Definition at line 84 of file stm32f4_discovery.c.

Referenced by BSP_PB_Init().

const uint16_t BUTTON_PIN[BUTTONn] = {KEY_BUTTON_PIN}

Definition at line 83 of file stm32f4_discovery.c.

Referenced by BSP_PB_GetState(), and BSP_PB_Init().

GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {KEY_BUTTON_GPIO_PORT}

Definition at line 82 of file stm32f4_discovery.c.

Referenced by BSP_PB_GetState(), and BSP_PB_Init().

const uint16_t GPIO_PIN[LEDn]
Initial value:
 {LED4_PIN,
                                 LED3_PIN,
                                 LED5_PIN,
                                 LED6_PIN}

Definition at line 77 of file stm32f4_discovery.c.

Referenced by BSP_LED_Init(), BSP_LED_Off(), BSP_LED_On(), and BSP_LED_Toggle().

GPIO_TypeDef* GPIO_PORT[LEDn]
Initial value:
 {LED4_GPIO_PORT,
                                 LED3_GPIO_PORT,
                                 LED5_GPIO_PORT,
                                 LED6_GPIO_PORT}

Definition at line 73 of file stm32f4_discovery.c.

Referenced by BSP_LED_Init(), BSP_LED_Off(), BSP_LED_On(), and BSP_LED_Toggle().

I2C_HandleTypeDef I2cHandle [static]

Definition at line 90 of file stm32f4_discovery.c.

Referenced by I2Cx_Error(), I2Cx_Init(), I2Cx_ReadData(), and I2Cx_WriteData().

uint32_t I2cxTimeout = I2Cx_TIMEOUT_MAX

Definition at line 86 of file stm32f4_discovery.c.

Referenced by I2Cx_ReadData(), and I2Cx_WriteData().

SPI_HandleTypeDef SpiHandle [static]

Definition at line 89 of file stm32f4_discovery.c.

Referenced by SPIx_Error(), SPIx_Init(), and SPIx_WriteRead().

uint32_t SpixTimeout = SPIx_TIMEOUT_MAX

Definition at line 87 of file stm32f4_discovery.c.

Referenced by SPIx_WriteRead().


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY LOW LEVEL Private FunctionPrototypes

STM32F4 DISCOVERY LOW LEVEL Private FunctionPrototypes
STM32F4 DISCOVERY LOW LEVEL


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY LOW LEVEL Private Functions

Functions
STM32F4 DISCOVERY LOW LEVEL Private Functions
STM32F4 DISCOVERY LOW LEVEL

Functions

static void | I2Cx_Init (void)
Configures I2C interface.
static void | I2Cx_MspInit (void)
I2C MSP Initialization.
static void | SPIx_Init (void)
SPIx Bus initialization.
static void | SPIx_MspInit (void)
SPI MSP Init.
static void | SPIx_Error (void)
SPIx error treatment function.
void | ACCELERO_IO_Init (void)
Configures the Accelerometer SPI interface.
void | AUDIO_IO_Init (void)
Initializes Audio low level.
void | AUDIO_IO_DeInit (void)
DeInitializes Audio low level.

Function Documentation

void ACCELERO_IO_Init ( void )

Configures the Accelerometer SPI interface.

Definition at line 491 of file stm32f4_discovery.c.

References ACCELERO_CS_GPIO_CLK_ENABLE, ACCELERO_CS_GPIO_PORT, ACCELERO_CS_HIGH, ACCELERO_CS_PIN, and SPIx_Init().

void AUDIO_IO_DeInit ( void )

DeInitializes Audio low level.

Definition at line 641 of file stm32f4_discovery.c.

void AUDIO_IO_Init ( void )

Initializes Audio low level.

Definition at line 609 of file stm32f4_discovery.c.

References AUDIO_RESET_GPIO, AUDIO_RESET_GPIO_CLK_ENABLE, AUDIO_RESET_PIN, and I2Cx_Init().

static void I2Cx_Init ( void ) [static]

Configures I2C interface.

Definition at line 373 of file stm32f4_discovery.c.

References DISCOVERY_I2Cx, I2cHandle, and I2Cx_MspInit().

Referenced by AUDIO_IO_Init(), and I2Cx_Error().

static void I2Cx_MspInit ( void ) [static]

I2C MSP Initialization.

Definition at line 449 of file stm32f4_discovery.c.

References DISCOVERY_I2Cx_CLK_ENABLE, DISCOVERY_I2Cx_ER_IRQn, DISCOVERY_I2Cx_EV_IRQn, DISCOVERY_I2Cx_FORCE_RESET, DISCOVERY_I2Cx_RELEASE_RESET, DISCOVERY_I2Cx_SCL_PIN, DISCOVERY_I2Cx_SCL_SDA_AF, DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_ENABLE, DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT, and DISCOVERY_I2Cx_SDA_PIN.

Referenced by I2Cx_Init().

static void SPIx_Error ( void ) [static]

SPIx error treatment function.

Definition at line 338 of file stm32f4_discovery.c.

References SpiHandle, and SPIx_Init().

Referenced by SPIx_WriteRead().

static void SPIx_Init ( void ) [static]

SPIx Bus initialization.

Definition at line 292 of file stm32f4_discovery.c.

References DISCOVERY_SPIx, SpiHandle, and SPIx_MspInit().

Referenced by ACCELERO_IO_Init(), and SPIx_Error().

static void SPIx_MspInit ( void ) [static]

SPI MSP Init.

Definition at line 350 of file stm32f4_discovery.c.

References DISCOVERY_SPIx_AF, DISCOVERY_SPIx_CLK_ENABLE, DISCOVERY_SPIx_GPIO_CLK_ENABLE, DISCOVERY_SPIx_GPIO_PORT, DISCOVERY_SPIx_MISO_PIN, DISCOVERY_SPIx_MOSI_PIN, and DISCOVERY_SPIx_SCK_PIN.

Referenced by SPIx_Init().


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY LOW LEVEL LED Functions

Functions
STM32F4 DISCOVERY LOW LEVEL LED Functions
STM32F4 DISCOVERY LOW LEVEL

Functions

uint32_t | BSP_GetVersion (void)
This method returns the STM32F4 DISCO BSP Driver revision.
void | BSP_LED_Init (Led_TypeDef Led)
Configures LED GPIO.
void | BSP_LED_On (Led_TypeDef Led)
Turns selected LED On.
void | BSP_LED_Off (Led_TypeDef Led)
Turns selected LED Off.
void | BSP_LED_Toggle (Led_TypeDef Led)
Toggles the selected LED.

Function Documentation

uint32_t BSP_GetVersion ( void )

This method returns the STM32F4 DISCO BSP Driver revision.

Return values:
version : 0xXYZR (8bits for each decimal, R for RC)

Definition at line 139 of file stm32f4_discovery.c.

References __STM32F4_DISCO_BSP_VERSION.

void BSP_LED_Init ( Led_TypeDef Led )

Configures LED GPIO.

Parameters:
Led,: Specifies the Led to be configured. This parameter can be one of following parameters:
  • LED4
  • LED3
  • LED5
  • LED6

Definition at line 153 of file stm32f4_discovery.c.

References GPIO_PIN, GPIO_PORT, and LEDx_GPIO_CLK_ENABLE.

void BSP_LED_Off ( Led_TypeDef Led )

Turns selected LED Off.

Parameters:
Led,: Specifies the Led to be set off. This parameter can be one of following parameters:
  • LED4
  • LED3
  • LED5
  • LED6

Definition at line 194 of file stm32f4_discovery.c.

References GPIO_PIN, and GPIO_PORT.

void BSP_LED_On ( Led_TypeDef Led )

Turns selected LED On.

Parameters:
Led,: Specifies the Led to be set on. This parameter can be one of following parameters:
  • LED4
  • LED3
  • LED5
  • LED6

Definition at line 180 of file stm32f4_discovery.c.

References GPIO_PIN, and GPIO_PORT.

void BSP_LED_Toggle ( Led_TypeDef Led )

Toggles the selected LED.

Parameters:
Led,: Specifies the Led to be toggled. This parameter can be one of following parameters:
  • LED4
  • LED3
  • LED5
  • LED6

Definition at line 208 of file stm32f4_discovery.c.

References GPIO_PIN, and GPIO_PORT.


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY LOW LEVEL BUTTON Functions

Functions
STM32F4 DISCOVERY LOW LEVEL BUTTON Functions
STM32F4 DISCOVERY LOW LEVEL

Functions

void | BSP_PB_Init (Button_TypeDef Button, ButtonMode_TypeDef Mode)
Configures Button GPIO and EXTI Line.
uint32_t | BSP_PB_GetState (Button_TypeDef Button)
Returns the selected Button state.

Function Documentation

uint32_t BSP_PB_GetState ( Button_TypeDef Button )

Returns the selected Button state.

Parameters:
Button,: Specifies the Button to be checked. This parameter should be: BUTTON_KEY
Return values:
The Button GPIO pin value.

Definition at line 270 of file stm32f4_discovery.c.

References BUTTON_PIN, and BUTTON_PORT.

void BSP_PB_Init | ( | Button_TypeDef | Button,
 |  | ButtonMode_TypeDef | Mode
 | ) |  |

Configures Button GPIO and EXTI Line.

Parameters:
Button,: Specifies the Button to be configured. This parameter should be: BUTTON_KEY
Mode,: Specifies Button mode. This parameter can be one of following parameters:
  • BUTTON_MODE_GPIO: Button will be used as simple IO
  • BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt generation capability

Definition at line 231 of file stm32f4_discovery.c.

References BUTTON_IRQn, BUTTON_MODE_EXTI, BUTTON_MODE_GPIO, BUTTON_PIN, BUTTON_PORT, and BUTTONx_GPIO_CLK_ENABLE.


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY LOW LEVEL BUS Functions

Functions
STM32F4 DISCOVERY LOW LEVEL BUS Functions
STM32F4 DISCOVERY LOW LEVEL

Functions

static uint8_t | SPIx_WriteRead (uint8_t Byte)
Sends a Byte through the SPI interface and return the Byte received from the SPI bus.
static void | I2Cx_WriteData (uint8_t Addr, uint8_t Reg, uint8_t Value)
Write a value in a register of the device through BUS.
static uint8_t | I2Cx_ReadData (uint8_t Addr, uint8_t Reg)
Read a register of the device through BUS.
static void | I2Cx_Error (uint8_t Addr)
Manages error callback by re-initializing I2C.
void | ACCELERO_IO_ITConfig (void)
Configures the Accelerometer INT2.
void | ACCELERO_IO_Write (uint8_t *pBuffer, uint8_t WriteAddr, uint16_t NumByteToWrite)
Writes one byte to the Accelerometer.
void | ACCELERO_IO_Read (uint8_t *pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead)
Reads a block of data from the Accelerometer.
void | AUDIO_IO_Write (uint8_t Addr, uint8_t Reg, uint8_t Value)
Writes a single data.
uint8_t | AUDIO_IO_Read (uint8_t Addr, uint8_t Reg)
Reads a single data.

Function Documentation

void ACCELERO_IO_ITConfig ( void )

Configures the Accelerometer INT2.

EXTI0 is already used by user button so INT1 is not configured here.

Definition at line 516 of file stm32f4_discovery.c.

References ACCELERO_INT2_EXTI_IRQn, ACCELERO_INT2_PIN, ACCELERO_INT_GPIO_CLK_ENABLE, and ACCELERO_INT_GPIO_PORT.

void ACCELERO_IO_Read | ( | uint8_t * | pBuffer,
 |  | uint8_t | ReadAddr,
 |  | uint16_t | NumByteToRead
 | ) |  |

Reads a block of data from the Accelerometer.

Parameters:
pBuffer,: pointer to the buffer that receives the data read from the Accelerometer.
ReadAddr,: Accelerometer's internal address to read from.
NumByteToRead,: number of bytes to read from the Accelerometer.

Definition at line 575 of file stm32f4_discovery.c.

References ACCELERO_CS_HIGH, ACCELERO_CS_LOW, DUMMY_BYTE, MULTIPLEBYTE_CMD, READWRITE_CMD, and SPIx_WriteRead().

void ACCELERO_IO_Write | ( | uint8_t * | pBuffer,
 |  | uint8_t | WriteAddr,
 |  | uint16_t | NumByteToWrite
 | ) |  |

Writes one byte to the Accelerometer.

Parameters:
pBuffer,: pointer to the buffer containing the data to be written to the Accelerometer.
WriteAddr,: Accelerometer's internal address to write to.
NumByteToWrite,: Number of bytes to write.

Definition at line 541 of file stm32f4_discovery.c.

References ACCELERO_CS_HIGH, ACCELERO_CS_LOW, MULTIPLEBYTE_CMD, and SPIx_WriteRead().

uint8_t AUDIO_IO_Read | ( | uint8_t | Addr,
 |  | uint8_t | Reg
 | ) |  |

Reads a single data.

Parameters:
Addr,: I2C address
Reg,: Reg address
Return values:
Data to be read

Definition at line 663 of file stm32f4_discovery.c.

References I2Cx_ReadData().

void AUDIO_IO_Write | ( | uint8_t | Addr,
 |  | uint8_t | Reg,
 |  | uint8_t | Value
 | ) |  |

Writes a single data.

Parameters:
Addr,: I2C address
Reg,: Reg address
Value,: Data to be written

Definition at line 652 of file stm32f4_discovery.c.

References I2Cx_WriteData().

static void I2Cx_Error ( uint8_t Addr ) [static]

Manages error callback by re-initializing I2C.

Parameters:
Addr,: I2C Address

Definition at line 437 of file stm32f4_discovery.c.

References I2cHandle, and I2Cx_Init().

Referenced by I2Cx_ReadData(), and I2Cx_WriteData().

static uint8_t I2Cx_ReadData | ( | uint8_t | Addr,
 |  | uint8_t | Reg
 | ) |  | [static]

Read a register of the device through BUS.

Parameters:
Addr,: Device address on BUS
Reg,: The target register address to read
Return values:
HAL status

Definition at line 417 of file stm32f4_discovery.c.

References I2cHandle, I2Cx_Error(), and I2cxTimeout.

Referenced by AUDIO_IO_Read().

static void I2Cx_WriteData | ( | uint8_t | Addr,
 |  | uint8_t | Reg,
 |  | uint8_t | Value
 | ) |  | [static]

Write a value in a register of the device through BUS.

Parameters:
Addr,: Device address on BUS Bus.
Reg,: The target register address to write
Value,: The target register value to be written
Return values:
HAL status

Definition at line 397 of file stm32f4_discovery.c.

References I2cHandle, I2Cx_Error(), and I2cxTimeout.

Referenced by AUDIO_IO_Write().

static uint8_t SPIx_WriteRead ( uint8_t Byte ) [static]

Sends a Byte through the SPI interface and return the Byte received from the SPI bus.

Parameters:
Byte,: Byte send.
Return values:
The received byte value

Definition at line 321 of file stm32f4_discovery.c.

References SpiHandle, SPIx_Error(), and SpixTimeout.

Referenced by ACCELERO_IO_Read(), and ACCELERO_IO_Write().


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY LOW LEVEL_Exported_Types

Enumerations
STM32F4 DISCOVERY LOW LEVEL_Exported_Types
STM32F4 DISCOVERY LOW LEVEL

Enumerations

enum | Led_TypeDef { LED4 = 0, LED3 = 1, LED5 = 2, LED6 = 3 }
enum | Button_TypeDef { BUTTON_KEY = 0 }
enum | ButtonMode_TypeDef { BUTTON_MODE_GPIO = 0, BUTTON_MODE_EXTI = 1 }

Enumeration Type Documentation

enum Button_TypeDef
Enumerator:
BUTTON_KEY

Definition at line 54 of file stm32f4_discovery.h.

enum ButtonMode_TypeDef
Enumerator:
BUTTON_MODE_GPIO
BUTTON_MODE_EXTI

Definition at line 59 of file stm32f4_discovery.h.

enum Led_TypeDef
Enumerator:
LED4
LED3
LED5
LED6

Definition at line 46 of file stm32f4_discovery.h.


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY LOW LEVEL LED

Defines
STM32F4 DISCOVERY LOW LEVEL LED
STM32F4 DISCOVERY LOW LEVEL Exported Constants

Define for STM32F4_DISCOVERY board. More...

Defines

#define | LEDn 4
#define | LED4_PIN GPIO_PIN_12
#define | LED4_GPIO_PORT GPIOD
#define | LED4_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define | LED4_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
#define | LED3_PIN GPIO_PIN_13
#define | LED3_GPIO_PORT GPIOD
#define | LED3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define | LED3_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
#define | LED5_PIN GPIO_PIN_14
#define | LED5_GPIO_PORT GPIOD
#define | LED5_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define | LED5_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
#define | LED6_PIN GPIO_PIN_15
#define | LED6_GPIO_PORT GPIOD
#define | LED6_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define | LED6_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
#define | LEDx_GPIO_CLK_ENABLE(__INDEX__)
#define | LEDx_GPIO_CLK_DISABLE(__INDEX__)

Detailed Description

Define for STM32F4_DISCOVERY board.

Define Documentation

#define LED3_GPIO_CLK_DISABLE ( ) __HAL_RCC_GPIOD_CLK_DISABLE()

Definition at line 92 of file stm32f4_discovery.h.

#define LED3_GPIO_CLK_ENABLE ( ) __HAL_RCC_GPIOD_CLK_ENABLE()

Definition at line 91 of file stm32f4_discovery.h.

#define LED3_GPIO_PORT GPIOD

Definition at line 90 of file stm32f4_discovery.h.

#define LED3_PIN GPIO_PIN_13

Definition at line 89 of file stm32f4_discovery.h.

#define LED4_GPIO_CLK_DISABLE ( ) __HAL_RCC_GPIOD_CLK_DISABLE()

Definition at line 87 of file stm32f4_discovery.h.

#define LED4_GPIO_CLK_ENABLE ( ) __HAL_RCC_GPIOD_CLK_ENABLE()

Definition at line 86 of file stm32f4_discovery.h.

#define LED4_GPIO_PORT GPIOD

Definition at line 85 of file stm32f4_discovery.h.

#define LED4_PIN GPIO_PIN_12

Definition at line 84 of file stm32f4_discovery.h.

#define LED5_GPIO_CLK_DISABLE ( ) __HAL_RCC_GPIOD_CLK_DISABLE()

Definition at line 97 of file stm32f4_discovery.h.

#define LED5_GPIO_CLK_ENABLE ( ) __HAL_RCC_GPIOD_CLK_ENABLE()

Definition at line 96 of file stm32f4_discovery.h.

#define LED5_GPIO_PORT GPIOD

Definition at line 95 of file stm32f4_discovery.h.

#define LED5_PIN GPIO_PIN_14

Definition at line 94 of file stm32f4_discovery.h.

#define LED6_GPIO_CLK_DISABLE ( ) __HAL_RCC_GPIOD_CLK_DISABLE()

Definition at line 102 of file stm32f4_discovery.h.

#define LED6_GPIO_CLK_ENABLE ( ) __HAL_RCC_GPIOD_CLK_ENABLE()

Definition at line 101 of file stm32f4_discovery.h.

#define LED6_GPIO_PORT GPIOD

Definition at line 100 of file stm32f4_discovery.h.

#define LED6_PIN GPIO_PIN_15

Definition at line 99 of file stm32f4_discovery.h.

#define LEDn 4

Definition at line 82 of file stm32f4_discovery.h.

#define LEDx_GPIO_CLK_DISABLE ( __INDEX__ )
Value:
do{if((__INDEX__) == 0) LED4_GPIO_CLK_DISABLE(); else \
                                            if((__INDEX__) == 1) LED3_GPIO_CLK_DISABLE(); else \
                                            if((__INDEX__) == 2) LED5_GPIO_CLK_DISABLE(); else \
                                            if((__INDEX__) == 3) LED6_GPIO_CLK_DISABLE(); \
                                            }while(0)

Definition at line 110 of file stm32f4_discovery.h.

#define LEDx_GPIO_CLK_ENABLE ( __INDEX__ )
Value:
do{if((__INDEX__) == 0) LED4_GPIO_CLK_ENABLE(); else \
                                           if((__INDEX__) == 1) LED3_GPIO_CLK_ENABLE(); else \
                                           if((__INDEX__) == 2) LED5_GPIO_CLK_ENABLE(); else \
                                           if((__INDEX__) == 3) LED6_GPIO_CLK_ENABLE(); \
                                           }while(0)

Definition at line 104 of file stm32f4_discovery.h.

Referenced by BSP_LED_Init().


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY LOW LEVEL BUTTON

Defines
STM32F4 DISCOVERY LOW LEVEL BUTTON
STM32F4 DISCOVERY LOW LEVEL Exported Constants

Defines

#define | BUTTONn 1
#define | KEY_BUTTON_PIN GPIO_PIN_0
Wakeup push-button.
#define | KEY_BUTTON_GPIO_PORT GPIOA
#define | KEY_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define | KEY_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
#define | KEY_BUTTON_EXTI_IRQn EXTI0_IRQn
#define | BUTTONx_GPIO_CLK_ENABLE(__INDEX__)
#define | BUTTONx_GPIO_CLK_DISABLE(__INDEX__)

Define Documentation

#define BUTTONn 1

Definition at line 122 of file stm32f4_discovery.h.

#define BUTTONx_GPIO_CLK_DISABLE ( __INDEX__ )
Value:
do{if((__INDEX__) == 0) KEY_BUTTON_GPIO_CLK_DISABLE(); \
                                                 }while(0)

Definition at line 136 of file stm32f4_discovery.h.

#define BUTTONx_GPIO_CLK_ENABLE ( __INDEX__ )
Value:
do{if((__INDEX__) == 0) KEY_BUTTON_GPIO_CLK_ENABLE(); \
                                                }while(0)

Definition at line 133 of file stm32f4_discovery.h.

Referenced by BSP_PB_Init().

#define KEY_BUTTON_EXTI_IRQn EXTI0_IRQn

Definition at line 131 of file stm32f4_discovery.h.

#define KEY_BUTTON_GPIO_CLK_DISABLE ( ) __HAL_RCC_GPIOA_CLK_DISABLE()

Definition at line 130 of file stm32f4_discovery.h.

#define KEY_BUTTON_GPIO_CLK_ENABLE ( ) __HAL_RCC_GPIOA_CLK_ENABLE()

Definition at line 129 of file stm32f4_discovery.h.

#define KEY_BUTTON_GPIO_PORT GPIOA

Definition at line 128 of file stm32f4_discovery.h.

#define KEY_BUTTON_PIN GPIO_PIN_0

Wakeup push-button.

Definition at line 127 of file stm32f4_discovery.h.


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY LOW LEVEL BUS

Defines
STM32F4 DISCOVERY LOW LEVEL BUS
STM32F4 DISCOVERY LOW LEVEL Exported Constants

Defines

#define | DISCOVERY_SPIx SPI1
#define | DISCOVERY_SPIx_CLK_ENABLE() __HAL_RCC_SPI1_CLK_ENABLE()
#define | DISCOVERY_SPIx_GPIO_PORT GPIOA /* GPIOA */
#define | DISCOVERY_SPIx_AF GPIO_AF5_SPI1
#define | DISCOVERY_SPIx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define | DISCOVERY_SPIx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
#define | DISCOVERY_SPIx_SCK_PIN GPIO_PIN_5 /* PA.05 */
#define | DISCOVERY_SPIx_MISO_PIN GPIO_PIN_6 /* PA.06 */
#define | DISCOVERY_SPIx_MOSI_PIN GPIO_PIN_7 /* PA.07 */
#define | SPIx_TIMEOUT_MAX 0x1000 /*<! The value of the maximal timeout for BUS waiting loops */
#define | DISCOVERY_I2Cx I2C1
#define | DISCOVERY_I2Cx_CLK_ENABLE() __HAL_RCC_I2C1_CLK_ENABLE()
#define | DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define | DISCOVERY_I2Cx_SCL_SDA_AF GPIO_AF4_I2C1
#define | DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT GPIOB
#define | DISCOVERY_I2Cx_SCL_PIN GPIO_PIN_6
#define | DISCOVERY_I2Cx_SDA_PIN GPIO_PIN_9
#define | DISCOVERY_I2Cx_FORCE_RESET() __HAL_RCC_I2C1_FORCE_RESET()
#define | DISCOVERY_I2Cx_RELEASE_RESET() __HAL_RCC_I2C1_RELEASE_RESET()
#define | DISCOVERY_I2Cx_EV_IRQn I2C1_EV_IRQn
#define | DISCOVERY_I2Cx_ER_IRQn I2C1_ER_IRQn
#define | I2Cx_TIMEOUT_MAX 0x1000 /*<! The value of the maximal timeout for BUS waiting loops */
#define | READWRITE_CMD ((uint8_t)0x80)
#define | MULTIPLEBYTE_CMD ((uint8_t)0x40)
#define | DUMMY_BYTE ((uint8_t)0x00)
#define | ACCELERO_CS_LOW() HAL_GPIO_WritePin(ACCELERO_CS_GPIO_PORT, ACCELERO_CS_PIN, GPIO_PIN_RESET)
#define | ACCELERO_CS_HIGH() HAL_GPIO_WritePin(ACCELERO_CS_GPIO_PORT, ACCELERO_CS_PIN, GPIO_PIN_SET)
#define | ACCELERO_CS_PIN GPIO_PIN_3 /* PE.03 */
ACCELEROMETER Interface pins.
#define | ACCELERO_CS_GPIO_PORT GPIOE /* GPIOE */
#define | ACCELERO_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
#define | ACCELERO_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE()
#define | ACCELERO_INT_GPIO_PORT GPIOE /* GPIOE */
#define | ACCELERO_INT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
#define | ACCELERO_INT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE()
#define | ACCELERO_INT1_PIN GPIO_PIN_0 /* PE.00 */
#define | ACCELERO_INT1_EXTI_IRQn EXTI0_IRQn
#define | ACCELERO_INT2_PIN GPIO_PIN_1 /* PE.01 */
#define | ACCELERO_INT2_EXTI_IRQn EXTI1_IRQn

Define Documentation

#define ACCELERO_CS_GPIO_CLK_DISABLE ( ) __HAL_RCC_GPIOE_CLK_DISABLE()

Definition at line 213 of file stm32f4_discovery.h.

#define ACCELERO_CS_GPIO_CLK_ENABLE ( ) __HAL_RCC_GPIOE_CLK_ENABLE()

Definition at line 212 of file stm32f4_discovery.h.

Referenced by ACCELERO_IO_Init().

#define ACCELERO_CS_GPIO_PORT GPIOE /* GPIOE */

Definition at line 211 of file stm32f4_discovery.h.

Referenced by ACCELERO_IO_Init().

#define ACCELERO_CS_HIGH ( ) HAL_GPIO_WritePin(ACCELERO_CS_GPIO_PORT, ACCELERO_CS_PIN, GPIO_PIN_SET)

Definition at line 205 of file stm32f4_discovery.h.

Referenced by ACCELERO_IO_Init(), ACCELERO_IO_Read(), and ACCELERO_IO_Write().

#define ACCELERO_CS_LOW ( ) HAL_GPIO_WritePin(ACCELERO_CS_GPIO_PORT, ACCELERO_CS_PIN, GPIO_PIN_RESET)

Definition at line 204 of file stm32f4_discovery.h.

Referenced by ACCELERO_IO_Read(), and ACCELERO_IO_Write().

#define ACCELERO_CS_PIN GPIO_PIN_3 /* PE.03 */

ACCELEROMETER Interface pins.

Definition at line 210 of file stm32f4_discovery.h.

Referenced by ACCELERO_IO_Init().

#define ACCELERO_INT1_EXTI_IRQn EXTI0_IRQn

Definition at line 218 of file stm32f4_discovery.h.

#define ACCELERO_INT1_PIN GPIO_PIN_0 /* PE.00 */

Definition at line 217 of file stm32f4_discovery.h.

#define ACCELERO_INT2_EXTI_IRQn EXTI1_IRQn

Definition at line 220 of file stm32f4_discovery.h.

Referenced by ACCELERO_IO_ITConfig().

#define ACCELERO_INT2_PIN GPIO_PIN_1 /* PE.01 */

Definition at line 219 of file stm32f4_discovery.h.

Referenced by ACCELERO_IO_ITConfig().

#define ACCELERO_INT_GPIO_CLK_DISABLE ( ) __HAL_RCC_GPIOE_CLK_DISABLE()

Definition at line 216 of file stm32f4_discovery.h.

#define ACCELERO_INT_GPIO_CLK_ENABLE ( ) __HAL_RCC_GPIOE_CLK_ENABLE()

Definition at line 215 of file stm32f4_discovery.h.

Referenced by ACCELERO_IO_ITConfig().

#define ACCELERO_INT_GPIO_PORT GPIOE /* GPIOE */

Definition at line 214 of file stm32f4_discovery.h.

Referenced by ACCELERO_IO_ITConfig().

#define DISCOVERY_I2Cx I2C1

Definition at line 172 of file stm32f4_discovery.h.

Referenced by I2Cx_Init().

#define DISCOVERY_I2Cx_CLK_ENABLE ( ) __HAL_RCC_I2C1_CLK_ENABLE()

Definition at line 173 of file stm32f4_discovery.h.

Referenced by I2Cx_MspInit().

#define DISCOVERY_I2Cx_ER_IRQn I2C1_ER_IRQn

Definition at line 185 of file stm32f4_discovery.h.

Referenced by I2Cx_MspInit().

#define DISCOVERY_I2Cx_EV_IRQn I2C1_EV_IRQn

Definition at line 184 of file stm32f4_discovery.h.

Referenced by I2Cx_MspInit().

#define DISCOVERY_I2Cx_FORCE_RESET ( ) __HAL_RCC_I2C1_FORCE_RESET()

Definition at line 180 of file stm32f4_discovery.h.

Referenced by I2Cx_MspInit().

#define DISCOVERY_I2Cx_RELEASE_RESET ( ) __HAL_RCC_I2C1_RELEASE_RESET()

Definition at line 181 of file stm32f4_discovery.h.

Referenced by I2Cx_MspInit().

#define DISCOVERY_I2Cx_SCL_PIN GPIO_PIN_6

Definition at line 177 of file stm32f4_discovery.h.

Referenced by I2Cx_MspInit().

#define DISCOVERY_I2Cx_SCL_SDA_AF GPIO_AF4_I2C1

Definition at line 175 of file stm32f4_discovery.h.

Referenced by I2Cx_MspInit().

#define DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_ENABLE ( ) __HAL_RCC_GPIOB_CLK_ENABLE()

Definition at line 174 of file stm32f4_discovery.h.

Referenced by I2Cx_MspInit().

#define DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT GPIOB

Definition at line 176 of file stm32f4_discovery.h.

Referenced by I2Cx_MspInit().

#define DISCOVERY_I2Cx_SDA_PIN GPIO_PIN_9

Definition at line 178 of file stm32f4_discovery.h.

Referenced by I2Cx_MspInit().

#define DISCOVERY_SPIx SPI1

Definition at line 147 of file stm32f4_discovery.h.

Referenced by SPIx_Init().

#define DISCOVERY_SPIx_AF GPIO_AF5_SPI1

Definition at line 150 of file stm32f4_discovery.h.

Referenced by SPIx_MspInit().

#define DISCOVERY_SPIx_CLK_ENABLE ( ) __HAL_RCC_SPI1_CLK_ENABLE()

Definition at line 148 of file stm32f4_discovery.h.

Referenced by SPIx_MspInit().

#define DISCOVERY_SPIx_GPIO_CLK_DISABLE ( ) __HAL_RCC_GPIOA_CLK_DISABLE()

Definition at line 152 of file stm32f4_discovery.h.

#define DISCOVERY_SPIx_GPIO_CLK_ENABLE ( ) __HAL_RCC_GPIOA_CLK_ENABLE()

Definition at line 151 of file stm32f4_discovery.h.

Referenced by SPIx_MspInit().

#define DISCOVERY_SPIx_GPIO_PORT GPIOA /* GPIOA */

Definition at line 149 of file stm32f4_discovery.h.

Referenced by SPIx_MspInit().

#define DISCOVERY_SPIx_MISO_PIN GPIO_PIN_6 /* PA.06 */

Definition at line 154 of file stm32f4_discovery.h.

Referenced by SPIx_MspInit().

#define DISCOVERY_SPIx_MOSI_PIN GPIO_PIN_7 /* PA.07 */

Definition at line 155 of file stm32f4_discovery.h.

Referenced by SPIx_MspInit().

#define DISCOVERY_SPIx_SCK_PIN GPIO_PIN_5 /* PA.05 */

Definition at line 153 of file stm32f4_discovery.h.

Referenced by SPIx_MspInit().

#define DUMMY_BYTE ((uint8_t)0x00)

Definition at line 201 of file stm32f4_discovery.h.

Referenced by ACCELERO_IO_Read().

#define I2Cx_TIMEOUT_MAX 0x1000 /*<! The value of the maximal timeout for BUS waiting loops */

Definition at line 192 of file stm32f4_discovery.h.

#define MULTIPLEBYTE_CMD ((uint8_t)0x40)

Definition at line 199 of file stm32f4_discovery.h.

Referenced by ACCELERO_IO_Read(), and ACCELERO_IO_Write().

#define READWRITE_CMD ((uint8_t)0x80)

Definition at line 197 of file stm32f4_discovery.h.

Referenced by ACCELERO_IO_Read().

#define SPIx_TIMEOUT_MAX 0x1000 /*<! The value of the maximal timeout for BUS waiting loops */

Definition at line 162 of file stm32f4_discovery.h.


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY LOW LEVEL Exported Constants

Modules | Defines
STM32F4 DISCOVERY LOW LEVEL Exported Constants
STM32F4 DISCOVERY LOW LEVEL

Modules

STM32F4 DISCOVERY LOW LEVEL LED

Define for STM32F4_DISCOVERY board.

STM32F4 DISCOVERY LOW LEVEL BUTTON
STM32F4 DISCOVERY LOW LEVEL BUS

Defines

#define | AUDIO_I2C_ADDRESS 0x94
AUDIO I2C Interface pins.
#define | AUDIO_RESET_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define | AUDIO_RESET_PIN GPIO_PIN_4
#define | AUDIO_RESET_GPIO GPIOD

Define Documentation

#define AUDIO_I2C_ADDRESS 0x94

AUDIO I2C Interface pins.

Definition at line 230 of file stm32f4_discovery.h.

Referenced by BSP_AUDIO_OUT_Init(), BSP_AUDIO_OUT_Pause(), BSP_AUDIO_OUT_Play(), BSP_AUDIO_OUT_Resume(), BSP_AUDIO_OUT_SetMute(), BSP_AUDIO_OUT_SetOutputMode(), BSP_AUDIO_OUT_SetVolume(), and BSP_AUDIO_OUT_Stop().

#define AUDIO_RESET_GPIO GPIOD

Definition at line 235 of file stm32f4_discovery.h.

Referenced by AUDIO_IO_Init(), and BSP_AUDIO_OUT_Stop().

#define AUDIO_RESET_GPIO_CLK_ENABLE ( ) __HAL_RCC_GPIOD_CLK_ENABLE()

Definition at line 233 of file stm32f4_discovery.h.

Referenced by AUDIO_IO_Init().

#define AUDIO_RESET_PIN GPIO_PIN_4

Definition at line 234 of file stm32f4_discovery.h.

Referenced by AUDIO_IO_Init(), and BSP_AUDIO_OUT_Stop().


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY LOW LEVEL Exported Macros

STM32F4 DISCOVERY LOW LEVEL Exported Macros
STM32F4 DISCOVERY LOW LEVEL


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY LOW LEVEL Exported Functions

Functions
STM32F4 DISCOVERY LOW LEVEL Exported Functions
STM32F4 DISCOVERY LOW LEVEL

Functions

uint32_t | BSP_GetVersion (void)
This method returns the STM32F4 DISCO BSP Driver revision.
void | BSP_LED_Init (Led_TypeDef Led)
Configures LED GPIO.
void | BSP_LED_On (Led_TypeDef Led)
Turns selected LED On.
void | BSP_LED_Off (Led_TypeDef Led)
Turns selected LED Off.
void | BSP_LED_Toggle (Led_TypeDef Led)
Toggles the selected LED.
void | BSP_PB_Init (Button_TypeDef Button, ButtonMode_TypeDef Mode)
Configures Button GPIO and EXTI Line.
uint32_t | BSP_PB_GetState (Button_TypeDef Button)
Returns the selected Button state.

Function Documentation

uint32_t BSP_GetVersion ( void )

This method returns the STM32F4 DISCO BSP Driver revision.

Return values:
version : 0xXYZR (8bits for each decimal, R for RC)

Definition at line 139 of file stm32f4_discovery.c.

References __STM32F4_DISCO_BSP_VERSION.

void BSP_LED_Init ( Led_TypeDef Led )

Configures LED GPIO.

Parameters:
Led,: Specifies the Led to be configured. This parameter can be one of following parameters:
  • LED4
  • LED3
  • LED5
  • LED6

Definition at line 153 of file stm32f4_discovery.c.

References GPIO_PIN, GPIO_PORT, and LEDx_GPIO_CLK_ENABLE.

void BSP_LED_Off ( Led_TypeDef Led )

Turns selected LED Off.

Parameters:
Led,: Specifies the Led to be set off. This parameter can be one of following parameters:
  • LED4
  • LED3
  • LED5
  • LED6

Definition at line 194 of file stm32f4_discovery.c.

References GPIO_PIN, and GPIO_PORT.

void BSP_LED_On ( Led_TypeDef Led )

Turns selected LED On.

Parameters:
Led,: Specifies the Led to be set on. This parameter can be one of following parameters:
  • LED4
  • LED3
  • LED5
  • LED6

Definition at line 180 of file stm32f4_discovery.c.

References GPIO_PIN, and GPIO_PORT.

void BSP_LED_Toggle ( Led_TypeDef Led )

Toggles the selected LED.

Parameters:
Led,: Specifies the Led to be toggled. This parameter can be one of following parameters:
  • LED4
  • LED3
  • LED5
  • LED6

Definition at line 208 of file stm32f4_discovery.c.

References GPIO_PIN, and GPIO_PORT.

uint32_t BSP_PB_GetState ( Button_TypeDef Button )

Returns the selected Button state.

Parameters:
Button,: Specifies the Button to be checked. This parameter should be: BUTTON_KEY
Return values:
The Button GPIO pin value.

Definition at line 270 of file stm32f4_discovery.c.

References BUTTON_PIN, and BUTTON_PORT.

void BSP_PB_Init | ( | Button_TypeDef | Button,
 |  | ButtonMode_TypeDef | Mode
 | ) |  |

Configures Button GPIO and EXTI Line.

Parameters:
Button,: Specifies the Button to be configured. This parameter should be: BUTTON_KEY
Mode,: Specifies Button mode. This parameter can be one of following parameters:
  • BUTTON_MODE_GPIO: Button will be used as simple IO
  • BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt generation capability

Definition at line 231 of file stm32f4_discovery.c.

References BUTTON_IRQn, BUTTON_MODE_EXTI, BUTTON_MODE_GPIO, BUTTON_PIN, BUTTON_PORT, and BUTTONx_GPIO_CLK_ENABLE.


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY ACCELEROMETER Private TypesDefinitions

STM32F4 DISCOVERY ACCELEROMETER Private TypesDefinitions
STM32F4 DISCOVERY ACCELEROMETER


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY ACCELEROMETER Private Defines

STM32F4 DISCOVERY ACCELEROMETER Private Defines
STM32F4 DISCOVERY ACCELEROMETER


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY ACCELEROMETER Private Macros

STM32F4 DISCOVERY ACCELEROMETER Private Macros
STM32F4 DISCOVERY ACCELEROMETER


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY ACCELEROMETER Private Variables

Variables
STM32F4 DISCOVERY ACCELEROMETER Private Variables
STM32F4 DISCOVERY ACCELEROMETER

Variables

static ACCELERO_DrvTypeDef * AcceleroDrv

Variable Documentation

ACCELERO_DrvTypeDef* AcceleroDrv [static]

Definition at line 61 of file stm32f4_discovery_accelerometer.c.

Referenced by BSP_ACCELERO_Click_ITClear(), BSP_ACCELERO_Click_ITConfig(), BSP_ACCELERO_GetXYZ(), BSP_ACCELERO_Init(), BSP_ACCELERO_ReadID(), and BSP_ACCELERO_Reset().


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY ACCELEROMETER Private FunctionPrototypes

STM32F4 DISCOVERY ACCELEROMETER Private FunctionPrototypes
STM32F4 DISCOVERY ACCELEROMETER


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY ACCELEROMETER Private Functions

Functions
STM32F4 DISCOVERY ACCELEROMETER Private Functions
STM32F4 DISCOVERY ACCELEROMETER

Functions

uint8_t | BSP_ACCELERO_Init (void)
Setx Accelerometer Initialization.
uint8_t | BSP_ACCELERO_ReadID (void)
Read ID of Accelerometer component.
void | BSP_ACCELERO_Reset (void)
Reboot memory content of Accelerometer.
void | BSP_ACCELERO_Click_ITConfig (void)
Configure Accelerometer click IT.
void | BSP_ACCELERO_Click_ITClear (void)
Clear Accelerometer click IT.
void | BSP_ACCELERO_GetXYZ (int16_t *pDataXYZ)
Get XYZ axes acceleration.

Function Documentation

void BSP_ACCELERO_Click_ITClear ( void )

Clear Accelerometer click IT.

Definition at line 200 of file stm32f4_discovery_accelerometer.c.

References AcceleroDrv.

void BSP_ACCELERO_Click_ITConfig ( void )

Configure Accelerometer click IT.

Definition at line 189 of file stm32f4_discovery_accelerometer.c.

References AcceleroDrv.

void BSP_ACCELERO_GetXYZ ( int16_t * pDataXYZ )

Get XYZ axes acceleration.

Parameters:
pDataXYZ,: Pointer to 3 angular acceleration axes. pDataXYZ[0] = X axis, pDataXYZ[1] = Y axis, pDataXYZ[2] = Z axis

Definition at line 213 of file stm32f4_discovery_accelerometer.c.

References AcceleroDrv.

uint8_t BSP_ACCELERO_Init ( void )

Setx Accelerometer Initialization.

Return values:
ACCELERO_OK if no problem during initialization

Definition at line 81 of file stm32f4_discovery_accelerometer.c.

References ACCELERO_ERROR, ACCELERO_OK, and AcceleroDrv.

uint8_t BSP_ACCELERO_ReadID ( void )

Read ID of Accelerometer component.

Return values:
ID

Definition at line 164 of file stm32f4_discovery_accelerometer.c.

References AcceleroDrv.

void BSP_ACCELERO_Reset ( void )

Reboot memory content of Accelerometer.

Definition at line 178 of file stm32f4_discovery_accelerometer.c.

References AcceleroDrv.


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY ACCELEROMETER Exported Types

Enumerations
STM32F4 DISCOVERY ACCELEROMETER Exported Types
STM32F4 DISCOVERY ACCELEROMETER

Enumerations

enum ACCELERO_StatusTypeDef { ACCELERO_OK = 0, ACCELERO_ERROR = 1, ACCELERO_TIMEOUT = 2 }

Enumeration Type Documentation

enum ACCELERO_StatusTypeDef
Enumerator:
ACCELERO_OK
ACCELERO_ERROR
ACCELERO_TIMEOUT

Definition at line 50 of file stm32f4_discovery_accelerometer.h.


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY ACCELEROMETER Exported Functions

Functions
STM32F4 DISCOVERY ACCELEROMETER Exported Functions
STM32F4 DISCOVERY ACCELEROMETER

Functions

uint8_t | BSP_ACCELERO_Init (void)
Setx Accelerometer Initialization.
uint8_t | BSP_ACCELERO_ReadID (void)
Read ID of Accelerometer component.
void | BSP_ACCELERO_Reset (void)
Reboot memory content of Accelerometer.
void | BSP_ACCELERO_Click_ITConfig (void)
Configure Accelerometer click IT.
void | BSP_ACCELERO_Click_ITClear (void)
Clear Accelerometer click IT.
void | BSP_ACCELERO_GetXYZ (int16_t *pDataXYZ)
Get XYZ axes acceleration.

Function Documentation

void BSP_ACCELERO_Click_ITClear ( void )

Clear Accelerometer click IT.

Definition at line 200 of file stm32f4_discovery_accelerometer.c.

References AcceleroDrv.

void BSP_ACCELERO_Click_ITConfig ( void )

Configure Accelerometer click IT.

Definition at line 189 of file stm32f4_discovery_accelerometer.c.

References AcceleroDrv.

void BSP_ACCELERO_GetXYZ ( int16_t * pDataXYZ )

Get XYZ axes acceleration.

Parameters:
pDataXYZ,: Pointer to 3 angular acceleration axes. pDataXYZ[0] = X axis, pDataXYZ[1] = Y axis, pDataXYZ[2] = Z axis

Definition at line 213 of file stm32f4_discovery_accelerometer.c.

References AcceleroDrv.

uint8_t BSP_ACCELERO_Init ( void )

Setx Accelerometer Initialization.

Return values:
ACCELERO_OK if no problem during initialization

Definition at line 81 of file stm32f4_discovery_accelerometer.c.

References ACCELERO_ERROR, ACCELERO_OK, and AcceleroDrv.

uint8_t BSP_ACCELERO_ReadID ( void )

Read ID of Accelerometer component.

Return values:
ID

Definition at line 164 of file stm32f4_discovery_accelerometer.c.

References AcceleroDrv.

void BSP_ACCELERO_Reset ( void )

Reboot memory content of Accelerometer.

Definition at line 178 of file stm32f4_discovery_accelerometer.c.

References AcceleroDrv.


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY AUDIO Private Types

STM32F4 DISCOVERY AUDIO Private Types
STM32F4 DISCOVERY AUDIO


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY AUDIO Private Defines

Variables
STM32F4 DISCOVERY AUDIO Private Defines
STM32F4 DISCOVERY AUDIO

Variables

const uint32_t | I2SFreq [8] = {8000, 11025, 16000, 22050, 32000, 44100, 48000, 96000}
const uint32_t | I2SPLLN [8] = {256, 429, 213, 429, 426, 271, 258, 344}
const uint32_t | I2SPLLR [8] = {5, 4, 4, 4, 4, 6, 3, 1}

Variable Documentation

const uint32_t I2SFreq[8] = {8000, 11025, 16000, 22050, 32000, 44100, 48000, 96000}

Definition at line 142 of file stm32f4_discovery_audio.c.

Referenced by BSP_AUDIO_OUT_ClockConfig().

const uint32_t I2SPLLN[8] = {256, 429, 213, 429, 426, 271, 258, 344}

Definition at line 143 of file stm32f4_discovery_audio.c.

Referenced by BSP_AUDIO_OUT_ClockConfig().

const uint32_t I2SPLLR[8] = {5, 4, 4, 4, 4, 6, 3, 1}

Definition at line 144 of file stm32f4_discovery_audio.c.

Referenced by BSP_AUDIO_OUT_ClockConfig().


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY AUDIO Private Macros

STM32F4 DISCOVERY AUDIO Private Macros
STM32F4 DISCOVERY AUDIO


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY AUDIO Private Variables

Variables
STM32F4 DISCOVERY AUDIO Private Variables
STM32F4 DISCOVERY AUDIO

Variables

static AUDIO_DrvTypeDef * | pAudioDrv
I2S_HandleTypeDef | hAudioOutI2s
I2S_HandleTypeDef | hAudioInI2s
PDM_Filter_Handler_t | PDM_FilterHandler [2]
PDM_Filter_Config_t | PDM_FilterConfig [2]
__IO uint16_t | AudioInVolume = DEFAULT_AUDIO_IN_VOLUME

Variable Documentation

__IO uint16_t AudioInVolume = DEFAULT_AUDIO_IN_VOLUME

Definition at line 170 of file stm32f4_discovery_audio.c.

Referenced by BSP_AUDIO_IN_SetVolume().

I2S_HandleTypeDef hAudioInI2s

Definition at line 164 of file stm32f4_discovery_audio.c.

Referenced by BSP_AUDIO_IN_Init(), BSP_AUDIO_IN_Pause(), BSP_AUDIO_IN_Record(), BSP_AUDIO_IN_Resume(), BSP_AUDIO_IN_Stop(), and I2S2_Init().

I2S_HandleTypeDef hAudioOutI2s

Definition at line 161 of file stm32f4_discovery_audio.c.

Referenced by BSP_AUDIO_OUT_ChangeBuffer(), BSP_AUDIO_OUT_Init(), BSP_AUDIO_OUT_Pause(), BSP_AUDIO_OUT_Play(), BSP_AUDIO_OUT_Resume(), BSP_AUDIO_OUT_SetFrequency(), BSP_AUDIO_OUT_Stop(), and I2S3_Init().

AUDIO_DrvTypeDef* pAudioDrv [static]

Definition at line 160 of file stm32f4_discovery_audio.c.

Referenced by BSP_AUDIO_OUT_Init(), BSP_AUDIO_OUT_Pause(), BSP_AUDIO_OUT_Play(), BSP_AUDIO_OUT_Resume(), BSP_AUDIO_OUT_SetMute(), BSP_AUDIO_OUT_SetOutputMode(), BSP_AUDIO_OUT_SetVolume(), and BSP_AUDIO_OUT_Stop().

PDM_Filter_Config_t PDM_FilterConfig[2]

Definition at line 168 of file stm32f4_discovery_audio.c.

Referenced by PDMDecoder_Init().

PDM_Filter_Handler_t PDM_FilterHandler[2]

Definition at line 167 of file stm32f4_discovery_audio.c.

Referenced by BSP_AUDIO_IN_PDMToPCM(), and PDMDecoder_Init().


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY AUDIO Private Function Prototypes

STM32F4 DISCOVERY AUDIO Private Function Prototypes
STM32F4 DISCOVERY AUDIO


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY AUDIO OUT Private Functions

Functions
STM32F4 DISCOVERY AUDIO OUT Private Functions
STM32F4 DISCOVERY AUDIO

Functions

uint8_t | BSP_AUDIO_OUT_Init (uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)
Configures the audio peripherals.
uint8_t | BSP_AUDIO_OUT_Play (uint16_t *pBuffer, uint32_t Size)
Starts playing audio stream from a data buffer for a determined size.
void | BSP_AUDIO_OUT_ChangeBuffer (uint16_t *pData, uint16_t Size)
Sends n-Bytes on the I2S interface.
uint8_t | BSP_AUDIO_OUT_Pause (void)
Pauses the audio file stream.
uint8_t | BSP_AUDIO_OUT_Resume (void)
Resumes the audio file streaming.
uint8_t | BSP_AUDIO_OUT_Stop (uint32_t Option)
Stops audio playing and Power down the Audio Codec.
uint8_t | BSP_AUDIO_OUT_SetVolume (uint8_t Volume)
Controls the current audio volume level.
uint8_t | BSP_AUDIO_OUT_SetMute (uint32_t Cmd)
Enables or disables the MUTE mode by software.
uint8_t | BSP_AUDIO_OUT_SetOutputMode (uint8_t Output)
Switch dynamically (while audio file is played) the output target (speaker or headphone).
void | BSP_AUDIO_OUT_SetFrequency (uint32_t AudioFreq)
Update the audio frequency.
void | HAL_I2S_TxCpltCallback (I2S_HandleTypeDef *hi2s)
Tx Transfer completed callbacks.
void | HAL_I2S_TxHalfCpltCallback (I2S_HandleTypeDef *hi2s)
Tx Half Transfer completed callbacks.
__weak void | BSP_AUDIO_OUT_ClockConfig (I2S_HandleTypeDef *hi2s, uint32_t AudioFreq, void *Params)
Clock Config.
__weak void | BSP_AUDIO_OUT_MspInit (I2S_HandleTypeDef *hi2s, void *Params)
AUDIO OUT I2S MSP Init.
__weak void | BSP_AUDIO_OUT_MspDeInit (I2S_HandleTypeDef *hi2s, void *Params)
De-Initializes BSP_AUDIO_OUT MSP.
__weak void | BSP_AUDIO_OUT_TransferComplete_CallBack (void)
Manages the DMA full Transfer complete event.
__weak void | BSP_AUDIO_OUT_HalfTransfer_CallBack (void)
Manages the DMA Half Transfer complete event.
__weak void | BSP_AUDIO_OUT_Error_CallBack (void)
Manages the DMA FIFO error event.
static uint8_t | I2S3_Init (uint32_t AudioFreq)
Initializes the Audio Codec audio interface (I2S).

Function Documentation

void BSP_AUDIO_OUT_ChangeBuffer | ( | uint16_t * | pData,
 |  | uint16_t | Size
 | ) |  |

Sends n-Bytes on the I2S interface.

Parameters:
pData,: Pointer to data address
Size,: Number of data to be written

Definition at line 271 of file stm32f4_discovery_audio.c.

References hAudioOutI2s.

__weak void BSP_AUDIO_OUT_ClockConfig | ( | I2S_HandleTypeDef * | hi2s,
 |  | uint32_t | AudioFreq,
 |  | void * | Params
 | ) |  |

Clock Config.

Parameters:
hi2s,: might be required to set audio peripheral predivider if any.
AudioFreq,: Audio frequency used to play the audio stream.
Note:
This API is called by BSP_AUDIO_OUT_Init() and BSP_AUDIO_OUT_SetFrequency() Being __weak it can be overwritten by the application
Parameters:
Params : pointer on additional configuration parameters, can be NULL.

Definition at line 470 of file stm32f4_discovery_audio.c.

References I2SFreq, I2SPLLN, and I2SPLLR.

Referenced by BSP_AUDIO_OUT_Init(), and BSP_AUDIO_OUT_SetFrequency().

__weak void BSP_AUDIO_OUT_Error_CallBack ( void )

Manages the DMA FIFO error event.

Definition at line 634 of file stm32f4_discovery_audio.c.

Referenced by HAL_I2S_ErrorCallback().

__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack ( void )

Manages the DMA Half Transfer complete event.

Definition at line 627 of file stm32f4_discovery_audio.c.

Referenced by HAL_I2S_TxHalfCpltCallback().

uint8_t BSP_AUDIO_OUT_Init | ( | uint16_t | OutputDevice,
 |  | uint8_t | Volume,
 |  | uint32_t | AudioFreq
 | ) |  |

Configures the audio peripherals.

Parameters:
OutputDevice,: OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO .
Volume,: Initial volume level (from 0 (Mute) to 100 (Max))
AudioFreq,: Audio frequency used to play the audio stream.
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 197 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_I2C_ADDRESS, AUDIO_OK, BSP_AUDIO_OUT_ClockConfig(), BSP_AUDIO_OUT_MspInit(), hAudioOutI2s, I2S3, I2S3_Init(), and pAudioDrv.

__weak void BSP_AUDIO_OUT_MspDeInit | ( | I2S_HandleTypeDef * | hi2s,
 |  | void * | Params
 | ) |  |

De-Initializes BSP_AUDIO_OUT MSP.

Parameters:
hi2s,: might be required to set audio peripheral predivider if any.
Params : pointer on additional configuration parameters, can be NULL.

Definition at line 582 of file stm32f4_discovery_audio.c.

References I2S3, I2S3_CLK_DISABLE, I2S3_DMAx_IRQ, I2S3_MCK_GPIO_PORT, I2S3_MCK_PIN, I2S3_SCK_PIN, I2S3_SCK_SD_GPIO_PORT, I2S3_SD_PIN, I2S3_WS_GPIO_PORT, and I2S3_WS_PIN.

__weak void BSP_AUDIO_OUT_MspInit | ( | I2S_HandleTypeDef * | hi2s,
 |  | void * | Params
 | ) |  |

AUDIO OUT I2S MSP Init.

Parameters:
hi2s,: might be required to set audio peripheral predivider if any.
Params : pointer on additional configuration parameters, can be NULL.

Definition at line 512 of file stm32f4_discovery_audio.c.

References AUDIO_OUT_IRQ_PREPRIO, I2S3, I2S3_CLK_ENABLE, I2S3_DMAx_CHANNEL, I2S3_DMAx_CLK_ENABLE, I2S3_DMAx_IRQ, I2S3_DMAx_MEM_DATA_SIZE, I2S3_DMAx_PERIPH_DATA_SIZE, I2S3_DMAx_STREAM, I2S3_MCK_CLK_ENABLE, I2S3_MCK_GPIO_PORT, I2S3_MCK_PIN, I2S3_SCK_PIN, I2S3_SCK_SD_CLK_ENABLE, I2S3_SCK_SD_GPIO_PORT, I2S3_SCK_SD_WS_AF, I2S3_SD_PIN, I2S3_WS_CLK_ENABLE, I2S3_WS_GPIO_PORT, and I2S3_WS_PIN.

Referenced by BSP_AUDIO_OUT_Init().

uint8_t BSP_AUDIO_OUT_Pause ( void )

Pauses the audio file stream.

In case of using DMA, the DMA Pause feature is used. WARNING: When calling BSP_AUDIO_OUT_Pause() function for pause, only the BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() function for resume could lead to unexpected behavior).

Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 284 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_I2C_ADDRESS, AUDIO_OK, hAudioOutI2s, and pAudioDrv.

uint8_t BSP_AUDIO_OUT_Play | ( | uint16_t * | pBuffer,
 |  | uint32_t | Size
 | ) |  |

Starts playing audio stream from a data buffer for a determined size.

Parameters:
pBuffer,: Pointer to the buffer
Size,: Number of audio data BYTES.
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 249 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_I2C_ADDRESS, AUDIO_OK, AUDIODATA_SIZE, DMA_MAX, hAudioOutI2s, and pAudioDrv.

uint8_t BSP_AUDIO_OUT_Resume ( void )

Resumes the audio file streaming.

WARNING: When calling BSP_AUDIO_OUT_Pause() function for pause, only BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() function for resume could lead to unexpected behavior).

Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 308 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_I2C_ADDRESS, AUDIO_OK, hAudioOutI2s, and pAudioDrv.

void BSP_AUDIO_OUT_SetFrequency ( uint32_t AudioFreq )

Update the audio frequency.

Parameters:
AudioFreq,: Audio frequency used to play the audio stream.
Note:
This API should be called after the BSP_AUDIO_OUT_Init() to adjust the audio frequency.

Definition at line 426 of file stm32f4_discovery_audio.c.

References BSP_AUDIO_OUT_ClockConfig(), hAudioOutI2s, and I2S3_Init().

uint8_t BSP_AUDIO_OUT_SetMute ( uint32_t Cmd )

Enables or disables the MUTE mode by software.

Parameters:
Cmd,: could be AUDIO_MUTE_ON to mute sound or AUDIO_MUTE_OFF to unmute the codec and restore previous volume level.
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 384 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_I2C_ADDRESS, AUDIO_OK, and pAudioDrv.

uint8_t BSP_AUDIO_OUT_SetOutputMode ( uint8_t Output )

Switch dynamically (while audio file is played) the output target (speaker or headphone).

Note:
This function modifies a global variable of the audio codec driver: OutputDev.
Parameters:
Output,: specifies the audio output target: OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 406 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_I2C_ADDRESS, AUDIO_OK, and pAudioDrv.

uint8_t BSP_AUDIO_OUT_SetVolume ( uint8_t Volume )

Controls the current audio volume level.

Parameters:
Volume,: Volume level to be set in percentage from 0% to 100% (0 for Mute and 100 for Max volume level).
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 364 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_I2C_ADDRESS, AUDIO_OK, and pAudioDrv.

uint8_t BSP_AUDIO_OUT_Stop ( uint32_t Option )

Stops audio playing and Power down the Audio Codec.

Parameters:
Option,: could be one of the following parameters
  • CODEC_PDWN_HW: completely shut down the codec (physically). Then need to reconfigure the Codec after power on.
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 332 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_I2C_ADDRESS, AUDIO_OK, AUDIO_RESET_GPIO, AUDIO_RESET_PIN, hAudioOutI2s, and pAudioDrv.

__weak void BSP_AUDIO_OUT_TransferComplete_CallBack ( void )

Manages the DMA full Transfer complete event.

Definition at line 620 of file stm32f4_discovery_audio.c.

Referenced by HAL_I2S_TxCpltCallback().

void HAL_I2S_TxCpltCallback ( I2S_HandleTypeDef * hi2s )

Tx Transfer completed callbacks.

Parameters:
hi2s,: I2S handle

Definition at line 439 of file stm32f4_discovery_audio.c.

References BSP_AUDIO_OUT_TransferComplete_CallBack(), and I2S3.

void HAL_I2S_TxHalfCpltCallback ( I2S_HandleTypeDef * hi2s )

Tx Half Transfer completed callbacks.

Parameters:
hi2s,: I2S handle

Definition at line 452 of file stm32f4_discovery_audio.c.

References BSP_AUDIO_OUT_HalfTransfer_CallBack(), and I2S3.

static uint8_t I2S3_Init ( uint32_t AudioFreq ) [static]

Initializes the Audio Codec audio interface (I2S).

Parameters:
AudioFreq,: Audio frequency to be configured for the I2S peripheral.

Definition at line 646 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_OK, hAudioOutI2s, and I2S3.

Referenced by BSP_AUDIO_OUT_Init(), and BSP_AUDIO_OUT_SetFrequency().


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY AUDIO IN Private Functions

Functions
STM32F4 DISCOVERY AUDIO IN Private Functions
STM32F4 DISCOVERY AUDIO

Functions

uint8_t | BSP_AUDIO_IN_Init (uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr)
Initializes wave recording.
uint8_t | BSP_AUDIO_IN_Record (uint16_t *pbuf, uint32_t size)
Starts audio recording.
uint8_t | BSP_AUDIO_IN_Stop (void)
Stops audio recording.
uint8_t | BSP_AUDIO_IN_Pause (void)
Pauses the audio file stream.
uint8_t | BSP_AUDIO_IN_Resume (void)
Resumes the audio file stream.
uint8_t | BSP_AUDIO_IN_SetVolume (uint8_t Volume)
Controls the audio in volume level.
uint8_t | BSP_AUDIO_IN_PDMToPCM (uint16_t *PDMBuf, uint16_t *PCMBuf)
Converts audio format from PDM to PCM.
void | HAL_I2S_RxCpltCallback (I2S_HandleTypeDef *hi2s)
Rx Transfer completed callbacks.
void | HAL_I2S_RxHalfCpltCallback (I2S_HandleTypeDef *hi2s)
Rx Half Transfer completed callbacks.
__weak void | BSP_AUDIO_IN_ClockConfig (I2S_HandleTypeDef *hi2s, uint32_t AudioFreq, void *Params)
Audio In Clock Config.
__weak void | BSP_AUDIO_IN_MspInit (I2S_HandleTypeDef *hi2s, void *Params)
BSP AUDIO IN MSP Init.
__weak void | BSP_AUDIO_IN_MspDeInit (I2S_HandleTypeDef *hi2s, void *Params)
DeInitializes BSP_AUDIO_IN MSP.
__weak void | BSP_AUDIO_IN_TransferComplete_CallBack (void)
User callback when record buffer is filled.
__weak void | BSP_AUDIO_IN_HalfTransfer_CallBack (void)
Manages the DMA Half Transfer complete event.
__weak void | BSP_AUDIO_IN_Error_Callback (void)
Audio IN Error callback function.
static void | PDMDecoder_Init (uint32_t AudioFreq, uint32_t ChnlNbrIn, uint32_t ChnlNbrOut)
Initializes the PDM library.
static uint8_t | I2S2_Init (uint32_t AudioFreq)
Initializes the Audio Codec audio interface (I2S)

Function Documentation

__weak void BSP_AUDIO_IN_ClockConfig | ( | I2S_HandleTypeDef * | hi2s,
 |  | uint32_t | AudioFreq,
 |  | void * | Params
 | ) |  |

Audio In Clock Config.

Parameters:
hi2s,: I2S handle
AudioFreq,: Audio frequency used to record the audio stream.
Params : pointer on additional configuration parameters, can be NULL.
Note:
This API is called by BSP_AUDIO_IN_Init() Being __weak it can be overwritten by the application

Definition at line 852 of file stm32f4_discovery_audio.c.

Referenced by BSP_AUDIO_IN_Init().

__weak void BSP_AUDIO_IN_Error_Callback ( void )

Audio IN Error callback function.

Definition at line 1004 of file stm32f4_discovery_audio.c.

Referenced by HAL_I2S_ErrorCallback().

__weak void BSP_AUDIO_IN_HalfTransfer_CallBack ( void )

Manages the DMA Half Transfer complete event.

Definition at line 994 of file stm32f4_discovery_audio.c.

Referenced by HAL_I2S_RxHalfCpltCallback().

uint8_t BSP_AUDIO_IN_Init | ( | uint32_t | AudioFreq,
 |  | uint32_t | BitRes,
 |  | uint32_t | ChnlNbr
 | ) |  |

Initializes wave recording.

Parameters:
AudioFreq,: Audio frequency to be configured for the I2S peripheral.
BitRes,: Audio frequency to be configured for the I2S peripheral.
ChnlNbr,: Audio frequency to be configured for the I2S peripheral.
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 688 of file stm32f4_discovery_audio.c.

References AUDIO_OK, BSP_AUDIO_IN_ClockConfig(), BSP_AUDIO_IN_MspInit(), hAudioInI2s, I2S2, I2S2_Init(), and PDMDecoder_Init().

__weak void BSP_AUDIO_IN_MspDeInit | ( | I2S_HandleTypeDef * | hi2s,
 |  | void * | Params
 | ) |  |

DeInitializes BSP_AUDIO_IN MSP.

Parameters:
hi2s,: I2S handle
Params : pointer on additional configuration parameters, can be NULL.

Definition at line 952 of file stm32f4_discovery_audio.c.

References I2S2, I2S2_CLK_DISABLE, I2S2_DMAx_IRQ, I2S2_MOSI_GPIO_PORT, I2S2_MOSI_PIN, I2S2_SCK_GPIO_PORT, and I2S2_SCK_PIN.

__weak void BSP_AUDIO_IN_MspInit | ( | I2S_HandleTypeDef * | hi2s,
 |  | void * | Params
 | ) |  |

BSP AUDIO IN MSP Init.

Parameters:
hi2s,: I2S handle
Params : pointer on additional configuration parameters, can be NULL.

Definition at line 886 of file stm32f4_discovery_audio.c.

References AUDIO_IN_IRQ_PREPRIO, I2S2, I2S2_CLK_ENABLE, I2S2_DMAx_CHANNEL, I2S2_DMAx_CLK_ENABLE, I2S2_DMAx_IRQ, I2S2_DMAx_MEM_DATA_SIZE, I2S2_DMAx_PERIPH_DATA_SIZE, I2S2_DMAx_STREAM, I2S2_MOSI_AF, I2S2_MOSI_GPIO_CLK_ENABLE, I2S2_MOSI_GPIO_PORT, I2S2_MOSI_PIN, I2S2_SCK_AF, I2S2_SCK_GPIO_CLK_ENABLE, I2S2_SCK_GPIO_PORT, and I2S2_SCK_PIN.

Referenced by BSP_AUDIO_IN_Init().

uint8_t BSP_AUDIO_IN_Pause ( void )

Pauses the audio file stream.

Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 754 of file stm32f4_discovery_audio.c.

References AUDIO_OK, and hAudioInI2s.

uint8_t BSP_AUDIO_IN_PDMToPCM | ( | uint16_t * | PDMBuf,
 |  | uint16_t * | PCMBuf
 | ) |  |

Converts audio format from PDM to PCM.

Parameters:
PDMBuf,: Pointer to data PDM buffer
PCMBuf,: Pointer to data PCM buffer
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 797 of file stm32f4_discovery_audio.c.

References AUDIO_OK, DEFAULT_AUDIO_IN_CHANNEL_NBR, HTONS, INTERNAL_BUFF_SIZE, PCM_OUT_SIZE, and PDM_FilterHandler.

uint8_t BSP_AUDIO_IN_Record | ( | uint16_t * | pbuf,
 |  | uint32_t | size
 | ) |  |

Starts audio recording.

Parameters:
pbuf,: Main buffer pointer for the recorded data storing
size,: Current size of the recorded buffer
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 720 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_OK, and hAudioInI2s.

uint8_t BSP_AUDIO_IN_Resume ( void )

Resumes the audio file stream.

Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 767 of file stm32f4_discovery_audio.c.

References AUDIO_OK, and hAudioInI2s.

uint8_t BSP_AUDIO_IN_SetVolume ( uint8_t Volume )

Controls the audio in volume level.

Parameters:
Volume,: Volume level to be set in percentage from 0% to 100% (0 for Mute and 100 for Max volume level).
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 782 of file stm32f4_discovery_audio.c.

References AUDIO_OK, and AudioInVolume.

uint8_t BSP_AUDIO_IN_Stop ( void )

Stops audio recording.

Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 737 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_OK, and hAudioInI2s.

__weak void BSP_AUDIO_IN_TransferComplete_CallBack ( void )

User callback when record buffer is filled.

Definition at line 984 of file stm32f4_discovery_audio.c.

Referenced by HAL_I2S_RxCpltCallback().

void HAL_I2S_RxCpltCallback ( I2S_HandleTypeDef * hi2s )

Rx Transfer completed callbacks.

Parameters:
hi2s,: I2S handle

Definition at line 827 of file stm32f4_discovery_audio.c.

References BSP_AUDIO_IN_TransferComplete_CallBack().

void HAL_I2S_RxHalfCpltCallback ( I2S_HandleTypeDef * hi2s )

Rx Half Transfer completed callbacks.

Parameters:
hi2s,: I2S handle

Definition at line 837 of file stm32f4_discovery_audio.c.

References BSP_AUDIO_IN_HalfTransfer_CallBack().

static uint8_t I2S2_Init ( uint32_t AudioFreq ) [static]

Initializes the Audio Codec audio interface (I2S)

Note:
This function assumes that the I2S input clock (through PLL_R in Devices RevA/Z and through dedicated PLLI2S_R in Devices RevB/Y) is already configured and ready to be used.
Parameters:
AudioFreq,: Audio frequency to be configured for the I2S peripheral.

Definition at line 1053 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_OK, hAudioInI2s, and I2S2.

Referenced by BSP_AUDIO_IN_Init().

static void PDMDecoder_Init | ( | uint32_t | AudioFreq,
 |  | uint32_t | ChnlNbrIn,
 |  | uint32_t | ChnlNbrOut
 | ) |  | [static]

Initializes the PDM library.

Parameters:
AudioFreq,: Audio sampling frequency
ChnlNbrIn,: Number of input audio channels in the PDM buffer
ChnlNbrOut,: Number of desired output audio channels in the resulting PCM buffer Number of audio channels (1: mono; 2: stereo)

Definition at line 1021 of file stm32f4_discovery_audio.c.

References PDM_FilterConfig, and PDM_FilterHandler.

Referenced by BSP_AUDIO_IN_Init().


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY AUDIO IN OUT Private Functions

Functions
STM32F4 DISCOVERY AUDIO IN OUT Private Functions
STM32F4 DISCOVERY AUDIO

Functions

void HAL_I2S_ErrorCallback (I2S_HandleTypeDef *hi2s)
I2S error callbacks.

Function Documentation

void HAL_I2S_ErrorCallback ( I2S_HandleTypeDef * hi2s )

I2S error callbacks.

Parameters:
hi2s,: I2S handle

Definition at line 1093 of file stm32f4_discovery_audio.c.

References BSP_AUDIO_IN_Error_Callback(), BSP_AUDIO_OUT_Error_CallBack(), I2S2, and I2S3.


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY AUDIO Exported Types

STM32F4 DISCOVERY AUDIO Exported Types
STM32F4 DISCOVERY AUDIO


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY AUDIO OUT Exported Constants

Defines
STM32F4 DISCOVERY AUDIO OUT Exported Constants
STM32F4 DISCOVERY AUDIO

Defines

#define | I2S3 SPI3
#define | I2S3_CLK_ENABLE() __HAL_RCC_SPI3_CLK_ENABLE()
#define | I2S3_CLK_DISABLE() __HAL_RCC_SPI3_CLK_DISABLE()
#define | I2S3_SCK_SD_WS_AF GPIO_AF6_SPI3
#define | I2S3_SCK_SD_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define | I2S3_MCK_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define | I2S3_WS_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define | I2S3_WS_PIN GPIO_PIN_4
#define | I2S3_SCK_PIN GPIO_PIN_10
#define | I2S3_SD_PIN GPIO_PIN_12
#define | I2S3_MCK_PIN GPIO_PIN_7
#define | I2S3_SCK_SD_GPIO_PORT GPIOC
#define | I2S3_WS_GPIO_PORT GPIOA
#define | I2S3_MCK_GPIO_PORT GPIOC
#define | I2S3_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE()
#define | I2S3_DMAx_CLK_DISABLE() __HAL_RCC_DMA1_CLK_DISABLE()
#define | I2S3_DMAx_STREAM DMA1_Stream7
#define | I2S3_DMAx_CHANNEL DMA_CHANNEL_0
#define | I2S3_DMAx_IRQ DMA1_Stream7_IRQn
#define | I2S3_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
#define | I2S3_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
#define | DMA_MAX_SZE 0xFFFF
#define | I2S3_IRQHandler DMA1_Stream7_IRQHandler
#define | AUDIO_OUT_IRQ_PREPRIO 0x0E /* Select the preemption priority level(0 is the highest) */
#define | I2S2 SPI2
#define | I2S2_CLK_ENABLE() __HAL_RCC_SPI2_CLK_ENABLE()
#define | I2S2_CLK_DISABLE() __HAL_RCC_SPI2_CLK_DISABLE()
#define | I2S2_SCK_PIN GPIO_PIN_10
#define | I2S2_SCK_GPIO_PORT GPIOB
#define | I2S2_SCK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define | I2S2_SCK_AF GPIO_AF5_SPI2
#define | I2S2_MOSI_PIN GPIO_PIN_3
#define | I2S2_MOSI_GPIO_PORT GPIOC
#define | I2S2_MOSI_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define | I2S2_MOSI_AF GPIO_AF5_SPI2
#define | I2S2_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE()
#define | I2S2_DMAx_CLK_DISABLE() __HAL_RCC_DMA1_CLK_DISABLE()
#define | I2S2_DMAx_STREAM DMA1_Stream3
#define | I2S2_DMAx_CHANNEL DMA_CHANNEL_0
#define | I2S2_DMAx_IRQ DMA1_Stream3_IRQn
#define | I2S2_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
#define | I2S2_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
#define | I2S2_IRQHandler DMA1_Stream3_IRQHandler
#define | AUDIO_IN_IRQ_PREPRIO 0x0F /* Select the preemption priority level(0 is the highest) */
#define | AUDIODATA_SIZE 2 /* 16-bits audio data size */
#define | AUDIO_OK 0
#define | AUDIO_ERROR 1
#define | AUDIO_TIMEOUT 2
#define | DEFAULT_AUDIO_IN_FREQ I2S_AUDIOFREQ_16K
#define | DEFAULT_AUDIO_IN_BIT_RESOLUTION 16
#define | DEFAULT_AUDIO_IN_CHANNEL_NBR 1 /* Mono = 1, Stereo = 2 */
#define | DEFAULT_AUDIO_IN_VOLUME 64
#define | INTERNAL_BUFF_SIZE 128*DEFAULT_AUDIO_IN_FREQ/16000*DEFAULT_AUDIO_IN_CHANNEL_NBR
#define | PCM_OUT_SIZE DEFAULT_AUDIO_IN_FREQ/1000
#define | CHANNEL_DEMUX_MASK 0x55

Define Documentation

#define AUDIO_ERROR 1

Definition at line 133 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_Record(), BSP_AUDIO_IN_Stop(), BSP_AUDIO_OUT_Init(), BSP_AUDIO_OUT_Pause(), BSP_AUDIO_OUT_Play(), BSP_AUDIO_OUT_Resume(), BSP_AUDIO_OUT_SetMute(), BSP_AUDIO_OUT_SetOutputMode(), BSP_AUDIO_OUT_SetVolume(), BSP_AUDIO_OUT_Stop(), I2S2_Init(), and I2S3_Init().

#define AUDIO_IN_IRQ_PREPRIO 0x0F /* Select the preemption priority level(0 is the highest) */

Definition at line 123 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_MspInit().

#define AUDIO_OK 0

Definition at line 132 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_Init(), BSP_AUDIO_IN_Pause(), BSP_AUDIO_IN_PDMToPCM(), BSP_AUDIO_IN_Record(), BSP_AUDIO_IN_Resume(), BSP_AUDIO_IN_SetVolume(), BSP_AUDIO_IN_Stop(), BSP_AUDIO_OUT_Init(), BSP_AUDIO_OUT_Pause(), BSP_AUDIO_OUT_Play(), BSP_AUDIO_OUT_Resume(), BSP_AUDIO_OUT_SetMute(), BSP_AUDIO_OUT_SetOutputMode(), BSP_AUDIO_OUT_SetVolume(), BSP_AUDIO_OUT_Stop(), I2S2_Init(), and I2S3_Init().

#define AUDIO_OUT_IRQ_PREPRIO 0x0E /* Select the preemption priority level(0 is the highest) */

Definition at line 92 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspInit().

#define AUDIO_TIMEOUT 2

Definition at line 134 of file stm32f4_discovery_audio.h.

#define AUDIODATA_SIZE 2 /* 16-bits audio data size */

Definition at line 129 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_Play().

#define CHANNEL_DEMUX_MASK 0x55

Definition at line 146 of file stm32f4_discovery_audio.h.

#define DEFAULT_AUDIO_IN_BIT_RESOLUTION 16

Definition at line 138 of file stm32f4_discovery_audio.h.

#define DEFAULT_AUDIO_IN_CHANNEL_NBR 1 /* Mono = 1, Stereo = 2 */

Definition at line 139 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_PDMToPCM().

#define DEFAULT_AUDIO_IN_FREQ I2S_AUDIOFREQ_16K

Definition at line 137 of file stm32f4_discovery_audio.h.

#define DEFAULT_AUDIO_IN_VOLUME 64

Definition at line 140 of file stm32f4_discovery_audio.h.

#define DMA_MAX_SZE 0xFFFF

Definition at line 87 of file stm32f4_discovery_audio.h.

#define I2S2 SPI2

Definition at line 98 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_Init(), BSP_AUDIO_IN_MspDeInit(), BSP_AUDIO_IN_MspInit(), HAL_I2S_ErrorCallback(), and I2S2_Init().

#define I2S2_CLK_DISABLE ( ) __HAL_RCC_SPI2_CLK_DISABLE()

Definition at line 100 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_MspDeInit().

#define I2S2_CLK_ENABLE ( ) __HAL_RCC_SPI2_CLK_ENABLE()

Definition at line 99 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_MspInit().

#define I2S2_DMAx_CHANNEL DMA_CHANNEL_0

Definition at line 115 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_MspInit().

#define I2S2_DMAx_CLK_DISABLE ( ) __HAL_RCC_DMA1_CLK_DISABLE()

Definition at line 113 of file stm32f4_discovery_audio.h.

#define I2S2_DMAx_CLK_ENABLE ( ) __HAL_RCC_DMA1_CLK_ENABLE()

Definition at line 112 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_MspInit().

#define I2S2_DMAx_IRQ DMA1_Stream3_IRQn

Definition at line 116 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_MspDeInit(), and BSP_AUDIO_IN_MspInit().

#define I2S2_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD

Definition at line 118 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_MspInit().

#define I2S2_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD

Definition at line 117 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_MspInit().

#define I2S2_DMAx_STREAM DMA1_Stream3

Definition at line 114 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_MspInit().

#define I2S2_IRQHandler DMA1_Stream3_IRQHandler

Definition at line 120 of file stm32f4_discovery_audio.h.

#define I2S2_MOSI_AF GPIO_AF5_SPI2

Definition at line 109 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_MspInit().

#define I2S2_MOSI_GPIO_CLK_ENABLE ( ) __HAL_RCC_GPIOC_CLK_ENABLE()

Definition at line 108 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_MspInit().

#define I2S2_MOSI_GPIO_PORT GPIOC

Definition at line 107 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_MspDeInit(), and BSP_AUDIO_IN_MspInit().

#define I2S2_MOSI_PIN GPIO_PIN_3

Definition at line 106 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_MspDeInit(), and BSP_AUDIO_IN_MspInit().

#define I2S2_SCK_AF GPIO_AF5_SPI2

Definition at line 104 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_MspInit().

#define I2S2_SCK_GPIO_CLK_ENABLE ( ) __HAL_RCC_GPIOB_CLK_ENABLE()

Definition at line 103 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_MspInit().

#define I2S2_SCK_GPIO_PORT GPIOB

Definition at line 102 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_MspDeInit(), and BSP_AUDIO_IN_MspInit().

#define I2S2_SCK_PIN GPIO_PIN_10

Definition at line 101 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_MspDeInit(), and BSP_AUDIO_IN_MspInit().

#define I2S3 SPI3

Definition at line 64 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_Init(), BSP_AUDIO_OUT_MspDeInit(), BSP_AUDIO_OUT_MspInit(), HAL_I2S_ErrorCallback(), HAL_I2S_TxCpltCallback(), HAL_I2S_TxHalfCpltCallback(), and I2S3_Init().

#define I2S3_CLK_DISABLE ( ) __HAL_RCC_SPI3_CLK_DISABLE()

Definition at line 66 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspDeInit().

#define I2S3_CLK_ENABLE ( ) __HAL_RCC_SPI3_CLK_ENABLE()

Definition at line 65 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspInit().

#define I2S3_DMAx_CHANNEL DMA_CHANNEL_0

Definition at line 83 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspInit().

#define I2S3_DMAx_CLK_DISABLE ( ) __HAL_RCC_DMA1_CLK_DISABLE()

Definition at line 81 of file stm32f4_discovery_audio.h.

#define I2S3_DMAx_CLK_ENABLE ( ) __HAL_RCC_DMA1_CLK_ENABLE()

Definition at line 80 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspInit().

#define I2S3_DMAx_IRQ DMA1_Stream7_IRQn

Definition at line 84 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspDeInit(), and BSP_AUDIO_OUT_MspInit().

#define I2S3_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD

Definition at line 86 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspInit().

#define I2S3_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD

Definition at line 85 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspInit().

#define I2S3_DMAx_STREAM DMA1_Stream7

Definition at line 82 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspInit().

#define I2S3_IRQHandler DMA1_Stream7_IRQHandler

Definition at line 89 of file stm32f4_discovery_audio.h.

#define I2S3_MCK_CLK_ENABLE ( ) __HAL_RCC_GPIOC_CLK_ENABLE()

Definition at line 69 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspInit().

#define I2S3_MCK_GPIO_PORT GPIOC

Definition at line 77 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspDeInit(), and BSP_AUDIO_OUT_MspInit().

#define I2S3_MCK_PIN GPIO_PIN_7

Definition at line 74 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspDeInit(), and BSP_AUDIO_OUT_MspInit().

#define I2S3_SCK_PIN GPIO_PIN_10

Definition at line 72 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspDeInit(), and BSP_AUDIO_OUT_MspInit().

#define I2S3_SCK_SD_CLK_ENABLE ( ) __HAL_RCC_GPIOC_CLK_ENABLE()

Definition at line 68 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspInit().

#define I2S3_SCK_SD_GPIO_PORT GPIOC

Definition at line 75 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspDeInit(), and BSP_AUDIO_OUT_MspInit().

#define I2S3_SCK_SD_WS_AF GPIO_AF6_SPI3

Definition at line 67 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspInit().

#define I2S3_SD_PIN GPIO_PIN_12

Definition at line 73 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspDeInit(), and BSP_AUDIO_OUT_MspInit().

#define I2S3_WS_CLK_ENABLE ( ) __HAL_RCC_GPIOA_CLK_ENABLE()

Definition at line 70 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspInit().

#define I2S3_WS_GPIO_PORT GPIOA

Definition at line 76 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspDeInit(), and BSP_AUDIO_OUT_MspInit().

#define I2S3_WS_PIN GPIO_PIN_4

Definition at line 71 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_MspDeInit(), and BSP_AUDIO_OUT_MspInit().

#define INTERNAL_BUFF_SIZE 128*DEFAULT_AUDIO_IN_FREQ/16000*DEFAULT_AUDIO_IN_CHANNEL_NBR

Definition at line 143 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_PDMToPCM().

#define PCM_OUT_SIZE DEFAULT_AUDIO_IN_FREQ/1000

Definition at line 145 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_PDMToPCM().


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY AUDIO Exported Variables

Variables
STM32F4 DISCOVERY AUDIO Exported Variables
STM32F4 DISCOVERY AUDIO

Variables

__IO uint16_t AudioInVolume

Variable Documentation

__IO uint16_t AudioInVolume

Definition at line 170 of file stm32f4_discovery_audio.c.

Referenced by BSP_AUDIO_IN_SetVolume().


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY AUDIO Exported Macros

Defines
STM32F4 DISCOVERY AUDIO Exported Macros
STM32F4 DISCOVERY AUDIO

Defines

#define | DMA_MAX(_X_) (((_X_) <= DMA_MAX_SZE)? (_X_):DMA_MAX_SZE)
#define | HTONS(A) ((((uint16_t)(A) & 0xff00) >> 8) | (((uint16_t)(A) & 0x00ff) << 8))

Define Documentation

#define DMA_MAX ( _X_ ) (((_X_) <= DMA_MAX_SZE)? (_X_):DMA_MAX_SZE)

Definition at line 167 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_OUT_Play().

#define HTONS ( A ) ((((uint16_t)(A) & 0xff00) >> 8) | (((uint16_t)(A) & 0x00ff) << 8))

Definition at line 168 of file stm32f4_discovery_audio.h.

Referenced by BSP_AUDIO_IN_PDMToPCM().


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY AUDIO OUT Exported Functions

Functions
STM32F4 DISCOVERY AUDIO OUT Exported Functions
STM32F4 DISCOVERY AUDIO

Functions

uint8_t | BSP_AUDIO_OUT_Init (uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)
Configures the audio peripherals.
uint8_t | BSP_AUDIO_OUT_Play (uint16_t *pBuffer, uint32_t Size)
Starts playing audio stream from a data buffer for a determined size.
void | BSP_AUDIO_OUT_ChangeBuffer (uint16_t *pData, uint16_t Size)
Sends n-Bytes on the I2S interface.
uint8_t | BSP_AUDIO_OUT_Pause (void)
Pauses the audio file stream.
uint8_t | BSP_AUDIO_OUT_Resume (void)
Resumes the audio file streaming.
uint8_t | BSP_AUDIO_OUT_Stop (uint32_t Option)
Stops audio playing and Power down the Audio Codec.
uint8_t | BSP_AUDIO_OUT_SetVolume (uint8_t Volume)
Controls the current audio volume level.
void | BSP_AUDIO_OUT_SetFrequency (uint32_t AudioFreq)
Update the audio frequency.
uint8_t | BSP_AUDIO_OUT_SetMute (uint32_t Cmd)
Enables or disables the MUTE mode by software.
uint8_t | BSP_AUDIO_OUT_SetOutputMode (uint8_t Output)
Switch dynamically (while audio file is played) the output target (speaker or headphone).
void | BSP_AUDIO_OUT_TransferComplete_CallBack (void)
Manages the DMA full Transfer complete event.
void | BSP_AUDIO_OUT_HalfTransfer_CallBack (void)
Manages the DMA Half Transfer complete event.
void | BSP_AUDIO_OUT_Error_CallBack (void)
Manages the DMA FIFO error event.
void | BSP_AUDIO_OUT_ClockConfig (I2S_HandleTypeDef *hi2s, uint32_t AudioFreq, void *Params)
Clock Config.
void | BSP_AUDIO_OUT_MspInit (I2S_HandleTypeDef *hi2s, void *Params)
AUDIO OUT I2S MSP Init.
void | BSP_AUDIO_OUT_MspDeInit (I2S_HandleTypeDef *hi2s, void *Params)
De-Initializes BSP_AUDIO_OUT MSP.

Function Documentation

void BSP_AUDIO_OUT_ChangeBuffer | ( | uint16_t * | pData,
 |  | uint16_t | Size
 | ) |  |

Sends n-Bytes on the I2S interface.

Parameters:
pData,: Pointer to data address
Size,: Number of data to be written

Definition at line 271 of file stm32f4_discovery_audio.c.

References hAudioOutI2s.

void BSP_AUDIO_OUT_ClockConfig | ( | I2S_HandleTypeDef * | hi2s,
 |  | uint32_t | AudioFreq,
 |  | void * | Params
 | ) |  |

Clock Config.

Parameters:
hi2s,: might be required to set audio peripheral predivider if any.
AudioFreq,: Audio frequency used to play the audio stream.
Note:
This API is called by BSP_AUDIO_OUT_Init() and BSP_AUDIO_OUT_SetFrequency() Being __weak it can be overwritten by the application
Parameters:
Params : pointer on additional configuration parameters, can be NULL.

Definition at line 470 of file stm32f4_discovery_audio.c.

References I2SFreq, I2SPLLN, and I2SPLLR.

Referenced by BSP_AUDIO_OUT_Init(), and BSP_AUDIO_OUT_SetFrequency().

void BSP_AUDIO_OUT_Error_CallBack ( void )

Manages the DMA FIFO error event.

Definition at line 634 of file stm32f4_discovery_audio.c.

Referenced by HAL_I2S_ErrorCallback().

void BSP_AUDIO_OUT_HalfTransfer_CallBack ( void )

Manages the DMA Half Transfer complete event.

Definition at line 627 of file stm32f4_discovery_audio.c.

Referenced by HAL_I2S_TxHalfCpltCallback().

uint8_t BSP_AUDIO_OUT_Init | ( | uint16_t | OutputDevice,
 |  | uint8_t | Volume,
 |  | uint32_t | AudioFreq
 | ) |  |

Configures the audio peripherals.

Parameters:
OutputDevice,: OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO .
Volume,: Initial volume level (from 0 (Mute) to 100 (Max))
AudioFreq,: Audio frequency used to play the audio stream.
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 197 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_I2C_ADDRESS, AUDIO_OK, BSP_AUDIO_OUT_ClockConfig(), BSP_AUDIO_OUT_MspInit(), hAudioOutI2s, I2S3, I2S3_Init(), and pAudioDrv.

void BSP_AUDIO_OUT_MspDeInit | ( | I2S_HandleTypeDef * | hi2s,
 |  | void * | Params
 | ) |  |

De-Initializes BSP_AUDIO_OUT MSP.

Parameters:
hi2s,: might be required to set audio peripheral predivider if any.
Params : pointer on additional configuration parameters, can be NULL.

Definition at line 582 of file stm32f4_discovery_audio.c.

References I2S3, I2S3_CLK_DISABLE, I2S3_DMAx_IRQ, I2S3_MCK_GPIO_PORT, I2S3_MCK_PIN, I2S3_SCK_PIN, I2S3_SCK_SD_GPIO_PORT, I2S3_SD_PIN, I2S3_WS_GPIO_PORT, and I2S3_WS_PIN.

void BSP_AUDIO_OUT_MspInit | ( | I2S_HandleTypeDef * | hi2s,
 |  | void * | Params
 | ) |  |

AUDIO OUT I2S MSP Init.

Parameters:
hi2s,: might be required to set audio peripheral predivider if any.
Params : pointer on additional configuration parameters, can be NULL.

Definition at line 512 of file stm32f4_discovery_audio.c.

References AUDIO_OUT_IRQ_PREPRIO, I2S3, I2S3_CLK_ENABLE, I2S3_DMAx_CHANNEL, I2S3_DMAx_CLK_ENABLE, I2S3_DMAx_IRQ, I2S3_DMAx_MEM_DATA_SIZE, I2S3_DMAx_PERIPH_DATA_SIZE, I2S3_DMAx_STREAM, I2S3_MCK_CLK_ENABLE, I2S3_MCK_GPIO_PORT, I2S3_MCK_PIN, I2S3_SCK_PIN, I2S3_SCK_SD_CLK_ENABLE, I2S3_SCK_SD_GPIO_PORT, I2S3_SCK_SD_WS_AF, I2S3_SD_PIN, I2S3_WS_CLK_ENABLE, I2S3_WS_GPIO_PORT, and I2S3_WS_PIN.

Referenced by BSP_AUDIO_OUT_Init().

uint8_t BSP_AUDIO_OUT_Pause ( void )

Pauses the audio file stream.

In case of using DMA, the DMA Pause feature is used. WARNING: When calling BSP_AUDIO_OUT_Pause() function for pause, only the BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() function for resume could lead to unexpected behavior).

Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 284 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_I2C_ADDRESS, AUDIO_OK, hAudioOutI2s, and pAudioDrv.

uint8_t BSP_AUDIO_OUT_Play | ( | uint16_t * | pBuffer,
 |  | uint32_t | Size
 | ) |  |

Starts playing audio stream from a data buffer for a determined size.

Parameters:
pBuffer,: Pointer to the buffer
Size,: Number of audio data BYTES.
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 249 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_I2C_ADDRESS, AUDIO_OK, AUDIODATA_SIZE, DMA_MAX, hAudioOutI2s, and pAudioDrv.

uint8_t BSP_AUDIO_OUT_Resume ( void )

Resumes the audio file streaming.

WARNING: When calling BSP_AUDIO_OUT_Pause() function for pause, only BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() function for resume could lead to unexpected behavior).

Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 308 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_I2C_ADDRESS, AUDIO_OK, hAudioOutI2s, and pAudioDrv.

void BSP_AUDIO_OUT_SetFrequency ( uint32_t AudioFreq )

Update the audio frequency.

Parameters:
AudioFreq,: Audio frequency used to play the audio stream.
Note:
This API should be called after the BSP_AUDIO_OUT_Init() to adjust the audio frequency.

Definition at line 426 of file stm32f4_discovery_audio.c.

References BSP_AUDIO_OUT_ClockConfig(), hAudioOutI2s, and I2S3_Init().

uint8_t BSP_AUDIO_OUT_SetMute ( uint32_t Cmd )

Enables or disables the MUTE mode by software.

Parameters:
Cmd,: could be AUDIO_MUTE_ON to mute sound or AUDIO_MUTE_OFF to unmute the codec and restore previous volume level.
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 384 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_I2C_ADDRESS, AUDIO_OK, and pAudioDrv.

uint8_t BSP_AUDIO_OUT_SetOutputMode ( uint8_t Output )

Switch dynamically (while audio file is played) the output target (speaker or headphone).

Note:
This function modifies a global variable of the audio codec driver: OutputDev.
Parameters:
Output,: specifies the audio output target: OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 406 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_I2C_ADDRESS, AUDIO_OK, and pAudioDrv.

uint8_t BSP_AUDIO_OUT_SetVolume ( uint8_t Volume )

Controls the current audio volume level.

Parameters:
Volume,: Volume level to be set in percentage from 0% to 100% (0 for Mute and 100 for Max volume level).
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 364 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_I2C_ADDRESS, AUDIO_OK, and pAudioDrv.

uint8_t BSP_AUDIO_OUT_Stop ( uint32_t Option )

Stops audio playing and Power down the Audio Codec.

Parameters:
Option,: could be one of the following parameters
  • CODEC_PDWN_HW: completely shut down the codec (physically). Then need to reconfigure the Codec after power on.
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 332 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_I2C_ADDRESS, AUDIO_OK, AUDIO_RESET_GPIO, AUDIO_RESET_PIN, hAudioOutI2s, and pAudioDrv.

void BSP_AUDIO_OUT_TransferComplete_CallBack ( void )

Manages the DMA full Transfer complete event.

Definition at line 620 of file stm32f4_discovery_audio.c.

Referenced by HAL_I2S_TxCpltCallback().


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY AUDIO IN Exported Functions

Functions
STM32F4 DISCOVERY AUDIO IN Exported Functions
STM32F4 DISCOVERY AUDIO

Functions

uint8_t | BSP_AUDIO_IN_Init (uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr)
Initializes wave recording.
uint8_t | BSP_AUDIO_IN_Record (uint16_t *pData, uint32_t Size)
Starts audio recording.
uint8_t | BSP_AUDIO_IN_Stop (void)
Stops audio recording.
uint8_t | BSP_AUDIO_IN_Pause (void)
Pauses the audio file stream.
uint8_t | BSP_AUDIO_IN_Resume (void)
Resumes the audio file stream.
uint8_t | BSP_AUDIO_IN_SetVolume (uint8_t Volume)
Controls the audio in volume level.
uint8_t | BSP_AUDIO_IN_PDMToPCM (uint16_t *PDMBuf, uint16_t *PCMBuf)
Converts audio format from PDM to PCM.
void | BSP_AUDIO_IN_TransferComplete_CallBack (void)
User callback when record buffer is filled.
void | BSP_AUDIO_IN_HalfTransfer_CallBack (void)
Manages the DMA Half Transfer complete event.
void | BSP_AUDIO_IN_Error_Callback (void)
Audio IN Error callback function.
void | BSP_AUDIO_IN_ClockConfig (I2S_HandleTypeDef *hi2s, uint32_t AudioFreq, void *Params)
Audio In Clock Config.
void | BSP_AUDIO_IN_MspInit (I2S_HandleTypeDef *hi2s, void *Params)
BSP AUDIO IN MSP Init.
void | BSP_AUDIO_IN_MspDeInit (I2S_HandleTypeDef *hi2s, void *Params)
DeInitializes BSP_AUDIO_IN MSP.

Function Documentation

void BSP_AUDIO_IN_ClockConfig | ( | I2S_HandleTypeDef * | hi2s,
 |  | uint32_t | AudioFreq,
 |  | void * | Params
 | ) |  |

Audio In Clock Config.

Parameters:
hi2s,: I2S handle
AudioFreq,: Audio frequency used to record the audio stream.
Params : pointer on additional configuration parameters, can be NULL.
Note:
This API is called by BSP_AUDIO_IN_Init() Being __weak it can be overwritten by the application

Definition at line 852 of file stm32f4_discovery_audio.c.

Referenced by BSP_AUDIO_IN_Init().

void BSP_AUDIO_IN_Error_Callback ( void )

Audio IN Error callback function.

Definition at line 1004 of file stm32f4_discovery_audio.c.

Referenced by HAL_I2S_ErrorCallback().

void BSP_AUDIO_IN_HalfTransfer_CallBack ( void )

Manages the DMA Half Transfer complete event.

Definition at line 994 of file stm32f4_discovery_audio.c.

Referenced by HAL_I2S_RxHalfCpltCallback().

uint8_t BSP_AUDIO_IN_Init | ( | uint32_t | AudioFreq,
 |  | uint32_t | BitRes,
 |  | uint32_t | ChnlNbr
 | ) |  |

Initializes wave recording.

Parameters:
AudioFreq,: Audio frequency to be configured for the I2S peripheral.
BitRes,: Audio frequency to be configured for the I2S peripheral.
ChnlNbr,: Audio frequency to be configured for the I2S peripheral.
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 688 of file stm32f4_discovery_audio.c.

References AUDIO_OK, BSP_AUDIO_IN_ClockConfig(), BSP_AUDIO_IN_MspInit(), hAudioInI2s, I2S2, I2S2_Init(), and PDMDecoder_Init().

void BSP_AUDIO_IN_MspDeInit | ( | I2S_HandleTypeDef * | hi2s,
 |  | void * | Params
 | ) |  |

DeInitializes BSP_AUDIO_IN MSP.

Parameters:
hi2s,: I2S handle
Params : pointer on additional configuration parameters, can be NULL.

Definition at line 952 of file stm32f4_discovery_audio.c.

References I2S2, I2S2_CLK_DISABLE, I2S2_DMAx_IRQ, I2S2_MOSI_GPIO_PORT, I2S2_MOSI_PIN, I2S2_SCK_GPIO_PORT, and I2S2_SCK_PIN.

void BSP_AUDIO_IN_MspInit | ( | I2S_HandleTypeDef * | hi2s,
 |  | void * | Params
 | ) |  |

BSP AUDIO IN MSP Init.

Parameters:
hi2s,: I2S handle
Params : pointer on additional configuration parameters, can be NULL.

Definition at line 886 of file stm32f4_discovery_audio.c.

References AUDIO_IN_IRQ_PREPRIO, I2S2, I2S2_CLK_ENABLE, I2S2_DMAx_CHANNEL, I2S2_DMAx_CLK_ENABLE, I2S2_DMAx_IRQ, I2S2_DMAx_MEM_DATA_SIZE, I2S2_DMAx_PERIPH_DATA_SIZE, I2S2_DMAx_STREAM, I2S2_MOSI_AF, I2S2_MOSI_GPIO_CLK_ENABLE, I2S2_MOSI_GPIO_PORT, I2S2_MOSI_PIN, I2S2_SCK_AF, I2S2_SCK_GPIO_CLK_ENABLE, I2S2_SCK_GPIO_PORT, and I2S2_SCK_PIN.

Referenced by BSP_AUDIO_IN_Init().

uint8_t BSP_AUDIO_IN_Pause ( void )

Pauses the audio file stream.

Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 754 of file stm32f4_discovery_audio.c.

References AUDIO_OK, and hAudioInI2s.

uint8_t BSP_AUDIO_IN_PDMToPCM | ( | uint16_t * | PDMBuf,
 |  | uint16_t * | PCMBuf
 | ) |  |

Converts audio format from PDM to PCM.

Parameters:
PDMBuf,: Pointer to data PDM buffer
PCMBuf,: Pointer to data PCM buffer
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 797 of file stm32f4_discovery_audio.c.

References AUDIO_OK, DEFAULT_AUDIO_IN_CHANNEL_NBR, HTONS, INTERNAL_BUFF_SIZE, PCM_OUT_SIZE, and PDM_FilterHandler.

uint8_t BSP_AUDIO_IN_Record | ( | uint16_t * | pbuf,
 |  | uint32_t | size
 | ) |  |

Starts audio recording.

Parameters:
pbuf,: Main buffer pointer for the recorded data storing
size,: Current size of the recorded buffer
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 720 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_OK, and hAudioInI2s.

uint8_t BSP_AUDIO_IN_Resume ( void )

Resumes the audio file stream.

Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 767 of file stm32f4_discovery_audio.c.

References AUDIO_OK, and hAudioInI2s.

uint8_t BSP_AUDIO_IN_SetVolume ( uint8_t Volume )

Controls the audio in volume level.

Parameters:
Volume,: Volume level to be set in percentage from 0% to 100% (0 for Mute and 100 for Max volume level).
Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 782 of file stm32f4_discovery_audio.c.

References AUDIO_OK, and AudioInVolume.

uint8_t BSP_AUDIO_IN_Stop ( void )

Stops audio recording.

Return values:
AUDIO_OK if correct communication, else wrong communication

Definition at line 737 of file stm32f4_discovery_audio.c.

References AUDIO_ERROR, AUDIO_OK, and hAudioInI2s.

void BSP_AUDIO_IN_TransferComplete_CallBack ( void )

User callback when record buffer is filled.

Definition at line 984 of file stm32f4_discovery_audio.c.

Referenced by HAL_I2S_RxCpltCallback().


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • _
  • a
  • b
  • c
  • d
  • g
  • h
  • i
  • k
  • l
  • m
  • p
  • r
  • s
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- _ -

  • __STM32F4_DISCO_BSP_VERSION : stm32f4_discovery.c
  • __STM32F4_DISCO_BSP_VERSION_MAIN : stm32f4_discovery.c
  • __STM32F4_DISCO_BSP_VERSION_RC : stm32f4_discovery.c
  • __STM32F4_DISCO_BSP_VERSION_SUB1 : stm32f4_discovery.c
  • __STM32F4_DISCO_BSP_VERSION_SUB2 : stm32f4_discovery.c


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • _
  • a
  • b
  • c
  • d
  • g
  • h
  • i
  • k
  • l
  • m
  • p
  • r
  • s
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- a -

  • ACCELERO_CS_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • ACCELERO_CS_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • ACCELERO_CS_GPIO_PORT : stm32f4_discovery.h
  • ACCELERO_CS_HIGH : stm32f4_discovery.h
  • ACCELERO_CS_LOW : stm32f4_discovery.h
  • ACCELERO_CS_PIN : stm32f4_discovery.h
  • ACCELERO_ERROR : stm32f4_discovery_accelerometer.h
  • ACCELERO_INT1_EXTI_IRQn : stm32f4_discovery.h
  • ACCELERO_INT1_PIN : stm32f4_discovery.h
  • ACCELERO_INT2_EXTI_IRQn : stm32f4_discovery.h
  • ACCELERO_INT2_PIN : stm32f4_discovery.h
  • ACCELERO_INT_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • ACCELERO_INT_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • ACCELERO_INT_GPIO_PORT : stm32f4_discovery.h
  • ACCELERO_IO_Init() : stm32f4_discovery.c
  • ACCELERO_IO_ITConfig() : stm32f4_discovery.c
  • ACCELERO_IO_Read() : stm32f4_discovery.c
  • ACCELERO_IO_Write() : stm32f4_discovery.c
  • ACCELERO_OK : stm32f4_discovery_accelerometer.h
  • ACCELERO_StatusTypeDef : stm32f4_discovery_accelerometer.h
  • ACCELERO_TIMEOUT : stm32f4_discovery_accelerometer.h
  • AcceleroDrv : stm32f4_discovery_accelerometer.c
  • AUDIO_ERROR : stm32f4_discovery_audio.h
  • AUDIO_I2C_ADDRESS : stm32f4_discovery.h
  • AUDIO_IN_IRQ_PREPRIO : stm32f4_discovery_audio.h
  • AUDIO_IO_DeInit() : stm32f4_discovery.c
  • AUDIO_IO_Init() : stm32f4_discovery.c
  • AUDIO_IO_Read() : stm32f4_discovery.c
  • AUDIO_IO_Write() : stm32f4_discovery.c
  • AUDIO_OK : stm32f4_discovery_audio.h
  • AUDIO_OUT_IRQ_PREPRIO : stm32f4_discovery_audio.h
  • AUDIO_RESET_GPIO : stm32f4_discovery.h
  • AUDIO_RESET_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • AUDIO_RESET_PIN : stm32f4_discovery.h
  • AUDIO_TIMEOUT : stm32f4_discovery_audio.h
  • AUDIODATA_SIZE : stm32f4_discovery_audio.h
  • AudioInVolume : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • _
  • a
  • b
  • c
  • d
  • g
  • h
  • i
  • k
  • l
  • m
  • p
  • r
  • s
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- b -

  • BSP_ACCELERO_Click_ITClear() : stm32f4_discovery_accelerometer.c , stm32f4_discovery_accelerometer.h
  • BSP_ACCELERO_Click_ITConfig() : stm32f4_discovery_accelerometer.h , stm32f4_discovery_accelerometer.c
  • BSP_ACCELERO_GetXYZ() : stm32f4_discovery_accelerometer.c , stm32f4_discovery_accelerometer.h
  • BSP_ACCELERO_Init() : stm32f4_discovery_accelerometer.h , stm32f4_discovery_accelerometer.c
  • BSP_ACCELERO_ReadID() : stm32f4_discovery_accelerometer.c , stm32f4_discovery_accelerometer.h
  • BSP_ACCELERO_Reset() : stm32f4_discovery_accelerometer.c , stm32f4_discovery_accelerometer.h
  • BSP_AUDIO_IN_ClockConfig() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_Error_Callback() : stm32f4_discovery_audio.h , stm32f4_discovery_audio.c
  • BSP_AUDIO_IN_HalfTransfer_CallBack() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_Init() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_MspDeInit() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_MspInit() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_Pause() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_PDMToPCM() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_Record() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_Resume() : stm32f4_discovery_audio.h , stm32f4_discovery_audio.c
  • BSP_AUDIO_IN_SetVolume() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_Stop() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_TransferComplete_CallBack() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_ChangeBuffer() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_ClockConfig() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_Error_CallBack() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_HalfTransfer_CallBack() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_Init() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_MspDeInit() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_MspInit() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_Pause() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_Play() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_Resume() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_SetFrequency() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_SetMute() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_SetOutputMode() : stm32f4_discovery_audio.h , stm32f4_discovery_audio.c
  • BSP_AUDIO_OUT_SetVolume() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_Stop() : stm32f4_discovery_audio.h , stm32f4_discovery_audio.c
  • BSP_AUDIO_OUT_TransferComplete_CallBack() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_GetVersion() : stm32f4_discovery.h , stm32f4_discovery.c
  • BSP_LED_Init() : stm32f4_discovery.c , stm32f4_discovery.h
  • BSP_LED_Off() : stm32f4_discovery.h , stm32f4_discovery.c
  • BSP_LED_On() : stm32f4_discovery.h , stm32f4_discovery.c
  • BSP_LED_Toggle() : stm32f4_discovery.h , stm32f4_discovery.c
  • BSP_PB_GetState() : stm32f4_discovery.h , stm32f4_discovery.c
  • BSP_PB_Init() : stm32f4_discovery.h , stm32f4_discovery.c
  • BUTTON_IRQn : stm32f4_discovery.c
  • BUTTON_KEY : stm32f4_discovery.h
  • BUTTON_MODE_EXTI : stm32f4_discovery.h
  • BUTTON_MODE_GPIO : stm32f4_discovery.h
  • BUTTON_PIN : stm32f4_discovery.c
  • BUTTON_PORT : stm32f4_discovery.c
  • Button_TypeDef : stm32f4_discovery.h
  • ButtonMode_TypeDef : stm32f4_discovery.h
  • BUTTONn : stm32f4_discovery.h
  • BUTTONx_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • BUTTONx_GPIO_CLK_ENABLE : stm32f4_discovery.h


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • _
  • a
  • b
  • c
  • d
  • g
  • h
  • i
  • k
  • l
  • m
  • p
  • r
  • s
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- c -

  • CHANNEL_DEMUX_MASK : stm32f4_discovery_audio.h


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • _
  • a
  • b
  • c
  • d
  • g
  • h
  • i
  • k
  • l
  • m
  • p
  • r
  • s
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- d -

  • DEFAULT_AUDIO_IN_BIT_RESOLUTION : stm32f4_discovery_audio.h
  • DEFAULT_AUDIO_IN_CHANNEL_NBR : stm32f4_discovery_audio.h
  • DEFAULT_AUDIO_IN_FREQ : stm32f4_discovery_audio.h
  • DEFAULT_AUDIO_IN_VOLUME : stm32f4_discovery_audio.h
  • DISCOVERY_I2Cx : stm32f4_discovery.h
  • DISCOVERY_I2Cx_CLK_ENABLE : stm32f4_discovery.h
  • DISCOVERY_I2Cx_ER_IRQn : stm32f4_discovery.h
  • DISCOVERY_I2Cx_EV_IRQn : stm32f4_discovery.h
  • DISCOVERY_I2Cx_FORCE_RESET : stm32f4_discovery.h
  • DISCOVERY_I2Cx_RELEASE_RESET : stm32f4_discovery.h
  • DISCOVERY_I2Cx_SCL_PIN : stm32f4_discovery.h
  • DISCOVERY_I2Cx_SCL_SDA_AF : stm32f4_discovery.h
  • DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT : stm32f4_discovery.h
  • DISCOVERY_I2Cx_SDA_PIN : stm32f4_discovery.h
  • DISCOVERY_SPIx : stm32f4_discovery.h
  • DISCOVERY_SPIx_AF : stm32f4_discovery.h
  • DISCOVERY_SPIx_CLK_ENABLE : stm32f4_discovery.h
  • DISCOVERY_SPIx_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • DISCOVERY_SPIx_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • DISCOVERY_SPIx_GPIO_PORT : stm32f4_discovery.h
  • DISCOVERY_SPIx_MISO_PIN : stm32f4_discovery.h
  • DISCOVERY_SPIx_MOSI_PIN : stm32f4_discovery.h
  • DISCOVERY_SPIx_SCK_PIN : stm32f4_discovery.h
  • DMA_MAX : stm32f4_discovery_audio.h
  • DMA_MAX_SZE : stm32f4_discovery_audio.h
  • DUMMY_BYTE : stm32f4_discovery.h


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • _
  • a
  • b
  • c
  • d
  • g
  • h
  • i
  • k
  • l
  • m
  • p
  • r
  • s
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- g -

  • GPIO_PIN : stm32f4_discovery.c
  • GPIO_PORT : stm32f4_discovery.c


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • _
  • a
  • b
  • c
  • d
  • g
  • h
  • i
  • k
  • l
  • m
  • p
  • r
  • s
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- h -

  • HAL_I2S_ErrorCallback() : stm32f4_discovery_audio.c
  • HAL_I2S_RxCpltCallback() : stm32f4_discovery_audio.c
  • HAL_I2S_RxHalfCpltCallback() : stm32f4_discovery_audio.c
  • HAL_I2S_TxCpltCallback() : stm32f4_discovery_audio.c
  • HAL_I2S_TxHalfCpltCallback() : stm32f4_discovery_audio.c
  • hAudioInI2s : stm32f4_discovery_audio.c
  • hAudioOutI2s : stm32f4_discovery_audio.c
  • HTONS : stm32f4_discovery_audio.h


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • _
  • a
  • b
  • c
  • d
  • g
  • h
  • i
  • k
  • l
  • m
  • p
  • r
  • s
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- i -

  • I2cHandle : stm32f4_discovery.c
  • I2Cx_Error() : stm32f4_discovery.c
  • I2Cx_Init() : stm32f4_discovery.c
  • I2Cx_MspInit() : stm32f4_discovery.c
  • I2Cx_ReadData() : stm32f4_discovery.c
  • I2Cx_TIMEOUT_MAX : stm32f4_discovery.h
  • I2Cx_WriteData() : stm32f4_discovery.c
  • I2cxTimeout : stm32f4_discovery.c
  • I2S2 : stm32f4_discovery_audio.h
  • I2S2_CLK_DISABLE : stm32f4_discovery_audio.h
  • I2S2_CLK_ENABLE : stm32f4_discovery_audio.h
  • I2S2_DMAx_CHANNEL : stm32f4_discovery_audio.h
  • I2S2_DMAx_CLK_DISABLE : stm32f4_discovery_audio.h
  • I2S2_DMAx_CLK_ENABLE : stm32f4_discovery_audio.h
  • I2S2_DMAx_IRQ : stm32f4_discovery_audio.h
  • I2S2_DMAx_MEM_DATA_SIZE : stm32f4_discovery_audio.h
  • I2S2_DMAx_PERIPH_DATA_SIZE : stm32f4_discovery_audio.h
  • I2S2_DMAx_STREAM : stm32f4_discovery_audio.h
  • I2S2_Init() : stm32f4_discovery_audio.c
  • I2S2_IRQHandler : stm32f4_discovery_audio.h
  • I2S2_MOSI_AF : stm32f4_discovery_audio.h
  • I2S2_MOSI_GPIO_CLK_ENABLE : stm32f4_discovery_audio.h
  • I2S2_MOSI_GPIO_PORT : stm32f4_discovery_audio.h
  • I2S2_MOSI_PIN : stm32f4_discovery_audio.h
  • I2S2_SCK_AF : stm32f4_discovery_audio.h
  • I2S2_SCK_GPIO_CLK_ENABLE : stm32f4_discovery_audio.h
  • I2S2_SCK_GPIO_PORT : stm32f4_discovery_audio.h
  • I2S2_SCK_PIN : stm32f4_discovery_audio.h
  • I2S3 : stm32f4_discovery_audio.h
  • I2S3_CLK_DISABLE : stm32f4_discovery_audio.h
  • I2S3_CLK_ENABLE : stm32f4_discovery_audio.h
  • I2S3_DMAx_CHANNEL : stm32f4_discovery_audio.h
  • I2S3_DMAx_CLK_DISABLE : stm32f4_discovery_audio.h
  • I2S3_DMAx_CLK_ENABLE : stm32f4_discovery_audio.h
  • I2S3_DMAx_IRQ : stm32f4_discovery_audio.h
  • I2S3_DMAx_MEM_DATA_SIZE : stm32f4_discovery_audio.h
  • I2S3_DMAx_PERIPH_DATA_SIZE : stm32f4_discovery_audio.h
  • I2S3_DMAx_STREAM : stm32f4_discovery_audio.h
  • I2S3_Init() : stm32f4_discovery_audio.c
  • I2S3_IRQHandler : stm32f4_discovery_audio.h
  • I2S3_MCK_CLK_ENABLE : stm32f4_discovery_audio.h
  • I2S3_MCK_GPIO_PORT : stm32f4_discovery_audio.h
  • I2S3_MCK_PIN : stm32f4_discovery_audio.h
  • I2S3_SCK_PIN : stm32f4_discovery_audio.h
  • I2S3_SCK_SD_CLK_ENABLE : stm32f4_discovery_audio.h
  • I2S3_SCK_SD_GPIO_PORT : stm32f4_discovery_audio.h
  • I2S3_SCK_SD_WS_AF : stm32f4_discovery_audio.h
  • I2S3_SD_PIN : stm32f4_discovery_audio.h
  • I2S3_WS_CLK_ENABLE : stm32f4_discovery_audio.h
  • I2S3_WS_GPIO_PORT : stm32f4_discovery_audio.h
  • I2S3_WS_PIN : stm32f4_discovery_audio.h
  • I2SFreq : stm32f4_discovery_audio.c
  • I2SPLLN : stm32f4_discovery_audio.c
  • I2SPLLR : stm32f4_discovery_audio.c
  • INTERNAL_BUFF_SIZE : stm32f4_discovery_audio.h


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • _
  • a
  • b
  • c
  • d
  • g
  • h
  • i
  • k
  • l
  • m
  • p
  • r
  • s
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- k -

  • KEY_BUTTON_EXTI_IRQn : stm32f4_discovery.h
  • KEY_BUTTON_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • KEY_BUTTON_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • KEY_BUTTON_GPIO_PORT : stm32f4_discovery.h
  • KEY_BUTTON_PIN : stm32f4_discovery.h


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • _
  • a
  • b
  • c
  • d
  • g
  • h
  • i
  • k
  • l
  • m
  • p
  • r
  • s
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- l -

  • LED3 : stm32f4_discovery.h
  • LED3_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • LED3_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • LED3_GPIO_PORT : stm32f4_discovery.h
  • LED3_PIN : stm32f4_discovery.h
  • LED4 : stm32f4_discovery.h
  • LED4_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • LED4_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • LED4_GPIO_PORT : stm32f4_discovery.h
  • LED4_PIN : stm32f4_discovery.h
  • LED5 : stm32f4_discovery.h
  • LED5_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • LED5_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • LED5_GPIO_PORT : stm32f4_discovery.h
  • LED5_PIN : stm32f4_discovery.h
  • LED6 : stm32f4_discovery.h
  • LED6_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • LED6_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • LED6_GPIO_PORT : stm32f4_discovery.h
  • LED6_PIN : stm32f4_discovery.h
  • Led_TypeDef : stm32f4_discovery.h
  • LEDn : stm32f4_discovery.h
  • LEDx_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • LEDx_GPIO_CLK_ENABLE : stm32f4_discovery.h


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • _
  • a
  • b
  • c
  • d
  • g
  • h
  • i
  • k
  • l
  • m
  • p
  • r
  • s
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- m -

  • MULTIPLEBYTE_CMD : stm32f4_discovery.h


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • _
  • a
  • b
  • c
  • d
  • g
  • h
  • i
  • k
  • l
  • m
  • p
  • r
  • s
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- p -

  • pAudioDrv : stm32f4_discovery_audio.c
  • PCM_OUT_SIZE : stm32f4_discovery_audio.h
  • PDM_FilterConfig : stm32f4_discovery_audio.c
  • PDM_FilterHandler : stm32f4_discovery_audio.c
  • PDMDecoder_Init() : stm32f4_discovery_audio.c


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • _
  • a
  • b
  • c
  • d
  • g
  • h
  • i
  • k
  • l
  • m
  • p
  • r
  • s
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- r -

  • READWRITE_CMD : stm32f4_discovery.h


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • _
  • a
  • b
  • c
  • d
  • g
  • h
  • i
  • k
  • l
  • m
  • p
  • r
  • s
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- s -

  • SpiHandle : stm32f4_discovery.c
  • SPIx_Error() : stm32f4_discovery.c
  • SPIx_Init() : stm32f4_discovery.c
  • SPIx_MspInit() : stm32f4_discovery.c
  • SPIx_TIMEOUT_MAX : stm32f4_discovery.h
  • SPIx_WriteRead() : stm32f4_discovery.c
  • SpixTimeout : stm32f4_discovery.c


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • a
  • b
  • h
  • i
  • p
  • s

- a -

  • ACCELERO_IO_Init() : stm32f4_discovery.c
  • ACCELERO_IO_ITConfig() : stm32f4_discovery.c
  • ACCELERO_IO_Read() : stm32f4_discovery.c
  • ACCELERO_IO_Write() : stm32f4_discovery.c
  • AUDIO_IO_DeInit() : stm32f4_discovery.c
  • AUDIO_IO_Init() : stm32f4_discovery.c
  • AUDIO_IO_Read() : stm32f4_discovery.c
  • AUDIO_IO_Write() : stm32f4_discovery.c

- b -

  • BSP_ACCELERO_Click_ITClear() : stm32f4_discovery_accelerometer.c , stm32f4_discovery_accelerometer.h
  • BSP_ACCELERO_Click_ITConfig() : stm32f4_discovery_accelerometer.h , stm32f4_discovery_accelerometer.c
  • BSP_ACCELERO_GetXYZ() : stm32f4_discovery_accelerometer.c , stm32f4_discovery_accelerometer.h
  • BSP_ACCELERO_Init() : stm32f4_discovery_accelerometer.h , stm32f4_discovery_accelerometer.c
  • BSP_ACCELERO_ReadID() : stm32f4_discovery_accelerometer.c , stm32f4_discovery_accelerometer.h
  • BSP_ACCELERO_Reset() : stm32f4_discovery_accelerometer.c , stm32f4_discovery_accelerometer.h
  • BSP_AUDIO_IN_ClockConfig() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_Error_Callback() : stm32f4_discovery_audio.h , stm32f4_discovery_audio.c
  • BSP_AUDIO_IN_HalfTransfer_CallBack() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_Init() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_MspDeInit() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_MspInit() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_Pause() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_PDMToPCM() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_Record() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_Resume() : stm32f4_discovery_audio.h , stm32f4_discovery_audio.c
  • BSP_AUDIO_IN_SetVolume() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_Stop() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_IN_TransferComplete_CallBack() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_ChangeBuffer() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_ClockConfig() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_Error_CallBack() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_HalfTransfer_CallBack() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_Init() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_MspDeInit() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_MspInit() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_Pause() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_Play() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_Resume() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_SetFrequency() : stm32f4_discovery_audio.h , stm32f4_discovery_audio.c
  • BSP_AUDIO_OUT_SetMute() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_SetOutputMode() : stm32f4_discovery_audio.h , stm32f4_discovery_audio.c
  • BSP_AUDIO_OUT_SetVolume() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_Stop() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_AUDIO_OUT_TransferComplete_CallBack() : stm32f4_discovery_audio.c , stm32f4_discovery_audio.h
  • BSP_GetVersion() : stm32f4_discovery.c , stm32f4_discovery.h
  • BSP_LED_Init() : stm32f4_discovery.c , stm32f4_discovery.h
  • BSP_LED_Off() : stm32f4_discovery.h , stm32f4_discovery.c
  • BSP_LED_On() : stm32f4_discovery.h , stm32f4_discovery.c
  • BSP_LED_Toggle() : stm32f4_discovery.h , stm32f4_discovery.c
  • BSP_PB_GetState() : stm32f4_discovery.h , stm32f4_discovery.c
  • BSP_PB_Init() : stm32f4_discovery.h , stm32f4_discovery.c

- h -

  • HAL_I2S_ErrorCallback() : stm32f4_discovery_audio.c
  • HAL_I2S_RxCpltCallback() : stm32f4_discovery_audio.c
  • HAL_I2S_RxHalfCpltCallback() : stm32f4_discovery_audio.c
  • HAL_I2S_TxCpltCallback() : stm32f4_discovery_audio.c
  • HAL_I2S_TxHalfCpltCallback() : stm32f4_discovery_audio.c

- i -

  • I2Cx_Error() : stm32f4_discovery.c
  • I2Cx_Init() : stm32f4_discovery.c
  • I2Cx_MspInit() : stm32f4_discovery.c
  • I2Cx_ReadData() : stm32f4_discovery.c
  • I2Cx_WriteData() : stm32f4_discovery.c
  • I2S2_Init() : stm32f4_discovery_audio.c
  • I2S3_Init() : stm32f4_discovery_audio.c

- p -

  • PDMDecoder_Init() : stm32f4_discovery_audio.c

- s -

  • SPIx_Error() : stm32f4_discovery.c
  • SPIx_Init() : stm32f4_discovery.c
  • SPIx_MspInit() : stm32f4_discovery.c
  • SPIx_WriteRead() : stm32f4_discovery.c


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • AcceleroDrv : stm32f4_discovery_accelerometer.c
  • AudioInVolume : stm32f4_discovery_audio.h , stm32f4_discovery_audio.c
  • BUTTON_IRQn : stm32f4_discovery.c
  • BUTTON_PIN : stm32f4_discovery.c
  • BUTTON_PORT : stm32f4_discovery.c
  • GPIO_PIN : stm32f4_discovery.c
  • GPIO_PORT : stm32f4_discovery.c
  • hAudioInI2s : stm32f4_discovery_audio.c
  • hAudioOutI2s : stm32f4_discovery_audio.c
  • I2cHandle : stm32f4_discovery.c
  • I2cxTimeout : stm32f4_discovery.c
  • I2SFreq : stm32f4_discovery_audio.c
  • I2SPLLN : stm32f4_discovery_audio.c
  • I2SPLLR : stm32f4_discovery_audio.c
  • pAudioDrv : stm32f4_discovery_audio.c
  • PDM_FilterConfig : stm32f4_discovery_audio.c
  • PDM_FilterHandler : stm32f4_discovery_audio.c
  • SpiHandle : stm32f4_discovery.c
  • SpixTimeout : stm32f4_discovery.c


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • ACCELERO_StatusTypeDef : stm32f4_discovery_accelerometer.h
  • Button_TypeDef : stm32f4_discovery.h
  • ButtonMode_TypeDef : stm32f4_discovery.h
  • Led_TypeDef : stm32f4_discovery.h


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • ACCELERO_ERROR : stm32f4_discovery_accelerometer.h
  • ACCELERO_OK : stm32f4_discovery_accelerometer.h
  • ACCELERO_TIMEOUT : stm32f4_discovery_accelerometer.h
  • BUTTON_KEY : stm32f4_discovery.h
  • BUTTON_MODE_EXTI : stm32f4_discovery.h
  • BUTTON_MODE_GPIO : stm32f4_discovery.h
  • LED3 : stm32f4_discovery.h
  • LED4 : stm32f4_discovery.h
  • LED5 : stm32f4_discovery.h
  • LED6 : stm32f4_discovery.h


./STM32F4-Discovery BSP User Manual: Globals

  • File List
  • Globals
  • All
  • Functions
  • Variables
  • Enumerations
  • Enumerator
  • Defines
  • _
  • a
  • b
  • c
  • d
  • h
  • i
  • k
  • l
  • m
  • p
  • r
  • s

- _ -

  • __STM32F4_DISCO_BSP_VERSION : stm32f4_discovery.c
  • __STM32F4_DISCO_BSP_VERSION_MAIN : stm32f4_discovery.c
  • __STM32F4_DISCO_BSP_VERSION_RC : stm32f4_discovery.c
  • __STM32F4_DISCO_BSP_VERSION_SUB1 : stm32f4_discovery.c
  • __STM32F4_DISCO_BSP_VERSION_SUB2 : stm32f4_discovery.c

- a -

  • ACCELERO_CS_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • ACCELERO_CS_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • ACCELERO_CS_GPIO_PORT : stm32f4_discovery.h
  • ACCELERO_CS_HIGH : stm32f4_discovery.h
  • ACCELERO_CS_LOW : stm32f4_discovery.h
  • ACCELERO_CS_PIN : stm32f4_discovery.h
  • ACCELERO_INT1_EXTI_IRQn : stm32f4_discovery.h
  • ACCELERO_INT1_PIN : stm32f4_discovery.h
  • ACCELERO_INT2_EXTI_IRQn : stm32f4_discovery.h
  • ACCELERO_INT2_PIN : stm32f4_discovery.h
  • ACCELERO_INT_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • ACCELERO_INT_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • ACCELERO_INT_GPIO_PORT : stm32f4_discovery.h
  • AUDIO_ERROR : stm32f4_discovery_audio.h
  • AUDIO_I2C_ADDRESS : stm32f4_discovery.h
  • AUDIO_IN_IRQ_PREPRIO : stm32f4_discovery_audio.h
  • AUDIO_OK : stm32f4_discovery_audio.h
  • AUDIO_OUT_IRQ_PREPRIO : stm32f4_discovery_audio.h
  • AUDIO_RESET_GPIO : stm32f4_discovery.h
  • AUDIO_RESET_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • AUDIO_RESET_PIN : stm32f4_discovery.h
  • AUDIO_TIMEOUT : stm32f4_discovery_audio.h
  • AUDIODATA_SIZE : stm32f4_discovery_audio.h

- b -

  • BUTTONn : stm32f4_discovery.h
  • BUTTONx_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • BUTTONx_GPIO_CLK_ENABLE : stm32f4_discovery.h

- c -

  • CHANNEL_DEMUX_MASK : stm32f4_discovery_audio.h

- d -

  • DEFAULT_AUDIO_IN_BIT_RESOLUTION : stm32f4_discovery_audio.h
  • DEFAULT_AUDIO_IN_CHANNEL_NBR : stm32f4_discovery_audio.h
  • DEFAULT_AUDIO_IN_FREQ : stm32f4_discovery_audio.h
  • DEFAULT_AUDIO_IN_VOLUME : stm32f4_discovery_audio.h
  • DISCOVERY_I2Cx : stm32f4_discovery.h
  • DISCOVERY_I2Cx_CLK_ENABLE : stm32f4_discovery.h
  • DISCOVERY_I2Cx_ER_IRQn : stm32f4_discovery.h
  • DISCOVERY_I2Cx_EV_IRQn : stm32f4_discovery.h
  • DISCOVERY_I2Cx_FORCE_RESET : stm32f4_discovery.h
  • DISCOVERY_I2Cx_RELEASE_RESET : stm32f4_discovery.h
  • DISCOVERY_I2Cx_SCL_PIN : stm32f4_discovery.h
  • DISCOVERY_I2Cx_SCL_SDA_AF : stm32f4_discovery.h
  • DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT : stm32f4_discovery.h
  • DISCOVERY_I2Cx_SDA_PIN : stm32f4_discovery.h
  • DISCOVERY_SPIx : stm32f4_discovery.h
  • DISCOVERY_SPIx_AF : stm32f4_discovery.h
  • DISCOVERY_SPIx_CLK_ENABLE : stm32f4_discovery.h
  • DISCOVERY_SPIx_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • DISCOVERY_SPIx_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • DISCOVERY_SPIx_GPIO_PORT : stm32f4_discovery.h
  • DISCOVERY_SPIx_MISO_PIN : stm32f4_discovery.h
  • DISCOVERY_SPIx_MOSI_PIN : stm32f4_discovery.h
  • DISCOVERY_SPIx_SCK_PIN : stm32f4_discovery.h
  • DMA_MAX : stm32f4_discovery_audio.h
  • DMA_MAX_SZE : stm32f4_discovery_audio.h
  • DUMMY_BYTE : stm32f4_discovery.h

- h -

  • HTONS : stm32f4_discovery_audio.h

- i -

  • I2Cx_TIMEOUT_MAX : stm32f4_discovery.h
  • I2S2 : stm32f4_discovery_audio.h
  • I2S2_CLK_DISABLE : stm32f4_discovery_audio.h
  • I2S2_CLK_ENABLE : stm32f4_discovery_audio.h
  • I2S2_DMAx_CHANNEL : stm32f4_discovery_audio.h
  • I2S2_DMAx_CLK_DISABLE : stm32f4_discovery_audio.h
  • I2S2_DMAx_CLK_ENABLE : stm32f4_discovery_audio.h
  • I2S2_DMAx_IRQ : stm32f4_discovery_audio.h
  • I2S2_DMAx_MEM_DATA_SIZE : stm32f4_discovery_audio.h
  • I2S2_DMAx_PERIPH_DATA_SIZE : stm32f4_discovery_audio.h
  • I2S2_DMAx_STREAM : stm32f4_discovery_audio.h
  • I2S2_IRQHandler : stm32f4_discovery_audio.h
  • I2S2_MOSI_AF : stm32f4_discovery_audio.h
  • I2S2_MOSI_GPIO_CLK_ENABLE : stm32f4_discovery_audio.h
  • I2S2_MOSI_GPIO_PORT : stm32f4_discovery_audio.h
  • I2S2_MOSI_PIN : stm32f4_discovery_audio.h
  • I2S2_SCK_AF : stm32f4_discovery_audio.h
  • I2S2_SCK_GPIO_CLK_ENABLE : stm32f4_discovery_audio.h
  • I2S2_SCK_GPIO_PORT : stm32f4_discovery_audio.h
  • I2S2_SCK_PIN : stm32f4_discovery_audio.h
  • I2S3 : stm32f4_discovery_audio.h
  • I2S3_CLK_DISABLE : stm32f4_discovery_audio.h
  • I2S3_CLK_ENABLE : stm32f4_discovery_audio.h
  • I2S3_DMAx_CHANNEL : stm32f4_discovery_audio.h
  • I2S3_DMAx_CLK_DISABLE : stm32f4_discovery_audio.h
  • I2S3_DMAx_CLK_ENABLE : stm32f4_discovery_audio.h
  • I2S3_DMAx_IRQ : stm32f4_discovery_audio.h
  • I2S3_DMAx_MEM_DATA_SIZE : stm32f4_discovery_audio.h
  • I2S3_DMAx_PERIPH_DATA_SIZE : stm32f4_discovery_audio.h
  • I2S3_DMAx_STREAM : stm32f4_discovery_audio.h
  • I2S3_IRQHandler : stm32f4_discovery_audio.h
  • I2S3_MCK_CLK_ENABLE : stm32f4_discovery_audio.h
  • I2S3_MCK_GPIO_PORT : stm32f4_discovery_audio.h
  • I2S3_MCK_PIN : stm32f4_discovery_audio.h
  • I2S3_SCK_PIN : stm32f4_discovery_audio.h
  • I2S3_SCK_SD_CLK_ENABLE : stm32f4_discovery_audio.h
  • I2S3_SCK_SD_GPIO_PORT : stm32f4_discovery_audio.h
  • I2S3_SCK_SD_WS_AF : stm32f4_discovery_audio.h
  • I2S3_SD_PIN : stm32f4_discovery_audio.h
  • I2S3_WS_CLK_ENABLE : stm32f4_discovery_audio.h
  • I2S3_WS_GPIO_PORT : stm32f4_discovery_audio.h
  • I2S3_WS_PIN : stm32f4_discovery_audio.h
  • INTERNAL_BUFF_SIZE : stm32f4_discovery_audio.h

- k -

  • KEY_BUTTON_EXTI_IRQn : stm32f4_discovery.h
  • KEY_BUTTON_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • KEY_BUTTON_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • KEY_BUTTON_GPIO_PORT : stm32f4_discovery.h
  • KEY_BUTTON_PIN : stm32f4_discovery.h

- l -

  • LED3_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • LED3_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • LED3_GPIO_PORT : stm32f4_discovery.h
  • LED3_PIN : stm32f4_discovery.h
  • LED4_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • LED4_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • LED4_GPIO_PORT : stm32f4_discovery.h
  • LED4_PIN : stm32f4_discovery.h
  • LED5_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • LED5_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • LED5_GPIO_PORT : stm32f4_discovery.h
  • LED5_PIN : stm32f4_discovery.h
  • LED6_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • LED6_GPIO_CLK_ENABLE : stm32f4_discovery.h
  • LED6_GPIO_PORT : stm32f4_discovery.h
  • LED6_PIN : stm32f4_discovery.h
  • LEDn : stm32f4_discovery.h
  • LEDx_GPIO_CLK_DISABLE : stm32f4_discovery.h
  • LEDx_GPIO_CLK_ENABLE : stm32f4_discovery.h

- m -

  • MULTIPLEBYTE_CMD : stm32f4_discovery.h

- p -

  • PCM_OUT_SIZE : stm32f4_discovery_audio.h

- r -

  • READWRITE_CMD : stm32f4_discovery.h

- s -

  • SPIx_TIMEOUT_MAX : stm32f4_discovery.h


./STM32F4-Discovery BSP User Manual: stm32f4_discovery.c File Reference

  • File List
  • Globals
  • Firmware
  • Drivers
  • BSP
  • STM32F4-Discovery
Defines | Functions | Variables
stm32f4_discovery.c File Reference

This file provides set of firmware functions to manage Leds and push-button available on STM32F4-Discovery Kit from STMicroelectronics. More...

#include "stm32f4_discovery.h"

Go to the source code of this file.

Defines

#define | __STM32F4_DISCO_BSP_VERSION_MAIN (0x02)
STM32F4 DISCO BSP Driver version number V2.1.4.
#define | __STM32F4_DISCO_BSP_VERSION_SUB1 (0x01)
#define | __STM32F4_DISCO_BSP_VERSION_SUB2 (0x04)
#define | __STM32F4_DISCO_BSP_VERSION_RC (0x00)
#define | __STM32F4_DISCO_BSP_VERSION

Functions

static void | I2Cx_Init (void)
Configures I2C interface.
static void | I2Cx_WriteData (uint8_t Addr, uint8_t Reg, uint8_t Value)
Write a value in a register of the device through BUS.
static uint8_t | I2Cx_ReadData (uint8_t Addr, uint8_t Reg)
Read a register of the device through BUS.
static void | I2Cx_MspInit (void)
I2C MSP Initialization.
static void | I2Cx_Error (uint8_t Addr)
Manages error callback by re-initializing I2C.
static void | SPIx_Init (void)
SPIx Bus initialization.
static void | SPIx_MspInit (void)
SPI MSP Init.
static uint8_t | SPIx_WriteRead (uint8_t Byte)
Sends a Byte through the SPI interface and return the Byte received from the SPI bus.
static void | SPIx_Error (void)
SPIx error treatment function.
void | ACCELERO_IO_Init (void)
Configures the Accelerometer SPI interface.
void | ACCELERO_IO_ITConfig (void)
Configures the Accelerometer INT2.
void | ACCELERO_IO_Write (uint8_t *pBuffer, uint8_t WriteAddr, uint16_t NumByteToWrite)
Writes one byte to the Accelerometer.
void | ACCELERO_IO_Read (uint8_t *pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead)
Reads a block of data from the Accelerometer.
void | AUDIO_IO_Init (void)
Initializes Audio low level.
void | AUDIO_IO_DeInit (void)
DeInitializes Audio low level.
void | AUDIO_IO_Write (uint8_t Addr, uint8_t Reg, uint8_t Value)
Writes a single data.
uint8_t | AUDIO_IO_Read (uint8_t Addr, uint8_t Reg)
Reads a single data.
uint32_t | BSP_GetVersion (void)
This method returns the STM32F4 DISCO BSP Driver revision.
void | BSP_LED_Init (Led_TypeDef Led)
Configures LED GPIO.
void | BSP_LED_On (Led_TypeDef Led)
Turns selected LED On.
void | BSP_LED_Off (Led_TypeDef Led)
Turns selected LED Off.
void | BSP_LED_Toggle (Led_TypeDef Led)
Toggles the selected LED.
void | BSP_PB_Init (Button_TypeDef Button, ButtonMode_TypeDef Mode)
Configures Button GPIO and EXTI Line.
uint32_t | BSP_PB_GetState (Button_TypeDef Button)
Returns the selected Button state.

Variables

GPIO_TypeDef * | GPIO_PORT [LEDn]
const uint16_t | GPIO_PIN [LEDn]
GPIO_TypeDef * | BUTTON_PORT [BUTTONn] = {KEY_BUTTON_GPIO_PORT}
const uint16_t | BUTTON_PIN [BUTTONn] = {KEY_BUTTON_PIN}
const uint8_t | BUTTON_IRQn [BUTTONn] = {KEY_BUTTON_EXTI_IRQn}
uint32_t | I2cxTimeout = I2Cx_TIMEOUT_MAX
uint32_t | SpixTimeout = SPIx_TIMEOUT_MAX
static SPI_HandleTypeDef | SpiHandle
static I2C_HandleTypeDef | I2cHandle

Detailed Description

This file provides set of firmware functions to manage Leds and push-button available on STM32F4-Discovery Kit from STMicroelectronics.

Author:
MCD Application Team
Attention:

Copyright (c) 2017 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

Definition in file stm32f4_discovery.c.


./STM32F4-Discovery BSP User Manual: stm32f4_discovery.h File Reference

  • File List
  • Globals
  • Firmware
  • Drivers
  • BSP
  • STM32F4-Discovery
Defines | Enumerations | Functions
stm32f4_discovery.h File Reference

This file contains definitions for STM32F4-Discovery Kit's Leds and push-button hardware resources. More...

#include "stm32f4xx_hal.h"

Go to the source code of this file.

Defines

#define | LEDn 4
#define | LED4_PIN GPIO_PIN_12
#define | LED4_GPIO_PORT GPIOD
#define | LED4_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define | LED4_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
#define | LED3_PIN GPIO_PIN_13
#define | LED3_GPIO_PORT GPIOD
#define | LED3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define | LED3_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
#define | LED5_PIN GPIO_PIN_14
#define | LED5_GPIO_PORT GPIOD
#define | LED5_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define | LED5_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
#define | LED6_PIN GPIO_PIN_15
#define | LED6_GPIO_PORT GPIOD
#define | LED6_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define | LED6_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
#define | LEDx_GPIO_CLK_ENABLE(__INDEX__)
#define | LEDx_GPIO_CLK_DISABLE(__INDEX__)
#define | BUTTONn 1
#define | KEY_BUTTON_PIN GPIO_PIN_0
Wakeup push-button.
#define | KEY_BUTTON_GPIO_PORT GPIOA
#define | KEY_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define | KEY_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
#define | KEY_BUTTON_EXTI_IRQn EXTI0_IRQn
#define | BUTTONx_GPIO_CLK_ENABLE(__INDEX__)
#define | BUTTONx_GPIO_CLK_DISABLE(__INDEX__)
#define | DISCOVERY_SPIx SPI1
#define | DISCOVERY_SPIx_CLK_ENABLE() __HAL_RCC_SPI1_CLK_ENABLE()
#define | DISCOVERY_SPIx_GPIO_PORT GPIOA /* GPIOA */
#define | DISCOVERY_SPIx_AF GPIO_AF5_SPI1
#define | DISCOVERY_SPIx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define | DISCOVERY_SPIx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
#define | DISCOVERY_SPIx_SCK_PIN GPIO_PIN_5 /* PA.05 */
#define | DISCOVERY_SPIx_MISO_PIN GPIO_PIN_6 /* PA.06 */
#define | DISCOVERY_SPIx_MOSI_PIN GPIO_PIN_7 /* PA.07 */
#define | SPIx_TIMEOUT_MAX 0x1000 /*<! The value of the maximal timeout for BUS waiting loops */
#define | DISCOVERY_I2Cx I2C1
#define | DISCOVERY_I2Cx_CLK_ENABLE() __HAL_RCC_I2C1_CLK_ENABLE()
#define | DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define | DISCOVERY_I2Cx_SCL_SDA_AF GPIO_AF4_I2C1
#define | DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT GPIOB
#define | DISCOVERY_I2Cx_SCL_PIN GPIO_PIN_6
#define | DISCOVERY_I2Cx_SDA_PIN GPIO_PIN_9
#define | DISCOVERY_I2Cx_FORCE_RESET() __HAL_RCC_I2C1_FORCE_RESET()
#define | DISCOVERY_I2Cx_RELEASE_RESET() __HAL_RCC_I2C1_RELEASE_RESET()
#define | DISCOVERY_I2Cx_EV_IRQn I2C1_EV_IRQn
#define | DISCOVERY_I2Cx_ER_IRQn I2C1_ER_IRQn
#define | I2Cx_TIMEOUT_MAX 0x1000 /*<! The value of the maximal timeout for BUS waiting loops */
#define | READWRITE_CMD ((uint8_t)0x80)
#define | MULTIPLEBYTE_CMD ((uint8_t)0x40)
#define | DUMMY_BYTE ((uint8_t)0x00)
#define | ACCELERO_CS_LOW() HAL_GPIO_WritePin(ACCELERO_CS_GPIO_PORT, ACCELERO_CS_PIN, GPIO_PIN_RESET)
#define | ACCELERO_CS_HIGH() HAL_GPIO_WritePin(ACCELERO_CS_GPIO_PORT, ACCELERO_CS_PIN, GPIO_PIN_SET)
#define | ACCELERO_CS_PIN GPIO_PIN_3 /* PE.03 */
ACCELEROMETER Interface pins.
#define | ACCELERO_CS_GPIO_PORT GPIOE /* GPIOE */
#define | ACCELERO_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
#define | ACCELERO_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE()
#define | ACCELERO_INT_GPIO_PORT GPIOE /* GPIOE */
#define | ACCELERO_INT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
#define | ACCELERO_INT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE()
#define | ACCELERO_INT1_PIN GPIO_PIN_0 /* PE.00 */
#define | ACCELERO_INT1_EXTI_IRQn EXTI0_IRQn
#define | ACCELERO_INT2_PIN GPIO_PIN_1 /* PE.01 */
#define | ACCELERO_INT2_EXTI_IRQn EXTI1_IRQn
#define | AUDIO_I2C_ADDRESS 0x94
AUDIO I2C Interface pins.
#define | AUDIO_RESET_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define | AUDIO_RESET_PIN GPIO_PIN_4
#define | AUDIO_RESET_GPIO GPIOD

Enumerations

enum | Led_TypeDef { LED4 = 0, LED3 = 1, LED5 = 2, LED6 = 3 }
enum | Button_TypeDef { BUTTON_KEY = 0 }
enum | ButtonMode_TypeDef { BUTTON_MODE_GPIO = 0, BUTTON_MODE_EXTI = 1 }

Functions

uint32_t | BSP_GetVersion (void)
This method returns the STM32F4 DISCO BSP Driver revision.
void | BSP_LED_Init (Led_TypeDef Led)
Configures LED GPIO.
void | BSP_LED_On (Led_TypeDef Led)
Turns selected LED On.
void | BSP_LED_Off (Led_TypeDef Led)
Turns selected LED Off.
void | BSP_LED_Toggle (Led_TypeDef Led)
Toggles the selected LED.
void | BSP_PB_Init (Button_TypeDef Button, ButtonMode_TypeDef Mode)
Configures Button GPIO and EXTI Line.
uint32_t | BSP_PB_GetState (Button_TypeDef Button)
Returns the selected Button state.

Detailed Description

This file contains definitions for STM32F4-Discovery Kit's Leds and push-button hardware resources.

Author:
MCD Application Team
Attention:

Copyright (c) 2017 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

Definition in file stm32f4_discovery.h.


./STM32F4-Discovery BSP User Manual: stm32f4_discovery_accelerometer.c File Reference

  • File List
  • Globals
  • Firmware
  • Drivers
  • BSP
  • STM32F4-Discovery
Functions | Variables
stm32f4_discovery_accelerometer.c File Reference

This file provides a set of functions needed to manage the MEMS accelerometers available on STM32F4-Discovery Kit. More...

#include "stm32f4_discovery_accelerometer.h"

Go to the source code of this file.

Functions

uint8_t | BSP_ACCELERO_Init (void)
Setx Accelerometer Initialization.
uint8_t | BSP_ACCELERO_ReadID (void)
Read ID of Accelerometer component.
void | BSP_ACCELERO_Reset (void)
Reboot memory content of Accelerometer.
void | BSP_ACCELERO_Click_ITConfig (void)
Configure Accelerometer click IT.
void | BSP_ACCELERO_Click_ITClear (void)
Clear Accelerometer click IT.
void | BSP_ACCELERO_GetXYZ (int16_t *pDataXYZ)
Get XYZ axes acceleration.

Variables

static ACCELERO_DrvTypeDef * | AcceleroDrv

Detailed Description

This file provides a set of functions needed to manage the MEMS accelerometers available on STM32F4-Discovery Kit.

Author:
MCD Application Team
Attention:

Copyright (c) 2017 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

Definition in file stm32f4_discovery_accelerometer.c.


./STM32F4-Discovery BSP User Manual: stm32f4_discovery_accelerometer.h File Reference

  • File List
  • Globals
  • Firmware
  • Drivers
  • BSP
  • STM32F4-Discovery
Enumerations | Functions
stm32f4_discovery_accelerometer.h File Reference

This file contains all the functions prototypes for the stm32f4_discovery_accelerometer.c firmware driver. More...

#include "stm32f4_discovery.h"
#include "../Components/lis302dl/lis302dl.h"
#include "../Components/lis3dsh/lis3dsh.h"

Go to the source code of this file.

Enumerations

enum | ACCELERO_StatusTypeDef { ACCELERO_OK = 0, ACCELERO_ERROR = 1, ACCELERO_TIMEOUT = 2 }

Functions

uint8_t | BSP_ACCELERO_Init (void)
Setx Accelerometer Initialization.
uint8_t | BSP_ACCELERO_ReadID (void)
Read ID of Accelerometer component.
void | BSP_ACCELERO_Reset (void)
Reboot memory content of Accelerometer.
void | BSP_ACCELERO_Click_ITConfig (void)
Configure Accelerometer click IT.
void | BSP_ACCELERO_Click_ITClear (void)
Clear Accelerometer click IT.
void | BSP_ACCELERO_GetXYZ (int16_t *pDataXYZ)
Get XYZ axes acceleration.

Detailed Description

This file contains all the functions prototypes for the stm32f4_discovery_accelerometer.c firmware driver.

Author:
MCD Application Team
Attention:

Copyright (c) 2017 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

Definition in file stm32f4_discovery_accelerometer.h.


./STM32F4-Discovery BSP User Manual: stm32f4_discovery_audio.c File Reference

  • File List
  • Globals
  • Firmware
  • Drivers
  • BSP
  • STM32F4-Discovery
Functions | Variables
stm32f4_discovery_audio.c File Reference

This file provides the Audio driver for the STM32F4-Discovery board. More...

#include "stm32f4_discovery_audio.h"

Go to the source code of this file.

Functions

static uint8_t | I2S3_Init (uint32_t AudioFreq)
Initializes the Audio Codec audio interface (I2S).
static uint8_t | I2S2_Init (uint32_t AudioFreq)
Initializes the Audio Codec audio interface (I2S)
static void | PDMDecoder_Init (uint32_t AudioFreq, uint32_t ChnlNbrIn, uint32_t ChnlNbrOut)
Initializes the PDM library.
uint8_t | BSP_AUDIO_OUT_Init (uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)
Configures the audio peripherals.
uint8_t | BSP_AUDIO_OUT_Play (uint16_t *pBuffer, uint32_t Size)
Starts playing audio stream from a data buffer for a determined size.
void | BSP_AUDIO_OUT_ChangeBuffer (uint16_t *pData, uint16_t Size)
Sends n-Bytes on the I2S interface.
uint8_t | BSP_AUDIO_OUT_Pause (void)
Pauses the audio file stream.
uint8_t | BSP_AUDIO_OUT_Resume (void)
Resumes the audio file streaming.
uint8_t | BSP_AUDIO_OUT_Stop (uint32_t Option)
Stops audio playing and Power down the Audio Codec.
uint8_t | BSP_AUDIO_OUT_SetVolume (uint8_t Volume)
Controls the current audio volume level.
uint8_t | BSP_AUDIO_OUT_SetMute (uint32_t Cmd)
Enables or disables the MUTE mode by software.
uint8_t | BSP_AUDIO_OUT_SetOutputMode (uint8_t Output)
Switch dynamically (while audio file is played) the output target (speaker or headphone).
void | BSP_AUDIO_OUT_SetFrequency (uint32_t AudioFreq)
Update the audio frequency.
void | HAL_I2S_TxCpltCallback (I2S_HandleTypeDef *hi2s)
Tx Transfer completed callbacks.
void | HAL_I2S_TxHalfCpltCallback (I2S_HandleTypeDef *hi2s)
Tx Half Transfer completed callbacks.
__weak void | BSP_AUDIO_OUT_ClockConfig (I2S_HandleTypeDef *hi2s, uint32_t AudioFreq, void *Params)
Clock Config.
__weak void | BSP_AUDIO_OUT_MspInit (I2S_HandleTypeDef *hi2s, void *Params)
AUDIO OUT I2S MSP Init.
__weak void | BSP_AUDIO_OUT_MspDeInit (I2S_HandleTypeDef *hi2s, void *Params)
De-Initializes BSP_AUDIO_OUT MSP.
__weak void | BSP_AUDIO_OUT_TransferComplete_CallBack (void)
Manages the DMA full Transfer complete event.
__weak void | BSP_AUDIO_OUT_HalfTransfer_CallBack (void)
Manages the DMA Half Transfer complete event.
__weak void | BSP_AUDIO_OUT_Error_CallBack (void)
Manages the DMA FIFO error event.
uint8_t | BSP_AUDIO_IN_Init (uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr)
Initializes wave recording.
uint8_t | BSP_AUDIO_IN_Record (uint16_t *pbuf, uint32_t size)
Starts audio recording.
uint8_t | BSP_AUDIO_IN_Stop (void)
Stops audio recording.
uint8_t | BSP_AUDIO_IN_Pause (void)
Pauses the audio file stream.
uint8_t | BSP_AUDIO_IN_Resume (void)
Resumes the audio file stream.
uint8_t | BSP_AUDIO_IN_SetVolume (uint8_t Volume)
Controls the audio in volume level.
uint8_t | BSP_AUDIO_IN_PDMToPCM (uint16_t *PDMBuf, uint16_t *PCMBuf)
Converts audio format from PDM to PCM.
void | HAL_I2S_RxCpltCallback (I2S_HandleTypeDef *hi2s)
Rx Transfer completed callbacks.
void | HAL_I2S_RxHalfCpltCallback (I2S_HandleTypeDef *hi2s)
Rx Half Transfer completed callbacks.
__weak void | BSP_AUDIO_IN_ClockConfig (I2S_HandleTypeDef *hi2s, uint32_t AudioFreq, void *Params)
Audio In Clock Config.
__weak void | BSP_AUDIO_IN_MspInit (I2S_HandleTypeDef *hi2s, void *Params)
BSP AUDIO IN MSP Init.
__weak void | BSP_AUDIO_IN_MspDeInit (I2S_HandleTypeDef *hi2s, void *Params)
DeInitializes BSP_AUDIO_IN MSP.
__weak void | BSP_AUDIO_IN_TransferComplete_CallBack (void)
User callback when record buffer is filled.
__weak void | BSP_AUDIO_IN_HalfTransfer_CallBack (void)
Manages the DMA Half Transfer complete event.
__weak void | BSP_AUDIO_IN_Error_Callback (void)
Audio IN Error callback function.
void | HAL_I2S_ErrorCallback (I2S_HandleTypeDef *hi2s)
I2S error callbacks.

Variables

const uint32_t | I2SFreq [8] = {8000, 11025, 16000, 22050, 32000, 44100, 48000, 96000}
const uint32_t | I2SPLLN [8] = {256, 429, 213, 429, 426, 271, 258, 344}
const uint32_t | I2SPLLR [8] = {5, 4, 4, 4, 4, 6, 3, 1}
static AUDIO_DrvTypeDef * | pAudioDrv
I2S_HandleTypeDef | hAudioOutI2s
I2S_HandleTypeDef | hAudioInI2s
PDM_Filter_Handler_t | PDM_FilterHandler [2]
PDM_Filter_Config_t | PDM_FilterConfig [2]
__IO uint16_t | AudioInVolume = DEFAULT_AUDIO_IN_VOLUME

Detailed Description

This file provides the Audio driver for the STM32F4-Discovery board.

Author:
MCD Application Team
Attention:

Copyright (c) 2017 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

Definition in file stm32f4_discovery_audio.c.


./STM32F4-Discovery BSP User Manual: stm32f4_discovery_audio.h File Reference

  • File List
  • Globals
  • Firmware
  • Drivers
  • BSP
  • STM32F4-Discovery
Defines | Functions | Variables
stm32f4_discovery_audio.h File Reference

This file contains the common defines and functions prototypes for stm32f4_discovery_audio.c driver. More...

#include "../Components/cs43l22/cs43l22.h"
#include "stm32f4_discovery.h"
#include "../../../Middlewares/ST/STM32_Audio/Addons/PDM/Inc/pdm2pcm_glo.h"

Go to the source code of this file.

Defines

#define | I2S3 SPI3
#define | I2S3_CLK_ENABLE() __HAL_RCC_SPI3_CLK_ENABLE()
#define | I2S3_CLK_DISABLE() __HAL_RCC_SPI3_CLK_DISABLE()
#define | I2S3_SCK_SD_WS_AF GPIO_AF6_SPI3
#define | I2S3_SCK_SD_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define | I2S3_MCK_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define | I2S3_WS_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define | I2S3_WS_PIN GPIO_PIN_4
#define | I2S3_SCK_PIN GPIO_PIN_10
#define | I2S3_SD_PIN GPIO_PIN_12
#define | I2S3_MCK_PIN GPIO_PIN_7
#define | I2S3_SCK_SD_GPIO_PORT GPIOC
#define | I2S3_WS_GPIO_PORT GPIOA
#define | I2S3_MCK_GPIO_PORT GPIOC
#define | I2S3_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE()
#define | I2S3_DMAx_CLK_DISABLE() __HAL_RCC_DMA1_CLK_DISABLE()
#define | I2S3_DMAx_STREAM DMA1_Stream7
#define | I2S3_DMAx_CHANNEL DMA_CHANNEL_0
#define | I2S3_DMAx_IRQ DMA1_Stream7_IRQn
#define | I2S3_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
#define | I2S3_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
#define | DMA_MAX_SZE 0xFFFF
#define | I2S3_IRQHandler DMA1_Stream7_IRQHandler
#define | AUDIO_OUT_IRQ_PREPRIO 0x0E /* Select the preemption priority level(0 is the highest) */
#define | I2S2 SPI2
#define | I2S2_CLK_ENABLE() __HAL_RCC_SPI2_CLK_ENABLE()
#define | I2S2_CLK_DISABLE() __HAL_RCC_SPI2_CLK_DISABLE()
#define | I2S2_SCK_PIN GPIO_PIN_10
#define | I2S2_SCK_GPIO_PORT GPIOB
#define | I2S2_SCK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define | I2S2_SCK_AF GPIO_AF5_SPI2
#define | I2S2_MOSI_PIN GPIO_PIN_3
#define | I2S2_MOSI_GPIO_PORT GPIOC
#define | I2S2_MOSI_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define | I2S2_MOSI_AF GPIO_AF5_SPI2
#define | I2S2_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE()
#define | I2S2_DMAx_CLK_DISABLE() __HAL_RCC_DMA1_CLK_DISABLE()
#define | I2S2_DMAx_STREAM DMA1_Stream3
#define | I2S2_DMAx_CHANNEL DMA_CHANNEL_0
#define | I2S2_DMAx_IRQ DMA1_Stream3_IRQn
#define | I2S2_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
#define | I2S2_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
#define | I2S2_IRQHandler DMA1_Stream3_IRQHandler
#define | AUDIO_IN_IRQ_PREPRIO 0x0F /* Select the preemption priority level(0 is the highest) */
#define | AUDIODATA_SIZE 2 /* 16-bits audio data size */
#define | AUDIO_OK 0
#define | AUDIO_ERROR 1
#define | AUDIO_TIMEOUT 2
#define | DEFAULT_AUDIO_IN_FREQ I2S_AUDIOFREQ_16K
#define | DEFAULT_AUDIO_IN_BIT_RESOLUTION 16
#define | DEFAULT_AUDIO_IN_CHANNEL_NBR 1 /* Mono = 1, Stereo = 2 */
#define | DEFAULT_AUDIO_IN_VOLUME 64
#define | INTERNAL_BUFF_SIZE 128*DEFAULT_AUDIO_IN_FREQ/16000*DEFAULT_AUDIO_IN_CHANNEL_NBR
#define | PCM_OUT_SIZE DEFAULT_AUDIO_IN_FREQ/1000
#define | CHANNEL_DEMUX_MASK 0x55
#define | DMA_MAX(_X_) (((_X_) <= DMA_MAX_SZE)? (_X_):DMA_MAX_SZE)
#define | HTONS(A) ((((uint16_t)(A) & 0xff00) >> 8) | (((uint16_t)(A) & 0x00ff) << 8))

Functions

uint8_t | BSP_AUDIO_OUT_Init (uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)
Configures the audio peripherals.
uint8_t | BSP_AUDIO_OUT_Play (uint16_t *pBuffer, uint32_t Size)
Starts playing audio stream from a data buffer for a determined size.
void | BSP_AUDIO_OUT_ChangeBuffer (uint16_t *pData, uint16_t Size)
Sends n-Bytes on the I2S interface.
uint8_t | BSP_AUDIO_OUT_Pause (void)
Pauses the audio file stream.
uint8_t | BSP_AUDIO_OUT_Resume (void)
Resumes the audio file streaming.
uint8_t | BSP_AUDIO_OUT_Stop (uint32_t Option)
Stops audio playing and Power down the Audio Codec.
uint8_t | BSP_AUDIO_OUT_SetVolume (uint8_t Volume)
Controls the current audio volume level.
void | BSP_AUDIO_OUT_SetFrequency (uint32_t AudioFreq)
Update the audio frequency.
uint8_t | BSP_AUDIO_OUT_SetMute (uint32_t Cmd)
Enables or disables the MUTE mode by software.
uint8_t | BSP_AUDIO_OUT_SetOutputMode (uint8_t Output)
Switch dynamically (while audio file is played) the output target (speaker or headphone).
void | BSP_AUDIO_OUT_TransferComplete_CallBack (void)
Manages the DMA full Transfer complete event.
void | BSP_AUDIO_OUT_HalfTransfer_CallBack (void)
Manages the DMA Half Transfer complete event.
void | BSP_AUDIO_OUT_Error_CallBack (void)
Manages the DMA FIFO error event.
void | BSP_AUDIO_OUT_ClockConfig (I2S_HandleTypeDef *hi2s, uint32_t AudioFreq, void *Params)
Clock Config.
void | BSP_AUDIO_OUT_MspInit (I2S_HandleTypeDef *hi2s, void *Params)
AUDIO OUT I2S MSP Init.
void | BSP_AUDIO_OUT_MspDeInit (I2S_HandleTypeDef *hi2s, void *Params)
De-Initializes BSP_AUDIO_OUT MSP.
uint8_t | BSP_AUDIO_IN_Init (uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr)
Initializes wave recording.
uint8_t | BSP_AUDIO_IN_Record (uint16_t *pData, uint32_t Size)
Starts audio recording.
uint8_t | BSP_AUDIO_IN_Stop (void)
Stops audio recording.
uint8_t | BSP_AUDIO_IN_Pause (void)
Pauses the audio file stream.
uint8_t | BSP_AUDIO_IN_Resume (void)
Resumes the audio file stream.
uint8_t | BSP_AUDIO_IN_SetVolume (uint8_t Volume)
Controls the audio in volume level.
uint8_t | BSP_AUDIO_IN_PDMToPCM (uint16_t *PDMBuf, uint16_t *PCMBuf)
Converts audio format from PDM to PCM.
void | BSP_AUDIO_IN_TransferComplete_CallBack (void)
User callback when record buffer is filled.
void | BSP_AUDIO_IN_HalfTransfer_CallBack (void)
Manages the DMA Half Transfer complete event.
void | BSP_AUDIO_IN_Error_Callback (void)
Audio IN Error callback function.
void | BSP_AUDIO_IN_ClockConfig (I2S_HandleTypeDef *hi2s, uint32_t AudioFreq, void *Params)
Audio In Clock Config.
void | BSP_AUDIO_IN_MspInit (I2S_HandleTypeDef *hi2s, void *Params)
BSP AUDIO IN MSP Init.
void | BSP_AUDIO_IN_MspDeInit (I2S_HandleTypeDef *hi2s, void *Params)
DeInitializes BSP_AUDIO_IN MSP.

Variables

__IO uint16_t | AudioInVolume

Detailed Description

This file contains the common defines and functions prototypes for stm32f4_discovery_audio.c driver.

Author:
MCD Application Team
Attention:

Copyright (c) 2017 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

Definition in file stm32f4_discovery_audio.h.


./STM32F4-Discovery BSP User Manual: C:/git/f4_master/Firmware/Drivers/ Directory Reference

  • Firmware
  • Drivers
Drivers Directory Reference

Directories

directory BSP


./STM32F4-Discovery BSP User Manual: C:/git/f4_master/Firmware/Drivers/BSP/ Directory Reference

  • Firmware
  • Drivers
  • BSP
BSP Directory Reference

Directories

directory STM32F4-Discovery


./STM32F4-Discovery BSP User Manual: C:/git/f4_master/Firmware/Drivers/BSP/STM32F4-Discovery/ Directory Reference

  • Firmware
  • Drivers
  • BSP
  • STM32F4-Discovery
STM32F4-Discovery Directory Reference

Files

file | stm32f4_discovery.c [code]

This file provides set of firmware functions to manage Leds and push-button available on STM32F4-Discovery Kit from STMicroelectronics.

file | stm32f4_discovery.h [code]

This file contains definitions for STM32F4-Discovery Kit's Leds and push-button hardware resources.

file | stm32f4_discovery_accelerometer.c [code]

This file provides a set of functions needed to manage the MEMS accelerometers available on STM32F4-Discovery Kit.

file | stm32f4_discovery_accelerometer.h [code]

This file contains all the functions prototypes for the stm32f4_discovery_accelerometer.c firmware driver.

file | stm32f4_discovery_audio.c [code]

This file provides the Audio driver for the STM32F4-Discovery board.

file | stm32f4_discovery_audio.h [code]

This file contains the common defines and functions prototypes for stm32f4_discovery_audio.c driver.


./STM32F4-Discovery BSP User Manual: C:/git/f4_master/Firmware/ Directory Reference

  • Firmware
Firmware Directory Reference

Directories

directory Drivers


./STM32F4-Discovery BSP User Manual: Directories

Directories
This directory hierarchy is sorted roughly, but not completely, alphabetically:
  • Firmware
    • Drivers
      • BSP
        • STM32F4-Discovery


./STM32F4-Discovery BSP User Manual: File List

  • File List
  • Globals
File List
Here is a list of all files with brief descriptions:
stm32f4_discovery.c [code] | This file provides set of firmware functions to manage Leds and push-button available on STM32F4-Discovery Kit from STMicroelectronics
stm32f4_discovery.h [code] | This file contains definitions for STM32F4-Discovery Kit's Leds and push-button hardware resources
stm32f4_discovery_accelerometer.c [code] | This file provides a set of functions needed to manage the MEMS accelerometers available on STM32F4-Discovery Kit
stm32f4_discovery_accelerometer.h [code] | This file contains all the functions prototypes for the stm32f4_discovery_accelerometer.c firmware driver
stm32f4_discovery_audio.c [code] | This file provides the Audio driver for the STM32F4-Discovery board
stm32f4_discovery_audio.h [code] | This file contains the common defines and functions prototypes for stm32f4_discovery_audio.c driver


./STM32F4-Discovery BSP User Manual: BSP

Modules
BSP

Modules

STM32F4 DISCOVERY


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY

Modules
STM32F4 DISCOVERY
BSP

Modules

STM32F4 DISCOVERY LOW LEVEL

This file provides set of firmware functions to manage Leds and push-button available on STM32F4-Discovery Kit from STMicroelectronics.

STM32F4 DISCOVERY ACCELEROMETER

This file includes the motion sensor driver for ACCELEROMETER motion sensor devices.

STM32F4 DISCOVERY AUDIO

This file includes the low layer audio driver available on STM32F4-Discovery discovery board.


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY ACCELEROMETER

Modules
STM32F4 DISCOVERY ACCELEROMETER
STM32F4 DISCOVERY

This file includes the motion sensor driver for ACCELEROMETER motion sensor devices. More...

Modules

STM32F4 DISCOVERY ACCELEROMETER Private TypesDefinitions
STM32F4 DISCOVERY ACCELEROMETER Private Defines
STM32F4 DISCOVERY ACCELEROMETER Private Macros
STM32F4 DISCOVERY ACCELEROMETER Private Variables
STM32F4 DISCOVERY ACCELEROMETER Private FunctionPrototypes
STM32F4 DISCOVERY ACCELEROMETER Private Functions
STM32F4 DISCOVERY ACCELEROMETER Exported Types
STM32F4 DISCOVERY ACCELEROMETER Exported Functions

Detailed Description

This file includes the motion sensor driver for ACCELEROMETER motion sensor devices.


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY AUDIO

Modules
STM32F4 DISCOVERY AUDIO
STM32F4 DISCOVERY

This file includes the low layer audio driver available on STM32F4-Discovery discovery board. More...

Modules

STM32F4 DISCOVERY AUDIO Private Types
STM32F4 DISCOVERY AUDIO Private Defines
STM32F4 DISCOVERY AUDIO Private Macros
STM32F4 DISCOVERY AUDIO Private Variables
STM32F4 DISCOVERY AUDIO Private Function Prototypes
STM32F4 DISCOVERY AUDIO OUT Private Functions
STM32F4 DISCOVERY AUDIO IN Private Functions
STM32F4 DISCOVERY AUDIO IN OUT Private Functions
STM32F4 DISCOVERY AUDIO Exported Types
STM32F4 DISCOVERY AUDIO OUT Exported Constants
STM32F4 DISCOVERY AUDIO Exported Variables
STM32F4 DISCOVERY AUDIO Exported Macros
STM32F4 DISCOVERY AUDIO OUT Exported Functions
STM32F4 DISCOVERY AUDIO IN Exported Functions

Detailed Description

This file includes the low layer audio driver available on STM32F4-Discovery discovery board.


./STM32F4-Discovery BSP User Manual: STM32F4 DISCOVERY LOW LEVEL

Modules
STM32F4 DISCOVERY LOW LEVEL
STM32F4 DISCOVERY

This file provides set of firmware functions to manage Leds and push-button available on STM32F4-Discovery Kit from STMicroelectronics. More...

Modules

STM32F4 DISCOVERY LOW LEVEL Private TypesDefinitions
STM32F4 DISCOVERY LOW LEVEL Private Defines
STM32F4 DISCOVERY LOW LEVEL Private Macros
STM32F4 DISCOVERY LOW LEVEL Private Variables
STM32F4 DISCOVERY LOW LEVEL Private FunctionPrototypes
STM32F4 DISCOVERY LOW LEVEL Private Functions
STM32F4 DISCOVERY LOW LEVEL LED Functions
STM32F4 DISCOVERY LOW LEVEL BUTTON Functions
STM32F4 DISCOVERY LOW LEVEL BUS Functions
STM32F4 DISCOVERY LOW LEVEL_Exported_Types
STM32F4 DISCOVERY LOW LEVEL Exported Constants
STM32F4 DISCOVERY LOW LEVEL Exported Macros
STM32F4 DISCOVERY LOW LEVEL Exported Functions

Detailed Description

This file provides set of firmware functions to manage Leds and push-button available on STM32F4-Discovery Kit from STMicroelectronics.


./STM32F4-Discovery BSP User Manual: Modules

Modules
Here is a list of all modules:
  • BSP
    • STM32F4 DISCOVERY
      • STM32F4 DISCOVERY LOW LEVEL
        • STM32F4 DISCOVERY LOW LEVEL Private TypesDefinitions
        • STM32F4 DISCOVERY LOW LEVEL Private Defines
        • STM32F4 DISCOVERY LOW LEVEL Private Macros
        • STM32F4 DISCOVERY LOW LEVEL Private Variables
        • STM32F4 DISCOVERY LOW LEVEL Private FunctionPrototypes
        • STM32F4 DISCOVERY LOW LEVEL Private Functions
        • STM32F4 DISCOVERY LOW LEVEL LED Functions
        • STM32F4 DISCOVERY LOW LEVEL BUTTON Functions
        • STM32F4 DISCOVERY LOW LEVEL BUS Functions
        • STM32F4 DISCOVERY LOW LEVEL_Exported_Types
        • STM32F4 DISCOVERY LOW LEVEL Exported Constants
          • STM32F4 DISCOVERY LOW LEVEL LED
          • STM32F4 DISCOVERY LOW LEVEL BUTTON
          • STM32F4 DISCOVERY LOW LEVEL BUS
        • STM32F4 DISCOVERY LOW LEVEL Exported Macros
        • STM32F4 DISCOVERY LOW LEVEL Exported Functions
      • STM32F4 DISCOVERY ACCELEROMETER
        • STM32F4 DISCOVERY ACCELEROMETER Private TypesDefinitions
        • STM32F4 DISCOVERY ACCELEROMETER Private Defines
        • STM32F4 DISCOVERY ACCELEROMETER Private Macros
        • STM32F4 DISCOVERY ACCELEROMETER Private Variables
        • STM32F4 DISCOVERY ACCELEROMETER Private FunctionPrototypes
        • STM32F4 DISCOVERY ACCELEROMETER Private Functions
        • STM32F4 DISCOVERY ACCELEROMETER Exported Types
        • STM32F4 DISCOVERY ACCELEROMETER Exported Functions
      • STM32F4 DISCOVERY AUDIO
        • STM32F4 DISCOVERY AUDIO Private Types
        • STM32F4 DISCOVERY AUDIO Private Defines
        • STM32F4 DISCOVERY AUDIO Private Macros
        • STM32F4 DISCOVERY AUDIO Private Variables
        • STM32F4 DISCOVERY AUDIO Private Function Prototypes
        • STM32F4 DISCOVERY AUDIO OUT Private Functions
        • STM32F4 DISCOVERY AUDIO IN Private Functions
        • STM32F4 DISCOVERY AUDIO IN OUT Private Functions
        • STM32F4 DISCOVERY AUDIO Exported Types
        • STM32F4 DISCOVERY AUDIO OUT Exported Constants
        • STM32F4 DISCOVERY AUDIO Exported Variables
        • STM32F4 DISCOVERY AUDIO Exported Macros
        • STM32F4 DISCOVERY AUDIO OUT Exported Functions
        • STM32F4 DISCOVERY AUDIO IN Exported Functions


./STM32F4-Discovery BSP User Manual: stm32f4_discovery.c Source File

  • File List
  • Globals
  • Firmware
  • Drivers
  • BSP
  • STM32F4-Discovery
stm32f4_discovery.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4_discovery.c
00004   * @author  MCD Application Team
00005   * @brief   This file provides set of firmware functions to manage Leds and
00006   *          push-button available on STM32F4-Discovery Kit from STMicroelectronics.
00007   ******************************************************************************
00008   * @attention
00009   *
00010   * Copyright (c) 2017 STMicroelectronics.
00011   * All rights reserved.
00012   *
00013   * This software is licensed under terms that can be found in the LICENSE file
00014   * in the root directory of this software component.
00015   * If no LICENSE file comes with this software, it is provided AS-IS.
00016   *
00017   ******************************************************************************
00018   */
00019 /* Includes ------------------------------------------------------------------*/
00020 #include "stm32f4_discovery.h"
00021
00022 /** @defgroup BSP BSP
00023   * @{
00024   */
00025
00026 /** @defgroup STM32F4_DISCOVERY STM32F4 DISCOVERY
00027   * @{
00028   */
00029
00030 /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL STM32F4 DISCOVERY LOW LEVEL
00031   * @brief This file provides set of firmware functions to manage Leds and push-button
00032   *        available on STM32F4-Discovery Kit from STMicroelectronics.
00033   * @{
00034   */
00035
00036 /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Private_TypesDefinitions STM32F4 DISCOVERY LOW LEVEL Private TypesDefinitions
00037   * @{
00038   */
00039 /**
00040   * @}
00041   */
00042
00043 /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Private_Defines STM32F4 DISCOVERY LOW LEVEL Private Defines
00044   * @{
00045   */
00046
00047   /**
00048   * @brief STM32F4 DISCO BSP Driver version number V2.1.4
00049   */
00050 #define __STM32F4_DISCO_BSP_VERSION_MAIN   (0x02) /*!< [31:24] main version */
00051 #define __STM32F4_DISCO_BSP_VERSION_SUB1   (0x01) /*!< [23:16] sub1 version */
00052 #define __STM32F4_DISCO_BSP_VERSION_SUB2   (0x04) /*!< [15:8]  sub2 version */
00053 #define __STM32F4_DISCO_BSP_VERSION_RC     (0x00) /*!< [7:0]  release candidate */
00054 #define __STM32F4_DISCO_BSP_VERSION         ((__STM32F4_DISCO_BSP_VERSION_MAIN << 24)\
00055                                              |(__STM32F4_DISCO_BSP_VERSION_SUB1 << 16)\
00056                                              |(__STM32F4_DISCO_BSP_VERSION_SUB2 << 8 )\
00057                                              |(__STM32F4_DISCO_BSP_VERSION_RC))
00058 /**
00059   * @}
00060   */
00061
00062
00063 /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Private_Macros STM32F4 DISCOVERY LOW LEVEL Private Macros
00064   * @{
00065   */
00066 /**
00067   * @}
00068   */
00069
00070 /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Private_Variables STM32F4 DISCOVERY LOW LEVEL Private Variables
00071   * @{
00072   */
00073 GPIO_TypeDef* GPIO_PORT[LEDn] = {LED4_GPIO_PORT,
00074                                  LED3_GPIO_PORT,
00075                                  LED5_GPIO_PORT,
00076                                  LED6_GPIO_PORT};
00077 const uint16_t GPIO_PIN[LEDn] = {LED4_PIN,
00078                                  LED3_PIN,
00079                                  LED5_PIN,
00080                                  LED6_PIN};
00081
00082 GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {KEY_BUTTON_GPIO_PORT};
00083 const uint16_t BUTTON_PIN[BUTTONn] = {KEY_BUTTON_PIN};
00084 const uint8_t BUTTON_IRQn[BUTTONn] = {KEY_BUTTON_EXTI_IRQn};
00085
00086 uint32_t I2cxTimeout = I2Cx_TIMEOUT_MAX;    /*<! Value of Timeout when I2C communication fails */
00087 uint32_t SpixTimeout = SPIx_TIMEOUT_MAX;    /*<! Value of Timeout when SPI communication fails */
00088
00089 static SPI_HandleTypeDef    SpiHandle;
00090 static I2C_HandleTypeDef    I2cHandle;
00091 /**
00092   * @}
00093   */
00094
00095 /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Private_FunctionPrototypes STM32F4 DISCOVERY LOW LEVEL Private FunctionPrototypes
00096   * @{
00097   */
00098 /**
00099   * @}
00100   */
00101
00102 /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Private_Functions STM32F4 DISCOVERY LOW LEVEL Private Functions
00103   * @{
00104   */
00105 static void     I2Cx_Init(void);
00106 static void     I2Cx_WriteData(uint8_t Addr, uint8_t Reg, uint8_t Value);
00107 static uint8_t  I2Cx_ReadData(uint8_t Addr, uint8_t Reg);
00108 static void     I2Cx_MspInit(void);
00109 static void     I2Cx_Error(uint8_t Addr);
00110
00111 static void     SPIx_Init(void);
00112 static void     SPIx_MspInit(void);
00113 static uint8_t  SPIx_WriteRead(uint8_t Byte);
00114 static  void    SPIx_Error(void);
00115
00116 /* Link functions for Accelerometer peripheral */
00117 void            ACCELERO_IO_Init(void);
00118 void            ACCELERO_IO_ITConfig(void);
00119 void            ACCELERO_IO_Write(uint8_t *pBuffer, uint8_t WriteAddr, uint16_t NumByteToWrite);
00120 void            ACCELERO_IO_Read(uint8_t *pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead);
00121
00122 /* Link functions for Audio peripheral */
00123 void            AUDIO_IO_Init(void);
00124 void            AUDIO_IO_DeInit(void);
00125 void            AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
00126 uint8_t         AUDIO_IO_Read(uint8_t Addr, uint8_t Reg);
00127 /**
00128   * @}
00129   */
00130
00131 /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_LED_Functions STM32F4 DISCOVERY LOW LEVEL LED Functions
00132   * @{
00133   */
00134
00135 /**
00136   * @brief  This method returns the STM32F4 DISCO BSP Driver revision
00137   * @retval version : 0xXYZR (8bits for each decimal, R for RC)
00138   */
00139 uint32_t BSP_GetVersion(void)
00140 {
00141   return __STM32F4_DISCO_BSP_VERSION;
00142 }
00143
00144 /**
00145   * @brief  Configures LED GPIO.
00146   * @param  Led: Specifies the Led to be configured.
00147   *   This parameter can be one of following parameters:
00148   *     @arg LED4
00149   *     @arg LED3
00150   *     @arg LED5
00151   *     @arg LED6
00152   */
00153 void BSP_LED_Init(Led_TypeDef Led)
00154 {
00155   GPIO_InitTypeDef  GPIO_InitStruct;
00156
00157   /* Enable the GPIO_LED Clock */
00158   LEDx_GPIO_CLK_ENABLE(Led);
00159
00160   /* Configure the GPIO_LED pin */
00161   GPIO_InitStruct.Pin = GPIO_PIN[Led];
00162   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
00163   GPIO_InitStruct.Pull = GPIO_PULLUP;
00164   GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
00165
00166   HAL_GPIO_Init(GPIO_PORT[Led], &GPIO_InitStruct);
00167
00168   HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_RESET);
00169 }
00170
00171 /**
00172   * @brief  Turns selected LED On.
00173   * @param  Led: Specifies the Led to be set on.
00174   *   This parameter can be one of following parameters:
00175   *     @arg LED4
00176   *     @arg LED3
00177   *     @arg LED5
00178   *     @arg LED6
00179   */
00180 void BSP_LED_On(Led_TypeDef Led)
00181 {
00182   HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_SET);
00183 }
00184
00185 /**
00186   * @brief  Turns selected LED Off.
00187   * @param  Led: Specifies the Led to be set off.
00188   *   This parameter can be one of following parameters:
00189   *     @arg LED4
00190   *     @arg LED3
00191   *     @arg LED5
00192   *     @arg LED6
00193   */
00194 void BSP_LED_Off(Led_TypeDef Led)
00195 {
00196   HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_RESET);
00197 }
00198
00199 /**
00200   * @brief  Toggles the selected LED.
00201   * @param  Led: Specifies the Led to be toggled.
00202   *   This parameter can be one of following parameters:
00203   *     @arg LED4
00204   *     @arg LED3
00205   *     @arg LED5
00206   *     @arg LED6
00207   */
00208 void BSP_LED_Toggle(Led_TypeDef Led)
00209 {
00210   HAL_GPIO_TogglePin(GPIO_PORT[Led], GPIO_PIN[Led]);
00211 }
00212
00213 /**
00214   * @}
00215   */
00216
00217 /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_BUTTON_Functions STM32F4 DISCOVERY LOW LEVEL BUTTON Functions
00218   * @{
00219   */
00220
00221 /**
00222   * @brief  Configures Button GPIO and EXTI Line.
00223   * @param  Button: Specifies the Button to be configured.
00224   *   This parameter should be: BUTTON_KEY
00225   * @param  Mode: Specifies Button mode.
00226   *   This parameter can be one of following parameters:
00227   *     @arg BUTTON_MODE_GPIO: Button will be used as simple IO
00228   *     @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt
00229   *                            generation capability
00230   */
00231 void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Mode)
00232 {
00233   GPIO_InitTypeDef GPIO_InitStruct;
00234
00235   /* Enable the BUTTON Clock */
00236   BUTTONx_GPIO_CLK_ENABLE(Button);
00237
00238   if (Mode == BUTTON_MODE_GPIO)
00239   {
00240     /* Configure Button pin as input */
00241     GPIO_InitStruct.Pin = BUTTON_PIN[Button];
00242     GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
00243     GPIO_InitStruct.Pull = GPIO_NOPULL;
00244     GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
00245
00246     HAL_GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStruct);
00247   }
00248
00249   if (Mode == BUTTON_MODE_EXTI)
00250   {
00251     /* Configure Button pin as input with External interrupt */
00252     GPIO_InitStruct.Pin = BUTTON_PIN[Button];
00253     GPIO_InitStruct.Pull = GPIO_NOPULL;
00254     GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
00255     GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
00256     HAL_GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStruct);
00257
00258     /* Enable and set Button EXTI Interrupt to the lowest priority */
00259     HAL_NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x0F, 0);
00260     HAL_NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));
00261   }
00262 }
00263
00264 /**
00265   * @brief  Returns the selected Button state.
00266   * @param  Button: Specifies the Button to be checked.
00267   *   This parameter should be: BUTTON_KEY
00268   * @retval The Button GPIO pin value.
00269   */
00270 uint32_t BSP_PB_GetState(Button_TypeDef Button)
00271 {
00272   return HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]);
00273 }
00274
00275 /**
00276   * @}
00277   */
00278
00279 /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_BUS_Functions STM32F4 DISCOVERY LOW LEVEL BUS Functions
00280   * @{
00281   */
00282
00283 /*******************************************************************************
00284                             BUS OPERATIONS
00285 *******************************************************************************/
00286
00287 /******************************* SPI Routines *********************************/
00288
00289 /**
00290   * @brief  SPIx Bus initialization
00291   */
00292 static void SPIx_Init(void)
00293 {
00294   if(HAL_SPI_GetState(&SpiHandle) == HAL_SPI_STATE_RESET)
00295   {
00296     /* SPI configuration -----------------------------------------------------*/
00297     SpiHandle.Instance = DISCOVERY_SPIx;
00298     SpiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
00299     SpiHandle.Init.Direction = SPI_DIRECTION_2LINES;
00300     SpiHandle.Init.CLKPhase = SPI_PHASE_1EDGE;
00301     SpiHandle.Init.CLKPolarity = SPI_POLARITY_LOW;
00302     SpiHandle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
00303     SpiHandle.Init.CRCPolynomial = 7;
00304     SpiHandle.Init.DataSize = SPI_DATASIZE_8BIT;
00305     SpiHandle.Init.FirstBit = SPI_FIRSTBIT_MSB;
00306     SpiHandle.Init.NSS = SPI_NSS_SOFT;
00307     SpiHandle.Init.TIMode = SPI_TIMODE_DISABLED;
00308     SpiHandle.Init.Mode = SPI_MODE_MASTER;
00309
00310     SPIx_MspInit();
00311     HAL_SPI_Init(&SpiHandle);
00312   }
00313 }
00314
00315 /**
00316   * @brief  Sends a Byte through the SPI interface and return the Byte received
00317   *         from the SPI bus.
00318   * @param  Byte: Byte send.
00319   * @retval The received byte value
00320   */
00321 static uint8_t SPIx_WriteRead(uint8_t Byte)
00322 {
00323   uint8_t receivedbyte = 0;
00324
00325   /* Send a Byte through the SPI peripheral */
00326   /* Read byte from the SPI bus */
00327   if(HAL_SPI_TransmitReceive(&SpiHandle, (uint8_t*) &Byte, (uint8_t*) &receivedbyte, 1, SpixTimeout) != HAL_OK)
00328   {
00329     SPIx_Error();
00330   }
00331
00332   return receivedbyte;
00333 }
00334
00335 /**
00336   * @brief  SPIx error treatment function.
00337   */
00338 static void SPIx_Error(void)
00339 {
00340   /* De-initialize the SPI communication bus */
00341   HAL_SPI_DeInit(&SpiHandle);
00342
00343   /* Re-Initialize the SPI communication bus */
00344   SPIx_Init();
00345 }
00346
00347 /**
00348   * @brief  SPI MSP Init.
00349   */
00350 static void SPIx_MspInit(void)
00351 {
00352   GPIO_InitTypeDef   GPIO_InitStructure;
00353
00354   /* Enable the SPI peripheral */
00355   DISCOVERY_SPIx_CLK_ENABLE();
00356
00357   /* Enable SCK, MOSI and MISO GPIO clocks */
00358   DISCOVERY_SPIx_GPIO_CLK_ENABLE();
00359
00360   /* SPI SCK, MOSI, MISO pin configuration */
00361   GPIO_InitStructure.Pin = (DISCOVERY_SPIx_SCK_PIN | DISCOVERY_SPIx_MISO_PIN | DISCOVERY_SPIx_MOSI_PIN);
00362   GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
00363   GPIO_InitStructure.Pull  = GPIO_PULLDOWN;
00364   GPIO_InitStructure.Speed = GPIO_SPEED_MEDIUM;
00365   GPIO_InitStructure.Alternate = DISCOVERY_SPIx_AF;
00366   HAL_GPIO_Init(DISCOVERY_SPIx_GPIO_PORT, &GPIO_InitStructure);
00367 }
00368
00369 /******************************* I2C Routines**********************************/
00370 /**
00371   * @brief  Configures I2C interface.
00372   */
00373 static void I2Cx_Init(void)
00374 {
00375   if(HAL_I2C_GetState(&I2cHandle) == HAL_I2C_STATE_RESET)
00376   {
00377     /* DISCOVERY_I2Cx peripheral configuration */
00378     I2cHandle.Init.ClockSpeed = BSP_I2C_SPEED;
00379     I2cHandle.Init.DutyCycle = I2C_DUTYCYCLE_2;
00380     I2cHandle.Init.OwnAddress1 = 0x33;
00381     I2cHandle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
00382     I2cHandle.Instance = DISCOVERY_I2Cx;
00383
00384     /* Init the I2C */
00385     I2Cx_MspInit();
00386     HAL_I2C_Init(&I2cHandle);
00387   }
00388 }
00389
00390 /**
00391   * @brief  Write a value in a register of the device through BUS.
00392   * @param  Addr: Device address on BUS Bus.
00393   * @param  Reg: The target register address to write
00394   * @param  Value: The target register value to be written
00395   * @retval HAL status
00396   */
00397 static void I2Cx_WriteData(uint8_t Addr, uint8_t Reg, uint8_t Value)
00398 {
00399   HAL_StatusTypeDef status = HAL_OK;
00400
00401   status = HAL_I2C_Mem_Write(&I2cHandle, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, &Value, 1, I2cxTimeout);
00402
00403   /* Check the communication status */
00404   if(status != HAL_OK)
00405   {
00406     /* Execute user timeout callback */
00407     I2Cx_Error(Addr);
00408   }
00409 }
00410
00411 /**
00412   * @brief  Read a register of the device through BUS
00413   * @param  Addr: Device address on BUS
00414   * @param  Reg: The target register address to read
00415   * @retval HAL status
00416   */
00417 static uint8_t  I2Cx_ReadData(uint8_t Addr, uint8_t Reg)
00418 {
00419   HAL_StatusTypeDef status = HAL_OK;
00420   uint8_t value = 0;
00421
00422   status = HAL_I2C_Mem_Read(&I2cHandle, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, &value, 1,I2cxTimeout);
00423
00424   /* Check the communication status */
00425   if(status != HAL_OK)
00426   {
00427     /* Execute user timeout callback */
00428     I2Cx_Error(Addr);
00429   }
00430   return value;
00431 }
00432
00433 /**
00434   * @brief  Manages error callback by re-initializing I2C.
00435   * @param  Addr: I2C Address
00436   */
00437 static void I2Cx_Error(uint8_t Addr)
00438 {
00439   /* De-initialize the I2C communication bus */
00440   HAL_I2C_DeInit(&I2cHandle);
00441
00442   /* Re-Initialize the I2C communication bus */
00443   I2Cx_Init();
00444 }
00445
00446 /**
00447   * @brief I2C MSP Initialization
00448   */
00449 static void I2Cx_MspInit(void)
00450 {
00451   GPIO_InitTypeDef  GPIO_InitStruct;
00452
00453   /* Enable I2C GPIO clocks */
00454   DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_ENABLE();
00455
00456   /* DISCOVERY_I2Cx SCL and SDA pins configuration ---------------------------*/
00457   GPIO_InitStruct.Pin = DISCOVERY_I2Cx_SCL_PIN | DISCOVERY_I2Cx_SDA_PIN;
00458   GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
00459   GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
00460   GPIO_InitStruct.Pull  = GPIO_NOPULL;
00461   GPIO_InitStruct.Alternate  = DISCOVERY_I2Cx_SCL_SDA_AF;
00462   HAL_GPIO_Init(DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT, &GPIO_InitStruct);
00463
00464   /* Enable the DISCOVERY_I2Cx peripheral clock */
00465   DISCOVERY_I2Cx_CLK_ENABLE();
00466
00467   /* Force the I2C peripheral clock reset */
00468   DISCOVERY_I2Cx_FORCE_RESET();
00469
00470   /* Release the I2C peripheral clock reset */
00471   DISCOVERY_I2Cx_RELEASE_RESET();
00472
00473   /* Enable and set I2Cx Interrupt to the highest priority */
00474   HAL_NVIC_SetPriority(DISCOVERY_I2Cx_EV_IRQn, 0, 0);
00475   HAL_NVIC_EnableIRQ(DISCOVERY_I2Cx_EV_IRQn);
00476
00477   /* Enable and set I2Cx Interrupt to the highest priority */
00478   HAL_NVIC_SetPriority(DISCOVERY_I2Cx_ER_IRQn, 0, 0);
00479   HAL_NVIC_EnableIRQ(DISCOVERY_I2Cx_ER_IRQn);
00480 }
00481
00482 /*******************************************************************************
00483                             LINK OPERATIONS
00484 *******************************************************************************/
00485
00486 /***************************** LINK ACCELEROMETER *****************************/
00487
00488 /**
00489   * @brief  Configures the Accelerometer SPI interface.
00490   */
00491 void ACCELERO_IO_Init(void)
00492 {
00493   GPIO_InitTypeDef GPIO_InitStructure;
00494
00495   /* Configure the Accelerometer Control pins --------------------------------*/
00496   /* Enable CS GPIO clock and configure GPIO pin for Accelerometer Chip select */
00497   ACCELERO_CS_GPIO_CLK_ENABLE();
00498
00499   /* Configure GPIO PIN for LIS Chip select */
00500   GPIO_InitStructure.Pin = ACCELERO_CS_PIN;
00501   GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
00502   GPIO_InitStructure.Pull  = GPIO_NOPULL;
00503   GPIO_InitStructure.Speed = GPIO_SPEED_MEDIUM;
00504   HAL_GPIO_Init(ACCELERO_CS_GPIO_PORT, &GPIO_InitStructure);
00505
00506   /* Deselect: Chip Select high */
00507   ACCELERO_CS_HIGH();
00508
00509   SPIx_Init();
00510 }
00511
00512 /**
00513   * @brief  Configures the Accelerometer INT2.
00514   *         EXTI0 is already used by user button so INT1 is not configured here.
00515   */
00516 void ACCELERO_IO_ITConfig(void)
00517 {
00518   GPIO_InitTypeDef GPIO_InitStructure;
00519
00520   /* Enable INT2 GPIO clock and configure GPIO PINs to detect Interrupts */
00521   ACCELERO_INT_GPIO_CLK_ENABLE();
00522
00523   /* Configure GPIO PINs to detect Interrupts */
00524   GPIO_InitStructure.Pin = ACCELERO_INT2_PIN;
00525   GPIO_InitStructure.Mode = GPIO_MODE_IT_RISING;
00526   GPIO_InitStructure.Speed = GPIO_SPEED_FAST;
00527   GPIO_InitStructure.Pull = GPIO_NOPULL;
00528   HAL_GPIO_Init(ACCELERO_INT_GPIO_PORT, &GPIO_InitStructure);
00529
00530   /* Enable and set Accelerometer INT2 to the lowest priority */
00531   HAL_NVIC_SetPriority((IRQn_Type)ACCELERO_INT2_EXTI_IRQn, 0x0F, 0);
00532   HAL_NVIC_EnableIRQ((IRQn_Type)ACCELERO_INT2_EXTI_IRQn);
00533 }
00534
00535 /**
00536   * @brief  Writes one byte to the Accelerometer.
00537   * @param  pBuffer: pointer to the buffer containing the data to be written to the Accelerometer.
00538   * @param  WriteAddr: Accelerometer's internal address to write to.
00539   * @param  NumByteToWrite: Number of bytes to write.
00540   */
00541 void ACCELERO_IO_Write(uint8_t *pBuffer, uint8_t WriteAddr, uint16_t NumByteToWrite)
00542 {
00543   /* Configure the MS bit:
00544      - When 0, the address will remain unchanged in multiple read/write commands.
00545      - When 1, the address will be auto incremented in multiple read/write commands.
00546   */
00547   if(NumByteToWrite > 0x01)
00548   {
00549     WriteAddr |= (uint8_t)MULTIPLEBYTE_CMD;
00550   }
00551   /* Set chip select Low at the start of the transmission */
00552   ACCELERO_CS_LOW();
00553
00554   /* Send the Address of the indexed register */
00555   SPIx_WriteRead(WriteAddr);
00556
00557   /* Send the data that will be written into the device (MSB First) */
00558   while(NumByteToWrite >= 0x01)
00559   {
00560     SPIx_WriteRead(*pBuffer);
00561     NumByteToWrite--;
00562     pBuffer++;
00563   }
00564
00565   /* Set chip select High at the end of the transmission */
00566   ACCELERO_CS_HIGH();
00567 }
00568
00569 /**
00570   * @brief  Reads a block of data from the Accelerometer.
00571   * @param  pBuffer: pointer to the buffer that receives the data read from the Accelerometer.
00572   * @param  ReadAddr: Accelerometer's internal address to read from.
00573   * @param  NumByteToRead: number of bytes to read from the Accelerometer.
00574   */
00575 void ACCELERO_IO_Read(uint8_t *pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead)
00576 {
00577   if(NumByteToRead > 0x01)
00578   {
00579     ReadAddr |= (uint8_t)(READWRITE_CMD | MULTIPLEBYTE_CMD);
00580   }
00581   else
00582   {
00583     ReadAddr |= (uint8_t)READWRITE_CMD;
00584   }
00585   /* Set chip select Low at the start of the transmission */
00586   ACCELERO_CS_LOW();
00587
00588   /* Send the Address of the indexed register */
00589   SPIx_WriteRead(ReadAddr);
00590
00591   /* Receive the data that will be read from the device (MSB First) */
00592   while(NumByteToRead > 0x00)
00593   {
00594     /* Send dummy byte (0x00) to generate the SPI clock to ACCELEROMETER (Slave device) */
00595     *pBuffer = SPIx_WriteRead(DUMMY_BYTE);
00596     NumByteToRead--;
00597     pBuffer++;
00598   }
00599
00600   /* Set chip select High at the end of the transmission */
00601   ACCELERO_CS_HIGH();
00602 }
00603
00604 /********************************* LINK AUDIO *********************************/
00605
00606 /**
00607   * @brief  Initializes Audio low level.
00608   */
00609 void AUDIO_IO_Init(void)
00610 {
00611   GPIO_InitTypeDef  GPIO_InitStruct;
00612
00613   /* Enable Reset GPIO Clock */
00614   AUDIO_RESET_GPIO_CLK_ENABLE();
00615
00616   /* Audio reset pin configuration */
00617   GPIO_InitStruct.Pin = AUDIO_RESET_PIN;
00618   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
00619   GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
00620   GPIO_InitStruct.Pull  = GPIO_NOPULL;
00621   HAL_GPIO_Init(AUDIO_RESET_GPIO, &GPIO_InitStruct);
00622
00623   I2Cx_Init();
00624
00625   /* Power Down the codec */
00626   HAL_GPIO_WritePin(AUDIO_RESET_GPIO, AUDIO_RESET_PIN, GPIO_PIN_RESET);
00627
00628   /* Wait for a delay to insure registers erasing */
00629   HAL_Delay(5);
00630
00631   /* Power on the codec */
00632   HAL_GPIO_WritePin(AUDIO_RESET_GPIO, AUDIO_RESET_PIN, GPIO_PIN_SET);
00633
00634   /* Wait for a delay to insure registers erasing */
00635   HAL_Delay(5);
00636 }
00637
00638 /**
00639   * @brief  DeInitializes Audio low level.
00640   */
00641 void AUDIO_IO_DeInit(void)
00642 {
00643
00644 }
00645
00646 /**
00647   * @brief  Writes a single data.
00648   * @param  Addr: I2C address
00649   * @param  Reg: Reg address
00650   * @param  Value: Data to be written
00651   */
00652 void AUDIO_IO_Write (uint8_t Addr, uint8_t Reg, uint8_t Value)
00653 {
00654   I2Cx_WriteData(Addr, Reg, Value);
00655 }
00656
00657 /**
00658   * @brief  Reads a single data.
00659   * @param  Addr: I2C address
00660   * @param  Reg: Reg address
00661   * @retval Data to be read
00662   */
00663 uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg)
00664 {
00665   return I2Cx_ReadData(Addr, Reg);
00666 }
00667
00668 /**
00669   * @}
00670   */
00671
00672 /**
00673   * @}
00674   */
00675
00676 /**
00677   * @}
00678   */
00679
00680 /**
00681   * @}
00682   */


./STM32F4-Discovery BSP User Manual: stm32f4_discovery.h Source File

  • File List
  • Globals
  • Firmware
  • Drivers
  • BSP
  • STM32F4-Discovery
stm32f4_discovery.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4_discovery.h
00004   * @author  MCD Application Team
00005   * @brief   This file contains definitions for STM32F4-Discovery Kit's Leds and
00006   *          push-button hardware resources.
00007   ******************************************************************************
00008   * @attention
00009   *
00010   * Copyright (c) 2017 STMicroelectronics.
00011   * All rights reserved.
00012   *
00013   * This software is licensed under terms that can be found in the LICENSE file
00014   * in the root directory of this software component.
00015   * If no LICENSE file comes with this software, it is provided AS-IS.
00016   *
00017   ******************************************************************************
00018   */
00019
00020 /* Define to prevent recursive inclusion -------------------------------------*/
00021 #ifndef __STM32F4_DISCOVERY_H
00022 #define __STM32F4_DISCOVERY_H
00023
00024 #ifdef __cplusplus
00025  extern "C" {
00026 #endif
00027
00028 /* Includes ------------------------------------------------------------------*/
00029 #include "stm32f4xx_hal.h"
00030
00031 /** @addtogroup BSP
00032   * @{
00033   */
00034
00035 /** @addtogroup STM32F4_DISCOVERY
00036   * @{
00037   */
00038
00039 /** @addtogroup STM32F4_DISCOVERY_LOW_LEVEL
00040   * @{
00041   */
00042
00043 /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Exported_Types STM32F4 DISCOVERY LOW LEVEL_Exported_Types
00044   * @{
00045   */
00046 typedef enum
00047 {
00048   LED4 = 0,
00049   LED3 = 1,
00050   LED5 = 2,
00051   LED6 = 3
00052 } Led_TypeDef;
00053
00054 typedef enum
00055 {
00056   BUTTON_KEY = 0,
00057 } Button_TypeDef;
00058
00059 typedef enum
00060 {
00061   BUTTON_MODE_GPIO = 0,
00062   BUTTON_MODE_EXTI = 1
00063 } ButtonMode_TypeDef;
00064 /**
00065   * @}
00066   */
00067
00068 /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Exported_Constants STM32F4 DISCOVERY LOW LEVEL Exported Constants
00069   * @{
00070   */
00071
00072 /**
00073 * @brief  Define for STM32F4_DISCOVERY board
00074 */
00075 #if !defined (USE_STM32F4_DISCO)
00076  #define USE_STM32F4_DISCO
00077 #endif
00078
00079 /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_LED STM32F4 DISCOVERY LOW LEVEL LED
00080   * @{
00081   */
00082 #define LEDn                             4
00083
00084 #define LED4_PIN                         GPIO_PIN_12
00085 #define LED4_GPIO_PORT                   GPIOD
00086 #define LED4_GPIO_CLK_ENABLE()           __HAL_RCC_GPIOD_CLK_ENABLE()
00087 #define LED4_GPIO_CLK_DISABLE()          __HAL_RCC_GPIOD_CLK_DISABLE()
00088
00089 #define LED3_PIN                         GPIO_PIN_13
00090 #define LED3_GPIO_PORT                   GPIOD
00091 #define LED3_GPIO_CLK_ENABLE()           __HAL_RCC_GPIOD_CLK_ENABLE()
00092 #define LED3_GPIO_CLK_DISABLE()          __HAL_RCC_GPIOD_CLK_DISABLE()
00093
00094 #define LED5_PIN                         GPIO_PIN_14
00095 #define LED5_GPIO_PORT                   GPIOD
00096 #define LED5_GPIO_CLK_ENABLE()           __HAL_RCC_GPIOD_CLK_ENABLE()
00097 #define LED5_GPIO_CLK_DISABLE()          __HAL_RCC_GPIOD_CLK_DISABLE()
00098
00099 #define LED6_PIN                         GPIO_PIN_15
00100 #define LED6_GPIO_PORT                   GPIOD
00101 #define LED6_GPIO_CLK_ENABLE()           __HAL_RCC_GPIOD_CLK_ENABLE()
00102 #define LED6_GPIO_CLK_DISABLE()          __HAL_RCC_GPIOD_CLK_DISABLE()
00103
00104 #define LEDx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) LED4_GPIO_CLK_ENABLE(); else \
00105                                            if((__INDEX__) == 1) LED3_GPIO_CLK_ENABLE(); else \
00106                                            if((__INDEX__) == 2) LED5_GPIO_CLK_ENABLE(); else \
00107                                            if((__INDEX__) == 3) LED6_GPIO_CLK_ENABLE(); \
00108                                            }while(0)
00109
00110 #define LEDx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) LED4_GPIO_CLK_DISABLE(); else \
00111                                             if((__INDEX__) == 1) LED3_GPIO_CLK_DISABLE(); else \
00112                                             if((__INDEX__) == 2) LED5_GPIO_CLK_DISABLE(); else \
00113                                             if((__INDEX__) == 3) LED6_GPIO_CLK_DISABLE(); \
00114                                             }while(0)
00115 /**
00116   * @}
00117   */
00118
00119 /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_BUTTON STM32F4 DISCOVERY LOW LEVEL BUTTON
00120   * @{
00121   */
00122 #define BUTTONn                          1
00123
00124 /**
00125  * @brief Wakeup push-button
00126  */
00127 #define KEY_BUTTON_PIN                GPIO_PIN_0
00128 #define KEY_BUTTON_GPIO_PORT          GPIOA
00129 #define KEY_BUTTON_GPIO_CLK_ENABLE()  __HAL_RCC_GPIOA_CLK_ENABLE()
00130 #define KEY_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
00131 #define KEY_BUTTON_EXTI_IRQn          EXTI0_IRQn
00132
00133 #define BUTTONx_GPIO_CLK_ENABLE(__INDEX__)    do{if((__INDEX__) == 0) KEY_BUTTON_GPIO_CLK_ENABLE(); \
00134                                                 }while(0)
00135
00136 #define BUTTONx_GPIO_CLK_DISABLE(__INDEX__)    do{if((__INDEX__) == 0) KEY_BUTTON_GPIO_CLK_DISABLE(); \
00137                                                  }while(0)
00138 /**
00139   * @}
00140   */
00141
00142 /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_BUS STM32F4 DISCOVERY LOW LEVEL BUS
00143   * @{
00144   */
00145
00146 /*############################### SPI1 #######################################*/
00147 #define DISCOVERY_SPIx                              SPI1
00148 #define DISCOVERY_SPIx_CLK_ENABLE()                 __HAL_RCC_SPI1_CLK_ENABLE()
00149 #define DISCOVERY_SPIx_GPIO_PORT                    GPIOA                      /* GPIOA */
00150 #define DISCOVERY_SPIx_AF                           GPIO_AF5_SPI1
00151 #define DISCOVERY_SPIx_GPIO_CLK_ENABLE()            __HAL_RCC_GPIOA_CLK_ENABLE()
00152 #define DISCOVERY_SPIx_GPIO_CLK_DISABLE()           __HAL_RCC_GPIOA_CLK_DISABLE()
00153 #define DISCOVERY_SPIx_SCK_PIN                      GPIO_PIN_5                 /* PA.05 */
00154 #define DISCOVERY_SPIx_MISO_PIN                     GPIO_PIN_6                 /* PA.06 */
00155 #define DISCOVERY_SPIx_MOSI_PIN                     GPIO_PIN_7                 /* PA.07 */
00156
00157 /* Maximum Timeout values for flags waiting loops. These timeouts are not based
00158    on accurate values, they just guarantee that the application will not remain
00159    stuck if the SPI communication is corrupted.
00160    You may modify these timeout values depending on CPU frequency and application
00161    conditions (interrupts routines ...). */
00162 #define SPIx_TIMEOUT_MAX                            0x1000 /*<! The value of the maximal timeout for BUS waiting loops */
00163
00164
00165 /*############################# I2C1 #########################################*/
00166 /* I2C clock speed configuration (in Hz) */
00167 #ifndef BSP_I2C_SPEED
00168  #define BSP_I2C_SPEED                            100000
00169 #endif /* BSP_I2C_SPEED */
00170
00171 /* I2C peripheral configuration defines (control interface of the audio codec) */
00172 #define DISCOVERY_I2Cx                            I2C1
00173 #define DISCOVERY_I2Cx_CLK_ENABLE()               __HAL_RCC_I2C1_CLK_ENABLE()
00174 #define DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_ENABLE()  __HAL_RCC_GPIOB_CLK_ENABLE()
00175 #define DISCOVERY_I2Cx_SCL_SDA_AF                 GPIO_AF4_I2C1
00176 #define DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT          GPIOB
00177 #define DISCOVERY_I2Cx_SCL_PIN                    GPIO_PIN_6
00178 #define DISCOVERY_I2Cx_SDA_PIN                    GPIO_PIN_9
00179
00180 #define DISCOVERY_I2Cx_FORCE_RESET()              __HAL_RCC_I2C1_FORCE_RESET()
00181 #define DISCOVERY_I2Cx_RELEASE_RESET()            __HAL_RCC_I2C1_RELEASE_RESET()
00182
00183 /* I2C interrupt requests */
00184 #define DISCOVERY_I2Cx_EV_IRQn                    I2C1_EV_IRQn
00185 #define DISCOVERY_I2Cx_ER_IRQn                    I2C1_ER_IRQn
00186
00187 /* Maximum Timeout values for flags waiting loops. These timeouts are not based
00188    on accurate values, they just guarantee that the application will not remain
00189    stuck if the SPI communication is corrupted.
00190    You may modify these timeout values depending on CPU frequency and application
00191    conditions (interrupts routines ...). */
00192 #define I2Cx_TIMEOUT_MAX    0x1000 /*<! The value of the maximal timeout for BUS waiting loops */
00193
00194
00195 /*############################# ACCELEROMETER ################################*/
00196 /* Read/Write command */
00197 #define READWRITE_CMD                     ((uint8_t)0x80)
00198 /* Multiple byte read/write command */
00199 #define MULTIPLEBYTE_CMD                  ((uint8_t)0x40)
00200 /* Dummy Byte Send by the SPI Master device in order to generate the Clock to the Slave device */
00201 #define DUMMY_BYTE                        ((uint8_t)0x00)
00202
00203 /* Chip Select macro definition */
00204 #define ACCELERO_CS_LOW()       HAL_GPIO_WritePin(ACCELERO_CS_GPIO_PORT, ACCELERO_CS_PIN, GPIO_PIN_RESET)
00205 #define ACCELERO_CS_HIGH()      HAL_GPIO_WritePin(ACCELERO_CS_GPIO_PORT, ACCELERO_CS_PIN, GPIO_PIN_SET)
00206
00207 /**
00208   * @brief  ACCELEROMETER Interface pins
00209   */
00210 #define ACCELERO_CS_PIN                        GPIO_PIN_3                 /* PE.03 */
00211 #define ACCELERO_CS_GPIO_PORT                  GPIOE                      /* GPIOE */
00212 #define ACCELERO_CS_GPIO_CLK_ENABLE()          __HAL_RCC_GPIOE_CLK_ENABLE()
00213 #define ACCELERO_CS_GPIO_CLK_DISABLE()         __HAL_RCC_GPIOE_CLK_DISABLE()
00214 #define ACCELERO_INT_GPIO_PORT                 GPIOE                      /* GPIOE */
00215 #define ACCELERO_INT_GPIO_CLK_ENABLE()         __HAL_RCC_GPIOE_CLK_ENABLE()
00216 #define ACCELERO_INT_GPIO_CLK_DISABLE()        __HAL_RCC_GPIOE_CLK_DISABLE()
00217 #define ACCELERO_INT1_PIN                      GPIO_PIN_0                 /* PE.00 */
00218 #define ACCELERO_INT1_EXTI_IRQn                EXTI0_IRQn
00219 #define ACCELERO_INT2_PIN                      GPIO_PIN_1                 /* PE.01 */
00220 #define ACCELERO_INT2_EXTI_IRQn                EXTI1_IRQn
00221 /**
00222   * @}
00223   */
00224
00225
00226 /*############################### AUDIO ######################################*/
00227 /**
00228   * @brief  AUDIO I2C Interface pins
00229   */
00230 #define AUDIO_I2C_ADDRESS                     0x94
00231
00232   /* Audio Reset Pin definition */
00233 #define AUDIO_RESET_GPIO_CLK_ENABLE()         __HAL_RCC_GPIOD_CLK_ENABLE()
00234 #define AUDIO_RESET_PIN                       GPIO_PIN_4
00235 #define AUDIO_RESET_GPIO                      GPIOD
00236 /**
00237   * @}
00238   */
00239
00240 /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Exported_Macros STM32F4 DISCOVERY LOW LEVEL Exported Macros
00241   * @{
00242   */
00243 /**
00244   * @}
00245   */
00246
00247 /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Exported_Functions STM32F4 DISCOVERY LOW LEVEL Exported Functions
00248   * @{
00249   */
00250 uint32_t BSP_GetVersion(void);
00251 void     BSP_LED_Init(Led_TypeDef Led);
00252 void     BSP_LED_On(Led_TypeDef Led);
00253 void     BSP_LED_Off(Led_TypeDef Led);
00254 void     BSP_LED_Toggle(Led_TypeDef Led);
00255 void     BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Mode);
00256 uint32_t BSP_PB_GetState(Button_TypeDef Button);
00257
00258 /**
00259   * @}
00260   */
00261
00262 /**
00263   * @}
00264   */
00265
00266 /**
00267   * @}
00268   */
00269
00270 /**
00271   * @}
00272   */
00273
00274 /**
00275   * @}
00276   */
00277
00278 #ifdef __cplusplus
00279 }
00280 #endif
00281
00282 #endif /* __STM32F4_DISCOVERY_H */


./STM32F4-Discovery BSP User Manual: stm32f4_discovery_accelerometer.c Source File

  • File List
  • Globals
  • Firmware
  • Drivers
  • BSP
  • STM32F4-Discovery
stm32f4_discovery_accelerometer.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4_discovery_accelerometer.c
00004   * @author  MCD Application Team
00005   * @brief   This file provides a set of functions needed to manage the
00006   *          MEMS accelerometers available on STM32F4-Discovery Kit.
00007   ******************************************************************************
00008   * @attention
00009   *
00010   * Copyright (c) 2017 STMicroelectronics.
00011   * All rights reserved.
00012   *
00013   * This software is licensed under terms that can be found in the LICENSE file
00014   * in the root directory of this software component.
00015   * If no LICENSE file comes with this software, it is provided AS-IS.
00016   *
00017   ******************************************************************************
00018   */
00019
00020 /* Includes ------------------------------------------------------------------*/
00021 #include "stm32f4_discovery_accelerometer.h"
00022
00023 /** @addtogroup BSP
00024   * @{
00025   */
00026
00027 /** @addtogroup STM32F4_DISCOVERY
00028   * @{
00029   */
00030
00031 /** @defgroup STM32F4_DISCOVERY_ACCELEROMETER STM32F4 DISCOVERY ACCELEROMETER
00032   * @brief  This file includes the motion sensor driver for ACCELEROMETER motion sensor
00033   *         devices.
00034   * @{
00035   */
00036
00037 /** @defgroup STM32F4_DISCOVERY_ACCELEROMETER_Private_TypesDefinitions STM32F4 DISCOVERY ACCELEROMETER Private TypesDefinitions
00038   * @{
00039   */
00040 /**
00041   * @}
00042   */
00043
00044 /** @defgroup STM32F4_DISCOVERY_ACCELEROMETER_Private_Defines STM32F4 DISCOVERY ACCELEROMETER Private Defines
00045   * @{
00046   */
00047 /**
00048   * @}
00049   */
00050
00051 /** @defgroup STM32F4_DISCOVERY_ACCELEROMETER_Private_Macros STM32F4 DISCOVERY ACCELEROMETER Private Macros
00052   * @{
00053   */
00054 /**
00055   * @}
00056   */
00057
00058 /** @defgroup STM32F4_DISCOVERY_ACCELEROMETER_Private_Variables STM32F4 DISCOVERY ACCELEROMETER Private Variables
00059   * @{
00060   */
00061 static ACCELERO_DrvTypeDef *AcceleroDrv;
00062 /**
00063   * @}
00064   */
00065
00066 /** @defgroup STM32F4_DISCOVERY_ACCELEROMETER_Private_FunctionPrototypes STM32F4 DISCOVERY ACCELEROMETER Private FunctionPrototypes
00067   * @{
00068   */
00069 /**
00070   * @}
00071   */
00072
00073 /** @defgroup STM32F4_DISCOVERY_ACCELEROMETER_Private_Functions STM32F4 DISCOVERY ACCELEROMETER Private Functions
00074   * @{
00075   */
00076
00077 /**
00078   * @brief  Setx Accelerometer Initialization.
00079   * @retval ACCELERO_OK if no problem during initialization
00080   */
00081 uint8_t BSP_ACCELERO_Init(void)
00082 {
00083   uint8_t ret = ACCELERO_ERROR;
00084   uint16_t ctrl = 0x0000;
00085   LIS302DL_InitTypeDef         lis302dl_initstruct;
00086   LIS302DL_FilterConfigTypeDef lis302dl_filter = {0,0,0};
00087   LIS3DSH_InitTypeDef          l1s3dsh_InitStruct;
00088
00089   if(Lis302dlDrv.ReadID() == I_AM_LIS302DL)
00090   {
00091     /* Initialize the accelerometer driver structure */
00092     AcceleroDrv = &Lis302dlDrv;
00093
00094     /* Set configuration of LIS302DL MEMS Accelerometer *********************/
00095     lis302dl_initstruct.Power_Mode = LIS302DL_LOWPOWERMODE_ACTIVE;
00096     lis302dl_initstruct.Output_DataRate = LIS302DL_DATARATE_100;
00097     lis302dl_initstruct.Axes_Enable = LIS302DL_XYZ_ENABLE;
00098     lis302dl_initstruct.Full_Scale = LIS302DL_FULLSCALE_2_3;
00099     lis302dl_initstruct.Self_Test = LIS302DL_SELFTEST_NORMAL;
00100
00101     /* Configure MEMS: data rate, power mode, full scale, self test and axes */
00102     ctrl = (uint16_t) (lis302dl_initstruct.Output_DataRate | lis302dl_initstruct.Power_Mode | \
00103                        lis302dl_initstruct.Full_Scale | lis302dl_initstruct.Self_Test | \
00104                        lis302dl_initstruct.Axes_Enable);
00105
00106     /* Configure the accelerometer main parameters */
00107     AcceleroDrv->Init(ctrl);
00108
00109     /* MEMS High Pass Filter configuration */
00110     lis302dl_filter.HighPassFilter_Data_Selection = LIS302DL_FILTEREDDATASELECTION_OUTPUTREGISTER;
00111     lis302dl_filter.HighPassFilter_CutOff_Frequency = LIS302DL_HIGHPASSFILTER_LEVEL_1;
00112     lis302dl_filter.HighPassFilter_Interrupt = LIS302DL_HIGHPASSFILTERINTERRUPT_1_2;
00113
00114     /* Configure MEMS high pass filter cut-off level, interrupt and data selection bits */
00115     ctrl = (uint8_t)(lis302dl_filter.HighPassFilter_Data_Selection | \
00116                      lis302dl_filter.HighPassFilter_CutOff_Frequency | \
00117                      lis302dl_filter.HighPassFilter_Interrupt);
00118
00119     /* Configure the accelerometer LPF main parameters */
00120     AcceleroDrv->FilterConfig(ctrl);
00121
00122     ret = ACCELERO_OK;
00123   }
00124   else if(Lis3dshDrv.ReadID() == I_AM_LIS3DSH)
00125   {
00126     /* Initialize the accelerometer driver structure */
00127     AcceleroDrv = &Lis3dshDrv;
00128
00129     /* Set configuration of LIS3DSH MEMS Accelerometer **********************/
00130     l1s3dsh_InitStruct.Output_DataRate = LIS3DSH_DATARATE_100;
00131     l1s3dsh_InitStruct.Axes_Enable = LIS3DSH_XYZ_ENABLE;
00132     l1s3dsh_InitStruct.SPI_Wire = LIS3DSH_SERIALINTERFACE_4WIRE;
00133     l1s3dsh_InitStruct.Self_Test = LIS3DSH_SELFTEST_NORMAL;
00134     l1s3dsh_InitStruct.Full_Scale = LIS3DSH_FULLSCALE_2;
00135     l1s3dsh_InitStruct.Filter_BW = LIS3DSH_FILTER_BW_800;
00136
00137     /* Configure MEMS: power mode(ODR) and axes enable */
00138     ctrl = (uint16_t) (l1s3dsh_InitStruct.Output_DataRate | \
00139                        l1s3dsh_InitStruct.Axes_Enable);
00140
00141     /* Configure MEMS: full scale and self test */
00142     ctrl |= (uint16_t) ((l1s3dsh_InitStruct.SPI_Wire    | \
00143                          l1s3dsh_InitStruct.Self_Test   | \
00144                          l1s3dsh_InitStruct.Full_Scale  | \
00145                          l1s3dsh_InitStruct.Filter_BW) << 8);
00146
00147     /* Configure the accelerometer main parameters */
00148     AcceleroDrv->Init(ctrl);
00149
00150     ret = ACCELERO_OK;
00151   }
00152
00153   else
00154   {
00155     ret = ACCELERO_ERROR;
00156   }
00157   return ret;
00158 }
00159
00160 /**
00161   * @brief  Read ID of Accelerometer component.
00162   * @retval ID
00163   */
00164 uint8_t BSP_ACCELERO_ReadID(void)
00165 {
00166   uint8_t id = 0x00;
00167
00168   if(AcceleroDrv->ReadID != NULL)
00169   {
00170     id = AcceleroDrv->ReadID();
00171   }
00172   return id;
00173 }
00174
00175 /**
00176   * @brief  Reboot memory content of Accelerometer.
00177   */
00178 void BSP_ACCELERO_Reset(void)
00179 {
00180   if(AcceleroDrv->Reset != NULL)
00181   {
00182     AcceleroDrv->Reset();
00183   }
00184 }
00185
00186 /**
00187   * @brief  Configure Accelerometer click IT.
00188   */
00189 void BSP_ACCELERO_Click_ITConfig(void)
00190 {
00191   if(AcceleroDrv->ConfigIT != NULL)
00192   {
00193     AcceleroDrv->ConfigIT();
00194   }
00195 }
00196
00197 /**
00198   * @brief  Clear Accelerometer click IT.
00199   */
00200 void BSP_ACCELERO_Click_ITClear(void)
00201 {
00202   if(AcceleroDrv->ClearIT != NULL)
00203   {
00204     AcceleroDrv->ClearIT();
00205   }
00206 }
00207
00208 /**
00209   * @brief  Get XYZ axes acceleration.
00210   * @param  pDataXYZ: Pointer to 3 angular acceleration axes.
00211   *                   pDataXYZ[0] = X axis, pDataXYZ[1] = Y axis, pDataXYZ[2] = Z axis
00212   */
00213 void BSP_ACCELERO_GetXYZ(int16_t *pDataXYZ)
00214 {
00215   int16_t SwitchXY = 0;
00216
00217   if(AcceleroDrv->GetXYZ != NULL)
00218   {
00219     AcceleroDrv->GetXYZ(pDataXYZ);
00220
00221     /* Switch X and Y Axes in case of LIS302DL MEMS */
00222     if(AcceleroDrv == &Lis302dlDrv)
00223     {
00224       SwitchXY  = pDataXYZ[0];
00225       pDataXYZ[0] = pDataXYZ[1];
00226       /* Invert Y Axis to be compliant with LIS3DSH MEMS */
00227       pDataXYZ[1] = -SwitchXY;
00228     }
00229   }
00230 }
00231
00232 /**
00233   * @}
00234   */
00235
00236 /**
00237   * @}
00238   */
00239
00240 /**
00241   * @}
00242   */
00243
00244 /**
00245   * @}
00246   */


./STM32F4-Discovery BSP User Manual: stm32f4_discovery_accelerometer.h Source File

  • File List
  • Globals
  • Firmware
  • Drivers
  • BSP
  • STM32F4-Discovery
stm32f4_discovery_accelerometer.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4_discovery_accelerometer.h
00004   * @author  MCD Application Team
00005   * @brief   This file contains all the functions prototypes for the
00006   *          stm32f4_discovery_accelerometer.c firmware driver.
00007   ******************************************************************************
00008   * @attention
00009   *
00010   * Copyright (c) 2017 STMicroelectronics.
00011   * All rights reserved.
00012   *
00013   * This software is licensed under terms that can be found in the LICENSE file
00014   * in the root directory of this software component.
00015   * If no LICENSE file comes with this software, it is provided AS-IS.
00016   *
00017   ******************************************************************************
00018   */
00019
00020 /* Define to prevent recursive inclusion -------------------------------------*/
00021 #ifndef __STM32F4_DISCOVERY_ACCELEROMETER_H
00022 #define __STM32F4_DISCOVERY_ACCELEROMETER_H
00023
00024 #ifdef __cplusplus
00025  extern "C" {
00026 #endif
00027
00028 /* Includes ------------------------------------------------------------------*/
00029 #include "stm32f4_discovery.h"
00030
00031 /* Include Accelerometer component drivers */
00032 #include "../Components/lis302dl/lis302dl.h"
00033 #include "../Components/lis3dsh/lis3dsh.h"
00034
00035 /** @addtogroup BSP
00036   * @{
00037   */
00038
00039 /** @addtogroup STM32F4_DISCOVERY
00040   * @{
00041   */
00042
00043 /** @addtogroup STM32F4_DISCOVERY_ACCELEROMETER
00044   * @{
00045   */
00046
00047 /** @defgroup STM32F4_DISCOVERY_ACCELEROMETER_Exported_Types STM32F4 DISCOVERY ACCELEROMETER Exported Types
00048   * @{
00049   */
00050 typedef enum
00051 {
00052   ACCELERO_OK = 0,
00053   ACCELERO_ERROR = 1,
00054   ACCELERO_TIMEOUT = 2
00055 }ACCELERO_StatusTypeDef;
00056 /**
00057   * @}
00058   */
00059
00060 /** @defgroup STM32F4_DISCOVERY_ACCELEROMETER_Exported_Functions STM32F4 DISCOVERY ACCELEROMETER Exported Functions
00061   * @{
00062   */
00063 /* Accelerometer functions */
00064 uint8_t BSP_ACCELERO_Init(void);
00065 uint8_t BSP_ACCELERO_ReadID(void);
00066 void    BSP_ACCELERO_Reset(void);
00067 void    BSP_ACCELERO_Click_ITConfig(void);
00068 void    BSP_ACCELERO_Click_ITClear(void);
00069 void    BSP_ACCELERO_GetXYZ(int16_t *pDataXYZ);
00070
00071 /**
00072   * @}
00073   */
00074
00075 /**
00076   * @}
00077   */
00078
00079 /**
00080   * @}
00081   */
00082
00083 /**
00084   * @}
00085   */
00086
00087 #ifdef __cplusplus
00088 }
00089 #endif
00090
00091 #endif /* __STM32F4_DISCOVERY_ACCELEROMETER_H */


./STM32F4-Discovery BSP User Manual: stm32f4_discovery_audio.c Source File

  • File List
  • Globals
  • Firmware
  • Drivers
  • BSP
  • STM32F4-Discovery
stm32f4_discovery_audio.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4_discovery_audio.c
00004   * @author  MCD Application Team
00005   * @brief   This file provides the Audio driver for the STM32F4-Discovery
00006   *          board.
00007   ******************************************************************************
00008   * @attention
00009   *
00010   * Copyright (c) 2017 STMicroelectronics.
00011   * All rights reserved.
00012   *
00013   * This software is licensed under terms that can be found in the LICENSE file
00014   * in the root directory of this software component.
00015   * If no LICENSE file comes with this software, it is provided AS-IS.
00016   *
00017   ******************************************************************************
00018   */
00019
00020 /*==============================================================================
00021                                              User NOTES
00022 1. How To use this driver:
00023 --------------------------
00024    - This driver supports STM32F4xx devices on STM32F4-Discovery Kit:
00025         a) to play an audio file (all functions names start by BSP_AUDIO_OUT_xxx)
00026         b) to record an audio file through MP45DT02, ST MEMS (all functions names start by AUDIO_IN_xxx)
00027
00028 a) PLAY A FILE:
00029 ==============
00030    + Call the function BSP_AUDIO_OUT_Init(
00031                                     OutputDevice: physical output mode (OUTPUT_DEVICE_SPEAKER,
00032                                                  OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_AUTO or
00033                                                  OUTPUT_DEVICE_BOTH)
00034                                     Volume: initial volume to be set (0 is min (mute), 100 is max (100%)
00035                                     AudioFreq: Audio frequency in Hz (8000, 16000, 22500, 32000 ...)
00036                                     this parameter is relative to the audio file/stream type.
00037                                    )
00038       This function configures all the hardware required for the audio application (codec, I2C, I2S,
00039       GPIOs, DMA and interrupt if needed). This function returns 0 if configuration is OK.
00040       If the returned value is different from 0 or the function is stuck then the communication with
00041       the codec (try to un-plug the power or reset device in this case).
00042       - OUTPUT_DEVICE_SPEAKER: only speaker will be set as output for the audio stream.
00043       - OUTPUT_DEVICE_HEADPHONE: only headphones will be set as output for the audio stream.
00044       - OUTPUT_DEVICE_AUTO: Selection of output device is made through external switch (implemented
00045          into the audio jack on the discovery board). When the Headphone is connected it is used
00046          as output. When the headphone is disconnected from the audio jack, the output is
00047          automatically switched to Speaker.
00048       - OUTPUT_DEVICE_BOTH: both Speaker and Headphone are used as outputs for the audio stream
00049          at the same time.
00050    + Call the function BSP_AUDIO_OUT_Play(
00051                                   pBuffer: pointer to the audio data file address
00052                                   Size: size of the buffer to be sent in Bytes
00053                                  )
00054       to start playing (for the first time) from the audio file/stream.
00055    + Call the function BSP_AUDIO_OUT_Pause() to pause playing
00056    + Call the function BSP_AUDIO_OUT_Resume() to resume playing.
00057        Note. After calling BSP_AUDIO_OUT_Pause() function for pause, only BSP_AUDIO_OUT_Resume() should be called
00058           for resume (it is not allowed to call BSP_AUDIO_OUT_Play() in this case).
00059        Note. This function should be called only when the audio file is played or paused (not stopped).
00060    + For each mode, you may need to implement the relative callback functions into your code.
00061       The Callback functions are named BSP_AUDIO_OUT_XXXCallBack() and only their prototypes are declared in
00062       the stm32f4_discovery_audio.h file. (refer to the example for more details on the callbacks implementations)
00063    + To Stop playing, to modify the volume level, the frequency or to mute, use the functions
00064        BSP_AUDIO_OUT_Stop(), BSP_AUDIO_OUT_SetVolume(), AUDIO_OUT_SetFrequency() BSP_AUDIO_OUT_SetOutputMode and BSP_AUDIO_OUT_SetMute().
00065    + The driver API and the callback functions are at the end of the stm32f4_discovery_audio.h file.
00066
00067 Driver architecture:
00068 --------------------
00069    + This driver provide the High Audio Layer: consists of the function API exported in the stm32f4_discovery_audio.h file
00070        (BSP_AUDIO_OUT_Init(), BSP_AUDIO_OUT_Play() ...)
00071    + This driver provide also the Media Access Layer (MAL): which consists of functions allowing to access the media containing/
00072        providing the audio file/stream. These functions are also included as local functions into
00073        the stm32f4_discovery_audio.c file (I2S3_Init()...)
00074
00075 Known Limitations:
00076 -------------------
00077    1- When using the Speaker, if the audio file quality is not high enough, the speaker output
00078       may produce high and uncomfortable noise level. To avoid this issue, to use speaker
00079       output properly, try to increase audio file sampling rate (typically higher than 48KHz).
00080       This operation will lead to larger file size.
00081    2- Communication with the audio codec (through I2C) may be corrupted if it is interrupted by some
00082       user interrupt routines (in this case, interrupts could be disabled just before the start of
00083       communication then re-enabled when it is over). Note that this communication is only done at
00084       the configuration phase (BSP_AUDIO_OUT_Init() or BSP_AUDIO_OUT_Stop()) and when Volume control modification is
00085       performed (BSP_AUDIO_OUT_SetVolume() or BSP_AUDIO_OUT_SetMute()or BSP_AUDIO_OUT_SetOutputMode()).
00086       When the audio data is played, no communication is required with the audio codec.
00087    3- Parsing of audio file is not implemented (in order to determine audio file properties: Mono/Stereo, Data size,
00088       File size, Audio Frequency, Audio Data header size ...). The configuration is fixed for the given audio file.
00089    4- Supports only Stereo audio streaming. To play mono audio streams, each data should be sent twice
00090       on the I2S or should be duplicated on the source buffer. Or convert the stream in stereo before playing.
00091    5- Supports only 16-bits audio data size.
00092
00093 b) RECORD A FILE:
00094 ================
00095    + Call the function BSP_AUDIO_IN_Init(
00096                                     AudioFreq: Audio frequency in Hz (8000, 16000, 22500, 32000 ...)
00097                                     )
00098       This function configures all the hardware required for the audio application (I2S,
00099       GPIOs, DMA and interrupt if needed). This function returns 0 if configuration is OK.
00100
00101    + Call the function BSP_AUDIO_IN_Record(
00102                             pbuf Main buffer pointer for the recorded data storing
00103                             size Current size of the recorded buffer
00104                             )
00105       to start recording from the microphone.
00106
00107    + User needs to implement user callbacks to retrieve data saved in the record buffer
00108       (AUDIO_IN_RxHalfCpltCallback/BSP_AUDIO_IN_ReceiveComplete_CallBack)
00109
00110    + Call the function AUDIO_IN_STOP() to stop recording
00111
00112 ==============================================================================*/
00113
00114 /* Includes ------------------------------------------------------------------*/
00115 #include "stm32f4_discovery_audio.h"
00116
00117 /** @addtogroup BSP
00118   * @{
00119   */
00120
00121 /** @addtogroup STM32F4_DISCOVERY
00122   * @{
00123   */
00124
00125 /** @defgroup STM32F4_DISCOVERY_AUDIO STM32F4 DISCOVERY AUDIO
00126   * @brief This file includes the low layer audio driver available on STM32F4-Discovery
00127   *        discovery board.
00128   * @{
00129   */
00130
00131 /** @defgroup STM32F4_DISCOVERY_AUDIO_Private_Types STM32F4 DISCOVERY AUDIO Private Types
00132   * @{
00133   */
00134 /**
00135   * @}
00136   */
00137
00138 /** @defgroup STM32F4_DISCOVERY_AUDIO_Private_Defines STM32F4 DISCOVERY AUDIO Private Defines
00139   * @{
00140   */
00141 /* These PLL parameters are valid when the f(VCO clock) = 1Mhz */
00142 const uint32_t I2SFreq[8] = {8000, 11025, 16000, 22050, 32000, 44100, 48000, 96000};
00143 const uint32_t I2SPLLN[8] = {256, 429, 213, 429, 426, 271, 258, 344};
00144 const uint32_t I2SPLLR[8] = {5, 4, 4, 4, 4, 6, 3, 1};
00145 /**
00146   * @}
00147   */
00148
00149 /** @defgroup STM32F4_DISCOVERY_AUDIO_Private_Macros STM32F4 DISCOVERY AUDIO Private Macros
00150   * @{
00151   */
00152 /**
00153   * @}
00154   */
00155
00156 /** @defgroup STM32F4_DISCOVERY_AUDIO_Private_Variables STM32F4 DISCOVERY AUDIO Private Variables
00157   * @{
00158   */
00159 /*##### PLAY #####*/
00160 static AUDIO_DrvTypeDef           *pAudioDrv;
00161 I2S_HandleTypeDef                 hAudioOutI2s;
00162
00163 /*### RECORDER ###*/
00164 I2S_HandleTypeDef                 hAudioInI2s;
00165
00166 /* PDM filters params */
00167 PDM_Filter_Handler_t  PDM_FilterHandler[2];
00168 PDM_Filter_Config_t   PDM_FilterConfig[2];
00169
00170 __IO uint16_t AudioInVolume = DEFAULT_AUDIO_IN_VOLUME;
00171 /**
00172   * @}
00173   */
00174
00175 /** @defgroup STM32F4_DISCOVERY_AUDIO_Private_Function_Prototypes STM32F4 DISCOVERY AUDIO Private Function Prototypes
00176   * @{
00177   */
00178 static uint8_t I2S3_Init(uint32_t AudioFreq);
00179 static uint8_t I2S2_Init(uint32_t AudioFreq);
00180 static void PDMDecoder_Init(uint32_t AudioFreq, uint32_t ChnlNbrIn, uint32_t ChnlNbrOut);
00181 /**
00182   * @}
00183   */
00184
00185 /** @defgroup STM32F4_DISCOVERY_AUDIO_OUT_Private_Functions STM32F4 DISCOVERY AUDIO OUT Private Functions
00186   * @{
00187   */
00188
00189 /**
00190   * @brief  Configures the audio peripherals.
00191   * @param  OutputDevice: OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE,
00192   *                       OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO .
00193   * @param  Volume: Initial volume level (from 0 (Mute) to 100 (Max))
00194   * @param  AudioFreq: Audio frequency used to play the audio stream.
00195   * @retval AUDIO_OK if correct communication, else wrong communication
00196   */
00197 uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)
00198 {
00199   uint8_t ret = AUDIO_OK;
00200
00201   /* PLL clock is set depending by the AudioFreq (44.1khz vs 48khz groups) */
00202   BSP_AUDIO_OUT_ClockConfig(&hAudioOutI2s, AudioFreq, NULL);
00203
00204   /* I2S data transfer preparation:
00205   Prepare the Media to be used for the audio transfer from memory to I2S peripheral */
00206   hAudioOutI2s.Instance = I2S3;
00207   if(HAL_I2S_GetState(&hAudioOutI2s) == HAL_I2S_STATE_RESET)
00208   {
00209     /* Init the I2S MSP: this __weak function can be redefined by the application*/
00210     BSP_AUDIO_OUT_MspInit(&hAudioOutI2s, NULL);
00211   }
00212
00213   /* I2S data transfer preparation:
00214   Prepare the Media to be used for the audio transfer from memory to I2S peripheral */
00215   /* Configure the I2S peripheral */
00216   if(I2S3_Init(AudioFreq) != AUDIO_OK)
00217   {
00218     ret = AUDIO_ERROR;
00219   }
00220
00221   if(ret == AUDIO_OK)
00222   {
00223     /* Retieve audio codec identifier */
00224     if(((cs43l22_drv.ReadID(AUDIO_I2C_ADDRESS)) & CS43L22_ID_MASK) == CS43L22_ID)
00225     {
00226       /* Initialize the audio driver structure */
00227       pAudioDrv = &cs43l22_drv;
00228     }
00229     else
00230     {
00231       ret = AUDIO_ERROR;
00232     }
00233   }
00234
00235   if(ret == AUDIO_OK)
00236   {
00237     pAudioDrv->Init(AUDIO_I2C_ADDRESS, OutputDevice, Volume, AudioFreq);
00238   }
00239
00240   return ret;
00241 }
00242
00243 /**
00244   * @brief  Starts playing audio stream from a data buffer for a determined size.
00245   * @param  pBuffer: Pointer to the buffer
00246   * @param  Size: Number of audio data BYTES.
00247   * @retval AUDIO_OK if correct communication, else wrong communication
00248   */
00249 uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size)
00250 {
00251   /* Call the audio Codec Play function */
00252   if(pAudioDrv->Play(AUDIO_I2C_ADDRESS, pBuffer, Size) != 0)
00253   {
00254     return AUDIO_ERROR;
00255   }
00256   else
00257   {
00258     /* Update the Media layer and enable it for play */
00259     HAL_I2S_Transmit_DMA(&hAudioOutI2s, pBuffer, DMA_MAX(Size/AUDIODATA_SIZE));
00260
00261     /* Return AUDIO_OK when all operations are correctly done */
00262     return AUDIO_OK;
00263   }
00264 }
00265
00266 /**
00267   * @brief  Sends n-Bytes on the I2S interface.
00268   * @param  pData: Pointer to data address
00269   * @param  Size: Number of data to be written
00270   */
00271 void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size)
00272 {
00273   HAL_I2S_Transmit_DMA(&hAudioOutI2s, pData, Size);
00274 }
00275
00276 /**
00277   * @brief   Pauses the audio file stream. In case of using DMA, the DMA Pause
00278   *          feature is used.
00279   * WARNING: When calling BSP_AUDIO_OUT_Pause() function for pause, only the
00280   *          BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play()
00281   *          function for resume could lead to unexpected behavior).
00282   * @retval  AUDIO_OK if correct communication, else wrong communication
00283   */
00284 uint8_t BSP_AUDIO_OUT_Pause(void)
00285 {
00286   /* Call the Audio Codec Pause/Resume function */
00287   if(pAudioDrv->Pause(AUDIO_I2C_ADDRESS) != 0)
00288   {
00289     return AUDIO_ERROR;
00290   }
00291   else
00292   {
00293     /* Call the Media layer pause function */
00294     HAL_I2S_DMAPause(&hAudioOutI2s);
00295
00296     /* Return AUDIO_OK when all operations are correctly done */
00297     return AUDIO_OK;
00298   }
00299 }
00300
00301 /**
00302   * @brief   Resumes the audio file streaming.
00303   * WARNING: When calling BSP_AUDIO_OUT_Pause() function for pause, only
00304   *          BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play()
00305   *          function for resume could lead to unexpected behavior).
00306   * @retval  AUDIO_OK if correct communication, else wrong communication
00307   */
00308 uint8_t BSP_AUDIO_OUT_Resume(void)
00309 {
00310   /* Call the Audio Codec Pause/Resume function */
00311   if(pAudioDrv->Resume(AUDIO_I2C_ADDRESS) != 0)
00312   {
00313     return AUDIO_ERROR;
00314   }
00315   else
00316   {
00317     /* Call the Media layer resume function */
00318     HAL_I2S_DMAResume(&hAudioOutI2s);
00319
00320     /* Return AUDIO_OK when all operations are correctly done */
00321     return AUDIO_OK;
00322   }
00323 }
00324
00325 /**
00326   * @brief  Stops audio playing and Power down the Audio Codec.
00327   * @param  Option: could be one of the following parameters
00328   *           - CODEC_PDWN_HW: completely shut down the codec (physically).
00329   *                            Then need to reconfigure the Codec after power on.
00330   * @retval AUDIO_OK if correct communication, else wrong communication
00331   */
00332 uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option)
00333 {
00334   /* Call DMA Stop to disable DMA stream before stopping codec */
00335   HAL_I2S_DMAStop(&hAudioOutI2s);
00336
00337   /* Call Audio Codec Stop function */
00338   if(pAudioDrv->Stop(AUDIO_I2C_ADDRESS, Option) != 0)
00339   {
00340     return AUDIO_ERROR;
00341   }
00342   else
00343   {
00344     if(Option == CODEC_PDWN_HW)
00345     {
00346       /* Wait at least 1ms */
00347       HAL_Delay(1);
00348
00349       /* Reset the pin */
00350       HAL_GPIO_WritePin(AUDIO_RESET_GPIO, AUDIO_RESET_PIN, GPIO_PIN_RESET);
00351     }
00352
00353     /* Return AUDIO_OK when all operations are correctly done */
00354     return AUDIO_OK;
00355   }
00356 }
00357
00358 /**
00359   * @brief  Controls the current audio volume level.
00360   * @param  Volume: Volume level to be set in percentage from 0% to 100% (0 for
00361   *         Mute and 100 for Max volume level).
00362   * @retval AUDIO_OK if correct communication, else wrong communication
00363   */
00364 uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume)
00365 {
00366   /* Call the codec volume control function with converted volume value */
00367   if(pAudioDrv->SetVolume(AUDIO_I2C_ADDRESS, Volume) != 0)
00368   {
00369     return AUDIO_ERROR;
00370   }
00371   else
00372   {
00373     /* Return AUDIO_OK when all operations are correctly done */
00374     return AUDIO_OK;
00375   }
00376 }
00377
00378 /**
00379   * @brief  Enables or disables the MUTE mode by software
00380   * @param  Cmd: could be AUDIO_MUTE_ON to mute sound or AUDIO_MUTE_OFF to
00381   *         unmute the codec and restore previous volume level.
00382   * @retval AUDIO_OK if correct communication, else wrong communication
00383   */
00384 uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd)
00385 {
00386   /* Call the Codec Mute function */
00387   if(pAudioDrv->SetMute(AUDIO_I2C_ADDRESS, Cmd) != 0)
00388   {
00389     return AUDIO_ERROR;
00390   }
00391   else
00392   {
00393     /* Return AUDIO_OK when all operations are correctly done */
00394     return AUDIO_OK;
00395   }
00396 }
00397
00398 /**
00399   * @brief  Switch dynamically (while audio file is played) the output target
00400   *         (speaker or headphone).
00401   * @note   This function modifies a global variable of the audio codec driver: OutputDev.
00402   * @param  Output: specifies the audio output target: OUTPUT_DEVICE_SPEAKER,
00403   *         OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO
00404   * @retval AUDIO_OK if correct communication, else wrong communication
00405   */
00406 uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output)
00407 {
00408   /* Call the Codec output Device function */
00409   if(pAudioDrv->SetOutputMode(AUDIO_I2C_ADDRESS, Output) != 0)
00410   {
00411     return AUDIO_ERROR;
00412   }
00413   else
00414   {
00415     /* Return AUDIO_OK when all operations are correctly done */
00416     return AUDIO_OK;
00417   }
00418 }
00419
00420 /**
00421   * @brief  Update the audio frequency.
00422   * @param  AudioFreq: Audio frequency used to play the audio stream.
00423   * @note   This API should be called after the BSP_AUDIO_OUT_Init() to adjust the
00424   *         audio frequency.
00425   */
00426 void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq)
00427 {
00428   /* PLL clock is set depending by the AudioFreq (44.1khz vs 48khz groups) */
00429   BSP_AUDIO_OUT_ClockConfig(&hAudioOutI2s, AudioFreq, NULL);
00430
00431   /* Update the I2S audio frequency configuration */
00432   I2S3_Init(AudioFreq);
00433 }
00434
00435 /**
00436   * @brief  Tx Transfer completed callbacks.
00437   * @param  hi2s: I2S handle
00438   */
00439 void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s)
00440 {
00441   if(hi2s->Instance == I2S3)
00442   {
00443     /* Call the user function which will manage directly transfer complete */
00444     BSP_AUDIO_OUT_TransferComplete_CallBack();
00445   }
00446 }
00447
00448 /**
00449   * @brief  Tx Half Transfer completed callbacks.
00450   * @param  hi2s: I2S handle
00451   */
00452 void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s)
00453 {
00454   if(hi2s->Instance == I2S3)
00455   {
00456     /* Manage the remaining file size and new address offset: This function should
00457        be coded by user (its prototype is already declared in stm32f4_discovery_audio.h) */
00458     BSP_AUDIO_OUT_HalfTransfer_CallBack();
00459   }
00460 }
00461
00462 /**
00463   * @brief  Clock Config.
00464   * @param  hi2s: might be required to set audio peripheral predivider if any.
00465   * @param  AudioFreq: Audio frequency used to play the audio stream.
00466   * @note   This API is called by BSP_AUDIO_OUT_Init() and BSP_AUDIO_OUT_SetFrequency()
00467   *         Being __weak it can be overwritten by the application
00468   * @param  Params : pointer on additional configuration parameters, can be NULL.
00469   */
00470 __weak void BSP_AUDIO_OUT_ClockConfig(I2S_HandleTypeDef *hi2s, uint32_t AudioFreq, void *Params)
00471 {
00472   RCC_PeriphCLKInitTypeDef rccclkinit;
00473   uint8_t index = 0, freqindex = 0xFF;
00474
00475   for(index = 0; index < 8; index++)
00476   {
00477     if(I2SFreq[index] == AudioFreq)
00478     {
00479       freqindex = index;
00480     }
00481   }
00482   /* Enable PLLI2S clock */
00483   HAL_RCCEx_GetPeriphCLKConfig(&rccclkinit);
00484   /* PLLI2S_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
00485   if ((freqindex & 0x7) == 0)
00486   {
00487     /* I2S clock config
00488     PLLI2S_VCO = f(VCO clock) = f(PLLI2S clock input) × (PLLI2SN/PLLM)
00489     I2SCLK = f(PLLI2S clock output) = f(VCO clock) / PLLI2SR */
00490     rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S;
00491     rccclkinit.PLLI2S.PLLI2SN = I2SPLLN[freqindex];
00492     rccclkinit.PLLI2S.PLLI2SR = I2SPLLR[freqindex];
00493     HAL_RCCEx_PeriphCLKConfig(&rccclkinit);
00494   }
00495   else
00496   {
00497     /* I2S clock config
00498     PLLI2S_VCO = f(VCO clock) = f(PLLI2S clock input) × (PLLI2SN/PLLM)
00499     I2SCLK = f(PLLI2S clock output) = f(VCO clock) / PLLI2SR */
00500     rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S;
00501     rccclkinit.PLLI2S.PLLI2SN = 258;
00502     rccclkinit.PLLI2S.PLLI2SR = 3;
00503     HAL_RCCEx_PeriphCLKConfig(&rccclkinit);
00504   }
00505 }
00506
00507 /**
00508   * @brief  AUDIO OUT I2S MSP Init.
00509   * @param  hi2s: might be required to set audio peripheral predivider if any.
00510   * @param  Params : pointer on additional configuration parameters, can be NULL.
00511   */
00512 __weak void BSP_AUDIO_OUT_MspInit(I2S_HandleTypeDef *hi2s, void *Params)
00513 {
00514   static DMA_HandleTypeDef hdma_i2sTx;
00515   GPIO_InitTypeDef  GPIO_InitStruct;
00516
00517   /* Enable I2S3 clock */
00518   I2S3_CLK_ENABLE();
00519
00520   /*** Configure the GPIOs ***/
00521   /* Enable I2S GPIO clocks */
00522   I2S3_SCK_SD_CLK_ENABLE();
00523   I2S3_WS_CLK_ENABLE();
00524
00525   /* I2S3 pins configuration: WS, SCK and SD pins ----------------------------*/
00526   GPIO_InitStruct.Pin         = I2S3_SCK_PIN | I2S3_SD_PIN;
00527   GPIO_InitStruct.Mode        = GPIO_MODE_AF_PP;
00528   GPIO_InitStruct.Pull        = GPIO_NOPULL;
00529   GPIO_InitStruct.Speed       = GPIO_SPEED_FAST;
00530   GPIO_InitStruct.Alternate   = I2S3_SCK_SD_WS_AF;
00531   HAL_GPIO_Init(I2S3_SCK_SD_GPIO_PORT, &GPIO_InitStruct);
00532
00533   GPIO_InitStruct.Pin         = I2S3_WS_PIN ;
00534   HAL_GPIO_Init(I2S3_WS_GPIO_PORT, &GPIO_InitStruct);
00535
00536   /* I2S3 pins configuration: MCK pin */
00537   I2S3_MCK_CLK_ENABLE();
00538   GPIO_InitStruct.Pin         = I2S3_MCK_PIN;
00539   HAL_GPIO_Init(I2S3_MCK_GPIO_PORT, &GPIO_InitStruct);
00540
00541   /* Enable the I2S DMA clock */
00542   I2S3_DMAx_CLK_ENABLE();
00543
00544   if(hi2s->Instance == I2S3)
00545   {
00546     /* Configure the hdma_i2sTx handle parameters */
00547     hdma_i2sTx.Init.Channel             = I2S3_DMAx_CHANNEL;
00548     hdma_i2sTx.Init.Direction           = DMA_MEMORY_TO_PERIPH;
00549     hdma_i2sTx.Init.PeriphInc           = DMA_PINC_DISABLE;
00550     hdma_i2sTx.Init.MemInc              = DMA_MINC_ENABLE;
00551     hdma_i2sTx.Init.PeriphDataAlignment = I2S3_DMAx_PERIPH_DATA_SIZE;
00552     hdma_i2sTx.Init.MemDataAlignment    = I2S3_DMAx_MEM_DATA_SIZE;
00553     hdma_i2sTx.Init.Mode                = DMA_NORMAL;
00554     hdma_i2sTx.Init.Priority            = DMA_PRIORITY_HIGH;
00555     hdma_i2sTx.Init.FIFOMode            = DMA_FIFOMODE_ENABLE;
00556     hdma_i2sTx.Init.FIFOThreshold       = DMA_FIFO_THRESHOLD_FULL;
00557     hdma_i2sTx.Init.MemBurst            = DMA_MBURST_SINGLE;
00558     hdma_i2sTx.Init.PeriphBurst         = DMA_PBURST_SINGLE;
00559
00560     hdma_i2sTx.Instance                 = I2S3_DMAx_STREAM;
00561
00562     /* Associate the DMA handle */
00563     __HAL_LINKDMA(hi2s, hdmatx, hdma_i2sTx);
00564
00565     /* Deinitialize the Stream for new transfer */
00566     HAL_DMA_DeInit(&hdma_i2sTx);
00567
00568     /* Configure the DMA Stream */
00569     HAL_DMA_Init(&hdma_i2sTx);
00570   }
00571
00572   /* I2S DMA IRQ Channel configuration */
00573   HAL_NVIC_SetPriority(I2S3_DMAx_IRQ, AUDIO_OUT_IRQ_PREPRIO, 0);
00574   HAL_NVIC_EnableIRQ(I2S3_DMAx_IRQ);
00575 }
00576
00577 /**
00578   * @brief  De-Initializes BSP_AUDIO_OUT MSP.
00579   * @param  hi2s: might be required to set audio peripheral predivider if any.
00580   * @param  Params : pointer on additional configuration parameters, can be NULL.
00581   */
00582 __weak void BSP_AUDIO_OUT_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params)
00583 {
00584   GPIO_InitTypeDef  GPIO_InitStruct;
00585
00586   /* I2S DMA IRQ Channel deactivation */
00587   HAL_NVIC_DisableIRQ(I2S3_DMAx_IRQ);
00588
00589   if(hi2s->Instance == I2S3)
00590   {
00591     /* Deinitialize the Stream for new transfer */
00592     HAL_DMA_DeInit(hi2s->hdmatx);
00593   }
00594
00595  /* Disable I2S block */
00596   __HAL_I2S_DISABLE(hi2s);
00597
00598   /* CODEC_I2S pins configuration: SCK and SD pins */
00599   GPIO_InitStruct.Pin = I2S3_SCK_PIN | I2S3_SD_PIN;
00600   HAL_GPIO_DeInit(I2S3_SCK_SD_GPIO_PORT, GPIO_InitStruct.Pin);
00601
00602   /* CODEC_I2S pins configuration: WS pin */
00603   GPIO_InitStruct.Pin = I2S3_WS_PIN;
00604   HAL_GPIO_DeInit(I2S3_WS_GPIO_PORT, GPIO_InitStruct.Pin);
00605
00606   /* CODEC_I2S pins configuration: MCK pin */
00607   GPIO_InitStruct.Pin = I2S3_MCK_PIN;
00608   HAL_GPIO_DeInit(I2S3_MCK_GPIO_PORT, GPIO_InitStruct.Pin);
00609
00610   /* Disable I2S clock */
00611   I2S3_CLK_DISABLE();
00612
00613   /* GPIO pins clock and DMA clock can be shut down in the applic
00614      by surcgarging this __weak function */
00615 }
00616
00617 /**
00618   * @brief  Manages the DMA full Transfer complete event.
00619   */
00620 __weak void BSP_AUDIO_OUT_TransferComplete_CallBack(void)
00621 {
00622 }
00623
00624 /**
00625   * @brief  Manages the DMA Half Transfer complete event.
00626   */
00627 __weak void BSP_AUDIO_OUT_HalfTransfer_CallBack(void)
00628 {
00629 }
00630
00631 /**
00632   * @brief  Manages the DMA FIFO error event.
00633   */
00634 __weak void BSP_AUDIO_OUT_Error_CallBack(void)
00635 {
00636 }
00637
00638 /*******************************************************************************
00639                             Static Functions
00640 *******************************************************************************/
00641
00642 /**
00643   * @brief  Initializes the Audio Codec audio interface (I2S).
00644   * @param  AudioFreq: Audio frequency to be configured for the I2S peripheral.
00645   */
00646 static uint8_t I2S3_Init(uint32_t AudioFreq)
00647 {
00648   /* Initialize the hAudioOutI2s Instance parameter */
00649   hAudioOutI2s.Instance         = I2S3;
00650
00651  /* Disable I2S block */
00652   __HAL_I2S_DISABLE(&hAudioOutI2s);
00653
00654   /* I2S3 peripheral configuration */
00655   hAudioOutI2s.Init.AudioFreq   = AudioFreq;
00656   hAudioOutI2s.Init.ClockSource = I2S_CLOCK_PLL;
00657   hAudioOutI2s.Init.CPOL        = I2S_CPOL_LOW;
00658   hAudioOutI2s.Init.DataFormat  = I2S_DATAFORMAT_16B;
00659   hAudioOutI2s.Init.MCLKOutput  = I2S_MCLKOUTPUT_ENABLE;
00660   hAudioOutI2s.Init.Mode        = I2S_MODE_MASTER_TX;
00661   hAudioOutI2s.Init.Standard    = I2S_STANDARD;
00662   /* Initialize the I2S peripheral with the structure above */
00663   if(HAL_I2S_Init(&hAudioOutI2s) != HAL_OK)
00664   {
00665     return AUDIO_ERROR;
00666   }
00667   else
00668   {
00669     return AUDIO_OK;
00670   }
00671 }
00672
00673 /**
00674   * @}
00675   */
00676
00677 /** @defgroup STM32F4_DISCOVERY_AUDIO_IN_Private_Functions STM32F4 DISCOVERY AUDIO IN Private Functions
00678   * @{
00679   */
00680
00681 /**
00682   * @brief  Initializes wave recording.
00683   * @param  AudioFreq: Audio frequency to be configured for the I2S peripheral.
00684   * @param  BitRes: Audio frequency to be configured for the I2S peripheral.
00685   * @param  ChnlNbr: Audio frequency to be configured for the I2S peripheral.
00686   * @retval AUDIO_OK if correct communication, else wrong communication
00687   */
00688 uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr)
00689 {
00690
00691   /* Configure PLL clock */
00692   BSP_AUDIO_IN_ClockConfig(&hAudioInI2s, AudioFreq, NULL);
00693
00694   /* Configure the PDM library */
00695   /* On STM32F4-Discovery a single microphone is mounted, samples are duplicated
00696      to make stereo audio streams */
00697   PDMDecoder_Init(AudioFreq, ChnlNbr, 2);
00698
00699   /* Configure the I2S peripheral */
00700   hAudioInI2s.Instance = I2S2;
00701   if(HAL_I2S_GetState(&hAudioInI2s) == HAL_I2S_STATE_RESET)
00702   {
00703     /* Initialize the I2S Msp: this __weak function can be rewritten by the application */
00704     BSP_AUDIO_IN_MspInit(&hAudioInI2s, NULL);
00705   }
00706
00707   /* Configure the I2S2 */
00708   I2S2_Init(AudioFreq);
00709
00710   /* Return AUDIO_OK when all operations are correctly done */
00711   return AUDIO_OK;
00712 }
00713
00714 /**
00715   * @brief  Starts audio recording.
00716   * @param  pbuf: Main buffer pointer for the recorded data storing
00717   * @param  size: Current size of the recorded buffer
00718   * @retval AUDIO_OK if correct communication, else wrong communication
00719   */
00720 uint8_t BSP_AUDIO_IN_Record(uint16_t* pbuf, uint32_t size)
00721 {
00722   uint32_t ret = AUDIO_ERROR;
00723
00724   /* Start the process receive DMA */
00725   HAL_I2S_Receive_DMA(&hAudioInI2s, pbuf, size);
00726
00727   /* Return AUDIO_OK when all operations are correctly done */
00728   ret = AUDIO_OK;
00729
00730   return ret;
00731 }
00732
00733 /**
00734   * @brief  Stops audio recording.
00735   * @retval AUDIO_OK if correct communication, else wrong communication
00736   */
00737 uint8_t BSP_AUDIO_IN_Stop(void)
00738 {
00739   uint32_t ret = AUDIO_ERROR;
00740
00741   /* Call the Media layer pause function */
00742   HAL_I2S_DMAStop(&hAudioInI2s);
00743
00744   /* Return AUDIO_OK when all operations are correctly done */
00745   ret = AUDIO_OK;
00746
00747   return ret;
00748 }
00749
00750 /**
00751   * @brief  Pauses the audio file stream.
00752   * @retval AUDIO_OK if correct communication, else wrong communication
00753   */
00754 uint8_t BSP_AUDIO_IN_Pause(void)
00755 {
00756   /* Call the Media layer pause function */
00757   HAL_I2S_DMAPause(&hAudioInI2s);
00758
00759   /* Return AUDIO_OK when all operations are correctly done */
00760   return AUDIO_OK;
00761 }
00762
00763 /**
00764   * @brief  Resumes the audio file stream.
00765   * @retval AUDIO_OK if correct communication, else wrong communication
00766   */
00767 uint8_t BSP_AUDIO_IN_Resume(void)
00768 {
00769   /* Call the Media layer pause/resume function */
00770   HAL_I2S_DMAResume(&hAudioInI2s);
00771
00772   /* Return AUDIO_OK when all operations are correctly done */
00773   return AUDIO_OK;
00774 }
00775
00776 /**
00777   * @brief  Controls the audio in volume level.
00778   * @param  Volume: Volume level to be set in percentage from 0% to 100% (0 for
00779   *         Mute and 100 for Max volume level).
00780   * @retval AUDIO_OK if correct communication, else wrong communication
00781   */
00782 uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume)
00783 {
00784   /* Set the Global variable AudioInVolume */
00785   AudioInVolume = Volume;
00786
00787   /* Return AUDIO_OK when all operations are correctly done */
00788   return AUDIO_OK;
00789 }
00790
00791 /**
00792   * @brief  Converts audio format from PDM to PCM.
00793   * @param  PDMBuf: Pointer to data PDM buffer
00794   * @param  PCMBuf: Pointer to data PCM buffer
00795   * @retval AUDIO_OK if correct communication, else wrong communication
00796   */
00797 uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t *PDMBuf, uint16_t *PCMBuf)
00798 {
00799   uint16_t AppPDM[INTERNAL_BUFF_SIZE/2];
00800   uint32_t index = 0;
00801
00802   /* PDM Demux */
00803   for(index = 0; index<INTERNAL_BUFF_SIZE/2; index++)
00804   {
00805     AppPDM[index] = HTONS(PDMBuf[index]);
00806   }
00807
00808   for(index = 0; index < DEFAULT_AUDIO_IN_CHANNEL_NBR; index++)
00809   {
00810     /* PDM to PCM filter */
00811         PDM_Filter((uint8_t*)&AppPDM[index], (uint16_t*)&(PCMBuf[index]), &PDM_FilterHandler[index]);
00812   }
00813   /* Duplicate samples since a single microphone in mounted on STM32F4-Discovery */
00814   for(index = 0; index < PCM_OUT_SIZE; index++)
00815   {
00816     PCMBuf[(index<<1)+1] = PCMBuf[index<<1];
00817   }
00818
00819   /* Return AUDIO_OK when all operations are correctly done */
00820   return AUDIO_OK;
00821 }
00822
00823 /**
00824   * @brief  Rx Transfer completed callbacks
00825   * @param  hi2s: I2S handle
00826   */
00827 void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s)
00828 {
00829   /* Call the record update function to get the next buffer to fill and its size (size is ignored) */
00830   BSP_AUDIO_IN_TransferComplete_CallBack();
00831 }
00832
00833 /**
00834   * @brief  Rx Half Transfer completed callbacks.
00835   * @param  hi2s: I2S handle
00836   */
00837 void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s)
00838 {
00839   /* Manage the remaining file size and new address offset: This function
00840      should be coded by user (its prototype is already declared in stm32f4_discovery_audio.h) */
00841   BSP_AUDIO_IN_HalfTransfer_CallBack();
00842 }
00843
00844 /**
00845   * @brief  Audio In Clock Config.
00846   * @param  hi2s: I2S handle
00847   * @param  AudioFreq: Audio frequency used to record the audio stream.
00848   * @param  Params : pointer on additional configuration parameters, can be NULL.
00849   * @note   This API is called by BSP_AUDIO_IN_Init()
00850   *         Being __weak it can be overwritten by the application
00851   */
00852 __weak void BSP_AUDIO_IN_ClockConfig(I2S_HandleTypeDef *hi2s, uint32_t AudioFreq, void *Params)
00853 {
00854   RCC_PeriphCLKInitTypeDef rccclkinit;
00855
00856   /*Enable PLLI2S clock*/
00857   HAL_RCCEx_GetPeriphCLKConfig(&rccclkinit);
00858   /* PLLI2S_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
00859   if ((AudioFreq & 0x7) == 0)
00860   {
00861     /* Audio frequency multiple of 8 (8/16/32/48/96/192)*/
00862     /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN = 192 Mhz */
00863     /* I2SCLK = PLLI2S_VCO Output/PLLI2SR = 192/6 = 32 Mhz */
00864     rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S;
00865     rccclkinit.PLLI2S.PLLI2SN = 192;
00866     rccclkinit.PLLI2S.PLLI2SR = 6;
00867     HAL_RCCEx_PeriphCLKConfig(&rccclkinit);
00868   }
00869   else
00870   {
00871     /* Other Frequency (11.025/22.500/44.100) */
00872     /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN = 290 Mhz */
00873     /* I2SCLK = PLLI2S_VCO Output/PLLI2SR = 290/2 = 145 Mhz */
00874     rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S;
00875     rccclkinit.PLLI2S.PLLI2SN = 290;
00876     rccclkinit.PLLI2S.PLLI2SR = 2;
00877     HAL_RCCEx_PeriphCLKConfig(&rccclkinit);
00878   }
00879 }
00880
00881 /**
00882   * @brief  BSP AUDIO IN MSP Init.
00883   * @param  hi2s: I2S handle
00884   * @param  Params : pointer on additional configuration parameters, can be NULL.
00885   */
00886 __weak void BSP_AUDIO_IN_MspInit(I2S_HandleTypeDef *hi2s, void *Params)
00887 {
00888   static DMA_HandleTypeDef hdma_i2sRx;
00889   GPIO_InitTypeDef  GPIO_InitStruct;
00890
00891   /* Enable the I2S2 peripheral clock */
00892   I2S2_CLK_ENABLE();
00893
00894   /* Enable I2S GPIO clocks */
00895   I2S2_SCK_GPIO_CLK_ENABLE();
00896   I2S2_MOSI_GPIO_CLK_ENABLE();
00897
00898   /* I2S2 pins configuration: SCK and MOSI pins ------------------------------*/
00899   GPIO_InitStruct.Mode      = GPIO_MODE_AF_PP;
00900   GPIO_InitStruct.Pull      = GPIO_NOPULL;
00901   GPIO_InitStruct.Speed     = GPIO_SPEED_FAST;
00902
00903   GPIO_InitStruct.Pin       = I2S2_SCK_PIN;
00904   GPIO_InitStruct.Alternate = I2S2_SCK_AF;
00905   HAL_GPIO_Init(I2S2_SCK_GPIO_PORT, &GPIO_InitStruct);
00906
00907   GPIO_InitStruct.Pin       = I2S2_MOSI_PIN ;
00908   GPIO_InitStruct.Alternate = I2S2_MOSI_AF;
00909   HAL_GPIO_Init(I2S2_MOSI_GPIO_PORT, &GPIO_InitStruct);
00910
00911   /* Enable the DMA clock */
00912   I2S2_DMAx_CLK_ENABLE();
00913
00914   if(hi2s->Instance == I2S2)
00915   {
00916     /* Configure the hdma_i2sRx handle parameters */
00917     hdma_i2sRx.Init.Channel             = I2S2_DMAx_CHANNEL;
00918     hdma_i2sRx.Init.Direction           = DMA_PERIPH_TO_MEMORY;
00919     hdma_i2sRx.Init.PeriphInc           = DMA_PINC_DISABLE;
00920     hdma_i2sRx.Init.MemInc              = DMA_MINC_ENABLE;
00921     hdma_i2sRx.Init.PeriphDataAlignment = I2S2_DMAx_PERIPH_DATA_SIZE;
00922     hdma_i2sRx.Init.MemDataAlignment    = I2S2_DMAx_MEM_DATA_SIZE;
00923     hdma_i2sRx.Init.Mode                = DMA_CIRCULAR;
00924     hdma_i2sRx.Init.Priority            = DMA_PRIORITY_HIGH;
00925     hdma_i2sRx.Init.FIFOMode            = DMA_FIFOMODE_DISABLE;
00926     hdma_i2sRx.Init.FIFOThreshold       = DMA_FIFO_THRESHOLD_FULL;
00927     hdma_i2sRx.Init.MemBurst            = DMA_MBURST_SINGLE;
00928     hdma_i2sRx.Init.PeriphBurst         = DMA_MBURST_SINGLE;
00929
00930     hdma_i2sRx.Instance = I2S2_DMAx_STREAM;
00931
00932     /* Associate the DMA handle */
00933     __HAL_LINKDMA(hi2s, hdmarx, hdma_i2sRx);
00934
00935     /* Deinitialize the Stream for new transfer */
00936     HAL_DMA_DeInit(&hdma_i2sRx);
00937
00938     /* Configure the DMA Stream */
00939     HAL_DMA_Init(&hdma_i2sRx);
00940   }
00941
00942   /* I2S DMA IRQ Channel configuration */
00943   HAL_NVIC_SetPriority(I2S2_DMAx_IRQ, AUDIO_IN_IRQ_PREPRIO, 0);
00944   HAL_NVIC_EnableIRQ(I2S2_DMAx_IRQ);
00945 }
00946
00947 /**
00948   * @brief  DeInitializes BSP_AUDIO_IN MSP.
00949   * @param  hi2s: I2S handle
00950   * @param  Params : pointer on additional configuration parameters, can be NULL.
00951   */
00952 __weak void BSP_AUDIO_IN_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params)
00953 {
00954   GPIO_InitTypeDef  gpio_init_structure;
00955
00956   /* I2S DMA IRQ Channel deactivation */
00957   HAL_NVIC_DisableIRQ(I2S2_DMAx_IRQ);
00958
00959   if(hi2s->Instance == I2S2)
00960   {
00961     /* Deinitialize the Stream for new transfer */
00962     HAL_DMA_DeInit(hi2s->hdmarx);
00963   }
00964
00965  /* Disable I2S block */
00966   __HAL_I2S_DISABLE(hi2s);
00967
00968   /* Disable pins: SCK and SD pins */
00969   gpio_init_structure.Pin = I2S2_SCK_PIN;
00970   HAL_GPIO_DeInit(I2S2_SCK_GPIO_PORT, gpio_init_structure.Pin);
00971   gpio_init_structure.Pin = I2S2_MOSI_PIN;
00972   HAL_GPIO_DeInit(I2S2_MOSI_GPIO_PORT, gpio_init_structure.Pin);
00973
00974   /* Disable I2S clock */
00975   I2S2_CLK_DISABLE();
00976
00977   /* GPIO pins clock and DMA clock can be shut down in the applic
00978      by surcgarging this __weak function */
00979 }
00980
00981 /**
00982   * @brief  User callback when record buffer is filled.
00983   */
00984 __weak void BSP_AUDIO_IN_TransferComplete_CallBack(void)
00985 {
00986   /* This function should be implemented by the user application.
00987      It is called into this driver when the current buffer is filled
00988      to prepare the next buffer pointer and its size. */
00989 }
00990
00991 /**
00992   * @brief  Manages the DMA Half Transfer complete event.
00993   */
00994 __weak void BSP_AUDIO_IN_HalfTransfer_CallBack(void)
00995 {
00996   /* This function should be implemented by the user application.
00997      It is called into this driver when the current buffer is filled
00998      to prepare the next buffer pointer and its size. */
00999 }
01000
01001 /**
01002   * @brief  Audio IN Error callback function.
01003   */
01004 __weak void BSP_AUDIO_IN_Error_Callback(void)
01005 {
01006   /* This function is called when an Interrupt due to transfer error on or peripheral
01007      error occurs. */
01008 }
01009
01010 /*******************************************************************************
01011                             Static Functions
01012 *******************************************************************************/
01013
01014 /**
01015   * @brief  Initializes the PDM library.
01016   * @param  AudioFreq: Audio sampling frequency
01017   * @param  ChnlNbrIn: Number of input audio channels in the PDM buffer
01018   * @param  ChnlNbrOut: Number of desired output audio channels in the  resulting PCM buffer
01019   *         Number of audio channels (1: mono; 2: stereo)
01020   */
01021 static void PDMDecoder_Init(uint32_t AudioFreq, uint32_t ChnlNbrIn, uint32_t ChnlNbrOut)
01022 {
01023   uint32_t index = 0;
01024
01025   /* Enable CRC peripheral to unlock the PDM library */
01026   __HAL_RCC_CRC_CLK_ENABLE();
01027
01028   for(index = 0; index < ChnlNbrIn; index++)
01029   {
01030     /* Init PDM filters */
01031     PDM_FilterHandler[index].bit_order  = PDM_FILTER_BIT_ORDER_LSB;
01032     PDM_FilterHandler[index].endianness = PDM_FILTER_ENDIANNESS_LE;
01033     PDM_FilterHandler[index].high_pass_tap = 2122358088;
01034     PDM_FilterHandler[index].out_ptr_channels = ChnlNbrOut;
01035     PDM_FilterHandler[index].in_ptr_channels  = ChnlNbrIn;
01036     PDM_Filter_Init((PDM_Filter_Handler_t *)(&PDM_FilterHandler[index]));
01037
01038     /* PDM lib config phase */
01039     PDM_FilterConfig[index].output_samples_number = AudioFreq/1000;
01040     PDM_FilterConfig[index].mic_gain = 24;
01041     PDM_FilterConfig[index].decimation_factor = PDM_FILTER_DEC_FACTOR_64;
01042     PDM_Filter_setConfig((PDM_Filter_Handler_t *)&PDM_FilterHandler[index], &PDM_FilterConfig[index]);
01043   }
01044 }
01045
01046 /**
01047   * @brief  Initializes the Audio Codec audio interface (I2S)
01048   * @note   This function assumes that the I2S input clock (through PLL_R in
01049   *         Devices RevA/Z and through dedicated PLLI2S_R in Devices RevB/Y)
01050   *         is already configured and ready to be used.
01051   * @param  AudioFreq: Audio frequency to be configured for the I2S peripheral.
01052   */
01053 static uint8_t I2S2_Init(uint32_t AudioFreq)
01054 {
01055   /* Initialize the hAudioInI2s Instance parameter */
01056   hAudioInI2s.Instance          = I2S2;
01057
01058   /* Disable I2S block */
01059   __HAL_I2S_DISABLE(&hAudioInI2s);
01060
01061   /* I2S2 peripheral configuration */
01062   hAudioInI2s.Init.AudioFreq    = 2 * AudioFreq;
01063   hAudioInI2s.Init.ClockSource  = I2S_CLOCK_PLL;
01064   hAudioInI2s.Init.CPOL         = I2S_CPOL_HIGH;
01065   hAudioInI2s.Init.DataFormat   = I2S_DATAFORMAT_16B;
01066   hAudioInI2s.Init.MCLKOutput   = I2S_MCLKOUTPUT_DISABLE;
01067   hAudioInI2s.Init.Mode         = I2S_MODE_MASTER_RX;
01068   hAudioInI2s.Init.Standard     = I2S_STANDARD_LSB;
01069
01070   /* Initialize the I2S peripheral with the structure above */
01071   if(HAL_I2S_Init(&hAudioInI2s) != HAL_OK)
01072   {
01073     return AUDIO_ERROR;
01074   }
01075   else
01076   {
01077     return AUDIO_OK;
01078   }
01079 }
01080
01081 /**
01082   * @}
01083   */
01084
01085 /** @defgroup STM32F4_DISCOVERY_AUDIO_IN_OUT_Private_Functions STM32F4 DISCOVERY AUDIO IN OUT Private Functions
01086   * @{
01087   */
01088
01089 /**
01090   * @brief  I2S error callbacks.
01091   * @param  hi2s: I2S handle
01092   */
01093 void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s)
01094 {
01095   /* Manage the error generated on DMA FIFO: This function
01096      should be coded by user (its prototype is already declared in stm32f4_discovery_audio.h) */
01097   if(hi2s->Instance == I2S3)
01098   {
01099     BSP_AUDIO_OUT_Error_CallBack();
01100   }
01101   if(hi2s->Instance == I2S2)
01102   {
01103     BSP_AUDIO_IN_Error_Callback();
01104   }
01105 }
01106
01107 /**
01108   * @}
01109   */
01110
01111 /**
01112   * @}
01113   */
01114
01115 /**
01116   * @}
01117   */
01118
01119 /**
01120   * @}
01121   */


./STM32F4-Discovery BSP User Manual: stm32f4_discovery_audio.h Source File

  • File List
  • Globals
  • Firmware
  • Drivers
  • BSP
  • STM32F4-Discovery
stm32f4_discovery_audio.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4_discovery_audio.h
00004   * @author  MCD Application Team
00005   * @brief   This file contains the common defines and functions prototypes for
00006   *          stm32f4_discovery_audio.c driver.
00007   ******************************************************************************
00008   * @attention
00009   *
00010   * Copyright (c) 2017 STMicroelectronics.
00011   * All rights reserved.
00012   *
00013   * This software is licensed under terms that can be found in the LICENSE file
00014   * in the root directory of this software component.
00015   * If no LICENSE file comes with this software, it is provided AS-IS.
00016   *
00017   ******************************************************************************
00018   */
00019
00020 /* Define to prevent recursive inclusion -------------------------------------*/
00021 #ifndef __STM32F4_DISCOVERY_AUDIO_H
00022 #define __STM32F4_DISCOVERY_AUDIO_H
00023
00024 #ifdef __cplusplus
00025  extern "C" {
00026 #endif
00027
00028 /* Includes ------------------------------------------------------------------*/
00029 /* Include audio component Driver */
00030 #include "../Components/cs43l22/cs43l22.h"
00031
00032 #include "stm32f4_discovery.h"
00033 #include "../../../Middlewares/ST/STM32_Audio/Addons/PDM/Inc/pdm2pcm_glo.h"
00034
00035 /** @addtogroup BSP
00036   * @{
00037   */
00038
00039 /** @addtogroup STM32F4_DISCOVERY
00040   * @{
00041   */
00042
00043 /** @addtogroup STM32F4_DISCOVERY_AUDIO
00044   * @{
00045   */
00046
00047
00048 /** @defgroup STM32F4_DISCOVERY_AUDIO_Exported_Types STM32F4 DISCOVERY AUDIO Exported Types
00049   * @{
00050   */
00051 /**
00052   * @}
00053   */
00054
00055 /** @defgroup STM32F4_DISCOVERY_AUDIO_OUT_Exported_Constants STM32F4 DISCOVERY AUDIO OUT Exported Constants
00056   * @{
00057   */
00058
00059 /*------------------------------------------------------------------------------
00060                           AUDIO OUT CONFIGURATION
00061 ------------------------------------------------------------------------------*/
00062
00063 /* I2S peripheral configuration defines */
00064 #define I2S3                            SPI3
00065 #define I2S3_CLK_ENABLE()               __HAL_RCC_SPI3_CLK_ENABLE()
00066 #define I2S3_CLK_DISABLE()              __HAL_RCC_SPI3_CLK_DISABLE()
00067 #define I2S3_SCK_SD_WS_AF               GPIO_AF6_SPI3
00068 #define I2S3_SCK_SD_CLK_ENABLE()        __HAL_RCC_GPIOC_CLK_ENABLE()
00069 #define I2S3_MCK_CLK_ENABLE()           __HAL_RCC_GPIOC_CLK_ENABLE()
00070 #define I2S3_WS_CLK_ENABLE()            __HAL_RCC_GPIOA_CLK_ENABLE()
00071 #define I2S3_WS_PIN                     GPIO_PIN_4
00072 #define I2S3_SCK_PIN                    GPIO_PIN_10
00073 #define I2S3_SD_PIN                     GPIO_PIN_12
00074 #define I2S3_MCK_PIN                    GPIO_PIN_7
00075 #define I2S3_SCK_SD_GPIO_PORT           GPIOC
00076 #define I2S3_WS_GPIO_PORT               GPIOA
00077 #define I2S3_MCK_GPIO_PORT              GPIOC
00078
00079 /* I2S DMA Stream definitions */
00080 #define I2S3_DMAx_CLK_ENABLE()          __HAL_RCC_DMA1_CLK_ENABLE()
00081 #define I2S3_DMAx_CLK_DISABLE()         __HAL_RCC_DMA1_CLK_DISABLE()
00082 #define I2S3_DMAx_STREAM                DMA1_Stream7
00083 #define I2S3_DMAx_CHANNEL               DMA_CHANNEL_0
00084 #define I2S3_DMAx_IRQ                   DMA1_Stream7_IRQn
00085 #define I2S3_DMAx_PERIPH_DATA_SIZE      DMA_PDATAALIGN_HALFWORD
00086 #define I2S3_DMAx_MEM_DATA_SIZE         DMA_MDATAALIGN_HALFWORD
00087 #define DMA_MAX_SZE                     0xFFFF
00088
00089 #define I2S3_IRQHandler                 DMA1_Stream7_IRQHandler
00090
00091 /* Select the interrupt preemption priority and subpriority for the DMA interrupt */
00092 #define AUDIO_OUT_IRQ_PREPRIO           0x0E   /* Select the preemption priority level(0 is the highest) */
00093
00094 /*------------------------------------------------------------------------------
00095                           AUDIO IN CONFIGURATION
00096 ------------------------------------------------------------------------------*/
00097 /* SPI Configuration defines */
00098 #define I2S2                            SPI2
00099 #define I2S2_CLK_ENABLE()               __HAL_RCC_SPI2_CLK_ENABLE()
00100 #define I2S2_CLK_DISABLE()              __HAL_RCC_SPI2_CLK_DISABLE()
00101 #define I2S2_SCK_PIN                    GPIO_PIN_10
00102 #define I2S2_SCK_GPIO_PORT              GPIOB
00103 #define I2S2_SCK_GPIO_CLK_ENABLE()      __HAL_RCC_GPIOB_CLK_ENABLE()
00104 #define I2S2_SCK_AF                     GPIO_AF5_SPI2
00105
00106 #define I2S2_MOSI_PIN                   GPIO_PIN_3
00107 #define I2S2_MOSI_GPIO_PORT             GPIOC
00108 #define I2S2_MOSI_GPIO_CLK_ENABLE()     __HAL_RCC_GPIOC_CLK_ENABLE()
00109 #define I2S2_MOSI_AF                    GPIO_AF5_SPI2
00110
00111 /* I2S DMA Stream Rx definitions */
00112 #define I2S2_DMAx_CLK_ENABLE()          __HAL_RCC_DMA1_CLK_ENABLE()
00113 #define I2S2_DMAx_CLK_DISABLE()         __HAL_RCC_DMA1_CLK_DISABLE()
00114 #define I2S2_DMAx_STREAM                DMA1_Stream3
00115 #define I2S2_DMAx_CHANNEL               DMA_CHANNEL_0
00116 #define I2S2_DMAx_IRQ                   DMA1_Stream3_IRQn
00117 #define I2S2_DMAx_PERIPH_DATA_SIZE      DMA_PDATAALIGN_HALFWORD
00118 #define I2S2_DMAx_MEM_DATA_SIZE         DMA_MDATAALIGN_HALFWORD
00119
00120 #define I2S2_IRQHandler                 DMA1_Stream3_IRQHandler
00121
00122 /* Select the interrupt preemption priority and subpriority for the IT/DMA interrupt */
00123 #define AUDIO_IN_IRQ_PREPRIO            0x0F   /* Select the preemption priority level(0 is the highest) */
00124
00125 /*------------------------------------------------------------------------------
00126              CONFIGURATION: Audio Driver Configuration parameters
00127 ------------------------------------------------------------------------------*/
00128
00129 #define AUDIODATA_SIZE                  2   /* 16-bits audio data size */
00130
00131 /* Audio status definition */
00132 #define AUDIO_OK                        0
00133 #define AUDIO_ERROR                     1
00134 #define AUDIO_TIMEOUT                   2
00135
00136 /* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */
00137 #define DEFAULT_AUDIO_IN_FREQ                 I2S_AUDIOFREQ_16K
00138 #define DEFAULT_AUDIO_IN_BIT_RESOLUTION       16
00139 #define DEFAULT_AUDIO_IN_CHANNEL_NBR          1 /* Mono = 1, Stereo = 2 */
00140 #define DEFAULT_AUDIO_IN_VOLUME               64
00141
00142 /* PDM buffer input size */
00143 #define INTERNAL_BUFF_SIZE                    128*DEFAULT_AUDIO_IN_FREQ/16000*DEFAULT_AUDIO_IN_CHANNEL_NBR
00144 /* PCM buffer output size */
00145 #define PCM_OUT_SIZE                          DEFAULT_AUDIO_IN_FREQ/1000
00146 #define CHANNEL_DEMUX_MASK                    0x55
00147
00148 /*------------------------------------------------------------------------------
00149                     OPTIONAL Configuration defines parameters
00150 ------------------------------------------------------------------------------*/
00151
00152 /**
00153   * @}
00154   */
00155
00156 /** @defgroup STM32F4_DISCOVERY_AUDIO_Exported_Variables STM32F4 DISCOVERY AUDIO Exported Variables
00157   * @{
00158   */
00159 extern __IO uint16_t AudioInVolume;
00160 /**
00161   * @}
00162   */
00163
00164 /** @defgroup STM32F4_DISCOVERY_AUDIO_Exported_Macros STM32F4 DISCOVERY AUDIO Exported Macros
00165   * @{
00166   */
00167 #define DMA_MAX(_X_)                (((_X_) <= DMA_MAX_SZE)? (_X_):DMA_MAX_SZE)
00168 #define HTONS(A)  ((((uint16_t)(A) & 0xff00) >> 8) | (((uint16_t)(A) & 0x00ff) << 8))
00169 /**
00170   * @}
00171   */
00172
00173 /** @defgroup STM32F4_DISCOVERY_AUDIO_OUT_Exported_Functions  STM32F4 DISCOVERY AUDIO OUT Exported Functions
00174   * @{
00175   */
00176 uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq);
00177 uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size);
00178 void    BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size);
00179 uint8_t BSP_AUDIO_OUT_Pause(void);
00180 uint8_t BSP_AUDIO_OUT_Resume(void);
00181 uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option);
00182 uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume);
00183 void    BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq);
00184 uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd);
00185 uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output);
00186
00187 /* User Callbacks: user has to implement these functions in his code if they are needed. */
00188 /* This function is called when the requested data has been completely transferred. */
00189 void    BSP_AUDIO_OUT_TransferComplete_CallBack(void);
00190
00191 /* This function is called when half of the requested buffer has been transferred. */
00192 void    BSP_AUDIO_OUT_HalfTransfer_CallBack(void);
00193
00194 /* This function is called when an Interrupt due to transfer error on or peripheral
00195    error occurs. */
00196 void    BSP_AUDIO_OUT_Error_CallBack(void);
00197
00198 /* These function can be modified in case the current settings (e.g. DMA stream)
00199    need to be changed for specific application needs */
00200 void  BSP_AUDIO_OUT_ClockConfig(I2S_HandleTypeDef *hi2s, uint32_t AudioFreq, void *Params);
00201 void  BSP_AUDIO_OUT_MspInit(I2S_HandleTypeDef *hi2s, void *Params);
00202 void  BSP_AUDIO_OUT_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params);
00203
00204 /**
00205   * @}
00206   */
00207
00208 /** @defgroup STM32F4_DISCOVERY_AUDIO_IN_Exported_Functions STM32F4 DISCOVERY AUDIO IN Exported Functions
00209   * @{
00210   */
00211 uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr);
00212 uint8_t BSP_AUDIO_IN_Record(uint16_t *pData, uint32_t Size);
00213 uint8_t BSP_AUDIO_IN_Stop(void);
00214 uint8_t BSP_AUDIO_IN_Pause(void);
00215 uint8_t BSP_AUDIO_IN_Resume(void);
00216 uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume);
00217 uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t *PDMBuf, uint16_t *PCMBuf);
00218 /* User Callbacks: user has to implement these functions in his code if they are needed. */
00219 /* This function should be implemented by the user application.
00220    It is called into this driver when the current buffer is filled to prepare the next
00221    buffer pointer and its size. */
00222 void    BSP_AUDIO_IN_TransferComplete_CallBack(void);
00223 void    BSP_AUDIO_IN_HalfTransfer_CallBack(void);
00224
00225 /* This function is called when an Interrupt due to transfer error on or peripheral
00226    error occurs. */
00227 void    BSP_AUDIO_IN_Error_Callback(void);
00228
00229 /* These function can be modified in case the current settings (e.g. DMA stream)
00230    need to be changed for specific application needs */
00231 void  BSP_AUDIO_IN_ClockConfig(I2S_HandleTypeDef *hi2s, uint32_t AudioFreq, void *Params);
00232 void  BSP_AUDIO_IN_MspInit(I2S_HandleTypeDef *hi2s, void *Params);
00233 void  BSP_AUDIO_IN_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params);
00234
00235 /**
00236   * @}
00237   */
00238
00239 /**
00240   * @}
00241   */
00242
00243 /**
00244   * @}
00245   */
00246
00247 /**
00248   * @}
00249   */
00250
00251 #ifdef __cplusplus
00252 }
00253 #endif
00254
00255 #endif /* __STM32F4_DISCOVERY_AUDIO_H */


./STM32F4-Discovery BSP User Manual: userManualMainpage.txt File Reference

  • File List
  • Globals
userManualMainpage.txt File Reference