├── source ├── CMakeLists.txt ├── nucleo-f446ze-library │ ├── Libraries │ │ ├── CMakeLists.txt │ │ ├── Middleware │ │ │ ├── CMakeLists.txt │ │ │ ├── Include │ │ │ │ └── led.h │ │ │ └── Src │ │ │ │ └── led.c │ │ └── Drivers │ │ │ ├── CMakeLists.txt │ │ │ ├── Include │ │ │ └── gpio.h │ │ │ └── Src │ │ │ └── gpio.c │ ├── BuildArtifacts │ │ └── libnucleo-f446ze-library.a │ ├── CMakeLists.txt │ ├── Drivers │ │ ├── CMSIS │ │ │ ├── Device │ │ │ │ └── ST │ │ │ │ │ └── STM32F4xx │ │ │ │ │ ├── LICENSE.txt │ │ │ │ │ └── Include │ │ │ │ │ └── system_stm32f4xx.h │ │ │ └── Include │ │ │ │ ├── cmsis_version.h │ │ │ │ └── tz_context.h │ │ └── STM32F4xx_HAL_Driver │ │ │ ├── LICENSE.txt │ │ │ └── Inc │ │ │ ├── stm32_assert_template.h │ │ │ ├── stm32f4xx_hal_flash_ramfunc.h │ │ │ ├── stm32f4xx_hal_ltdc_ex.h │ │ │ ├── stm32f4xx_hal_dma_ex.h │ │ │ ├── stm32f4xx_hal_i2c_ex.h │ │ │ ├── stm32f4xx_hal_pcd_ex.h │ │ │ ├── stm32f4xx_hal_cryp_ex.h │ │ │ ├── stm32f4xx_hal_sai_ex.h │ │ │ ├── stm32f4xx_hal_fmpsmbus_ex.h │ │ │ ├── stm32f4xx_hal_fmpi2c_ex.h │ │ │ ├── stm32f4xx_hal_crc.h │ │ │ ├── stm32f4xx_ll_crc.h │ │ │ ├── stm32f4xx_hal_iwdg.h │ │ │ └── stm32f4xx_hal_hash_ex.h │ ├── .project │ ├── .mxproject │ └── Src │ │ ├── sysmem.c │ │ └── syscalls.c └── stm32-cube-ide │ ├── Drivers │ ├── CMSIS │ │ ├── Device │ │ │ └── ST │ │ │ │ └── STM32F4xx │ │ │ │ ├── LICENSE.txt │ │ │ │ └── Include │ │ │ │ └── system_stm32f4xx.h │ │ └── Include │ │ │ ├── cmsis_version.h │ │ │ └── tz_context.h │ └── STM32F4xx_HAL_Driver │ │ ├── LICENSE.txt │ │ ├── Inc │ │ ├── stm32f4xx_hal_flash_ramfunc.h │ │ ├── stm32f4xx_hal_dma_ex.h │ │ ├── stm32f4xx_hal_pcd_ex.h │ │ └── stm32f4xx_hal_def.h │ │ └── Src │ │ └── stm32f4xx_hal_flash_ramfunc.c │ ├── BSP │ ├── Include │ │ └── bsp.h │ └── Src │ │ └── bsp.c │ ├── .project │ ├── Core │ ├── Inc │ │ ├── stm32f4xx_it.h │ │ └── main.h │ └── Src │ │ ├── sysmem.c │ │ ├── syscalls.c │ │ ├── stm32f4xx_it.c │ │ └── stm32f4xx_hal_msp.c │ ├── STM32F446ZETX_RAM.ld │ ├── STM32F446ZETX_FLASH.ld │ └── .mxproject ├── docs ├── images │ ├── stm32_gtest.gif │ └── dependency_graph.png └── Doxyfile ├── codecov.yml ├── cmake └── Docs.cmake ├── tests ├── integration │ └── hello_integration_test.cpp ├── mock │ ├── assert_mock.c │ ├── gpio_mock.h │ ├── hal_gpio_mock.cpp │ ├── gpio_mock.cpp │ └── hal_gpio_mock.h ├── unit │ ├── hello_unit_test.cpp │ ├── middleware │ │ └── led_test.cpp │ └── drivers │ │ └── gpio_test.cpp ├── header-overrides │ ├── core_cm4_override.h │ ├── stm32f4xx_hal_gpio_override.h │ └── main_override.h └── CMakeLists.txt ├── .github └── workflows │ ├── unit-test.yml │ ├── lizard.yml │ └── flawfinder.yml ├── LICENSE ├── docker └── Dockerfile ├── Makefile ├── CMakeLists.txt ├── .gitignore └── README.md /source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(nucleo-f446ze-library) -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Libraries/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(Drivers) 2 | add_subdirectory(Middleware) -------------------------------------------------------------------------------- /docs/images/stm32_gtest.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CharlesDias/stm32_gtest_c_code/HEAD/docs/images/stm32_gtest.gif -------------------------------------------------------------------------------- /docs/images/dependency_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CharlesDias/stm32_gtest_c_code/HEAD/docs/images/dependency_graph.png -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | range: 70..100 3 | round: down 4 | precision: 1 5 | 6 | ignore: 7 | - "build" 8 | - "cmake" 9 | - "docs" 10 | - "tests" -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/BuildArtifacts/libnucleo-f446ze-library.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CharlesDias/stm32_gtest_c_code/HEAD/source/nucleo-f446ze-library/BuildArtifacts/libnucleo-f446ze-library.a -------------------------------------------------------------------------------- /cmake/Docs.cmake: -------------------------------------------------------------------------------- 1 | find_package(Doxygen) 2 | 3 | if (DOXYGEN_FOUND) 4 | add_custom_target( 5 | docs 6 | ${DOXYGEN_EXECUTABLE} 7 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs 8 | ) 9 | endif() 10 | -------------------------------------------------------------------------------- /tests/integration/hello_integration_test.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | 4 | TEST(HelloIntegrationTests, Test_1) 5 | { 6 | EXPECT_TRUE(1); 7 | } 8 | 9 | TEST(HelloIntegrationTests, Test_2) 10 | { 11 | EXPECT_FALSE(0); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Libraries/Middleware/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MIDDLEWARE_SOURCES_FILES 2 | "Src/led.c" 3 | ) 4 | 5 | add_library(${MIDDLEWARE_LIBRARY_TARGET} STATIC 6 | ${MIDDLEWARE_SOURCES_FILES} 7 | ) 8 | 9 | target_include_directories( ${MIDDLEWARE_LIBRARY_TARGET} PUBLIC 10 | "../../Libraries/" 11 | ) -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_FOLDER_PATH "${CMAKE_CURRENT_SOURCE_DIR}") 2 | 3 | set(STM32_CUBE_INCLUDE_FILES 4 | ${CURRENT_FOLDER_PATH}/Inc/ 5 | ${CURRENT_FOLDER_PATH}/Drivers/STM32F4xx_HAL_Driver/Inc/ 6 | ${CURRENT_FOLDER_PATH}/Drivers/CMSIS/Include/ 7 | ${CURRENT_FOLDER_PATH}/Drivers/CMSIS/Device/ST/STM32F4xx/Include/ 8 | ) 9 | 10 | add_subdirectory(Libraries) -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Libraries/Drivers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_definitions(-DSTM32F446xx) 2 | 3 | set(DRIVERS_SOURCES_FILES 4 | "Src/gpio.c" 5 | ) 6 | 7 | add_library(${DRIVERS_LIBRARY_TARGET} STATIC 8 | ${DRIVERS_SOURCES_FILES} 9 | ) 10 | 11 | target_include_directories( ${DRIVERS_LIBRARY_TARGET} PUBLIC 12 | "../../Libraries/" 13 | PRIVATE 14 | ${STM32_CUBE_INCLUDE_FILES} 15 | ) -------------------------------------------------------------------------------- /tests/mock/assert_mock.c: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | extern "C" { 3 | #endif 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | void assert_failed(uint8_t *file, unsigned int line) 11 | { 12 | printf("assert_failed: file %s on line %lu\r\n", file, line); 13 | fflush(stdout); 14 | assert(false); 15 | } 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif -------------------------------------------------------------------------------- /tests/unit/hello_unit_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | TEST(HelloUnitTests, BasicAssertions_1) 5 | { 6 | // Expect to br true 7 | EXPECT_TRUE(1); 8 | 9 | // Expect to br false 10 | EXPECT_FALSE(0); 11 | } 12 | 13 | TEST(HelloUnitTests, BasicAssertions_2) 14 | { 15 | // Expect two strings not to be equal. 16 | EXPECT_STRNE("hello", "world"); 17 | 18 | // Expect equality. 19 | EXPECT_EQ(7 * 6, 42); 20 | } -------------------------------------------------------------------------------- /source/stm32-cube-ide/Drivers/CMSIS/Device/ST/STM32F4xx/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the Apache-2.0 license shall apply. 5 | You may obtain a copy of the Apache-2.0 at: 6 | https://opensource.org/licenses/Apache-2.0 7 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/Drivers/STM32F4xx_HAL_Driver/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the BSD-3-Clause license shall apply. 5 | You may obtain a copy of the BSD-3-Clause at: 6 | https://opensource.org/licenses/BSD-3-Clause 7 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/CMSIS/Device/ST/STM32F4xx/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the Apache-2.0 license shall apply. 5 | You may obtain a copy of the Apache-2.0 at: 6 | https://opensource.org/licenses/Apache-2.0 7 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/STM32F4xx_HAL_Driver/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the BSD-3-Clause license shall apply. 5 | You may obtain a copy of the BSD-3-Clause at: 6 | https://opensource.org/licenses/BSD-3-Clause 7 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/BSP/Include/bsp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * bsp.h 3 | * 4 | * Created on: Dec 3, 2022 5 | * Author: charlesdias 6 | */ 7 | 8 | #ifndef INCLUDE_BSP_H_ 9 | #define INCLUDE_BSP_H_ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | void BSP_Initialize(void); 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | #endif /* INCLUDE_BSP_H_ */ 26 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/BSP/Src/bsp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * bsp.c 3 | * 4 | * Created on: Dec 3, 2022 5 | * Author: charlesdias 6 | */ 7 | 8 | #include "bsp.h" 9 | #include "stm32f4xx_hal.h" 10 | 11 | 12 | extern UART_HandleTypeDef huart3; 13 | 14 | void BSP_Initialize(void) 15 | { 16 | printf("BSP_Initialize\r\n"); 17 | } 18 | 19 | // Function used by printf 20 | int __io_putchar(int ch) 21 | { 22 | HAL_UART_Transmit(&huart3, (uint8_t *)&ch, 1, 1); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /.github/workflows/unit-test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: [push] 4 | 5 | jobs: 6 | unit-tests: 7 | runs-on: ubuntu-latest 8 | container: 9 | image: charlesdias/stm32_gtest:latest 10 | 11 | steps: 12 | - uses: actions/checkout@v3 13 | 14 | - name: Configure, build, and run Google Test 15 | run: | 16 | make test 17 | 18 | - name: Run coverage 19 | run: | 20 | make coverage 21 | 22 | - name: Upload coverage reports to Codecov with GitHub Action 23 | uses: codecov/codecov-action@v3 24 | with: 25 | gcov_ignore: 26 | ./build 27 | ./docs 28 | ./tests -------------------------------------------------------------------------------- /.github/workflows/lizard.yml: -------------------------------------------------------------------------------- 1 | # https://github.com/terryyin/lizard 2 | name: Lizard 3 | 4 | on: [push] 5 | 6 | jobs: 7 | lizard: 8 | name: Lizard 9 | 10 | runs-on: ubuntu-latest 11 | container: 12 | image: charlesdias/stm32_gtest:latest 13 | 14 | permissions: 15 | actions: read 16 | contents: read 17 | security-events: write 18 | 19 | steps: 20 | - name: Checkout code 21 | uses: actions/checkout@v3 22 | 23 | - name: Lizard scan 24 | run: lizard --CCN 15 --length 1000 --arguments 100 ./source/nucleo-f446ze-library/Libraries > lizard-report.txt 25 | 26 | - name: Upload analysis results 27 | uses: actions/upload-artifact@v3 28 | with: 29 | name: Archive production artifacts 30 | path: lizard-report.txt 31 | retention-days: 90 -------------------------------------------------------------------------------- /tests/mock/gpio_mock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "Drivers/Include/gpio.h" 6 | 7 | /** 8 | * @class GpioMock 9 | * Mock class for the GPIO_* C functions. 10 | */ 11 | class GpioMock 12 | { 13 | public: 14 | MOCK_METHOD(void, GPIO_Initialize, (Gpio_t *const me, const GpioPort_t *const port, const GpioPin_t pin)); 15 | MOCK_METHOD(void, GPIO_TogglePin, (const Gpio_t *const me)); 16 | MOCK_METHOD(void, GPIO_WritePin, (const Gpio_t *const me, GpioState_t state)); 17 | MOCK_METHOD(GpioState_t, GPIO_ReadPin, (const Gpio_t *const me)); 18 | }; 19 | 20 | /** 21 | * @brief Sets the global GpioMock pointer that the extern "C" GPIO_* stubs will call. 22 | * 23 | * @param mock Pointer to a GpioMock instance (or nullptr to disable). 24 | */ 25 | void setGpioMock(GpioMock *mock); 26 | -------------------------------------------------------------------------------- /tests/mock/hal_gpio_mock.cpp: -------------------------------------------------------------------------------- 1 | #include "hal_gpio_mock.h" 2 | 3 | // A global pointer to the current mock instance 4 | static HalMock* g_halMock = nullptr; 5 | 6 | void setHalMock(HalMock* mock) 7 | { 8 | g_halMock = mock; 9 | } 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) 16 | { 17 | if (g_halMock) 18 | { 19 | g_halMock->HAL_GPIO_TogglePin(GPIOx, GPIO_Pin); 20 | } 21 | } 22 | 23 | void HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState) 24 | { 25 | if (g_halMock) 26 | { 27 | g_halMock->HAL_GPIO_WritePin(GPIOx, GPIO_Pin, PinState); 28 | } 29 | } 30 | 31 | GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) 32 | { 33 | if (g_halMock) 34 | { 35 | return g_halMock->HAL_GPIO_ReadPin(GPIOx, GPIO_Pin); 36 | } 37 | return GPIO_PIN_RESET; // Default fallback 38 | } 39 | 40 | #ifdef __cplusplus 41 | } // extern "C" 42 | #endif -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Libraries/Middleware/Include/led.h: -------------------------------------------------------------------------------- 1 | /* 2 | * led.h 3 | * 4 | * Created on: 3 de dez de 2022 5 | * Author: charlesdias 6 | */ 7 | 8 | #ifndef MIDDLEWARE_INCLUDE_LED_H_ 9 | #define MIDDLEWARE_INCLUDE_LED_H_ 10 | 11 | #ifdef __cplusplus 12 | extern "C" 13 | { 14 | #endif 15 | 16 | #include "Drivers/Include/gpio.h" 17 | 18 | typedef enum 19 | { 20 | LED_STATE_OFF, 21 | LED_STATE_ON, 22 | } LedState_t; 23 | 24 | typedef enum 25 | { 26 | LED_ACTIVE_LOW, 27 | LED_ACTIVE_HIGH, 28 | } LedActiveLevel_t; 29 | 30 | typedef struct Led 31 | { 32 | bool init; 33 | const Gpio_t *gpio; 34 | bool activeLevel; 35 | } Led_t; 36 | 37 | void LED_Initialize(Led_t * const me, const Gpio_t * const gpio, const LedActiveLevel_t activeLevel); 38 | void LED_Write(const Led_t * const me, const LedState_t state); 39 | void LED_Toggle(const Led_t * const me); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif /* MIDDLEWARE_INCLUDE_LED_H_ */ 46 | -------------------------------------------------------------------------------- /tests/header-overrides/core_cm4_override.h: -------------------------------------------------------------------------------- 1 | #ifndef __CORE_CM4_H_OVERRIDE 2 | #define __CORE_CM4_H_OVERRIDE 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #ifdef __cplusplus 9 | #define __I volatile /*!< Defines 'read only' permissions */ 10 | #else 11 | #define __I volatile const /*!< Defines 'read only' permissions */ 12 | #endif 13 | #define __O volatile /*!< Defines 'write only' permissions */ 14 | #define __IO volatile /*!< Defines 'read / write' permissions */ 15 | 16 | /* following defines should be used for structure members */ 17 | #define __IM volatile const /*! Defines 'read only' structure member permissions */ 18 | #define __OM volatile /*! Defines 'write only' structure member permissions */ 19 | #define __IOM volatile /*! Defines 'read / write' structure member permissions */ 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | #endif /* __CORE_CM4_H_OVERRIDE */ -------------------------------------------------------------------------------- /tests/mock/gpio_mock.cpp: -------------------------------------------------------------------------------- 1 | #include "gpio_mock.h" 2 | 3 | static GpioMock *g_mock = nullptr; 4 | 5 | void setGpioMock(GpioMock *mock) 6 | { 7 | g_mock = mock; 8 | } 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | void GPIO_Initialize(Gpio_t *const me, const GpioPort_t *const port, const GpioPin_t pin) 15 | { 16 | if (g_mock) 17 | { 18 | g_mock->GPIO_Initialize(me, port, pin); 19 | } 20 | } 21 | 22 | void GPIO_TogglePin(const Gpio_t *const me) 23 | { 24 | if (g_mock) 25 | { 26 | g_mock->GPIO_TogglePin(me); 27 | } 28 | } 29 | 30 | void GPIO_WritePin(const Gpio_t *const me, const GpioState_t state) 31 | { 32 | if (g_mock) 33 | { 34 | g_mock->GPIO_WritePin(me, state); 35 | } 36 | } 37 | 38 | GpioState_t GPIO_ReadPin(const Gpio_t *const me) 39 | { 40 | if (g_mock) 41 | { 42 | return g_mock->GPIO_ReadPin(me); 43 | } 44 | return GPIO_STATE_RESET; // Default fallback if no mock is set 45 | } 46 | 47 | #ifdef __cplusplus 48 | } // extern "C" 49 | #endif -------------------------------------------------------------------------------- /.github/workflows/flawfinder.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | 6 | name: Flawfinder 7 | 8 | on: [push] 9 | 10 | jobs: 11 | flawfinder: 12 | name: Flawfinder 13 | 14 | runs-on: ubuntu-latest 15 | container: 16 | image: charlesdias/stm32_gtest:latest 17 | 18 | permissions: 19 | actions: read 20 | contents: read 21 | security-events: write 22 | 23 | steps: 24 | - name: Checkout code 25 | uses: actions/checkout@v3 26 | 27 | - name: Flawfinder scan 28 | run: flawfinder --html --context --minlevel=1 ./source/nucleo-f446ze-library/Libraries > flawfinder-report.html 29 | 30 | - name: Upload analysis results 31 | uses: actions/upload-artifact@v3 32 | with: 33 | name: Archive production artifacts 34 | path: flawfinder-report.html 35 | retention-days: 90 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Charles Dias 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Libraries/Middleware/Src/led.c: -------------------------------------------------------------------------------- 1 | /* 2 | * led.c 3 | * 4 | * Created on: 3 de dez de 2022 5 | * Author: charlesdias 6 | */ 7 | 8 | #include "Middleware/Include/led.h" 9 | #include 10 | #include 11 | 12 | void LED_Initialize(Led_t * const me, const Gpio_t * const gpio, const LedActiveLevel_t activeLevel) 13 | { 14 | assert(me != NULL); 15 | assert(!me->init); 16 | 17 | assert(gpio != NULL); 18 | 19 | me->init = true; 20 | me->gpio = gpio; 21 | me->activeLevel = activeLevel; 22 | } 23 | 24 | void LED_Write(const Led_t * const me, const LedState_t state) 25 | { 26 | assert(me != NULL); 27 | assert(me->init); 28 | 29 | GpioState_t gpioState = GPIO_STATE_RESET; 30 | 31 | if (me->activeLevel == LED_ACTIVE_HIGH) 32 | { 33 | if(state == LED_STATE_ON) 34 | { 35 | gpioState = GPIO_STATE_SET; 36 | } 37 | } 38 | else if (state == LED_STATE_OFF) 39 | { 40 | gpioState = GPIO_STATE_SET; 41 | } 42 | 43 | GPIO_WritePin(me->gpio, gpioState); 44 | } 45 | 46 | void LED_Toggle(const Led_t * const me) 47 | { 48 | assert(me != NULL); 49 | assert(me->init); 50 | 51 | GPIO_TogglePin(me->gpio); 52 | } 53 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | nucleo-f446ze-library 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | com.st.stm32cube.ide.mcu.MCUProjectNature 23 | org.eclipse.cdt.core.cnature 24 | com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature 25 | com.st.stm32cube.ide.mcu.MCUCubeProjectNature 26 | com.st.stm32cube.ide.mcu.MCUSingleCpuProjectNature 27 | com.st.stm32cube.ide.mcu.MCURootProjectNature 28 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 29 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 30 | 31 | 32 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | tutorial-gtest-stm32 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | com.st.stm32cube.ide.mcu.MCUProjectNature 23 | com.st.stm32cube.ide.mcu.MCUCubeProjectNature 24 | org.eclipse.cdt.core.cnature 25 | com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature 26 | com.st.stm32cube.ide.mcu.MCUAdvancedStructureProjectNature 27 | com.st.stm32cube.ide.mcu.MCUSingleCpuProjectNature 28 | com.st.stm32cube.ide.mcu.MCURootProjectNature 29 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 30 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 31 | 32 | 33 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Libraries/Drivers/Include/gpio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gpio.h 3 | * 4 | * Created on: Dec 3, 2022 5 | * Author: charlesdias 6 | */ 7 | 8 | #ifndef DRIVERS_INCLUDE_GPIO_H_ 9 | #define DRIVERS_INCLUDE_GPIO_H_ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #include 16 | #include 17 | 18 | typedef uint32_t GpioPort_t; 19 | typedef uint16_t GpioPin_t; 20 | 21 | typedef enum 22 | { 23 | GPIO_STATE_RESET = 0, 24 | GPIO_STATE_SET 25 | }GpioState_t; 26 | 27 | 28 | /** 29 | * @struct A structure to represent the GPIO pin. 30 | */ 31 | typedef struct Gpio 32 | { 33 | bool init; /**< Flag to inform if the structure has been initialized.*/ 34 | const GpioPort_t *port; /**< Port number.*/ 35 | GpioPin_t pin; /**< Pin number.*/ 36 | }Gpio_t; 37 | 38 | /** 39 | * @brief Initialize the \ref Gpio_t structure. 40 | * 41 | * @param me Pointer to \ref Gpio_t. 42 | * @param port Port number. 43 | * @param pin Pin number. 44 | */ 45 | void GPIO_Initialize(Gpio_t * const me, const GpioPort_t * const port, const GpioPin_t pin); 46 | void GPIO_TogglePin(const Gpio_t * const me); 47 | void GPIO_WritePin(const Gpio_t * const me, const GpioState_t state); 48 | GpioState_t GPIO_ReadPin(const Gpio_t * const me); 49 | 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif /* DRIVERS_INCLUDE_GPIO_H_ */ 56 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Libraries/Drivers/Src/gpio.c: -------------------------------------------------------------------------------- 1 | /* 2 | * gpio.c 3 | * 4 | * Created on: Dec 3, 2022 5 | * Author: charlesdias 6 | */ 7 | 8 | #include "Drivers/Include/gpio.h" 9 | #include "stm32f4xx_hal.h" 10 | #include 11 | 12 | 13 | void GPIO_Initialize(Gpio_t * const me, const GpioPort_t * const port, const GpioPin_t pin) 14 | { 15 | assert(me != NULL); 16 | assert(!me->init); 17 | 18 | assert(port != NULL); 19 | 20 | me->init = true; 21 | me->port = port; 22 | me->pin = pin; 23 | } 24 | 25 | void GPIO_TogglePin(const Gpio_t * const me) 26 | { 27 | assert(me != NULL); 28 | assert(me->init); 29 | 30 | HAL_GPIO_TogglePin((GPIO_TypeDef *)me->port, me->pin); 31 | } 32 | 33 | void GPIO_WritePin(const Gpio_t * const me, const GpioState_t state) 34 | { 35 | assert(me != NULL); 36 | assert(me->init); 37 | 38 | if(state == GPIO_STATE_SET) 39 | { 40 | HAL_GPIO_WritePin((GPIO_TypeDef *)me->port, me->pin, GPIO_PIN_SET); 41 | } 42 | else 43 | { 44 | HAL_GPIO_WritePin((GPIO_TypeDef *)me->port, me->pin, GPIO_PIN_RESET); 45 | } 46 | } 47 | 48 | GpioState_t GPIO_ReadPin(const Gpio_t * const me) 49 | { 50 | assert(me != NULL); 51 | assert(me->init); 52 | 53 | if(HAL_GPIO_ReadPin((GPIO_TypeDef *)me->port, me->pin)) 54 | { 55 | return GPIO_STATE_SET; 56 | } 57 | else 58 | { 59 | return GPIO_STATE_RESET; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /tests/mock/hal_gpio_mock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #define __IO volatile 11 | 12 | typedef enum 13 | { 14 | GPIO_PIN_RESET = 0, 15 | GPIO_PIN_SET 16 | } GPIO_PinState; 17 | 18 | /** 19 | * Minimal GPIO_TypeDef layout (fake or from STM32 HAL) 20 | */ 21 | typedef struct 22 | { 23 | __IO unsigned int MODER; 24 | __IO unsigned int OTYPER; 25 | __IO unsigned int OSPEEDR; 26 | __IO unsigned int PUPDR; 27 | __IO unsigned int IDR; 28 | __IO unsigned int ODR; 29 | __IO unsigned int BSRR; 30 | __IO unsigned int LCKR; 31 | __IO unsigned int AFR[2]; 32 | } GPIO_TypeDef; 33 | 34 | #ifdef __cplusplus 35 | } // extern "C" 36 | #endif 37 | 38 | /** 39 | * @class HalMock 40 | * Mock class for the STM32 HAL GPIO functions. 41 | */ 42 | class HalMock 43 | { 44 | public: 45 | virtual ~HalMock() {} 46 | 47 | // HAL Functions 48 | MOCK_METHOD(void, HAL_GPIO_TogglePin, (GPIO_TypeDef*, uint16_t)); 49 | MOCK_METHOD(void, HAL_GPIO_WritePin, (GPIO_TypeDef*, uint16_t, GPIO_PinState)); 50 | MOCK_METHOD(GPIO_PinState, HAL_GPIO_ReadPin, (GPIO_TypeDef*, uint16_t)); 51 | }; 52 | 53 | /** 54 | * @brief Set the global HalMock pointer that the extern "C" functions will call. 55 | * 56 | * @param mock Pointer to a HalMock instance (or nullptr to disable mock calls). 57 | */ 58 | void setHalMock(HalMock* mock); -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | # Docker name 2 | # charlesdias/stm32_gtest 3 | # 4 | # Docker build 5 | # docker build -t charlesdias/stm32_gtest: -t charlesdias/stm32_gtest:latest . 6 | # 7 | # Docker push 8 | # docker push charlesdias/stm32_gtest --all-tags 9 | 10 | FROM ubuntu:22.04 11 | 12 | LABEL maintainer="Charles Dias " 13 | 14 | ENV TZ=America/Fortaleza 15 | RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone 16 | 17 | # Download Linux support tools 18 | RUN apt-get update && apt-get clean && apt-get install -y \ 19 | build-essential git wget python3 doxygen graphviz gcovr lcov \ 20 | python3-pip flawfinder \ 21 | && apt-get clean && rm -rf /var/lib/apt/lists/* 22 | 23 | # Install Lizard 24 | RUN pip3 install lizard 25 | 26 | # Get and install the CMake 27 | RUN wget https://github.com/Kitware/CMake/releases/download/v3.24.2/cmake-3.24.2-linux-x86_64.sh \ 28 | -q -O /tmp/cmake-install.sh \ 29 | && chmod u+x /tmp/cmake-install.sh \ 30 | && mkdir /usr/bin/cmake \ 31 | && /tmp/cmake-install.sh --skip-license --prefix=/usr/bin/cmake \ 32 | && rm /tmp/cmake-install.sh 33 | 34 | # Set up the CMake path 35 | ENV PATH="/usr/bin/cmake/bin:${PATH}" 36 | 37 | # # Clone and install Google Test framework. Install in /usr/local/ by default 38 | # RUN git clone -b v1.12.1 https://github.com/google/googletest.git /googletest \ 39 | # && cd /googletest \ 40 | # && mkdir -p build && cd build \ 41 | # && cmake .. && make && make install \ 42 | # && cd / && rm -rf /googletest 43 | 44 | # Set up the working directory 45 | WORKDIR /home/project -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousGenFiles] 2 | SourcePath=../Src 3 | SourceFiles=nucleo-f446ze-library.c; 4 | 5 | [PreviousLibFiles] 6 | LibFiles=Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f446xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;Drivers/CMSIS/Include/mpu_armv7.h;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/tz_context.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/cmsis_version.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_armv8mbl.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/cmsis_gcc.h; 7 | 8 | [PreviousUsedCubeIDEFiles] 9 | SourceFiles=Src/nucleo-f446ze-library.c;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;Src/stm32f4xx_hal_conf_template.h;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;Src/stm32f4xx_hal_conf_template.h;;; 10 | HeaderPath=Drivers/CMSIS/Device/ST/STM32F4xx/Include;Drivers/CMSIS/Include;Inc;Drivers/STM32F4xx_HAL_Driver/Inc;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy; 11 | CDefines=USE_HAL_DRIVER;STM32F446xx;USE_HAL_DRIVER;USE_HAL_DRIVER; 12 | 13 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | @echo "" 3 | @echo "Done!" 4 | 5 | build: 6 | @echo "-------------------- Configure and Build CMake -----------" 7 | cmake -S . -B build 8 | cmake --build build -- -j4 9 | @echo "" 10 | 11 | test: build 12 | @echo "-------------------- Run CTest ---------------------------" 13 | cd build && pwd && ctest --verbose 14 | @echo "" 15 | 16 | coverage: 17 | @echo "-------------------- Build Coverage--------------------------" 18 | cmake -DENABLE_COVERAGE=ON -S . -B build 19 | cmake --build build --config Debug --target coverage -j4 20 | @echo "" 21 | 22 | doxygen: build 23 | @echo "-------------------- Build Coverage--------------------------" 24 | cmake --build build --config Debug --target docs -j4 25 | @echo "" 26 | 27 | gtest_report: 28 | cd build-artifacts/gtest_report && xsltproc gtest2html.xslt out/*.xml > gtest_report.html 29 | # cd report && xsltproc gtest2html.xslt *.xml > gtest_report.html 30 | # cd report && xsltproc test.xslt *.xml > gtest_report.html 31 | # cd report && xsltproc newgtest2html.xsl *.xml > gtest_report.html 32 | # Don't work!!!! 33 | # report: 34 | # @echo "-------------------- Coverage Report ---------------------" 35 | # lcov --capture --directory build/coverage --output-file coverage.info 36 | # genhtml coverage.info --output-directory test/ 37 | # @echo "" 38 | 39 | dependency: 40 | @echo "-------------------- Create Graph Dependecy --------------" 41 | cd build && cmake .. --graphviz=graph.dot && dot -Tpng graph.dot -o graph_image.png 42 | @echo "" 43 | 44 | clean: 45 | @echo "" 46 | @echo "-------------------- Clean build folder ------------------" 47 | rm -rf build 48 | @echo "" -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21.0) 2 | 3 | project(stm32_gtest) 4 | 5 | set(CMAKE_C_STANDARD 17) 6 | set(CMAKE_C_STANDARD_REQUIRED ON) # Define explicitly to use of the standard C17 declared in the previous line 7 | set(CMAKE_C_EXTENSIONS OFF) # Disabling vendor-specific extensions 8 | 9 | set(CMAKE_CXX_STANDARD 17) 10 | set(CMAKE_CXX_STANDARD_REQUIRED ON) # Define explicitly to use of the standard C++17 declared in the previous line 11 | set(CMAKE_CXX_EXTENSIONS OFF) # Disabling vendor-specific extensions 12 | 13 | option(ENABLE_COVERAGE "Enable a Code Coverage build." OFF) 14 | 15 | ### CMAKE MODULES 16 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/) 17 | 18 | # Doxygen module 19 | include(Docs) 20 | 21 | if (ENABLE_COVERAGE) 22 | include(CodeCoverage) 23 | append_coverage_compiler_flags() 24 | endif() 25 | 26 | message(STATUS "EXTERNAL: Clone Google Test Framework from Git repository...") 27 | include(FetchContent) 28 | FetchContent_Declare( 29 | googletest 30 | GIT_REPOSITORY https://github.com/google/googletest.git 31 | GIT_TAG v1.15.2 32 | ) 33 | 34 | # For Windows: Prevent overriding the parent project's compiler/linker settings 35 | set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 36 | FetchContent_MakeAvailable(googletest) 37 | 38 | # It must to be declare before the test folder 39 | enable_testing() 40 | 41 | # Variables name for target 42 | set(LIBRARY_NAME library_gpio) 43 | set(DRIVERS_LIBRARY_TARGET drivers_library) 44 | set(MIDDLEWARE_LIBRARY_TARGET middleware_library) 45 | 46 | add_subdirectory(source) 47 | add_subdirectory(tests) -------------------------------------------------------------------------------- /source/stm32-cube-ide/Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.2 5 | * @date 19. April 2017 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.2 5 | * @date 19. April 2017 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/Core/Inc/stm32f4xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f4xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2022 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32F4xx_IT_H 22 | #define __STM32F4xx_IT_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Private includes ----------------------------------------------------------*/ 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN ET */ 35 | 36 | /* USER CODE END ET */ 37 | 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* USER CODE BEGIN EC */ 40 | 41 | /* USER CODE END EC */ 42 | 43 | /* Exported macro ------------------------------------------------------------*/ 44 | /* USER CODE BEGIN EM */ 45 | 46 | /* USER CODE END EM */ 47 | 48 | /* Exported functions prototypes ---------------------------------------------*/ 49 | void NMI_Handler(void); 50 | void HardFault_Handler(void); 51 | void MemManage_Handler(void); 52 | void BusFault_Handler(void); 53 | void UsageFault_Handler(void); 54 | void SVC_Handler(void); 55 | void DebugMon_Handler(void); 56 | void PendSV_Handler(void); 57 | void SysTick_Handler(void); 58 | /* USER CODE BEGIN EFP */ 59 | 60 | /* USER CODE END EFP */ 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* __STM32F4xx_IT_H */ 67 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### Doxygen ### 2 | docs/html/ 3 | 4 | ### Eclipse ### 5 | Debug/ 6 | Release/ 7 | ### CMake ### 8 | build/ 9 | 10 | # Created by https://www.toptal.com/developers/gitignore/api/eclipse,vscode,cmake 11 | # Edit at https://www.toptal.com/developers/gitignore?templates=eclipse,vscode,cmake 12 | 13 | ### CMake ### 14 | CMakeLists.txt.user 15 | CMakeCache.txt 16 | CMakeFiles 17 | CMakeScripts 18 | Testing 19 | cmake_install.cmake 20 | install_manifest.txt 21 | compile_commands.json 22 | CTestTestfile.cmake 23 | CPackConfig.cmake 24 | _deps 25 | CMakeUserPresets.json 26 | 27 | ### CMake Patch ### 28 | # External projects 29 | *-prefix/ 30 | 31 | ### Eclipse ### 32 | .metadata 33 | bin/ 34 | tmp/ 35 | *.tmp 36 | *.bak 37 | *.swp 38 | *~.nib 39 | local.properties 40 | .settings/ 41 | .loadpath 42 | .recommenders 43 | 44 | # External tool builders 45 | .externalToolBuilders/ 46 | 47 | # Locally stored "Eclipse launch configurations" 48 | *.launch 49 | 50 | # PyDev specific (Python IDE for Eclipse) 51 | *.pydevproject 52 | 53 | # CDT-specific (C/C++ Development Tooling) 54 | #.cproject 55 | 56 | # CDT- autotools 57 | .autotools 58 | 59 | # Java annotation processor (APT) 60 | .factorypath 61 | 62 | # PDT-specific (PHP Development Tools) 63 | .buildpath 64 | 65 | # sbteclipse plugin 66 | .target 67 | 68 | # Tern plugin 69 | .tern-project 70 | 71 | # TeXlipse plugin 72 | .texlipse 73 | 74 | # STS (Spring Tool Suite) 75 | .springBeans 76 | 77 | # Code Recommenders 78 | .recommenders/ 79 | 80 | # Annotation Processing 81 | .apt_generated/ 82 | .apt_generated_test/ 83 | 84 | # Scala IDE specific (Scala & Java development for Eclipse) 85 | .cache-main 86 | .scala_dependencies 87 | .worksheet 88 | 89 | # Uncomment this line if you wish to ignore the project description file. 90 | # Typically, this file would be tracked if it contains build/dependency configurations: 91 | #.project 92 | 93 | ### Eclipse Patch ### 94 | # Spring Boot Tooling 95 | .sts4-cache/ 96 | 97 | ### vscode ### 98 | .vscode/* 99 | !.vscode/settings.json 100 | !.vscode/tasks.json 101 | !.vscode/launch.json 102 | !.vscode/extensions.json 103 | *.code-workspace 104 | 105 | 106 | # End of https://www.toptal.com/developers/gitignore/api/eclipse,vscode,cmake -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/STM32F4xx_HAL_Driver/Inc/stm32_assert_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32_assert.h 4 | * @author MCD Application Team 5 | * @brief STM32 assert template file. 6 | * This file should be copied to the application folder and renamed 7 | * to stm32_assert.h. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * Copyright (c) 2017 STMicroelectronics. 12 | * All rights reserved. 13 | * 14 | * This software is licensed under terms that can be found in the LICENSE file 15 | * in the root directory of this software component. 16 | * If no LICENSE file comes with this software, it is provided AS-IS. 17 | * 18 | ****************************************************************************** 19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32_ASSERT_H 23 | #define __STM32_ASSERT_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Exported types ------------------------------------------------------------*/ 30 | /* Exported constants --------------------------------------------------------*/ 31 | /* Includes ------------------------------------------------------------------*/ 32 | /* Exported macro ------------------------------------------------------------*/ 33 | #ifdef USE_FULL_ASSERT 34 | /** 35 | * @brief The assert_param macro is used for function's parameters check. 36 | * @param expr If expr is false, it calls assert_failed function 37 | * which reports the name of the source file and the source 38 | * line number of the call that failed. 39 | * If expr is true, it returns no value. 40 | * @retval None 41 | */ 42 | #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) 43 | /* Exported functions ------------------------------------------------------- */ 44 | void assert_failed(uint8_t* file, uint32_t line); 45 | #else 46 | #define assert_param(expr) ((void)0U) 47 | #endif /* USE_FULL_ASSERT */ 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif /* __STM32_ASSERT_H */ 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_flash_ramfunc.h 4 | * @author MCD Application Team 5 | * @brief Header file of FLASH RAMFUNC driver. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | ****************************************************************************** 16 | */ 17 | 18 | /* Define to prevent recursive inclusion -------------------------------------*/ 19 | #ifndef __STM32F4xx_FLASH_RAMFUNC_H 20 | #define __STM32F4xx_FLASH_RAMFUNC_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\ 26 | defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f4xx_hal_def.h" 30 | 31 | /** @addtogroup STM32F4xx_HAL_Driver 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup FLASH_RAMFUNC 36 | * @{ 37 | */ 38 | 39 | /* Exported types ------------------------------------------------------------*/ 40 | /* Exported macro ------------------------------------------------------------*/ 41 | /* Exported functions --------------------------------------------------------*/ 42 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions 43 | * @{ 44 | */ 45 | 46 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group1 47 | * @{ 48 | */ 49 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StopFlashInterfaceClk(void); 50 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StartFlashInterfaceClk(void); 51 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableFlashSleepMode(void); 52 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableFlashSleepMode(void); 53 | /** 54 | * @} 55 | */ 56 | 57 | /** 58 | * @} 59 | */ 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | /** 66 | * @} 67 | */ 68 | 69 | #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | 75 | #endif /* __STM32F4xx_FLASH_RAMFUNC_H */ 76 | 77 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_flash_ramfunc.h 4 | * @author MCD Application Team 5 | * @brief Header file of FLASH RAMFUNC driver. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | ****************************************************************************** 16 | */ 17 | 18 | /* Define to prevent recursive inclusion -------------------------------------*/ 19 | #ifndef __STM32F4xx_FLASH_RAMFUNC_H 20 | #define __STM32F4xx_FLASH_RAMFUNC_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\ 26 | defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f4xx_hal_def.h" 30 | 31 | /** @addtogroup STM32F4xx_HAL_Driver 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup FLASH_RAMFUNC 36 | * @{ 37 | */ 38 | 39 | /* Exported types ------------------------------------------------------------*/ 40 | /* Exported macro ------------------------------------------------------------*/ 41 | /* Exported functions --------------------------------------------------------*/ 42 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions 43 | * @{ 44 | */ 45 | 46 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group1 47 | * @{ 48 | */ 49 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StopFlashInterfaceClk(void); 50 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StartFlashInterfaceClk(void); 51 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableFlashSleepMode(void); 52 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableFlashSleepMode(void); 53 | /** 54 | * @} 55 | */ 56 | 57 | /** 58 | * @} 59 | */ 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | /** 66 | * @} 67 | */ 68 | 69 | #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | 75 | #endif /* __STM32F4xx_FLASH_RAMFUNC_H */ 76 | 77 | -------------------------------------------------------------------------------- /tests/unit/middleware/led_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "Middleware/Include/led.h" 5 | #include "gpio_mock.h" 6 | 7 | using ::testing::_; 8 | using ::testing::InSequence; 9 | using ::testing::Return; 10 | 11 | class LedUnitTest : public ::testing::Test 12 | { 13 | protected: 14 | ::testing::StrictMock *mock; 15 | Gpio_t gpio = {0}; 16 | Led_t led = {0}; 17 | 18 | void SetUp() override 19 | { 20 | // Create and install the mock 21 | mock = new ::testing::StrictMock(); 22 | setGpioMock(mock); 23 | } 24 | 25 | void TearDown() override 26 | { 27 | // Unset the mock 28 | setGpioMock(nullptr); 29 | delete mock; 30 | } 31 | }; 32 | 33 | TEST_F(LedUnitTest, LED_WhenCalled_InitializesStructFields) 34 | { 35 | LedActiveLevel_t expectedActiveLevel = LED_ACTIVE_HIGH; 36 | 37 | LED_Initialize(&led, &gpio, expectedActiveLevel); 38 | 39 | EXPECT_TRUE(led.init); 40 | EXPECT_EQ(&gpio, led.gpio); 41 | EXPECT_EQ(expectedActiveLevel, led.activeLevel); 42 | } 43 | 44 | struct LedParam 45 | { 46 | LedActiveLevel_t activeLevel; 47 | LedState_t state; 48 | GpioState_t expectedGpioState; 49 | const char *testName; 50 | }; 51 | 52 | class LedParamTest : public LedUnitTest, 53 | public testing::WithParamInterface 54 | { 55 | }; 56 | 57 | TEST_P(LedParamTest, LED_Write_WhenCalled_CallsGpioWritePinWithExpectedState) 58 | { 59 | const auto &p = GetParam(); 60 | 61 | LED_Initialize(&led, &gpio, p.activeLevel); 62 | 63 | EXPECT_CALL(*mock, GPIO_WritePin(&gpio, p.expectedGpioState)).Times(1); 64 | 65 | LED_Write(&led, p.state); 66 | } 67 | 68 | INSTANTIATE_TEST_SUITE_P( 69 | LedWriteTests, 70 | LedParamTest, 71 | testing::Values( 72 | // activeLevel, state, expectedGpioState, testName 73 | LedParam{LED_ACTIVE_HIGH, LED_STATE_ON, GPIO_STATE_SET, "ActiveHigh_STATE_ON_GPIO_SET"}, 74 | LedParam{LED_ACTIVE_HIGH, LED_STATE_OFF, GPIO_STATE_RESET, "ActiveHigh_STATE_OFF_GPIO_RESET"}, 75 | LedParam{LED_ACTIVE_LOW, LED_STATE_ON, GPIO_STATE_RESET, "ActiveLow_STATE_ON_GPIO_RESET"}, 76 | LedParam{LED_ACTIVE_LOW, LED_STATE_OFF, GPIO_STATE_SET, "ActiveLow_STATE_OFF_GPIO_SET"}), 77 | [](const testing::TestParamInfo &info) 78 | { 79 | return info.param.testName; 80 | } 81 | 82 | ); 83 | 84 | TEST_F(LedUnitTest, LED_Toggle_WhenCalled_CallsGpioTogglePin) 85 | { 86 | LED_Initialize(&led, &gpio, LED_ACTIVE_HIGH); 87 | 88 | EXPECT_CALL(*mock, GPIO_TogglePin(&gpio)).Times(2); 89 | 90 | LED_Toggle(&led); 91 | LED_Toggle(&led); 92 | } -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_ltdc_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_ltdc_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of LTDC HAL Extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32F4xx_HAL_LTDC_EX_H 21 | #define STM32F4xx_HAL_LTDC_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f4xx_hal_def.h" 29 | 30 | #if defined (LTDC) && defined (DSI) 31 | 32 | #include "stm32f4xx_hal_dsi.h" 33 | 34 | /** @addtogroup STM32F4xx_HAL_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup LTDCEx 39 | * @{ 40 | */ 41 | 42 | /* Exported types ------------------------------------------------------------*/ 43 | /* Exported constants --------------------------------------------------------*/ 44 | /* Exported macro ------------------------------------------------------------*/ 45 | /* Exported functions --------------------------------------------------------*/ 46 | /** @addtogroup LTDCEx_Exported_Functions 47 | * @{ 48 | */ 49 | 50 | /** @addtogroup LTDCEx_Exported_Functions_Group1 51 | * @{ 52 | */ 53 | HAL_StatusTypeDef HAL_LTDCEx_StructInitFromVideoConfig(LTDC_HandleTypeDef *hltdc, DSI_VidCfgTypeDef *VidCfg); 54 | HAL_StatusTypeDef HAL_LTDCEx_StructInitFromAdaptedCommandConfig(LTDC_HandleTypeDef *hltdc, DSI_CmdCfgTypeDef *CmdCfg); 55 | /** 56 | * @} 57 | */ 58 | 59 | /** 60 | * @} 61 | */ 62 | 63 | /* Private types -------------------------------------------------------------*/ 64 | /* Private variables ---------------------------------------------------------*/ 65 | /* Private constants ---------------------------------------------------------*/ 66 | /* Private macros ------------------------------------------------------------*/ 67 | /* Private functions ---------------------------------------------------------*/ 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** 74 | * @} 75 | */ 76 | 77 | #endif /* LTDC && DSI */ 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | 83 | #endif /* STM32F4xx_HAL_LTDC_EX_H */ 84 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f4xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /** @addtogroup CMSIS 20 | * @{ 21 | */ 22 | 23 | /** @addtogroup stm32f4xx_system 24 | * @{ 25 | */ 26 | 27 | /** 28 | * @brief Define to prevent recursive inclusion 29 | */ 30 | #ifndef __SYSTEM_STM32F4XX_H 31 | #define __SYSTEM_STM32F4XX_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** @addtogroup STM32F4xx_System_Includes 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @} 43 | */ 44 | 45 | 46 | /** @addtogroup STM32F4xx_System_Exported_types 47 | * @{ 48 | */ 49 | /* This variable is updated in three ways: 50 | 1) by calling CMSIS function SystemCoreClockUpdate() 51 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 52 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 53 | Note: If you use this function to configure the system clock; then there 54 | is no need to call the 2 first functions listed above, since SystemCoreClock 55 | variable is updated automatically. 56 | */ 57 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 58 | 59 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 60 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @addtogroup STM32F4xx_System_Exported_Constants 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @addtogroup STM32F4xx_System_Exported_Macros 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @addtogroup STM32F4xx_System_Exported_Functions 83 | * @{ 84 | */ 85 | 86 | extern void SystemInit(void); 87 | extern void SystemCoreClockUpdate(void); 88 | /** 89 | * @} 90 | */ 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /*__SYSTEM_STM32F4XX_H */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /** 103 | * @} 104 | */ 105 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f4xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /** @addtogroup CMSIS 20 | * @{ 21 | */ 22 | 23 | /** @addtogroup stm32f4xx_system 24 | * @{ 25 | */ 26 | 27 | /** 28 | * @brief Define to prevent recursive inclusion 29 | */ 30 | #ifndef __SYSTEM_STM32F4XX_H 31 | #define __SYSTEM_STM32F4XX_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** @addtogroup STM32F4xx_System_Includes 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @} 43 | */ 44 | 45 | 46 | /** @addtogroup STM32F4xx_System_Exported_types 47 | * @{ 48 | */ 49 | /* This variable is updated in three ways: 50 | 1) by calling CMSIS function SystemCoreClockUpdate() 51 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 52 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 53 | Note: If you use this function to configure the system clock; then there 54 | is no need to call the 2 first functions listed above, since SystemCoreClock 55 | variable is updated automatically. 56 | */ 57 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 58 | 59 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 60 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @addtogroup STM32F4xx_System_Exported_Constants 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @addtogroup STM32F4xx_System_Exported_Macros 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @addtogroup STM32F4xx_System_Exported_Functions 83 | * @{ 84 | */ 85 | 86 | extern void SystemInit(void); 87 | extern void SystemCoreClockUpdate(void); 88 | /** 89 | * @} 90 | */ 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /*__SYSTEM_STM32F4XX_H */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /** 103 | * @} 104 | */ 105 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Src/sysmem.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file sysmem.c 4 | * @author Generated by STM32CubeIDE 5 | * @brief STM32CubeIDE System Memory calls file 6 | * 7 | * For more information about which C functions 8 | * need which of these lowlevel functions 9 | * please consult the newlib libc manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2022 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | 27 | /** 28 | * Pointer to the current high watermark of the heap usage 29 | */ 30 | static uint8_t *__sbrk_heap_end = NULL; 31 | 32 | /** 33 | * @brief _sbrk() allocates memory to the newlib heap and is used by malloc 34 | * and others from the C library 35 | * 36 | * @verbatim 37 | * ############################################################################ 38 | * # .data # .bss # newlib heap # MSP stack # 39 | * # # # # Reserved by _Min_Stack_Size # 40 | * ############################################################################ 41 | * ^-- RAM start ^-- _end _estack, RAM end --^ 42 | * @endverbatim 43 | * 44 | * This implementation starts allocating at the '_end' linker symbol 45 | * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack 46 | * The implementation considers '_estack' linker symbol to be RAM end 47 | * NOTE: If the MSP stack, at any point during execution, grows larger than the 48 | * reserved size, please increase the '_Min_Stack_Size'. 49 | * 50 | * @param incr Memory size 51 | * @return Pointer to allocated memory 52 | */ 53 | void *_sbrk(ptrdiff_t incr) 54 | { 55 | extern uint8_t _end; /* Symbol defined in the linker script */ 56 | extern uint8_t _estack; /* Symbol defined in the linker script */ 57 | extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ 58 | const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; 59 | const uint8_t *max_heap = (uint8_t *)stack_limit; 60 | uint8_t *prev_heap_end; 61 | 62 | /* Initialize heap end at first call */ 63 | if (NULL == __sbrk_heap_end) 64 | { 65 | __sbrk_heap_end = &_end; 66 | } 67 | 68 | /* Protect heap from growing into the reserved MSP stack */ 69 | if (__sbrk_heap_end + incr > max_heap) 70 | { 71 | errno = ENOMEM; 72 | return (void *)-1; 73 | } 74 | 75 | prev_heap_end = __sbrk_heap_end; 76 | __sbrk_heap_end += incr; 77 | 78 | return (void *)prev_heap_end; 79 | } 80 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/Core/Src/sysmem.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file sysmem.c 4 | * @author Generated by STM32CubeIDE 5 | * @brief STM32CubeIDE System Memory calls file 6 | * 7 | * For more information about which C functions 8 | * need which of these lowlevel functions 9 | * please consult the newlib libc manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2022 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | 27 | /** 28 | * Pointer to the current high watermark of the heap usage 29 | */ 30 | static uint8_t *__sbrk_heap_end = NULL; 31 | 32 | /** 33 | * @brief _sbrk() allocates memory to the newlib heap and is used by malloc 34 | * and others from the C library 35 | * 36 | * @verbatim 37 | * ############################################################################ 38 | * # .data # .bss # newlib heap # MSP stack # 39 | * # # # # Reserved by _Min_Stack_Size # 40 | * ############################################################################ 41 | * ^-- RAM start ^-- _end _estack, RAM end --^ 42 | * @endverbatim 43 | * 44 | * This implementation starts allocating at the '_end' linker symbol 45 | * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack 46 | * The implementation considers '_estack' linker symbol to be RAM end 47 | * NOTE: If the MSP stack, at any point during execution, grows larger than the 48 | * reserved size, please increase the '_Min_Stack_Size'. 49 | * 50 | * @param incr Memory size 51 | * @return Pointer to allocated memory 52 | */ 53 | void *_sbrk(ptrdiff_t incr) 54 | { 55 | extern uint8_t _end; /* Symbol defined in the linker script */ 56 | extern uint8_t _estack; /* Symbol defined in the linker script */ 57 | extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ 58 | const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; 59 | const uint8_t *max_heap = (uint8_t *)stack_limit; 60 | uint8_t *prev_heap_end; 61 | 62 | /* Initialize heap end at first call */ 63 | if (NULL == __sbrk_heap_end) 64 | { 65 | __sbrk_heap_end = &_end; 66 | } 67 | 68 | /* Protect heap from growing into the reserved MSP stack */ 69 | if (__sbrk_heap_end + incr > max_heap) 70 | { 71 | errno = ENOMEM; 72 | return (void *)-1; 73 | } 74 | 75 | prev_heap_end = __sbrk_heap_end; 76 | __sbrk_heap_end += incr; 77 | 78 | return (void *)prev_heap_end; 79 | } 80 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/Drivers/CMSIS/Include/tz_context.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file tz_context.h 3 | * @brief Context Management for Armv8-M TrustZone 4 | * @version V1.0.1 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef TZ_CONTEXT_H 32 | #define TZ_CONTEXT_H 33 | 34 | #include 35 | 36 | #ifndef TZ_MODULEID_T 37 | #define TZ_MODULEID_T 38 | /// \details Data type that identifies secure software modules called by a process. 39 | typedef uint32_t TZ_ModuleId_t; 40 | #endif 41 | 42 | /// \details TZ Memory ID identifies an allocated memory slot. 43 | typedef uint32_t TZ_MemoryId_t; 44 | 45 | /// Initialize secure context memory system 46 | /// \return execution status (1: success, 0: error) 47 | uint32_t TZ_InitContextSystem_S (void); 48 | 49 | /// Allocate context memory for calling secure software modules in TrustZone 50 | /// \param[in] module identifies software modules called from non-secure mode 51 | /// \return value != 0 id TrustZone memory slot identifier 52 | /// \return value 0 no memory available or internal error 53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); 54 | 55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S 56 | /// \param[in] id TrustZone memory slot identifier 57 | /// \return execution status (1: success, 0: error) 58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); 59 | 60 | /// Load secure context (called on RTOS thread context switch) 61 | /// \param[in] id TrustZone memory slot identifier 62 | /// \return execution status (1: success, 0: error) 63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); 64 | 65 | /// Store secure context (called on RTOS thread context switch) 66 | /// \param[in] id TrustZone memory slot identifier 67 | /// \return execution status (1: success, 0: error) 68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); 69 | 70 | #endif // TZ_CONTEXT_H 71 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/CMSIS/Include/tz_context.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file tz_context.h 3 | * @brief Context Management for Armv8-M TrustZone 4 | * @version V1.0.1 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef TZ_CONTEXT_H 32 | #define TZ_CONTEXT_H 33 | 34 | #include 35 | 36 | #ifndef TZ_MODULEID_T 37 | #define TZ_MODULEID_T 38 | /// \details Data type that identifies secure software modules called by a process. 39 | typedef uint32_t TZ_ModuleId_t; 40 | #endif 41 | 42 | /// \details TZ Memory ID identifies an allocated memory slot. 43 | typedef uint32_t TZ_MemoryId_t; 44 | 45 | /// Initialize secure context memory system 46 | /// \return execution status (1: success, 0: error) 47 | uint32_t TZ_InitContextSystem_S (void); 48 | 49 | /// Allocate context memory for calling secure software modules in TrustZone 50 | /// \param[in] module identifies software modules called from non-secure mode 51 | /// \return value != 0 id TrustZone memory slot identifier 52 | /// \return value 0 no memory available or internal error 53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); 54 | 55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S 56 | /// \param[in] id TrustZone memory slot identifier 57 | /// \return execution status (1: success, 0: error) 58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); 59 | 60 | /// Load secure context (called on RTOS thread context switch) 61 | /// \param[in] id TrustZone memory slot identifier 62 | /// \return execution status (1: success, 0: error) 63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); 64 | 65 | /// Store secure context (called on RTOS thread context switch) 66 | /// \param[in] id TrustZone memory slot identifier 67 | /// \return execution status (1: success, 0: error) 68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); 69 | 70 | #endif // TZ_CONTEXT_H 71 | -------------------------------------------------------------------------------- /tests/header-overrides/stm32f4xx_hal_gpio_override.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_gpio.h 4 | * @author MCD Application Team 5 | * @brief Header file of GPIO HAL module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __STM32F4xx_HAL_GPIO_H 21 | #define __STM32F4xx_HAL_GPIO_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** 28 | * @brief GPIO Bit SET and Bit RESET enumeration 29 | */ 30 | typedef enum 31 | { 32 | GPIO_PIN_RESET = 0, 33 | GPIO_PIN_SET 34 | }GPIO_PinState; 35 | 36 | /** @defgroup GPIO_pins_define GPIO pins define 37 | * @{ 38 | */ 39 | #define GPIO_PIN_0 ((uint16_t)0x0001) /* Pin 0 selected */ 40 | #define GPIO_PIN_1 ((uint16_t)0x0002) /* Pin 1 selected */ 41 | #define GPIO_PIN_2 ((uint16_t)0x0004) /* Pin 2 selected */ 42 | #define GPIO_PIN_3 ((uint16_t)0x0008) /* Pin 3 selected */ 43 | #define GPIO_PIN_4 ((uint16_t)0x0010) /* Pin 4 selected */ 44 | #define GPIO_PIN_5 ((uint16_t)0x0020) /* Pin 5 selected */ 45 | #define GPIO_PIN_6 ((uint16_t)0x0040) /* Pin 6 selected */ 46 | #define GPIO_PIN_7 ((uint16_t)0x0080) /* Pin 7 selected */ 47 | #define GPIO_PIN_8 ((uint16_t)0x0100) /* Pin 8 selected */ 48 | #define GPIO_PIN_9 ((uint16_t)0x0200) /* Pin 9 selected */ 49 | #define GPIO_PIN_10 ((uint16_t)0x0400) /* Pin 10 selected */ 50 | #define GPIO_PIN_11 ((uint16_t)0x0800) /* Pin 11 selected */ 51 | #define GPIO_PIN_12 ((uint16_t)0x1000) /* Pin 12 selected */ 52 | #define GPIO_PIN_13 ((uint16_t)0x2000) /* Pin 13 selected */ 53 | #define GPIO_PIN_14 ((uint16_t)0x4000) /* Pin 14 selected */ 54 | #define GPIO_PIN_15 ((uint16_t)0x8000) /* Pin 15 selected */ 55 | #define GPIO_PIN_All ((uint16_t)0xFFFF) /* All pins selected */ 56 | 57 | #define GPIO_PIN_MASK 0x0000FFFFU /* PIN mask for assert test */ 58 | 59 | #include "stm32f446xx_override.h" 60 | 61 | /** @addtogroup GPIO_Exported_Functions_Group2 62 | * @{ 63 | */ 64 | /* IO operation functions *****************************************************/ 65 | GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 66 | void HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState); 67 | void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* __STM32F4xx_HAL_GPIO_H */ 74 | 75 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_dma_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of DMA HAL extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __STM32F4xx_HAL_DMA_EX_H 21 | #define __STM32F4xx_HAL_DMA_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f4xx_hal_def.h" 29 | 30 | /** @addtogroup STM32F4xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup DMAEx 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /** @defgroup DMAEx_Exported_Types DMAEx Exported Types 40 | * @brief DMAEx Exported types 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief HAL DMA Memory definition 46 | */ 47 | typedef enum 48 | { 49 | MEMORY0 = 0x00U, /*!< Memory 0 */ 50 | MEMORY1 = 0x01U /*!< Memory 1 */ 51 | }HAL_DMA_MemoryTypeDef; 52 | 53 | /** 54 | * @} 55 | */ 56 | 57 | /* Exported functions --------------------------------------------------------*/ 58 | /** @defgroup DMAEx_Exported_Functions DMAEx Exported Functions 59 | * @brief DMAEx Exported functions 60 | * @{ 61 | */ 62 | 63 | /** @defgroup DMAEx_Exported_Functions_Group1 Extended features functions 64 | * @brief Extended features functions 65 | * @{ 66 | */ 67 | 68 | /* IO operation functions *******************************************************/ 69 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 70 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 71 | HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory); 72 | 73 | /** 74 | * @} 75 | */ 76 | /** 77 | * @} 78 | */ 79 | 80 | /* Private functions ---------------------------------------------------------*/ 81 | /** @defgroup DMAEx_Private_Functions DMAEx Private Functions 82 | * @brief DMAEx Private functions 83 | * @{ 84 | */ 85 | /** 86 | * @} 87 | */ 88 | 89 | /** 90 | * @} 91 | */ 92 | 93 | /** 94 | * @} 95 | */ 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /*__STM32F4xx_HAL_DMA_EX_H*/ 102 | 103 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_dma_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of DMA HAL extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __STM32F4xx_HAL_DMA_EX_H 21 | #define __STM32F4xx_HAL_DMA_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f4xx_hal_def.h" 29 | 30 | /** @addtogroup STM32F4xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup DMAEx 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /** @defgroup DMAEx_Exported_Types DMAEx Exported Types 40 | * @brief DMAEx Exported types 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief HAL DMA Memory definition 46 | */ 47 | typedef enum 48 | { 49 | MEMORY0 = 0x00U, /*!< Memory 0 */ 50 | MEMORY1 = 0x01U /*!< Memory 1 */ 51 | }HAL_DMA_MemoryTypeDef; 52 | 53 | /** 54 | * @} 55 | */ 56 | 57 | /* Exported functions --------------------------------------------------------*/ 58 | /** @defgroup DMAEx_Exported_Functions DMAEx Exported Functions 59 | * @brief DMAEx Exported functions 60 | * @{ 61 | */ 62 | 63 | /** @defgroup DMAEx_Exported_Functions_Group1 Extended features functions 64 | * @brief Extended features functions 65 | * @{ 66 | */ 67 | 68 | /* IO operation functions *******************************************************/ 69 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 70 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 71 | HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory); 72 | 73 | /** 74 | * @} 75 | */ 76 | /** 77 | * @} 78 | */ 79 | 80 | /* Private functions ---------------------------------------------------------*/ 81 | /** @defgroup DMAEx_Private_Functions DMAEx Private Functions 82 | * @brief DMAEx Private functions 83 | * @{ 84 | */ 85 | /** 86 | * @} 87 | */ 88 | 89 | /** 90 | * @} 91 | */ 92 | 93 | /** 94 | * @} 95 | */ 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /*__STM32F4xx_HAL_DMA_EX_H*/ 102 | 103 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Src/syscalls.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file syscalls.c 4 | * @author Auto-generated by STM32CubeIDE 5 | * @brief STM32CubeIDE Minimal System calls file 6 | * 7 | * For more information about which c-functions 8 | * need which of these lowlevel functions 9 | * please consult the Newlib libc-manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2022 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | 34 | /* Variables */ 35 | extern int __io_putchar(int ch) __attribute__((weak)); 36 | extern int __io_getchar(void) __attribute__((weak)); 37 | 38 | 39 | char *__env[1] = { 0 }; 40 | char **environ = __env; 41 | 42 | 43 | /* Functions */ 44 | void initialise_monitor_handles() 45 | { 46 | } 47 | 48 | int _getpid(void) 49 | { 50 | return 1; 51 | } 52 | 53 | int _kill(int pid, int sig) 54 | { 55 | errno = EINVAL; 56 | return -1; 57 | } 58 | 59 | void _exit (int status) 60 | { 61 | _kill(status, -1); 62 | while (1) {} /* Make sure we hang here */ 63 | } 64 | 65 | __attribute__((weak)) int _read(int file, char *ptr, int len) 66 | { 67 | int DataIdx; 68 | 69 | for (DataIdx = 0; DataIdx < len; DataIdx++) 70 | { 71 | *ptr++ = __io_getchar(); 72 | } 73 | 74 | return len; 75 | } 76 | 77 | __attribute__((weak)) int _write(int file, char *ptr, int len) 78 | { 79 | int DataIdx; 80 | 81 | for (DataIdx = 0; DataIdx < len; DataIdx++) 82 | { 83 | __io_putchar(*ptr++); 84 | } 85 | return len; 86 | } 87 | 88 | int _close(int file) 89 | { 90 | return -1; 91 | } 92 | 93 | 94 | int _fstat(int file, struct stat *st) 95 | { 96 | st->st_mode = S_IFCHR; 97 | return 0; 98 | } 99 | 100 | int _isatty(int file) 101 | { 102 | return 1; 103 | } 104 | 105 | int _lseek(int file, int ptr, int dir) 106 | { 107 | return 0; 108 | } 109 | 110 | int _open(char *path, int flags, ...) 111 | { 112 | /* Pretend like we always fail */ 113 | return -1; 114 | } 115 | 116 | int _wait(int *status) 117 | { 118 | errno = ECHILD; 119 | return -1; 120 | } 121 | 122 | int _unlink(char *name) 123 | { 124 | errno = ENOENT; 125 | return -1; 126 | } 127 | 128 | int _times(struct tms *buf) 129 | { 130 | return -1; 131 | } 132 | 133 | int _stat(char *file, struct stat *st) 134 | { 135 | st->st_mode = S_IFCHR; 136 | return 0; 137 | } 138 | 139 | int _link(char *old, char *new) 140 | { 141 | errno = EMLINK; 142 | return -1; 143 | } 144 | 145 | int _fork(void) 146 | { 147 | errno = EAGAIN; 148 | return -1; 149 | } 150 | 151 | int _execve(char *name, char **argv, char **env) 152 | { 153 | errno = ENOMEM; 154 | return -1; 155 | } 156 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/Core/Src/syscalls.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file syscalls.c 4 | * @author Auto-generated by STM32CubeIDE 5 | * @brief STM32CubeIDE Minimal System calls file 6 | * 7 | * For more information about which c-functions 8 | * need which of these lowlevel functions 9 | * please consult the Newlib libc-manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2022 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | 34 | /* Variables */ 35 | extern int __io_putchar(int ch) __attribute__((weak)); 36 | extern int __io_getchar(void) __attribute__((weak)); 37 | 38 | 39 | char *__env[1] = { 0 }; 40 | char **environ = __env; 41 | 42 | 43 | /* Functions */ 44 | void initialise_monitor_handles() 45 | { 46 | } 47 | 48 | int _getpid(void) 49 | { 50 | return 1; 51 | } 52 | 53 | int _kill(int pid, int sig) 54 | { 55 | errno = EINVAL; 56 | return -1; 57 | } 58 | 59 | void _exit (int status) 60 | { 61 | _kill(status, -1); 62 | while (1) {} /* Make sure we hang here */ 63 | } 64 | 65 | __attribute__((weak)) int _read(int file, char *ptr, int len) 66 | { 67 | int DataIdx; 68 | 69 | for (DataIdx = 0; DataIdx < len; DataIdx++) 70 | { 71 | *ptr++ = __io_getchar(); 72 | } 73 | 74 | return len; 75 | } 76 | 77 | __attribute__((weak)) int _write(int file, char *ptr, int len) 78 | { 79 | int DataIdx; 80 | 81 | for (DataIdx = 0; DataIdx < len; DataIdx++) 82 | { 83 | __io_putchar(*ptr++); 84 | } 85 | return len; 86 | } 87 | 88 | int _close(int file) 89 | { 90 | return -1; 91 | } 92 | 93 | 94 | int _fstat(int file, struct stat *st) 95 | { 96 | st->st_mode = S_IFCHR; 97 | return 0; 98 | } 99 | 100 | int _isatty(int file) 101 | { 102 | return 1; 103 | } 104 | 105 | int _lseek(int file, int ptr, int dir) 106 | { 107 | return 0; 108 | } 109 | 110 | int _open(char *path, int flags, ...) 111 | { 112 | /* Pretend like we always fail */ 113 | return -1; 114 | } 115 | 116 | int _wait(int *status) 117 | { 118 | errno = ECHILD; 119 | return -1; 120 | } 121 | 122 | int _unlink(char *name) 123 | { 124 | errno = ENOENT; 125 | return -1; 126 | } 127 | 128 | int _times(struct tms *buf) 129 | { 130 | return -1; 131 | } 132 | 133 | int _stat(char *file, struct stat *st) 134 | { 135 | st->st_mode = S_IFCHR; 136 | return 0; 137 | } 138 | 139 | int _link(char *old, char *new) 140 | { 141 | errno = EMLINK; 142 | return -1; 143 | } 144 | 145 | int _fork(void) 146 | { 147 | errno = EAGAIN; 148 | return -1; 149 | } 150 | 151 | int _execve(char *name, char **argv, char **env) 152 | { 153 | errno = ENOMEM; 154 | return -1; 155 | } 156 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/Core/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __MAIN_H 23 | #define __MAIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32f4xx_hal.h" 31 | 32 | /* Private includes ----------------------------------------------------------*/ 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* USER CODE BEGIN ET */ 39 | 40 | /* USER CODE END ET */ 41 | 42 | /* Exported constants --------------------------------------------------------*/ 43 | /* USER CODE BEGIN EC */ 44 | 45 | /* USER CODE END EC */ 46 | 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* USER CODE BEGIN EM */ 49 | 50 | /* USER CODE END EM */ 51 | 52 | /* Exported functions prototypes ---------------------------------------------*/ 53 | void Error_Handler(void); 54 | 55 | /* USER CODE BEGIN EFP */ 56 | 57 | /* USER CODE END EFP */ 58 | 59 | /* Private defines -----------------------------------------------------------*/ 60 | #define USER_Btn_Pin GPIO_PIN_13 61 | #define USER_Btn_GPIO_Port GPIOC 62 | #define MCO_Pin GPIO_PIN_0 63 | #define MCO_GPIO_Port GPIOH 64 | #define LD1_Pin GPIO_PIN_0 65 | #define LD1_GPIO_Port GPIOB 66 | #define LD3_Pin GPIO_PIN_14 67 | #define LD3_GPIO_Port GPIOB 68 | #define STLK_RX_Pin GPIO_PIN_8 69 | #define STLK_RX_GPIO_Port GPIOD 70 | #define STLK_TX_Pin GPIO_PIN_9 71 | #define STLK_TX_GPIO_Port GPIOD 72 | #define USB_PowerSwitchOn_Pin GPIO_PIN_6 73 | #define USB_PowerSwitchOn_GPIO_Port GPIOG 74 | #define USB_OverCurrent_Pin GPIO_PIN_7 75 | #define USB_OverCurrent_GPIO_Port GPIOG 76 | #define USB_SOF_Pin GPIO_PIN_8 77 | #define USB_SOF_GPIO_Port GPIOA 78 | #define USB_VBUS_Pin GPIO_PIN_9 79 | #define USB_VBUS_GPIO_Port GPIOA 80 | #define USB_ID_Pin GPIO_PIN_10 81 | #define USB_ID_GPIO_Port GPIOA 82 | #define USB_DM_Pin GPIO_PIN_11 83 | #define USB_DM_GPIO_Port GPIOA 84 | #define USB_DP_Pin GPIO_PIN_12 85 | #define USB_DP_GPIO_Port GPIOA 86 | #define TMS_Pin GPIO_PIN_13 87 | #define TMS_GPIO_Port GPIOA 88 | #define TCK_Pin GPIO_PIN_14 89 | #define TCK_GPIO_Port GPIOA 90 | #define LD2_Pin GPIO_PIN_7 91 | #define LD2_GPIO_Port GPIOB 92 | /* USER CODE BEGIN Private defines */ 93 | 94 | /* USER CODE END Private defines */ 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | #endif /* __MAIN_H */ 101 | -------------------------------------------------------------------------------- /tests/header-overrides/main_override.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __MAIN_H 23 | #define __MAIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | // #include "stm32f4xx_hal.h" 31 | 32 | /* Private includes ----------------------------------------------------------*/ 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* USER CODE BEGIN ET */ 39 | 40 | /* USER CODE END ET */ 41 | 42 | /* Exported constants --------------------------------------------------------*/ 43 | /* USER CODE BEGIN EC */ 44 | 45 | /* USER CODE END EC */ 46 | 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* USER CODE BEGIN EM */ 49 | 50 | /* USER CODE END EM */ 51 | 52 | /* Exported functions prototypes ---------------------------------------------*/ 53 | void Error_Handler(void); 54 | 55 | /* USER CODE BEGIN EFP */ 56 | 57 | /* USER CODE END EFP */ 58 | 59 | /* Private defines -----------------------------------------------------------*/ 60 | #define USER_Btn_Pin GPIO_PIN_13 61 | #define USER_Btn_GPIO_Port GPIOC 62 | #define MCO_Pin GPIO_PIN_0 63 | #define MCO_GPIO_Port GPIOH 64 | #define LD1_Pin GPIO_PIN_0 65 | #define LD1_GPIO_Port GPIOB 66 | #define LD3_Pin GPIO_PIN_14 67 | #define LD3_GPIO_Port GPIOB 68 | #define STLK_RX_Pin GPIO_PIN_8 69 | #define STLK_RX_GPIO_Port GPIOD 70 | #define STLK_TX_Pin GPIO_PIN_9 71 | #define STLK_TX_GPIO_Port GPIOD 72 | #define USB_PowerSwitchOn_Pin GPIO_PIN_6 73 | #define USB_PowerSwitchOn_GPIO_Port GPIOG 74 | #define USB_OverCurrent_Pin GPIO_PIN_7 75 | #define USB_OverCurrent_GPIO_Port GPIOG 76 | #define USB_SOF_Pin GPIO_PIN_8 77 | #define USB_SOF_GPIO_Port GPIOA 78 | #define USB_VBUS_Pin GPIO_PIN_9 79 | #define USB_VBUS_GPIO_Port GPIOA 80 | #define USB_ID_Pin GPIO_PIN_10 81 | #define USB_ID_GPIO_Port GPIOA 82 | #define USB_DM_Pin GPIO_PIN_11 83 | #define USB_DM_GPIO_Port GPIOA 84 | #define USB_DP_Pin GPIO_PIN_12 85 | #define USB_DP_GPIO_Port GPIOA 86 | #define TMS_Pin GPIO_PIN_13 87 | #define TMS_GPIO_Port GPIOA 88 | #define TCK_Pin GPIO_PIN_14 89 | #define TCK_GPIO_Port GPIOA 90 | #define LD2_Pin GPIO_PIN_7 91 | #define LD2_GPIO_Port GPIOB 92 | /* USER CODE BEGIN Private defines */ 93 | 94 | /* USER CODE END Private defines */ 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | #endif /* __MAIN_H */ 101 | -------------------------------------------------------------------------------- /docs/Doxyfile: -------------------------------------------------------------------------------- 1 | # Configuration for Doxygen for use with CMake 2 | # Only options that deviate from the default are included 3 | # To create a new Doxyfile containing all available options, call `doxygen -g` 4 | 5 | #--------------------------------------------------------------------------- 6 | # Project related configuration options 7 | #--------------------------------------------------------------------------- 8 | DOXYFILE_ENCODING = UTF-8 9 | PROJECT_NAME = "STM32 C code and Google Test Framework" 10 | PROJECT_NUMBER = 1.0 11 | PROJECT_BRIEF = 12 | PROJECT_LOGO = 13 | OUTPUT_DIRECTORY = ./ 14 | OUTPUT_LANGUAGE = English 15 | MARKDOWN_SUPPORT = YES 16 | 17 | #--------------------------------------------------------------------------- 18 | # Build related configuration options 19 | #--------------------------------------------------------------------------- 20 | EXTRACT_ALL = YES 21 | RECURSIVE = YES 22 | GENERATE_HTML = YES 23 | GENERATE_LATEX = NO 24 | HAVE_DOT = YES 25 | 26 | # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT tags are set 27 | # to YES then doxygen will generate a graph for each documented file showing the direct 28 | # and indirect include dependencies of the file with other documented files. 29 | INCLUDE_GRAPH = YES 30 | 31 | # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen will graphical 32 | # hierarchy of all classes instead of a textual one. 33 | GRAPHICAL_HIERARCHY = YES 34 | 35 | # If the CLASS_DIAGRAMS tag is set to YES (the default) doxygen will generate a class 36 | # diagram (in HTML and $\mbox{\LaTeX}$) for classes with base or super classes. 37 | CLASS_DIAGRAMS = YES 38 | 39 | # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen will generate a graph 40 | # for each documented class showing the direct and indirect inheritance relations. 41 | CLASS_GRAPH = YES 42 | 43 | # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen will generate a 44 | # graph for each documented class showing the direct and indirect implementation dependencies 45 | # (inheritance, containment, and class references variables) of the class with other documented classes. 46 | COLLABORATION_GRAPH = YES 47 | 48 | # If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will generate a call 49 | # dependency graph for every global function or class method 50 | CALL_GRAPH = YES 51 | UML_LOOK = YES 52 | UML_LIMIT_NUM_FIELDS = 50 53 | TEMPLATE_RELATIONS = YES 54 | DOT_GRAPH_MAX_NODES = 100 55 | MAX_DOT_GRAPH_DEPTH = 0 56 | DOT_TRANSPARENT = YES 57 | HIDE_UNDOC_RELATIONS = NO 58 | 59 | #--------------------------------------------------------------------------- 60 | # Configuration options related to the input files 61 | #--------------------------------------------------------------------------- 62 | USE_MDFILE_AS_MAINPAGE = ../README.md 63 | IMAGE_PATH = ./images 64 | INPUT = ../README.md \ 65 | INPUT = ../source/nucleo-f446ze-library/Libraries 66 | INPUT_ENCODING = UTF-8 67 | FILE_PATTERNS = *.c \ 68 | *.cc \ 69 | *.cpp \ 70 | *.c++ \ 71 | *.h \ 72 | *.hpp \ 73 | *.h++ \ 74 | *.md \ 75 | *.dox \ 76 | *.doc \ 77 | *.txt 78 | 79 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_i2c_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of I2C HAL Extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __STM32F4xx_HAL_I2C_EX_H 21 | #define __STM32F4xx_HAL_I2C_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #if defined(I2C_FLTR_ANOFF)&&defined(I2C_FLTR_DNF) 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f4xx_hal_def.h" 30 | 31 | /** @addtogroup STM32F4xx_HAL_Driver 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup I2CEx 36 | * @{ 37 | */ 38 | 39 | /* Exported types ------------------------------------------------------------*/ 40 | /* Exported constants --------------------------------------------------------*/ 41 | /** @defgroup I2CEx_Exported_Constants I2C Exported Constants 42 | * @{ 43 | */ 44 | 45 | /** @defgroup I2CEx_Analog_Filter I2C Analog Filter 46 | * @{ 47 | */ 48 | #define I2C_ANALOGFILTER_ENABLE 0x00000000U 49 | #define I2C_ANALOGFILTER_DISABLE I2C_FLTR_ANOFF 50 | /** 51 | * @} 52 | */ 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /* Exported macro ------------------------------------------------------------*/ 59 | /* Exported functions --------------------------------------------------------*/ 60 | /** @addtogroup I2CEx_Exported_Functions 61 | * @{ 62 | */ 63 | 64 | /** @addtogroup I2CEx_Exported_Functions_Group1 65 | * @{ 66 | */ 67 | /* Peripheral Control functions ************************************************/ 68 | HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter); 69 | HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter); 70 | /** 71 | * @} 72 | */ 73 | 74 | /** 75 | * @} 76 | */ 77 | /* Private types -------------------------------------------------------------*/ 78 | /* Private variables ---------------------------------------------------------*/ 79 | /* Private constants ---------------------------------------------------------*/ 80 | /** @defgroup I2CEx_Private_Constants I2C Private Constants 81 | * @{ 82 | */ 83 | 84 | /** 85 | * @} 86 | */ 87 | 88 | /* Private macros ------------------------------------------------------------*/ 89 | /** @defgroup I2CEx_Private_Macros I2C Private Macros 90 | * @{ 91 | */ 92 | #define IS_I2C_ANALOG_FILTER(FILTER) (((FILTER) == I2C_ANALOGFILTER_ENABLE) || \ 93 | ((FILTER) == I2C_ANALOGFILTER_DISABLE)) 94 | #define IS_I2C_DIGITAL_FILTER(FILTER) ((FILTER) <= 0x0000000FU) 95 | /** 96 | * @} 97 | */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | #endif 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | 113 | #endif /* __STM32F4xx_HAL_I2C_EX_H */ 114 | 115 | 116 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_pcd_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of PCD HAL Extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32F4xx_HAL_PCD_EX_H 21 | #define STM32F4xx_HAL_PCD_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif /* __cplusplus */ 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f4xx_hal_def.h" 29 | 30 | #if defined (USB_OTG_FS) || defined (USB_OTG_HS) 31 | /** @addtogroup STM32F4xx_HAL_Driver 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup PCDEx 36 | * @{ 37 | */ 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* Exported constants --------------------------------------------------------*/ 40 | /* Exported macros -----------------------------------------------------------*/ 41 | /* Exported functions --------------------------------------------------------*/ 42 | /** @addtogroup PCDEx_Exported_Functions PCDEx Exported Functions 43 | * @{ 44 | */ 45 | /** @addtogroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 46 | * @{ 47 | */ 48 | 49 | #if defined (USB_OTG_FS) || defined (USB_OTG_HS) 50 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size); 51 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size); 52 | #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */ 53 | 54 | #if defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) 55 | HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd); 56 | HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd); 57 | #endif /* defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) */ 58 | #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) 59 | HAL_StatusTypeDef HAL_PCDEx_ActivateBCD(PCD_HandleTypeDef *hpcd); 60 | HAL_StatusTypeDef HAL_PCDEx_DeActivateBCD(PCD_HandleTypeDef *hpcd); 61 | void HAL_PCDEx_BCD_VBUSDetect(PCD_HandleTypeDef *hpcd); 62 | #endif /* defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) */ 63 | void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg); 64 | void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg); 65 | 66 | /** 67 | * @} 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** 75 | * @} 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */ 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif /* __cplusplus */ 86 | 87 | 88 | #endif /* STM32F4xx_HAL_PCD_EX_H */ 89 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_pcd_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of PCD HAL Extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32F4xx_HAL_PCD_EX_H 21 | #define STM32F4xx_HAL_PCD_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif /* __cplusplus */ 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f4xx_hal_def.h" 29 | 30 | #if defined (USB_OTG_FS) || defined (USB_OTG_HS) 31 | /** @addtogroup STM32F4xx_HAL_Driver 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup PCDEx 36 | * @{ 37 | */ 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* Exported constants --------------------------------------------------------*/ 40 | /* Exported macros -----------------------------------------------------------*/ 41 | /* Exported functions --------------------------------------------------------*/ 42 | /** @addtogroup PCDEx_Exported_Functions PCDEx Exported Functions 43 | * @{ 44 | */ 45 | /** @addtogroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 46 | * @{ 47 | */ 48 | 49 | #if defined (USB_OTG_FS) || defined (USB_OTG_HS) 50 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size); 51 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size); 52 | #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */ 53 | 54 | #if defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) 55 | HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd); 56 | HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd); 57 | #endif /* defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) */ 58 | #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) 59 | HAL_StatusTypeDef HAL_PCDEx_ActivateBCD(PCD_HandleTypeDef *hpcd); 60 | HAL_StatusTypeDef HAL_PCDEx_DeActivateBCD(PCD_HandleTypeDef *hpcd); 61 | void HAL_PCDEx_BCD_VBUSDetect(PCD_HandleTypeDef *hpcd); 62 | #endif /* defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) */ 63 | void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg); 64 | void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg); 65 | 66 | /** 67 | * @} 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** 75 | * @} 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */ 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif /* __cplusplus */ 86 | 87 | 88 | #endif /* STM32F4xx_HAL_PCD_EX_H */ 89 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(GoogleTest) 2 | 3 | ############################ Test Project ############################ 4 | set(SOURCE_FOLDER_PATH "${CMAKE_SOURCE_DIR}/stm32-cube-ide") 5 | set(TEST_FOLDER_PATH "${CMAKE_SOURCE_DIR}/tests") 6 | 7 | # target_include_directories( ${HELLO_UNIT_TEST} PRIVATE 8 | # ${TEST_FOLDER_PATH}/header-overrides 9 | # ${TEST_FOLDER_PATH}/mock 10 | # ) 11 | 12 | include_directories( 13 | ${TEST_FOLDER_PATH}/header-overrides 14 | ${TEST_FOLDER_PATH}/mock 15 | ) 16 | 17 | # set(ASSERT_MOCK AssertMock) 18 | # add_library(${ASSERT_MOCK} 19 | # ${TEST_FOLDER_PATH}/mock/assert_mock.c 20 | # ) 21 | 22 | ###################################################################### 23 | # Hello unit test 24 | set(HELLO_UNIT_TEST HelloUnitTest) 25 | add_executable( ${HELLO_UNIT_TEST} 26 | ${TEST_FOLDER_PATH}/unit/hello_unit_test.cpp 27 | ) 28 | 29 | target_link_libraries( ${HELLO_UNIT_TEST} PUBLIC 30 | GTest::gtest_main 31 | ) 32 | gtest_discover_tests( ${HELLO_UNIT_TEST} 33 | # See 34 | # https://cmake.org/cmake/help/latest/module/GoogleTest.html#command:gtest_discover_tests 35 | # 36 | # XML_OUTPUT_DIR dir 37 | # New in version 3.18. 38 | 39 | # If specified, the parameter is passed along with --gtest_output=xml: to test executable. 40 | # The actual file name is the same as the test target, including prefix and suffix. This should 41 | # be used instead of EXTRA_ARGS --gtest_output=xml to avoid race conditions writing the XML 42 | # result output when using parallel test execution. 43 | 44 | # XML_OUTPUT_DIR ${TEST_FOLDER_PATH} 45 | ) 46 | 47 | ###################################################################### 48 | # Hello integration test 49 | set(HELLO_INTEGRATION_TEST HelloIntegrationTest) 50 | add_executable( ${HELLO_INTEGRATION_TEST} 51 | ${TEST_FOLDER_PATH}/integration/hello_integration_test.cpp 52 | ) 53 | target_link_libraries( ${HELLO_INTEGRATION_TEST} 54 | GTest::gtest_main 55 | ) 56 | gtest_discover_tests( ${HELLO_INTEGRATION_TEST} 57 | ) 58 | 59 | ###################################################################### 60 | # Unit tests for drivers functions 61 | set(DRIVERS_UNIT_TEST DriversUnitTest) 62 | add_executable( ${DRIVERS_UNIT_TEST} 63 | ${TEST_FOLDER_PATH}/unit/drivers/gpio_test.cpp 64 | ) 65 | 66 | target_link_libraries( ${DRIVERS_UNIT_TEST} PUBLIC 67 | ${DRIVERS_LIBRARY_TARGET} 68 | # ${ASSERT_MOCK} 69 | GTest::gmock_main 70 | ) 71 | gtest_discover_tests( ${DRIVERS_UNIT_TEST} 72 | ) 73 | 74 | ###################################################################### 75 | # Unit tests for middleware functions 76 | set(MIDDLEWARE_UNIT_TEST MiddlewareUnitTest) 77 | add_executable( ${MIDDLEWARE_UNIT_TEST} 78 | ${TEST_FOLDER_PATH}/unit/middleware/led_test.cpp 79 | ${TEST_FOLDER_PATH}/mock/gpio_mock.cpp 80 | ) 81 | 82 | target_link_libraries( ${MIDDLEWARE_UNIT_TEST} PUBLIC 83 | ${MIDDLEWARE_LIBRARY_TARGET} 84 | GTest::gmock_main 85 | ) 86 | gtest_discover_tests( ${MIDDLEWARE_UNIT_TEST} 87 | ) 88 | 89 | ###################################################################### 90 | # Settings for code coverage 91 | if (ENABLE_COVERAGE) 92 | set(COVERAGE_MAIN "coverage") 93 | 94 | set(COVERAGE_EXCLUDES 95 | "${PROJECT_SOURCE_DIR}/build/*" 96 | "${PROJECT_SOURCE_DIR}/stm32-cube-ide/*" 97 | "${PROJECT_SOURCE_DIR}/cmake/*" 98 | "${PROJECT_SOURCE_DIR}/docs/*" 99 | # "${PROJECT_SOURCE_DIR}/external/*" 100 | "${PROJECT_SOURCE_DIR}/tests/*" 101 | "/usr/include/*" 102 | ) 103 | 104 | set(COVERAGE_DEPENDENCIES 105 | ${DRIVERS_UNIT_TEST} 106 | ${MIDDLEWARE_UNIT_TEST} 107 | ${HELLO_UNIT_TEST} 108 | ${HELLO_INTEGRATION_TEST} 109 | ) 110 | 111 | setup_target_for_coverage_lcov( 112 | NAME ${COVERAGE_MAIN} 113 | EXECUTABLE ctest -j${PROCESSOR_COUNT} 114 | DEPENDENCIES ${COVERAGE_DEPENDENCIES} 115 | EXCLUDE ${COVERAGE_EXCLUDES} 116 | ) 117 | 118 | endif() -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cryp_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_cryp_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of CRYP HAL Extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __STM32F4xx_HAL_CRYP_EX_H 21 | #define __STM32F4xx_HAL_CRYP_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f4xx_hal_def.h" 29 | 30 | /** @addtogroup STM32F4xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup CRYPEx 35 | * @{ 36 | */ 37 | /* Exported types ------------------------------------------------------------*/ 38 | /** @defgroup CRYPEx_Exported_Types CRYPEx Exported types 39 | * @{ 40 | */ 41 | 42 | /** 43 | * @} 44 | */ 45 | /* Exported constants --------------------------------------------------------*/ 46 | /** @defgroup CRYPEx_Exported_Constants CRYPEx Exported constants 47 | * @{ 48 | */ 49 | 50 | /** 51 | * @} 52 | */ 53 | 54 | /* Private types -------------------------------------------------------------*/ 55 | /** @defgroup CRYPEx_Private_Types CRYPEx Private Types 56 | * @{ 57 | */ 58 | 59 | /** 60 | * @} 61 | */ 62 | 63 | /* Private variables ---------------------------------------------------------*/ 64 | /** @defgroup CRYPEx_Private_Variables CRYPEx Private Variables 65 | * @{ 66 | */ 67 | 68 | /** 69 | * @} 70 | */ 71 | 72 | /* Private constants ---------------------------------------------------------*/ 73 | /** @defgroup CRYPEx_Private_Constants CRYPEx Private Constants 74 | * @{ 75 | */ 76 | 77 | /** 78 | * @} 79 | */ 80 | 81 | /* Private macros ------------------------------------------------------------*/ 82 | /** @defgroup CRYPEx_Private_Macros CRYPEx Private Macros 83 | * @{ 84 | */ 85 | 86 | /** 87 | * @} 88 | */ 89 | 90 | /* Private functions ---------------------------------------------------------*/ 91 | /** @defgroup CRYPEx_Private_Functions CRYPEx Private Functions 92 | * @{ 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /* Exported functions --------------------------------------------------------*/ 100 | /** @defgroup CRYPEx_Exported_Functions CRYPEx Exported Functions 101 | * @{ 102 | */ 103 | #if defined (CRYP) || defined (AES) 104 | /** @addtogroup CRYPEx_Exported_Functions_Group1 105 | * @{ 106 | */ 107 | HAL_StatusTypeDef HAL_CRYPEx_AESGCM_GenerateAuthTAG(CRYP_HandleTypeDef *hcryp, uint32_t *AuthTag, uint32_t Timeout); 108 | HAL_StatusTypeDef HAL_CRYPEx_AESCCM_GenerateAuthTAG(CRYP_HandleTypeDef *hcryp, uint32_t *AuthTag, uint32_t Timeout); 109 | /** 110 | * @} 111 | */ 112 | #endif /* CRYP||AES */ 113 | 114 | #if defined (AES) 115 | /** @addtogroup CRYPEx_Exported_Functions_Group2 116 | * @{ 117 | */ 118 | void HAL_CRYPEx_EnableAutoKeyDerivation(CRYP_HandleTypeDef *hcryp); 119 | void HAL_CRYPEx_DisableAutoKeyDerivation(CRYP_HandleTypeDef *hcryp); 120 | /** 121 | * @} 122 | */ 123 | #endif /* AES */ 124 | 125 | /** 126 | * @} 127 | */ 128 | 129 | /** 130 | * @} 131 | */ 132 | 133 | /** 134 | * @} 135 | */ 136 | 137 | #ifdef __cplusplus 138 | } 139 | #endif 140 | 141 | #endif /* __STM32F4xx_HAL_CRYP_EX_H */ 142 | 143 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_sai_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_sai_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of SAI Extension HAL module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __STM32F4xx_HAL_SAI_EX_H 21 | #define __STM32F4xx_HAL_SAI_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f4xx_hal_def.h" 29 | 30 | /** @addtogroup STM32F4xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup SAIEx 35 | * @{ 36 | */ 37 | 38 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \ 39 | defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F413xx) || \ 40 | defined(STM32F423xx) 41 | 42 | /* Exported types ------------------------------------------------------------*/ 43 | /* Exported constants --------------------------------------------------------*/ 44 | /** @defgroup SAI_Clock_Source SAI Clock Source 45 | * @{ 46 | */ 47 | #if defined(STM32F413xx) || defined(STM32F423xx) 48 | #define SAI_CLKSOURCE_PLLI2S 0x00000000U 49 | #define SAI_CLKSOURCE_EXT 0x00100000U 50 | #define SAI_CLKSOURCE_PLLR 0x00200000U 51 | #define SAI_CLKSOURCE_HS 0x00300000U 52 | #else 53 | #define SAI_CLKSOURCE_PLLSAI 0x00000000U 54 | #define SAI_CLKSOURCE_PLLI2S 0x00100000U 55 | #define SAI_CLKSOURCE_EXT 0x00200000U 56 | #define SAI_CLKSOURCE_NA 0x00400000U /*!< No applicable for STM32F446xx */ 57 | #endif 58 | 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | /* Exported functions --------------------------------------------------------*/ 65 | /** @addtogroup SAIEx_Exported_Functions 66 | * @{ 67 | */ 68 | 69 | /** @addtogroup SAIEx_Exported_Functions_Group1 70 | * @{ 71 | */ 72 | 73 | /* Extended features functions ************************************************/ 74 | void SAI_BlockSynchroConfig(SAI_HandleTypeDef *hsai); 75 | uint32_t SAI_GetInputClock(SAI_HandleTypeDef *hsai); 76 | /** 77 | * @} 78 | */ 79 | 80 | /** 81 | * @} 82 | */ 83 | /* Private types -------------------------------------------------------------*/ 84 | /* Private variables ---------------------------------------------------------*/ 85 | /* Private constants ---------------------------------------------------------*/ 86 | /* Private macros ------------------------------------------------------------*/ 87 | #if defined(STM32F413xx) || defined(STM32F423xx) 88 | #define IS_SAI_CLK_SOURCE(SOURCE) (((SOURCE) == SAI_CLKSOURCE_PLLI2S) ||\ 89 | ((SOURCE) == SAI_CLKSOURCE_EXT)||\ 90 | ((SOURCE) == SAI_CLKSOURCE_PLLR)||\ 91 | ((SOURCE) == SAI_CLKSOURCE_HS)) 92 | #else 93 | #define IS_SAI_CLK_SOURCE(SOURCE) (((SOURCE) == SAI_CLKSOURCE_PLLSAI) ||\ 94 | ((SOURCE) == SAI_CLKSOURCE_EXT)||\ 95 | ((SOURCE) == SAI_CLKSOURCE_PLLI2S)||\ 96 | ((SOURCE) == SAI_CLKSOURCE_NA)) 97 | #endif 98 | /* Private functions ---------------------------------------------------------*/ 99 | 100 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx || STM32F413xx || STM32F423xx */ 101 | /** 102 | * @} 103 | */ 104 | 105 | /** 106 | * @} 107 | */ 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | 113 | #endif /* __STM32F4xx_HAL_SAI_EX_H */ 114 | 115 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_fmpsmbus_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_fmpsmbus_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of FMPSMBUS HAL Extended module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32F4xx_HAL_FMPSMBUS_EX_H 21 | #define STM32F4xx_HAL_FMPSMBUS_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #if defined(FMPI2C_CR1_PE) 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f4xx_hal_def.h" 30 | 31 | /** @addtogroup STM32F4xx_HAL_Driver 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup FMPSMBUSEx 36 | * @{ 37 | */ 38 | 39 | /* Exported types ------------------------------------------------------------*/ 40 | /* Exported constants --------------------------------------------------------*/ 41 | /** @defgroup FMPSMBUSEx_Exported_Constants FMPSMBUS Extended Exported Constants 42 | * @{ 43 | */ 44 | 45 | /** @defgroup FMPSMBUSEx_FastModePlus FMPSMBUS Extended Fast Mode Plus 46 | * @{ 47 | */ 48 | #define FMPSMBUS_FASTMODEPLUS_SCL SYSCFG_CFGR_FMPI2C1_SCL /*!< Enable Fast Mode Plus on FMPI2C1 SCL pins */ 49 | #define FMPSMBUS_FASTMODEPLUS_SDA SYSCFG_CFGR_FMPI2C1_SDA /*!< Enable Fast Mode Plus on FMPI2C1 SDA pins */ 50 | /** 51 | * @} 52 | */ 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /* Exported macro ------------------------------------------------------------*/ 59 | /** @defgroup FMPSMBUSEx_Exported_Macros FMPSMBUS Extended Exported Macros 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /* Exported functions --------------------------------------------------------*/ 68 | /** @addtogroup FMPSMBUSEx_Exported_Functions FMPSMBUS Extended Exported Functions 69 | * @{ 70 | */ 71 | 72 | /** @addtogroup FMPSMBUSEx_Exported_Functions_Group2 WakeUp Mode Functions 73 | * @{ 74 | */ 75 | /* Peripheral Control functions ************************************************/ 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @addtogroup FMPSMBUSEx_Exported_Functions_Group3 Fast Mode Plus Functions 81 | * @{ 82 | */ 83 | void HAL_FMPSMBUSEx_EnableFastModePlus(uint32_t ConfigFastModePlus); 84 | void HAL_FMPSMBUSEx_DisableFastModePlus(uint32_t ConfigFastModePlus); 85 | /** 86 | * @} 87 | */ 88 | 89 | /** 90 | * @} 91 | */ 92 | 93 | /* Private constants ---------------------------------------------------------*/ 94 | /** @defgroup FMPSMBUSEx_Private_Constants FMPSMBUS Extended Private Constants 95 | * @{ 96 | */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /* Private macros ------------------------------------------------------------*/ 103 | /** @defgroup FMPSMBUSEx_Private_Macro FMPSMBUS Extended Private Macros 104 | * @{ 105 | */ 106 | #define IS_FMPSMBUS_FASTMODEPLUS(__CONFIG__) ((((__CONFIG__) & (FMPSMBUS_FASTMODEPLUS_SCL)) == \ 107 | FMPSMBUS_FASTMODEPLUS_SCL) || \ 108 | (((__CONFIG__) & (FMPSMBUS_FASTMODEPLUS_SDA)) == \ 109 | FMPSMBUS_FASTMODEPLUS_SDA)) 110 | /** 111 | * @} 112 | */ 113 | 114 | /* Private Functions ---------------------------------------------------------*/ 115 | /** @defgroup FMPSMBUSEx_Private_Functions FMPSMBUS Extended Private Functions 116 | * @{ 117 | */ 118 | /* Private functions are defined in stm32f4xx_hal_fmpsmbus_ex.c file */ 119 | /** 120 | * @} 121 | */ 122 | 123 | /** 124 | * @} 125 | */ 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | #endif /* FMPI2C_CR1_PE */ 132 | #ifdef __cplusplus 133 | } 134 | #endif 135 | 136 | #endif /* STM32F4xx_HAL_FMPSMBUS_EX_H */ 137 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_fmpi2c_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_fmpi2c_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of FMPI2C HAL Extended module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32F4xx_HAL_FMPI2C_EX_H 21 | #define STM32F4xx_HAL_FMPI2C_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #if defined(FMPI2C_CR1_PE) 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f4xx_hal_def.h" 30 | 31 | /** @addtogroup STM32F4xx_HAL_Driver 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup FMPI2CEx 36 | * @{ 37 | */ 38 | 39 | /* Exported types ------------------------------------------------------------*/ 40 | /* Exported constants --------------------------------------------------------*/ 41 | /** @defgroup FMPI2CEx_Exported_Constants FMPI2C Extended Exported Constants 42 | * @{ 43 | */ 44 | 45 | /** @defgroup FMPI2CEx_Analog_Filter FMPI2C Extended Analog Filter 46 | * @{ 47 | */ 48 | #define FMPI2C_ANALOGFILTER_ENABLE 0x00000000U 49 | #define FMPI2C_ANALOGFILTER_DISABLE FMPI2C_CR1_ANFOFF 50 | /** 51 | * @} 52 | */ 53 | 54 | /** @defgroup FMPI2CEx_FastModePlus FMPI2C Extended Fast Mode Plus 55 | * @{ 56 | */ 57 | #define FMPI2C_FASTMODEPLUS_SCL SYSCFG_CFGR_FMPI2C1_SCL /*!< Enable Fast Mode Plus on FMPI2C1 SCL pins */ 58 | #define FMPI2C_FASTMODEPLUS_SDA SYSCFG_CFGR_FMPI2C1_SDA /*!< Enable Fast Mode Plus on FMPI2C1 SDA pins */ 59 | /** 60 | * @} 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /* Exported macro ------------------------------------------------------------*/ 68 | /** @defgroup FMPI2CEx_Exported_Macros FMPI2C Extended Exported Macros 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /* Exported functions --------------------------------------------------------*/ 77 | /** @addtogroup FMPI2CEx_Exported_Functions FMPI2C Extended Exported Functions 78 | * @{ 79 | */ 80 | 81 | /** @addtogroup FMPI2CEx_Exported_Functions_Group1 Filter Mode Functions 82 | * @{ 83 | */ 84 | /* Peripheral Control functions ************************************************/ 85 | HAL_StatusTypeDef HAL_FMPI2CEx_ConfigAnalogFilter(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t AnalogFilter); 86 | HAL_StatusTypeDef HAL_FMPI2CEx_ConfigDigitalFilter(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t DigitalFilter); 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @addtogroup FMPI2CEx_Exported_Functions_Group3 Fast Mode Plus Functions 92 | * @{ 93 | */ 94 | void HAL_FMPI2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus); 95 | void HAL_FMPI2CEx_DisableFastModePlus(uint32_t ConfigFastModePlus); 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | /* Private constants ---------------------------------------------------------*/ 105 | /** @defgroup FMPI2CEx_Private_Constants FMPI2C Extended Private Constants 106 | * @{ 107 | */ 108 | 109 | /** 110 | * @} 111 | */ 112 | 113 | /* Private macros ------------------------------------------------------------*/ 114 | /** @defgroup FMPI2CEx_Private_Macro FMPI2C Extended Private Macros 115 | * @{ 116 | */ 117 | #define IS_FMPI2C_ANALOG_FILTER(FILTER) (((FILTER) == FMPI2C_ANALOGFILTER_ENABLE) || \ 118 | ((FILTER) == FMPI2C_ANALOGFILTER_DISABLE)) 119 | 120 | #define IS_FMPI2C_DIGITAL_FILTER(FILTER) ((FILTER) <= 0x0000000FU) 121 | 122 | #define IS_FMPI2C_FASTMODEPLUS(__CONFIG__) ((((__CONFIG__) & (FMPI2C_FASTMODEPLUS_SCL)) == FMPI2C_FASTMODEPLUS_SCL) || \ 123 | (((__CONFIG__) & (FMPI2C_FASTMODEPLUS_SDA)) == FMPI2C_FASTMODEPLUS_SDA)) 124 | /** 125 | * @} 126 | */ 127 | 128 | /* Private Functions ---------------------------------------------------------*/ 129 | /** @defgroup FMPI2CEx_Private_Functions FMPI2C Extended Private Functions 130 | * @{ 131 | */ 132 | /* Private functions are defined in stm32f4xx_hal_fmpi2c_ex.c file */ 133 | /** 134 | * @} 135 | */ 136 | 137 | /** 138 | * @} 139 | */ 140 | 141 | /** 142 | * @} 143 | */ 144 | 145 | #endif /* FMPI2C_CR1_PE */ 146 | #ifdef __cplusplus 147 | } 148 | #endif 149 | 150 | #endif /* STM32F4xx_HAL_FMPI2C_EX_H */ 151 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/STM32F446ZETX_RAM.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** @file : LinkerScript.ld (debug in RAM dedicated) 5 | ** 6 | ** @author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** Abstract : Linker script for NUCLEO-F446ZE Board embedding STM32F446ZETx Device from stm32f4 series 9 | ** 512Kbytes FLASH 10 | ** 128Kbytes RAM 11 | ** 12 | ** Set heap size, stack size and stack location according 13 | ** to application requirements. 14 | ** 15 | ** Set memory bank area and size if external memory is used 16 | ** 17 | ** Target : STMicroelectronics STM32 18 | ** 19 | ** Distribution: The file is distributed as is, without any warranty 20 | ** of any kind. 21 | ** 22 | ****************************************************************************** 23 | ** @attention 24 | ** 25 | ** Copyright (c) 2022 STMicroelectronics. 26 | ** All rights reserved. 27 | ** 28 | ** This software is licensed under terms that can be found in the LICENSE file 29 | ** in the root directory of this software component. 30 | ** If no LICENSE file comes with this software, it is provided AS-IS. 31 | ** 32 | ****************************************************************************** 33 | */ 34 | 35 | /* Entry Point */ 36 | ENTRY(Reset_Handler) 37 | 38 | /* Highest address of the user mode stack */ 39 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ 40 | 41 | _Min_Heap_Size = 0x200; /* required amount of heap */ 42 | _Min_Stack_Size = 0x400; /* required amount of stack */ 43 | 44 | /* Memories definition */ 45 | MEMORY 46 | { 47 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K 48 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K 49 | } 50 | 51 | /* Sections */ 52 | SECTIONS 53 | { 54 | /* The startup code into "RAM" Ram type memory */ 55 | .isr_vector : 56 | { 57 | . = ALIGN(4); 58 | KEEP(*(.isr_vector)) /* Startup code */ 59 | . = ALIGN(4); 60 | } >RAM 61 | 62 | /* The program code and other data into "RAM" Ram type memory */ 63 | .text : 64 | { 65 | . = ALIGN(4); 66 | *(.text) /* .text sections (code) */ 67 | *(.text*) /* .text* sections (code) */ 68 | *(.glue_7) /* glue arm to thumb code */ 69 | *(.glue_7t) /* glue thumb to arm code */ 70 | *(.eh_frame) 71 | *(.RamFunc) /* .RamFunc sections */ 72 | *(.RamFunc*) /* .RamFunc* sections */ 73 | 74 | KEEP (*(.init)) 75 | KEEP (*(.fini)) 76 | 77 | . = ALIGN(4); 78 | _etext = .; /* define a global symbols at end of code */ 79 | } >RAM 80 | 81 | /* Constant data into "RAM" Ram type memory */ 82 | .rodata : 83 | { 84 | . = ALIGN(4); 85 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 86 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 87 | . = ALIGN(4); 88 | } >RAM 89 | 90 | .ARM.extab : { 91 | . = ALIGN(4); 92 | *(.ARM.extab* .gnu.linkonce.armextab.*) 93 | . = ALIGN(4); 94 | } >RAM 95 | 96 | .ARM : { 97 | . = ALIGN(4); 98 | __exidx_start = .; 99 | *(.ARM.exidx*) 100 | __exidx_end = .; 101 | . = ALIGN(4); 102 | } >RAM 103 | 104 | .preinit_array : 105 | { 106 | . = ALIGN(4); 107 | PROVIDE_HIDDEN (__preinit_array_start = .); 108 | KEEP (*(.preinit_array*)) 109 | PROVIDE_HIDDEN (__preinit_array_end = .); 110 | . = ALIGN(4); 111 | } >RAM 112 | 113 | .init_array : 114 | { 115 | . = ALIGN(4); 116 | PROVIDE_HIDDEN (__init_array_start = .); 117 | KEEP (*(SORT(.init_array.*))) 118 | KEEP (*(.init_array*)) 119 | PROVIDE_HIDDEN (__init_array_end = .); 120 | . = ALIGN(4); 121 | } >RAM 122 | 123 | .fini_array : 124 | { 125 | . = ALIGN(4); 126 | PROVIDE_HIDDEN (__fini_array_start = .); 127 | KEEP (*(SORT(.fini_array.*))) 128 | KEEP (*(.fini_array*)) 129 | PROVIDE_HIDDEN (__fini_array_end = .); 130 | . = ALIGN(4); 131 | } >RAM 132 | 133 | /* Used by the startup to initialize data */ 134 | _sidata = LOADADDR(.data); 135 | 136 | /* Initialized data sections into "RAM" Ram type memory */ 137 | .data : 138 | { 139 | . = ALIGN(4); 140 | _sdata = .; /* create a global symbol at data start */ 141 | *(.data) /* .data sections */ 142 | *(.data*) /* .data* sections */ 143 | 144 | . = ALIGN(4); 145 | _edata = .; /* define a global symbol at data end */ 146 | 147 | } >RAM 148 | 149 | /* Uninitialized data section into "RAM" Ram type memory */ 150 | . = ALIGN(4); 151 | .bss : 152 | { 153 | /* This is used by the startup in order to initialize the .bss section */ 154 | _sbss = .; /* define a global symbol at bss start */ 155 | __bss_start__ = _sbss; 156 | *(.bss) 157 | *(.bss*) 158 | *(COMMON) 159 | 160 | . = ALIGN(4); 161 | _ebss = .; /* define a global symbol at bss end */ 162 | __bss_end__ = _ebss; 163 | } >RAM 164 | 165 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ 166 | ._user_heap_stack : 167 | { 168 | . = ALIGN(8); 169 | PROVIDE ( end = . ); 170 | PROVIDE ( _end = . ); 171 | . = . + _Min_Heap_Size; 172 | . = . + _Min_Stack_Size; 173 | . = ALIGN(8); 174 | } >RAM 175 | 176 | /* Remove information from the compiler libraries */ 177 | /DISCARD/ : 178 | { 179 | libc.a ( * ) 180 | libm.a ( * ) 181 | libgcc.a ( * ) 182 | } 183 | 184 | .ARM.attributes 0 : { *(.ARM.attributes) } 185 | } 186 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/STM32F446ZETX_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** @file : LinkerScript.ld 5 | ** 6 | ** @author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** Abstract : Linker script for NUCLEO-F446ZE Board embedding STM32F446ZETx Device from stm32f4 series 9 | ** 512Kbytes FLASH 10 | ** 128Kbytes RAM 11 | ** 12 | ** Set heap size, stack size and stack location according 13 | ** to application requirements. 14 | ** 15 | ** Set memory bank area and size if external memory is used 16 | ** 17 | ** Target : STMicroelectronics STM32 18 | ** 19 | ** Distribution: The file is distributed as is, without any warranty 20 | ** of any kind. 21 | ** 22 | ****************************************************************************** 23 | ** @attention 24 | ** 25 | ** Copyright (c) 2022 STMicroelectronics. 26 | ** All rights reserved. 27 | ** 28 | ** This software is licensed under terms that can be found in the LICENSE file 29 | ** in the root directory of this software component. 30 | ** If no LICENSE file comes with this software, it is provided AS-IS. 31 | ** 32 | ****************************************************************************** 33 | */ 34 | 35 | /* Entry Point */ 36 | ENTRY(Reset_Handler) 37 | 38 | /* Highest address of the user mode stack */ 39 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ 40 | 41 | _Min_Heap_Size = 0x200 ; /* required amount of heap */ 42 | _Min_Stack_Size = 0x400 ; /* required amount of stack */ 43 | 44 | /* Memories definition */ 45 | MEMORY 46 | { 47 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K 48 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K 49 | } 50 | 51 | /* Sections */ 52 | SECTIONS 53 | { 54 | /* The startup code into "FLASH" Rom type memory */ 55 | .isr_vector : 56 | { 57 | . = ALIGN(4); 58 | KEEP(*(.isr_vector)) /* Startup code */ 59 | . = ALIGN(4); 60 | } >FLASH 61 | 62 | /* The program code and other data into "FLASH" Rom type memory */ 63 | .text : 64 | { 65 | . = ALIGN(4); 66 | *(.text) /* .text sections (code) */ 67 | *(.text*) /* .text* sections (code) */ 68 | *(.glue_7) /* glue arm to thumb code */ 69 | *(.glue_7t) /* glue thumb to arm code */ 70 | *(.eh_frame) 71 | 72 | KEEP (*(.init)) 73 | KEEP (*(.fini)) 74 | 75 | . = ALIGN(4); 76 | _etext = .; /* define a global symbols at end of code */ 77 | } >FLASH 78 | 79 | /* Constant data into "FLASH" Rom type memory */ 80 | .rodata : 81 | { 82 | . = ALIGN(4); 83 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 84 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 85 | . = ALIGN(4); 86 | } >FLASH 87 | 88 | .ARM.extab : { 89 | . = ALIGN(4); 90 | *(.ARM.extab* .gnu.linkonce.armextab.*) 91 | . = ALIGN(4); 92 | } >FLASH 93 | 94 | .ARM : { 95 | . = ALIGN(4); 96 | __exidx_start = .; 97 | *(.ARM.exidx*) 98 | __exidx_end = .; 99 | . = ALIGN(4); 100 | } >FLASH 101 | 102 | .preinit_array : 103 | { 104 | . = ALIGN(4); 105 | PROVIDE_HIDDEN (__preinit_array_start = .); 106 | KEEP (*(.preinit_array*)) 107 | PROVIDE_HIDDEN (__preinit_array_end = .); 108 | . = ALIGN(4); 109 | } >FLASH 110 | 111 | .init_array : 112 | { 113 | . = ALIGN(4); 114 | PROVIDE_HIDDEN (__init_array_start = .); 115 | KEEP (*(SORT(.init_array.*))) 116 | KEEP (*(.init_array*)) 117 | PROVIDE_HIDDEN (__init_array_end = .); 118 | . = ALIGN(4); 119 | } >FLASH 120 | 121 | .fini_array : 122 | { 123 | . = ALIGN(4); 124 | PROVIDE_HIDDEN (__fini_array_start = .); 125 | KEEP (*(SORT(.fini_array.*))) 126 | KEEP (*(.fini_array*)) 127 | PROVIDE_HIDDEN (__fini_array_end = .); 128 | . = ALIGN(4); 129 | } >FLASH 130 | 131 | /* Used by the startup to initialize data */ 132 | _sidata = LOADADDR(.data); 133 | 134 | /* Initialized data sections into "RAM" Ram type memory */ 135 | .data : 136 | { 137 | . = ALIGN(4); 138 | _sdata = .; /* create a global symbol at data start */ 139 | *(.data) /* .data sections */ 140 | *(.data*) /* .data* sections */ 141 | *(.RamFunc) /* .RamFunc sections */ 142 | *(.RamFunc*) /* .RamFunc* sections */ 143 | 144 | . = ALIGN(4); 145 | _edata = .; /* define a global symbol at data end */ 146 | 147 | } >RAM AT> FLASH 148 | 149 | /* Uninitialized data section into "RAM" Ram type memory */ 150 | . = ALIGN(4); 151 | .bss : 152 | { 153 | /* This is used by the startup in order to initialize the .bss section */ 154 | _sbss = .; /* define a global symbol at bss start */ 155 | __bss_start__ = _sbss; 156 | *(.bss) 157 | *(.bss*) 158 | *(COMMON) 159 | 160 | . = ALIGN(4); 161 | _ebss = .; /* define a global symbol at bss end */ 162 | __bss_end__ = _ebss; 163 | } >RAM 164 | 165 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ 166 | ._user_heap_stack : 167 | { 168 | . = ALIGN(8); 169 | PROVIDE ( end = . ); 170 | PROVIDE ( _end = . ); 171 | . = . + _Min_Heap_Size; 172 | . = . + _Min_Stack_Size; 173 | . = ALIGN(8); 174 | } >RAM 175 | 176 | /* Remove information from the compiler libraries */ 177 | /DISCARD/ : 178 | { 179 | libc.a ( * ) 180 | libm.a ( * ) 181 | libgcc.a ( * ) 182 | } 183 | 184 | .ARM.attributes 0 : { *(.ARM.attributes) } 185 | } 186 | -------------------------------------------------------------------------------- /tests/unit/drivers/gpio_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "Drivers/Include/gpio.h" 5 | #include "hal_gpio_mock.cpp" 6 | 7 | using ::testing::_; 8 | using ::testing::InSequence; 9 | using ::testing::Return; 10 | 11 | class GpioUnitTest : public ::testing::Test 12 | { 13 | protected: 14 | ::testing::StrictMock *mock; 15 | 16 | Gpio_t gpio = {0}; 17 | GpioPort_t *gpioPort = (GpioPort_t *)0x40020000; 18 | GpioPin_t gpioPin = (uint16_t)0x0001; 19 | 20 | void SetUp() override 21 | { 22 | // Create and install the mock 23 | mock = new ::testing::StrictMock(); 24 | setHalMock(mock); 25 | } 26 | 27 | void TearDown() override 28 | { 29 | setHalMock(nullptr); 30 | delete mock; 31 | } 32 | }; 33 | 34 | TEST_F(GpioUnitTest, GPIO_Initialize_WhenCalledWithValidParam_ThenInitializesStructField) 35 | { 36 | GPIO_Initialize(&gpio, gpioPort, gpioPin); 37 | 38 | EXPECT_EQ(true, gpio.init); 39 | EXPECT_EQ(gpioPort, gpio.port); 40 | EXPECT_EQ(gpioPin, gpio.pin); 41 | } 42 | 43 | TEST_F(GpioUnitTest, GPIO_WritePin_WhenCalledWithValidParam_ThenCallsHAL_GPIO_WritePin) 44 | { 45 | GPIO_Initialize(&gpio, gpioPort, gpioPin); 46 | 47 | InSequence seq; 48 | EXPECT_CALL(*mock, HAL_GPIO_WritePin((GPIO_TypeDef *)gpioPort, gpioPin, (GPIO_PinState)GPIO_STATE_SET)).Times(1); 49 | EXPECT_CALL(*mock, HAL_GPIO_WritePin((GPIO_TypeDef *)gpioPort, gpioPin, (GPIO_PinState)GPIO_STATE_RESET)).Times(1); 50 | 51 | GPIO_WritePin(&gpio, GPIO_STATE_SET); 52 | GPIO_WritePin(&gpio, GPIO_STATE_RESET); 53 | } 54 | 55 | TEST_F(GpioUnitTest, GPIO_ReadPin_WhenCalledWithValidParam_ThenCallsHAL_GPIO_ReadPin) 56 | { 57 | GpioState_t returnedState; 58 | GpioState_t expectStateSet = GPIO_STATE_SET; 59 | GpioState_t expectStateReset = GPIO_STATE_RESET; 60 | 61 | GPIO_Initialize(&gpio, gpioPort, gpioPin); 62 | 63 | EXPECT_CALL(*mock, HAL_GPIO_ReadPin((GPIO_TypeDef *)gpioPort, gpioPin)).Times(2).WillOnce(Return((GPIO_PinState)expectStateSet)).WillOnce(Return((GPIO_PinState)expectStateReset)); 64 | 65 | returnedState = GPIO_ReadPin(&gpio); 66 | EXPECT_EQ(expectStateSet, returnedState); 67 | 68 | returnedState = GPIO_ReadPin(&gpio); 69 | EXPECT_EQ(expectStateReset, returnedState); 70 | } 71 | 72 | TEST_F(GpioUnitTest, GPIO_TogglePin_WhenCalledWithValidParam_ThenCallsHAL_GPIO_TogglePin) 73 | { 74 | GPIO_Initialize(&gpio, gpioPort, gpioPin); 75 | 76 | EXPECT_CALL(*mock, HAL_GPIO_TogglePin((GPIO_TypeDef *)gpioPort, gpioPin)).Times(1); 77 | 78 | GPIO_TogglePin(&gpio); 79 | } 80 | 81 | #if GTEST_HAS_DEATH_TEST // Make sure death tests are available 82 | TEST_F(GpioUnitTest, GPIO_Initialize_WhenPointerIsNull_ThenFailsAssert) 83 | { 84 | // The function asserts me != NULL, so passing NULL should cause a crash/abort. 85 | EXPECT_DEATH( 86 | { 87 | GPIO_Initialize(nullptr, gpioPort, gpioPin); 88 | }, 89 | ".*" // A regex checking for assertion message, can be ".*" to ignore 90 | ); 91 | } 92 | 93 | TEST_F(GpioUnitTest, GPIO_Initialize_WhenAlreadyInitialized_ThenFailsAssert) 94 | { 95 | // First init is valid 96 | GPIO_Initialize(&gpio, gpioPort, gpioPin); 97 | 98 | // Second init with same struct => assertion fail: assert(!me->init); 99 | EXPECT_DEATH( 100 | { 101 | GPIO_Initialize(&gpio, gpioPort, gpioPin); 102 | }, 103 | ".*"); 104 | } 105 | 106 | TEST_F(GpioUnitTest, GPIO_Initialize_WhenPortIsNull_ThenFailsAssert) 107 | { 108 | // me != NULL, me->init is false, but 'port' is NULL => assertion triggers 109 | EXPECT_DEATH( 110 | { 111 | GPIO_Initialize(&gpio, nullptr, gpioPin); 112 | }, 113 | ".*"); 114 | } 115 | 116 | TEST_F(GpioUnitTest, Gpio_WritePin_WhenNotInitialized_ThenFailsAssert) 117 | { 118 | // me->init is false => assertion triggers 119 | EXPECT_DEATH( 120 | { 121 | GPIO_WritePin(&gpio, GPIO_STATE_SET); 122 | }, 123 | ".*"); 124 | } 125 | 126 | TEST_F(GpioUnitTest, GPIO_WritePin_WhenPointerIsNull_ThenFailsAssert) 127 | { 128 | GPIO_Initialize(&gpio, gpioPort, gpioPin); 129 | // The function asserts me != NULL, so passing NULL should cause a crash/abort. 130 | EXPECT_DEATH( 131 | { 132 | GPIO_WritePin(nullptr, GPIO_STATE_SET); 133 | }, 134 | ".*" // A regex checking for assertion message, can be ".*" to ignore 135 | ); 136 | } 137 | 138 | TEST_F(GpioUnitTest, GPIO_ReadPin_WhenNotInitialized_ThenFailsAssert) 139 | { 140 | // me->init is false => assertion triggers 141 | EXPECT_DEATH( 142 | { 143 | GPIO_ReadPin(&gpio); 144 | }, 145 | ".*"); 146 | } 147 | 148 | TEST_F(GpioUnitTest, GPIO_ReadPin_WhenPointerIsNull_ThenFailsAssert) 149 | { 150 | GPIO_Initialize(&gpio, gpioPort, gpioPin); 151 | // The function asserts me != NULL, so passing NULL should cause a crash/abort. 152 | EXPECT_DEATH( 153 | { 154 | GPIO_ReadPin(nullptr); 155 | }, 156 | ".*" // A regex checking for assertion message, can be ".*" to ignore 157 | ); 158 | } 159 | 160 | TEST_F(GpioUnitTest, GPIO_TogglePin_WhenNotInitialized_ThenFailsAssert) 161 | { 162 | // me->init is false => assertion triggers 163 | EXPECT_DEATH( 164 | { 165 | GPIO_TogglePin(&gpio); 166 | }, 167 | ".*"); 168 | } 169 | 170 | TEST_F(GpioUnitTest, GPIO_TogglePin_WhenPointerIsNull_ThenFailsAssert) 171 | { 172 | GPIO_Initialize(&gpio, gpioPort, gpioPin); 173 | // The function asserts me != NULL, so passing NULL should cause a crash/abort. 174 | EXPECT_DEATH( 175 | { 176 | GPIO_TogglePin(nullptr); 177 | }, 178 | ".*" // A regex checking for assertion message, can be ".*" to ignore 179 | ); 180 | } 181 | 182 | #endif // GTEST_HAS_DEATH_TEST 183 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_crc.h 4 | * @author MCD Application Team 5 | * @brief Header file of CRC HAL module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32F4xx_HAL_CRC_H 21 | #define STM32F4xx_HAL_CRC_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f4xx_hal_def.h" 29 | 30 | /** @addtogroup STM32F4xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup CRC 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /** @defgroup CRC_Exported_Types CRC Exported Types 40 | * @{ 41 | */ 42 | 43 | /** 44 | * @brief CRC HAL State Structure definition 45 | */ 46 | typedef enum 47 | { 48 | HAL_CRC_STATE_RESET = 0x00U, /*!< CRC not yet initialized or disabled */ 49 | HAL_CRC_STATE_READY = 0x01U, /*!< CRC initialized and ready for use */ 50 | HAL_CRC_STATE_BUSY = 0x02U, /*!< CRC internal process is ongoing */ 51 | HAL_CRC_STATE_TIMEOUT = 0x03U, /*!< CRC timeout state */ 52 | HAL_CRC_STATE_ERROR = 0x04U /*!< CRC error state */ 53 | } HAL_CRC_StateTypeDef; 54 | 55 | 56 | /** 57 | * @brief CRC Handle Structure definition 58 | */ 59 | typedef struct 60 | { 61 | CRC_TypeDef *Instance; /*!< Register base address */ 62 | 63 | HAL_LockTypeDef Lock; /*!< CRC Locking object */ 64 | 65 | __IO HAL_CRC_StateTypeDef State; /*!< CRC communication state */ 66 | 67 | } CRC_HandleTypeDef; 68 | /** 69 | * @} 70 | */ 71 | 72 | /* Exported constants --------------------------------------------------------*/ 73 | /** @defgroup CRC_Exported_Constants CRC Exported Constants 74 | * @{ 75 | */ 76 | 77 | /** 78 | * @} 79 | */ 80 | 81 | /* Exported macros -----------------------------------------------------------*/ 82 | /** @defgroup CRC_Exported_Macros CRC Exported Macros 83 | * @{ 84 | */ 85 | 86 | /** @brief Reset CRC handle state. 87 | * @param __HANDLE__ CRC handle. 88 | * @retval None 89 | */ 90 | #define __HAL_CRC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRC_STATE_RESET) 91 | 92 | /** 93 | * @brief Reset CRC Data Register. 94 | * @param __HANDLE__ CRC handle 95 | * @retval None 96 | */ 97 | #define __HAL_CRC_DR_RESET(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRC_CR_RESET) 98 | 99 | /** 100 | * @brief Store data in the Independent Data (ID) register. 101 | * @param __HANDLE__ CRC handle 102 | * @param __VALUE__ Value to be stored in the ID register 103 | * @note Refer to the Reference Manual to get the authorized __VALUE__ length in bits 104 | * @retval None 105 | */ 106 | #define __HAL_CRC_SET_IDR(__HANDLE__, __VALUE__) (WRITE_REG((__HANDLE__)->Instance->IDR, (__VALUE__))) 107 | 108 | /** 109 | * @brief Return the data stored in the Independent Data (ID) register. 110 | * @param __HANDLE__ CRC handle 111 | * @note Refer to the Reference Manual to get the authorized __VALUE__ length in bits 112 | * @retval Value of the ID register 113 | */ 114 | #define __HAL_CRC_GET_IDR(__HANDLE__) (((__HANDLE__)->Instance->IDR) & CRC_IDR_IDR) 115 | /** 116 | * @} 117 | */ 118 | 119 | 120 | /* Private macros --------------------------------------------------------*/ 121 | /** @defgroup CRC_Private_Macros CRC Private Macros 122 | * @{ 123 | */ 124 | 125 | /** 126 | * @} 127 | */ 128 | 129 | /* Exported functions --------------------------------------------------------*/ 130 | /** @defgroup CRC_Exported_Functions CRC Exported Functions 131 | * @{ 132 | */ 133 | 134 | /* Initialization and de-initialization functions ****************************/ 135 | /** @defgroup CRC_Exported_Functions_Group1 Initialization and de-initialization functions 136 | * @{ 137 | */ 138 | HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc); 139 | HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc); 140 | void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc); 141 | void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc); 142 | /** 143 | * @} 144 | */ 145 | 146 | /* Peripheral Control functions ***********************************************/ 147 | /** @defgroup CRC_Exported_Functions_Group2 Peripheral Control functions 148 | * @{ 149 | */ 150 | uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength); 151 | uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength); 152 | /** 153 | * @} 154 | */ 155 | 156 | /* Peripheral State and Error functions ***************************************/ 157 | /** @defgroup CRC_Exported_Functions_Group3 Peripheral State functions 158 | * @{ 159 | */ 160 | HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc); 161 | /** 162 | * @} 163 | */ 164 | 165 | /** 166 | * @} 167 | */ 168 | 169 | /** 170 | * @} 171 | */ 172 | 173 | /** 174 | * @} 175 | */ 176 | 177 | #ifdef __cplusplus 178 | } 179 | #endif 180 | 181 | #endif /* STM32F4xx_HAL_CRC_H */ 182 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # STM32 C code and Google Test Framework 2 | 3 | [![Language](https://img.shields.io/badge/language-C%20%7C%20C++-blue.svg)](https://en.wikipedia.org/wiki/C%2B%2B) 4 | [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) 5 | [![Test](https://github.com/CharlesDias/stm32_gtest_c_code/actions/workflows/unit-test.yml/badge.svg)](https://github.com/CharlesDias/stm32_gtest_c_code/actions/workflows/unit-test.yml) 6 | [![codecov](https://codecov.io/gh/CharlesDias/stm32_gtest_c_code/branch/main/graph/badge.svg)](https://codecov.io/gh/CharlesDias/stm32_gtest_c_code) 7 | [![Lizard](https://github.com/CharlesDias/stm32_gtest_c_code/actions/workflows/lizard.yml/badge.svg)](https://github.com/CharlesDias/stm32_gtest_c_code/actions/workflows/lizard.yml) 8 | [![Flawfinder](https://github.com/CharlesDias/stm32_gtest_c_code/actions/workflows/flawfinder.yml/badge.svg)](https://github.com/CharlesDias/stm32_gtest_c_code/actions/workflows/flawfinder.yml) 9 | 10 | This is a sample project for testing C code for STM32 microcontrollers using the Google Test Framework. Some topics covered: 11 | 12 | * Sample project using the NUCLEO-F446ZE board. 13 | * Embedded system without RTOS (bare metal). 14 | * Distinct folders for library, executable, and test code. 15 | * Use of STM32CubeIDE for building and compiling the application project. 16 | * Use of CMake for building the test code. 17 | * Testing C code via Google Test Framework. 18 | * Use GMock for mocking the STM32 HAL functions. 19 | * Code coverage with Github Actions and [Codecov](https://codecov.io). 20 | * Code quality analysis with Lizard and Flawfinder tools. 21 | * Assert verification and prints the failures via huart3. 22 | * Use of Docker container. 23 | 24 | I know! Maybe... you're thinking it's overengineer to blink a LED. However, look on the bright side. The goal is to give an example of how to apply these practices and tools. 25 | 26 | ## Project structure 27 | 28 | ``` text 29 | ./ 30 | ├── CMakeLists.txt 31 | │ 32 | ├── cmake 33 | │   └── cmake modules 34 | │ 35 | ├── docker 36 | │   └── Dockerfile 37 | │ 38 | ├── docs 39 | │   └── Documentation files 40 | │ 41 | ├── .github 42 | │   └── workflows 43 | │   └── GitHub workflows 44 | │ 45 | ├── source 46 | │   ├── CMakeLists.txt 47 | │ │ 48 | │ ├── nucleo-f446ze-library 49 | │   │ ├── CMakeLists.txt 50 | │   │ ├── BuildArtifacts 51 | │ │ │ └── Library artifacts 52 | │   │ ├── Drivers 53 | │   │ │   └── Files generated by STM32CubeIDE 54 | │   │ ├── Inc 55 | │   │ │   └── Files generated by STM32CubeIDE 56 | │   │ ├── Libraries 57 | │   │   │ ├── CMakeLists.txt 58 | │   │   │ ├── Drivers 59 | │   │   │ │ ├── CMakeLists.txt 60 | │   │   │ │ └── Header and source files 61 | │   │ │   └── Middleware 62 | │   │   │ ├── CMakeLists.txt 63 | │   │   │ └── Header and source files 64 | │ │ └── Src 65 | │ │ └── Files generated by STM32CubeIDE 66 | │ │ 67 | │ └── stm32-cube-ide 68 | │   ├── BSP 69 | │ │ └── Header and source files 70 | │   ├── Core (Files generated by STM32CubeIDE) 71 | │   │ ├── Inc 72 | │      │ │   └── Files generated by STM32CubeIDE 73 | │      │ ├── Src 74 | │      │   │ ├── main.c (Sample code) 75 | │      │   │ └── ... 76 | │ │ └── Startup 77 | │      │   └── Files generated by STM32CubeIDE 78 | │   ├── Drivers (Files generated by STM32CubeIDE) 79 | │      │  └── Files generated by STM32CubeIDE 80 | │   └── Project configuration files generated by STM32CubeIDE 81 | │ 82 | └── tests 83 | ├── CMakeLists.txt 84 | ├── header-overrides 85 | │ ├── core_cm4_override.h 86 | │ ├── main_override.h 87 | │ ├── stm32f446xx_override.h 88 | │ └── stm32f4xx_hal_gpio_override.h 89 | ├── integration 90 | │ └── hello_integration_test.cpp 91 | ├── mock 92 | │ ├── assert_mock.c 93 | │ ├── gpio_mock.cpp 94 | │ ├── gpio_mock.h 95 | │ ├── hal_gpio_mock.cpp 96 | │ └── hal_gpio_mock.h 97 | └── unit 98 | ├── drivers 99 | │ └── gpio_test.cpp 100 | ├── hello_unit_test.cpp 101 | └── middleware 102 | └── led_test.cpp 103 | ``` 104 | 105 | ## Building tests project via CMake 106 | 107 | Clone this repo for your local machine 108 | 109 | ```console 110 | git clone https://github.com/CharlesDias/stm32_gtest_c_code.git 111 | ``` 112 | 113 | Access the project folder **stm32_gtest_c_code** 114 | 115 | ```console 116 | cd stm32_gtest_c_code 117 | ``` 118 | 119 | Pull the latest docker image used to build the project. 120 | 121 | ```console 122 | docker pull charlesdias/stm32_gtest 123 | ``` 124 | 125 | Run the image docker. 126 | 127 | ```console 128 | docker run --rm -it -v $(pwd):/home/project -w /home/project charlesdias/stm32_gtest 129 | ``` 130 | 131 | Run the command below inside the Docker container 132 | 133 | ```console 134 | make clean && make build && make test 135 | ``` 136 | 137 | Access the `build/coverage/index.html` file to see the coverage report. 138 | 139 | ### Dependency graph 140 | 141 | To generate the dependency graph, build the test project as previously described and run the command below: 142 | 143 | ```console 144 | make dependency 145 | ``` 146 | 147 | Check the file build/graph_image.png. 148 | 149 | Dependency graph for test project. 150 | 151 | ![Dependency graph](docs/images/dependency_graph.png "Dependency graph") 152 | 153 | The graph_image.png file will be generated inside the build folder. 154 | 155 | ## Building application project via STM32CubeIDE 156 | 157 | Clone this repo for your local machine 158 | 159 | ```console 160 | git clone https://github.com/CharlesDias/stm32_gtest_c_code.git 161 | ``` 162 | 163 | Open the STM32CubeIDE and import this project. 164 | 165 | Build and load the firmware on NUCLEO-F446ZE board. See the expected output. 166 | 167 | ![STM32 project](docs/images/stm32_gtest.gif "STM32 project") 168 | 169 | ## Improvement suggestions 170 | 171 | * Add some function example to increase the CCN (cyclomatic complexity number). 172 | * Add some function example with security weaknesses to test the Flawfinder. 173 | * Build the application project via CMake. 174 | * Add Doxygen configuration. 175 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/Core/Src/stm32f4xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f4xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2022 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "main.h" 22 | #include "stm32f4xx_it.h" 23 | /* Private includes ----------------------------------------------------------*/ 24 | /* USER CODE BEGIN Includes */ 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN PD */ 34 | 35 | /* USER CODE END PD */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN PM */ 39 | 40 | /* USER CODE END PM */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* Private user code ---------------------------------------------------------*/ 53 | /* USER CODE BEGIN 0 */ 54 | 55 | /* USER CODE END 0 */ 56 | 57 | /* External variables --------------------------------------------------------*/ 58 | 59 | /* USER CODE BEGIN EV */ 60 | 61 | /* USER CODE END EV */ 62 | 63 | /******************************************************************************/ 64 | /* Cortex-M4 Processor Interruption and Exception Handlers */ 65 | /******************************************************************************/ 66 | /** 67 | * @brief This function handles Non maskable interrupt. 68 | */ 69 | void NMI_Handler(void) 70 | { 71 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 72 | 73 | /* USER CODE END NonMaskableInt_IRQn 0 */ 74 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 75 | while (1) 76 | { 77 | } 78 | /* USER CODE END NonMaskableInt_IRQn 1 */ 79 | } 80 | 81 | /** 82 | * @brief This function handles Hard fault interrupt. 83 | */ 84 | void HardFault_Handler(void) 85 | { 86 | /* USER CODE BEGIN HardFault_IRQn 0 */ 87 | 88 | /* USER CODE END HardFault_IRQn 0 */ 89 | while (1) 90 | { 91 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */ 92 | /* USER CODE END W1_HardFault_IRQn 0 */ 93 | } 94 | } 95 | 96 | /** 97 | * @brief This function handles Memory management fault. 98 | */ 99 | void MemManage_Handler(void) 100 | { 101 | /* USER CODE BEGIN MemoryManagement_IRQn 0 */ 102 | 103 | /* USER CODE END MemoryManagement_IRQn 0 */ 104 | while (1) 105 | { 106 | /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ 107 | /* USER CODE END W1_MemoryManagement_IRQn 0 */ 108 | } 109 | } 110 | 111 | /** 112 | * @brief This function handles Pre-fetch fault, memory access fault. 113 | */ 114 | void BusFault_Handler(void) 115 | { 116 | /* USER CODE BEGIN BusFault_IRQn 0 */ 117 | 118 | /* USER CODE END BusFault_IRQn 0 */ 119 | while (1) 120 | { 121 | /* USER CODE BEGIN W1_BusFault_IRQn 0 */ 122 | /* USER CODE END W1_BusFault_IRQn 0 */ 123 | } 124 | } 125 | 126 | /** 127 | * @brief This function handles Undefined instruction or illegal state. 128 | */ 129 | void UsageFault_Handler(void) 130 | { 131 | /* USER CODE BEGIN UsageFault_IRQn 0 */ 132 | 133 | /* USER CODE END UsageFault_IRQn 0 */ 134 | while (1) 135 | { 136 | /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ 137 | /* USER CODE END W1_UsageFault_IRQn 0 */ 138 | } 139 | } 140 | 141 | /** 142 | * @brief This function handles System service call via SWI instruction. 143 | */ 144 | void SVC_Handler(void) 145 | { 146 | /* USER CODE BEGIN SVCall_IRQn 0 */ 147 | 148 | /* USER CODE END SVCall_IRQn 0 */ 149 | /* USER CODE BEGIN SVCall_IRQn 1 */ 150 | 151 | /* USER CODE END SVCall_IRQn 1 */ 152 | } 153 | 154 | /** 155 | * @brief This function handles Debug monitor. 156 | */ 157 | void DebugMon_Handler(void) 158 | { 159 | /* USER CODE BEGIN DebugMonitor_IRQn 0 */ 160 | 161 | /* USER CODE END DebugMonitor_IRQn 0 */ 162 | /* USER CODE BEGIN DebugMonitor_IRQn 1 */ 163 | 164 | /* USER CODE END DebugMonitor_IRQn 1 */ 165 | } 166 | 167 | /** 168 | * @brief This function handles Pendable request for system service. 169 | */ 170 | void PendSV_Handler(void) 171 | { 172 | /* USER CODE BEGIN PendSV_IRQn 0 */ 173 | 174 | /* USER CODE END PendSV_IRQn 0 */ 175 | /* USER CODE BEGIN PendSV_IRQn 1 */ 176 | 177 | /* USER CODE END PendSV_IRQn 1 */ 178 | } 179 | 180 | /** 181 | * @brief This function handles System tick timer. 182 | */ 183 | void SysTick_Handler(void) 184 | { 185 | /* USER CODE BEGIN SysTick_IRQn 0 */ 186 | 187 | /* USER CODE END SysTick_IRQn 0 */ 188 | HAL_IncTick(); 189 | /* USER CODE BEGIN SysTick_IRQn 1 */ 190 | 191 | /* USER CODE END SysTick_IRQn 1 */ 192 | } 193 | 194 | /******************************************************************************/ 195 | /* STM32F4xx Peripheral Interrupt Handlers */ 196 | /* Add here the Interrupt Handlers for the used peripherals. */ 197 | /* For the available peripheral interrupt handler names, */ 198 | /* please refer to the startup file (startup_stm32f4xx.s). */ 199 | /******************************************************************************/ 200 | 201 | /* USER CODE BEGIN 1 */ 202 | 203 | /* USER CODE END 1 */ 204 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_ll_crc.h 4 | * @author MCD Application Team 5 | * @brief Header file of CRC LL module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32F4xx_LL_CRC_H 21 | #define STM32F4xx_LL_CRC_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f4xx.h" 29 | 30 | /** @addtogroup STM32F4xx_LL_Driver 31 | * @{ 32 | */ 33 | 34 | #if defined(CRC) 35 | 36 | /** @defgroup CRC_LL CRC 37 | * @{ 38 | */ 39 | 40 | /* Private types -------------------------------------------------------------*/ 41 | /* Private variables ---------------------------------------------------------*/ 42 | /* Private constants ---------------------------------------------------------*/ 43 | /* Private macros ------------------------------------------------------------*/ 44 | 45 | /* Exported types ------------------------------------------------------------*/ 46 | /* Exported constants --------------------------------------------------------*/ 47 | /** @defgroup CRC_LL_Exported_Constants CRC Exported Constants 48 | * @{ 49 | */ 50 | 51 | /** 52 | * @} 53 | */ 54 | 55 | /* Exported macro ------------------------------------------------------------*/ 56 | /** @defgroup CRC_LL_Exported_Macros CRC Exported Macros 57 | * @{ 58 | */ 59 | 60 | /** @defgroup CRC_LL_EM_WRITE_READ Common Write and read registers Macros 61 | * @{ 62 | */ 63 | 64 | /** 65 | * @brief Write a value in CRC register 66 | * @param __INSTANCE__ CRC Instance 67 | * @param __REG__ Register to be written 68 | * @param __VALUE__ Value to be written in the register 69 | * @retval None 70 | */ 71 | #define LL_CRC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, __VALUE__) 72 | 73 | /** 74 | * @brief Read a value in CRC register 75 | * @param __INSTANCE__ CRC Instance 76 | * @param __REG__ Register to be read 77 | * @retval Register value 78 | */ 79 | #define LL_CRC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) 80 | /** 81 | * @} 82 | */ 83 | 84 | /** 85 | * @} 86 | */ 87 | 88 | 89 | /* Exported functions --------------------------------------------------------*/ 90 | /** @defgroup CRC_LL_Exported_Functions CRC Exported Functions 91 | * @{ 92 | */ 93 | 94 | /** @defgroup CRC_LL_EF_Configuration CRC Configuration functions 95 | * @{ 96 | */ 97 | 98 | /** 99 | * @brief Reset the CRC calculation unit. 100 | * @note If Programmable Initial CRC value feature 101 | * is available, also set the Data Register to the value stored in the 102 | * CRC_INIT register, otherwise, reset Data Register to its default value. 103 | * @rmtoll CR RESET LL_CRC_ResetCRCCalculationUnit 104 | * @param CRCx CRC Instance 105 | * @retval None 106 | */ 107 | __STATIC_INLINE void LL_CRC_ResetCRCCalculationUnit(CRC_TypeDef *CRCx) 108 | { 109 | SET_BIT(CRCx->CR, CRC_CR_RESET); 110 | } 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /** @defgroup CRC_LL_EF_Data_Management Data_Management 117 | * @{ 118 | */ 119 | 120 | /** 121 | * @brief Write given 32-bit data to the CRC calculator 122 | * @rmtoll DR DR LL_CRC_FeedData32 123 | * @param CRCx CRC Instance 124 | * @param InData value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFFFFFF 125 | * @retval None 126 | */ 127 | __STATIC_INLINE void LL_CRC_FeedData32(CRC_TypeDef *CRCx, uint32_t InData) 128 | { 129 | WRITE_REG(CRCx->DR, InData); 130 | } 131 | 132 | /** 133 | * @brief Return current CRC calculation result. 32 bits value is returned. 134 | * @rmtoll DR DR LL_CRC_ReadData32 135 | * @param CRCx CRC Instance 136 | * @retval Current CRC calculation result as stored in CRC_DR register (32 bits). 137 | */ 138 | __STATIC_INLINE uint32_t LL_CRC_ReadData32(CRC_TypeDef *CRCx) 139 | { 140 | return (uint32_t)(READ_REG(CRCx->DR)); 141 | } 142 | 143 | /** 144 | * @brief Return data stored in the Independent Data(IDR) register. 145 | * @note This register can be used as a temporary storage location for one byte. 146 | * @rmtoll IDR IDR LL_CRC_Read_IDR 147 | * @param CRCx CRC Instance 148 | * @retval Value stored in CRC_IDR register (General-purpose 8-bit data register). 149 | */ 150 | __STATIC_INLINE uint32_t LL_CRC_Read_IDR(CRC_TypeDef *CRCx) 151 | { 152 | return (uint32_t)(READ_REG(CRCx->IDR)); 153 | } 154 | 155 | /** 156 | * @brief Store data in the Independent Data(IDR) register. 157 | * @note This register can be used as a temporary storage location for one byte. 158 | * @rmtoll IDR IDR LL_CRC_Write_IDR 159 | * @param CRCx CRC Instance 160 | * @param InData value to be stored in CRC_IDR register (8-bit) between Min_Data=0 and Max_Data=0xFF 161 | * @retval None 162 | */ 163 | __STATIC_INLINE void LL_CRC_Write_IDR(CRC_TypeDef *CRCx, uint32_t InData) 164 | { 165 | *((uint8_t __IO *)(&CRCx->IDR)) = (uint8_t) InData; 166 | } 167 | /** 168 | * @} 169 | */ 170 | 171 | #if defined(USE_FULL_LL_DRIVER) 172 | /** @defgroup CRC_LL_EF_Init Initialization and de-initialization functions 173 | * @{ 174 | */ 175 | 176 | ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx); 177 | 178 | /** 179 | * @} 180 | */ 181 | #endif /* USE_FULL_LL_DRIVER */ 182 | 183 | /** 184 | * @} 185 | */ 186 | 187 | /** 188 | * @} 189 | */ 190 | 191 | #endif /* defined(CRC) */ 192 | 193 | /** 194 | * @} 195 | */ 196 | 197 | #ifdef __cplusplus 198 | } 199 | #endif 200 | 201 | #endif /* STM32F4xx_LL_CRC_H */ 202 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_flash_ramfunc.c 4 | * @author MCD Application Team 5 | * @brief FLASH RAMFUNC module driver. 6 | * This file provides a FLASH firmware functions which should be 7 | * executed from internal SRAM 8 | * + Stop/Start the flash interface while System Run 9 | * + Enable/Disable the flash sleep while System Run 10 | @verbatim 11 | ============================================================================== 12 | ##### APIs executed from Internal RAM ##### 13 | ============================================================================== 14 | [..] 15 | *** ARM Compiler *** 16 | -------------------- 17 | [..] RAM functions are defined using the toolchain options. 18 | Functions that are be executed in RAM should reside in a separate 19 | source module. Using the 'Options for File' dialog you can simply change 20 | the 'Code / Const' area of a module to a memory space in physical RAM. 21 | Available memory areas are declared in the 'Target' tab of the 22 | Options for Target' dialog. 23 | 24 | *** ICCARM Compiler *** 25 | ----------------------- 26 | [..] RAM functions are defined using a specific toolchain keyword "__ramfunc". 27 | 28 | *** GNU Compiler *** 29 | -------------------- 30 | [..] RAM functions are defined using a specific toolchain attribute 31 | "__attribute__((section(".RamFunc")))". 32 | 33 | @endverbatim 34 | ****************************************************************************** 35 | * @attention 36 | * 37 | * Copyright (c) 2017 STMicroelectronics. 38 | * All rights reserved. 39 | * 40 | * This software is licensed under terms that can be found in the LICENSE file in 41 | * the root directory of this software component. 42 | * If no LICENSE file comes with this software, it is provided AS-IS. 43 | ****************************************************************************** 44 | */ 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include "stm32f4xx_hal.h" 48 | 49 | /** @addtogroup STM32F4xx_HAL_Driver 50 | * @{ 51 | */ 52 | 53 | /** @defgroup FLASH_RAMFUNC FLASH RAMFUNC 54 | * @brief FLASH functions executed from RAM 55 | * @{ 56 | */ 57 | #ifdef HAL_FLASH_MODULE_ENABLED 58 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \ 59 | defined(STM32F412Rx) || defined(STM32F412Cx) 60 | 61 | /* Private typedef -----------------------------------------------------------*/ 62 | /* Private define ------------------------------------------------------------*/ 63 | /* Private macro -------------------------------------------------------------*/ 64 | /* Private variables ---------------------------------------------------------*/ 65 | /* Private function prototypes -----------------------------------------------*/ 66 | /* Exported functions --------------------------------------------------------*/ 67 | /** @defgroup FLASH_RAMFUNC_Exported_Functions FLASH RAMFUNC Exported Functions 68 | * @{ 69 | */ 70 | 71 | /** @defgroup FLASH_RAMFUNC_Exported_Functions_Group1 Peripheral features functions executed from internal RAM 72 | * @brief Peripheral Extended features functions 73 | * 74 | @verbatim 75 | 76 | =============================================================================== 77 | ##### ramfunc functions ##### 78 | =============================================================================== 79 | [..] 80 | This subsection provides a set of functions that should be executed from RAM 81 | transfers. 82 | 83 | @endverbatim 84 | * @{ 85 | */ 86 | 87 | /** 88 | * @brief Stop the flash interface while System Run 89 | * @note This mode is only available for STM32F41xxx/STM32F446xx devices. 90 | * @note This mode couldn't be set while executing with the flash itself. 91 | * It should be done with specific routine executed from RAM. 92 | * @retval HAL status 93 | */ 94 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StopFlashInterfaceClk(void) 95 | { 96 | /* Enable Power ctrl clock */ 97 | __HAL_RCC_PWR_CLK_ENABLE(); 98 | /* Stop the flash interface while System Run */ 99 | SET_BIT(PWR->CR, PWR_CR_FISSR); 100 | 101 | return HAL_OK; 102 | } 103 | 104 | /** 105 | * @brief Start the flash interface while System Run 106 | * @note This mode is only available for STM32F411xx/STM32F446xx devices. 107 | * @note This mode couldn't be set while executing with the flash itself. 108 | * It should be done with specific routine executed from RAM. 109 | * @retval HAL status 110 | */ 111 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StartFlashInterfaceClk(void) 112 | { 113 | /* Enable Power ctrl clock */ 114 | __HAL_RCC_PWR_CLK_ENABLE(); 115 | /* Start the flash interface while System Run */ 116 | CLEAR_BIT(PWR->CR, PWR_CR_FISSR); 117 | 118 | return HAL_OK; 119 | } 120 | 121 | /** 122 | * @brief Enable the flash sleep while System Run 123 | * @note This mode is only available for STM32F41xxx/STM32F446xx devices. 124 | * @note This mode could n't be set while executing with the flash itself. 125 | * It should be done with specific routine executed from RAM. 126 | * @retval HAL status 127 | */ 128 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableFlashSleepMode(void) 129 | { 130 | /* Enable Power ctrl clock */ 131 | __HAL_RCC_PWR_CLK_ENABLE(); 132 | /* Enable the flash sleep while System Run */ 133 | SET_BIT(PWR->CR, PWR_CR_FMSSR); 134 | 135 | return HAL_OK; 136 | } 137 | 138 | /** 139 | * @brief Disable the flash sleep while System Run 140 | * @note This mode is only available for STM32F41xxx/STM32F446xx devices. 141 | * @note This mode couldn't be set while executing with the flash itself. 142 | * It should be done with specific routine executed from RAM. 143 | * @retval HAL status 144 | */ 145 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableFlashSleepMode(void) 146 | { 147 | /* Enable Power ctrl clock */ 148 | __HAL_RCC_PWR_CLK_ENABLE(); 149 | /* Disable the flash sleep while System Run */ 150 | CLEAR_BIT(PWR->CR, PWR_CR_FMSSR); 151 | 152 | return HAL_OK; 153 | } 154 | 155 | /** 156 | * @} 157 | */ 158 | 159 | /** 160 | * @} 161 | */ 162 | 163 | #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 164 | #endif /* HAL_FLASH_MODULE_ENABLED */ 165 | /** 166 | * @} 167 | */ 168 | 169 | /** 170 | * @} 171 | */ 172 | 173 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/Core/Src/stm32f4xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f4xx_hal_msp.c 5 | * @brief This file provides code for the MSP Initialization 6 | * and de-Initialization codes. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | /* USER CODE BEGIN Includes */ 24 | 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN Define */ 34 | 35 | /* USER CODE END Define */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN Macro */ 39 | 40 | /* USER CODE END Macro */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* External functions --------------------------------------------------------*/ 53 | /* USER CODE BEGIN ExternalFunctions */ 54 | 55 | /* USER CODE END ExternalFunctions */ 56 | 57 | /* USER CODE BEGIN 0 */ 58 | 59 | /* USER CODE END 0 */ 60 | /** 61 | * Initializes the Global MSP. 62 | */ 63 | void HAL_MspInit(void) 64 | { 65 | /* USER CODE BEGIN MspInit 0 */ 66 | 67 | /* USER CODE END MspInit 0 */ 68 | 69 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 70 | __HAL_RCC_PWR_CLK_ENABLE(); 71 | 72 | /* System interrupt init*/ 73 | 74 | /* USER CODE BEGIN MspInit 1 */ 75 | 76 | /* USER CODE END MspInit 1 */ 77 | } 78 | 79 | /** 80 | * @brief UART MSP Initialization 81 | * This function configures the hardware resources used in this example 82 | * @param huart: UART handle pointer 83 | * @retval None 84 | */ 85 | void HAL_UART_MspInit(UART_HandleTypeDef* huart) 86 | { 87 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 88 | if(huart->Instance==USART3) 89 | { 90 | /* USER CODE BEGIN USART3_MspInit 0 */ 91 | 92 | /* USER CODE END USART3_MspInit 0 */ 93 | /* Peripheral clock enable */ 94 | __HAL_RCC_USART3_CLK_ENABLE(); 95 | 96 | __HAL_RCC_GPIOD_CLK_ENABLE(); 97 | /**USART3 GPIO Configuration 98 | PD8 ------> USART3_TX 99 | PD9 ------> USART3_RX 100 | */ 101 | GPIO_InitStruct.Pin = STLK_RX_Pin|STLK_TX_Pin; 102 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 103 | GPIO_InitStruct.Pull = GPIO_NOPULL; 104 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 105 | GPIO_InitStruct.Alternate = GPIO_AF7_USART3; 106 | HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); 107 | 108 | /* USER CODE BEGIN USART3_MspInit 1 */ 109 | 110 | /* USER CODE END USART3_MspInit 1 */ 111 | } 112 | 113 | } 114 | 115 | /** 116 | * @brief UART MSP De-Initialization 117 | * This function freeze the hardware resources used in this example 118 | * @param huart: UART handle pointer 119 | * @retval None 120 | */ 121 | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) 122 | { 123 | if(huart->Instance==USART3) 124 | { 125 | /* USER CODE BEGIN USART3_MspDeInit 0 */ 126 | 127 | /* USER CODE END USART3_MspDeInit 0 */ 128 | /* Peripheral clock disable */ 129 | __HAL_RCC_USART3_CLK_DISABLE(); 130 | 131 | /**USART3 GPIO Configuration 132 | PD8 ------> USART3_TX 133 | PD9 ------> USART3_RX 134 | */ 135 | HAL_GPIO_DeInit(GPIOD, STLK_RX_Pin|STLK_TX_Pin); 136 | 137 | /* USER CODE BEGIN USART3_MspDeInit 1 */ 138 | 139 | /* USER CODE END USART3_MspDeInit 1 */ 140 | } 141 | 142 | } 143 | 144 | /** 145 | * @brief PCD MSP Initialization 146 | * This function configures the hardware resources used in this example 147 | * @param hpcd: PCD handle pointer 148 | * @retval None 149 | */ 150 | void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) 151 | { 152 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 153 | RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; 154 | if(hpcd->Instance==USB_OTG_FS) 155 | { 156 | /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ 157 | 158 | /* USER CODE END USB_OTG_FS_MspInit 0 */ 159 | 160 | /** Initializes the peripherals clock 161 | */ 162 | PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_CLK48; 163 | PeriphClkInitStruct.Clk48ClockSelection = RCC_CLK48CLKSOURCE_PLLQ; 164 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) 165 | { 166 | Error_Handler(); 167 | } 168 | 169 | __HAL_RCC_GPIOA_CLK_ENABLE(); 170 | /**USB_OTG_FS GPIO Configuration 171 | PA8 ------> USB_OTG_FS_SOF 172 | PA9 ------> USB_OTG_FS_VBUS 173 | PA10 ------> USB_OTG_FS_ID 174 | PA11 ------> USB_OTG_FS_DM 175 | PA12 ------> USB_OTG_FS_DP 176 | */ 177 | GPIO_InitStruct.Pin = USB_SOF_Pin|USB_ID_Pin|USB_DM_Pin|USB_DP_Pin; 178 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 179 | GPIO_InitStruct.Pull = GPIO_NOPULL; 180 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 181 | GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; 182 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 183 | 184 | GPIO_InitStruct.Pin = USB_VBUS_Pin; 185 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 186 | GPIO_InitStruct.Pull = GPIO_NOPULL; 187 | HAL_GPIO_Init(USB_VBUS_GPIO_Port, &GPIO_InitStruct); 188 | 189 | /* Peripheral clock enable */ 190 | __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); 191 | /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ 192 | 193 | /* USER CODE END USB_OTG_FS_MspInit 1 */ 194 | } 195 | 196 | } 197 | 198 | /** 199 | * @brief PCD MSP De-Initialization 200 | * This function freeze the hardware resources used in this example 201 | * @param hpcd: PCD handle pointer 202 | * @retval None 203 | */ 204 | void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) 205 | { 206 | if(hpcd->Instance==USB_OTG_FS) 207 | { 208 | /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ 209 | 210 | /* USER CODE END USB_OTG_FS_MspDeInit 0 */ 211 | /* Peripheral clock disable */ 212 | __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); 213 | 214 | /**USB_OTG_FS GPIO Configuration 215 | PA8 ------> USB_OTG_FS_SOF 216 | PA9 ------> USB_OTG_FS_VBUS 217 | PA10 ------> USB_OTG_FS_ID 218 | PA11 ------> USB_OTG_FS_DM 219 | PA12 ------> USB_OTG_FS_DP 220 | */ 221 | HAL_GPIO_DeInit(GPIOA, USB_SOF_Pin|USB_VBUS_Pin|USB_ID_Pin|USB_DM_Pin 222 | |USB_DP_Pin); 223 | 224 | /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ 225 | 226 | /* USER CODE END USB_OTG_FS_MspDeInit 1 */ 227 | } 228 | 229 | } 230 | 231 | /* USER CODE BEGIN 1 */ 232 | 233 | /* USER CODE END 1 */ 234 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_iwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_iwdg.h 4 | * @author MCD Application Team 5 | * @brief Header file of IWDG HAL module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32F4xx_HAL_IWDG_H 21 | #define STM32F4xx_HAL_IWDG_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f4xx_hal_def.h" 29 | 30 | /** @addtogroup STM32F4xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @defgroup IWDG IWDG 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /** @defgroup IWDG_Exported_Types IWDG Exported Types 40 | * @{ 41 | */ 42 | 43 | /** 44 | * @brief IWDG Init structure definition 45 | */ 46 | typedef struct 47 | { 48 | uint32_t Prescaler; /*!< Select the prescaler of the IWDG. 49 | This parameter can be a value of @ref IWDG_Prescaler */ 50 | 51 | uint32_t Reload; /*!< Specifies the IWDG down-counter reload value. 52 | This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */ 53 | 54 | } IWDG_InitTypeDef; 55 | 56 | /** 57 | * @brief IWDG Handle Structure definition 58 | */ 59 | typedef struct 60 | { 61 | IWDG_TypeDef *Instance; /*!< Register base address */ 62 | 63 | IWDG_InitTypeDef Init; /*!< IWDG required parameters */ 64 | } IWDG_HandleTypeDef; 65 | 66 | 67 | /** 68 | * @} 69 | */ 70 | 71 | /* Exported constants --------------------------------------------------------*/ 72 | /** @defgroup IWDG_Exported_Constants IWDG Exported Constants 73 | * @{ 74 | */ 75 | 76 | /** @defgroup IWDG_Prescaler IWDG Prescaler 77 | * @{ 78 | */ 79 | #define IWDG_PRESCALER_4 0x00000000u /*!< IWDG prescaler set to 4 */ 80 | #define IWDG_PRESCALER_8 IWDG_PR_PR_0 /*!< IWDG prescaler set to 8 */ 81 | #define IWDG_PRESCALER_16 IWDG_PR_PR_1 /*!< IWDG prescaler set to 16 */ 82 | #define IWDG_PRESCALER_32 (IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 32 */ 83 | #define IWDG_PRESCALER_64 IWDG_PR_PR_2 /*!< IWDG prescaler set to 64 */ 84 | #define IWDG_PRESCALER_128 (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 128 */ 85 | #define IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1) /*!< IWDG prescaler set to 256 */ 86 | /** 87 | * @} 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /* Exported macros -----------------------------------------------------------*/ 95 | /** @defgroup IWDG_Exported_Macros IWDG Exported Macros 96 | * @{ 97 | */ 98 | 99 | /** 100 | * @brief Enable the IWDG peripheral. 101 | * @param __HANDLE__ IWDG handle 102 | * @retval None 103 | */ 104 | #define __HAL_IWDG_START(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_ENABLE) 105 | 106 | /** 107 | * @brief Reload IWDG counter with value defined in the reload register 108 | * (write access to IWDG_PR and IWDG_RLR registers disabled). 109 | * @param __HANDLE__ IWDG handle 110 | * @retval None 111 | */ 112 | #define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_RELOAD) 113 | 114 | /** 115 | * @} 116 | */ 117 | 118 | /* Exported functions --------------------------------------------------------*/ 119 | /** @defgroup IWDG_Exported_Functions IWDG Exported Functions 120 | * @{ 121 | */ 122 | 123 | /** @defgroup IWDG_Exported_Functions_Group1 Initialization and Start functions 124 | * @{ 125 | */ 126 | /* Initialization/Start functions ********************************************/ 127 | HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg); 128 | /** 129 | * @} 130 | */ 131 | 132 | /** @defgroup IWDG_Exported_Functions_Group2 IO operation functions 133 | * @{ 134 | */ 135 | /* I/O operation functions ****************************************************/ 136 | HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg); 137 | /** 138 | * @} 139 | */ 140 | 141 | /** 142 | * @} 143 | */ 144 | 145 | /* Private constants ---------------------------------------------------------*/ 146 | /** @defgroup IWDG_Private_Constants IWDG Private Constants 147 | * @{ 148 | */ 149 | 150 | /** 151 | * @brief IWDG Key Register BitMask 152 | */ 153 | #define IWDG_KEY_RELOAD 0x0000AAAAu /*!< IWDG Reload Counter Enable */ 154 | #define IWDG_KEY_ENABLE 0x0000CCCCu /*!< IWDG Peripheral Enable */ 155 | #define IWDG_KEY_WRITE_ACCESS_ENABLE 0x00005555u /*!< IWDG KR Write Access Enable */ 156 | #define IWDG_KEY_WRITE_ACCESS_DISABLE 0x00000000u /*!< IWDG KR Write Access Disable */ 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | /* Private macros ------------------------------------------------------------*/ 163 | /** @defgroup IWDG_Private_Macros IWDG Private Macros 164 | * @{ 165 | */ 166 | 167 | /** 168 | * @brief Enable write access to IWDG_PR and IWDG_RLR registers. 169 | * @param __HANDLE__ IWDG handle 170 | * @retval None 171 | */ 172 | #define IWDG_ENABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_ENABLE) 173 | 174 | /** 175 | * @brief Disable write access to IWDG_PR and IWDG_RLR registers. 176 | * @param __HANDLE__ IWDG handle 177 | * @retval None 178 | */ 179 | #define IWDG_DISABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_DISABLE) 180 | 181 | /** 182 | * @brief Check IWDG prescaler value. 183 | * @param __PRESCALER__ IWDG prescaler value 184 | * @retval None 185 | */ 186 | #define IS_IWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == IWDG_PRESCALER_4) || \ 187 | ((__PRESCALER__) == IWDG_PRESCALER_8) || \ 188 | ((__PRESCALER__) == IWDG_PRESCALER_16) || \ 189 | ((__PRESCALER__) == IWDG_PRESCALER_32) || \ 190 | ((__PRESCALER__) == IWDG_PRESCALER_64) || \ 191 | ((__PRESCALER__) == IWDG_PRESCALER_128)|| \ 192 | ((__PRESCALER__) == IWDG_PRESCALER_256)) 193 | 194 | /** 195 | * @brief Check IWDG reload value. 196 | * @param __RELOAD__ IWDG reload value 197 | * @retval None 198 | */ 199 | #define IS_IWDG_RELOAD(__RELOAD__) ((__RELOAD__) <= IWDG_RLR_RL) 200 | 201 | 202 | 203 | /** 204 | * @} 205 | */ 206 | 207 | /** 208 | * @} 209 | */ 210 | 211 | /** 212 | * @} 213 | */ 214 | 215 | 216 | #ifdef __cplusplus 217 | } 218 | #endif 219 | 220 | #endif /* STM32F4xx_HAL_IWDG_H */ 221 | -------------------------------------------------------------------------------- /source/nucleo-f446ze-library/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_hash_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_hash_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of HASH HAL module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32F4xx_HAL_HASH_EX_H 21 | #define STM32F4xx_HAL_HASH_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f4xx_hal_def.h" 29 | 30 | /** @addtogroup STM32F4xx_HAL_Driver 31 | * @{ 32 | */ 33 | #if defined (HASH) 34 | /** @addtogroup HASHEx 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* Exported constants --------------------------------------------------------*/ 40 | /* Exported macro ------------------------------------------------------------*/ 41 | 42 | 43 | /* Exported functions --------------------------------------------------------*/ 44 | 45 | /** @addtogroup HASHEx_Exported_Functions HASH Extended Exported Functions 46 | * @{ 47 | */ 48 | 49 | /** @addtogroup HASHEx_Exported_Functions_Group1 HASH extended processing functions in polling mode 50 | * @{ 51 | */ 52 | 53 | HAL_StatusTypeDef HAL_HASHEx_SHA224_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, 54 | uint8_t *pOutBuffer, uint32_t Timeout); 55 | HAL_StatusTypeDef HAL_HASHEx_SHA224_Accmlt(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 56 | HAL_StatusTypeDef HAL_HASHEx_SHA224_Accmlt_End(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, 57 | uint8_t *pOutBuffer, uint32_t Timeout); 58 | HAL_StatusTypeDef HAL_HASHEx_SHA256_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, 59 | uint8_t *pOutBuffer, uint32_t Timeout); 60 | HAL_StatusTypeDef HAL_HASHEx_SHA256_Accmlt(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 61 | HAL_StatusTypeDef HAL_HASHEx_SHA256_Accmlt_End(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, 62 | uint8_t *pOutBuffer, uint32_t Timeout); 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @addtogroup HASHEx_Exported_Functions_Group2 HASH extended processing functions in interrupt mode 69 | * @{ 70 | */ 71 | 72 | HAL_StatusTypeDef HAL_HASHEx_SHA224_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, 73 | uint8_t *pOutBuffer); 74 | HAL_StatusTypeDef HAL_HASHEx_SHA224_Accmlt_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 75 | HAL_StatusTypeDef HAL_HASHEx_SHA224_Accmlt_End_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, 76 | uint8_t *pOutBuffer); 77 | HAL_StatusTypeDef HAL_HASHEx_SHA256_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, 78 | uint8_t *pOutBuffer); 79 | HAL_StatusTypeDef HAL_HASHEx_SHA256_Accmlt_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 80 | HAL_StatusTypeDef HAL_HASHEx_SHA256_Accmlt_End_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, 81 | uint8_t *pOutBuffer); 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | /** @addtogroup HASHEx_Exported_Functions_Group3 HASH extended processing functions in DMA mode 88 | * @{ 89 | */ 90 | HAL_StatusTypeDef HAL_HASHEx_SHA224_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 91 | HAL_StatusTypeDef HAL_HASHEx_SHA224_Finish(HASH_HandleTypeDef *hhash, uint8_t *pOutBuffer, uint32_t Timeout); 92 | HAL_StatusTypeDef HAL_HASHEx_SHA256_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 93 | HAL_StatusTypeDef HAL_HASHEx_SHA256_Finish(HASH_HandleTypeDef *hhash, uint8_t *pOutBuffer, uint32_t Timeout); 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /** @addtogroup HASHEx_Exported_Functions_Group4 HMAC extended processing functions in polling mode 100 | * @{ 101 | */ 102 | HAL_StatusTypeDef HAL_HMACEx_SHA224_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, 103 | uint8_t *pOutBuffer, uint32_t Timeout); 104 | HAL_StatusTypeDef HAL_HMACEx_SHA256_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, 105 | uint8_t *pOutBuffer, uint32_t Timeout); 106 | /** 107 | * @} 108 | */ 109 | 110 | /** @addtogroup HASHEx_Exported_Functions_Group5 HMAC extended processing functions in interrupt mode 111 | * @{ 112 | */ 113 | 114 | HAL_StatusTypeDef HAL_HMACEx_SHA224_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, 115 | uint8_t *pOutBuffer); 116 | HAL_StatusTypeDef HAL_HMACEx_SHA256_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, 117 | uint8_t *pOutBuffer); 118 | 119 | /** 120 | * @} 121 | */ 122 | 123 | /** @addtogroup HASHEx_Exported_Functions_Group6 HMAC extended processing functions in DMA mode 124 | * @{ 125 | */ 126 | 127 | HAL_StatusTypeDef HAL_HMACEx_SHA224_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 128 | HAL_StatusTypeDef HAL_HMACEx_SHA256_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 129 | 130 | /** 131 | * @} 132 | */ 133 | 134 | /** @addtogroup HASHEx_Exported_Functions_Group7 Multi-buffer HMAC extended processing functions in DMA mode 135 | * @{ 136 | */ 137 | 138 | HAL_StatusTypeDef HAL_HMACEx_MD5_Step1_2_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 139 | HAL_StatusTypeDef HAL_HMACEx_MD5_Step2_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 140 | HAL_StatusTypeDef HAL_HMACEx_MD5_Step2_3_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 141 | 142 | HAL_StatusTypeDef HAL_HMACEx_SHA1_Step1_2_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 143 | HAL_StatusTypeDef HAL_HMACEx_SHA1_Step2_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 144 | HAL_StatusTypeDef HAL_HMACEx_SHA1_Step2_3_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 145 | HAL_StatusTypeDef HAL_HMACEx_SHA224_Step1_2_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 146 | HAL_StatusTypeDef HAL_HMACEx_SHA224_Step2_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 147 | HAL_StatusTypeDef HAL_HMACEx_SHA224_Step2_3_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 148 | 149 | HAL_StatusTypeDef HAL_HMACEx_SHA256_Step1_2_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 150 | HAL_StatusTypeDef HAL_HMACEx_SHA256_Step2_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 151 | HAL_StatusTypeDef HAL_HMACEx_SHA256_Step2_3_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); 152 | /** 153 | * @} 154 | */ 155 | 156 | /** 157 | * @} 158 | */ 159 | 160 | /** 161 | * @} 162 | */ 163 | #endif /* HASH*/ 164 | /** 165 | * @} 166 | */ 167 | 168 | 169 | #ifdef __cplusplus 170 | } 171 | #endif 172 | 173 | 174 | #endif /* STM32F4xx_HAL_HASH_EX_H */ 175 | 176 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousLibFiles] 2 | LibFiles=Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_uart.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usart.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_bus.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_system.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_utils.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dmamux.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_exti.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_exti.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usb.h;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_uart.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usart.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_bus.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_system.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_utils.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dmamux.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_exti.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_exti.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usb.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f446xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;Drivers/CMSIS/Include/mpu_armv7.h;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/tz_context.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/cmsis_version.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_armv8mbl.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/cmsis_gcc.h; 3 | 4 | [PreviousUsedCubeIDEFiles] 5 | SourceFiles=Core/Src/main.c;Core/Src/stm32f4xx_it.c;Core/Src/stm32f4xx_hal_msp.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;Core/Src/system_stm32f4xx.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;Core/Src/system_stm32f4xx.c;;; 6 | HeaderPath=Drivers/STM32F4xx_HAL_Driver/Inc;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy;Drivers/CMSIS/Device/ST/STM32F4xx/Include;Drivers/CMSIS/Include;Core/Inc; 7 | CDefines=USE_HAL_DRIVER;STM32F446xx;USE_HAL_DRIVER;USE_HAL_DRIVER; 8 | 9 | [PreviousGenFiles] 10 | AdvancedFolderStructure=true 11 | HeaderFileListSize=3 12 | HeaderFiles#0=../Core/Inc/stm32f4xx_it.h 13 | HeaderFiles#1=../Core/Inc/stm32f4xx_hal_conf.h 14 | HeaderFiles#2=../Core/Inc/main.h 15 | HeaderFolderListSize=1 16 | HeaderPath#0=../Core/Inc 17 | HeaderFiles=; 18 | SourceFileListSize=3 19 | SourceFiles#0=../Core/Src/stm32f4xx_it.c 20 | SourceFiles#1=../Core/Src/stm32f4xx_hal_msp.c 21 | SourceFiles#2=../Core/Src/main.c 22 | SourceFolderListSize=1 23 | SourcePath#0=../Core/Src 24 | SourceFiles=; 25 | 26 | -------------------------------------------------------------------------------- /source/stm32-cube-ide/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_def.h 4 | * @author MCD Application Team 5 | * @brief This file contains HAL common defines, enumeration, macros and 6 | * structures definitions. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2017 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32F4xx_HAL_DEF 22 | #define __STM32F4xx_HAL_DEF 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f4xx.h" 30 | #include "Legacy/stm32_hal_legacy.h" 31 | #include 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | 35 | /** 36 | * @brief HAL Status structures definition 37 | */ 38 | typedef enum 39 | { 40 | HAL_OK = 0x00U, 41 | HAL_ERROR = 0x01U, 42 | HAL_BUSY = 0x02U, 43 | HAL_TIMEOUT = 0x03U 44 | } HAL_StatusTypeDef; 45 | 46 | /** 47 | * @brief HAL Lock structures definition 48 | */ 49 | typedef enum 50 | { 51 | HAL_UNLOCKED = 0x00U, 52 | HAL_LOCKED = 0x01U 53 | } HAL_LockTypeDef; 54 | 55 | /* Exported macro ------------------------------------------------------------*/ 56 | 57 | #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */ 58 | 59 | #define HAL_MAX_DELAY 0xFFFFFFFFU 60 | 61 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT)) 62 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U) 63 | 64 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ 65 | do{ \ 66 | (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ 67 | (__DMA_HANDLE__).Parent = (__HANDLE__); \ 68 | } while(0U) 69 | 70 | /** @brief Reset the Handle's State field. 71 | * @param __HANDLE__ specifies the Peripheral Handle. 72 | * @note This macro can be used for the following purpose: 73 | * - When the Handle is declared as local variable; before passing it as parameter 74 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro 75 | * to set to 0 the Handle's "State" field. 76 | * Otherwise, "State" field may have any random value and the first time the function 77 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed 78 | * (i.e. HAL_PPP_MspInit() will not be executed). 79 | * - When there is a need to reconfigure the low level hardware: instead of calling 80 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). 81 | * In this later function, when the Handle's "State" field is set to 0, it will execute the function 82 | * HAL_PPP_MspInit() which will reconfigure the low level hardware. 83 | * @retval None 84 | */ 85 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U) 86 | 87 | #if (USE_RTOS == 1U) 88 | /* Reserved for future use */ 89 | #error "USE_RTOS should be 0 in the current HAL release" 90 | #else 91 | #define __HAL_LOCK(__HANDLE__) \ 92 | do{ \ 93 | if((__HANDLE__)->Lock == HAL_LOCKED) \ 94 | { \ 95 | return HAL_BUSY; \ 96 | } \ 97 | else \ 98 | { \ 99 | (__HANDLE__)->Lock = HAL_LOCKED; \ 100 | } \ 101 | }while (0U) 102 | 103 | #define __HAL_UNLOCK(__HANDLE__) \ 104 | do{ \ 105 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ 106 | }while (0U) 107 | #endif /* USE_RTOS */ 108 | 109 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ 110 | #ifndef __weak 111 | #define __weak __attribute__((weak)) 112 | #endif 113 | #ifndef __packed 114 | #define __packed __attribute__((packed)) 115 | #endif 116 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ 117 | #ifndef __weak 118 | #define __weak __attribute__((weak)) 119 | #endif /* __weak */ 120 | #ifndef __packed 121 | #define __packed __attribute__((__packed__)) 122 | #endif /* __packed */ 123 | #endif /* __GNUC__ */ 124 | 125 | 126 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ 127 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ 128 | #ifndef __ALIGN_BEGIN 129 | #define __ALIGN_BEGIN 130 | #endif 131 | #ifndef __ALIGN_END 132 | #define __ALIGN_END __attribute__ ((aligned (4))) 133 | #endif 134 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ 135 | #ifndef __ALIGN_END 136 | #define __ALIGN_END __attribute__ ((aligned (4))) 137 | #endif /* __ALIGN_END */ 138 | #ifndef __ALIGN_BEGIN 139 | #define __ALIGN_BEGIN 140 | #endif /* __ALIGN_BEGIN */ 141 | #else 142 | #ifndef __ALIGN_END 143 | #define __ALIGN_END 144 | #endif /* __ALIGN_END */ 145 | #ifndef __ALIGN_BEGIN 146 | #if defined (__CC_ARM) /* ARM Compiler V5*/ 147 | #define __ALIGN_BEGIN __align(4) 148 | #elif defined (__ICCARM__) /* IAR Compiler */ 149 | #define __ALIGN_BEGIN 150 | #endif /* __CC_ARM */ 151 | #endif /* __ALIGN_BEGIN */ 152 | #endif /* __GNUC__ */ 153 | 154 | 155 | /** 156 | * @brief __RAM_FUNC definition 157 | */ 158 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) 159 | /* ARM Compiler V4/V5 and V6 160 | -------------------------- 161 | RAM functions are defined using the toolchain options. 162 | Functions that are executed in RAM should reside in a separate source module. 163 | Using the 'Options for File' dialog you can simply change the 'Code / Const' 164 | area of a module to a memory space in physical RAM. 165 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' 166 | dialog. 167 | */ 168 | #define __RAM_FUNC 169 | 170 | #elif defined ( __ICCARM__ ) 171 | /* ICCARM Compiler 172 | --------------- 173 | RAM functions are defined using a specific toolchain keyword "__ramfunc". 174 | */ 175 | #define __RAM_FUNC __ramfunc 176 | 177 | #elif defined ( __GNUC__ ) 178 | /* GNU Compiler 179 | ------------ 180 | RAM functions are defined using a specific toolchain attribute 181 | "__attribute__((section(".RamFunc")))". 182 | */ 183 | #define __RAM_FUNC __attribute__((section(".RamFunc"))) 184 | 185 | #endif 186 | 187 | /** 188 | * @brief __NOINLINE definition 189 | */ 190 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined ( __GNUC__ ) 191 | /* ARM V4/V5 and V6 & GNU Compiler 192 | ------------------------------- 193 | */ 194 | #define __NOINLINE __attribute__ ( (noinline) ) 195 | 196 | #elif defined ( __ICCARM__ ) 197 | /* ICCARM Compiler 198 | --------------- 199 | */ 200 | #define __NOINLINE _Pragma("optimize = no_inline") 201 | 202 | #endif 203 | 204 | #ifdef __cplusplus 205 | } 206 | #endif 207 | 208 | #endif /* ___STM32F4xx_HAL_DEF */ 209 | 210 | 211 | --------------------------------------------------------------------------------