pv_st_f411.c
Go to the documentation of this file.
1 /*
2  Copyright 2020-2021 Picovoice Inc.
3 
4  You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
5  file accompanying this source.
6 
7  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8  an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9  specific language governing permissions and limitations under the License.
10 */
11 
12 #include <stdbool.h>
13 #include <string.h>
14 
15 #include "stm32f411e_discovery.h"
16 
17 #include "pv_st_f411.h"
18 
19 #define UUID_ADDRESS (0x1FFF7A10)
20 #define UUID_SIZE (12)
21 
22 static uint8_t uuid[UUID_SIZE];
23 
25  RCC_ClkInitTypeDef RCC_ClkInitStruct;
26  RCC_OscInitTypeDef RCC_OscInitStruct;
29  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
30  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
31  RCC_OscInitStruct.HSICalibrationValue = 0x10;
32  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
33  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
34  RCC_OscInitStruct.PLL.PLLM = 16;
35  RCC_OscInitStruct.PLL.PLLN = 400;
36  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
37  RCC_OscInitStruct.PLL.PLLQ = 7;
38  if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
40  }
42  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
43  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
44  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
45  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
46  if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK) {
48  }
49  return PV_STATUS_SUCCESS;
50 }
51 
52 const uint8_t *pv_get_uuid(void) {
53  return (const uint8_t *) uuid;
54 }
55 
56 const uint32_t pv_get_uuid_size(void) {
57  return UUID_SIZE;
58 }
59 
61  if (HAL_Init() != HAL_OK) {
63  }
66  }
67  memcpy(uuid, (uint8_t *) UUID_ADDRESS, UUID_SIZE);
68 
73 
74  return PV_STATUS_SUCCESS;
75 }
76 
78 }
79 
80 void pv_error_handler(void) {
81  __disable_irq();
82  while(true);
83 }
84 
85 void assert_failed(uint8_t* file, uint32_t line)
86 {
87  (void) file;
88  (void) line;
90 }
91 
92 int __io_putchar(uint8_t ch) {
93  ITM_SendChar(ch);
94  return ch;
95 }
pv_board_init
pv_status_t pv_board_init()
Definition: pv_st_f411.c:60
RCC_PLLInitTypeDef::PLLQ
uint32_t PLLQ
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h:65
uuid
static uint8_t uuid[UUID_SIZE]
Definition: pv_st_f411.c:22
RCC_PLLSOURCE_HSI
#define RCC_PLLSOURCE_HSI
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:181
RCC_PLLInitTypeDef::PLLState
uint32_t PLLState
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h:49
FLASH_LATENCY_3
#define FLASH_LATENCY_3
Definition: stm32f7xx_hal_flash_ex.h:287
LED4
@ LED4
Definition: stm32f4_discovery.h:65
PV_STATUS_INVALID_STATE
@ PV_STATUS_INVALID_STATE
Definition: porcupine/include/picovoice.h:40
RCC_PLL_ON
#define RCC_PLL_ON
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:162
RCC_HCLK_DIV2
#define RCC_HCLK_DIV2
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:244
RCC_ClkInitTypeDef
RCC System, AHB and APB busses clock configuration structure definition.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:77
RCC_PLLInitTypeDef::PLLP
uint32_t PLLP
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h:62
RCC_OscInitTypeDef
RCC Internal/External Oscillator (HSE, HSI, LSE and LSI) configuration structure definition.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:51
RCC_OscInitTypeDef::HSICalibrationValue
uint32_t HSICalibrationValue
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:65
RCC_ClkInitTypeDef::APB2CLKDivider
uint32_t APB2CLKDivider
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:91
RCC_PLLInitTypeDef::PLLM
uint32_t PLLM
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h:55
__io_putchar
int __io_putchar(uint8_t ch)
Definition: pv_st_f411.c:92
__disable_irq
__STATIC_FORCEINLINE void __disable_irq(void)
Disable IRQ Interrupts.
Definition: imxrt1050/imxrt1050-evkb/CMSIS/cmsis_gcc.h:207
ITM_SendChar
__STATIC_INLINE uint32_t ITM_SendChar(uint32_t ch)
ITM Send Character.
Definition: imxrt1050/imxrt1050-evkb/CMSIS/core_cm7.h:2660
RCC_SYSCLKSOURCE_PLLCLK
#define RCC_SYSCLKSOURCE_PLLCLK
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:205
pv_error_handler
void pv_error_handler(void)
Definition: pv_st_f411.c:80
HAL_OK
@ HAL_OK
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:42
PWR_REGULATOR_VOLTAGE_SCALE2
#define PWR_REGULATOR_VOLTAGE_SCALE2
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h:75
LED6
@ LED6
Definition: stm32f4_discovery.h:68
pv_board_deinit
void pv_board_deinit()
Definition: pv_st_f411.c:77
RCC_CLOCKTYPE_PCLK1
#define RCC_CLOCKTYPE_PCLK1
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:192
RCC_OscInitTypeDef::HSIState
uint32_t HSIState
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:62
UUID_SIZE
#define UUID_SIZE
Definition: pv_st_f411.c:20
PV_STATUS_SUCCESS
@ PV_STATUS_SUCCESS
Definition: porcupine/include/picovoice.h:34
UUID_ADDRESS
#define UUID_ADDRESS
Definition: pv_st_f411.c:19
RCC_PLLInitTypeDef::PLLSource
uint32_t PLLSource
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h:52
pv_status_t
pv_status_t
Definition: porcupine/include/picovoice.h:33
HAL_RCC_ClockConfig
HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency)
RCC_ClkInitTypeDef::AHBCLKDivider
uint32_t AHBCLKDivider
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:85
RCC_OSCILLATORTYPE_HSI
#define RCC_OSCILLATORTYPE_HSI
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:110
RCC_HCLK_DIV1
#define RCC_HCLK_DIV1
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:243
HAL_RCC_OscConfig
HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct)
assert_failed
void assert_failed(uint8_t *file, uint32_t line)
Definition: pv_st_f411.c:85
RCC_OscInitTypeDef::PLL
RCC_PLLInitTypeDef PLL
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:71
RCC_ClkInitTypeDef::ClockType
uint32_t ClockType
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:79
RCC_CLOCKTYPE_PCLK2
#define RCC_CLOCKTYPE_PCLK2
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:193
RCC_CLOCKTYPE_SYSCLK
#define RCC_CLOCKTYPE_SYSCLK
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:190
LED3
@ LED3
Definition: stm32f4_discovery.h:66
HAL_Init
HAL_StatusTypeDef HAL_Init(void)
This function is used to initialize the HAL Library; it must be the first instruction to be executed ...
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:157
__HAL_RCC_PWR_CLK_ENABLE
#define __HAL_RCC_PWR_CLK_ENABLE()
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:512
RCC_CLOCKTYPE_HCLK
#define RCC_CLOCKTYPE_HCLK
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:191
RCC_SYSCLK_DIV1
#define RCC_SYSCLK_DIV1
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:227
pv_get_uuid_size
const uint32_t pv_get_uuid_size(void)
Definition: pv_st_f411.c:56
RCC_PLLP_DIV4
#define RCC_PLLP_DIV4
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:171
RCC_ClkInitTypeDef::SYSCLKSource
uint32_t SYSCLKSource
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:82
LED5
@ LED5
Definition: stm32f4_discovery.h:67
RCC_PLLInitTypeDef::PLLN
uint32_t PLLN
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h:58
pv_st_f411.h
RCC_OscInitTypeDef::OscillatorType
uint32_t OscillatorType
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:53
stm32f411e_discovery.h
This file contains definitions for STM32F401-Discovery Kit's Leds and push-button hardware resources.
RCC_HSI_ON
#define RCC_HSI_ON
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:141
RCC_ClkInitTypeDef::APB1CLKDivider
uint32_t APB1CLKDivider
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:88
BSP_LED_Init
void BSP_LED_Init(Led_TypeDef Led)
Configures LED GPIO.
Definition: stm32f4_discovery.c:170
__HAL_PWR_VOLTAGESCALING_CONFIG
#define __HAL_PWR_VOLTAGESCALING_CONFIG(__REGULATOR__)
macros configure the main internal regulator output voltage.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h:135
pv_clock_config
static pv_status_t pv_clock_config(void)
Definition: pv_st_f411.c:24
pv_get_uuid
const uint8_t * pv_get_uuid(void)
Definition: pv_st_f411.c:52


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