baseplatform stm32 f4 reference manual - jblopen · 2019. 7. 9. · contents v...

207
PM0003 July 9, 2019 JBLopen Embedded Soſtware Insight BASEplatform STM32 F4 Reference Manual

Upload: others

Post on 10-Feb-2021

6 views

Category:

Documents


0 download

TRANSCRIPT

  • PM0003

    July 9, 2019

    JBLopenEmbedded Software Insight

    BASEplatformSTM32F4ReferenceManual

  • Copyright© 2017-2019 JBLopen Inc.All rights reserved. No part of this document and any associated software may be reproduced,distributed or transmitted in any form or by any means without the prior written consent of JBLopen Inc.

    DisclaimerWhile JBLopen Inc. has made every attempt to ensure the accuracy of the information contained in thispublication, JBLopen Inc. cannot warrant the accuracy of completeness of such information. JBLopenInc. may change, add or remove any content in this publication at any time without notice.

    All the information contained in this publication as well as any associated material, including software,scripts, and examples are provided “as is”. JBLopen Inc. makes no express or implied warranty of anykind, including warranty of merchantability, noninfringement of intellectual property, or fitness for aparticular purpose. In no event shall JBLopen Inc. be held liable for any damage resulting from the useor inability to use the information contained therein or any other associated material.

    TrademarkJBLopen, the JBLopen logo, and BASEplatformTM are trademarks of JBLopen Inc. All other trademarksare trademarks or registered trademarks of their respective owners.

  • Contents

    1 Overview 1About the BASEplatform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Missing Module or API? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Elements of the API Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    Function Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Blocking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5ISR-Safe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Critical Safe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Thread-Safe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Function Attributes in Header Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    API Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Naming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Timeouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Numerical Values of Macros and Enumeration Constants . . . . . . . . . . . . . . . . . . . . 8

    Driver API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Advanced Driver API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Accessing the Drivers Directly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    STM32 F4 Specific Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9SoC Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9External Clocks Frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    2 STM32F4 Definitions 10bp_stm32f4_clk_gate_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10bp_stm32f4_clk_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13bp_stm32f4_int_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14bp_stm32f4_reset_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17BP_NVIC_SOC_DEF_INT_CNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20BP_STM32F4_GPIO_MAX_BANK_CNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20BP_STM32F4_BASE_* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Contents ii

    3 STM32F4 Reset and Clock Control 23bp_stm32f4_rcc_bd_reset() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23bp_stm32f4_rcc_clk_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23bp_stm32f4_rcc_clk_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24bp_stm32f4_rcc_clk_freq_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24bp_stm32f4_rcc_clk_id_is_valid() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25bp_stm32f4_rcc_clk_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25bp_stm32f4_rcc_css_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25bp_stm32f4_rcc_css_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26bp_stm32f4_rcc_css_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26bp_stm32f4_rcc_gate_id_is_valid() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26bp_stm32f4_rcc_hse_bypass_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27bp_stm32f4_rcc_hse_bypass_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27bp_stm32f4_rcc_hse_bypass_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27bp_stm32f4_rcc_hse_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28bp_stm32f4_rcc_hse_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28bp_stm32f4_rcc_hse_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28bp_stm32f4_rcc_hse_is_rdy() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29bp_stm32f4_rcc_hsi_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29bp_stm32f4_rcc_hsi_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29bp_stm32f4_rcc_hsi_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30bp_stm32f4_rcc_hsi_is_rdy() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30bp_stm32f4_rcc_hsical_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30bp_stm32f4_rcc_hsitrim_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31bp_stm32f4_rcc_hsitrim_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31bp_stm32f4_rcc_i2s_pll_cfg_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31bp_stm32f4_rcc_i2s_pll_cfg_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32bp_stm32f4_rcc_i2s_pll_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32bp_stm32f4_rcc_i2s_pll_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33bp_stm32f4_rcc_i2s_pll_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33bp_stm32f4_rcc_i2s_pll_is_rdy() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33bp_stm32f4_rcc_lpclk_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34bp_stm32f4_rcc_lpclk_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34bp_stm32f4_rcc_lse_bypass_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35bp_stm32f4_rcc_lse_bypass_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35bp_stm32f4_rcc_lse_bypass_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35bp_stm32f4_rcc_lse_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35bp_stm32f4_rcc_lse_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36bp_stm32f4_rcc_lse_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36bp_stm32f4_rcc_lse_is_rdy() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37bp_stm32f4_rcc_lse_mode_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37bp_stm32f4_rcc_lse_mode_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37bp_stm32f4_rcc_lsi_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38bp_stm32f4_rcc_lsi_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38bp_stm32f4_rcc_lsi_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38bp_stm32f4_rcc_lsi_is_rdy() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39bp_stm32f4_rcc_main_clk_cfg_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39bp_stm32f4_rcc_main_clk_cfg_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39bp_stm32f4_rcc_main_pll_cfg_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40bp_stm32f4_rcc_main_pll_cfg_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40bp_stm32f4_rcc_main_pll_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Contents iii

    bp_stm32f4_rcc_main_pll_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41bp_stm32f4_rcc_main_pll_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41bp_stm32f4_rcc_main_pll_is_rdy() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42bp_stm32f4_rcc_mco1_pre_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42bp_stm32f4_rcc_mco1_pre_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42bp_stm32f4_rcc_mco1_src_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43bp_stm32f4_rcc_mco1_src_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43bp_stm32f4_rcc_mco2_pre_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44bp_stm32f4_rcc_mco2_pre_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44bp_stm32f4_rcc_mco2_src_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44bp_stm32f4_rcc_mco2_src_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45bp_stm32f4_rcc_reset_assert() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45bp_stm32f4_rcc_reset_deassert() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46bp_stm32f4_rcc_reset_is_assert() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46bp_stm32f4_rcc_reset_is_valid() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46bp_stm32f4_rcc_rtc_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47bp_stm32f4_rcc_rtc_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47bp_stm32f4_rcc_rtc_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47bp_stm32f4_rcc_rtc_pre_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48bp_stm32f4_rcc_rtc_pre_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48bp_stm32f4_rcc_rtc_src_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49bp_stm32f4_rcc_rtc_src_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49bp_stm32f4_rcc_sai_pll_cfg_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49bp_stm32f4_rcc_sai_pll_cfg_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50bp_stm32f4_rcc_sai_pll_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50bp_stm32f4_rcc_sai_pll_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50bp_stm32f4_rcc_sai_pll_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51bp_stm32f4_rcc_sai_pll_is_rdy() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51bp_stm32f4_rcc_sys_clk_status_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52bp_stm32f4_rcc_sys_clk_switch_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52bp_stm32f4_rcc_sys_clk_switch_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52bp_stm32f4_rcc_lse_mode_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53bp_stm32f4_rcc_mco1_clk_sel_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53bp_stm32f4_rcc_mco2_clk_sel_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53bp_stm32f4_rcc_pll_src_sel_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54bp_stm32f4_rcc_rtc_src_sel_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54bp_stm32f4_rcc_sys_clk_sel_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54bp_stm32f4_rcc_i2s_pll_cfg_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55bp_stm32f4_rcc_main_clk_cfg_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55bp_stm32f4_rcc_pll_cfg_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55bp_stm32f4_rcc_sai_pll_cfg_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

    4 STM32F4 Embedded Flash Interface 57bp_stm32f4_flash_dcache_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57bp_stm32f4_flash_dcache_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57bp_stm32f4_flash_dcache_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58bp_stm32f4_flash_dcache_reset() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58bp_stm32f4_flash_icache_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58bp_stm32f4_flash_icache_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59bp_stm32f4_flash_icache_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59bp_stm32f4_flash_icache_reset() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Contents iv

    bp_stm32f4_flash_latency_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60bp_stm32f4_flash_latency_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60bp_stm32f4_flash_prefetch_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60bp_stm32f4_flash_prefetch_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61bp_stm32f4_flash_prefetch_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

    5 STM32F4 Power Control 62bp_stm32f4_over_drive_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62bp_stm32f4_pwr_adcdc1_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62bp_stm32f4_pwr_adcdc1_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63bp_stm32f4_pwr_adcdc1_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63bp_stm32f4_pwr_bre_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63bp_stm32f4_pwr_bre_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64bp_stm32f4_pwr_bre_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64bp_stm32f4_pwr_dbp_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64bp_stm32f4_pwr_dpb_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65bp_stm32f4_pwr_dpb_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65bp_stm32f4_pwr_flash_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65bp_stm32f4_pwr_flash_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66bp_stm32f4_pwr_flash_if_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66bp_stm32f4_pwr_flash_if_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66bp_stm32f4_pwr_flash_if_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67bp_stm32f4_pwr_flash_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67bp_stm32f4_pwr_flash_ods_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67bp_stm32f4_pwr_flash_over_drive_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68bp_stm32f4_pwr_flash_under_drive_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68bp_stm32f4_pwr_fpds_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68bp_stm32f4_pwr_fpds_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69bp_stm32f4_pwr_fpds_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69bp_stm32f4_pwr_lpds_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69bp_stm32f4_pwr_lpds_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70bp_stm32f4_pwr_lpds_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70bp_stm32f4_pwr_lpuds_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70bp_stm32f4_pwr_lpuds_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71bp_stm32f4_pwr_lpuds_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71bp_stm32f4_pwr_mruds_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71bp_stm32f4_pwr_mruds_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72bp_stm32f4_pwr_mruds_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72bp_stm32f4_pwr_od_is_rdy() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72bp_stm32f4_pwr_ods_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73bp_stm32f4_pwr_ods_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73bp_stm32f4_pwr_ods_is_rdy() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73bp_stm32f4_pwr_over_drive_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74bp_stm32f4_pwr_pdds_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74bp_stm32f4_pwr_pdds_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74bp_stm32f4_pwr_pdds_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75bp_stm32f4_pwr_pvd_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75bp_stm32f4_pwr_pvd_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75bp_stm32f4_pwr_pvd_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76bp_stm32f4_pwr_pvd_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76bp_stm32f4_pwr_pvd_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Contents v

    bp_stm32f4_pwr_sbf_is_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77bp_stm32f4_pwr_standby_flg_clr() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77bp_stm32f4_pwr_ud_is_rdy() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78bp_stm32f4_pwr_under_drive_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78bp_stm32f4_pwr_under_driver_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78bp_stm32f4_pwr_vos_is_rdy() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79bp_stm32f4_pwr_vos_scale_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79bp_stm32f4_pwr_vos_scale_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79bp_stm32f4_pwr_wakeup_flg_clr() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80bp_stm32f4_pwr_wuf_is_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80bp_stm32f4_pwr_wup1_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80bp_stm32f4_pwr_wup1_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81bp_stm32f4_pwr_wup1_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81bp_stm32f4_pwr_wup2_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81bp_stm32f4_pwr_wup2_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82bp_stm32f4_pwr_wup2_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82bp_stm32f4_pwr_pvd_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82bp_stm32f4_pwr_vos_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

    6 STM32F4 GPIO Multiplexer 84bp_stm32f4_gpio_mux_altf_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84bp_stm32f4_gpio_mux_altf_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85bp_stm32f4_gpio_mux_mode_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85bp_stm32f4_gpio_mux_mode_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86bp_stm32f4_gpio_mux_pupd_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86bp_stm32f4_gpio_mux_pupd_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87bp_stm32f4_gpio_mux_speed_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87bp_stm32f4_gpio_mux_speed_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88bp_stm32f4_gpio_mux_type_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88bp_stm32f4_gpio_mux_type_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89bp_stm32f4_gpio_mode_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89bp_stm32f4_gpio_pupd_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90bp_stm32f4_gpio_speed_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90bp_stm32f4_gpio_type_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

    7 ARM v7-M System Control 91bp_arch_v7m_afsr_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91bp_arch_v7m_bfar_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91bp_arch_v7m_bfhfnmign_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92bp_arch_v7m_bfhfnmign_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92bp_arch_v7m_bfhfnmign_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92bp_arch_v7m_bfsr_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93bp_arch_v7m_busfault_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93bp_arch_v7m_busfault_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93bp_arch_v7m_busfault_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94bp_arch_v7m_cfsr_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94bp_arch_v7m_cpacr_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94bp_arch_v7m_cpacr_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95bp_arch_v7m_cpuid_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95bp_arch_v7m_cpuid_impl_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95bp_arch_v7m_cpuid_pn_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Contents vi

    bp_arch_v7m_cpuid_rev_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96bp_arch_v7m_cpuid_var_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97bp_arch_v7m_div0_trp_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97bp_arch_v7m_div0_trp_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97bp_arch_v7m_div0_trp_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98bp_arch_v7m_endian_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98bp_arch_v7m_hfsr_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98bp_arch_v7m_icsr_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99bp_arch_v7m_ictr_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99bp_arch_v7m_memfault_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99bp_arch_v7m_memfault_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100bp_arch_v7m_memfault_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100bp_arch_v7m_mmfar_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100bp_arch_v7m_mmfsr_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101bp_arch_v7m_nonbasethrd_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101bp_arch_v7m_nonbasethrd_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101bp_arch_v7m_nonbasethrd_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102bp_arch_v7m_prigroup_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102bp_arch_v7m_prigroup_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102bp_arch_v7m_sevonpend_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103bp_arch_v7m_sevonpend_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103bp_arch_v7m_sevonpend_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103bp_arch_v7m_sh_prio_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104bp_arch_v7m_sh_prio_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104bp_arch_v7m_sh_status_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104bp_arch_v7m_sleepdeep_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105bp_arch_v7m_sleepdeep_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105bp_arch_v7m_sleepdeep_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105bp_arch_v7m_sleeponexit_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106bp_arch_v7m_sleeponexit_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106bp_arch_v7m_sleeponexit_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106bp_arch_v7m_stkalign_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107bp_arch_v7m_sysreset_req() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107bp_arch_v7m_ufsr_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107bp_arch_v7m_unalign_trp_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108bp_arch_v7m_unalign_trp_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108bp_arch_v7m_unalign_trp_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108bp_arch_v7m_usagefault_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109bp_arch_v7m_usagefault_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109bp_arch_v7m_usagefault_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109bp_arch_v7m_user_stir_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110bp_arch_v7m_user_stir_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110bp_arch_v7m_user_stir_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110bp_arch_v7m_vectactive_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111bp_arch_v7m_vectpending_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111bp_arch_v7m_vtor_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111bp_arch_v7m_vtor_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112BP_V7M_SH_STAT_* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

    8 ARM v7-M SysTick 113bp_v7m_systick_calib_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Contents vii

    bp_v7m_systick_calib_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113bp_v7m_systick_clk_src_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114bp_v7m_systick_clk_src_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114bp_v7m_systick_count_flag_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115bp_v7m_systick_counter_clr() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115bp_v7m_systick_counter_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115bp_v7m_systick_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116bp_v7m_systick_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116bp_v7m_systick_int_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116bp_v7m_systick_int_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116bp_v7m_systick_int_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117bp_v7m_systick_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117bp_v7m_systick_reload_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117bp_v7m_systick_reload_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

    9 ARM Cortex-M4 Control 119bp_arch_cm4_fold_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119bp_arch_cm4_fold_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119bp_arch_cm4_fold_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120bp_arch_cm4_fpca_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120bp_arch_cm4_fpca_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120bp_arch_cm4_fpca_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121bp_arch_cm4_mcycint_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121bp_arch_cm4_mcycint_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121bp_arch_cm4_mcycint_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122bp_arch_cm4_oofp_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122bp_arch_cm4_oofp_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122bp_arch_cm4_oofp_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

    10 STM32F4 GPIO Driver 124bp_stm32f4_gpio_create() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124bp_stm32f4_gpio_data_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125bp_stm32f4_gpio_data_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125bp_stm32f4_gpio_data_tog() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126bp_stm32f4_gpio_destroy() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126bp_stm32f4_gpio_dir_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127bp_stm32f4_gpio_dir_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127bp_stm32f4_gpio_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128bp_stm32f4_gpio_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128bp_stm32f4_gpio_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129bp_stm32f4_gpio_drv_def_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

    11 STM32 UART Driver 130bp_stm32_uart_cfg_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130bp_stm32_uart_cfg_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131bp_stm32_uart_create() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131bp_stm32_uart_destroy() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132bp_stm32_uart_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132bp_stm32_uart_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133bp_stm32_uart_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133bp_stm32_uart_reset() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Contents viii

    bp_stm32_uart_rx() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134bp_stm32_uart_rx_async() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135bp_stm32_uart_rx_async_abort() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135bp_stm32_uart_rx_flush() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136bp_stm32_uart_rx_idle_wait() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136bp_stm32_uart_tx() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137bp_stm32_uart_tx_async() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138bp_stm32_uart_tx_async_abort() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138bp_stm32_uart_tx_flush() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139bp_stm32_uart_tx_idle_wait() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139bp_stm32_uart_drv_def_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

    12 STM32 I2C Driver 141bp_stm32_i2c_cfg_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141bp_stm32_i2c_cfg_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142bp_stm32_i2c_create() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142bp_stm32_i2c_destroy() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143bp_stm32_i2c_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143bp_stm32_i2c_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144bp_stm32_i2c_flush() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144bp_stm32_i2c_idle_wait() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145bp_stm32_i2c_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145bp_stm32_i2c_reset() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146bp_stm32_i2c_xfer() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146bp_stm32_i2c_xfer_async() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147bp_stm32_i2c_xfer_async_abort() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147bp_stm32_i2c_drv_def_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148bp_stm32_i2c_param_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

    13 STM32 SPI Driver 149bp_stm32_spi_cfg_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149bp_stm32_spi_cfg_set() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150bp_stm32_spi_create() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150bp_stm32_spi_destroy() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151bp_stm32_spi_dis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151bp_stm32_spi_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152bp_stm32_spi_flush() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152bp_stm32_spi_idle_wait() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153bp_stm32_spi_is_en() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153bp_stm32_spi_last_err_get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154bp_stm32_spi_reset() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154bp_stm32_spi_slave_desel() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155bp_stm32_spi_slave_sel() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155bp_stm32_spi_xfer() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156bp_stm32_spi_xfer_async() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156bp_stm32_spi_xfer_async_abort() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157bp_stm32_spi_drv_def_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

    14 Error Codes 159RTNC_* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Contents ix

    15 GPIO Driver Reference 160bp_gpio_drv_create_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160bp_gpio_drv_data_get_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161bp_gpio_drv_data_set_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161bp_gpio_drv_data_tog_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162bp_gpio_drv_destroy_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162bp_gpio_drv_dir_get_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163bp_gpio_drv_dir_set_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163bp_gpio_drv_dis_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164bp_gpio_drv_en_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164bp_gpio_drv_is_en_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165bp_gpio_drv_reset_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165BP_GPIO_DRV_HNDL_IS_NULL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166BP_GPIO_DRV_NULL_HNDL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166

    16 I2C Driver Reference 167bp_i2c_drv_cfg_get_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167bp_i2c_drv_cfg_set_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168bp_i2c_drv_create_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168bp_i2c_drv_destroy_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169bp_i2c_drv_dis_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169bp_i2c_drv_en_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170bp_i2c_drv_flush_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170bp_i2c_drv_idle_wait_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171bp_i2c_drv_is_en_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171bp_i2c_drv_reset_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172bp_i2c_drv_xfer_async_abort_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172bp_i2c_drv_xfer_async_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173bp_i2c_drv_xfer_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173BP_I2C_DRV_HNDL_IS_NULL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174BP_I2C_DRV_NULL_HNDL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174

    17 SPI Driver Reference 175bp_spi_drv_cfg_get_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175bp_spi_drv_cfg_set_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176bp_spi_drv_create_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177bp_spi_drv_destroy_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177bp_spi_drv_dis_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178bp_spi_drv_en_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178bp_spi_drv_flush_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179bp_spi_drv_idle_wait_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179bp_spi_drv_is_en_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180bp_spi_drv_reset_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180bp_spi_drv_slave_desel_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180bp_spi_drv_slave_sel_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181bp_spi_drv_xfer_async_abort_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181bp_spi_drv_xfer_async_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182bp_spi_drv_xfer_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183BP_SPI_DRV_HNDL_IS_NULL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183BP_SPI_DRV_NULL_HNDL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Contents x

    18 UART Driver Reference 184bp_uart_cfg_get_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184bp_uart_drv_cfg_set_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185bp_uart_drv_create_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185bp_uart_drv_destroy_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186bp_uart_drv_dis_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186bp_uart_drv_en_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187bp_uart_drv_is_en_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187bp_uart_drv_reset_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188bp_uart_drv_rx_async_abort_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188bp_uart_drv_rx_async_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189bp_uart_drv_rx_flush_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189bp_uart_drv_rx_idle_wait_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190bp_uart_drv_rx_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190bp_uart_drv_tx_async_abort_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191bp_uart_drv_tx_async_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191bp_uart_drv_tx_flush_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192bp_uart_drv_tx_idle_wait_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192bp_uart_drv_tx_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193BP_UART_DRV_HNDL_IS_NULL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193BP_UART_DRV_NULL_HNDL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194

    19 Document Revision History 195

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • Chapter

    1Overview

    Welcome to the BASEplatformTM platform reference manual for the STMicroelectronics STM32® F4Series. This reference manual covers the platform-specific API relevant to the STM32 F4. Thisdocument includes important configuration information as well as the complete API reference for theSTM32 F4. The core API of the BASEplatform can be found in the BASEplatform API reference availableon the documentation section of the JBLopen website. Similarly to the core API, the platform-specificAPI is written in ISO/IEC 9899:1999 (C99) compliant C and designed to be portable across thetoolchains supporting the STM32 family.

    For convenience during development, all the information related to each individual API element is alsoreproduced within the relevant header source files in human readable format.

    About the BASEplatformThe BASEplatform is a collection of low-level interface modules, drivers and board support packages(BSPs) designed to provide the foundation for an embedded software application. The BASEplatformcan support a variety of free or commercial RTOSes as well as bare-metal applications, both inmulti-core and single core configurations. BASEplatform packages are created specifically for anapplication’s needs, and usually include support for an RTOS or bare-metal, low level I/Os, such as UART,I2C, GPIO etc. as well as communication and storage stacks, as selected by the application developer,alongside the necessary drivers, integration and IDE files to get everything working out of the box.

    Missing Module or API?The BASEplatform’s set of modules is developed prioritizing our customer’s need. If a needed module orAPI function is missing do not hesitate to inform us. In addition make sure to consult both theBASEplatform API reference manual as well as the platform-specific reference manual for a complete listof API and modules.

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 1 Overview 2

    Elements of the API ReferenceEach documented API element, be it a function, data type or preprocessor definition is presented usinga similar layout which are described below. This section briefly describes the various elements of theAPI reference.

    FunctionsThe most numerous and important API elements documented are functions. Below is an example of APIreference for a hypothetical function named bp_example_func():

    bp_example_func()Function

    Example function description.

    Prototype int bp_example_func ( uint32_t arg1,uint32_t arg2 );

    Attributes Blocking ISR-safe Critical safe Thread-safe

    7 3 3 3

    Parameters arg1 First argument’s description.arg2 Second argument’s description.

    ReturnedErrors

    RTNC_SUCCESSRTNC_FATAL

    Example

    uint32_t a = 0u;uint32_t b = 1u;int result;

    result = bp_example_func(a, b);if(result != RTNC_SUCCESS) \{

    // Handle error.\}

    Function NameAt the top of each API is the name of the function or object as it appears in the source code.BASEplatform functions are always prefixed with bp_ followed by the module name and then thefunction’s specific name.

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 1 Overview 3

    HeaderFollowing the name is the header file where the declaration of the documented API can be found. It isrecommended to use the displayed path relative to the root of the source directory of the BASEplatformwhen including BASEplatform’s headers.

    For example, to include the UART module header file bp_uart.h the following include directive isrecommended.

    #include

    The root of the BASEplatform source directory should be added to the include path of the compiler.

    DescriptionA description of the API element including basic usage information.

    PrototypeFor functions, the full signature of the API along with parameter names, types, and function return type.

    AttributesFor functions only, this section lists the relevant function attributes. See the function attributes sectionof this manual for a detailed description of each attribute.

    ParametersFunction parameters list along with a short description of each parameter.

    Returned Errors or Return ValuesFor functions that return a BASEplatform standard error code, this section is named Returned Errors andlists the relevant errors that can be returned. See the error handling convention section of this manualfor more information on the BASEplatform error handling.

    For other functions that do not return a standard error code, this section lists the possible output valuesof the function. In this case the section is named ”Returned Values”.

    ExampleSome API functions may include a small code example to illustrate usage. Note that these examples arefor documentation purpose and may not include error handling and checking to keep the examplesconcise.

    Data TypesData types include structure definitions, enumerated types as well as scalar type definitions. They allfollow a similar documentation layout, below is an example of API reference for a hypothetical structuredefinition named bp_example_struct_t:

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 1 Overview 4

    bp_example_struct_tData Type

    Example structure description.

    Members

    member1 uint32_t First member’s description.

    member2 uint32_t Second member’s description.

    Data Type NameAt the top of each API is the name of the data type as it appears in the source code. In the case ofstructures and enumerated types, this is always the typedef’d data type. BASEplatform types alwaysprefixed with bp_ followed by the module name and then the type’s specific name. Types are alsoalways suffixed with _t to differentiate them from other definitions.

    HeaderFollowing the name is the header file where the declaration of the documented API can be found. It isrecommended to use the displayed path relative to the root of the source directory of the BASEplatformwhen including BASEplatform’s headers.

    DescriptionA description of the data type including basic usage information.

    Members/Enumeration ValuesIf documented, the API reference will list the structure members or the list of enumeration constantsalong with a short description of each member. The list of members for opaque types with no publiclyaccessible members are omitted from the list of members in the API documentation.

    MacrosRelevant and preprocessor macros that are part of the public API are documented in the API reference.This includes function-like macros as well as object-like macros. The latter is often referred to aspreprocessor definitions or simply defines. Below is an example of function-like macro namedBP_EXAMPLE_MACRO():

    BP_EXAMPLE_MACRO()Macro

    Example macro description.

    Prototype BP_EXAMPLE_MACRO ( arg1,arg2 );

    Parameters arg1 First argument’s description.arg2 First argument’s description.

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 1 Overview 5

    Expansion Macro expansion’s description.

    Macro NameAt the top of each API is the name of the macro as it appears in the source code. BASEplatformpreprocessor definitions are always in capital letters and prefixed with BP_ followed by the modulename and then the macro’s specific name.

    HeaderFollowing the name is the header file where the declaration of the documented API can be found. It isrecommended to use the displayed path relative to the root of the source directory of the BASEplatformwhen including BASEplatform’s headers.

    DescriptionA description of the macro including basic usage information.

    ParametersMacro parameters list along with a short description of each parameter.

    ExpansionFor function-like macros an expansion section describes the macro’s expansion including the type ifapplicable.

    Function AttributesThe API reference documentation for API functions includes a set of attributes that clarifies in whichcontext it is safe to call a specific API function. The attributes are as follows:

    • Blocking• ISR-safe• Critical-safe• Thread-safe

    BlockingThe function is potentially blocking, which means it can wait or pend on a kernel object such as asemaphore or mutex, in order to wait for a resource to be available or for an operation to complete.Some functions may be optionally blocking depending on the function’s arguments. Those functions arealways marked as blocking in the API reference regardless.

    In a bare-metal environment, any function marked as blocking can potentially suspend the backgroundtask while waiting for a specific interrupt. Many of those functions take a timeout parameter that canbe set to 0 to make them non-blocking (polling) if suspension of the background task is undesired.

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 1 Overview 6

    As a general rule, blocking functions should not be called from an interrupt service routine, also knownas interrupt handler or while the CPU interrupts are disabled. In addition, some RTOSes allowsuspending or locking the scheduler, when this is the case, blocking functions should not be called whilethe scheduler is suspended or locked.

    ISR-SafeAn ISR-safe function can be called from within an interrupt service routine. This also includes callbackfunctions that are called from an interrupt context. Note that while an ISR-safe function is usuallycritical-safe this is not always the case. Also an ISR-safe function may not necessarily be thread-safe.

    Critical SafeCritical safe functions can be called when the CPU interrupts are disabled, this is also called a criticalcontext or sometimes a critical section. Critical sections are usually entered by calling a spinlock acquireor critical section enter function. Calling a non-critical-safe function from within a critical section cancorrupt the state of the CPU’s interrupt disable flags and cause runtime faults or data corruption.

    Thread-SafeA thread safe function guarantees correct operations between multiple threads or tasks when runningunder a multitasking kernel. In the context of the BASEplatform API, thread-safe also implies threadsafety on an SMP system, which means it is safe to use the API function from different threads inparallel. Due to the design of the BASEplatform, thread-safe functions are also re-entrant assuming thatthe other function attributes, such as ISR safety, are respected.

    Function Attributes in Header FilesFunction attributes are documented slightly differently in the source header files in order to be moreconcise and easier to maintain. The attributes are documented under an ”Attributes” section and arenamed as follows:

    • non-blocking• non-thread-safe• ISR-safe• critical-section-safe

    Absence of an attribute implies that the opposite attribute applies to the function. For example, in theabsence of any explicit function attribute in the header documentation, a function is assumed to beblocking, thread-safe and not safe to call from ISRs and critical sections.

    API ConventionsThe BASEplatform API adheres to a few conventions with respect to the naming, error handling andtimeouts that are useful for the application developers.

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 1 Overview 7

    NamingThe BASEplatform API function names are all written in lower case, except preprocessor macros whichare in upper case. Words within an object name are separated by underscores and the whole name isprefixed with bp_ followed by the module name and finally the function specific part of the name.

    For example, the time module function to get the current time is written as follows:

    bp_time_get()

    And the memory barrier macro from the architecture module, ”arch” for short, is named as follows:

    BP_ARCH_MB()

    Error HandlingMost API functions return a status in the form of a plain int as the function’s return value. As a generalexception, some functions that cannot fail are allowed to return nothing (void) or another value.

    In general, the BASEplatform attempts to minimize the number of different error codes to simplify theapplication’s error handling and improve performance. The list of possible error codes is included withinevery function’s documentation. The meaning of each error code is also documented in a function’sdescription. See the Error Codes chapter for a list of defined error codes.

    As with other preprocessor macros and enumeration constants, the application should never rely on theexact numerical value of any specific error code. However, two guarantees are made with respect to theerror code numerical values. The first is that RTNC_SUCCESS will always expand to 0. The second isthat all other error codes are negative. Positive values are not used for any valid error code. Anyundefined or unexpected error code returned by a function should be treated as a fatal error.

    Two error codes have the exact same meaning for all the functions, namely RTNC_SUCCESS andRTNC_FATAL.

    RTNC_SUCCESS is returned when a function completed successfully without issue.

    RTNC_FATAL is returned if and only if an unexpected situation that should not happen at runtime isdetected. This includes invalid function arguments, internal data corruption and assertion failures withinthe code. In addition, any unexpected error code returned from a function should be treated as a fatalerror. It is up to the application to decide on the proper action to perform upon receiving a fatal error.As a general rule, the application should not perform any other calls to that module instance. Safetycritical applications should consider an RTNC_FATAL error code as a severe assertion failure and actaccordingly.

    Some modules, especially IO modules such as UART and I2C, provides a reset API call that can be usedto reset the internal state of a module as well as the underlying peripheral. This can be used to attemptto recover from a fatal error in case the error condition is temporary.

    TimeoutsMost of the blocking functions have a timeout argument that takes a timeout value in milliseconds. Thetimeout period is guaranteed to be at least the requested value rounded up to the next multiple of thekernel’s tick rate if necessary. Internally, the BASEplatform modules and drivers will attempt to respectthe timeout value as closely as possible while guaranteeing the minimum timeout value. However, RTOS

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 1 Overview 8

    scheduling, higher priority tasks and interrupt response time may increase the amount of time taken toreturn from a timeout condition.

    For all functions that take a timeout value, specifying a timeout value of 0 means that the function willreturn immediately instead of blocking when having to wait on a mutex or an interrupt. A value ofTIMEOUT_INF or -1 will result in an infinite timeout.

    Numerical Values of Macros and Enumeration ConstantsTo ease maintainability and ensure compatibility with future versions, the application should never relyon enumeration constants and macros numerical value.

    Driver APIMany of the BASEplatform modules, especially the IO modules, use drivers to perform hardware access.In those situations the top-level module provides lifecycle management as well as thread-safety.However, it may be desirable in some circumstances to access the driver API directly. The various driverfunction signatures are gathered at the end of this manual but additional details may be available fromeach platform’s reference manual.

    Advanced Driver APIEach driver is allowed to implement additional, driver specific, functionalities not available from the toplevel module API. These functions are usually meant to control advanced features of the underlyingperipherals. Each I/O module provides an API to retrieve the driver’s handle which can be used toaccess those advanced functions directly. There is also an optional locking mechanism that can be usedto ensure thread safety while performing direct operations on the drivers.

    Accessing the Drivers DirectlyIt is also possible to access the drivers standard operation directly at the driver level. This reduces theoverhead associated the kernel mutexes and driver dereference at the cost of thread safety. As such,direct driver access should be done with care. As with the case of the advanced driver features, there isan optional exclusive lock mechanism that can be used to ensure thread safety.

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 1 Overview 9

    STM32 F4 Specific ConfigurationsSoC DefinitionThe generic definitions for the STM32 F4 SoC peripherals can be found insoc/stmicro/stm32f4/bp_stm32f4_soc_def.h. These can be used to write a custom boarddefinition.

    External Clocks FrequencySince there is no way for the BASEplatform to derive the input frequency of external clock inputs andexternal oscillators, they must be specified in the board definition file. For example:

    #define BP_STM32F4_BOARD_DEF_LSE_CLK_FREQ (32768U)

    #define BP_STM32F4_BOARD_DEF_HSE_CLK_FREQ (8000000U)

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • Chapter

    2STM32F4 Definitions

    STM32F4 global definitions. This module contains various definitions pertaining to the STM32 F4 seriesincluding interrupt, reset and clock lists as well as the base addresses of the various peripherals. Thesedefinitions are used in the SoC definition files for the STM32F4 but can also be used as input values forthe clock, reset and interrupt management modules.

    bp_stm32f4_clk_gate_tData Type

    STM32F4 clock gate list. These enumeration constants can be used with the clock management APIsuch as bp_clock_en() and bp_clock_dis().

    Values

    BP_STM32F4_CLK_GATE_OTGHS_ULPI USB OTG HS ULPI.

    BP_STM32F4_CLK_GATE_OTGHS USB OTG HS.

    BP_STM32F4_CLK_GATE_ETH_MAC_PTP Ethernet MAC PTP.

    BP_STM32F4_CLK_GATE_ETH_MAC_RX Ethernet MAC RX.

    BP_STM32F4_CLK_GATE_ETH_MAC_TX Ethernet MAC TX.

    BP_STM32F4_CLK_GATE_ETH_MAC Ethernet MAC.

    BP_STM32F4_CLK_GATE_DMA2D DMA2D.

    BP_STM32F4_CLK_GATE_DMA1 DMA1.

    BP_STM32F4_CLK_GATE_DMA2 DMA2.

    BP_STM32F4_CLK_GATE_CCM_DATA CCM Data RAM.

    BP_STM32F4_CLK_GATE_BKP Backup RAM.

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 2 STM32F4 Definitions 11

    BP_STM32F4_CLK_GATE_CRC CRC.

    BP_STM32F4_CLK_GATE_GPIOA GPIOA.

    BP_STM32F4_CLK_GATE_GPIOB GPIOB.

    BP_STM32F4_CLK_GATE_GPIOC GPIOC.

    BP_STM32F4_CLK_GATE_GPIOD GPIOD.

    BP_STM32F4_CLK_GATE_GPIOE GPIOE.

    BP_STM32F4_CLK_GATE_GPIOF GPIOF.

    BP_STM32F4_CLK_GATE_GPIOG GPIOG.

    BP_STM32F4_CLK_GATE_GPIOH GPIOH.

    BP_STM32F4_CLK_GATE_GPIOI GPIOI.

    BP_STM32F4_CLK_GATE_GPIOJ GPIOJ.

    BP_STM32F4_CLK_GATE_GPIOK GPIOK.

    BP_STM32F4_CLK_GATE_OTGFS USB OTG FS.

    BP_STM32F4_CLK_GATE_RNG RNG.

    BP_STM32F4_CLK_GATE_HASH HASH.

    BP_STM32F4_CLK_GATE_CRYP CRYP.

    BP_STM32F4_CLK_GATE_DCMI DCMI.

    BP_STM32F4_CLK_GATE_QSPI QSPI.

    BP_STM32F4_CLK_GATE_FMC FMC.

    BP_STM32F4_CLK_GATE_UART1 UART1.

    BP_STM32F4_CLK_GATE_UART2 UART2.

    BP_STM32F4_CLK_GATE_UART3 UART3.

    BP_STM32F4_CLK_GATE_UART4 UART4.

    BP_STM32F4_CLK_GATE_UART5 UART5.

    BP_STM32F4_CLK_GATE_UART6 UART6.

    BP_STM32F4_CLK_GATE_UART7 UART7.

    BP_STM32F4_CLK_GATE_UART8 UART8.

    BP_STM32F4_CLK_GATE_DAC DAC.

    BP_STM32F4_CLK_GATE_PWR PWR.

    BP_STM32F4_CLK_GATE_CAN1 CAN1.

    BP_STM32F4_CLK_GATE_CAN2 CAN2.

    BP_STM32F4_CLK_GATE_I2C1 I2C1.

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 2 STM32F4 Definitions 12

    BP_STM32F4_CLK_GATE_I2C2 I2C2.

    BP_STM32F4_CLK_GATE_I2C3 I2C3.

    BP_STM32F4_CLK_GATE_WWDOG WWDOG.

    BP_STM32F4_CLK_GATE_TIM1 TIM1.

    BP_STM32F4_CLK_GATE_TIM2 TIM2.

    BP_STM32F4_CLK_GATE_TIM3 TIM3.

    BP_STM32F4_CLK_GATE_TIM4 TIM4.

    BP_STM32F4_CLK_GATE_TIM5 TIM5.

    BP_STM32F4_CLK_GATE_TIM6 TIM6.

    BP_STM32F4_CLK_GATE_TIM7 TIM7.

    BP_STM32F4_CLK_GATE_TIM8 TIM8.

    BP_STM32F4_CLK_GATE_TIM9 TIM9.

    BP_STM32F4_CLK_GATE_TIM10 TIM10.

    BP_STM32F4_CLK_GATE_TIM11 TIM11.

    BP_STM32F4_CLK_GATE_TIM12 TIM12.

    BP_STM32F4_CLK_GATE_TIM13 TIM13.

    BP_STM32F4_CLK_GATE_TIM14 TIM14.

    BP_STM32F4_CLK_GATE_DSI DSI.

    BP_STM32F4_CLK_GATE_LTDC LTDC.

    BP_STM32F4_CLK_GATE_SAI1 SAI1.

    BP_STM32F4_CLK_GATE_SAI2 SAI2.

    BP_STM32F4_CLK_GATE_SPI1 SPI1.

    BP_STM32F4_CLK_GATE_SPI2 SPI2.

    BP_STM32F4_CLK_GATE_SPI3 SPI3.

    BP_STM32F4_CLK_GATE_SPI4 SPI4.

    BP_STM32F4_CLK_GATE_SPI5 SPI5.

    BP_STM32F4_CLK_GATE_SPI6 SPI6.

    BP_STM32F4_CLK_GATE_SYSCFG SYSCFG.

    BP_STM32F4_CLK_GATE_SDIO SDIO.

    BP_STM32F4_CLK_GATE_ADC1 ADC1.

    BP_STM32F4_CLK_GATE_ADC2 ADC2.

    BP_STM32F4_CLK_GATE_ADC3 ADC3.

    BP_STM32F4_CLK_GATE_NONE Special invalid value.

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 2 STM32F4 Definitions 13

    bp_stm32f4_clk_tData Type

    STM32F4 clock list. These enumeration constants can be used with the clock management API such asbp_clk_freq_get().

    Values

    BP_STM32F4_CLK_LSI Low speed internal.

    BP_STM32F4_CLK_LSE Low speed external.

    BP_STM32F4_CLK_HSI High speed internal.

    BP_STM32F4_CLK_HSE High speed external.

    BP_STM32F4_CLK_EXT External I2D clock input.

    BP_STM32F4_CLK_HSE_RTC High speed RTC input.

    BP_STM32F4_CLK_PLL Main PLL output.

    BP_STM32F4_CLK_PLL_48 Main PLL 48MHz output.

    BP_STM32F4_CLK_PLL_DSI Main PLL DSI output.

    BP_STM32F4_CLK_PLL_I2S I2S PLL I2S output.

    BP_STM32F4_CLK_PLL_I2S_SAI I2S PLL SAI output.

    BP_STM32F4_CLK_PLL_SAI SAI PLL SAI output.

    BP_STM32F4_CLK_PLL_SAI_48 SAI PLL 48MHz output.

    BP_STM32F4_CLK_PLL_SAI_LCD SAI PLL LCD output.

    BP_STM32F4_CLK_MCO1 MCO1 clock output.

    BP_STM32F4_CLK_MCO2 MCO2 clock output.

    BP_STM32F4_CLK_PTP Ethernet PTP.

    BP_STM32F4_CLK_HCLK AHB, Core and DMA clock.

    BP_STM32F4_CLK_SYS_CLK System clock.

    BP_STM32F4_CLK_CORTEX_TIM Cortex system timer clock.

    BP_STM32F4_CLK_CORTEX_FCLK Cortex free running clock.

    BP_STM32F4_CLK_APB1 APB1 peripheral clock.

    BP_STM32F4_CLK_APB1_TIM APB1 timer clock.

    BP_STM32F4_CLK_APB2 APB1 peripheral clock.

    BP_STM32F4_CLK_APB2_TIM APB1 timer clock.

    BP_STM32F4_CLK_48 48MHz clock.

    BP_STM32F4_CLK_SDIO SDIO clock.

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 2 STM32F4 Definitions 14

    BP_STM32F4_CLK_DSI DSI host clock.

    BP_STM32F4_CLK_I2S I2S clock.

    BP_STM32F4_CLK_SAI1_A SAI1_A clock.

    BP_STM32F4_CLK_SAI1_B SAI1_B clock.

    BP_STM32F4_CLK_LCD_TFT LCD TFT clock.

    BP_STM32F4_CLK_NONE Special invalid value.

    bp_stm32f4_int_tData Type

    STM32F4 interrupt list. These enumeration constants can be used with the interrupt management APIsuch as bp_int_reg() and bp_int_src_en() for convenience.

    Values

    BP_STM32F4_INT_RSVD0 Reserved.

    BP_STM32F4_INT_RSVD1 Reserved.

    BP_STM32F4_INT_NMI ARMv7M NMI.

    BP_STM32F4_INT_HARD_FAULT ARMv7M Hard fault.

    BP_STM32F4_INT_MM_FAULT ARMv7M Memory management fault.

    BP_STM32F4_INT_BUS_FAULT ARMv7M bus fault.

    BP_STM32F4_INT_USAGE_FAULT ARMv7M usage fault.

    BP_STM32F4_INT_SEC_FAULT ARMv7M secure fault.

    BP_STM32F4_INT_RSVD2 Reserved.

    BP_STM32F4_INT_RSVD3 Reserved.

    BP_STM32F4_INT_RSVD4 Reserved.

    BP_STM32F4_INT_SVC ARMv7M SVC.

    BP_STM32F4_INT_DEBUG ARMv7M Debug monitor.

    BP_STM32F4_INT_RSVD5 Reserved.

    BP_STM32F4_INT_PENDSV ARMv7M PendSV.

    BP_STM32F4_INT_SYSTICK ARMv7M SysTick.

    BP_STM32F4_INT_WWDOG Window watchdog.

    BP_STM32F4_INT_PVD PVD.

    BP_STM32F4_INT_TAMP Tamper and TimeStamp.

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 2 STM32F4 Definitions 15

    BP_STM32F4_INT_RTC_WKUP RTC Wakeup.

    BP_STM32F4_INT_FLASH Flash.

    BP_STM32F4_INT_RCC RCC.

    BP_STM32F4_INT_EXTI0 EXTI0.

    BP_STM32F4_INT_EXTI1 EXTI1.

    BP_STM32F4_INT_EXTI2 EXTI2.

    BP_STM32F4_INT_EXTI3 EXTI3.

    BP_STM32F4_INT_EXTI4 EXTI4.

    BP_STM32F4_INT_DMA1S0 DMA1 STREAM0.

    BP_STM32F4_INT_DMA1S1 DMA1 STREAM1.

    BP_STM32F4_INT_DMA1S2 DMA1 STREAM2.

    BP_STM32F4_INT_DMA1S3 DMA1 STREAM3.

    BP_STM32F4_INT_DMA1S4 DMA1 STREAM4.

    BP_STM32F4_INT_DMA1S5 DMA1 STREAM5.

    BP_STM32F4_INT_DMA1S6 DMA1 STREAM6.

    BP_STM32F4_INT_ADC ADC.

    BP_STM32F4_INT_CAN1_TX CAN1 Transmit.

    BP_STM32F4_INT_CAN1_RX0 CAN1 Receive 0.

    BP_STM32F4_INT_CAN1_RX1 CAN1 Receive 1.

    BP_STM32F4_INT_CAN1_SCE CAN1 SCE.

    BP_STM32F4_INT_EXTI9_5 EXTI 5 to 9.

    BP_STM32F4_INT_TIM1_BRK_TIM9 Timer1 break and timer 9 global.

    BP_STM32F4_INT_TIM1_UP_TIM10 Timer1 update and timer 10 global.

    BP_STM32F4_INT_TIM1_TRIG_TIM11 Timer1 trigger and timer 11 global.

    BP_STM32F4_INT_TIM1_CC Timer1 compare.

    BP_STM32F4_INT_TIM2 Timer2 global.

    BP_STM32F4_INT_TIM3 Timer3 global.

    BP_STM32F4_INT_TIM4 Timer4 global.

    BP_STM32F4_INT_I2C1_EV I2C1 event.

    BP_STM32F4_INT_I2C1_ER I2C1 error.

    BP_STM32F4_INT_I2C2_EV I2C2 event.

    BP_STM32F4_INT_I2C2_ER I2C2 error.

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 2 STM32F4 Definitions 16

    BP_STM32F4_INT_SPI1 SPI1.

    BP_STM32F4_INT_SPI2 SPI2.

    BP_STM32F4_INT_UART1 USART1.

    BP_STM32F4_INT_UART2 USART2.

    BP_STM32F4_INT_UART3 USART3.

    BP_STM32F4_INT_EXTI10_15 EXTI 10 to 15.

    BP_STM32F4_INT_RTC_ALARM RTC alarm.

    BP_STM32F4_INT_OTG_FS_WKUP USB OTG FS wakeup.

    BP_STM32F4_INT_TIM8_BRK_TIM12 Timer 8 break and timer 12 global.

    BP_STM32F4_INT_TIM8_UP_TIM13 Timer 8 update and timer 13 global.

    BP_STM32F4_INT_TIM8_TRIG_TIM14 Timer 8 trigger and timer 14 global.

    BP_STM32F4_INT_TIM8_CC Timer 8 compare.

    BP_STM32F4_INT_DMA1S7 DAM1 STREAM7.

    BP_STM32F4_INT_FMC FMC.

    BP_STM32F4_INT_SDIO SDIO.

    BP_STM32F4_INT_TIM5 TIM5.

    BP_STM32F4_INT_SPI3 SPI3.

    BP_STM32F4_INT_UART4 USART4.

    BP_STM32F4_INT_UART5 USART5.

    BP_STM32F4_INT_TIM6_DAC Timer 6 global and DAC1/2 underrun.

    BP_STM32F4_INT_TIM7 Timer 7.

    BP_STM32F4_INT_DMA2S0 DMA2 STREAM0.

    BP_STM32F4_INT_DMA2S1 DMA2 STREAM1.

    BP_STM32F4_INT_DMA2S2 DMA2 STREAM2.

    BP_STM32F4_INT_DMA2S3 DMA2 STREAM3.

    BP_STM32F4_INT_DMA2S4 DMA2 STREAM4.

    BP_STM32F4_INT_ETH Ethernet.

    BP_STM32F4_INT_ETH_WKUP Ethernet wakeup.

    BP_STM32F4_INT_CAN2_TX CAN2 Transmit.

    BP_STM32F4_INT_CAN2_RX0 CAN2 Receive 0.

    BP_STM32F4_INT_CAN2_RX1 CAN2 Receive 1.

    BP_STM32F4_INT_CAN2_SCE CAN2 SCE.

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 2 STM32F4 Definitions 17

    BP_STM32F4_INT_OTG_FS OTG_FS.

    BP_STM32F4_INT_DMA2S5 DMA2 STREAM5.

    BP_STM32F4_INT_DMA2S6 DMA2 STREAM6.

    BP_STM32F4_INT_DMA2S7 DMA2 STREAM7.

    BP_STM32F4_INT_UART6 USART6.

    BP_STM32F4_INT_I2C3_EV I2C3 event.

    BP_STM32F4_INT_I2C3_ER I2C3 error.

    BP_STM32F4_INT_OTG_HS_EP1_OUT USB OTG HS endpoint 1 out.

    BP_STM32F4_INT_OTG_HS_EP1_IN USB OTG HS endpoint 1 in.

    BP_STM32F4_INT_OTG_HS_WKUP USB OTG HS wakeup.

    BP_STM32F4_INT_OTG_HS USB OTG HS.

    BP_STM32F4_INT_DCMI DCMI.

    BP_STM32F4_INT_CRYP CRYP.

    BP_STM32F4_INT_HASH_RNG HASH and RNG global.

    BP_STM32F4_INT_FPU FPU.

    BP_STM32F4_INT_UART7 UART7.

    BP_STM32F4_INT_UART8 UART8.

    BP_STM32F4_INT_SPI4 SPI4.

    BP_STM32F4_INT_SPI5 SPI5.

    BP_STM32F4_INT_SPI6 SPI6.

    BP_STM32F4_INT_SAI1 SAI1.

    BP_STM32F4_INT_LCD LCD global.

    BP_STM32F4_INT_LCD_ER LCD error.

    BP_STM32F4_INT_DMA2D DMA2D.

    BP_STM32F4_INT_QSPI QSPI.

    BP_STM32F4_INT_DSI DSI.

    BP_STM32F4_INT_NONE Special invalid value.

    bp_stm32f4_reset_tData Type

    STM32F4 reset list. These enumeration constants can be used with the reset management API such asbp_periph_reset_assert() and bp_periph_reset_deassert().

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 2 STM32F4 Definitions 18

    Values

    BP_STM32F4_RESET_OTGHS USB OTG HS.

    BP_STM32F4_RESET_ETH Ethernet MAC.

    BP_STM32F4_RESET_DMA2D DMA2D.

    BP_STM32F4_RESET_DMA1 DMA1.

    BP_STM32F4_RESET_DMA2 DMA2.

    BP_STM32F4_RESET_CRC CRC.

    BP_STM32F4_RESET_GPIOA GPIOA.

    BP_STM32F4_RESET_GPIOB GPIOB.

    BP_STM32F4_RESET_GPIOC GPIOC.

    BP_STM32F4_RESET_GPIOD GPIOD.

    BP_STM32F4_RESET_GPIOE GPIOE.

    BP_STM32F4_RESET_GPIOF GPIOF.

    BP_STM32F4_RESET_GPIOG GPIOG.

    BP_STM32F4_RESET_GPIOH GPIOH.

    BP_STM32F4_RESET_GPIOI GPIOI.

    BP_STM32F4_RESET_GPIOJ GPIOJ.

    BP_STM32F4_RESET_GPIOK GPIOK.

    BP_STM32F4_RESET_OTGFS USB OTG FS.

    BP_STM32F4_RESET_RNG RNG.

    BP_STM32F4_RESET_HASH HASH.

    BP_STM32F4_RESET_CRYP CRYP.

    BP_STM32F4_RESET_DCMI DCMI.

    BP_STM32F4_RESET_QSPI QSPI.

    BP_STM32F4_RESET_FMC FMC.

    BP_STM32F4_RESET_UART1 UART1.

    BP_STM32F4_RESET_UART2 UART2.

    BP_STM32F4_RESET_UART3 UART3.

    BP_STM32F4_RESET_UART4 UART4.

    BP_STM32F4_RESET_UART5 UART5.

    BP_STM32F4_RESET_UART6 UART6.

    BP_STM32F4_RESET_UART7 UART7.

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 2 STM32F4 Definitions 19

    BP_STM32F4_RESET_UART8 UART8.

    BP_STM32F4_RESET_DAC DAC.

    BP_STM32F4_RESET_PWR PWR.

    BP_STM32F4_RESET_CAN1 CAN1.

    BP_STM32F4_RESET_CAN2 CAN2.

    BP_STM32F4_RESET_I2C1 I2C1.

    BP_STM32F4_RESET_I2C2 I2C2.

    BP_STM32F4_RESET_I2C3 I2C3.

    BP_STM32F4_RESET_SPI1 SPI1.

    BP_STM32F4_RESET_SPI2 SPI2.

    BP_STM32F4_RESET_SPI3 SPI3.

    BP_STM32F4_RESET_SPI4 SPI4.

    BP_STM32F4_RESET_SPI5 SPI5.

    BP_STM32F4_RESET_SPI6 SPI6.

    BP_STM32F4_RESET_WWDG WWDG.

    BP_STM32F4_RESET_TIM1 TIM1.

    BP_STM32F4_RESET_TIM2 TIM2.

    BP_STM32F4_RESET_TIM3 TIM3.

    BP_STM32F4_RESET_TIM4 TIM4.

    BP_STM32F4_RESET_TIM5 TIM5.

    BP_STM32F4_RESET_TIM6 TIM6.

    BP_STM32F4_RESET_TIM7 TIM7.

    BP_STM32F4_RESET_TIM8 TIM8.

    BP_STM32F4_RESET_TIM9 TIM9.

    BP_STM32F4_RESET_TIM10 TIM10.

    BP_STM32F4_RESET_TIM11 TIM11.

    BP_STM32F4_RESET_TIM12 TIM12.

    BP_STM32F4_RESET_TIM13 TIM13.

    BP_STM32F4_RESET_TIM14 TIM14.

    BP_STM32F4_RESET_DSI DSI.

    BP_STM32F4_RESET_LTDC LTDC.

    BP_STM32F4_RESET_SAI1 SAI1.

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 2 STM32F4 Definitions 20

    BP_STM32F4_RESET_SAI2 SAI2.

    BP_STM32F4_RESET_SYSCFG SYSCFG.

    BP_STM32F4_RESET_SDIO SDIO.

    BP_STM32F4_RESET_ADC ADC.

    BP_STM32F4_RESET_NONE Special invalid value.

    BP_NVIC_SOC_DEF_INT_CNTMacro

    Number of NVIC interrupts.

    BP_STM32F4_GPIO_MAX_BANK_CNTMacro

    Maximum possible bank count for the STM32 F4 series.

    BP_STM32F4_BASE_*Macro

    Description STM32F4 peripheral base addresses.

    BP_STM32F4_BASE_BKPSRAM_MEM_START BACKUP SRAM START

    BP_STM32F4_BASE_FMC FMC

    BP_STM32F4_BASE_QSPI QSPI

    BP_STM32F4_BASE_RNG RNG

    BP_STM32F4_BASE_HASH HASH

    BP_STM32F4_BASE_CRYP CRYP

    BP_STM32F4_BASE_DCMI DCMI

    BP_STM32F4_BASE_USBFS USB OTG FS

    BP_STM32F4_BASE_USBHS USB OTG HS

    BP_STM32F4_BASE_DMA2D DMA2D

    BP_STM32F4_BASE_ETH ETHERNET

    BP_STM32F4_BASE_DMA2 DMA2

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 2 STM32F4 Definitions 21

    BP_STM32F4_BASE_DMA1 DMA1

    BP_STM32F4_BASE_FLASH FLASH INTERFACE

    BP_STM32F4_BASE_RCC RCC

    BP_STM32F4_BASE_CRC CRC

    BP_STM32F4_BASE_GPIOK GPIOK

    BP_STM32F4_BASE_GPIOJ GPIOJ

    BP_STM32F4_BASE_GPIOI GPIOI

    BP_STM32F4_BASE_GPIOH GPIOH

    BP_STM32F4_BASE_GPIOG GPIOG

    BP_STM32F4_BASE_GPIOF GPIOF

    BP_STM32F4_BASE_GPIOE GPIOE

    BP_STM32F4_BASE_GPIOD GPIOD

    BP_STM32F4_BASE_GPIOC GPIOC

    BP_STM32F4_BASE_GPIOB GPIOB

    BP_STM32F4_BASE_GPIOA GPIOA

    BP_STM32F4_BASE_DSI DSI HOST

    BP_STM32F4_BASE_LCD LCD TFT

    BP_STM32F4_BASE_SAI1 SAI1

    BP_STM32F4_BASE_SPI6 SPI6

    BP_STM32F4_BASE_SPI5 SPI5

    BP_STM32F4_BASE_TIM11 TIM11

    BP_STM32F4_BASE_TIM10 TIM10

    BP_STM32F4_BASE_TIM9 TIM9

    BP_STM32F4_BASE_EXTI EXTI

    BP_STM32F4_BASE_SYSCFG SYSCFG

    BP_STM32F4_BASE_SPI4 SPI4

    BP_STM32F4_BASE_SPI1 SPI1

    BP_STM32F4_BASE_SDIO SDIO

    BP_STM32F4_BASE_ADC ADC

    BP_STM32F4_BASE_UART6 USART6

    BP_STM32F4_BASE_UART1 USART1

    BP_STM32F4_BASE_TIM8 TIM8

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 2 STM32F4 Definitions 22

    BP_STM32F4_BASE_TIM1 TIM1

    BP_STM32F4_BASE_USART8 USART8

    BP_STM32F4_BASE_USART7 USART7

    BP_STM32F4_BASE_DAC DAC

    BP_STM32F4_BASE_PWR PWR

    BP_STM32F4_BASE_CAN2 CAN2

    BP_STM32F4_BASE_CAN1 CAN1

    BP_STM32F4_BASE_I2C3 I2C3

    BP_STM32F4_BASE_I2C2 I2C2

    BP_STM32F4_BASE_I2C1 I2C1

    BP_STM32F4_BASE_UART5 USART5

    BP_STM32F4_BASE_UART4 USART4

    BP_STM32F4_BASE_UART3 USART3

    BP_STM32F4_BASE_UART2 USART2

    BP_STM32F4_BASE_I2S3 I2S3

    BP_STM32F4_BASE_SPI3 SPI3

    BP_STM32F4_BASE_SPI2 SPI2

    BP_STM32F4_BASE_I2S2 I2S2

    BP_STM32F4_BASE_IWDG IWDG

    BP_STM32F4_BASE_WWDG WWDG

    BP_STM32F4_BASE_RTC RTC

    BP_STM32F4_BASE_TIM14 TIM14

    BP_STM32F4_BASE_TIM13 TIM13

    BP_STM32F4_BASE_TIM12 TIM12

    BP_STM32F4_BASE_TIM7 TIM7

    BP_STM32F4_BASE_TIM6 TIM6

    BP_STM32F4_BASE_TIM5 TIM5

    BP_STM32F4_BASE_TIM4 TIM4

    BP_STM32F4_BASE_TIM3 TIM3

    BP_STM32F4_BASE_TIM2 TIM2

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • Chapter

    3STM32F4 Reset and Clock Control

    Interface module to the STM32 F4 Reset and Clock Control (RCC). This module also provides theimplementation of the BASEplatform clock and reset modules. Note that the generic clock and resetmodules can be used to manipulate the clock and reset lines at a higher level using a portable API.

    bp_stm32f4_rcc_bd_reset()Function

    Resets the backup domain.

    Prototype void bp_stm32f4_rcc_bd_reset ( );

    Attributes Blocking ISR-safe Critical safe Thread-safe

    7 3 3 3

    bp_stm32f4_rcc_clk_dis()Function

    Disables a specific clock.

    Prototype int bp_stm32f4_rcc_clk_dis ( bp_stm32f4_clk_gate_t clk );

    Attributes Blocking ISR-safe Critical safe Thread-safe

    7 3 3 3

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 3 STM32F4 Reset and Clock Control 24

    Parameters clk Clock to disable.

    ReturnedErrors

    RTNC_SUCCESSRTNC_FATAL

    bp_stm32f4_rcc_clk_en()Function

    Enables a specific clock.

    Prototype int bp_stm32f4_rcc_clk_en ( bp_stm32f4_clk_gate_t clk );

    Attributes Blocking ISR-safe Critical safe Thread-safe

    7 3 3 3

    Parameters clk Clock to enable.

    ReturnedErrors

    RTNC_SUCCESSRTNC_FATAL

    bp_stm32f4_rcc_clk_freq_get()Function

    Returns the frequency of a specific clock in Hertz.

    Prototype int bp_stm32f4_rcc_clk_freq_get ( bp_stm32f4_clk_t clk,uint32_t * p_clk_freq );

    Attributes Blocking ISR-safe Critical safe Thread-safe

    7 3 3 3

    Parameters clk Clock to query.p_clk_freq Pointer to the returned clock frequency in Hertz.

    ReturnedErrors

    RTNC_SUCCESSRTNC_FATAL

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 3 STM32F4 Reset and Clock Control 25

    bp_stm32f4_rcc_clk_id_is_valid()Function

    Prototype bool bp_stm32f4_rcc_clk_id_is_valid ( bp_stm32f4_clk_t clk );

    Attributes Blocking ISR-safe Critical safe Thread-safe

    7 3 3 3

    Parameters clk Clock id to check.

    ReturnedValues

    true if the clock id is valid, false otherwise.

    bp_stm32f4_rcc_clk_is_en()Function

    Returned the state of a specific clock. Returns true through p_is_en if the clock clk is enabled,false otherwise.

    Prototype int bp_stm32f4_rcc_clk_is_en ( bp_stm32f4_clk_gate_t clk,bool * p_is_en );

    Attributes Blocking ISR-safe Critical safe Thread-safe

    7 3 3 3

    Parameters clk Clock to query.p_is_en Pointer to the returned state.

    ReturnedErrors

    RTNC_SUCCESSRTNC_FATAL

    bp_stm32f4_rcc_css_dis()Function

    Disables the clock security systems.

    Prototype void bp_stm32f4_rcc_css_dis ( );

    BASEplatform STM32 F4 Reference Manual www.jblopen.com

    https://www.jblopen.com

  • JBLopenEmbedded Software Insight Chapter 3 STM32F4 Reset and Clock Control 26

    Attributes Blocking ISR-safe Critical safe Thread-safe

    7 3 3 3

    bp_stm32f4_rcc_css_en()Function

    Enables the clock security system.

    Prototype void bp_stm32f4_rcc_css_en ( );

    Attributes Blocking ISR-safe Critical safe Thread-safe

    7 3 3 3

    bp_stm32f4_rcc_css_is_en()Function

    Returns the enabled/disabled state of the clock security system.

    Prototype bool bp_stm32f4_rcc_css_is_en ( );

    Attributes Blocking ISR-safe Critical safe Thread-safe

    7 3 3 3

    bp_stm32f4_rcc_gate_id_is_valid()Function

    Prototype bool bp_stm32f4_rcc_gate_id_is_valid ( bp_stm32f4_clk_gate_t clk_gate );

    Attributes Blocking ISR-safe Critical safe Thread-safe

    7 3 3 3

    Parameters clk_gate Clock gate id to check.

    BASEplatform STM32 F4 Referen