stm32f4_discovery.c
Go to the documentation of this file.
1 
36 /* Includes ------------------------------------------------------------------*/
37 #include "stm32f4_discovery.h"
38 
67 #define __STM32F4_DISCO_BSP_VERSION_MAIN (0x02)
68 #define __STM32F4_DISCO_BSP_VERSION_SUB1 (0x01)
69 #define __STM32F4_DISCO_BSP_VERSION_SUB2 (0x03)
70 #define __STM32F4_DISCO_BSP_VERSION_RC (0x00)
71 #define __STM32F4_DISCO_BSP_VERSION ((__STM32F4_DISCO_BSP_VERSION_MAIN << 24)\
72  |(__STM32F4_DISCO_BSP_VERSION_SUB1 << 16)\
73  |(__STM32F4_DISCO_BSP_VERSION_SUB2 << 8 )\
74  |(__STM32F4_DISCO_BSP_VERSION_RC))
75 
94 const uint16_t GPIO_PIN[LEDn] = {LED4_PIN,
95  LED3_PIN,
96  LED5_PIN,
97  LED6_PIN};
98 
100 const uint16_t BUTTON_PIN[BUTTONn] = {KEY_BUTTON_PIN};
102 
103 uint32_t I2cxTimeout = I2Cx_TIMEOUT_MAX; /*<! Value of Timeout when I2C communication fails */
104 uint32_t SpixTimeout = SPIx_TIMEOUT_MAX; /*<! Value of Timeout when SPI communication fails */
105 
122 static void I2Cx_Init(void);
123 static void I2Cx_WriteData(uint8_t Addr, uint8_t Reg, uint8_t Value);
124 static uint8_t I2Cx_ReadData(uint8_t Addr, uint8_t Reg);
125 static void I2Cx_MspInit(void);
126 static void I2Cx_Error(uint8_t Addr);
127 
128 static void SPIx_Init(void);
129 static void SPIx_MspInit(void);
130 static uint8_t SPIx_WriteRead(uint8_t Byte);
131 static void SPIx_Error(void);
132 
133 /* Link functions for Accelerometer peripheral */
134 void ACCELERO_IO_Init(void);
135 void ACCELERO_IO_ITConfig(void);
136 void ACCELERO_IO_Write(uint8_t *pBuffer, uint8_t WriteAddr, uint16_t NumByteToWrite);
137 void ACCELERO_IO_Read(uint8_t *pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead);
138 
139 /* Link functions for Audio peripheral */
140 void AUDIO_IO_Init(void);
141 void AUDIO_IO_DeInit(void);
142 void AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
143 uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg);
156 uint32_t BSP_GetVersion(void)
157 {
159 }
160 
171 {
172  GPIO_InitTypeDef GPIO_InitStruct;
173 
174  /* Enable the GPIO_LED Clock */
176 
177  /* Configure the GPIO_LED pin */
178  GPIO_InitStruct.Pin = GPIO_PIN[Led];
179  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
180  GPIO_InitStruct.Pull = GPIO_PULLUP;
181  GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
182 
183  HAL_GPIO_Init(GPIO_PORT[Led], &GPIO_InitStruct);
184 
186 }
187 
198 {
200 }
201 
212 {
214 }
215 
226 {
228 }
229 
249 {
250  GPIO_InitTypeDef GPIO_InitStruct;
251 
252  /* Enable the BUTTON Clock */
253  BUTTONx_GPIO_CLK_ENABLE(Button);
254 
255  if (Mode == BUTTON_MODE_GPIO)
256  {
257  /* Configure Button pin as input */
258  GPIO_InitStruct.Pin = BUTTON_PIN[Button];
259  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
260  GPIO_InitStruct.Pull = GPIO_NOPULL;
261  GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
262 
263  HAL_GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStruct);
264  }
265 
266  if (Mode == BUTTON_MODE_EXTI)
267  {
268  /* Configure Button pin as input with External interrupt */
269  GPIO_InitStruct.Pin = BUTTON_PIN[Button];
270  GPIO_InitStruct.Pull = GPIO_NOPULL;
271  GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
272  GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
273  HAL_GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStruct);
274 
275  /* Enable and set Button EXTI Interrupt to the lowest priority */
276  HAL_NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x0F, 0);
278  }
279 }
280 
288 {
289  return HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]);
290 }
291 
300 /*******************************************************************************
301  BUS OPERATIONS
302 *******************************************************************************/
303 
304 /******************************* SPI Routines *********************************/
305 
309 static void SPIx_Init(void)
310 {
312  {
313  /* SPI configuration -----------------------------------------------------*/
326 
327  SPIx_MspInit();
329  }
330 }
331 
338 static uint8_t SPIx_WriteRead(uint8_t Byte)
339 {
340  uint8_t receivedbyte = 0;
341 
342  /* Send a Byte through the SPI peripheral */
343  /* Read byte from the SPI bus */
344  if(HAL_SPI_TransmitReceive(&SpiHandle, (uint8_t*) &Byte, (uint8_t*) &receivedbyte, 1, SpixTimeout) != HAL_OK)
345  {
346  SPIx_Error();
347  }
348 
349  return receivedbyte;
350 }
351 
355 static void SPIx_Error(void)
356 {
357  /* De-initialize the SPI communication bus */
359 
360  /* Re-Initialize the SPI communication bus */
361  SPIx_Init();
362 }
363 
367 static void SPIx_MspInit(void)
368 {
369  GPIO_InitTypeDef GPIO_InitStructure;
370 
371  /* Enable the SPI peripheral */
373 
374  /* Enable SCK, MOSI and MISO GPIO clocks */
376 
377  /* SPI SCK, MOSI, MISO pin configuration */
379  GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
380  GPIO_InitStructure.Pull = GPIO_PULLDOWN;
381  GPIO_InitStructure.Speed = GPIO_SPEED_MEDIUM;
382  GPIO_InitStructure.Alternate = DISCOVERY_SPIx_AF;
383  HAL_GPIO_Init(DISCOVERY_SPIx_GPIO_PORT, &GPIO_InitStructure);
384 }
385 
386 /******************************* I2C Routines**********************************/
390 static void I2Cx_Init(void)
391 {
393  {
394  /* DISCOVERY_I2Cx peripheral configuration */
397  I2cHandle.Init.OwnAddress1 = 0x33;
400 
401  /* Init the I2C */
402  I2Cx_MspInit();
404  }
405 }
406 
414 static void I2Cx_WriteData(uint8_t Addr, uint8_t Reg, uint8_t Value)
415 {
416  HAL_StatusTypeDef status = HAL_OK;
417 
418  status = HAL_I2C_Mem_Write(&I2cHandle, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, &Value, 1, I2cxTimeout);
419 
420  /* Check the communication status */
421  if(status != HAL_OK)
422  {
423  /* Execute user timeout callback */
424  I2Cx_Error(Addr);
425  }
426 }
427 
434 static uint8_t I2Cx_ReadData(uint8_t Addr, uint8_t Reg)
435 {
436  HAL_StatusTypeDef status = HAL_OK;
437  uint8_t value = 0;
438 
439  status = HAL_I2C_Mem_Read(&I2cHandle, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, &value, 1,I2cxTimeout);
440 
441  /* Check the communication status */
442  if(status != HAL_OK)
443  {
444  /* Execute user timeout callback */
445  I2Cx_Error(Addr);
446  }
447  return value;
448 }
449 
454 static void I2Cx_Error(uint8_t Addr)
455 {
456  /* De-initialize the I2C communication bus */
458 
459  /* Re-Initialize the I2C communication bus */
460  I2Cx_Init();
461 }
462 
466 static void I2Cx_MspInit(void)
467 {
468  GPIO_InitTypeDef GPIO_InitStruct;
469 
470  /* Enable I2C GPIO clocks */
472 
473  /* DISCOVERY_I2Cx SCL and SDA pins configuration ---------------------------*/
475  GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
476  GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
477  GPIO_InitStruct.Pull = GPIO_NOPULL;
478  GPIO_InitStruct.Alternate = DISCOVERY_I2Cx_SCL_SDA_AF;
480 
481  /* Enable the DISCOVERY_I2Cx peripheral clock */
483 
484  /* Force the I2C peripheral clock reset */
486 
487  /* Release the I2C peripheral clock reset */
489 
490  /* Enable and set I2Cx Interrupt to the highest priority */
493 
494  /* Enable and set I2Cx Interrupt to the highest priority */
497 }
498 
499 /*******************************************************************************
500  LINK OPERATIONS
501 *******************************************************************************/
502 
503 /***************************** LINK ACCELEROMETER *****************************/
504 
509 {
510  GPIO_InitTypeDef GPIO_InitStructure;
511 
512  /* Configure the Accelerometer Control pins --------------------------------*/
513  /* Enable CS GPIO clock and configure GPIO pin for Accelerometer Chip select */
515 
516  /* Configure GPIO PIN for LIS Chip select */
517  GPIO_InitStructure.Pin = ACCELERO_CS_PIN;
518  GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
519  GPIO_InitStructure.Pull = GPIO_NOPULL;
520  GPIO_InitStructure.Speed = GPIO_SPEED_MEDIUM;
521  HAL_GPIO_Init(ACCELERO_CS_GPIO_PORT, &GPIO_InitStructure);
522 
523  /* Deselect: Chip Select high */
525 
526  SPIx_Init();
527 }
528 
534 {
535  GPIO_InitTypeDef GPIO_InitStructure;
536 
537  /* Enable INT2 GPIO clock and configure GPIO PINs to detect Interrupts */
539 
540  /* Configure GPIO PINs to detect Interrupts */
541  GPIO_InitStructure.Pin = ACCELERO_INT2_PIN;
542  GPIO_InitStructure.Mode = GPIO_MODE_IT_RISING;
543  GPIO_InitStructure.Speed = GPIO_SPEED_FAST;
544  GPIO_InitStructure.Pull = GPIO_NOPULL;
545  HAL_GPIO_Init(ACCELERO_INT_GPIO_PORT, &GPIO_InitStructure);
546 
547  /* Enable and set Accelerometer INT2 to the lowest priority */
550 }
551 
558 void ACCELERO_IO_Write(uint8_t *pBuffer, uint8_t WriteAddr, uint16_t NumByteToWrite)
559 {
560  /* Configure the MS bit:
561  - When 0, the address will remain unchanged in multiple read/write commands.
562  - When 1, the address will be auto incremented in multiple read/write commands.
563  */
564  if(NumByteToWrite > 0x01)
565  {
566  WriteAddr |= (uint8_t)MULTIPLEBYTE_CMD;
567  }
568  /* Set chip select Low at the start of the transmission */
569  ACCELERO_CS_LOW();
570 
571  /* Send the Address of the indexed register */
572  SPIx_WriteRead(WriteAddr);
573 
574  /* Send the data that will be written into the device (MSB First) */
575  while(NumByteToWrite >= 0x01)
576  {
577  SPIx_WriteRead(*pBuffer);
578  NumByteToWrite--;
579  pBuffer++;
580  }
581 
582  /* Set chip select High at the end of the transmission */
584 }
585 
592 void ACCELERO_IO_Read(uint8_t *pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead)
593 {
594  if(NumByteToRead > 0x01)
595  {
596  ReadAddr |= (uint8_t)(READWRITE_CMD | MULTIPLEBYTE_CMD);
597  }
598  else
599  {
600  ReadAddr |= (uint8_t)READWRITE_CMD;
601  }
602  /* Set chip select Low at the start of the transmission */
603  ACCELERO_CS_LOW();
604 
605  /* Send the Address of the indexed register */
606  SPIx_WriteRead(ReadAddr);
607 
608  /* Receive the data that will be read from the device (MSB First) */
609  while(NumByteToRead > 0x00)
610  {
611  /* Send dummy byte (0x00) to generate the SPI clock to ACCELEROMETER (Slave device) */
612  *pBuffer = SPIx_WriteRead(DUMMY_BYTE);
613  NumByteToRead--;
614  pBuffer++;
615  }
616 
617  /* Set chip select High at the end of the transmission */
619 }
620 
621 /********************************* LINK AUDIO *********************************/
622 
626 void AUDIO_IO_Init(void)
627 {
628  GPIO_InitTypeDef GPIO_InitStruct;
629 
630  /* Enable Reset GPIO Clock */
632 
633  /* Audio reset pin configuration */
634  GPIO_InitStruct.Pin = AUDIO_RESET_PIN;
635  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
636  GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
637  GPIO_InitStruct.Pull = GPIO_NOPULL;
638  HAL_GPIO_Init(AUDIO_RESET_GPIO, &GPIO_InitStruct);
639 
640  I2Cx_Init();
641 
642  /* Power Down the codec */
644 
645  /* Wait for a delay to insure registers erasing */
646  HAL_Delay(5);
647 
648  /* Power on the codec */
650 
651  /* Wait for a delay to insure registers erasing */
652  HAL_Delay(5);
653 }
654 
658 void AUDIO_IO_DeInit(void)
659 {
660 
661 }
662 
669 void AUDIO_IO_Write (uint8_t Addr, uint8_t Reg, uint8_t Value)
670 {
671  I2Cx_WriteData(Addr, Reg, Value);
672 }
673 
680 uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg)
681 {
682  return I2Cx_ReadData(Addr, Reg);
683 }
684 
701 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
HAL_I2C_Init
HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c)
__SPI_HandleTypeDef::Init
SPI_InitTypeDef Init
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:109
SPIx_Init
static void SPIx_Init(void)
SPIx Bus initialization.
Definition: stm32f4_discovery.c:309
GPIO_MODE_AF_PP
#define GPIO_MODE_AF_PP
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:122
HAL_StatusTypeDef
HAL_StatusTypeDef
HAL Status structures definition
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:40
SPI_InitTypeDef::BaudRatePrescaler
uint32_t BaudRatePrescaler
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:68
AUDIO_IO_DeInit
void AUDIO_IO_DeInit(void)
DeInitializes Audio low level.
Definition: stm32f4_discovery.c:658
HAL_I2C_GetState
HAL_I2C_StateTypeDef HAL_I2C_GetState(I2C_HandleTypeDef *hi2c)
I2C_InitTypeDef::OwnAddress1
uint32_t OwnAddress1
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h:56
I2cxTimeout
uint32_t I2cxTimeout
Definition: stm32f4_discovery.c:103
HAL_NVIC_EnableIRQ
void HAL_NVIC_EnableIRQ(IRQn_Type IRQn)
I2C_InitTypeDef::AddressingMode
uint32_t AddressingMode
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h:59
SPI_InitTypeDef::CLKPhase
uint32_t CLKPhase
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:61
BUTTON_MODE_GPIO
@ BUTTON_MODE_GPIO
Definition: stm32f4_discovery.h:78
BUTTON_PIN
const uint16_t BUTTON_PIN[BUTTONn]
Definition: stm32f4_discovery.c:100
SPI_InitTypeDef::NSS
uint32_t NSS
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:64
GPIO_InitTypeDef
GPIO Init structure definition
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:47
BUTTONx_GPIO_CLK_ENABLE
#define BUTTONx_GPIO_CLK_ENABLE(__INDEX__)
Definition: stm32f4_discovery.h:150
LED6_PIN
#define LED6_PIN
Definition: stm32f4_discovery.h:116
GPIO_PORT
GPIO_TypeDef * GPIO_PORT[LEDn]
Definition: stm32f4_discovery.c:90
SPI_MODE_MASTER
#define SPI_MODE_MASTER
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:208
ACCELERO_CS_HIGH
#define ACCELERO_CS_HIGH()
Definition: stm32f4_discovery.h:222
DISCOVERY_I2Cx_SDA_PIN
#define DISCOVERY_I2Cx_SDA_PIN
Definition: stm32f4_discovery.h:195
SPI_PHASE_1EDGE
#define SPI_PHASE_1EDGE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:244
BUTTON_IRQn
const uint8_t BUTTON_IRQn[BUTTONn]
Definition: stm32f4_discovery.c:101
stm32f4_discovery.h
This file contains definitions for STM32F4-Discovery Kit's Leds and push-button hardware resources.
LEDx_GPIO_CLK_ENABLE
#define LEDx_GPIO_CLK_ENABLE(__INDEX__)
Definition: stm32f4_discovery.h:121
GPIO_InitTypeDef::Alternate
uint32_t Alternate
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:61
__SPI_HandleTypeDef
SPI handle Structure definition.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:105
DISCOVERY_I2Cx_EV_IRQn
#define DISCOVERY_I2Cx_EV_IRQn
Definition: stm32f4_discovery.h:201
LED4_PIN
#define LED4_PIN
Definition: stm32f4_discovery.h:101
SPI_InitTypeDef::FirstBit
uint32_t FirstBit
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:74
I2C_ADDRESSINGMODE_7BIT
#define I2C_ADDRESSINGMODE_7BIT
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h:299
I2Cx_ReadData
static uint8_t I2Cx_ReadData(uint8_t Addr, uint8_t Reg)
Read a register of the device through BUS.
Definition: stm32f4_discovery.c:434
DISCOVERY_I2Cx_SCL_SDA_AF
#define DISCOVERY_I2Cx_SCL_SDA_AF
Definition: stm32f4_discovery.h:192
I2Cx_Init
static void I2Cx_Init(void)
Configures I2C interface.
Definition: stm32f4_discovery.c:390
GPIO_PIN_SET
@ GPIO_PIN_SET
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:71
LED5_PIN
#define LED5_PIN
Definition: stm32f4_discovery.h:111
DISCOVERY_SPIx
#define DISCOVERY_SPIx
Definition: stm32f4_discovery.h:164
HAL_I2C_STATE_RESET
@ HAL_I2C_STATE_RESET
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h:109
DISCOVERY_I2Cx
#define DISCOVERY_I2Cx
Definition: stm32f4_discovery.h:189
I2C_DUTYCYCLE_2
#define I2C_DUTYCYCLE_2
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h:290
BSP_LED_Off
void BSP_LED_Off(Led_TypeDef Led)
Turns selected LED Off.
Definition: stm32f4_discovery.c:211
DISCOVERY_SPIx_SCK_PIN
#define DISCOVERY_SPIx_SCK_PIN
Definition: stm32f4_discovery.h:170
SPI_TIMODE_DISABLED
#define SPI_TIMODE_DISABLED
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h:1106
HAL_I2C_Mem_Write
HAL_StatusTypeDef HAL_I2C_Mem_Write(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout)
HAL_Delay
void HAL_Delay(uint32_t Delay)
This function provides minimum delay (in milliseconds) based on variable incremented.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:389
BUTTON_MODE_EXTI
@ BUTTON_MODE_EXTI
Definition: stm32f4_discovery.h:79
I2Cx_Error
static void I2Cx_Error(uint8_t Addr)
Manages error callback by re-initializing I2C.
Definition: stm32f4_discovery.c:454
KEY_BUTTON_GPIO_PORT
#define KEY_BUTTON_GPIO_PORT
Definition: stm32f4_discovery.h:145
AUDIO_RESET_PIN
#define AUDIO_RESET_PIN
Definition: stm32f4_discovery.h:251
HAL_GPIO_ReadPin
GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
__SPI_HandleTypeDef::Instance
SPI_TypeDef * Instance
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:107
ButtonMode_TypeDef
ButtonMode_TypeDef
Definition: stm32f4_discovery.h:76
LED4_GPIO_PORT
#define LED4_GPIO_PORT
Definition: stm32f4_discovery.h:102
GPIO_PIN
const uint16_t GPIO_PIN[LEDn]
Definition: stm32f4_discovery.c:94
HAL_OK
@ HAL_OK
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:42
BSP_I2C_SPEED
#define BSP_I2C_SPEED
Definition: stm32f4_discovery.h:185
LED3_GPIO_PORT
#define LED3_GPIO_PORT
Definition: stm32f4_discovery.h:107
BSP_GetVersion
uint32_t BSP_GetVersion(void)
This method returns the STM32F4 DISCO BSP Driver revision.
Definition: stm32f4_discovery.c:156
ACCELERO_CS_LOW
#define ACCELERO_CS_LOW()
Definition: stm32f4_discovery.h:221
HAL_GPIO_Init
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
DISCOVERY_SPIx_CLK_ENABLE
#define DISCOVERY_SPIx_CLK_ENABLE()
Definition: stm32f4_discovery.h:165
ACCELERO_IO_Write
void ACCELERO_IO_Write(uint8_t *pBuffer, uint8_t WriteAddr, uint16_t NumByteToWrite)
Writes one byte to the Accelerometer.
Definition: stm32f4_discovery.c:558
GPIO_InitTypeDef::Mode
uint32_t Mode
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:52
AUDIO_RESET_GPIO
#define AUDIO_RESET_GPIO
Definition: stm32f4_discovery.h:252
I2C_InitTypeDef::DutyCycle
uint32_t DutyCycle
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h:53
I2Cx_MspInit
static void I2Cx_MspInit(void)
I2C MSP Initialization.
Definition: stm32f4_discovery.c:466
GPIO_InitTypeDef::Pull
uint32_t Pull
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:55
SPI_DIRECTION_2LINES
#define SPI_DIRECTION_2LINES
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:216
GPIO_NOPULL
#define GPIO_NOPULL
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:154
LED5_GPIO_PORT
#define LED5_GPIO_PORT
Definition: stm32f4_discovery.h:112
BSP_LED_On
void BSP_LED_On(Led_TypeDef Led)
Turns selected LED On.
Definition: stm32f4_discovery.c:197
READWRITE_CMD
#define READWRITE_CMD
Definition: stm32f4_discovery.h:214
BSP_PB_GetState
uint32_t BSP_PB_GetState(Button_TypeDef Button)
Returns the selected Button state.
Definition: stm32f4_discovery.c:287
SPIx_MspInit
static void SPIx_MspInit(void)
SPI MSP Init.
Definition: stm32f4_discovery.c:367
SPIx_WriteRead
static uint8_t SPIx_WriteRead(uint8_t Byte)
Sends a Byte through the SPI interface and return the Byte received from the SPI bus.
Definition: stm32f4_discovery.c:338
AUDIO_RESET_GPIO_CLK_ENABLE
#define AUDIO_RESET_GPIO_CLK_ENABLE()
Definition: stm32f4_discovery.h:250
SpixTimeout
uint32_t SpixTimeout
Definition: stm32f4_discovery.c:104
SPIx_Error
static void SPIx_Error(void)
SPIx error treatment function.
Definition: stm32f4_discovery.c:355
ACCELERO_CS_PIN
#define ACCELERO_CS_PIN
ACCELEROMETER Interface pins.
Definition: stm32f4_discovery.h:227
I2cHandle
static I2C_HandleTypeDef I2cHandle
Definition: stm32f4_discovery.c:107
SPI_InitTypeDef::Mode
uint32_t Mode
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:49
IRQn_Type
IRQn_Type
STM32F4XX Interrupt Number Definition, according to the selected device in Library_configuration_sect...
Definition: stm32f407xx.h:66
ACCELERO_INT2_EXTI_IRQn
#define ACCELERO_INT2_EXTI_IRQn
Definition: stm32f4_discovery.h:237
ACCELERO_INT_GPIO_PORT
#define ACCELERO_INT_GPIO_PORT
Definition: stm32f4_discovery.h:231
HAL_SPI_STATE_RESET
@ HAL_SPI_STATE_RESET
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:92
DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT
#define DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT
Definition: stm32f4_discovery.h:193
AUDIO_IO_Init
void AUDIO_IO_Init(void)
Initializes Audio low level.
Definition: stm32f4_discovery.c:626
KEY_BUTTON_EXTI_IRQn
#define KEY_BUTTON_EXTI_IRQn
Definition: stm32f4_discovery.h:148
DISCOVERY_I2Cx_FORCE_RESET
#define DISCOVERY_I2Cx_FORCE_RESET()
Definition: stm32f4_discovery.h:197
GPIO_InitTypeDef::Speed
uint32_t Speed
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:58
SPI_FIRSTBIT_MSB
#define SPI_FIRSTBIT_MSB
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:278
I2C_MEMADD_SIZE_8BIT
#define I2C_MEMADD_SIZE_8BIT
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h:335
DISCOVERY_I2Cx_ER_IRQn
#define DISCOVERY_I2Cx_ER_IRQn
Definition: stm32f4_discovery.h:202
ACCELERO_IO_Read
void ACCELERO_IO_Read(uint8_t *pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead)
Reads a block of data from the Accelerometer.
Definition: stm32f4_discovery.c:592
BUTTON_PORT
GPIO_TypeDef * BUTTON_PORT[BUTTONn]
Definition: stm32f4_discovery.c:99
AUDIO_IO_Write
void AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value)
Writes a single data.
Definition: stm32f4_discovery.c:669
GPIO_PULLUP
#define GPIO_PULLUP
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:155
__STM32F4_DISCO_BSP_VERSION
#define __STM32F4_DISCO_BSP_VERSION
Definition: stm32f4_discovery.c:71
SPI_CRCCALCULATION_DISABLED
#define SPI_CRCCALCULATION_DISABLED
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h:1109
LED3_PIN
#define LED3_PIN
Definition: stm32f4_discovery.h:106
GPIO_PIN_RESET
@ GPIO_PIN_RESET
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:70
SPI_POLARITY_LOW
#define SPI_POLARITY_LOW
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:235
HAL_SPI_GetState
HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi)
ACCELERO_IO_ITConfig
void ACCELERO_IO_ITConfig(void)
Configures the Accelerometer INT2. EXTI0 is already used by user button so INT1 is not configured her...
Definition: stm32f4_discovery.c:533
DISCOVERY_I2Cx_SCL_PIN
#define DISCOVERY_I2Cx_SCL_PIN
Definition: stm32f4_discovery.h:194
KEY_BUTTON_PIN
#define KEY_BUTTON_PIN
Wakeup push-button.
Definition: stm32f4_discovery.h:144
DISCOVERY_I2Cx_CLK_ENABLE
#define DISCOVERY_I2Cx_CLK_ENABLE()
Definition: stm32f4_discovery.h:190
Button_TypeDef
Button_TypeDef
Definition: stm32f4_discovery.h:71
DISCOVERY_I2Cx_RELEASE_RESET
#define DISCOVERY_I2Cx_RELEASE_RESET()
Definition: stm32f4_discovery.h:198
SPI_InitTypeDef::CLKPolarity
uint32_t CLKPolarity
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:58
DISCOVERY_SPIx_GPIO_PORT
#define DISCOVERY_SPIx_GPIO_PORT
Definition: stm32f4_discovery.h:166
GPIO_TypeDef
General Purpose I/O.
Definition: stm32f407xx.h:527
SpiHandle
static SPI_HandleTypeDef SpiHandle
Definition: stm32f4_discovery.c:106
I2C_HandleTypeDef::Init
I2C_InitTypeDef Init
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h:193
LED6_GPIO_PORT
#define LED6_GPIO_PORT
Definition: stm32f4_discovery.h:117
DISCOVERY_SPIx_GPIO_CLK_ENABLE
#define DISCOVERY_SPIx_GPIO_CLK_ENABLE()
Definition: stm32f4_discovery.h:168
SPI_BAUDRATEPRESCALER_16
#define SPI_BAUDRATEPRESCALER_16
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:266
GPIO_MODE_AF_OD
#define GPIO_MODE_AF_OD
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:123
I2Cx_TIMEOUT_MAX
#define I2Cx_TIMEOUT_MAX
Definition: stm32f4_discovery.h:209
AUDIO_IO_Read
uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg)
Reads a single data.
Definition: stm32f4_discovery.c:680
SPI_NSS_SOFT
#define SPI_NSS_SOFT
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:253
Led_TypeDef
Led_TypeDef
Definition: stm32f4_discovery.h:63
GPIO_MODE_IT_RISING
#define GPIO_MODE_IT_RISING
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:127
BUTTONn
@ BUTTONn
Definition: stm32h747i_discovery.h:75
I2Cx_WriteData
static void I2Cx_WriteData(uint8_t Addr, uint8_t Reg, uint8_t Value)
Write a value in a register of the device through BUS.
Definition: stm32f4_discovery.c:414
ACCELERO_CS_GPIO_CLK_ENABLE
#define ACCELERO_CS_GPIO_CLK_ENABLE()
Definition: stm32f4_discovery.h:229
SPI_InitTypeDef::CRCPolynomial
uint32_t CRCPolynomial
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:83
I2C_HandleTypeDef
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h:188
GPIO_PULLDOWN
#define GPIO_PULLDOWN
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:156
SPI_DATASIZE_8BIT
#define SPI_DATASIZE_8BIT
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:226
ACCELERO_INT2_PIN
#define ACCELERO_INT2_PIN
Definition: stm32f4_discovery.h:236
BSP_LED_Toggle
void BSP_LED_Toggle(Led_TypeDef Led)
Toggles the selected LED.
Definition: stm32f4_discovery.c:225
HAL_NVIC_SetPriority
void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
MULTIPLEBYTE_CMD
#define MULTIPLEBYTE_CMD
Definition: stm32f4_discovery.h:216
I2C_InitTypeDef::ClockSpeed
uint32_t ClockSpeed
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h:50
SPI_InitTypeDef::DataSize
uint32_t DataSize
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:55
DUMMY_BYTE
#define DUMMY_BYTE
Definition: stm32f4_discovery.h:218
GPIO_MODE_OUTPUT_PP
#define GPIO_MODE_OUTPUT_PP
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:120
HAL_I2C_Mem_Read
HAL_StatusTypeDef HAL_I2C_Mem_Read(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout)
HAL_GPIO_TogglePin
void HAL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
SPI_InitTypeDef::TIMode
uint32_t TIMode
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:77
I2C_HandleTypeDef::Instance
I2C_TypeDef * Instance
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h:191
DISCOVERY_SPIx_AF
#define DISCOVERY_SPIx_AF
Definition: stm32f4_discovery.h:167
DISCOVERY_SPIx_MOSI_PIN
#define DISCOVERY_SPIx_MOSI_PIN
Definition: stm32f4_discovery.h:172
ACCELERO_INT_GPIO_CLK_ENABLE
#define ACCELERO_INT_GPIO_CLK_ENABLE()
Definition: stm32f4_discovery.h:232
Mode
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/extras/stb_vorbis.c:745
GPIO_MODE_INPUT
#define GPIO_MODE_INPUT
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:119
BSP_LED_Init
void BSP_LED_Init(Led_TypeDef Led)
Configures LED GPIO.
Definition: stm32f4_discovery.c:170
HAL_SPI_DeInit
HAL_StatusTypeDef HAL_SPI_DeInit(SPI_HandleTypeDef *hspi)
SPI_InitTypeDef::Direction
uint32_t Direction
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:52
SPI_InitTypeDef::CRCCalculation
uint32_t CRCCalculation
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:80
HAL_SPI_TransmitReceive
HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout)
DISCOVERY_SPIx_MISO_PIN
#define DISCOVERY_SPIx_MISO_PIN
Definition: stm32f4_discovery.h:171
LEDn
@ LEDn
Definition: stm32h747i_discovery.h:69
ACCELERO_CS_GPIO_PORT
#define ACCELERO_CS_GPIO_PORT
Definition: stm32f4_discovery.h:228
HAL_I2C_DeInit
HAL_StatusTypeDef HAL_I2C_DeInit(I2C_HandleTypeDef *hi2c)
ACCELERO_IO_Init
void ACCELERO_IO_Init(void)
Configures the Accelerometer SPI interface.
Definition: stm32f4_discovery.c:508
HAL_GPIO_WritePin
void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
BSP_PB_Init
void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Mode)
Configures Button GPIO and EXTI Line.
Definition: stm32f4_discovery.c:248
DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_ENABLE
#define DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_ENABLE()
Definition: stm32f4_discovery.h:191
SPIx_TIMEOUT_MAX
#define SPIx_TIMEOUT_MAX
Definition: stm32f4_discovery.h:179
GPIO_InitTypeDef::Pin
uint32_t Pin
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:49
HAL_SPI_Init
HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi)


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:14:51