├── .gitmodules ├── README.md └── STM32F415APP ├── .cproject ├── .gitignore ├── .mxproject ├── .project ├── Application ├── AppMain.cpp ├── Application.cpp ├── Application.h ├── Calc.cpp ├── Calc.h ├── DefCfgUsr.h ├── ExampleMsgTask.cpp ├── ExampleMsgTask.h ├── Gario.cpp ├── Gario.h ├── GraphDemo.cpp ├── GraphDemo.h ├── InputTest.cpp ├── InputTest.h ├── Pong.cpp ├── Pong.h ├── Tetris.cpp └── Tetris.h ├── Core ├── Inc │ ├── FreeRTOSConfig.h │ ├── adc.h │ ├── dma.h │ ├── gpio.h │ ├── i2c.h │ ├── main.h │ ├── rtc.h │ ├── sdio.h │ ├── spi.h │ ├── stm32f4xx_hal_conf.h │ ├── stm32f4xx_it.h │ └── tim.h ├── Src │ ├── adc.c │ ├── dma.c │ ├── freertos.c │ ├── gpio.c │ ├── i2c.c │ ├── main.c │ ├── rtc.c │ ├── sdio.c │ ├── spi.c │ ├── stm32f4xx_hal_msp.c │ ├── stm32f4xx_it.c │ ├── syscalls.c │ ├── sysmem.c │ ├── system_stm32f4xx.c │ └── tim.c └── Startup │ └── startup_stm32f415rgtx.s ├── Drivers ├── CMSIS │ ├── Device │ │ └── ST │ │ │ └── STM32F4xx │ │ │ ├── Include │ │ │ ├── stm32f415xx.h │ │ │ ├── stm32f4xx.h │ │ │ └── system_stm32f4xx.h │ │ │ └── LICENSE.txt │ ├── Include │ │ ├── cachel1_armv7.h │ │ ├── cmsis_armcc.h │ │ ├── cmsis_armclang.h │ │ ├── cmsis_armclang_ltm.h │ │ ├── cmsis_compiler.h │ │ ├── cmsis_gcc.h │ │ ├── cmsis_iccarm.h │ │ ├── cmsis_version.h │ │ ├── core_armv81mml.h │ │ ├── core_armv8mbl.h │ │ ├── core_armv8mml.h │ │ ├── core_cm0.h │ │ ├── core_cm0plus.h │ │ ├── core_cm1.h │ │ ├── core_cm23.h │ │ ├── core_cm3.h │ │ ├── core_cm33.h │ │ ├── core_cm35p.h │ │ ├── core_cm4.h │ │ ├── core_cm55.h │ │ ├── core_cm7.h │ │ ├── core_cm85.h │ │ ├── core_sc000.h │ │ ├── core_sc300.h │ │ ├── core_starmc1.h │ │ ├── mpu_armv7.h │ │ ├── mpu_armv8.h │ │ ├── pac_armv81.h │ │ ├── pmu_armv8.h │ │ └── tz_context.h │ └── LICENSE.txt └── STM32F4xx_HAL_Driver │ ├── Inc │ ├── Legacy │ │ └── stm32_hal_legacy.h │ ├── stm32f4xx_hal.h │ ├── stm32f4xx_hal_adc.h │ ├── stm32f4xx_hal_adc_ex.h │ ├── stm32f4xx_hal_cortex.h │ ├── stm32f4xx_hal_def.h │ ├── stm32f4xx_hal_dma.h │ ├── stm32f4xx_hal_dma_ex.h │ ├── stm32f4xx_hal_exti.h │ ├── stm32f4xx_hal_flash.h │ ├── stm32f4xx_hal_flash_ex.h │ ├── stm32f4xx_hal_flash_ramfunc.h │ ├── stm32f4xx_hal_gpio.h │ ├── stm32f4xx_hal_gpio_ex.h │ ├── stm32f4xx_hal_i2c.h │ ├── stm32f4xx_hal_i2c_ex.h │ ├── stm32f4xx_hal_mmc.h │ ├── stm32f4xx_hal_pcd.h │ ├── stm32f4xx_hal_pcd_ex.h │ ├── stm32f4xx_hal_pwr.h │ ├── stm32f4xx_hal_pwr_ex.h │ ├── stm32f4xx_hal_rcc.h │ ├── stm32f4xx_hal_rcc_ex.h │ ├── stm32f4xx_hal_rtc.h │ ├── stm32f4xx_hal_rtc_ex.h │ ├── stm32f4xx_hal_sd.h │ ├── stm32f4xx_hal_spi.h │ ├── stm32f4xx_hal_tim.h │ ├── stm32f4xx_hal_tim_ex.h │ ├── stm32f4xx_ll_adc.h │ ├── stm32f4xx_ll_bus.h │ ├── stm32f4xx_ll_cortex.h │ ├── stm32f4xx_ll_dma.h │ ├── stm32f4xx_ll_exti.h │ ├── stm32f4xx_ll_gpio.h │ ├── stm32f4xx_ll_i2c.h │ ├── stm32f4xx_ll_pwr.h │ ├── stm32f4xx_ll_rcc.h │ ├── stm32f4xx_ll_rtc.h │ ├── stm32f4xx_ll_sdmmc.h │ ├── stm32f4xx_ll_spi.h │ ├── stm32f4xx_ll_system.h │ ├── stm32f4xx_ll_tim.h │ ├── stm32f4xx_ll_usb.h │ └── stm32f4xx_ll_utils.h │ ├── LICENSE.txt │ └── Src │ ├── stm32f4xx_hal.c │ ├── stm32f4xx_hal_adc.c │ ├── stm32f4xx_hal_adc_ex.c │ ├── stm32f4xx_hal_cortex.c │ ├── stm32f4xx_hal_dma.c │ ├── stm32f4xx_hal_dma_ex.c │ ├── stm32f4xx_hal_exti.c │ ├── stm32f4xx_hal_flash.c │ ├── stm32f4xx_hal_flash_ex.c │ ├── stm32f4xx_hal_flash_ramfunc.c │ ├── stm32f4xx_hal_gpio.c │ ├── stm32f4xx_hal_i2c.c │ ├── stm32f4xx_hal_i2c_ex.c │ ├── stm32f4xx_hal_mmc.c │ ├── stm32f4xx_hal_pcd.c │ ├── stm32f4xx_hal_pcd_ex.c │ ├── stm32f4xx_hal_pwr.c │ ├── stm32f4xx_hal_pwr_ex.c │ ├── stm32f4xx_hal_rcc.c │ ├── stm32f4xx_hal_rcc_ex.c │ ├── stm32f4xx_hal_rtc.c │ ├── stm32f4xx_hal_rtc_ex.c │ ├── stm32f4xx_hal_sd.c │ ├── stm32f4xx_hal_spi.c │ ├── stm32f4xx_hal_tim.c │ ├── stm32f4xx_hal_tim_ex.c │ ├── stm32f4xx_ll_adc.c │ ├── stm32f4xx_ll_sdmmc.c │ └── stm32f4xx_ll_usb.c ├── FATFS ├── App │ ├── fatfs.c │ └── fatfs.h └── Target │ ├── bsp_driver_sd.c │ ├── bsp_driver_sd.h │ ├── ffconf.h │ ├── sd_diskio.c │ └── sd_diskio.h ├── Middlewares ├── ST │ └── STM32_USB_Device_Library │ │ ├── Class │ │ └── CDC │ │ │ ├── Inc │ │ │ └── usbd_cdc.h │ │ │ └── Src │ │ │ └── usbd_cdc.c │ │ ├── Core │ │ ├── Inc │ │ │ ├── usbd_core.h │ │ │ ├── usbd_ctlreq.h │ │ │ ├── usbd_def.h │ │ │ └── usbd_ioreq.h │ │ └── Src │ │ │ ├── usbd_core.c │ │ │ ├── usbd_ctlreq.c │ │ │ └── usbd_ioreq.c │ │ └── LICENSE.txt └── Third_Party │ ├── FatFs │ └── src │ │ ├── diskio.c │ │ ├── diskio.h │ │ ├── ff.c │ │ ├── ff.h │ │ ├── ff_gen_drv.c │ │ ├── ff_gen_drv.h │ │ ├── integer.h │ │ └── option │ │ └── syscall.c │ └── FreeRTOS │ └── Source │ ├── CMSIS_RTOS │ ├── cmsis_os.c │ └── cmsis_os.h │ ├── LICENSE │ ├── croutine.c │ ├── event_groups.c │ ├── include │ ├── FreeRTOS.h │ ├── StackMacros.h │ ├── atomic.h │ ├── croutine.h │ ├── deprecated_definitions.h │ ├── event_groups.h │ ├── list.h │ ├── message_buffer.h │ ├── mpu_prototypes.h │ ├── mpu_wrappers.h │ ├── portable.h │ ├── projdefs.h │ ├── queue.h │ ├── semphr.h │ ├── stack_macros.h │ ├── stream_buffer.h │ ├── task.h │ └── timers.h │ ├── list.c │ ├── portable │ ├── GCC │ │ └── ARM_CM4F │ │ │ ├── port.c │ │ │ └── portmacro.h │ └── MemMang │ │ └── heap_4.c │ ├── queue.c │ ├── stream_buffer.c │ ├── tasks.c │ └── timers.c ├── STM32F415RGTX_RAM.ld ├── STM32F415RGTx_FLASH.ld ├── USB_DEVICE ├── App │ ├── usb_device.c │ ├── usb_device.h │ ├── usbd_cdc_if.c │ ├── usbd_cdc_if.h │ ├── usbd_desc.c │ └── usbd_desc.h └── Target │ ├── usbd_conf.c │ └── usbd_conf.h └── stm32f415app.ioc /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "STM32F415APP/DevCore"] 2 | path = STM32F415APP/DevCore 3 | url = https://github.com/nickshl/DevCore.git 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DevBoy 2 | 3 | [DevBoy](http://www.devboy.us/) - an open source modular system for learning, development and games. 4 | 5 | ## Built With 6 | 7 | * [System Workbench for STM32](http://www.openstm32.org/System%2BWorkbench%2Bfor%2BSTM32) - free STM32 integrated development environment 8 | * [STM32CubeMX](http://www.st.com/en/development-tools/stm32cubemx.html) - a graphical software configuration tool that allows the generation of C initialization code using graphical wizards -------------------------------------------------------------------------------- /STM32F415APP/.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse settings 2 | .settings 3 | .launch 4 | 5 | # Build folders 6 | Debug 7 | Release 8 | 9 | # Prerequisites 10 | *.d 11 | 12 | # Compiled Object files 13 | *.slo 14 | *.lo 15 | *.o 16 | *.obj 17 | 18 | # Precompiled Headers 19 | *.gch 20 | *.pch 21 | 22 | # Compiled Dynamic libraries 23 | *.so 24 | *.dylib 25 | *.dll 26 | 27 | # Fortran module files 28 | *.mod 29 | *.smod 30 | 31 | # Compiled Static libraries 32 | *.lai 33 | *.la 34 | *.a 35 | *.lib 36 | 37 | # Executables 38 | *.exe 39 | *.out 40 | *.app 41 | *.launch 42 | -------------------------------------------------------------------------------- /STM32F415APP/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | stm32f415app 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 | org.eclipse.cdt.core.ccnature 26 | com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature 27 | com.st.stm32cube.ide.mcu.MCUAdvancedStructureProjectNature 28 | com.st.stm32cube.ide.mcu.MCUSingleCpuProjectNature 29 | com.st.stm32cube.ide.mcu.MCURootProjectNature 30 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 31 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 32 | 33 | 34 | -------------------------------------------------------------------------------- /STM32F415APP/Application/AppMain.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // @file AppMain.cpp 3 | // @author Nicolai Shlapunov 4 | // 5 | // @details Application: Main file, header 6 | // 7 | // @copyright Copyright (c) 2016, Devtronic & Nicolai Shlapunov 8 | // All rights reserved. 9 | // 10 | // @section SUPPORT 11 | // 12 | // Devtronic invests time and resources providing this open source code, 13 | // please support Devtronic and open-source hardware/software by 14 | // donations and/or purchasing products from Devtronic. 15 | // 16 | //****************************************************************************** 17 | 18 | // ***************************************************************************** 19 | // *** Includes ************************************************************ 20 | // ***************************************************************************** 21 | #include "DevCfg.h" 22 | // Objects 23 | #include "StHalSpi.h" 24 | #include "StHalGpio.h" 25 | #include "ILI9341.h" 26 | #include "XPT2046.h" 27 | // Tasks 28 | #include "DisplayDrv.h" 29 | #include "InputDrv.h" 30 | #include "SoundDrv.h" 31 | #include "ExampleMsgTask.h" 32 | // Application 33 | #include "Application.h" 34 | 35 | // ***************************************************************************** 36 | // *** Objects ************************************************************* 37 | // ***************************************************************************** 38 | 39 | // GPIOs 40 | static StHalGpio display_cs(LCD_CS_GPIO_Port, LCD_CS_Pin, IGpio::OUTPUT); 41 | static StHalGpio display_dc(LCD_DC_GPIO_Port, LCD_DC_Pin, IGpio::OUTPUT); 42 | static StHalGpio touch_cs(TOUCH_CS_GPIO_Port, TOUCH_CS_Pin, IGpio::OUTPUT); 43 | static StHalGpio touch_irq(T_IRQ_GPIO_Port, T_IRQ_Pin, IGpio::INPUT); 44 | // Interfaces 45 | static StHalSpi spi1(hspi1); 46 | // Other 47 | static ILI9341 display(320, 240, spi1, display_cs, display_dc); 48 | static XPT2046 touch(spi1, touch_cs, touch_irq); 49 | 50 | // ***************************************************************************** 51 | // *** Main function ******************************************************* 52 | // ***************************************************************************** 53 | extern "C" void AppMain(void) 54 | { 55 | // Init Display Driver Task 56 | DisplayDrv::GetInstance().SetDisplayDrv(&display); 57 | DisplayDrv::GetInstance().SetTouchDrv(&touch); 58 | DisplayDrv::GetInstance().InitTask(); 59 | // Init Input Driver Task 60 | InputDrv::GetInstance().InitTask(nullptr, &hadc2); 61 | // Init Sound Driver Task 62 | SoundDrv::GetInstance().InitTask(&htim4, TIM_CHANNEL_2); 63 | 64 | // Init Messages Test Task 65 | ExampleMsgTask::GetInstance().InitTask(); 66 | 67 | // Init Application Task 68 | Application::GetInstance().InitTask(); 69 | } 70 | 71 | // ***************************************************************************** 72 | // *** Stack overflow hook function **************************************** 73 | // ***************************************************************************** 74 | extern "C" void vApplicationStackOverflowHook(TaskHandle_t* px_task, signed portCHAR* pc_task_name) 75 | { 76 | while(1); 77 | } 78 | 79 | // ***************************************************************************** 80 | // *** Malloc failed hook function ***************************************** 81 | // ***************************************************************************** 82 | extern "C" void vApplicationMallocFailedHook(void) 83 | { 84 | while(1); 85 | } 86 | -------------------------------------------------------------------------------- /STM32F415APP/Application/Application.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // @file Application.h 3 | // @author Nicolai Shlapunov 4 | // 5 | // @details Application: User Application Class, header 6 | // 7 | // @copyright Copyright (c) 2016, Devtronic & Nicolai Shlapunov 8 | // All rights reserved. 9 | // 10 | // @section SUPPORT 11 | // 12 | // Devtronic invests time and resources providing this open source code, 13 | // please support Devtronic and open-source hardware/software by 14 | // donations and/or purchasing products from Devtronic. 15 | // 16 | //****************************************************************************** 17 | 18 | #ifndef Application_h 19 | #define Application_h 20 | 21 | // ***************************************************************************** 22 | // *** Includes ************************************************************ 23 | // ***************************************************************************** 24 | #include "DevCfg.h" 25 | #include "AppTask.h" 26 | #include "DisplayDrv.h" 27 | #include "InputDrv.h" 28 | #include "SoundDrv.h" 29 | #include "UiEngine.h" 30 | 31 | #include "IIic.h" 32 | 33 | // ***************************************************************************** 34 | // *** Local const variables *********************************************** 35 | // ***************************************************************************** 36 | 37 | // ***************************************************************************** 38 | // *** Defines ************************************************************* 39 | // ***************************************************************************** 40 | #define BG_Z (100) 41 | 42 | // ***************************************************************************** 43 | // *** Application Class *************************************************** 44 | // ***************************************************************************** 45 | class Application : public AppTask 46 | { 47 | public: 48 | // ************************************************************************* 49 | // *** Get Instance **************************************************** 50 | // ************************************************************************* 51 | static Application& GetInstance(void); 52 | 53 | // ************************************************************************* 54 | // *** Application Loop ************************************************ 55 | // ************************************************************************* 56 | virtual Result Loop(); 57 | 58 | private: 59 | // Display driver instance 60 | DisplayDrv& display_drv = DisplayDrv::GetInstance(); 61 | // Input driver instance 62 | InputDrv& input_drv = InputDrv::GetInstance(); 63 | // Sound driver instance 64 | SoundDrv& sound_drv = SoundDrv::GetInstance(); 65 | 66 | // ************************************************************************* 67 | // *** I2C Ping function *********************************************** 68 | // ************************************************************************* 69 | Result IicPing(IIic& iic); 70 | 71 | // ************************************************************************* 72 | // *** ProcessUserInput ************************************************ 73 | // ************************************************************************* 74 | static char* GetMenuStr(void* ptr, char* buf, uint32_t n, uint32_t add_param); 75 | 76 | // ************************************************************************* 77 | // *** Private constructor ********************************************* 78 | // ************************************************************************* 79 | Application() : AppTask(APPLICATION_TASK_STACK_SIZE, APPLICATION_TASK_PRIORITY, 80 | "Application") {}; 81 | }; 82 | 83 | // ***************************************************************************** 84 | // *** CheckBox Class ****************************************************** 85 | // ***************************************************************************** 86 | class SoundControlBox : public Image 87 | { 88 | public: 89 | // ************************************************************************* 90 | // *** Constructor ***************************************************** 91 | // ************************************************************************* 92 | SoundControlBox(int32_t x, int32_t y, bool mute_flag = true); 93 | 94 | // ************************************************************************* 95 | // *** Put line in buffer ********************************************** 96 | // ************************************************************************* 97 | virtual void Action(ActionType action, int32_t tx, int32_t ty, int32_t tpx, int32_t tpy); 98 | 99 | private: 100 | // Mute flag 101 | bool mute = false; 102 | 103 | // Sound driver instance 104 | SoundDrv& sound_drv = SoundDrv::GetInstance(); 105 | }; 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /STM32F415APP/Application/Calc.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // @file Calc.h 3 | // @author Nicolai Shlapunov 4 | // 5 | // @details Application: Calculator Application Class, header 6 | // 7 | // @copyright Copyright (c) 2017, Devtronic & Nicolai Shlapunov 8 | // All rights reserved. 9 | // 10 | // @section SUPPORT 11 | // 12 | // Devtronic invests time and resources providing this open source code, 13 | // please support Devtronic and open-source hardware/software by 14 | // donations and/or purchasing products from Devtronic. 15 | // 16 | //****************************************************************************** 17 | 18 | #ifndef Calc_h 19 | #define Calc_h 20 | 21 | // ***************************************************************************** 22 | // *** Includes ************************************************************ 23 | // ***************************************************************************** 24 | #include "DevCfg.h" 25 | #include "AppTask.h" 26 | #include "DisplayDrv.h" 27 | #include "InputDrv.h" 28 | #include "SoundDrv.h" 29 | #include "UiEngine.h" 30 | 31 | // ***************************************************************************** 32 | // *** Local const variables *********************************************** 33 | // ***************************************************************************** 34 | 35 | // ***************************************************************************** 36 | // *** Defines ************************************************************* 37 | // ***************************************************************************** 38 | #define BG_Z (100) 39 | 40 | // ***************************************************************************** 41 | // *** Application Class *************************************************** 42 | // ***************************************************************************** 43 | class Calc : public AppTask 44 | { 45 | public: 46 | // ************************************************************************* 47 | // *** Get Instance **************************************************** 48 | // ************************************************************************* 49 | static Calc& GetInstance(void); 50 | 51 | // ************************************************************************* 52 | // *** Application Loop ************************************************ 53 | // ************************************************************************* 54 | virtual Result Loop(); 55 | 56 | private: 57 | 58 | // Operand 1 59 | int32_t a = 0; 60 | // Operand 2 61 | int32_t b = 0; 62 | // Operation 63 | char op = '\0'; 64 | // String for result 65 | char str[128]; 66 | 67 | // Buttons 68 | UiButton result; 69 | UiButton btn[4*4]; 70 | 71 | // Display driver instance 72 | DisplayDrv& display_drv = DisplayDrv::GetInstance(); 73 | // Input driver instance 74 | InputDrv& input_drv = InputDrv::GetInstance(); 75 | // Sound driver instance 76 | SoundDrv& sound_drv = SoundDrv::GetInstance(); 77 | 78 | // ************************************************************************* 79 | // *** Callback ******************************************************** 80 | // ************************************************************************* 81 | static Result Callback(Calc* calc, void* ptr); 82 | 83 | // ************************************************************************* 84 | // *** GenerateStr ***************************************************** 85 | // ************************************************************************* 86 | void GenerateStr(); 87 | 88 | // ************************************************************************* 89 | // *** Private constructor ********************************************* 90 | // ************************************************************************* 91 | Calc() : AppTask(APPLICATION_TASK_STACK_SIZE, APPLICATION_TASK_PRIORITY, 92 | "Calc") {}; 93 | }; 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /STM32F415APP/Application/DefCfgUsr.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // @file DevCfg.h 3 | // @author Nicolai Shlapunov 4 | // 5 | // @details DevCore: Config file, header 6 | // 7 | // This file contains user configuration for DevCore library. 8 | // It will be included in DefCfg.h file 9 | // 10 | //****************************************************************************** 11 | 12 | // ***************************************************************************** 13 | // *** Include for hardware ************************************************ 14 | // ***************************************************************************** 15 | #include "stm32f4xx.h" 16 | 17 | // ***************************************************************************** 18 | // *** Configuration ******************************************************* 19 | // ***************************************************************************** 20 | 21 | //#define DWT_ENABLED 22 | //#define UITASK_ENABLED 23 | #define INPUTDRV_ENABLED 24 | #define SOUNDDRV_ENABLED 25 | 26 | // ***************************************************************************** 27 | // *** Tasks stack size and priorities configuration *********************** 28 | // ***************************************************************************** 29 | 30 | // *** Applications tasks stack sizes **************************************** 31 | #define APPLICATION_TASK_STACK_SIZE 1024u 32 | #define EXAMPLE_MSG_TASK_STACK_SIZE configMINIMAL_STACK_SIZE 33 | // *** Applications tasks priorities ***************************************** 34 | #define APPLICATION_TASK_PRIORITY (tskIDLE_PRIORITY + 2u) 35 | #define EXAMPLE_MSG_TASK_PRIORITY (tskIDLE_PRIORITY + 2u) 36 | 37 | // ***************************************************************************** 38 | // *** Display Configuration *********************************************** 39 | // ***************************************************************************** 40 | 41 | // Max line in pixels for allocate buffer in Display Driver. Usually equal to 42 | // maximum number of pixels in line. But sometimes can be greater than that. 43 | // For example ILI9488 uses 18 bit color(3 bytes per pixel) and if 16 bit color 44 | // is used(2 bytes per pixel) in order to prepare data display driver need 1.5 45 | // times more memory 46 | #define DISPLAY_MAX_BUF_LEN 320u 47 | 48 | // Color depth used by display 49 | #define COLOR_16BIT 50 | 51 | // By uncommenting this line, display task will update only specific area than 52 | // have to be updated 53 | #define UPDATE_AREA_ENABLED 54 | 55 | // In some cases one area isn't enough. In case of changes in small areas far 56 | // away on a large display, it makes sense to have multiple areas that can be 57 | // updated this option defines how many such areas is present. In case of 58 | // overflow, code will merge areas to update everything that have to be updated. 59 | #define MULTIPLE_UPDATE_AREAS 32u 60 | 61 | // Display FPS/Touch/Area debug options 62 | static constexpr bool DISPLAY_DEBUG_INFO = false; 63 | static constexpr bool DISPLAY_DEBUG_AREA = false; 64 | static constexpr bool DISPLAY_DEBUG_TOUCH = false; 65 | 66 | -------------------------------------------------------------------------------- /STM32F415APP/Application/ExampleMsgTask.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // @file ExampleMsgTask.cpp 3 | // @author Nicolai Shlapunov 4 | // 5 | // @details Application: Example Message Task Class, implementation 6 | // 7 | // @copyright Copyright (c) 2017, Devtronic & Nicolai Shlapunov 8 | // All rights reserved. 9 | // 10 | // @section SUPPORT 11 | // 12 | // Devtronic invests time and resources providing this open source code, 13 | // please support Devtronic and open-source hardware/software by 14 | // donations and/or purchasing products from Devtronic. 15 | // 16 | //****************************************************************************** 17 | 18 | // ***************************************************************************** 19 | // *** Includes ************************************************************ 20 | // ***************************************************************************** 21 | #include "ExampleMsgTask.h" 22 | 23 | // ***************************************************************************** 24 | // *** Get Instance ******************************************************** 25 | // ***************************************************************************** 26 | ExampleMsgTask& ExampleMsgTask::GetInstance(void) 27 | { 28 | static ExampleMsgTask example_msg_task; 29 | return example_msg_task; 30 | } 31 | 32 | // ***************************************************************************** 33 | // *** TimerExpired function *********************************************** 34 | // ***************************************************************************** 35 | Result ExampleMsgTask::TimerExpired() 36 | { 37 | TaskQueueMsg msg; 38 | msg.type = TASK_TIMER_MSG; 39 | Result result = SendTaskMessage(&msg); 40 | return result; 41 | } 42 | 43 | // ***************************************************************************** 44 | // *** ProcessMessage function ********************************************* 45 | // ***************************************************************************** 46 | Result ExampleMsgTask::ProcessMessage() 47 | { 48 | Result result = Result::ERR_NULL_PTR; 49 | 50 | switch(rcv_msg.type) 51 | { 52 | case TASK_TIMER_MSG: 53 | result = Result::RESULT_OK; 54 | break; 55 | 56 | default: 57 | result = Result::ERR_INVALID_ITEM; 58 | break; 59 | } 60 | 61 | return result; 62 | } 63 | 64 | -------------------------------------------------------------------------------- /STM32F415APP/Application/ExampleMsgTask.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // @file ExampleMsgTask.h 3 | // @author Nicolai Shlapunov 4 | // 5 | // @details Application: Example Message Task Class, header 6 | // 7 | // @copyright Copyright (c) 2017, Devtronic & Nicolai Shlapunov 8 | // All rights reserved. 9 | // 10 | // @section SUPPORT 11 | // 12 | // Devtronic invests time and resources providing this open source code, 13 | // please support Devtronic and open-source hardware/software by 14 | // donations and/or purchasing products from Devtronic. 15 | // 16 | //****************************************************************************** 17 | 18 | #ifndef ExampleMsgTask_h 19 | #define ExampleMsgTask_h 20 | 21 | // ***************************************************************************** 22 | // *** Includes ************************************************************ 23 | // ***************************************************************************** 24 | #include "DevCfg.h" 25 | #include "AppTask.h" 26 | 27 | // ***************************************************************************** 28 | // *** Application Class *************************************************** 29 | // ***************************************************************************** 30 | class ExampleMsgTask : public AppTask 31 | { 32 | public: 33 | // ************************************************************************* 34 | // *** Get Instance **************************************************** 35 | // ************************************************************************* 36 | static ExampleMsgTask& GetInstance(void); 37 | 38 | // ************************************************************************* 39 | // *** TimerExpired function ******************************************* 40 | // ************************************************************************* 41 | virtual Result TimerExpired(); 42 | 43 | // ************************************************************************* 44 | // *** ProcessMessage function ***************************************** 45 | // ************************************************************************* 46 | virtual Result ProcessMessage(); 47 | 48 | private: 49 | // Timer period 50 | static const uint32_t TASK_TIMER_PERIOD_MS = 1000U; 51 | 52 | // Task queue message types 53 | enum TaskQueueMsgType 54 | { 55 | TASK_TIMER_MSG 56 | }; 57 | 58 | // Task queue message struct 59 | struct TaskQueueMsg 60 | { 61 | TaskQueueMsgType type; 62 | }; 63 | 64 | // Buffer for received task message 65 | TaskQueueMsg rcv_msg; 66 | 67 | // ************************************************************************* 68 | // *** Private constructor ********************************************* 69 | // ************************************************************************* 70 | ExampleMsgTask() : AppTask(EXAMPLE_MSG_TASK_STACK_SIZE, EXAMPLE_MSG_TASK_PRIORITY, 71 | "ExampleMsgTask", 8U, sizeof(TaskQueueMsg), &rcv_msg, 72 | TASK_TIMER_PERIOD_MS) {}; 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /STM32F415APP/Application/GraphDemo.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // @file GraphDemo.cpp 3 | // @author Nicolai Shlapunov 4 | // 5 | // @details Application: Graphic Demo Application Class, implementation 6 | // 7 | // @copyright Copyright (c) 2016, Devtronic & Nicolai Shlapunov 8 | // All rights reserved. 9 | // 10 | // @section SUPPORT 11 | // 12 | // Devtronic invests time and resources providing this open source code, 13 | // please support Devtronic and open-source hardware/software by 14 | // donations and/or purchasing products from Devtronic. 15 | // 16 | //****************************************************************************** 17 | 18 | // ***************************************************************************** 19 | // *** Includes ************************************************************ 20 | // ***************************************************************************** 21 | #include "GraphDemo.h" 22 | 23 | #include 24 | 25 | // ***************************************************************************** 26 | // *** Get Instance ******************************************************** 27 | // ***************************************************************************** 28 | GraphDemo& GraphDemo::GetInstance(void) 29 | { 30 | static GraphDemo gd; 31 | return gd; 32 | } 33 | 34 | // ***************************************************************************** 35 | // *** GraphDemo Loop ****************************************************** 36 | // ***************************************************************************** 37 | Result GraphDemo::Loop() 38 | { 39 | static VisObjectRandomMover* pointer_list[60]; 40 | uint32_t list_item_cnt = 0; 41 | 42 | Circle circle1(150-30, 120+30, 30, COLOR_MAGENTA, true); 43 | circle1.Show(40); 44 | 45 | Circle circle2(150, 120, 30, COLOR_BLUE); 46 | circle2.Show(50); 47 | 48 | Line line1(46, 34, 126, 210, COLOR_GREEN); 49 | line1.Show(30); 50 | Line line2(46, 34, 310, 126, COLOR_CYAN); 51 | line2.Show(30); 52 | 53 | String str1("Hello World!", 0, 10, COLOR_MAGENTA, Font_4x6::GetInstance()); 54 | str1.Show(70); 55 | String str2("Hello World!", 0, 20, COLOR_CYAN, Font_6x8::GetInstance()); 56 | str2.Show(80); 57 | String str3("Hello World!", 0, 30, COLOR_YELLOW, Font_8x8::GetInstance()); 58 | str3.Show(90); 59 | String str4("Hello World!", 0, 50, COLOR_GREEN,COLOR_MAGENTA, Font_6x8::GetInstance()); 60 | str4.Show(100); 61 | String str5("Hello World!", 0, 70, COLOR_RED, Font_12x16::GetInstance()); 62 | str5.Show(110); 63 | 64 | Box box1(0, 0, 100, 10, COLOR_RED, true); 65 | box1.Show(10); 66 | Box box2(100, 70, 20, 10, COLOR_YELLOW); 67 | box2.Show(20); 68 | 69 | pointer_list[list_item_cnt++] = new VisObjectRandomMover(circle1); 70 | pointer_list[list_item_cnt++] = new VisObjectRandomMover(circle2); 71 | pointer_list[list_item_cnt++] = new VisObjectRandomMover(line1); 72 | pointer_list[list_item_cnt++] = new VisObjectRandomMover(line2); 73 | pointer_list[list_item_cnt++] = new VisObjectRandomMover(str1); 74 | pointer_list[list_item_cnt++] = new VisObjectRandomMover(str2); 75 | pointer_list[list_item_cnt++] = new VisObjectRandomMover(str3); 76 | pointer_list[list_item_cnt++] = new VisObjectRandomMover(str4); 77 | pointer_list[list_item_cnt++] = new VisObjectRandomMover(str5); 78 | pointer_list[list_item_cnt++] = new VisObjectRandomMover(box1); 79 | pointer_list[list_item_cnt++] = new VisObjectRandomMover(box2); 80 | 81 | // Infinite loop 82 | while (1) 83 | { 84 | // Lock Display 85 | if(display_drv.LockDisplay() == Result::RESULT_OK) 86 | { 87 | // Move all objects 88 | for(uint32_t i=0; i < list_item_cnt; i++) pointer_list[i]->Process(); 89 | // Unlock Display 90 | display_drv.UnlockDisplay(); 91 | // Update Display 92 | display_drv.UpdateDisplay(); 93 | // Pause for switch to Display Task 94 | RtosTick::DelayTicks(1U); 95 | } 96 | } 97 | // Always run 98 | return Result::RESULT_OK; 99 | } 100 | 101 | // ************************************************************************* 102 | // *** Constructor ***************************************************** 103 | // ************************************************************************* 104 | VisObjectRandomMover::VisObjectRandomMover(VisObject& obj) : object(obj) 105 | { 106 | x_dir = 1 + rand()%6; 107 | y_dir = 1 + rand()%6; 108 | speed = 1; 109 | } 110 | 111 | // ************************************************************************* 112 | // *** Constructor ***************************************************** 113 | // ************************************************************************* 114 | void VisObjectRandomMover::Process(void) 115 | { 116 | int32_t dx=0, dy=0; 117 | int32_t mid_x = (object.GetEndX() + object.GetStartX())/2; 118 | int32_t mid_y = (object.GetEndY() + object.GetStartY())/2; 119 | // X move 120 | if((mid_x+x_dir >= 0) && (mid_x+x_dir < display_drv.GetScreenW())) 121 | { 122 | dx = x_dir; 123 | } 124 | else 125 | { 126 | x_dir = -x_dir; 127 | } 128 | 129 | // Y move 130 | if((mid_y+y_dir >= 0) && (mid_y+y_dir < display_drv.GetScreenH())) 131 | { 132 | dy = y_dir; 133 | } 134 | else 135 | { 136 | y_dir = -y_dir; 137 | } 138 | 139 | // Move object 140 | object.Move(dx, dy, true); 141 | } 142 | -------------------------------------------------------------------------------- /STM32F415APP/Application/GraphDemo.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // @file GraphDemo.h 3 | // @author Nicolai Shlapunov 4 | // 5 | // @details Application: Graphic Demo Application Class, header 6 | // 7 | // @copyright Copyright (c) 2016, Devtronic & Nicolai Shlapunov 8 | // All rights reserved. 9 | // 10 | // @section SUPPORT 11 | // 12 | // Devtronic invests time and resources providing this open source code, 13 | // please support Devtronic and open-source hardware/software by 14 | // donations and/or purchasing products from Devtronic. 15 | // 16 | //****************************************************************************** 17 | 18 | #ifndef GraphDemo_h 19 | #define GraphDemo_h 20 | 21 | // ***************************************************************************** 22 | // *** Includes ************************************************************ 23 | // ***************************************************************************** 24 | #include "DevCfg.h" 25 | #include "AppTask.h" 26 | #include "DisplayDrv.h" 27 | #include "InputDrv.h" 28 | #include "SoundDrv.h" 29 | 30 | // ***************************************************************************** 31 | // *** Local const variables *********************************************** 32 | // ***************************************************************************** 33 | 34 | // ***************************************************************************** 35 | // *** Defines ************************************************************* 36 | // ***************************************************************************** 37 | #define BG_Z (100) 38 | 39 | // ***************************************************************************** 40 | // *** Application Class *************************************************** 41 | // ***************************************************************************** 42 | class GraphDemo : public AppTask 43 | { 44 | public: 45 | // ************************************************************************* 46 | // *** Get Instance **************************************************** 47 | // ************************************************************************* 48 | static GraphDemo& GetInstance(void); 49 | 50 | // ************************************************************************* 51 | // *** Application Loop ************************************************ 52 | // ************************************************************************* 53 | virtual Result Loop(); 54 | 55 | private: 56 | // Button states 57 | bool btn_states[InputDrv::BTN_MAX]; 58 | // Init time variable 59 | int32_t last_enc1_val = 0; 60 | // Init time variable 61 | int32_t last_enc2_val = 0; 62 | 63 | // Display driver instance 64 | DisplayDrv& display_drv = DisplayDrv::GetInstance(); 65 | 66 | // Input driver instance 67 | InputDrv& input_drv = InputDrv::GetInstance(); 68 | 69 | // ************************************************************************* 70 | // *** ProcessUserInput ************************************************ 71 | // ************************************************************************* 72 | bool ProcessUserInput(void); 73 | 74 | // ************************************************************************* 75 | // *** Private constructor ********************************************* 76 | // ************************************************************************* 77 | GraphDemo() : AppTask(APPLICATION_TASK_STACK_SIZE, APPLICATION_TASK_PRIORITY, 78 | "GraphDemo") {}; 79 | }; 80 | 81 | // ***************************************************************************** 82 | // *** Application Class *************************************************** 83 | // ***************************************************************************** 84 | class VisObjectRandomMover 85 | { 86 | public: 87 | // ************************************************************************* 88 | // *** Constructor ***************************************************** 89 | // ************************************************************************* 90 | explicit VisObjectRandomMover(VisObject& obj); 91 | 92 | // ************************************************************************* 93 | // *** Init Application Task ******************************************* 94 | // ************************************************************************* 95 | void Process(void); 96 | 97 | private: 98 | VisObject& object; 99 | int8_t x_dir = 0; 100 | int8_t y_dir = 0; 101 | int8_t speed = 0; 102 | 103 | // Display driver instance 104 | DisplayDrv& display_drv = DisplayDrv::GetInstance(); 105 | }; 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /STM32F415APP/Application/InputTest.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // @file InputTest.cpp 3 | // @author Nicolai Shlapunov 4 | // 5 | // @details Application: Input Test Application Class, implementation 6 | // 7 | // @copyright Copyright (c) 2017, Devtronic & Nicolai Shlapunov 8 | // All rights reserved. 9 | // 10 | // @section SUPPORT 11 | // 12 | // Devtronic invests time and resources providing this open source code, 13 | // please support Devtronic and open-source hardware/software by 14 | // donations and/or purchasing products from Devtronic. 15 | // 16 | //****************************************************************************** 17 | 18 | // ***************************************************************************** 19 | // *** Includes ************************************************************ 20 | // ***************************************************************************** 21 | #include "InputTest.h" 22 | 23 | // ***************************************************************************** 24 | // *** Get Instance ******************************************************** 25 | // ***************************************************************************** 26 | InputTest& InputTest::GetInstance(void) 27 | { 28 | static InputTest input_test; 29 | return input_test; 30 | } 31 | 32 | // ***************************************************************************** 33 | // *** Test get function *************************************************** 34 | // ***************************************************************************** 35 | char* InputTest::GetMenuStr(void* ptr, char * buf, uint32_t n, uint32_t add_param) 36 | { 37 | // InputTest* it = (InputTest*)ptr; 38 | snprintf(buf, n, "%lu", add_param); 39 | return buf; 40 | } 41 | 42 | // ***************************************************************************** 43 | // *** Application Loop **************************************************** 44 | // ***************************************************************************** 45 | Result InputTest::Loop() 46 | { 47 | char str_left[32] = {"\0"}; 48 | String left_str(str_left, 30-2, 20 - 14, COLOR_MAGENTA, Font_8x12::GetInstance()); 49 | char str_right[32] = {"\0"}; 50 | String right_str(str_right, 190-2, 20 - 14, COLOR_MAGENTA, Font_8x12::GetInstance()); 51 | 52 | Box box_left(30-2, 20, 100+4, 100+4, COLOR_YELLOW); 53 | Circle circle_left(30-1, 20-1, 3, COLOR_RED, true); 54 | char str_left_data[128] = {"\0"}; 55 | String left_str_data(str_left_data, 0, 200, COLOR_MAGENTA, Font_6x8::GetInstance()); 56 | 57 | Box box_right(190-2, 20, 100+4, 100+4, COLOR_YELLOW); 58 | Circle circle_right(190-1, 20-1, 3, COLOR_RED, true); 59 | char str_right_data[128] = {"\0"}; 60 | String right_str_data(str_right_data, 0, 212, COLOR_MAGENTA, Font_6x8::GetInstance()); 61 | 62 | if(input_drv.GetDeviceType(InputDrv::EXT_LEFT) == InputDrv::EXT_DEV_JOY) 63 | { 64 | sprintf(str_left, "JOYSTICK"); 65 | left_str.Show(30); 66 | 67 | box_left.Show(10); 68 | circle_left.Show(20); 69 | left_str_data.Show(30); 70 | } 71 | if(input_drv.GetDeviceType(InputDrv::EXT_LEFT) == InputDrv::EXT_DEV_ENC) 72 | { 73 | sprintf(str_left, "ENCODER"); 74 | left_str.Show(30); 75 | } 76 | if(input_drv.GetDeviceType(InputDrv::EXT_LEFT) == InputDrv::EXT_DEV_BTN) 77 | { 78 | sprintf(str_left, "BUTTONS"); 79 | left_str.Show(30); 80 | } 81 | 82 | if(input_drv.GetDeviceType(InputDrv::EXT_RIGHT) == InputDrv::EXT_DEV_JOY) 83 | { 84 | sprintf(str_left, "JOYSTICK"); 85 | left_str.Show(30); 86 | 87 | box_right.Show(10); 88 | circle_right.Show(20); 89 | right_str_data.Show(30); 90 | } 91 | if(input_drv.GetDeviceType(InputDrv::EXT_RIGHT) == InputDrv::EXT_DEV_ENC) 92 | { 93 | sprintf(str_right, "ENCODER"); 94 | right_str.Show(30); 95 | } 96 | if(input_drv.GetDeviceType(InputDrv::EXT_RIGHT) == InputDrv::EXT_DEV_BTN) 97 | { 98 | sprintf(str_right, "BUTTONS"); 99 | right_str.Show(30); 100 | } 101 | 102 | int32_t x = 0; 103 | int32_t y = 0; 104 | 105 | while(1) 106 | { 107 | if(input_drv.GetDeviceType(InputDrv::EXT_LEFT) == InputDrv::EXT_DEV_JOY) 108 | { 109 | // Get values for left 110 | input_drv.GetJoystickState(InputDrv::EXT_LEFT, x, y); 111 | circle_left.Move(30-2 + (x * 100) / 4095, 20-2 + (y * 100) / 4095); 112 | sprintf(str_left_data, "LEFT: X=%4li, Y=%4li", x, y); 113 | } 114 | 115 | if(input_drv.GetDeviceType(InputDrv::EXT_RIGHT) == InputDrv::EXT_DEV_JOY) 116 | { 117 | // Get values for right 118 | input_drv.GetJoystickState(InputDrv::EXT_RIGHT, x, y); 119 | circle_right.Move(190-2 + (x * 100) / 4095, 20-2 + (y * 100) / 4095); 120 | sprintf(str_right_data, "RIGHT: X=%4li, Y=%4li", x, y); 121 | } 122 | 123 | // Update Display 124 | display_drv.UpdateDisplay(); 125 | // Pause 126 | RtosTick::DelayTicks(50U); 127 | 128 | // Exit by touch 129 | if(display_drv.IsTouched() == true) 130 | { 131 | break; 132 | } 133 | } 134 | 135 | // Always run 136 | return Result::RESULT_OK; 137 | } 138 | -------------------------------------------------------------------------------- /STM32F415APP/Application/InputTest.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // @file InputTest.h 3 | // @author Nicolai Shlapunov 4 | // 5 | // @details Application: Input Test Application Class, header 6 | // 7 | // @copyright Copyright (c) 2017, Devtronic & Nicolai Shlapunov 8 | // All rights reserved. 9 | // 10 | // @section SUPPORT 11 | // 12 | // Devtronic invests time and resources providing this open source code, 13 | // please support Devtronic and open-source hardware/software by 14 | // donations and/or purchasing products from Devtronic. 15 | // 16 | //****************************************************************************** 17 | 18 | #ifndef InputTest_h 19 | #define InputTest_h 20 | 21 | // ***************************************************************************** 22 | // *** Includes ************************************************************ 23 | // ***************************************************************************** 24 | #include "DevCfg.h" 25 | #include "AppTask.h" 26 | #include "DisplayDrv.h" 27 | #include "InputDrv.h" 28 | #include "SoundDrv.h" 29 | #include "UiEngine.h" 30 | 31 | // ***************************************************************************** 32 | // *** Local const variables *********************************************** 33 | // ***************************************************************************** 34 | 35 | // ***************************************************************************** 36 | // *** Defines ************************************************************* 37 | // ***************************************************************************** 38 | #define BG_Z (100) 39 | 40 | // ***************************************************************************** 41 | // *** Application Class *************************************************** 42 | // ***************************************************************************** 43 | class InputTest : public AppTask 44 | { 45 | public: 46 | // ************************************************************************* 47 | // *** Get Instance **************************************************** 48 | // ************************************************************************* 49 | static InputTest& GetInstance(void); 50 | 51 | // ************************************************************************* 52 | // *** Application Loop ************************************************ 53 | // ************************************************************************* 54 | virtual Result Loop(); 55 | 56 | private: 57 | // Display driver instance 58 | DisplayDrv& display_drv = DisplayDrv::GetInstance(); 59 | // Input driver instance 60 | InputDrv& input_drv = InputDrv::GetInstance(); 61 | // Sound driver instance 62 | SoundDrv& sound_drv = SoundDrv::GetInstance(); 63 | 64 | // ************************************************************************* 65 | // *** ProcessUserInput ************************************************ 66 | // ************************************************************************* 67 | static char* GetMenuStr(void* ptr, char* buf, uint32_t n, uint32_t add_param); 68 | 69 | // ************************************************************************* 70 | // *** Private constructor ********************************************* 71 | // ************************************************************************* 72 | InputTest() : AppTask(APPLICATION_TASK_STACK_SIZE, APPLICATION_TASK_PRIORITY, 73 | "InputTest") {}; 74 | }; 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /STM32F415APP/Application/Pong.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // @file Pong.h 3 | // @author Nicolai Shlapunov 4 | // 5 | // @details Application: Pong Application Class, header 6 | // 7 | // @copyright Copyright (c) 2017, Devtronic & Nicolai Shlapunov 8 | // All rights reserved. 9 | // 10 | // @section SUPPORT 11 | // 12 | // Devtronic invests time and resources providing this open source code, 13 | // please support Devtronic and open-source hardware/software by 14 | // donations and/or purchasing products from Devtronic. 15 | // 16 | //****************************************************************************** 17 | 18 | #ifndef Pong_h 19 | #define Pong_h 20 | 21 | // ***************************************************************************** 22 | // *** Includes ************************************************************ 23 | // ***************************************************************************** 24 | #include "DevCfg.h" 25 | #include "AppTask.h" 26 | #include "DisplayDrv.h" 27 | #include "InputDrv.h" 28 | #include "SoundDrv.h" 29 | #include "UiEngine.h" 30 | 31 | // ***************************************************************************** 32 | // *** Local const variables *********************************************** 33 | // ***************************************************************************** 34 | 35 | // ***************************************************************************** 36 | // *** Defines ************************************************************* 37 | // ***************************************************************************** 38 | 39 | // ***************************************************************************** 40 | // *** Application Class *************************************************** 41 | // ***************************************************************************** 42 | class Pong : public AppTask 43 | { 44 | public: 45 | // ************************************************************************* 46 | // *** Get Instance **************************************************** 47 | // ************************************************************************* 48 | static Pong& GetInstance(void); 49 | 50 | // ************************************************************************* 51 | // *** Pong Loop ******************************************************* 52 | // ************************************************************************* 53 | virtual Result Loop(); 54 | 55 | private: 56 | // Max score 57 | static const uint8_t MAX_SCORE = 5U; 58 | 59 | // Game over flag 60 | bool game_over = false; 61 | // Round flag 62 | bool round = true; 63 | 64 | // Direction for x and y 65 | int8_t x_dir = 1; 66 | int8_t y_dir = 1; 67 | 68 | // Ball speed 69 | int8_t speed = 5; 70 | 71 | // Encoder 1 count 72 | int32_t enc_left_cnt = 0; 73 | // Encoder 2 count 74 | int32_t enc_right_cnt = 0; 75 | // Button states 76 | bool btn_states[InputDrv::BTN_MAX] = { false }; 77 | // Encoder variable 78 | int32_t last_enc_left_val = 0; 79 | // Encoder variable 80 | int32_t last_enc_right_val = 0; 81 | 82 | // Display driver instance 83 | DisplayDrv& display_drv = DisplayDrv::GetInstance(); 84 | // Input driver instance 85 | InputDrv& input_drv = InputDrv::GetInstance(); 86 | // Sound driver instance 87 | SoundDrv& sound_drv = SoundDrv::GetInstance(); 88 | 89 | // ************************************************************************* 90 | // *** MoveBall ******************************************************** 91 | // ************************************************************************* 92 | bool MoveBall(Circle &ball, Box &box_left, Box &box_right); 93 | 94 | // ************************************************************************* 95 | // ** Private constructor. Only GetInstance() allow to access this class. ** 96 | // ************************************************************************* 97 | Pong() : AppTask(APPLICATION_TASK_STACK_SIZE, APPLICATION_TASK_PRIORITY, 98 | "Pong") {}; 99 | }; 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /STM32F415APP/Core/Inc/adc.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file adc.h 5 | * @brief This file contains all the function prototypes for 6 | * the adc.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __ADC_H__ 22 | #define __ADC_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | extern ADC_HandleTypeDef hadc2; 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_ADC2_Init(void); 42 | 43 | /* USER CODE BEGIN Prototypes */ 44 | 45 | /* USER CODE END Prototypes */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __ADC_H__ */ 52 | 53 | -------------------------------------------------------------------------------- /STM32F415APP/Core/Inc/dma.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file dma.h 5 | * @brief This file contains all the function prototypes for 6 | * the dma.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __DMA_H__ 22 | #define __DMA_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* DMA memory to memory transfer handles -------------------------------------*/ 32 | 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_DMA_Init(void); 42 | 43 | /* USER CODE BEGIN Prototypes */ 44 | 45 | /* USER CODE END Prototypes */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __DMA_H__ */ 52 | 53 | -------------------------------------------------------------------------------- /STM32F415APP/Core/Inc/gpio.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.h 5 | * @brief This file contains all the function prototypes for 6 | * the gpio.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __GPIO_H__ 22 | #define __GPIO_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | /* USER CODE BEGIN Private defines */ 36 | 37 | /* USER CODE END Private defines */ 38 | 39 | void MX_GPIO_Init(void); 40 | 41 | /* USER CODE BEGIN Prototypes */ 42 | 43 | /* USER CODE END Prototypes */ 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif /*__ GPIO_H__ */ 49 | 50 | -------------------------------------------------------------------------------- /STM32F415APP/Core/Inc/i2c.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file i2c.h 5 | * @brief This file contains all the function prototypes for 6 | * the i2c.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __I2C_H__ 22 | #define __I2C_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | extern I2C_HandleTypeDef hi2c1; 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_I2C1_Init(void); 42 | 43 | /* USER CODE BEGIN Prototypes */ 44 | 45 | /* USER CODE END Prototypes */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __I2C_H__ */ 52 | 53 | -------------------------------------------------------------------------------- /STM32F415APP/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) 2023 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 EXT_L1_Pin GPIO_PIN_0 61 | #define EXT_L1_GPIO_Port GPIOC 62 | #define EXT_L2_Pin GPIO_PIN_1 63 | #define EXT_L2_GPIO_Port GPIOC 64 | #define EXT_R1_Pin GPIO_PIN_2 65 | #define EXT_R1_GPIO_Port GPIOC 66 | #define EXT_R2_Pin GPIO_PIN_3 67 | #define EXT_R2_GPIO_Port GPIOC 68 | #define EXT_R3_Pin GPIO_PIN_4 69 | #define EXT_R3_GPIO_Port GPIOC 70 | #define EXT_R4_Pin GPIO_PIN_5 71 | #define EXT_R4_GPIO_Port GPIOC 72 | #define EXT_L3_Pin GPIO_PIN_0 73 | #define EXT_L3_GPIO_Port GPIOB 74 | #define EXT_L4_Pin GPIO_PIN_1 75 | #define EXT_L4_GPIO_Port GPIOB 76 | #define LCD_DC_Pin GPIO_PIN_7 77 | #define LCD_DC_GPIO_Port GPIOC 78 | #define TOUCH_CS_Pin GPIO_PIN_9 79 | #define TOUCH_CS_GPIO_Port GPIOC 80 | #define LCD_CS_Pin GPIO_PIN_15 81 | #define LCD_CS_GPIO_Port GPIOA 82 | #define SPI_SCK_Pin GPIO_PIN_3 83 | #define SPI_SCK_GPIO_Port GPIOB 84 | #define SPI_MISO_Pin GPIO_PIN_4 85 | #define SPI_MISO_GPIO_Port GPIOB 86 | #define SPI_MOSI_Pin GPIO_PIN_5 87 | #define SPI_MOSI_GPIO_Port GPIOB 88 | #define T_IRQ_Pin GPIO_PIN_6 89 | #define T_IRQ_GPIO_Port GPIOB 90 | #define BUZZER_Pin GPIO_PIN_7 91 | #define BUZZER_GPIO_Port GPIOB 92 | 93 | /* USER CODE BEGIN Private defines */ 94 | 95 | /* USER CODE END Private defines */ 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /* __MAIN_H */ 102 | -------------------------------------------------------------------------------- /STM32F415APP/Core/Inc/rtc.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file rtc.h 5 | * @brief This file contains all the function prototypes for 6 | * the rtc.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __RTC_H__ 22 | #define __RTC_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | extern RTC_HandleTypeDef hrtc; 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_RTC_Init(void); 42 | 43 | /* USER CODE BEGIN Prototypes */ 44 | 45 | /* USER CODE END Prototypes */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __RTC_H__ */ 52 | 53 | -------------------------------------------------------------------------------- /STM32F415APP/Core/Inc/sdio.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file sdio.h 5 | * @brief This file contains all the function prototypes for 6 | * the sdio.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __SDIO_H__ 22 | #define __SDIO_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | extern SD_HandleTypeDef hsd; 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_SDIO_SD_Init(void); 42 | 43 | /* USER CODE BEGIN Prototypes */ 44 | 45 | /* USER CODE END Prototypes */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __SDIO_H__ */ 52 | 53 | -------------------------------------------------------------------------------- /STM32F415APP/Core/Inc/spi.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file spi.h 5 | * @brief This file contains all the function prototypes for 6 | * the spi.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __SPI_H__ 22 | #define __SPI_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | extern SPI_HandleTypeDef hspi1; 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_SPI1_Init(void); 42 | 43 | /* USER CODE BEGIN Prototypes */ 44 | 45 | /* USER CODE END Prototypes */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __SPI_H__ */ 52 | 53 | -------------------------------------------------------------------------------- /STM32F415APP/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) 2023 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 DebugMon_Handler(void); 55 | void SysTick_Handler(void); 56 | void SDIO_IRQHandler(void); 57 | void DMA2_Stream0_IRQHandler(void); 58 | void DMA2_Stream3_IRQHandler(void); 59 | void OTG_FS_IRQHandler(void); 60 | void DMA2_Stream5_IRQHandler(void); 61 | void DMA2_Stream6_IRQHandler(void); 62 | /* USER CODE BEGIN EFP */ 63 | 64 | /* USER CODE END EFP */ 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif /* __STM32F4xx_IT_H */ 71 | -------------------------------------------------------------------------------- /STM32F415APP/Core/Inc/tim.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file tim.h 5 | * @brief This file contains all the function prototypes for 6 | * the tim.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __TIM_H__ 22 | #define __TIM_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | extern TIM_HandleTypeDef htim4; 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_TIM4_Init(void); 42 | 43 | void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); 44 | 45 | /* USER CODE BEGIN Prototypes */ 46 | 47 | /* USER CODE END Prototypes */ 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif /* __TIM_H__ */ 54 | 55 | -------------------------------------------------------------------------------- /STM32F415APP/Core/Src/adc.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file adc.c 5 | * @brief This file provides code for the configuration 6 | * of the ADC instances. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 | /* Includes ------------------------------------------------------------------*/ 21 | #include "adc.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | ADC_HandleTypeDef hadc2; 28 | 29 | /* ADC2 init function */ 30 | void MX_ADC2_Init(void) 31 | { 32 | 33 | /* USER CODE BEGIN ADC2_Init 0 */ 34 | 35 | /* USER CODE END ADC2_Init 0 */ 36 | 37 | ADC_ChannelConfTypeDef sConfig = {0}; 38 | 39 | /* USER CODE BEGIN ADC2_Init 1 */ 40 | 41 | /* USER CODE END ADC2_Init 1 */ 42 | 43 | /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) 44 | */ 45 | hadc2.Instance = ADC2; 46 | hadc2.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4; 47 | hadc2.Init.Resolution = ADC_RESOLUTION_12B; 48 | hadc2.Init.ScanConvMode = DISABLE; 49 | hadc2.Init.ContinuousConvMode = DISABLE; 50 | hadc2.Init.DiscontinuousConvMode = DISABLE; 51 | hadc2.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; 52 | hadc2.Init.ExternalTrigConv = ADC_SOFTWARE_START; 53 | hadc2.Init.DataAlign = ADC_DATAALIGN_RIGHT; 54 | hadc2.Init.NbrOfConversion = 1; 55 | hadc2.Init.DMAContinuousRequests = DISABLE; 56 | hadc2.Init.EOCSelection = ADC_EOC_SINGLE_CONV; 57 | if (HAL_ADC_Init(&hadc2) != HAL_OK) 58 | { 59 | Error_Handler(); 60 | } 61 | 62 | /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. 63 | */ 64 | sConfig.Channel = ADC_CHANNEL_10; 65 | sConfig.Rank = 1; 66 | sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES; 67 | if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK) 68 | { 69 | Error_Handler(); 70 | } 71 | /* USER CODE BEGIN ADC2_Init 2 */ 72 | 73 | /* USER CODE END ADC2_Init 2 */ 74 | 75 | } 76 | 77 | void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle) 78 | { 79 | 80 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 81 | if(adcHandle->Instance==ADC2) 82 | { 83 | /* USER CODE BEGIN ADC2_MspInit 0 */ 84 | 85 | /* USER CODE END ADC2_MspInit 0 */ 86 | /* ADC2 clock enable */ 87 | __HAL_RCC_ADC2_CLK_ENABLE(); 88 | 89 | __HAL_RCC_GPIOC_CLK_ENABLE(); 90 | /**ADC2 GPIO Configuration 91 | PC0 ------> ADC2_IN10 92 | PC1 ------> ADC2_IN11 93 | PC2 ------> ADC2_IN12 94 | PC3 ------> ADC2_IN13 95 | */ 96 | GPIO_InitStruct.Pin = EXT_L1_Pin|EXT_L2_Pin|EXT_R1_Pin|EXT_R2_Pin; 97 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; 98 | GPIO_InitStruct.Pull = GPIO_NOPULL; 99 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); 100 | 101 | /* USER CODE BEGIN ADC2_MspInit 1 */ 102 | 103 | /* USER CODE END ADC2_MspInit 1 */ 104 | } 105 | } 106 | 107 | void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle) 108 | { 109 | 110 | if(adcHandle->Instance==ADC2) 111 | { 112 | /* USER CODE BEGIN ADC2_MspDeInit 0 */ 113 | 114 | /* USER CODE END ADC2_MspDeInit 0 */ 115 | /* Peripheral clock disable */ 116 | __HAL_RCC_ADC2_CLK_DISABLE(); 117 | 118 | /**ADC2 GPIO Configuration 119 | PC0 ------> ADC2_IN10 120 | PC1 ------> ADC2_IN11 121 | PC2 ------> ADC2_IN12 122 | PC3 ------> ADC2_IN13 123 | */ 124 | HAL_GPIO_DeInit(GPIOC, EXT_L1_Pin|EXT_L2_Pin|EXT_R1_Pin|EXT_R2_Pin); 125 | 126 | /* USER CODE BEGIN ADC2_MspDeInit 1 */ 127 | 128 | /* USER CODE END ADC2_MspDeInit 1 */ 129 | } 130 | } 131 | 132 | /* USER CODE BEGIN 1 */ 133 | 134 | /* USER CODE END 1 */ 135 | -------------------------------------------------------------------------------- /STM32F415APP/Core/Src/dma.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file dma.c 5 | * @brief This file provides code for the configuration 6 | * of all the requested memory to memory DMA transfers. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 "dma.h" 23 | 24 | /* USER CODE BEGIN 0 */ 25 | 26 | /* USER CODE END 0 */ 27 | 28 | /*----------------------------------------------------------------------------*/ 29 | /* Configure DMA */ 30 | /*----------------------------------------------------------------------------*/ 31 | 32 | /* USER CODE BEGIN 1 */ 33 | 34 | /* USER CODE END 1 */ 35 | 36 | /** 37 | * Enable DMA controller clock 38 | */ 39 | void MX_DMA_Init(void) 40 | { 41 | 42 | /* DMA controller clock enable */ 43 | __HAL_RCC_DMA2_CLK_ENABLE(); 44 | 45 | /* DMA interrupt init */ 46 | /* DMA2_Stream0_IRQn interrupt configuration */ 47 | HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 5, 0); 48 | HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn); 49 | /* DMA2_Stream3_IRQn interrupt configuration */ 50 | HAL_NVIC_SetPriority(DMA2_Stream3_IRQn, 5, 0); 51 | HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn); 52 | /* DMA2_Stream5_IRQn interrupt configuration */ 53 | HAL_NVIC_SetPriority(DMA2_Stream5_IRQn, 5, 0); 54 | HAL_NVIC_EnableIRQ(DMA2_Stream5_IRQn); 55 | /* DMA2_Stream6_IRQn interrupt configuration */ 56 | HAL_NVIC_SetPriority(DMA2_Stream6_IRQn, 5, 0); 57 | HAL_NVIC_EnableIRQ(DMA2_Stream6_IRQn); 58 | 59 | } 60 | 61 | /* USER CODE BEGIN 2 */ 62 | 63 | /* USER CODE END 2 */ 64 | 65 | -------------------------------------------------------------------------------- /STM32F415APP/Core/Src/freertos.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * File Name : freertos.c 5 | * Description : Code for freertos applications 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2023 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 "FreeRTOS.h" 22 | #include "task.h" 23 | #include "main.h" 24 | #include "cmsis_os.h" 25 | 26 | /* Private includes ----------------------------------------------------------*/ 27 | /* USER CODE BEGIN Includes */ 28 | 29 | /* USER CODE END Includes */ 30 | 31 | /* Private typedef -----------------------------------------------------------*/ 32 | /* USER CODE BEGIN PTD */ 33 | 34 | /* USER CODE END PTD */ 35 | 36 | /* Private define ------------------------------------------------------------*/ 37 | /* USER CODE BEGIN PD */ 38 | 39 | /* USER CODE END PD */ 40 | 41 | /* Private macro -------------------------------------------------------------*/ 42 | /* USER CODE BEGIN PM */ 43 | 44 | /* USER CODE END PM */ 45 | 46 | /* Private variables ---------------------------------------------------------*/ 47 | /* USER CODE BEGIN Variables */ 48 | 49 | /* USER CODE END Variables */ 50 | osThreadId defaultTaskHandle; 51 | 52 | /* Private function prototypes -----------------------------------------------*/ 53 | /* USER CODE BEGIN FunctionPrototypes */ 54 | 55 | /* USER CODE END FunctionPrototypes */ 56 | 57 | void StartDefaultTask(void const * argument); 58 | 59 | extern void MX_USB_DEVICE_Init(void); 60 | void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */ 61 | 62 | /* Hook prototypes */ 63 | void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName); 64 | void vApplicationMallocFailedHook(void); 65 | 66 | /* USER CODE BEGIN 4 */ 67 | __weak void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName) 68 | { 69 | /* Run time stack overflow checking is performed if 70 | configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is 71 | called if a stack overflow is detected. */ 72 | } 73 | /* USER CODE END 4 */ 74 | 75 | /* USER CODE BEGIN 5 */ 76 | __weak void vApplicationMallocFailedHook(void) 77 | { 78 | /* vApplicationMallocFailedHook() will only be called if 79 | configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook 80 | function that will get called if a call to pvPortMalloc() fails. 81 | pvPortMalloc() is called internally by the kernel whenever a task, queue, 82 | timer or semaphore is created. It is also called by various parts of the 83 | demo application. If heap_1.c or heap_2.c are used, then the size of the 84 | heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in 85 | FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used 86 | to query the size of free heap space that remains (although it does not 87 | provide information on how the remaining heap might be fragmented). */ 88 | } 89 | /* USER CODE END 5 */ 90 | 91 | /** 92 | * @brief FreeRTOS initialization 93 | * @param None 94 | * @retval None 95 | */ 96 | void MX_FREERTOS_Init(void) { 97 | /* USER CODE BEGIN Init */ 98 | 99 | /* USER CODE END Init */ 100 | 101 | /* USER CODE BEGIN RTOS_MUTEX */ 102 | /* add mutexes, ... */ 103 | /* USER CODE END RTOS_MUTEX */ 104 | 105 | /* USER CODE BEGIN RTOS_SEMAPHORES */ 106 | /* add semaphores, ... */ 107 | /* USER CODE END RTOS_SEMAPHORES */ 108 | 109 | /* USER CODE BEGIN RTOS_TIMERS */ 110 | /* start timers, add new ones, ... */ 111 | /* USER CODE END RTOS_TIMERS */ 112 | 113 | /* USER CODE BEGIN RTOS_QUEUES */ 114 | /* add queues, ... */ 115 | /* USER CODE END RTOS_QUEUES */ 116 | 117 | /* Create the thread(s) */ 118 | /* definition and creation of defaultTask */ 119 | osThreadDef(defaultTask, StartDefaultTask, osPriorityRealtime, 0, 128); 120 | defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL); 121 | 122 | /* USER CODE BEGIN RTOS_THREADS */ 123 | /* add threads, ... */ 124 | /* USER CODE END RTOS_THREADS */ 125 | 126 | } 127 | 128 | /* USER CODE BEGIN Header_StartDefaultTask */ 129 | /** 130 | * @brief Function implementing the defaultTask thread. 131 | * @param argument: Not used 132 | * @retval None 133 | */ 134 | /* USER CODE END Header_StartDefaultTask */ 135 | void StartDefaultTask(void const * argument) 136 | { 137 | /* init code for USB_DEVICE */ 138 | MX_USB_DEVICE_Init(); 139 | /* USER CODE BEGIN StartDefaultTask */ 140 | /* Infinite loop */ 141 | for(;;) 142 | { 143 | osDelay(1); 144 | } 145 | /* USER CODE END StartDefaultTask */ 146 | } 147 | 148 | /* Private application code --------------------------------------------------*/ 149 | /* USER CODE BEGIN Application */ 150 | 151 | /* USER CODE END Application */ 152 | -------------------------------------------------------------------------------- /STM32F415APP/Core/Src/gpio.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.c 5 | * @brief This file provides code for the configuration 6 | * of all used GPIO pins. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 "gpio.h" 23 | 24 | /* USER CODE BEGIN 0 */ 25 | 26 | /* USER CODE END 0 */ 27 | 28 | /*----------------------------------------------------------------------------*/ 29 | /* Configure GPIO */ 30 | /*----------------------------------------------------------------------------*/ 31 | /* USER CODE BEGIN 1 */ 32 | 33 | /* USER CODE END 1 */ 34 | 35 | /** Configure pins as 36 | * Analog 37 | * Input 38 | * Output 39 | * EVENT_OUT 40 | * EXTI 41 | */ 42 | void MX_GPIO_Init(void) 43 | { 44 | 45 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 46 | 47 | /* GPIO Ports Clock Enable */ 48 | __HAL_RCC_GPIOC_CLK_ENABLE(); 49 | __HAL_RCC_GPIOH_CLK_ENABLE(); 50 | __HAL_RCC_GPIOB_CLK_ENABLE(); 51 | __HAL_RCC_GPIOA_CLK_ENABLE(); 52 | __HAL_RCC_GPIOD_CLK_ENABLE(); 53 | 54 | /*Configure GPIO pin Output Level */ 55 | HAL_GPIO_WritePin(GPIOC, LCD_DC_Pin|TOUCH_CS_Pin, GPIO_PIN_RESET); 56 | 57 | /*Configure GPIO pin Output Level */ 58 | HAL_GPIO_WritePin(LCD_CS_GPIO_Port, LCD_CS_Pin, GPIO_PIN_RESET); 59 | 60 | /*Configure GPIO pins : EXT_R3_Pin EXT_R4_Pin */ 61 | GPIO_InitStruct.Pin = EXT_R3_Pin|EXT_R4_Pin; 62 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 63 | GPIO_InitStruct.Pull = GPIO_NOPULL; 64 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); 65 | 66 | /*Configure GPIO pins : EXT_L3_Pin EXT_L4_Pin T_IRQ_Pin */ 67 | GPIO_InitStruct.Pin = EXT_L3_Pin|EXT_L4_Pin|T_IRQ_Pin; 68 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 69 | GPIO_InitStruct.Pull = GPIO_NOPULL; 70 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 71 | 72 | /*Configure GPIO pins : LCD_DC_Pin TOUCH_CS_Pin */ 73 | GPIO_InitStruct.Pin = LCD_DC_Pin|TOUCH_CS_Pin; 74 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 75 | GPIO_InitStruct.Pull = GPIO_NOPULL; 76 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 77 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); 78 | 79 | /*Configure GPIO pin : LCD_CS_Pin */ 80 | GPIO_InitStruct.Pin = LCD_CS_Pin; 81 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 82 | GPIO_InitStruct.Pull = GPIO_NOPULL; 83 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 84 | HAL_GPIO_Init(LCD_CS_GPIO_Port, &GPIO_InitStruct); 85 | 86 | } 87 | 88 | /* USER CODE BEGIN 2 */ 89 | 90 | /* USER CODE END 2 */ 91 | -------------------------------------------------------------------------------- /STM32F415APP/Core/Src/i2c.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file i2c.c 5 | * @brief This file provides code for the configuration 6 | * of the I2C instances. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 | /* Includes ------------------------------------------------------------------*/ 21 | #include "i2c.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | I2C_HandleTypeDef hi2c1; 28 | 29 | /* I2C1 init function */ 30 | void MX_I2C1_Init(void) 31 | { 32 | 33 | /* USER CODE BEGIN I2C1_Init 0 */ 34 | 35 | /* USER CODE END I2C1_Init 0 */ 36 | 37 | /* USER CODE BEGIN I2C1_Init 1 */ 38 | 39 | /* USER CODE END I2C1_Init 1 */ 40 | hi2c1.Instance = I2C1; 41 | hi2c1.Init.ClockSpeed = 100000; 42 | hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2; 43 | hi2c1.Init.OwnAddress1 = 0; 44 | hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; 45 | hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; 46 | hi2c1.Init.OwnAddress2 = 0; 47 | hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; 48 | hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; 49 | if (HAL_I2C_Init(&hi2c1) != HAL_OK) 50 | { 51 | Error_Handler(); 52 | } 53 | /* USER CODE BEGIN I2C1_Init 2 */ 54 | 55 | /* USER CODE END I2C1_Init 2 */ 56 | 57 | } 58 | 59 | void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle) 60 | { 61 | 62 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 63 | if(i2cHandle->Instance==I2C1) 64 | { 65 | /* USER CODE BEGIN I2C1_MspInit 0 */ 66 | 67 | /* USER CODE END I2C1_MspInit 0 */ 68 | 69 | __HAL_RCC_GPIOB_CLK_ENABLE(); 70 | /**I2C1 GPIO Configuration 71 | PB8 ------> I2C1_SCL 72 | PB9 ------> I2C1_SDA 73 | */ 74 | GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9; 75 | GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; 76 | GPIO_InitStruct.Pull = GPIO_PULLUP; 77 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 78 | GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; 79 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 80 | 81 | /* I2C1 clock enable */ 82 | __HAL_RCC_I2C1_CLK_ENABLE(); 83 | /* USER CODE BEGIN I2C1_MspInit 1 */ 84 | 85 | /* USER CODE END I2C1_MspInit 1 */ 86 | } 87 | } 88 | 89 | void HAL_I2C_MspDeInit(I2C_HandleTypeDef* i2cHandle) 90 | { 91 | 92 | if(i2cHandle->Instance==I2C1) 93 | { 94 | /* USER CODE BEGIN I2C1_MspDeInit 0 */ 95 | 96 | /* USER CODE END I2C1_MspDeInit 0 */ 97 | /* Peripheral clock disable */ 98 | __HAL_RCC_I2C1_CLK_DISABLE(); 99 | 100 | /**I2C1 GPIO Configuration 101 | PB8 ------> I2C1_SCL 102 | PB9 ------> I2C1_SDA 103 | */ 104 | HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8); 105 | 106 | HAL_GPIO_DeInit(GPIOB, GPIO_PIN_9); 107 | 108 | /* USER CODE BEGIN I2C1_MspDeInit 1 */ 109 | 110 | /* USER CODE END I2C1_MspDeInit 1 */ 111 | } 112 | } 113 | 114 | /* USER CODE BEGIN 1 */ 115 | 116 | /* USER CODE END 1 */ 117 | -------------------------------------------------------------------------------- /STM32F415APP/Core/Src/rtc.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file rtc.c 5 | * @brief This file provides code for the configuration 6 | * of the RTC instances. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 | /* Includes ------------------------------------------------------------------*/ 21 | #include "rtc.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | RTC_HandleTypeDef hrtc; 28 | 29 | /* RTC init function */ 30 | void MX_RTC_Init(void) 31 | { 32 | 33 | /* USER CODE BEGIN RTC_Init 0 */ 34 | 35 | /* USER CODE END RTC_Init 0 */ 36 | 37 | /* USER CODE BEGIN RTC_Init 1 */ 38 | 39 | /* USER CODE END RTC_Init 1 */ 40 | 41 | /** Initialize RTC Only 42 | */ 43 | hrtc.Instance = RTC; 44 | hrtc.Init.HourFormat = RTC_HOURFORMAT_24; 45 | hrtc.Init.AsynchPrediv = 127; 46 | hrtc.Init.SynchPrediv = 255; 47 | hrtc.Init.OutPut = RTC_OUTPUT_DISABLE; 48 | hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; 49 | hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; 50 | if (HAL_RTC_Init(&hrtc) != HAL_OK) 51 | { 52 | Error_Handler(); 53 | } 54 | /* USER CODE BEGIN RTC_Init 2 */ 55 | 56 | /* USER CODE END RTC_Init 2 */ 57 | 58 | } 59 | 60 | void HAL_RTC_MspInit(RTC_HandleTypeDef* rtcHandle) 61 | { 62 | 63 | RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; 64 | if(rtcHandle->Instance==RTC) 65 | { 66 | /* USER CODE BEGIN RTC_MspInit 0 */ 67 | 68 | /* USER CODE END RTC_MspInit 0 */ 69 | 70 | /** Initializes the peripherals clock 71 | */ 72 | PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC; 73 | PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; 74 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) 75 | { 76 | Error_Handler(); 77 | } 78 | 79 | /* RTC clock enable */ 80 | __HAL_RCC_RTC_ENABLE(); 81 | /* USER CODE BEGIN RTC_MspInit 1 */ 82 | 83 | /* USER CODE END RTC_MspInit 1 */ 84 | } 85 | } 86 | 87 | void HAL_RTC_MspDeInit(RTC_HandleTypeDef* rtcHandle) 88 | { 89 | 90 | if(rtcHandle->Instance==RTC) 91 | { 92 | /* USER CODE BEGIN RTC_MspDeInit 0 */ 93 | 94 | /* USER CODE END RTC_MspDeInit 0 */ 95 | /* Peripheral clock disable */ 96 | __HAL_RCC_RTC_DISABLE(); 97 | /* USER CODE BEGIN RTC_MspDeInit 1 */ 98 | 99 | /* USER CODE END RTC_MspDeInit 1 */ 100 | } 101 | } 102 | 103 | /* USER CODE BEGIN 1 */ 104 | 105 | /* USER CODE END 1 */ 106 | -------------------------------------------------------------------------------- /STM32F415APP/Core/Src/spi.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file spi.c 5 | * @brief This file provides code for the configuration 6 | * of the SPI instances. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 | /* Includes ------------------------------------------------------------------*/ 21 | #include "spi.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | SPI_HandleTypeDef hspi1; 28 | DMA_HandleTypeDef hdma_spi1_rx; 29 | DMA_HandleTypeDef hdma_spi1_tx; 30 | 31 | /* SPI1 init function */ 32 | void MX_SPI1_Init(void) 33 | { 34 | 35 | /* USER CODE BEGIN SPI1_Init 0 */ 36 | 37 | /* USER CODE END SPI1_Init 0 */ 38 | 39 | /* USER CODE BEGIN SPI1_Init 1 */ 40 | 41 | /* USER CODE END SPI1_Init 1 */ 42 | hspi1.Instance = SPI1; 43 | hspi1.Init.Mode = SPI_MODE_MASTER; 44 | hspi1.Init.Direction = SPI_DIRECTION_2LINES; 45 | hspi1.Init.DataSize = SPI_DATASIZE_8BIT; 46 | hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; 47 | hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; 48 | hspi1.Init.NSS = SPI_NSS_SOFT; 49 | hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; 50 | hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; 51 | hspi1.Init.TIMode = SPI_TIMODE_DISABLE; 52 | hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; 53 | hspi1.Init.CRCPolynomial = 10; 54 | if (HAL_SPI_Init(&hspi1) != HAL_OK) 55 | { 56 | Error_Handler(); 57 | } 58 | /* USER CODE BEGIN SPI1_Init 2 */ 59 | 60 | /* USER CODE END SPI1_Init 2 */ 61 | 62 | } 63 | 64 | void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle) 65 | { 66 | 67 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 68 | if(spiHandle->Instance==SPI1) 69 | { 70 | /* USER CODE BEGIN SPI1_MspInit 0 */ 71 | 72 | /* USER CODE END SPI1_MspInit 0 */ 73 | /* SPI1 clock enable */ 74 | __HAL_RCC_SPI1_CLK_ENABLE(); 75 | 76 | __HAL_RCC_GPIOB_CLK_ENABLE(); 77 | /**SPI1 GPIO Configuration 78 | PB3 ------> SPI1_SCK 79 | PB4 ------> SPI1_MISO 80 | PB5 ------> SPI1_MOSI 81 | */ 82 | GPIO_InitStruct.Pin = SPI_SCK_Pin|SPI_MISO_Pin|SPI_MOSI_Pin; 83 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 84 | GPIO_InitStruct.Pull = GPIO_NOPULL; 85 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 86 | GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; 87 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 88 | 89 | /* SPI1 DMA Init */ 90 | /* SPI1_RX Init */ 91 | hdma_spi1_rx.Instance = DMA2_Stream0; 92 | hdma_spi1_rx.Init.Channel = DMA_CHANNEL_3; 93 | hdma_spi1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; 94 | hdma_spi1_rx.Init.PeriphInc = DMA_PINC_DISABLE; 95 | hdma_spi1_rx.Init.MemInc = DMA_MINC_ENABLE; 96 | hdma_spi1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; 97 | hdma_spi1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; 98 | hdma_spi1_rx.Init.Mode = DMA_NORMAL; 99 | hdma_spi1_rx.Init.Priority = DMA_PRIORITY_MEDIUM; 100 | hdma_spi1_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; 101 | if (HAL_DMA_Init(&hdma_spi1_rx) != HAL_OK) 102 | { 103 | Error_Handler(); 104 | } 105 | 106 | __HAL_LINKDMA(spiHandle,hdmarx,hdma_spi1_rx); 107 | 108 | /* SPI1_TX Init */ 109 | hdma_spi1_tx.Instance = DMA2_Stream5; 110 | hdma_spi1_tx.Init.Channel = DMA_CHANNEL_3; 111 | hdma_spi1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; 112 | hdma_spi1_tx.Init.PeriphInc = DMA_PINC_DISABLE; 113 | hdma_spi1_tx.Init.MemInc = DMA_MINC_ENABLE; 114 | hdma_spi1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; 115 | hdma_spi1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; 116 | hdma_spi1_tx.Init.Mode = DMA_NORMAL; 117 | hdma_spi1_tx.Init.Priority = DMA_PRIORITY_HIGH; 118 | hdma_spi1_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; 119 | if (HAL_DMA_Init(&hdma_spi1_tx) != HAL_OK) 120 | { 121 | Error_Handler(); 122 | } 123 | 124 | __HAL_LINKDMA(spiHandle,hdmatx,hdma_spi1_tx); 125 | 126 | /* USER CODE BEGIN SPI1_MspInit 1 */ 127 | 128 | /* USER CODE END SPI1_MspInit 1 */ 129 | } 130 | } 131 | 132 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle) 133 | { 134 | 135 | if(spiHandle->Instance==SPI1) 136 | { 137 | /* USER CODE BEGIN SPI1_MspDeInit 0 */ 138 | 139 | /* USER CODE END SPI1_MspDeInit 0 */ 140 | /* Peripheral clock disable */ 141 | __HAL_RCC_SPI1_CLK_DISABLE(); 142 | 143 | /**SPI1 GPIO Configuration 144 | PB3 ------> SPI1_SCK 145 | PB4 ------> SPI1_MISO 146 | PB5 ------> SPI1_MOSI 147 | */ 148 | HAL_GPIO_DeInit(GPIOB, SPI_SCK_Pin|SPI_MISO_Pin|SPI_MOSI_Pin); 149 | 150 | /* SPI1 DMA DeInit */ 151 | HAL_DMA_DeInit(spiHandle->hdmarx); 152 | HAL_DMA_DeInit(spiHandle->hdmatx); 153 | /* USER CODE BEGIN SPI1_MspDeInit 1 */ 154 | 155 | /* USER CODE END SPI1_MspDeInit 1 */ 156 | } 157 | } 158 | 159 | /* USER CODE BEGIN 1 */ 160 | 161 | /* USER CODE END 1 */ 162 | -------------------------------------------------------------------------------- /STM32F415APP/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) 2023 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 | 66 | /* USER CODE BEGIN MspInit 0 */ 67 | 68 | /* USER CODE END MspInit 0 */ 69 | 70 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 71 | __HAL_RCC_PWR_CLK_ENABLE(); 72 | 73 | /* System interrupt init*/ 74 | /* PendSV_IRQn interrupt configuration */ 75 | HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); 76 | 77 | /* USER CODE BEGIN MspInit 1 */ 78 | 79 | /* USER CODE END MspInit 1 */ 80 | } 81 | 82 | /* USER CODE BEGIN 1 */ 83 | 84 | /* USER CODE END 1 */ 85 | -------------------------------------------------------------------------------- /STM32F415APP/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) 2020-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 | (void)pid; 56 | (void)sig; 57 | errno = EINVAL; 58 | return -1; 59 | } 60 | 61 | void _exit (int status) 62 | { 63 | _kill(status, -1); 64 | while (1) {} /* Make sure we hang here */ 65 | } 66 | 67 | __attribute__((weak)) int _read(int file, char *ptr, int len) 68 | { 69 | (void)file; 70 | int DataIdx; 71 | 72 | for (DataIdx = 0; DataIdx < len; DataIdx++) 73 | { 74 | *ptr++ = __io_getchar(); 75 | } 76 | 77 | return len; 78 | } 79 | 80 | __attribute__((weak)) int _write(int file, char *ptr, int len) 81 | { 82 | (void)file; 83 | int DataIdx; 84 | 85 | for (DataIdx = 0; DataIdx < len; DataIdx++) 86 | { 87 | __io_putchar(*ptr++); 88 | } 89 | return len; 90 | } 91 | 92 | int _close(int file) 93 | { 94 | (void)file; 95 | return -1; 96 | } 97 | 98 | 99 | int _fstat(int file, struct stat *st) 100 | { 101 | (void)file; 102 | st->st_mode = S_IFCHR; 103 | return 0; 104 | } 105 | 106 | int _isatty(int file) 107 | { 108 | (void)file; 109 | return 1; 110 | } 111 | 112 | int _lseek(int file, int ptr, int dir) 113 | { 114 | (void)file; 115 | (void)ptr; 116 | (void)dir; 117 | return 0; 118 | } 119 | 120 | int _open(char *path, int flags, ...) 121 | { 122 | (void)path; 123 | (void)flags; 124 | /* Pretend like we always fail */ 125 | return -1; 126 | } 127 | 128 | int _wait(int *status) 129 | { 130 | (void)status; 131 | errno = ECHILD; 132 | return -1; 133 | } 134 | 135 | int _unlink(char *name) 136 | { 137 | (void)name; 138 | errno = ENOENT; 139 | return -1; 140 | } 141 | 142 | int _times(struct tms *buf) 143 | { 144 | (void)buf; 145 | return -1; 146 | } 147 | 148 | int _stat(char *file, struct stat *st) 149 | { 150 | (void)file; 151 | st->st_mode = S_IFCHR; 152 | return 0; 153 | } 154 | 155 | int _link(char *old, char *new) 156 | { 157 | (void)old; 158 | (void)new; 159 | errno = EMLINK; 160 | return -1; 161 | } 162 | 163 | int _fork(void) 164 | { 165 | errno = EAGAIN; 166 | return -1; 167 | } 168 | 169 | int _execve(char *name, char **argv, char **env) 170 | { 171 | (void)name; 172 | (void)argv; 173 | (void)env; 174 | errno = ENOMEM; 175 | return -1; 176 | } 177 | -------------------------------------------------------------------------------- /STM32F415APP/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 | -------------------------------------------------------------------------------- /STM32F415APP/Core/Src/tim.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file tim.c 5 | * @brief This file provides code for the configuration 6 | * of the TIM instances. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 | /* Includes ------------------------------------------------------------------*/ 21 | #include "tim.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | TIM_HandleTypeDef htim4; 28 | 29 | /* TIM4 init function */ 30 | void MX_TIM4_Init(void) 31 | { 32 | 33 | /* USER CODE BEGIN TIM4_Init 0 */ 34 | 35 | /* USER CODE END TIM4_Init 0 */ 36 | 37 | TIM_MasterConfigTypeDef sMasterConfig = {0}; 38 | TIM_OC_InitTypeDef sConfigOC = {0}; 39 | 40 | /* USER CODE BEGIN TIM4_Init 1 */ 41 | 42 | /* USER CODE END TIM4_Init 1 */ 43 | htim4.Instance = TIM4; 44 | htim4.Init.Prescaler = 0; 45 | htim4.Init.CounterMode = TIM_COUNTERMODE_UP; 46 | htim4.Init.Period = 50; 47 | htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; 48 | htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; 49 | if (HAL_TIM_OC_Init(&htim4) != HAL_OK) 50 | { 51 | Error_Handler(); 52 | } 53 | sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; 54 | sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; 55 | if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK) 56 | { 57 | Error_Handler(); 58 | } 59 | sConfigOC.OCMode = TIM_OCMODE_TOGGLE; 60 | sConfigOC.Pulse = 0; 61 | sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; 62 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; 63 | if (HAL_TIM_OC_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) 64 | { 65 | Error_Handler(); 66 | } 67 | /* USER CODE BEGIN TIM4_Init 2 */ 68 | 69 | /* USER CODE END TIM4_Init 2 */ 70 | HAL_TIM_MspPostInit(&htim4); 71 | 72 | } 73 | 74 | void HAL_TIM_OC_MspInit(TIM_HandleTypeDef* tim_ocHandle) 75 | { 76 | 77 | if(tim_ocHandle->Instance==TIM4) 78 | { 79 | /* USER CODE BEGIN TIM4_MspInit 0 */ 80 | 81 | /* USER CODE END TIM4_MspInit 0 */ 82 | /* TIM4 clock enable */ 83 | __HAL_RCC_TIM4_CLK_ENABLE(); 84 | /* USER CODE BEGIN TIM4_MspInit 1 */ 85 | 86 | /* USER CODE END TIM4_MspInit 1 */ 87 | } 88 | } 89 | void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle) 90 | { 91 | 92 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 93 | if(timHandle->Instance==TIM4) 94 | { 95 | /* USER CODE BEGIN TIM4_MspPostInit 0 */ 96 | 97 | /* USER CODE END TIM4_MspPostInit 0 */ 98 | 99 | __HAL_RCC_GPIOB_CLK_ENABLE(); 100 | /**TIM4 GPIO Configuration 101 | PB7 ------> TIM4_CH2 102 | */ 103 | GPIO_InitStruct.Pin = BUZZER_Pin; 104 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 105 | GPIO_InitStruct.Pull = GPIO_NOPULL; 106 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 107 | GPIO_InitStruct.Alternate = GPIO_AF2_TIM4; 108 | HAL_GPIO_Init(BUZZER_GPIO_Port, &GPIO_InitStruct); 109 | 110 | /* USER CODE BEGIN TIM4_MspPostInit 1 */ 111 | 112 | /* USER CODE END TIM4_MspPostInit 1 */ 113 | } 114 | 115 | } 116 | 117 | void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* tim_ocHandle) 118 | { 119 | 120 | if(tim_ocHandle->Instance==TIM4) 121 | { 122 | /* USER CODE BEGIN TIM4_MspDeInit 0 */ 123 | 124 | /* USER CODE END TIM4_MspDeInit 0 */ 125 | /* Peripheral clock disable */ 126 | __HAL_RCC_TIM4_CLK_DISABLE(); 127 | /* USER CODE BEGIN TIM4_MspDeInit 1 */ 128 | 129 | /* USER CODE END TIM4_MspDeInit 1 */ 130 | } 131 | } 132 | 133 | /* USER CODE BEGIN 1 */ 134 | 135 | /* USER CODE END 1 */ 136 | -------------------------------------------------------------------------------- /STM32F415APP/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 | -------------------------------------------------------------------------------- /STM32F415APP/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 | -------------------------------------------------------------------------------- /STM32F415APP/Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.5 5 | * @date 02. February 2022 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2022 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 ( 6U) /*!< [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 | -------------------------------------------------------------------------------- /STM32F415APP/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 | -------------------------------------------------------------------------------- /STM32F415APP/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 | -------------------------------------------------------------------------------- /STM32F415APP/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 | -------------------------------------------------------------------------------- /STM32F415APP/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 | -------------------------------------------------------------------------------- /STM32F415APP/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 | #if defined (USB_OTG_FS) || defined (USB_OTG_HS) 49 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size); 50 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size); 51 | #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */ 52 | 53 | #if defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) \ 54 | || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) \ 55 | || defined(STM32F423xx) 56 | HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd); 57 | HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd); 58 | #endif /* defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || 59 | defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || 60 | defined(STM32F423xx) */ 61 | #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) \ 62 | || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) 63 | HAL_StatusTypeDef HAL_PCDEx_ActivateBCD(PCD_HandleTypeDef *hpcd); 64 | HAL_StatusTypeDef HAL_PCDEx_DeActivateBCD(PCD_HandleTypeDef *hpcd); 65 | void HAL_PCDEx_BCD_VBUSDetect(PCD_HandleTypeDef *hpcd); 66 | #endif /* defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || 67 | defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) */ 68 | void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg); 69 | void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg); 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** 76 | * @} 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** 84 | * @} 85 | */ 86 | #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */ 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif /* __cplusplus */ 91 | 92 | 93 | #endif /* STM32F4xx_HAL_PCD_EX_H */ 94 | -------------------------------------------------------------------------------- /STM32F415APP/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 | -------------------------------------------------------------------------------- /STM32F415APP/FATFS/App/fatfs.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file fatfs.c 5 | * @brief Code for fatfs applications 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2023 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 | #include "fatfs.h" 20 | 21 | uint8_t retSD; /* Return value for SD */ 22 | char SDPath[4]; /* SD logical drive path */ 23 | FATFS SDFatFS; /* File system object for SD logical drive */ 24 | FIL SDFile; /* File object for SD */ 25 | 26 | /* USER CODE BEGIN Variables */ 27 | 28 | /* USER CODE END Variables */ 29 | 30 | void MX_FATFS_Init(void) 31 | { 32 | /*## FatFS: Link the SD driver ###########################*/ 33 | retSD = FATFS_LinkDriver(&SD_Driver, SDPath); 34 | 35 | /* USER CODE BEGIN Init */ 36 | /* additional user code for init */ 37 | /* USER CODE END Init */ 38 | } 39 | 40 | /** 41 | * @brief Gets Time from RTC 42 | * @param None 43 | * @retval Time in DWORD 44 | */ 45 | DWORD get_fattime(void) 46 | { 47 | /* USER CODE BEGIN get_fattime */ 48 | return 0; 49 | /* USER CODE END get_fattime */ 50 | } 51 | 52 | /* USER CODE BEGIN Application */ 53 | 54 | /* USER CODE END Application */ 55 | -------------------------------------------------------------------------------- /STM32F415APP/FATFS/App/fatfs.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file fatfs.h 5 | * @brief Header for fatfs applications 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2023 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 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __fatfs_H 21 | #define __fatfs_H 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | #include "ff.h" 27 | #include "ff_gen_drv.h" 28 | #include "sd_diskio.h" /* defines SD_Driver as external */ 29 | 30 | /* USER CODE BEGIN Includes */ 31 | 32 | /* USER CODE END Includes */ 33 | 34 | extern uint8_t retSD; /* Return value for SD */ 35 | extern char SDPath[4]; /* SD logical drive path */ 36 | extern FATFS SDFatFS; /* File system object for SD logical drive */ 37 | extern FIL SDFile; /* File object for SD */ 38 | 39 | void MX_FATFS_Init(void); 40 | 41 | /* USER CODE BEGIN Prototypes */ 42 | 43 | /* USER CODE END Prototypes */ 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | #endif /*__fatfs_H */ 48 | -------------------------------------------------------------------------------- /STM32F415APP/FATFS/Target/bsp_driver_sd.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file bsp_driver_sd.h for F4 (based on stm324x9i_eval_sd.h) 5 | * @brief This file contains the common defines and functions prototypes for 6 | * the bsp_driver_sd.c driver. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32F4_SD_H 22 | #define __STM32F4_SD_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f4xx_hal.h" 30 | 31 | /* Exported types --------------------------------------------------------*/ 32 | /** 33 | * @brief SD Card information structure 34 | */ 35 | #define BSP_SD_CardInfo HAL_SD_CardInfoTypeDef 36 | 37 | /* Exported constants --------------------------------------------------------*/ 38 | /** 39 | * @brief SD status structure definition 40 | */ 41 | #define MSD_OK ((uint8_t)0x00) 42 | #define MSD_ERROR ((uint8_t)0x01) 43 | 44 | /** 45 | * @brief SD transfer state definition 46 | */ 47 | #define SD_TRANSFER_OK ((uint8_t)0x00) 48 | #define SD_TRANSFER_BUSY ((uint8_t)0x01) 49 | 50 | #define SD_PRESENT ((uint8_t)0x01) 51 | #define SD_NOT_PRESENT ((uint8_t)0x00) 52 | #define SD_DATATIMEOUT ((uint32_t)100000000) 53 | 54 | #ifdef OLD_API 55 | /* kept to avoid issue when migrating old projects. */ 56 | /* USER CODE BEGIN 0 */ 57 | 58 | /* USER CODE END 0 */ 59 | #else 60 | /* USER CODE BEGIN BSP_H_CODE */ 61 | /* Exported functions --------------------------------------------------------*/ 62 | uint8_t BSP_SD_Init(void); 63 | uint8_t BSP_SD_ITConfig(void); 64 | void BSP_SD_DetectIT(void); 65 | void BSP_SD_DetectCallback(void); 66 | uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout); 67 | uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout); 68 | uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks); 69 | uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks); 70 | uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr); 71 | void BSP_SD_IRQHandler(void); 72 | void BSP_SD_DMA_Tx_IRQHandler(void); 73 | void BSP_SD_DMA_Rx_IRQHandler(void); 74 | uint8_t BSP_SD_GetCardState(void); 75 | void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo); 76 | uint8_t BSP_SD_IsDetected(void); 77 | 78 | /* These functions can be modified in case the current settings (e.g. DMA stream) 79 | need to be changed for specific application needs */ 80 | void BSP_SD_AbortCallback(void); 81 | void BSP_SD_WriteCpltCallback(void); 82 | void BSP_SD_ReadCpltCallback(void); 83 | /* USER CODE END BSP_H_CODE */ 84 | #endif 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /* __STM32F4_SD_H */ 91 | -------------------------------------------------------------------------------- /STM32F415APP/FATFS/Target/sd_diskio.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file sd_diskio.h 5 | * @brief Header for sd_diskio.c module 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2023 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 | /* Note: code generation based on sd_diskio_dma_rtos_template.h */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __SD_DISKIO_H 24 | #define __SD_DISKIO_H 25 | 26 | /* USER CODE BEGIN firstSection */ 27 | /* can be used to modify / undefine following code or add new definitions */ 28 | /* USER CODE END firstSection */ 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "bsp_driver_sd.h" 32 | /* Exported types ------------------------------------------------------------*/ 33 | /* Exported constants --------------------------------------------------------*/ 34 | /* Exported functions ------------------------------------------------------- */ 35 | extern const Diskio_drvTypeDef SD_Driver; 36 | 37 | /* USER CODE BEGIN lastSection */ 38 | /* can be used to modify / undefine previous code or add new definitions */ 39 | /* USER CODE END lastSection */ 40 | 41 | #endif /* __SD_DISKIO_H */ 42 | -------------------------------------------------------------------------------- /STM32F415APP/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc/usbd_cdc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_cdc.h 4 | * @author MCD Application Team 5 | * @brief header file for the usbd_cdc.c file. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2015 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 __USB_CDC_H 21 | #define __USB_CDC_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "usbd_ioreq.h" 29 | 30 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 31 | * @{ 32 | */ 33 | 34 | /** @defgroup usbd_cdc 35 | * @brief This file is the Header file for usbd_cdc.c 36 | * @{ 37 | */ 38 | 39 | 40 | /** @defgroup usbd_cdc_Exported_Defines 41 | * @{ 42 | */ 43 | #ifndef CDC_IN_EP 44 | #define CDC_IN_EP 0x81U /* EP1 for data IN */ 45 | #endif /* CDC_IN_EP */ 46 | #ifndef CDC_OUT_EP 47 | #define CDC_OUT_EP 0x01U /* EP1 for data OUT */ 48 | #endif /* CDC_OUT_EP */ 49 | #ifndef CDC_CMD_EP 50 | #define CDC_CMD_EP 0x82U /* EP2 for CDC commands */ 51 | #endif /* CDC_CMD_EP */ 52 | 53 | #ifndef CDC_HS_BINTERVAL 54 | #define CDC_HS_BINTERVAL 0x10U 55 | #endif /* CDC_HS_BINTERVAL */ 56 | 57 | #ifndef CDC_FS_BINTERVAL 58 | #define CDC_FS_BINTERVAL 0x10U 59 | #endif /* CDC_FS_BINTERVAL */ 60 | 61 | /* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */ 62 | #define CDC_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */ 63 | #define CDC_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */ 64 | #define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */ 65 | 66 | #define USB_CDC_CONFIG_DESC_SIZ 67U 67 | #define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE 68 | #define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE 69 | 70 | #define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE 71 | #define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE 72 | 73 | #define CDC_REQ_MAX_DATA_SIZE 0x7U 74 | /*---------------------------------------------------------------------*/ 75 | /* CDC definitions */ 76 | /*---------------------------------------------------------------------*/ 77 | #define CDC_SEND_ENCAPSULATED_COMMAND 0x00U 78 | #define CDC_GET_ENCAPSULATED_RESPONSE 0x01U 79 | #define CDC_SET_COMM_FEATURE 0x02U 80 | #define CDC_GET_COMM_FEATURE 0x03U 81 | #define CDC_CLEAR_COMM_FEATURE 0x04U 82 | #define CDC_SET_LINE_CODING 0x20U 83 | #define CDC_GET_LINE_CODING 0x21U 84 | #define CDC_SET_CONTROL_LINE_STATE 0x22U 85 | #define CDC_SEND_BREAK 0x23U 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | 92 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 93 | * @{ 94 | */ 95 | 96 | /** 97 | * @} 98 | */ 99 | typedef struct 100 | { 101 | uint32_t bitrate; 102 | uint8_t format; 103 | uint8_t paritytype; 104 | uint8_t datatype; 105 | } USBD_CDC_LineCodingTypeDef; 106 | 107 | typedef struct _USBD_CDC_Itf 108 | { 109 | int8_t (* Init)(void); 110 | int8_t (* DeInit)(void); 111 | int8_t (* Control)(uint8_t cmd, uint8_t *pbuf, uint16_t length); 112 | int8_t (* Receive)(uint8_t *Buf, uint32_t *Len); 113 | int8_t (* TransmitCplt)(uint8_t *Buf, uint32_t *Len, uint8_t epnum); 114 | } USBD_CDC_ItfTypeDef; 115 | 116 | 117 | typedef struct 118 | { 119 | uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32-bit alignment */ 120 | uint8_t CmdOpCode; 121 | uint8_t CmdLength; 122 | uint8_t *RxBuffer; 123 | uint8_t *TxBuffer; 124 | uint32_t RxLength; 125 | uint32_t TxLength; 126 | 127 | __IO uint32_t TxState; 128 | __IO uint32_t RxState; 129 | } USBD_CDC_HandleTypeDef; 130 | 131 | 132 | 133 | /** @defgroup USBD_CORE_Exported_Macros 134 | * @{ 135 | */ 136 | 137 | /** 138 | * @} 139 | */ 140 | 141 | /** @defgroup USBD_CORE_Exported_Variables 142 | * @{ 143 | */ 144 | 145 | extern USBD_ClassTypeDef USBD_CDC; 146 | #define USBD_CDC_CLASS &USBD_CDC 147 | /** 148 | * @} 149 | */ 150 | 151 | /** @defgroup USB_CORE_Exported_Functions 152 | * @{ 153 | */ 154 | uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev, 155 | USBD_CDC_ItfTypeDef *fops); 156 | 157 | #ifdef USE_USBD_COMPOSITE 158 | uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, 159 | uint32_t length, uint8_t ClassId); 160 | uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev, uint8_t ClassId); 161 | #else 162 | uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, 163 | uint32_t length); 164 | uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev); 165 | #endif /* USE_USBD_COMPOSITE */ 166 | uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff); 167 | uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev); 168 | /** 169 | * @} 170 | */ 171 | 172 | #ifdef __cplusplus 173 | } 174 | #endif 175 | 176 | #endif /* __USB_CDC_H */ 177 | /** 178 | * @} 179 | */ 180 | 181 | /** 182 | * @} 183 | */ 184 | 185 | -------------------------------------------------------------------------------- /STM32F415APP/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_req.h 4 | * @author MCD Application Team 5 | * @brief Header file for the usbd_req.c file 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2015 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 __USB_REQUEST_H 21 | #define __USB_REQUEST_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "usbd_def.h" 29 | 30 | 31 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 32 | * @{ 33 | */ 34 | 35 | /** @defgroup USBD_REQ 36 | * @brief header file for the usbd_req.c file 37 | * @{ 38 | */ 39 | 40 | /** @defgroup USBD_REQ_Exported_Defines 41 | * @{ 42 | */ 43 | /** 44 | * @} 45 | */ 46 | 47 | 48 | /** @defgroup USBD_REQ_Exported_Types 49 | * @{ 50 | */ 51 | /** 52 | * @} 53 | */ 54 | 55 | 56 | 57 | /** @defgroup USBD_REQ_Exported_Macros 58 | * @{ 59 | */ 60 | /** 61 | * @} 62 | */ 63 | 64 | /** @defgroup USBD_REQ_Exported_Variables 65 | * @{ 66 | */ 67 | /** 68 | * @} 69 | */ 70 | 71 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype 72 | * @{ 73 | */ 74 | 75 | USBD_StatusTypeDef USBD_StdDevReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 76 | USBD_StatusTypeDef USBD_StdItfReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 77 | USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 78 | 79 | void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 80 | void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata); 81 | void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len); 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif /* __USB_REQUEST_H */ 92 | 93 | /** 94 | * @} 95 | */ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | 102 | -------------------------------------------------------------------------------- /STM32F415APP/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.h 4 | * @author MCD Application Team 5 | * @brief Header file for the usbd_ioreq.c file 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2015 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 __USBD_IOREQ_H 21 | #define __USBD_IOREQ_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "usbd_def.h" 29 | #include "usbd_core.h" 30 | 31 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 32 | * @{ 33 | */ 34 | 35 | /** @defgroup USBD_IOREQ 36 | * @brief header file for the usbd_ioreq.c file 37 | * @{ 38 | */ 39 | 40 | /** @defgroup USBD_IOREQ_Exported_Defines 41 | * @{ 42 | */ 43 | /** 44 | * @} 45 | */ 46 | 47 | 48 | /** @defgroup USBD_IOREQ_Exported_Types 49 | * @{ 50 | */ 51 | 52 | 53 | /** 54 | * @} 55 | */ 56 | 57 | 58 | 59 | /** @defgroup USBD_IOREQ_Exported_Macros 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @defgroup USBD_IOREQ_Exported_Variables 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype 76 | * @{ 77 | */ 78 | 79 | USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev, 80 | uint8_t *pbuf, uint32_t len); 81 | 82 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, 83 | uint8_t *pbuf, uint32_t len); 84 | 85 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev, 86 | uint8_t *pbuf, uint32_t len); 87 | 88 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev, 89 | uint8_t *pbuf, uint32_t len); 90 | 91 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev); 92 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev); 93 | 94 | uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | 104 | #endif /* __USBD_IOREQ_H */ 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /** 111 | * @} 112 | */ 113 | 114 | -------------------------------------------------------------------------------- /STM32F415APP/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.c 4 | * @author MCD Application Team 5 | * @brief This file provides the IO requests APIs for control endpoints. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2015 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 | /* Includes ------------------------------------------------------------------*/ 20 | #include "usbd_ioreq.h" 21 | 22 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 23 | * @{ 24 | */ 25 | 26 | 27 | /** @defgroup USBD_IOREQ 28 | * @brief control I/O requests module 29 | * @{ 30 | */ 31 | 32 | /** @defgroup USBD_IOREQ_Private_TypesDefinitions 33 | * @{ 34 | */ 35 | /** 36 | * @} 37 | */ 38 | 39 | 40 | /** @defgroup USBD_IOREQ_Private_Defines 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @defgroup USBD_IOREQ_Private_Macros 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USBD_IOREQ_Private_Variables 58 | * @{ 59 | */ 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | 66 | /** @defgroup USBD_IOREQ_Private_FunctionPrototypes 67 | * @{ 68 | */ 69 | /** 70 | * @} 71 | */ 72 | 73 | 74 | /** @defgroup USBD_IOREQ_Private_Functions 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @brief USBD_CtlSendData 80 | * send data on the ctl pipe 81 | * @param pdev: device instance 82 | * @param buff: pointer to data buffer 83 | * @param len: length of data to be sent 84 | * @retval status 85 | */ 86 | USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev, 87 | uint8_t *pbuf, uint32_t len) 88 | { 89 | /* Set EP0 State */ 90 | pdev->ep0_state = USBD_EP0_DATA_IN; 91 | pdev->ep_in[0].total_length = len; 92 | 93 | #ifdef USBD_AVOID_PACKET_SPLIT_MPS 94 | pdev->ep_in[0].rem_length = 0U; 95 | #else 96 | pdev->ep_in[0].rem_length = len; 97 | #endif /* USBD_AVOID_PACKET_SPLIT_MPS */ 98 | 99 | /* Start the transfer */ 100 | (void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len); 101 | 102 | return USBD_OK; 103 | } 104 | 105 | /** 106 | * @brief USBD_CtlContinueSendData 107 | * continue sending data on the ctl pipe 108 | * @param pdev: device instance 109 | * @param buff: pointer to data buffer 110 | * @param len: length of data to be sent 111 | * @retval status 112 | */ 113 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, 114 | uint8_t *pbuf, uint32_t len) 115 | { 116 | /* Start the next transfer */ 117 | (void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len); 118 | 119 | return USBD_OK; 120 | } 121 | 122 | /** 123 | * @brief USBD_CtlPrepareRx 124 | * receive data on the ctl pipe 125 | * @param pdev: device instance 126 | * @param buff: pointer to data buffer 127 | * @param len: length of data to be received 128 | * @retval status 129 | */ 130 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev, 131 | uint8_t *pbuf, uint32_t len) 132 | { 133 | /* Set EP0 State */ 134 | pdev->ep0_state = USBD_EP0_DATA_OUT; 135 | pdev->ep_out[0].total_length = len; 136 | 137 | #ifdef USBD_AVOID_PACKET_SPLIT_MPS 138 | pdev->ep_out[0].rem_length = 0U; 139 | #else 140 | pdev->ep_out[0].rem_length = len; 141 | #endif /* USBD_AVOID_PACKET_SPLIT_MPS */ 142 | 143 | /* Start the transfer */ 144 | (void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len); 145 | 146 | return USBD_OK; 147 | } 148 | 149 | /** 150 | * @brief USBD_CtlContinueRx 151 | * continue receive data on the ctl pipe 152 | * @param pdev: device instance 153 | * @param buff: pointer to data buffer 154 | * @param len: length of data to be received 155 | * @retval status 156 | */ 157 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev, 158 | uint8_t *pbuf, uint32_t len) 159 | { 160 | (void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len); 161 | 162 | return USBD_OK; 163 | } 164 | 165 | /** 166 | * @brief USBD_CtlSendStatus 167 | * send zero lzngth packet on the ctl pipe 168 | * @param pdev: device instance 169 | * @retval status 170 | */ 171 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev) 172 | { 173 | /* Set EP0 State */ 174 | pdev->ep0_state = USBD_EP0_STATUS_IN; 175 | 176 | /* Start the transfer */ 177 | (void)USBD_LL_Transmit(pdev, 0x00U, NULL, 0U); 178 | 179 | return USBD_OK; 180 | } 181 | 182 | /** 183 | * @brief USBD_CtlReceiveStatus 184 | * receive zero lzngth packet on the ctl pipe 185 | * @param pdev: device instance 186 | * @retval status 187 | */ 188 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev) 189 | { 190 | /* Set EP0 State */ 191 | pdev->ep0_state = USBD_EP0_STATUS_OUT; 192 | 193 | /* Start the transfer */ 194 | (void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U); 195 | 196 | return USBD_OK; 197 | } 198 | 199 | /** 200 | * @brief USBD_GetRxCount 201 | * returns the received data length 202 | * @param pdev: device instance 203 | * @param ep_addr: endpoint address 204 | * @retval Rx Data blength 205 | */ 206 | uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr) 207 | { 208 | return USBD_LL_GetRxDataSize(pdev, ep_addr); 209 | } 210 | 211 | /** 212 | * @} 213 | */ 214 | 215 | 216 | /** 217 | * @} 218 | */ 219 | 220 | 221 | /** 222 | * @} 223 | */ 224 | 225 | -------------------------------------------------------------------------------- /STM32F415APP/Middlewares/ST/STM32_USB_Device_Library/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 SLA0044 license shall apply and are fully reproduced below: 5 | 6 | SLA0044 Rev5/February 2018 7 | 8 | Software license agreement 9 | 10 | ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT 11 | 12 | BY INSTALLING, COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE 13 | OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS 14 | INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES 15 | (STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON 16 | BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES 17 | TO BE BOUND BY THIS SOFTWARE LICENSE AGREEMENT. 18 | 19 | Under STMicroelectronics’ intellectual property rights, the redistribution, 20 | reproduction and use in source and binary forms of the software or any part 21 | thereof, with or without modification, are permitted provided that the following 22 | conditions are met: 23 | 24 | 1. Redistribution of source code (modified or not) must retain any copyright 25 | notice, this list of conditions and the disclaimer set forth below as items 10 26 | and 11. 27 | 28 | 2. Redistributions in binary form, except as embedded into microcontroller or 29 | microprocessor device manufactured by or for STMicroelectronics or a software 30 | update for such device, must reproduce any copyright notice provided with the 31 | binary code, this list of conditions, and the disclaimer set forth below as 32 | items 10 and 11, in documentation and/or other materials provided with the 33 | distribution. 34 | 35 | 3. Neither the name of STMicroelectronics nor the names of other contributors to 36 | this software may be used to endorse or promote products derived from this 37 | software or part thereof without specific written permission. 38 | 39 | 4. This software or any part thereof, including modifications and/or derivative 40 | works of this software, must be used and execute solely and exclusively on or in 41 | combination with a microcontroller or microprocessor device manufactured by or 42 | for STMicroelectronics. 43 | 44 | 5. No use, reproduction or redistribution of this software partially or totally 45 | may be done in any manner that would subject this software to any Open Source 46 | Terms. “Open Source Terms” shall mean any open source license which requires as 47 | part of distribution of software that the source code of such software is 48 | distributed therewith or otherwise made available, or open source license that 49 | substantially complies with the Open Source definition specified at 50 | www.opensource.org and any other comparable open source license such as for 51 | example GNU General Public License (GPL), Eclipse Public License (EPL), Apache 52 | Software License, BSD license or MIT license. 53 | 54 | 6. STMicroelectronics has no obligation to provide any maintenance, support or 55 | updates for the software. 56 | 57 | 7. The software is and will remain the exclusive property of STMicroelectronics 58 | and its licensors. The recipient will not take any action that jeopardizes 59 | STMicroelectronics and its licensors' proprietary rights or acquire any rights 60 | in the software, except the limited rights specified hereunder. 61 | 62 | 8. The recipient shall comply with all applicable laws and regulations affecting 63 | the use of the software or any part thereof including any applicable export 64 | control law or regulation. 65 | 66 | 9. Redistribution and use of this software or any part thereof other than as 67 | permitted under this license is void and will automatically terminate your 68 | rights under this license. 69 | 70 | 10. THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND 71 | ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 72 | IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 73 | NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, WHICH ARE 74 | DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL 75 | STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 76 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 77 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 78 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 79 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 80 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 81 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 82 | 83 | 11. EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS, WHETHER 84 | EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY 85 | RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY. 86 | 87 | -------------------------------------------------------------------------------- /STM32F415APP/Middlewares/Third_Party/FatFs/src/diskio.c: -------------------------------------------------------------------------------- 1 | /*-----------------------------------------------------------------------*/ 2 | /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2017 */ 3 | /* */ 4 | /* Portions COPYRIGHT 2017 STMicroelectronics */ 5 | /* Portions Copyright (C) 2017, ChaN, all right reserved */ 6 | /*-----------------------------------------------------------------------*/ 7 | /* If a working storage control module is available, it should be */ 8 | /* attached to the FatFs via a glue function rather than modifying it. */ 9 | /* This is an example of glue functions to attach various existing */ 10 | /* storage control modules to the FatFs module with a defined API. */ 11 | /*-----------------------------------------------------------------------*/ 12 | 13 | /* Includes ------------------------------------------------------------------*/ 14 | #include "diskio.h" 15 | #include "ff_gen_drv.h" 16 | 17 | #if defined ( __GNUC__ ) 18 | #ifndef __weak 19 | #define __weak __attribute__((weak)) 20 | #endif 21 | #endif 22 | 23 | /* Private typedef -----------------------------------------------------------*/ 24 | /* Private define ------------------------------------------------------------*/ 25 | /* Private variables ---------------------------------------------------------*/ 26 | extern Disk_drvTypeDef disk; 27 | 28 | /* Private function prototypes -----------------------------------------------*/ 29 | /* Private functions ---------------------------------------------------------*/ 30 | 31 | /** 32 | * @brief Gets Disk Status 33 | * @param pdrv: Physical drive number (0..) 34 | * @retval DSTATUS: Operation status 35 | */ 36 | DSTATUS disk_status ( 37 | BYTE pdrv /* Physical drive number to identify the drive */ 38 | ) 39 | { 40 | DSTATUS stat; 41 | 42 | stat = disk.drv[pdrv]->disk_status(disk.lun[pdrv]); 43 | return stat; 44 | } 45 | 46 | /** 47 | * @brief Initializes a Drive 48 | * @param pdrv: Physical drive number (0..) 49 | * @retval DSTATUS: Operation status 50 | */ 51 | DSTATUS disk_initialize ( 52 | BYTE pdrv /* Physical drive nmuber to identify the drive */ 53 | ) 54 | { 55 | DSTATUS stat = RES_OK; 56 | 57 | if(disk.is_initialized[pdrv] == 0) 58 | { 59 | stat = disk.drv[pdrv]->disk_initialize(disk.lun[pdrv]); 60 | if(stat == RES_OK) 61 | { 62 | disk.is_initialized[pdrv] = 1; 63 | } 64 | } 65 | return stat; 66 | } 67 | 68 | /** 69 | * @brief Reads Sector(s) 70 | * @param pdrv: Physical drive number (0..) 71 | * @param *buff: Data buffer to store read data 72 | * @param sector: Sector address (LBA) 73 | * @param count: Number of sectors to read (1..128) 74 | * @retval DRESULT: Operation result 75 | */ 76 | DRESULT disk_read ( 77 | BYTE pdrv, /* Physical drive nmuber to identify the drive */ 78 | BYTE *buff, /* Data buffer to store read data */ 79 | DWORD sector, /* Sector address in LBA */ 80 | UINT count /* Number of sectors to read */ 81 | ) 82 | { 83 | DRESULT res; 84 | 85 | res = disk.drv[pdrv]->disk_read(disk.lun[pdrv], buff, sector, count); 86 | return res; 87 | } 88 | 89 | /** 90 | * @brief Writes Sector(s) 91 | * @param pdrv: Physical drive number (0..) 92 | * @param *buff: Data to be written 93 | * @param sector: Sector address (LBA) 94 | * @param count: Number of sectors to write (1..128) 95 | * @retval DRESULT: Operation result 96 | */ 97 | #if _USE_WRITE == 1 98 | DRESULT disk_write ( 99 | BYTE pdrv, /* Physical drive nmuber to identify the drive */ 100 | const BYTE *buff, /* Data to be written */ 101 | DWORD sector, /* Sector address in LBA */ 102 | UINT count /* Number of sectors to write */ 103 | ) 104 | { 105 | DRESULT res; 106 | 107 | res = disk.drv[pdrv]->disk_write(disk.lun[pdrv], buff, sector, count); 108 | return res; 109 | } 110 | #endif /* _USE_WRITE == 1 */ 111 | 112 | /** 113 | * @brief I/O control operation 114 | * @param pdrv: Physical drive number (0..) 115 | * @param cmd: Control code 116 | * @param *buff: Buffer to send/receive control data 117 | * @retval DRESULT: Operation result 118 | */ 119 | #if _USE_IOCTL == 1 120 | DRESULT disk_ioctl ( 121 | BYTE pdrv, /* Physical drive nmuber (0..) */ 122 | BYTE cmd, /* Control code */ 123 | void *buff /* Buffer to send/receive control data */ 124 | ) 125 | { 126 | DRESULT res; 127 | 128 | res = disk.drv[pdrv]->disk_ioctl(disk.lun[pdrv], cmd, buff); 129 | return res; 130 | } 131 | #endif /* _USE_IOCTL == 1 */ 132 | 133 | /** 134 | * @brief Gets Time from RTC 135 | * @param None 136 | * @retval Time in DWORD 137 | */ 138 | __weak DWORD get_fattime (void) 139 | { 140 | return 0; 141 | } 142 | 143 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 144 | 145 | -------------------------------------------------------------------------------- /STM32F415APP/Middlewares/Third_Party/FatFs/src/diskio.h: -------------------------------------------------------------------------------- 1 | /*-----------------------------------------------------------------------/ 2 | / Low level disk interface modlue include file (C)ChaN, 2014 / 3 | /-----------------------------------------------------------------------*/ 4 | 5 | #ifndef _DISKIO_DEFINED 6 | #define _DISKIO_DEFINED 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #define _USE_WRITE 1 /* 1: Enable disk_write function */ 13 | #define _USE_IOCTL 1 /* 1: Enable disk_ioctl function */ 14 | 15 | #include "integer.h" 16 | 17 | 18 | /* Status of Disk Functions */ 19 | typedef BYTE DSTATUS; 20 | 21 | /* Results of Disk Functions */ 22 | typedef enum { 23 | RES_OK = 0, /* 0: Successful */ 24 | RES_ERROR, /* 1: R/W Error */ 25 | RES_WRPRT, /* 2: Write Protected */ 26 | RES_NOTRDY, /* 3: Not Ready */ 27 | RES_PARERR /* 4: Invalid Parameter */ 28 | } DRESULT; 29 | 30 | 31 | /*---------------------------------------*/ 32 | /* Prototypes for disk control functions */ 33 | 34 | 35 | DSTATUS disk_initialize (BYTE pdrv); 36 | DSTATUS disk_status (BYTE pdrv); 37 | DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); 38 | DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); 39 | DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); 40 | DWORD get_fattime (void); 41 | 42 | /* Disk Status Bits (DSTATUS) */ 43 | 44 | #define STA_NOINIT 0x01 /* Drive not initialized */ 45 | #define STA_NODISK 0x02 /* No medium in the drive */ 46 | #define STA_PROTECT 0x04 /* Write protected */ 47 | 48 | 49 | /* Command code for disk_ioctrl fucntion */ 50 | 51 | /* Generic command (Used by FatFs) */ 52 | #define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ 53 | #define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ 54 | #define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ 55 | #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ 56 | #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ 57 | 58 | /* Generic command (Not used by FatFs) */ 59 | #define CTRL_POWER 5 /* Get/Set power status */ 60 | #define CTRL_LOCK 6 /* Lock/Unlock media removal */ 61 | #define CTRL_EJECT 7 /* Eject media */ 62 | #define CTRL_FORMAT 8 /* Create physical format on the media */ 63 | 64 | /* MMC/SDC specific ioctl command */ 65 | #define MMC_GET_TYPE 10 /* Get card type */ 66 | #define MMC_GET_CSD 11 /* Get CSD */ 67 | #define MMC_GET_CID 12 /* Get CID */ 68 | #define MMC_GET_OCR 13 /* Get OCR */ 69 | #define MMC_GET_SDSTAT 14 /* Get SD status */ 70 | 71 | /* ATA/CF specific ioctl command */ 72 | #define ATA_GET_REV 20 /* Get F/W revision */ 73 | #define ATA_GET_MODEL 21 /* Get model name */ 74 | #define ATA_GET_SN 22 /* Get serial number */ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /STM32F415APP/Middlewares/Third_Party/FatFs/src/ff_gen_drv.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file ff_gen_drv.c 4 | * @author MCD Application Team 5 | * @brief FatFs generic low level driver. 6 | ***************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. All rights reserved. 10 | * 11 | * This software component is licensed by ST under BSD 3-Clause license, 12 | * the "License"; You may not use this file except in compliance with the 13 | * License. You may obtain a copy of the License at: 14 | * opensource.org/licenses/BSD-3-Clause 15 | * 16 | ****************************************************************************** 17 | **/ 18 | /* Includes ------------------------------------------------------------------*/ 19 | #include "ff_gen_drv.h" 20 | 21 | /* Private typedef -----------------------------------------------------------*/ 22 | /* Private define ------------------------------------------------------------*/ 23 | /* Private variables ---------------------------------------------------------*/ 24 | Disk_drvTypeDef disk = {{0},{0},{0},0}; 25 | 26 | /* Private function prototypes -----------------------------------------------*/ 27 | /* Private functions ---------------------------------------------------------*/ 28 | 29 | /** 30 | * @brief Links a compatible diskio driver/lun id and increments the number of active 31 | * linked drivers. 32 | * @note The number of linked drivers (volumes) is up to 10 due to FatFs limits. 33 | * @param drv: pointer to the disk IO Driver structure 34 | * @param path: pointer to the logical drive path 35 | * @param lun : only used for USB Key Disk to add multi-lun management 36 | else the parameter must be equal to 0 37 | * @retval Returns 0 in case of success, otherwise 1. 38 | */ 39 | uint8_t FATFS_LinkDriverEx(const Diskio_drvTypeDef *drv, char *path, uint8_t lun) 40 | { 41 | uint8_t ret = 1; 42 | uint8_t DiskNum = 0; 43 | 44 | if(disk.nbr < _VOLUMES) 45 | { 46 | disk.is_initialized[disk.nbr] = 0; 47 | disk.drv[disk.nbr] = drv; 48 | disk.lun[disk.nbr] = lun; 49 | DiskNum = disk.nbr++; 50 | path[0] = DiskNum + '0'; 51 | path[1] = ':'; 52 | path[2] = '/'; 53 | path[3] = 0; 54 | ret = 0; 55 | } 56 | 57 | return ret; 58 | } 59 | 60 | /** 61 | * @brief Links a compatible diskio driver and increments the number of active 62 | * linked drivers. 63 | * @note The number of linked drivers (volumes) is up to 10 due to FatFs limits 64 | * @param drv: pointer to the disk IO Driver structure 65 | * @param path: pointer to the logical drive path 66 | * @retval Returns 0 in case of success, otherwise 1. 67 | */ 68 | uint8_t FATFS_LinkDriver(const Diskio_drvTypeDef *drv, char *path) 69 | { 70 | return FATFS_LinkDriverEx(drv, path, 0); 71 | } 72 | 73 | /** 74 | * @brief Unlinks a diskio driver and decrements the number of active linked 75 | * drivers. 76 | * @param path: pointer to the logical drive path 77 | * @param lun : not used 78 | * @retval Returns 0 in case of success, otherwise 1. 79 | */ 80 | uint8_t FATFS_UnLinkDriverEx(char *path, uint8_t lun) 81 | { 82 | uint8_t DiskNum = 0; 83 | uint8_t ret = 1; 84 | 85 | if(disk.nbr >= 1) 86 | { 87 | DiskNum = path[0] - '0'; 88 | if(disk.drv[DiskNum] != 0) 89 | { 90 | disk.drv[DiskNum] = 0; 91 | disk.lun[DiskNum] = 0; 92 | disk.nbr--; 93 | ret = 0; 94 | } 95 | } 96 | 97 | return ret; 98 | } 99 | 100 | /** 101 | * @brief Unlinks a diskio driver and decrements the number of active linked 102 | * drivers. 103 | * @param path: pointer to the logical drive path 104 | * @retval Returns 0 in case of success, otherwise 1. 105 | */ 106 | uint8_t FATFS_UnLinkDriver(char *path) 107 | { 108 | return FATFS_UnLinkDriverEx(path, 0); 109 | } 110 | 111 | /** 112 | * @brief Gets number of linked drivers to the FatFs module. 113 | * @param None 114 | * @retval Number of attached drivers. 115 | */ 116 | uint8_t FATFS_GetAttachedDriversNbr(void) 117 | { 118 | return disk.nbr; 119 | } 120 | 121 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 122 | 123 | -------------------------------------------------------------------------------- /STM32F415APP/Middlewares/Third_Party/FatFs/src/ff_gen_drv.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file ff_gen_drv.h 4 | * @author MCD Application Team 5 | * @brief Header for ff_gen_drv.c module. 6 | ***************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. All rights reserved. 10 | * 11 | * This software component is licensed by ST under BSD 3-Clause license, 12 | * the "License"; You may not use this file except in compliance with the 13 | * License. You may obtain a copy of the License at: 14 | * opensource.org/licenses/BSD-3-Clause 15 | * 16 | ****************************************************************************** 17 | **/ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __FF_GEN_DRV_H 21 | #define __FF_GEN_DRV_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "diskio.h" 29 | #include "ff.h" 30 | #include "stdint.h" 31 | 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | 35 | /** 36 | * @brief Disk IO Driver structure definition 37 | */ 38 | typedef struct 39 | { 40 | DSTATUS (*disk_initialize) (BYTE); /*!< Initialize Disk Drive */ 41 | DSTATUS (*disk_status) (BYTE); /*!< Get Disk Status */ 42 | DRESULT (*disk_read) (BYTE, BYTE*, DWORD, UINT); /*!< Read Sector(s) */ 43 | #if _USE_WRITE == 1 44 | DRESULT (*disk_write) (BYTE, const BYTE*, DWORD, UINT); /*!< Write Sector(s) when _USE_WRITE = 0 */ 45 | #endif /* _USE_WRITE == 1 */ 46 | #if _USE_IOCTL == 1 47 | DRESULT (*disk_ioctl) (BYTE, BYTE, void*); /*!< I/O control operation when _USE_IOCTL = 1 */ 48 | #endif /* _USE_IOCTL == 1 */ 49 | 50 | }Diskio_drvTypeDef; 51 | 52 | /** 53 | * @brief Global Disk IO Drivers structure definition 54 | */ 55 | typedef struct 56 | { 57 | uint8_t is_initialized[_VOLUMES]; 58 | const Diskio_drvTypeDef *drv[_VOLUMES]; 59 | uint8_t lun[_VOLUMES]; 60 | volatile uint8_t nbr; 61 | 62 | }Disk_drvTypeDef; 63 | 64 | /* Exported constants --------------------------------------------------------*/ 65 | /* Exported macro ------------------------------------------------------------*/ 66 | /* Exported functions ------------------------------------------------------- */ 67 | uint8_t FATFS_LinkDriver(const Diskio_drvTypeDef *drv, char *path); 68 | uint8_t FATFS_UnLinkDriver(char *path); 69 | uint8_t FATFS_LinkDriverEx(const Diskio_drvTypeDef *drv, char *path, BYTE lun); 70 | uint8_t FATFS_UnLinkDriverEx(char *path, BYTE lun); 71 | uint8_t FATFS_GetAttachedDriversNbr(void); 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif /* __FF_GEN_DRV_H */ 78 | 79 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 80 | 81 | -------------------------------------------------------------------------------- /STM32F415APP/Middlewares/Third_Party/FatFs/src/integer.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------*/ 2 | /* Integer type definitions for FatFs module */ 3 | /*-------------------------------------------*/ 4 | 5 | #ifndef _FF_INTEGER 6 | #define _FF_INTEGER 7 | 8 | #ifdef _WIN32 /* FatFs development platform */ 9 | 10 | #include 11 | #include 12 | typedef unsigned __int64 QWORD; 13 | 14 | 15 | #else /* Embedded platform */ 16 | 17 | /* These types MUST be 16-bit or 32-bit */ 18 | typedef int INT; 19 | typedef unsigned int UINT; 20 | 21 | /* This type MUST be 8-bit */ 22 | typedef unsigned char BYTE; 23 | 24 | /* These types MUST be 16-bit */ 25 | typedef short SHORT; 26 | typedef unsigned short WORD; 27 | typedef unsigned short WCHAR; 28 | 29 | /* These types MUST be 32-bit */ 30 | typedef long LONG; 31 | typedef unsigned long DWORD; 32 | 33 | /* This type MUST be 64-bit (Remove this for ANSI C (C89) compatibility) */ 34 | typedef unsigned long long QWORD; 35 | 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /STM32F415APP/Middlewares/Third_Party/FatFs/src/option/syscall.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------*/ 2 | /* Sample code of OS dependent controls for FatFs */ 3 | /* (C)ChaN, 2014 */ 4 | /* Portions COPYRIGHT 2017 STMicroelectronics */ 5 | /* Portions Copyright (C) 2014, ChaN, all right reserved */ 6 | /*------------------------------------------------------------------------*/ 7 | 8 | /** 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * Copyright (c) 2017 STMicroelectronics. All rights reserved. 13 | * 14 | * This software component is licensed by ST under BSD 3-Clause license, 15 | * the "License"; You may not use this file except in compliance with the 16 | * License. You may obtain a copy of the License at: 17 | * opensource.org/licenses/BSD-3-Clause 18 | * 19 | ****************************************************************************** 20 | **/ 21 | 22 | 23 | 24 | #include "../ff.h" 25 | 26 | 27 | #if _FS_REENTRANT 28 | /*------------------------------------------------------------------------*/ 29 | /* Create a Synchronization Object */ 30 | /*------------------------------------------------------------------------*/ 31 | /* This function is called in f_mount() function to create a new 32 | / synchronization object, such as semaphore and mutex. When a 0 is returned, 33 | / the f_mount() function fails with FR_INT_ERR. 34 | */ 35 | 36 | int ff_cre_syncobj ( /* 1:Function succeeded, 0:Could not create the sync object */ 37 | BYTE vol, /* Corresponding volume (logical drive number) */ 38 | _SYNC_t *sobj /* Pointer to return the created sync object */ 39 | ) 40 | { 41 | 42 | int ret; 43 | #if _USE_MUTEX 44 | 45 | #if (osCMSIS < 0x20000U) 46 | osMutexDef(MTX); 47 | *sobj = osMutexCreate(osMutex(MTX)); 48 | #else 49 | *sobj = osMutexNew(NULL); 50 | #endif 51 | 52 | #else 53 | 54 | #if (osCMSIS < 0x20000U) 55 | osSemaphoreDef(SEM); 56 | *sobj = osSemaphoreCreate(osSemaphore(SEM), 1); 57 | #else 58 | *sobj = osSemaphoreNew(1, 1, NULL); 59 | #endif 60 | 61 | #endif 62 | ret = (*sobj != NULL); 63 | 64 | return ret; 65 | } 66 | 67 | 68 | 69 | /*------------------------------------------------------------------------*/ 70 | /* Delete a Synchronization Object */ 71 | /*------------------------------------------------------------------------*/ 72 | /* This function is called in f_mount() function to delete a synchronization 73 | / object that created with ff_cre_syncobj() function. When a 0 is returned, 74 | / the f_mount() function fails with FR_INT_ERR. 75 | */ 76 | 77 | int ff_del_syncobj ( /* 1:Function succeeded, 0:Could not delete due to any error */ 78 | _SYNC_t sobj /* Sync object tied to the logical drive to be deleted */ 79 | ) 80 | { 81 | #if _USE_MUTEX 82 | osMutexDelete (sobj); 83 | #else 84 | osSemaphoreDelete (sobj); 85 | #endif 86 | return 1; 87 | } 88 | 89 | 90 | 91 | /*------------------------------------------------------------------------*/ 92 | /* Request Grant to Access the Volume */ 93 | /*------------------------------------------------------------------------*/ 94 | /* This function is called on entering file functions to lock the volume. 95 | / When a 0 is returned, the file function fails with FR_TIMEOUT. 96 | */ 97 | 98 | int ff_req_grant ( /* 1:Got a grant to access the volume, 0:Could not get a grant */ 99 | _SYNC_t sobj /* Sync object to wait */ 100 | ) 101 | { 102 | int ret = 0; 103 | #if (osCMSIS < 0x20000U) 104 | 105 | #if _USE_MUTEX 106 | if(osMutexWait(sobj, _FS_TIMEOUT) == osOK) 107 | #else 108 | if(osSemaphoreWait(sobj, _FS_TIMEOUT) == osOK) 109 | #endif 110 | 111 | #else 112 | 113 | #if _USE_MUTEX 114 | if(osMutexAcquire(sobj, _FS_TIMEOUT) == osOK) 115 | #else 116 | if(osSemaphoreAcquire(sobj, _FS_TIMEOUT) == osOK) 117 | #endif 118 | 119 | #endif 120 | { 121 | ret = 1; 122 | } 123 | 124 | return ret; 125 | } 126 | 127 | 128 | 129 | /*------------------------------------------------------------------------*/ 130 | /* Release Grant to Access the Volume */ 131 | /*------------------------------------------------------------------------*/ 132 | /* This function is called on leaving file functions to unlock the volume. 133 | */ 134 | 135 | void ff_rel_grant ( 136 | _SYNC_t sobj /* Sync object to be signaled */ 137 | ) 138 | { 139 | #if _USE_MUTEX 140 | osMutexRelease(sobj); 141 | #else 142 | osSemaphoreRelease(sobj); 143 | #endif 144 | } 145 | 146 | #endif 147 | 148 | 149 | 150 | 151 | #if _USE_LFN == 3 /* LFN with a working buffer on the heap */ 152 | /*------------------------------------------------------------------------*/ 153 | /* Allocate a memory block */ 154 | /*------------------------------------------------------------------------*/ 155 | /* If a NULL is returned, the file function fails with FR_NOT_ENOUGH_CORE. 156 | */ 157 | 158 | void* ff_memalloc ( /* Returns pointer to the allocated memory block */ 159 | UINT msize /* Number of bytes to allocate */ 160 | ) 161 | { 162 | return ff_malloc(msize); /* Allocate a new memory block with POSIX API */ 163 | } 164 | 165 | 166 | /*------------------------------------------------------------------------*/ 167 | /* Free a memory block */ 168 | /*------------------------------------------------------------------------*/ 169 | 170 | void ff_memfree ( 171 | void* mblock /* Pointer to the memory block to free */ 172 | ) 173 | { 174 | ff_free(mblock); /* Discard the memory block with POSIX API */ 175 | } 176 | 177 | #endif 178 | -------------------------------------------------------------------------------- /STM32F415APP/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickshl/DevBoy/23a479d11731028b5977333b33421b6cd41dc287/STM32F415APP/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c -------------------------------------------------------------------------------- /STM32F415APP/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickshl/DevBoy/23a479d11731028b5977333b33421b6cd41dc287/STM32F415APP/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.h -------------------------------------------------------------------------------- /STM32F415APP/Middlewares/Third_Party/FreeRTOS/Source/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | Permission is hereby granted, free of charge, to any person obtaining a copy of 3 | this software and associated documentation files (the "Software"), to deal in 4 | the Software without restriction, including without limitation the rights to 5 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 6 | the Software, and to permit persons to whom the Software is furnished to do so, 7 | subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 14 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 15 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 16 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 17 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | 19 | -------------------------------------------------------------------------------- /STM32F415APP/Middlewares/Third_Party/FreeRTOS/Source/include/projdefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.3.1 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * 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, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * http://www.FreeRTOS.org 23 | * http://aws.amazon.com/freertos 24 | * 25 | * 1 tab == 4 spaces! 26 | */ 27 | 28 | #ifndef PROJDEFS_H 29 | #define PROJDEFS_H 30 | 31 | /* 32 | * Defines the prototype to which task functions must conform. Defined in this 33 | * file to ensure the type is known before portable.h is included. 34 | */ 35 | typedef void (*TaskFunction_t)( void * ); 36 | 37 | /* Converts a time in milliseconds to a time in ticks. This macro can be 38 | overridden by a macro of the same name defined in FreeRTOSConfig.h in case the 39 | definition here is not suitable for your application. */ 40 | #ifndef pdMS_TO_TICKS 41 | #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) 42 | #endif 43 | 44 | #define pdFALSE ( ( BaseType_t ) 0 ) 45 | #define pdTRUE ( ( BaseType_t ) 1 ) 46 | 47 | #define pdPASS ( pdTRUE ) 48 | #define pdFAIL ( pdFALSE ) 49 | #define errQUEUE_EMPTY ( ( BaseType_t ) 0 ) 50 | #define errQUEUE_FULL ( ( BaseType_t ) 0 ) 51 | 52 | /* FreeRTOS error definitions. */ 53 | #define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) 54 | #define errQUEUE_BLOCKED ( -4 ) 55 | #define errQUEUE_YIELD ( -5 ) 56 | 57 | /* Macros used for basic data corruption checks. */ 58 | #ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 59 | #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 60 | #endif 61 | 62 | #if( configUSE_16_BIT_TICKS == 1 ) 63 | #define pdINTEGRITY_CHECK_VALUE 0x5a5a 64 | #else 65 | #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL 66 | #endif 67 | 68 | /* The following errno values are used by FreeRTOS+ components, not FreeRTOS 69 | itself. */ 70 | #define pdFREERTOS_ERRNO_NONE 0 /* No errors */ 71 | #define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */ 72 | #define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */ 73 | #define pdFREERTOS_ERRNO_EIO 5 /* I/O error */ 74 | #define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */ 75 | #define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */ 76 | #define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */ 77 | #define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */ 78 | #define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */ 79 | #define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */ 80 | #define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */ 81 | #define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */ 82 | #define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */ 83 | #define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */ 84 | #define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */ 85 | #define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */ 86 | #define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */ 87 | #define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */ 88 | #define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */ 89 | #define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */ 90 | #define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */ 91 | #define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */ 92 | #define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */ 93 | #define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */ 94 | #define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */ 95 | #define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */ 96 | #define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */ 97 | #define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ 98 | #define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */ 99 | #define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */ 100 | #define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */ 101 | #define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */ 102 | #define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */ 103 | #define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */ 104 | #define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */ 105 | #define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */ 106 | #define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */ 107 | #define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */ 108 | #define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */ 109 | #define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */ 110 | 111 | /* The following endian values are used by FreeRTOS+ components, not FreeRTOS 112 | itself. */ 113 | #define pdFREERTOS_LITTLE_ENDIAN 0 114 | #define pdFREERTOS_BIG_ENDIAN 1 115 | 116 | /* Re-defining endian values for generic naming. */ 117 | #define pdLITTLE_ENDIAN pdFREERTOS_LITTLE_ENDIAN 118 | #define pdBIG_ENDIAN pdFREERTOS_BIG_ENDIAN 119 | 120 | 121 | #endif /* PROJDEFS_H */ 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /STM32F415APP/STM32F415RGTX_RAM.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** @file : LinkerScript.ld (debug in RAM dedicated) 5 | ** 6 | ** @author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** @brief : Linker script for STM32F415RGTx Device from STM32F4 series 9 | ** 1024Kbytes FLASH 10 | ** 64Kbytes CCMRAM 11 | ** 128Kbytes RAM 12 | ** 13 | ** Set heap size, stack size and stack location according 14 | ** to application requirements. 15 | ** 16 | ** Set memory bank area and size if external memory is used 17 | ** 18 | ** Target : STMicroelectronics STM32 19 | ** 20 | ** Distribution: The file is distributed as is, without any warranty 21 | ** of any kind. 22 | ** 23 | ****************************************************************************** 24 | ** @attention 25 | ** 26 | ** Copyright (c) 2023 STMicroelectronics. 27 | ** All rights reserved. 28 | ** 29 | ** This software is licensed under terms that can be found in the LICENSE file 30 | ** in the root directory of this software component. 31 | ** If no LICENSE file comes with this software, it is provided AS-IS. 32 | ** 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Entry Point */ 37 | ENTRY(Reset_Handler) 38 | 39 | /* Highest address of the user mode stack */ 40 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ 41 | 42 | _Min_Heap_Size = 0x0; /* required amount of heap */ 43 | _Min_Stack_Size = 0x10; /* required amount of stack */ 44 | 45 | /* Memories definition */ 46 | MEMORY 47 | { 48 | CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K 49 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K 50 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K 51 | } 52 | 53 | /* Sections */ 54 | SECTIONS 55 | { 56 | /* The startup code into "RAM" Ram type memory */ 57 | .isr_vector : 58 | { 59 | . = ALIGN(4); 60 | KEEP(*(.isr_vector)) /* Startup code */ 61 | . = ALIGN(4); 62 | } >RAM 63 | 64 | /* The program code and other data into "RAM" Ram type memory */ 65 | .text : 66 | { 67 | . = ALIGN(4); 68 | *(.text) /* .text sections (code) */ 69 | *(.text*) /* .text* sections (code) */ 70 | *(.glue_7) /* glue arm to thumb code */ 71 | *(.glue_7t) /* glue thumb to arm code */ 72 | *(.eh_frame) 73 | *(.RamFunc) /* .RamFunc sections */ 74 | *(.RamFunc*) /* .RamFunc* sections */ 75 | 76 | KEEP (*(.init)) 77 | KEEP (*(.fini)) 78 | 79 | . = ALIGN(4); 80 | _etext = .; /* define a global symbols at end of code */ 81 | } >RAM 82 | 83 | /* Constant data into "RAM" Ram type memory */ 84 | .rodata : 85 | { 86 | . = ALIGN(4); 87 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 88 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 89 | . = ALIGN(4); 90 | } >RAM 91 | 92 | .ARM.extab : { 93 | . = ALIGN(4); 94 | *(.ARM.extab* .gnu.linkonce.armextab.*) 95 | . = ALIGN(4); 96 | } >RAM 97 | 98 | .ARM : { 99 | . = ALIGN(4); 100 | __exidx_start = .; 101 | *(.ARM.exidx*) 102 | __exidx_end = .; 103 | . = ALIGN(4); 104 | } >RAM 105 | 106 | .preinit_array : 107 | { 108 | . = ALIGN(4); 109 | PROVIDE_HIDDEN (__preinit_array_start = .); 110 | KEEP (*(.preinit_array*)) 111 | PROVIDE_HIDDEN (__preinit_array_end = .); 112 | . = ALIGN(4); 113 | } >RAM 114 | 115 | .init_array : 116 | { 117 | . = ALIGN(4); 118 | PROVIDE_HIDDEN (__init_array_start = .); 119 | KEEP (*(SORT(.init_array.*))) 120 | KEEP (*(.init_array*)) 121 | PROVIDE_HIDDEN (__init_array_end = .); 122 | . = ALIGN(4); 123 | } >RAM 124 | 125 | .fini_array : 126 | { 127 | . = ALIGN(4); 128 | PROVIDE_HIDDEN (__fini_array_start = .); 129 | KEEP (*(SORT(.fini_array.*))) 130 | KEEP (*(.fini_array*)) 131 | PROVIDE_HIDDEN (__fini_array_end = .); 132 | . = ALIGN(4); 133 | } >RAM 134 | 135 | /* Used by the startup to initialize data */ 136 | _sidata = LOADADDR(.data); 137 | 138 | /* Initialized data sections into "RAM" Ram type memory */ 139 | .data : 140 | { 141 | . = ALIGN(4); 142 | _sdata = .; /* create a global symbol at data start */ 143 | *(.data) /* .data sections */ 144 | *(.data*) /* .data* sections */ 145 | 146 | . = ALIGN(4); 147 | _edata = .; /* define a global symbol at data end */ 148 | 149 | } >RAM 150 | 151 | _siccmram = LOADADDR(.ccmram); 152 | 153 | /* CCM-RAM section 154 | * 155 | * IMPORTANT NOTE! 156 | * If initialized variables will be placed in this section, 157 | * the startup code needs to be modified to copy the init-values. 158 | */ 159 | .ccmram : 160 | { 161 | . = ALIGN(4); 162 | _sccmram = .; /* create a global symbol at ccmram start */ 163 | *(.ccmram) 164 | *(.ccmram*) 165 | 166 | . = ALIGN(4); 167 | _eccmram = .; /* create a global symbol at ccmram end */ 168 | } >CCMRAM AT> RAM 169 | 170 | /* Uninitialized data section into "RAM" Ram type memory */ 171 | . = ALIGN(4); 172 | .bss : 173 | { 174 | /* This is used by the startup in order to initialize the .bss section */ 175 | _sbss = .; /* define a global symbol at bss start */ 176 | __bss_start__ = _sbss; 177 | *(.bss) 178 | *(.bss*) 179 | *(COMMON) 180 | 181 | . = ALIGN(4); 182 | _ebss = .; /* define a global symbol at bss end */ 183 | __bss_end__ = _ebss; 184 | } >RAM 185 | 186 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ 187 | ._user_heap_stack : 188 | { 189 | . = ALIGN(8); 190 | PROVIDE ( end = . ); 191 | PROVIDE ( _end = . ); 192 | . = . + _Min_Heap_Size; 193 | . = . + _Min_Stack_Size; 194 | . = ALIGN(8); 195 | } >RAM 196 | 197 | /* Remove information from the compiler libraries */ 198 | /DISCARD/ : 199 | { 200 | libc.a ( * ) 201 | libm.a ( * ) 202 | libgcc.a ( * ) 203 | } 204 | 205 | .ARM.attributes 0 : { *(.ARM.attributes) } 206 | } 207 | -------------------------------------------------------------------------------- /STM32F415APP/STM32F415RGTx_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** @file : LinkerScript.ld 5 | ** 6 | ** @author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** @brief : Linker script for STM32F415RGTx Device from STM32F4 series 9 | ** 1024Kbytes FLASH 10 | ** 64Kbytes CCMRAM 11 | ** 128Kbytes RAM 12 | ** 13 | ** Set heap size, stack size and stack location according 14 | ** to application requirements. 15 | ** 16 | ** Set memory bank area and size if external memory is used 17 | ** 18 | ** Target : STMicroelectronics STM32 19 | ** 20 | ** Distribution: The file is distributed as is, without any warranty 21 | ** of any kind. 22 | ** 23 | ****************************************************************************** 24 | ** @attention 25 | ** 26 | ** Copyright (c) 2023 STMicroelectronics. 27 | ** All rights reserved. 28 | ** 29 | ** This software is licensed under terms that can be found in the LICENSE file 30 | ** in the root directory of this software component. 31 | ** If no LICENSE file comes with this software, it is provided AS-IS. 32 | ** 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Entry Point */ 37 | ENTRY(Reset_Handler) 38 | 39 | /* Highest address of the user mode stack */ 40 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ 41 | 42 | _Min_Heap_Size = 0x0; /* required amount of heap */ 43 | _Min_Stack_Size = 0x10; /* required amount of stack */ 44 | 45 | /* Memories definition */ 46 | MEMORY 47 | { 48 | CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K 49 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K 50 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K 51 | } 52 | 53 | /* Sections */ 54 | SECTIONS 55 | { 56 | /* The startup code into "FLASH" Rom type memory */ 57 | .isr_vector : 58 | { 59 | . = ALIGN(4); 60 | KEEP(*(.isr_vector)) /* Startup code */ 61 | . = ALIGN(4); 62 | } >FLASH 63 | 64 | /* The program code and other data into "FLASH" Rom type memory */ 65 | .text : 66 | { 67 | . = ALIGN(4); 68 | *(.text) /* .text sections (code) */ 69 | *(.text*) /* .text* sections (code) */ 70 | *(.glue_7) /* glue arm to thumb code */ 71 | *(.glue_7t) /* glue thumb to arm code */ 72 | *(.eh_frame) 73 | 74 | KEEP (*(.init)) 75 | KEEP (*(.fini)) 76 | 77 | . = ALIGN(4); 78 | _etext = .; /* define a global symbols at end of code */ 79 | } >FLASH 80 | 81 | /* Constant data into "FLASH" Rom 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 | } >FLASH 89 | 90 | .ARM.extab : { 91 | . = ALIGN(4); 92 | *(.ARM.extab* .gnu.linkonce.armextab.*) 93 | . = ALIGN(4); 94 | } >FLASH 95 | 96 | .ARM : { 97 | . = ALIGN(4); 98 | __exidx_start = .; 99 | *(.ARM.exidx*) 100 | __exidx_end = .; 101 | . = ALIGN(4); 102 | } >FLASH 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 | } >FLASH 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 | } >FLASH 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 | } >FLASH 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 | *(.RamFunc) /* .RamFunc sections */ 144 | *(.RamFunc*) /* .RamFunc* sections */ 145 | 146 | . = ALIGN(4); 147 | _edata = .; /* define a global symbol at data end */ 148 | 149 | } >RAM AT> FLASH 150 | 151 | _siccmram = LOADADDR(.ccmram); 152 | 153 | /* CCM-RAM section 154 | * 155 | * IMPORTANT NOTE! 156 | * If initialized variables will be placed in this section, 157 | * the startup code needs to be modified to copy the init-values. 158 | */ 159 | .ccmram : 160 | { 161 | . = ALIGN(4); 162 | _sccmram = .; /* create a global symbol at ccmram start */ 163 | *(.ccmram) 164 | *(.ccmram*) 165 | 166 | . = ALIGN(4); 167 | _eccmram = .; /* create a global symbol at ccmram end */ 168 | } >CCMRAM AT> FLASH 169 | 170 | /* Uninitialized data section into "RAM" Ram type memory */ 171 | . = ALIGN(4); 172 | .bss : 173 | { 174 | /* This is used by the startup in order to initialize the .bss section */ 175 | _sbss = .; /* define a global symbol at bss start */ 176 | __bss_start__ = _sbss; 177 | *(.bss) 178 | *(.bss*) 179 | *(COMMON) 180 | 181 | . = ALIGN(4); 182 | _ebss = .; /* define a global symbol at bss end */ 183 | __bss_end__ = _ebss; 184 | } >RAM 185 | 186 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ 187 | ._user_heap_stack : 188 | { 189 | . = ALIGN(8); 190 | PROVIDE ( end = . ); 191 | PROVIDE ( _end = . ); 192 | . = . + _Min_Heap_Size; 193 | . = . + _Min_Stack_Size; 194 | . = ALIGN(8); 195 | } >RAM 196 | 197 | /* Remove information from the compiler libraries */ 198 | /DISCARD/ : 199 | { 200 | libc.a ( * ) 201 | libm.a ( * ) 202 | libgcc.a ( * ) 203 | } 204 | 205 | .ARM.attributes 0 : { *(.ARM.attributes) } 206 | } 207 | -------------------------------------------------------------------------------- /STM32F415APP/USB_DEVICE/App/usb_device.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usb_device.c 5 | * @version : v1.0_Cube 6 | * @brief : This file implements the USB Device 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 | 23 | #include "usb_device.h" 24 | #include "usbd_core.h" 25 | #include "usbd_desc.h" 26 | #include "usbd_cdc.h" 27 | #include "usbd_cdc_if.h" 28 | 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | /* USER CODE BEGIN PV */ 34 | /* Private variables ---------------------------------------------------------*/ 35 | 36 | /* USER CODE END PV */ 37 | 38 | /* USER CODE BEGIN PFP */ 39 | /* Private function prototypes -----------------------------------------------*/ 40 | 41 | /* USER CODE END PFP */ 42 | 43 | /* USB Device Core handle declaration. */ 44 | USBD_HandleTypeDef hUsbDeviceFS; 45 | 46 | /* 47 | * -- Insert your variables declaration here -- 48 | */ 49 | /* USER CODE BEGIN 0 */ 50 | 51 | /* USER CODE END 0 */ 52 | 53 | /* 54 | * -- Insert your external function declaration here -- 55 | */ 56 | /* USER CODE BEGIN 1 */ 57 | 58 | /* USER CODE END 1 */ 59 | 60 | /** 61 | * Init USB device Library, add supported class and start the library 62 | * @retval None 63 | */ 64 | void MX_USB_DEVICE_Init(void) 65 | { 66 | /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ 67 | 68 | /* USER CODE END USB_DEVICE_Init_PreTreatment */ 69 | 70 | /* Init Device Library, add supported class and start the library. */ 71 | if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) 72 | { 73 | Error_Handler(); 74 | } 75 | if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) 76 | { 77 | Error_Handler(); 78 | } 79 | if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK) 80 | { 81 | Error_Handler(); 82 | } 83 | if (USBD_Start(&hUsbDeviceFS) != USBD_OK) 84 | { 85 | Error_Handler(); 86 | } 87 | 88 | /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ 89 | 90 | /* USER CODE END USB_DEVICE_Init_PostTreatment */ 91 | } 92 | 93 | /** 94 | * @} 95 | */ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | -------------------------------------------------------------------------------- /STM32F415APP/USB_DEVICE/App/usb_device.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usb_device.h 5 | * @version : v1.0_Cube 6 | * @brief : Header for usb_device.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 __USB_DEVICE__H__ 23 | #define __USB_DEVICE__H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32f4xx.h" 31 | #include "stm32f4xx_hal.h" 32 | #include "usbd_def.h" 33 | 34 | /* USER CODE BEGIN INCLUDE */ 35 | 36 | /* USER CODE END INCLUDE */ 37 | 38 | /** @addtogroup USBD_OTG_DRIVER 39 | * @{ 40 | */ 41 | 42 | /** @defgroup USBD_DEVICE USBD_DEVICE 43 | * @brief Device file for Usb otg low level driver. 44 | * @{ 45 | */ 46 | 47 | /** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables 48 | * @brief Public variables. 49 | * @{ 50 | */ 51 | 52 | /* Private variables ---------------------------------------------------------*/ 53 | /* USER CODE BEGIN PV */ 54 | 55 | /* USER CODE END PV */ 56 | 57 | /* Private function prototypes -----------------------------------------------*/ 58 | /* USER CODE BEGIN PFP */ 59 | 60 | /* USER CODE END PFP */ 61 | 62 | /* 63 | * -- Insert your variables declaration here -- 64 | */ 65 | /* USER CODE BEGIN VARIABLES */ 66 | 67 | /* USER CODE END VARIABLES */ 68 | /** 69 | * @} 70 | */ 71 | 72 | /** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype 73 | * @brief Declaration of public functions for Usb device. 74 | * @{ 75 | */ 76 | 77 | /** USB Device initialization function. */ 78 | void MX_USB_DEVICE_Init(void); 79 | 80 | /* 81 | * -- Insert functions declaration here -- 82 | */ 83 | /* USER CODE BEGIN FD */ 84 | 85 | /* USER CODE END FD */ 86 | /** 87 | * @} 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif /* __USB_DEVICE__H__ */ 103 | -------------------------------------------------------------------------------- /STM32F415APP/USB_DEVICE/App/usbd_cdc_if.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_cdc_if.h 5 | * @version : v1.0_Cube 6 | * @brief : Header for usbd_cdc_if.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 | 23 | #ifndef __USBD_CDC_IF_H__ 24 | #define __USBD_CDC_IF_H__ 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "usbd_cdc.h" 32 | 33 | /* USER CODE BEGIN INCLUDE */ 34 | 35 | /* USER CODE END INCLUDE */ 36 | 37 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 38 | * @brief For Usb device. 39 | * @{ 40 | */ 41 | 42 | /** @defgroup USBD_CDC_IF USBD_CDC_IF 43 | * @brief Usb VCP device module 44 | * @{ 45 | */ 46 | 47 | /** @defgroup USBD_CDC_IF_Exported_Defines USBD_CDC_IF_Exported_Defines 48 | * @brief Defines. 49 | * @{ 50 | */ 51 | /* Define size for the receive and transmit buffer over CDC */ 52 | #define APP_RX_DATA_SIZE 2048 53 | #define APP_TX_DATA_SIZE 2048 54 | /* USER CODE BEGIN EXPORTED_DEFINES */ 55 | 56 | /* USER CODE END EXPORTED_DEFINES */ 57 | 58 | /** 59 | * @} 60 | */ 61 | 62 | /** @defgroup USBD_CDC_IF_Exported_Types USBD_CDC_IF_Exported_Types 63 | * @brief Types. 64 | * @{ 65 | */ 66 | 67 | /* USER CODE BEGIN EXPORTED_TYPES */ 68 | 69 | /* USER CODE END EXPORTED_TYPES */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USBD_CDC_IF_Exported_Macros USBD_CDC_IF_Exported_Macros 76 | * @brief Aliases. 77 | * @{ 78 | */ 79 | 80 | /* USER CODE BEGIN EXPORTED_MACRO */ 81 | 82 | /* USER CODE END EXPORTED_MACRO */ 83 | 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables 89 | * @brief Public variables. 90 | * @{ 91 | */ 92 | 93 | /** CDC Interface callback. */ 94 | extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS; 95 | 96 | /* USER CODE BEGIN EXPORTED_VARIABLES */ 97 | 98 | /* USER CODE END EXPORTED_VARIABLES */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | /** @defgroup USBD_CDC_IF_Exported_FunctionsPrototype USBD_CDC_IF_Exported_FunctionsPrototype 105 | * @brief Public functions declaration. 106 | * @{ 107 | */ 108 | 109 | uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len); 110 | 111 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */ 112 | 113 | /* USER CODE END EXPORTED_FUNCTIONS */ 114 | 115 | /** 116 | * @} 117 | */ 118 | 119 | /** 120 | * @} 121 | */ 122 | 123 | /** 124 | * @} 125 | */ 126 | 127 | #ifdef __cplusplus 128 | } 129 | #endif 130 | 131 | #endif /* __USBD_CDC_IF_H__ */ 132 | 133 | -------------------------------------------------------------------------------- /STM32F415APP/USB_DEVICE/App/usbd_desc.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_desc.c 5 | * @version : v1.0_Cube 6 | * @brief : Header for usbd_conf.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USBD_DESC__C__ 22 | #define __USBD_DESC__C__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_def.h" 30 | 31 | /* USER CODE BEGIN INCLUDE */ 32 | 33 | /* USER CODE END INCLUDE */ 34 | 35 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 36 | * @{ 37 | */ 38 | 39 | /** @defgroup USBD_DESC USBD_DESC 40 | * @brief Usb device descriptors module. 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants 45 | * @brief Constants. 46 | * @{ 47 | */ 48 | #define DEVICE_ID1 (UID_BASE) 49 | #define DEVICE_ID2 (UID_BASE + 0x4) 50 | #define DEVICE_ID3 (UID_BASE + 0x8) 51 | 52 | #define USB_SIZ_STRING_SERIAL 0x1A 53 | 54 | /* USER CODE BEGIN EXPORTED_CONSTANTS */ 55 | 56 | /* USER CODE END EXPORTED_CONSTANTS */ 57 | 58 | /** 59 | * @} 60 | */ 61 | 62 | /** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines 63 | * @brief Defines. 64 | * @{ 65 | */ 66 | 67 | /* USER CODE BEGIN EXPORTED_DEFINES */ 68 | 69 | /* USER CODE END EXPORTED_DEFINES */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions 76 | * @brief Types. 77 | * @{ 78 | */ 79 | 80 | /* USER CODE BEGIN EXPORTED_TYPES */ 81 | 82 | /* USER CODE END EXPORTED_TYPES */ 83 | 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros 89 | * @brief Aliases. 90 | * @{ 91 | */ 92 | 93 | /* USER CODE BEGIN EXPORTED_MACRO */ 94 | 95 | /* USER CODE END EXPORTED_MACRO */ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | /** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables 102 | * @brief Public variables. 103 | * @{ 104 | */ 105 | 106 | /** Descriptor for the Usb device. */ 107 | extern USBD_DescriptorsTypeDef FS_Desc; 108 | 109 | /* USER CODE BEGIN EXPORTED_VARIABLES */ 110 | 111 | /* USER CODE END EXPORTED_VARIABLES */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype 118 | * @brief Public functions declaration. 119 | * @{ 120 | */ 121 | 122 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */ 123 | 124 | /* USER CODE END EXPORTED_FUNCTIONS */ 125 | 126 | /** 127 | * @} 128 | */ 129 | 130 | /** 131 | * @} 132 | */ 133 | 134 | /** 135 | * @} 136 | */ 137 | 138 | #ifdef __cplusplus 139 | } 140 | #endif 141 | 142 | #endif /* __USBD_DESC__C__ */ 143 | 144 | -------------------------------------------------------------------------------- /STM32F415APP/USB_DEVICE/Target/usbd_conf.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_conf.h 5 | * @version : v1.0_Cube 6 | * @brief : Header for usbd_conf.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 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 __USBD_CONF__H__ 23 | #define __USBD_CONF__H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include 31 | #include 32 | #include 33 | #include "main.h" 34 | #include "stm32f4xx.h" 35 | #include "stm32f4xx_hal.h" 36 | 37 | /* USER CODE BEGIN INCLUDE */ 38 | 39 | /* USER CODE END INCLUDE */ 40 | 41 | /** @addtogroup USBD_OTG_DRIVER 42 | * @brief Driver for Usb device. 43 | * @{ 44 | */ 45 | 46 | /** @defgroup USBD_CONF USBD_CONF 47 | * @brief Configuration file for Usb otg low level driver. 48 | * @{ 49 | */ 50 | 51 | /** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables 52 | * @brief Public variables. 53 | * @{ 54 | */ 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | /** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines 61 | * @brief Defines for configuration of the Usb device. 62 | * @{ 63 | */ 64 | 65 | /*---------- -----------*/ 66 | #define USBD_MAX_NUM_INTERFACES 1U 67 | /*---------- -----------*/ 68 | #define USBD_MAX_NUM_CONFIGURATION 1U 69 | /*---------- -----------*/ 70 | #define USBD_MAX_STR_DESC_SIZ 512U 71 | /*---------- -----------*/ 72 | #define USBD_DEBUG_LEVEL 0U 73 | /*---------- -----------*/ 74 | #define USBD_LPM_ENABLED 0U 75 | /*---------- -----------*/ 76 | #define USBD_SELF_POWERED 1U 77 | 78 | /****************************************/ 79 | /* #define for FS and HS identification */ 80 | #define DEVICE_FS 0 81 | #define DEVICE_HS 1 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | /** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros 88 | * @brief Aliases. 89 | * @{ 90 | */ 91 | /* Memory management macros make sure to use static memory allocation */ 92 | /** Alias for memory allocation. */ 93 | 94 | #define USBD_malloc (void *)USBD_static_malloc 95 | 96 | /** Alias for memory release. */ 97 | #define USBD_free USBD_static_free 98 | 99 | /** Alias for memory set. */ 100 | #define USBD_memset memset 101 | 102 | /** Alias for memory copy. */ 103 | #define USBD_memcpy memcpy 104 | 105 | /** Alias for delay. */ 106 | #define USBD_Delay HAL_Delay 107 | 108 | /* DEBUG macros */ 109 | 110 | #if (USBD_DEBUG_LEVEL > 0) 111 | #define USBD_UsrLog(...) printf(__VA_ARGS__);\ 112 | printf("\n"); 113 | #else 114 | #define USBD_UsrLog(...) 115 | #endif /* (USBD_DEBUG_LEVEL > 0U) */ 116 | 117 | #if (USBD_DEBUG_LEVEL > 1) 118 | 119 | #define USBD_ErrLog(...) printf("ERROR: ");\ 120 | printf(__VA_ARGS__);\ 121 | printf("\n"); 122 | #else 123 | #define USBD_ErrLog(...) 124 | #endif /* (USBD_DEBUG_LEVEL > 1U) */ 125 | 126 | #if (USBD_DEBUG_LEVEL > 2) 127 | #define USBD_DbgLog(...) printf("DEBUG : ");\ 128 | printf(__VA_ARGS__);\ 129 | printf("\n"); 130 | #else 131 | #define USBD_DbgLog(...) 132 | #endif /* (USBD_DEBUG_LEVEL > 2U) */ 133 | 134 | /** 135 | * @} 136 | */ 137 | 138 | /** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types 139 | * @brief Types. 140 | * @{ 141 | */ 142 | 143 | /** 144 | * @} 145 | */ 146 | 147 | /** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype 148 | * @brief Declaration of public functions for Usb device. 149 | * @{ 150 | */ 151 | 152 | /* Exported functions -------------------------------------------------------*/ 153 | void *USBD_static_malloc(uint32_t size); 154 | void USBD_static_free(void *p); 155 | 156 | /** 157 | * @} 158 | */ 159 | 160 | /** 161 | * @} 162 | */ 163 | 164 | /** 165 | * @} 166 | */ 167 | 168 | #ifdef __cplusplus 169 | } 170 | #endif 171 | 172 | #endif /* __USBD_CONF__H__ */ 173 | 174 | --------------------------------------------------------------------------------