├── .gitignore ├── LICENSE ├── README.md ├── fw ├── sample_target │ ├── .gitignore │ ├── Core │ │ ├── Inc │ │ │ ├── adc.h │ │ │ ├── gpio.h │ │ │ ├── main.h │ │ │ ├── stm32_assert.h │ │ │ ├── stm32l4xx_hal_conf.h │ │ │ └── stm32l4xx_it.h │ │ └── Src │ │ │ ├── adc.c │ │ │ ├── gpio.c │ │ │ ├── main.c │ │ │ ├── stm32l4xx_hal_msp.c │ │ │ ├── stm32l4xx_it.c │ │ │ └── system_stm32l4xx.c │ ├── Drivers │ │ ├── CMSIS │ │ │ ├── Device │ │ │ │ └── ST │ │ │ │ │ └── STM32L4xx │ │ │ │ │ ├── Include │ │ │ │ │ ├── stm32l412xx.h │ │ │ │ │ ├── stm32l4xx.h │ │ │ │ │ └── system_stm32l4xx.h │ │ │ │ │ ├── LICENSE.txt │ │ │ │ │ └── License.md │ │ │ ├── Include │ │ │ │ ├── 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_cm7.h │ │ │ │ ├── core_sc000.h │ │ │ │ ├── core_sc300.h │ │ │ │ ├── mpu_armv7.h │ │ │ │ ├── mpu_armv8.h │ │ │ │ └── tz_context.h │ │ │ └── LICENSE.txt │ │ └── STM32L4xx_HAL_Driver │ │ │ ├── Inc │ │ │ ├── Legacy │ │ │ │ └── stm32_hal_legacy.h │ │ │ ├── stm32l4xx_hal.h │ │ │ ├── stm32l4xx_hal_cortex.h │ │ │ ├── stm32l4xx_hal_def.h │ │ │ ├── stm32l4xx_hal_dma.h │ │ │ ├── stm32l4xx_hal_dma_ex.h │ │ │ ├── stm32l4xx_hal_exti.h │ │ │ ├── stm32l4xx_hal_flash.h │ │ │ ├── stm32l4xx_hal_flash_ex.h │ │ │ ├── stm32l4xx_hal_flash_ramfunc.h │ │ │ ├── stm32l4xx_hal_gpio.h │ │ │ ├── stm32l4xx_hal_gpio_ex.h │ │ │ ├── stm32l4xx_hal_i2c.h │ │ │ ├── stm32l4xx_hal_i2c_ex.h │ │ │ ├── stm32l4xx_hal_pcd.h │ │ │ ├── stm32l4xx_hal_pcd_ex.h │ │ │ ├── stm32l4xx_hal_pwr.h │ │ │ ├── stm32l4xx_hal_pwr_ex.h │ │ │ ├── stm32l4xx_hal_rcc.h │ │ │ ├── stm32l4xx_hal_rcc_ex.h │ │ │ ├── stm32l4xx_hal_tim.h │ │ │ ├── stm32l4xx_hal_tim_ex.h │ │ │ ├── stm32l4xx_ll_adc.h │ │ │ ├── stm32l4xx_ll_bus.h │ │ │ ├── stm32l4xx_ll_cortex.h │ │ │ ├── stm32l4xx_ll_crs.h │ │ │ ├── stm32l4xx_ll_dma.h │ │ │ ├── stm32l4xx_ll_dmamux.h │ │ │ ├── stm32l4xx_ll_exti.h │ │ │ ├── stm32l4xx_ll_gpio.h │ │ │ ├── stm32l4xx_ll_pwr.h │ │ │ ├── stm32l4xx_ll_rcc.h │ │ │ ├── stm32l4xx_ll_system.h │ │ │ ├── stm32l4xx_ll_usb.h │ │ │ └── stm32l4xx_ll_utils.h │ │ │ ├── LICENSE.txt │ │ │ ├── License.md │ │ │ └── Src │ │ │ ├── stm32l4xx_hal.c │ │ │ ├── stm32l4xx_hal_cortex.c │ │ │ ├── stm32l4xx_hal_dma.c │ │ │ ├── stm32l4xx_hal_dma_ex.c │ │ │ ├── stm32l4xx_hal_exti.c │ │ │ ├── stm32l4xx_hal_flash.c │ │ │ ├── stm32l4xx_hal_flash_ex.c │ │ │ ├── stm32l4xx_hal_flash_ramfunc.c │ │ │ ├── stm32l4xx_hal_gpio.c │ │ │ ├── stm32l4xx_hal_i2c.c │ │ │ ├── stm32l4xx_hal_i2c_ex.c │ │ │ ├── stm32l4xx_hal_pcd.c │ │ │ ├── stm32l4xx_hal_pcd_ex.c │ │ │ ├── stm32l4xx_hal_pwr.c │ │ │ ├── stm32l4xx_hal_pwr_ex.c │ │ │ ├── stm32l4xx_hal_rcc.c │ │ │ ├── stm32l4xx_hal_rcc_ex.c │ │ │ ├── stm32l4xx_hal_tim.c │ │ │ ├── stm32l4xx_hal_tim_ex.c │ │ │ ├── stm32l4xx_ll_adc.c │ │ │ ├── stm32l4xx_ll_dma.c │ │ │ ├── stm32l4xx_ll_exti.c │ │ │ ├── stm32l4xx_ll_gpio.c │ │ │ ├── stm32l4xx_ll_usb.c │ │ │ └── stm32l4xx_ll_utils.c │ ├── Makefile │ ├── 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 │ ├── STM32L412C8Tx_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 │ ├── sample_target.ioc │ └── startup_stm32l412xx.s └── swd_over_usb_c │ ├── .gitignore │ ├── Makefile │ └── main.c ├── hw ├── docs │ └── rpu_calc.ods ├── sample_target │ ├── sample_target.kicad_pcb │ ├── sample_target.kicad_prl │ ├── sample_target.kicad_pro │ └── sample_target.kicad_sch ├── swd_over_c │ ├── swd_over_c.kicad_pcb │ ├── swd_over_c.kicad_prl │ ├── swd_over_c.kicad_pro │ └── swd_over_c.kicad_sch ├── swd_over_c_pogo │ ├── swd_over_c_pogo.kicad_pcb │ ├── swd_over_c_pogo.kicad_prl │ ├── swd_over_c_pogo.kicad_pro │ └── swd_over_c_pogo.kicad_sch ├── swd_switch │ ├── swd_switch.kicad_pcb │ ├── swd_switch.kicad_prl │ ├── swd_switch.kicad_pro │ └── swd_switch.kicad_sch └── usb_switch │ ├── usb_hub.kicad_sch │ ├── usb_power.kicad_sch │ ├── usb_switch.kicad_pcb │ ├── usb_switch.kicad_prl │ ├── usb_switch.kicad_pro │ └── usb_switch.kicad_sch └── img ├── IMG_2371.jpg ├── IMG_2372.jpg ├── IMG_2373.jpg ├── IMG_2376.jpg ├── IMG_2380.jpg ├── IMG_2494.jpg ├── IMG_2495.jpg └── IMG_2498.jpg /.gitignore: -------------------------------------------------------------------------------- 1 | *-backups 2 | *-bak 3 | *.zip 4 | gerbers/ 5 | gerber/ 6 | fp-info-cache 7 | _autosave* 8 | *auto_saved* 9 | *.csv 10 | *.xml 11 | *.pdf 12 | *.html -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2022, Alvaro Prieto 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Debugotron! 2 | 3 | Debugotron is a collection of debugging/automation tools I've wanted in the past but didn't have access to. Currently, the tools include: 4 | 5 | ## SWD to USB-C! 6 | 7 | ![SWD to USB-C Side 1](img/IMG_2371.jpg) ![SWD to USB-C Side 2](img/IMG_2372.jpg) 8 | 9 | Have you ever wanted to debug your device over USB-C? Sometimes there's not enough room for a JTAG/SWD connector, or even TAGConnect pads! The USB-C specification has a Debug Accessory Mode feature that allows for this. I have a [Twitter thread](https://twitter.com/alvaroprieto/status/1495860045728395278) with additional details. [Here's an unrolled version for easier reading.](https://threadreaderapp.com/thread/1495860045728395278.html) 10 | 11 | ### SWD to USB-C Programmer 12 | Since the current adapter uses an ATTiny24a, I made a different programmer adapter for it 13 | 14 | ![SWD to USB-C Programmer](img/IMG_2380.jpg) 15 | 16 | ### Example Target 17 | This is a simple STM32L4 board that implements USB-C DAM (the "proper way") as an example. 18 | 19 | ![SWD to USB-C Example Target](img/IMG_2373.jpg) 20 | 21 | ![SWD to USB-C Example Target in Use](img/IMG_2376.jpg) 22 | 23 | ## SWD Switch 24 | Tool that allows connecting/disconnecting the SWD/JTAG lines (Via ARM 10-pin connector) with a pushbutton (or external signal). This can be useful when trying to measure ultra low power consumption on a device while the debugger is connected (but not necessarily running/attached). 25 | 26 | ![SWD Switch Side 1](img/IMG_2494.jpg) ![SWD Switch Side 2](img/IMG_2495.jpg) 27 | 28 | ## USB-C Switch 29 | This one is more of an automation tool. I've always wanted to automate firmware testing. Sometimes, having USB connected is necessary to program/communicate with a device, but at the same time, having USB connected changes the power characteristics of the test (or just operating mode). 30 | 31 | For example, you might want to automatically test the power consumption of a battery powered device every night with the latest firmware. In order to run the test, you might have to connect to the device, flash it, then disconnect USB. The USB-C switch will allow software-controlled power and data connect/disconnects to a USB-C device. Depending on the configuration, it will also allow full 20V@5A pass-through by allowing USB-PD communication over the CC lines. 32 | 33 | In the cases where you want to communicate with a device over USB while still powering it via 20V (or anything higher than 5V), a USB switch allows for a different USB cable to be used for data only, while power is taken from a separate USB-C port. 34 | 35 | ![USB-C Switch (Bare PCB)](img/IMG_2498.jpg) 36 | -------------------------------------------------------------------------------- /fw/sample_target/.gitignore: -------------------------------------------------------------------------------- 1 | .mxproject 2 | build/ 3 | -------------------------------------------------------------------------------- /fw/sample_target/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) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* 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 | /* USER CODE BEGIN Private defines */ 36 | 37 | /* USER CODE END Private defines */ 38 | 39 | void MX_ADC1_Init(void); 40 | 41 | /* USER CODE BEGIN Prototypes */ 42 | 43 | /* USER CODE END Prototypes */ 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif /* __ADC_H__ */ 50 | 51 | -------------------------------------------------------------------------------- /fw/sample_target/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) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* 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 | -------------------------------------------------------------------------------- /fw/sample_target/Core/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __MAIN_H 23 | #define __MAIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32l4xx_hal.h" 31 | 32 | #include "stm32l4xx_ll_adc.h" 33 | #include "stm32l4xx_ll_crs.h" 34 | #include "stm32l4xx_ll_rcc.h" 35 | #include "stm32l4xx_ll_bus.h" 36 | #include "stm32l4xx_ll_system.h" 37 | #include "stm32l4xx_ll_exti.h" 38 | #include "stm32l4xx_ll_cortex.h" 39 | #include "stm32l4xx_ll_utils.h" 40 | #include "stm32l4xx_ll_pwr.h" 41 | #include "stm32l4xx_ll_dma.h" 42 | #include "stm32l4xx_ll_gpio.h" 43 | 44 | /* Private includes ----------------------------------------------------------*/ 45 | /* USER CODE BEGIN Includes */ 46 | 47 | /* USER CODE END Includes */ 48 | 49 | /* Exported types ------------------------------------------------------------*/ 50 | /* USER CODE BEGIN ET */ 51 | 52 | /* USER CODE END ET */ 53 | 54 | /* Exported constants --------------------------------------------------------*/ 55 | /* USER CODE BEGIN EC */ 56 | 57 | /* USER CODE END EC */ 58 | 59 | /* Exported macro ------------------------------------------------------------*/ 60 | /* USER CODE BEGIN EM */ 61 | 62 | /* USER CODE END EM */ 63 | 64 | /* Exported functions prototypes ---------------------------------------------*/ 65 | void Error_Handler(void); 66 | 67 | /* USER CODE BEGIN EFP */ 68 | 69 | /* USER CODE END EFP */ 70 | 71 | /* Private defines -----------------------------------------------------------*/ 72 | #define LED1_Pin LL_GPIO_PIN_0 73 | #define LED1_GPIO_Port GPIOB 74 | #define LED2_Pin LL_GPIO_PIN_1 75 | #define LED2_GPIO_Port GPIOB 76 | #define BOOT_Pin LL_GPIO_PIN_3 77 | #define BOOT_GPIO_Port GPIOH 78 | /* USER CODE BEGIN Private defines */ 79 | 80 | /* USER CODE END Private defines */ 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* __MAIN_H */ 87 | -------------------------------------------------------------------------------- /fw/sample_target/Core/Inc/stm32_assert.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32_assert.h 5 | * @brief STM32 assert file. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2018 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 __STM32_ASSERT_H 22 | #define __STM32_ASSERT_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Exported types ------------------------------------------------------------*/ 29 | /* Exported constants --------------------------------------------------------*/ 30 | /* Includes ------------------------------------------------------------------*/ 31 | /* Exported macro ------------------------------------------------------------*/ 32 | #ifdef USE_FULL_ASSERT 33 | /** 34 | * @brief The assert_param macro is used for function's parameters check. 35 | * @param expr: If expr is false, it calls assert_failed function 36 | * which reports the name of the source file and the source 37 | * line number of the call that failed. 38 | * If expr is true, it returns no value. 39 | * @retval None 40 | */ 41 | #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) 42 | /* Exported functions ------------------------------------------------------- */ 43 | void assert_failed(uint8_t* file, uint32_t line); 44 | #else 45 | #define assert_param(expr) ((void)0U) 46 | #endif /* USE_FULL_ASSERT */ 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* __STM32_ASSERT_H */ 53 | 54 | -------------------------------------------------------------------------------- /fw/sample_target/Core/Inc/stm32l4xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32l4xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2022 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32L4xx_IT_H 22 | #define __STM32L4xx_IT_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Private includes ----------------------------------------------------------*/ 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN ET */ 35 | 36 | /* USER CODE END ET */ 37 | 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* USER CODE BEGIN EC */ 40 | 41 | /* USER CODE END EC */ 42 | 43 | /* Exported macro ------------------------------------------------------------*/ 44 | /* USER CODE BEGIN EM */ 45 | 46 | /* USER CODE END EM */ 47 | 48 | /* Exported functions prototypes ---------------------------------------------*/ 49 | void NMI_Handler(void); 50 | void HardFault_Handler(void); 51 | void MemManage_Handler(void); 52 | void BusFault_Handler(void); 53 | void UsageFault_Handler(void); 54 | void SVC_Handler(void); 55 | void DebugMon_Handler(void); 56 | void PendSV_Handler(void); 57 | void SysTick_Handler(void); 58 | void USB_IRQHandler(void); 59 | /* USER CODE BEGIN EFP */ 60 | 61 | /* USER CODE END EFP */ 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif /* __STM32L4xx_IT_H */ 68 | -------------------------------------------------------------------------------- /fw/sample_target/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) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "adc.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | /* ADC1 init function */ 28 | void MX_ADC1_Init(void) 29 | { 30 | 31 | /* USER CODE BEGIN ADC1_Init 0 */ 32 | 33 | /* USER CODE END ADC1_Init 0 */ 34 | 35 | LL_ADC_InitTypeDef ADC_InitStruct = {0}; 36 | LL_ADC_REG_InitTypeDef ADC_REG_InitStruct = {0}; 37 | LL_ADC_CommonInitTypeDef ADC_CommonInitStruct = {0}; 38 | 39 | LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; 40 | 41 | /* Peripheral clock enable */ 42 | LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_ADC); 43 | 44 | LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); 45 | /**ADC1 GPIO Configuration 46 | PA0 ------> ADC1_IN5 47 | PA1 ------> ADC1_IN6 48 | */ 49 | GPIO_InitStruct.Pin = LL_GPIO_PIN_0|LL_GPIO_PIN_1; 50 | GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; 51 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; 52 | LL_GPIO_Init(GPIOA, &GPIO_InitStruct); 53 | 54 | /* USER CODE BEGIN ADC1_Init 1 */ 55 | 56 | /* USER CODE END ADC1_Init 1 */ 57 | /** Common config 58 | */ 59 | ADC_InitStruct.Resolution = LL_ADC_RESOLUTION_12B; 60 | ADC_InitStruct.DataAlignment = LL_ADC_DATA_ALIGN_RIGHT; 61 | ADC_InitStruct.LowPowerMode = LL_ADC_LP_MODE_NONE; 62 | LL_ADC_Init(ADC1, &ADC_InitStruct); 63 | ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_SOFTWARE; 64 | ADC_REG_InitStruct.SequencerLength = LL_ADC_REG_SEQ_SCAN_DISABLE; 65 | ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE; 66 | ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_SINGLE; 67 | ADC_REG_InitStruct.DMATransfer = LL_ADC_REG_DMA_TRANSFER_NONE; 68 | ADC_REG_InitStruct.Overrun = LL_ADC_REG_OVR_DATA_PRESERVED; 69 | LL_ADC_REG_Init(ADC1, &ADC_REG_InitStruct); 70 | ADC_CommonInitStruct.CommonClock = LL_ADC_CLOCK_ASYNC_DIV1; 71 | ADC_CommonInitStruct.Multimode = LL_ADC_MULTI_INDEPENDENT; 72 | LL_ADC_CommonInit(__LL_ADC_COMMON_INSTANCE(ADC1), &ADC_CommonInitStruct); 73 | LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(ADC1), LL_ADC_PATH_INTERNAL_NONE); 74 | 75 | /* Disable ADC deep power down (enabled by default after reset state) */ 76 | LL_ADC_DisableDeepPowerDown(ADC1); 77 | /* Enable ADC internal voltage regulator */ 78 | LL_ADC_EnableInternalRegulator(ADC1); 79 | /* Delay for ADC internal voltage regulator stabilization. */ 80 | /* Compute number of CPU cycles to wait for, from delay in us. */ 81 | /* Note: Variable divided by 2 to compensate partially */ 82 | /* CPU processing cycles (depends on compilation optimization). */ 83 | /* Note: If system core clock frequency is below 200kHz, wait time */ 84 | /* is only a few CPU processing cycles. */ 85 | uint32_t wait_loop_index; 86 | wait_loop_index = ((LL_ADC_DELAY_INTERNAL_REGUL_STAB_US * (SystemCoreClock / (100000 * 2))) / 10); 87 | while(wait_loop_index != 0) 88 | { 89 | wait_loop_index--; 90 | } 91 | /** Configure Regular Channel 92 | */ 93 | LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_1, LL_ADC_CHANNEL_5); 94 | LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_5, LL_ADC_SAMPLINGTIME_2CYCLES_5); 95 | LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_5, LL_ADC_SINGLE_ENDED); 96 | /* USER CODE BEGIN ADC1_Init 2 */ 97 | 98 | /* USER CODE END ADC1_Init 2 */ 99 | 100 | } 101 | 102 | /* USER CODE BEGIN 1 */ 103 | 104 | /* USER CODE END 1 */ 105 | -------------------------------------------------------------------------------- /fw/sample_target/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) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "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 36 | */ 37 | void MX_GPIO_Init(void) 38 | { 39 | 40 | LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; 41 | 42 | /* GPIO Ports Clock Enable */ 43 | LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); 44 | LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); 45 | LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOH); 46 | 47 | /**/ 48 | LL_GPIO_ResetOutputPin(GPIOB, LL_GPIO_PIN_0|LL_GPIO_PIN_1); 49 | 50 | /**/ 51 | GPIO_InitStruct.Pin = LL_GPIO_PIN_0|LL_GPIO_PIN_1; 52 | GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; 53 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; 54 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; 55 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; 56 | LL_GPIO_Init(GPIOB, &GPIO_InitStruct); 57 | 58 | /**/ 59 | GPIO_InitStruct.Pin = LL_GPIO_PIN_3; 60 | GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; 61 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; 62 | LL_GPIO_Init(GPIOH, &GPIO_InitStruct); 63 | 64 | } 65 | 66 | /* USER CODE BEGIN 2 */ 67 | 68 | /* USER CODE END 2 */ 69 | -------------------------------------------------------------------------------- /fw/sample_target/Core/Src/main.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.c 5 | * @brief : Main program body 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2022 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | /* Includes ------------------------------------------------------------------*/ 20 | #include "main.h" 21 | #include "adc.h" 22 | #include "usb_device.h" 23 | #include "gpio.h" 24 | 25 | /* Private includes ----------------------------------------------------------*/ 26 | /* USER CODE BEGIN Includes */ 27 | 28 | /* USER CODE END Includes */ 29 | 30 | /* Private typedef -----------------------------------------------------------*/ 31 | /* USER CODE BEGIN PTD */ 32 | 33 | /* USER CODE END PTD */ 34 | 35 | /* Private define ------------------------------------------------------------*/ 36 | /* USER CODE BEGIN PD */ 37 | /* USER CODE END PD */ 38 | 39 | /* Private macro -------------------------------------------------------------*/ 40 | /* USER CODE BEGIN PM */ 41 | 42 | /* USER CODE END PM */ 43 | 44 | /* Private variables ---------------------------------------------------------*/ 45 | 46 | /* USER CODE BEGIN PV */ 47 | 48 | /* USER CODE END PV */ 49 | 50 | /* Private function prototypes -----------------------------------------------*/ 51 | void SystemClock_Config(void); 52 | /* USER CODE BEGIN PFP */ 53 | 54 | /* USER CODE END PFP */ 55 | 56 | /* Private user code ---------------------------------------------------------*/ 57 | /* USER CODE BEGIN 0 */ 58 | 59 | /* USER CODE END 0 */ 60 | 61 | /** 62 | * @brief The application entry point. 63 | * @retval int 64 | */ 65 | int main(void) 66 | { 67 | /* USER CODE BEGIN 1 */ 68 | 69 | /* USER CODE END 1 */ 70 | 71 | /* MCU Configuration--------------------------------------------------------*/ 72 | 73 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 74 | HAL_Init(); 75 | 76 | /* USER CODE BEGIN Init */ 77 | 78 | /* USER CODE END Init */ 79 | 80 | /* Configure the system clock */ 81 | SystemClock_Config(); 82 | 83 | /* USER CODE BEGIN SysInit */ 84 | 85 | /* USER CODE END SysInit */ 86 | 87 | /* Initialize all configured peripherals */ 88 | MX_GPIO_Init(); 89 | MX_ADC1_Init(); 90 | MX_USB_DEVICE_Init(); 91 | /* USER CODE BEGIN 2 */ 92 | 93 | /* USER CODE END 2 */ 94 | 95 | /* Infinite loop */ 96 | /* USER CODE BEGIN WHILE */ 97 | while (1) 98 | { 99 | /* USER CODE END WHILE */ 100 | 101 | /* USER CODE BEGIN 3 */ 102 | LL_GPIO_ResetOutputPin(LED1_GPIO_Port, LED1_Pin); 103 | LL_GPIO_SetOutputPin(LED2_GPIO_Port, LED2_Pin); 104 | HAL_Delay(500); 105 | LL_GPIO_SetOutputPin(LED1_GPIO_Port, LED1_Pin); 106 | LL_GPIO_ResetOutputPin(LED2_GPIO_Port, LED2_Pin); 107 | HAL_Delay(500); 108 | } 109 | /* USER CODE END 3 */ 110 | } 111 | 112 | /** 113 | * @brief System Clock Configuration 114 | * @retval None 115 | */ 116 | void SystemClock_Config(void) 117 | { 118 | LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); 119 | while(LL_FLASH_GetLatency()!= LL_FLASH_LATENCY_4) 120 | { 121 | } 122 | LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1); 123 | LL_RCC_HSI_Enable(); 124 | 125 | /* Wait till HSI is ready */ 126 | while(LL_RCC_HSI_IsReady() != 1) 127 | { 128 | 129 | } 130 | LL_RCC_HSI_SetCalibTrimming(64); 131 | LL_RCC_MSI_Enable(); 132 | 133 | /* Wait till MSI is ready */ 134 | while(LL_RCC_MSI_IsReady() != 1) 135 | { 136 | 137 | } 138 | LL_RCC_MSI_EnableRangeSelection(); 139 | LL_RCC_MSI_SetRange(LL_RCC_MSIRANGE_11); 140 | LL_RCC_MSI_SetCalibTrimming(0); 141 | LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_1, 10, LL_RCC_PLLR_DIV_2); 142 | LL_RCC_PLL_EnableDomain_SYS(); 143 | LL_RCC_PLL_Enable(); 144 | 145 | /* Wait till PLL is ready */ 146 | while(LL_RCC_PLL_IsReady() != 1) 147 | { 148 | 149 | } 150 | LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); 151 | 152 | /* Wait till System clock is ready */ 153 | while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) 154 | { 155 | 156 | } 157 | LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); 158 | LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); 159 | LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); 160 | LL_SetSystemCoreClock(80000000); 161 | 162 | /* Update the time base */ 163 | if (HAL_InitTick (TICK_INT_PRIORITY) != HAL_OK) 164 | { 165 | Error_Handler(); 166 | } 167 | } 168 | 169 | /* USER CODE BEGIN 4 */ 170 | 171 | /* USER CODE END 4 */ 172 | 173 | /** 174 | * @brief This function is executed in case of error occurrence. 175 | * @retval None 176 | */ 177 | void Error_Handler(void) 178 | { 179 | /* USER CODE BEGIN Error_Handler_Debug */ 180 | /* User can add his own implementation to report the HAL error return state */ 181 | __disable_irq(); 182 | while (1) 183 | { 184 | } 185 | /* USER CODE END Error_Handler_Debug */ 186 | } 187 | 188 | #ifdef USE_FULL_ASSERT 189 | /** 190 | * @brief Reports the name of the source file and the source line number 191 | * where the assert_param error has occurred. 192 | * @param file: pointer to the source file name 193 | * @param line: assert_param error line source number 194 | * @retval None 195 | */ 196 | void assert_failed(uint8_t *file, uint32_t line) 197 | { 198 | /* USER CODE BEGIN 6 */ 199 | /* User can add his own implementation to report the file name and line number, 200 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 201 | /* USER CODE END 6 */ 202 | } 203 | #endif /* USE_FULL_ASSERT */ 204 | 205 | -------------------------------------------------------------------------------- /fw/sample_target/Core/Src/stm32l4xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32l4xx_hal_msp.c 5 | * @brief This file provides code for the MSP Initialization 6 | * and de-Initialization codes. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | /* USER CODE BEGIN Includes */ 24 | 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN Define */ 34 | 35 | /* USER CODE END Define */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN Macro */ 39 | 40 | /* USER CODE END Macro */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* External functions --------------------------------------------------------*/ 53 | /* USER CODE BEGIN ExternalFunctions */ 54 | 55 | /* USER CODE END ExternalFunctions */ 56 | 57 | /* USER CODE BEGIN 0 */ 58 | 59 | /* USER CODE END 0 */ 60 | /** 61 | * Initializes the Global MSP. 62 | */ 63 | void HAL_MspInit(void) 64 | { 65 | /* USER CODE BEGIN MspInit 0 */ 66 | 67 | /* USER CODE END MspInit 0 */ 68 | 69 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 70 | __HAL_RCC_PWR_CLK_ENABLE(); 71 | 72 | /* System interrupt init*/ 73 | 74 | /* USER CODE BEGIN MspInit 1 */ 75 | 76 | /* USER CODE END MspInit 1 */ 77 | } 78 | 79 | /* USER CODE BEGIN 1 */ 80 | 81 | /* USER CODE END 1 */ 82 | 83 | -------------------------------------------------------------------------------- /fw/sample_target/Core/Src/stm32l4xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32l4xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2022 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "main.h" 22 | #include "stm32l4xx_it.h" 23 | /* Private includes ----------------------------------------------------------*/ 24 | /* USER CODE BEGIN Includes */ 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN PD */ 34 | 35 | /* USER CODE END PD */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN PM */ 39 | 40 | /* USER CODE END PM */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* Private user code ---------------------------------------------------------*/ 53 | /* USER CODE BEGIN 0 */ 54 | 55 | /* USER CODE END 0 */ 56 | 57 | /* External variables --------------------------------------------------------*/ 58 | extern PCD_HandleTypeDef hpcd_USB_FS; 59 | /* USER CODE BEGIN EV */ 60 | 61 | /* USER CODE END EV */ 62 | 63 | /******************************************************************************/ 64 | /* Cortex-M4 Processor Interruption and Exception Handlers */ 65 | /******************************************************************************/ 66 | /** 67 | * @brief This function handles Non maskable interrupt. 68 | */ 69 | void NMI_Handler(void) 70 | { 71 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 72 | 73 | /* USER CODE END NonMaskableInt_IRQn 0 */ 74 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 75 | while (1) 76 | { 77 | } 78 | /* USER CODE END NonMaskableInt_IRQn 1 */ 79 | } 80 | 81 | /** 82 | * @brief This function handles Hard fault interrupt. 83 | */ 84 | void HardFault_Handler(void) 85 | { 86 | /* USER CODE BEGIN HardFault_IRQn 0 */ 87 | 88 | /* USER CODE END HardFault_IRQn 0 */ 89 | while (1) 90 | { 91 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */ 92 | /* USER CODE END W1_HardFault_IRQn 0 */ 93 | } 94 | } 95 | 96 | /** 97 | * @brief This function handles Memory management fault. 98 | */ 99 | void MemManage_Handler(void) 100 | { 101 | /* USER CODE BEGIN MemoryManagement_IRQn 0 */ 102 | 103 | /* USER CODE END MemoryManagement_IRQn 0 */ 104 | while (1) 105 | { 106 | /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ 107 | /* USER CODE END W1_MemoryManagement_IRQn 0 */ 108 | } 109 | } 110 | 111 | /** 112 | * @brief This function handles Prefetch fault, memory access fault. 113 | */ 114 | void BusFault_Handler(void) 115 | { 116 | /* USER CODE BEGIN BusFault_IRQn 0 */ 117 | 118 | /* USER CODE END BusFault_IRQn 0 */ 119 | while (1) 120 | { 121 | /* USER CODE BEGIN W1_BusFault_IRQn 0 */ 122 | /* USER CODE END W1_BusFault_IRQn 0 */ 123 | } 124 | } 125 | 126 | /** 127 | * @brief This function handles Undefined instruction or illegal state. 128 | */ 129 | void UsageFault_Handler(void) 130 | { 131 | /* USER CODE BEGIN UsageFault_IRQn 0 */ 132 | 133 | /* USER CODE END UsageFault_IRQn 0 */ 134 | while (1) 135 | { 136 | /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ 137 | /* USER CODE END W1_UsageFault_IRQn 0 */ 138 | } 139 | } 140 | 141 | /** 142 | * @brief This function handles System service call via SWI instruction. 143 | */ 144 | void SVC_Handler(void) 145 | { 146 | /* USER CODE BEGIN SVCall_IRQn 0 */ 147 | 148 | /* USER CODE END SVCall_IRQn 0 */ 149 | /* USER CODE BEGIN SVCall_IRQn 1 */ 150 | 151 | /* USER CODE END SVCall_IRQn 1 */ 152 | } 153 | 154 | /** 155 | * @brief This function handles Debug monitor. 156 | */ 157 | void DebugMon_Handler(void) 158 | { 159 | /* USER CODE BEGIN DebugMonitor_IRQn 0 */ 160 | 161 | /* USER CODE END DebugMonitor_IRQn 0 */ 162 | /* USER CODE BEGIN DebugMonitor_IRQn 1 */ 163 | 164 | /* USER CODE END DebugMonitor_IRQn 1 */ 165 | } 166 | 167 | /** 168 | * @brief This function handles Pendable request for system service. 169 | */ 170 | void PendSV_Handler(void) 171 | { 172 | /* USER CODE BEGIN PendSV_IRQn 0 */ 173 | 174 | /* USER CODE END PendSV_IRQn 0 */ 175 | /* USER CODE BEGIN PendSV_IRQn 1 */ 176 | 177 | /* USER CODE END PendSV_IRQn 1 */ 178 | } 179 | 180 | /** 181 | * @brief This function handles System tick timer. 182 | */ 183 | void SysTick_Handler(void) 184 | { 185 | /* USER CODE BEGIN SysTick_IRQn 0 */ 186 | 187 | /* USER CODE END SysTick_IRQn 0 */ 188 | HAL_IncTick(); 189 | /* USER CODE BEGIN SysTick_IRQn 1 */ 190 | 191 | /* USER CODE END SysTick_IRQn 1 */ 192 | } 193 | 194 | /******************************************************************************/ 195 | /* STM32L4xx Peripheral Interrupt Handlers */ 196 | /* Add here the Interrupt Handlers for the used peripherals. */ 197 | /* For the available peripheral interrupt handler names, */ 198 | /* please refer to the startup file (startup_stm32l4xx.s). */ 199 | /******************************************************************************/ 200 | 201 | /** 202 | * @brief This function handles USB event interrupt through EXTI line 17. 203 | */ 204 | void USB_IRQHandler(void) 205 | { 206 | /* USER CODE BEGIN USB_IRQn 0 */ 207 | 208 | /* USER CODE END USB_IRQn 0 */ 209 | HAL_PCD_IRQHandler(&hpcd_USB_FS); 210 | /* USER CODE BEGIN USB_IRQn 1 */ 211 | 212 | /* USER CODE END USB_IRQn 1 */ 213 | } 214 | 215 | /* USER CODE BEGIN 1 */ 216 | 217 | /* USER CODE END 1 */ 218 | 219 | -------------------------------------------------------------------------------- /fw/sample_target/Drivers/CMSIS/Device/ST/STM32L4xx/Include/system_stm32l4xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32l4xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M4 Device System Source File for STM32L4xx 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 stm32l4xx_system 24 | * @{ 25 | */ 26 | 27 | /** 28 | * @brief Define to prevent recursive inclusion 29 | */ 30 | #ifndef __SYSTEM_STM32L4XX_H 31 | #define __SYSTEM_STM32L4XX_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** @addtogroup STM32L4xx_System_Includes 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @} 43 | */ 44 | 45 | 46 | /** @addtogroup STM32L4xx_System_Exported_Variables 47 | * @{ 48 | */ 49 | /* The SystemCoreClock 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 | extern const uint32_t MSIRangeTable[12]; /*!< MSI ranges table values */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @addtogroup STM32L4xx_System_Exported_Constants 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32L4xx_System_Exported_Macros 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @addtogroup STM32L4xx_System_Exported_Functions 84 | * @{ 85 | */ 86 | 87 | extern void SystemInit(void); 88 | extern void SystemCoreClockUpdate(void); 89 | /** 90 | * @} 91 | */ 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /*__SYSTEM_STM32L4XX_H */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | -------------------------------------------------------------------------------- /fw/sample_target/Drivers/CMSIS/Device/ST/STM32L4xx/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 | -------------------------------------------------------------------------------- /fw/sample_target/Drivers/CMSIS/Device/ST/STM32L4xx/License.md: -------------------------------------------------------------------------------- 1 | License.md file kept for legacy purpose -------------------------------------------------------------------------------- /fw/sample_target/Drivers/CMSIS/Include/cmsis_compiler.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_compiler.h 3 | * @brief CMSIS compiler generic header file 4 | * @version V5.1.0 5 | * @date 09. October 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-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 | #ifndef __CMSIS_COMPILER_H 26 | #define __CMSIS_COMPILER_H 27 | 28 | #include 29 | 30 | /* 31 | * Arm Compiler 4/5 32 | */ 33 | #if defined ( __CC_ARM ) 34 | #include "cmsis_armcc.h" 35 | 36 | 37 | /* 38 | * Arm Compiler 6.6 LTM (armclang) 39 | */ 40 | #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100) 41 | #include "cmsis_armclang_ltm.h" 42 | 43 | /* 44 | * Arm Compiler above 6.10.1 (armclang) 45 | */ 46 | #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100) 47 | #include "cmsis_armclang.h" 48 | 49 | 50 | /* 51 | * GNU Compiler 52 | */ 53 | #elif defined ( __GNUC__ ) 54 | #include "cmsis_gcc.h" 55 | 56 | 57 | /* 58 | * IAR Compiler 59 | */ 60 | #elif defined ( __ICCARM__ ) 61 | #include 62 | 63 | 64 | /* 65 | * TI Arm Compiler 66 | */ 67 | #elif defined ( __TI_ARM__ ) 68 | #include 69 | 70 | #ifndef __ASM 71 | #define __ASM __asm 72 | #endif 73 | #ifndef __INLINE 74 | #define __INLINE inline 75 | #endif 76 | #ifndef __STATIC_INLINE 77 | #define __STATIC_INLINE static inline 78 | #endif 79 | #ifndef __STATIC_FORCEINLINE 80 | #define __STATIC_FORCEINLINE __STATIC_INLINE 81 | #endif 82 | #ifndef __NO_RETURN 83 | #define __NO_RETURN __attribute__((noreturn)) 84 | #endif 85 | #ifndef __USED 86 | #define __USED __attribute__((used)) 87 | #endif 88 | #ifndef __WEAK 89 | #define __WEAK __attribute__((weak)) 90 | #endif 91 | #ifndef __PACKED 92 | #define __PACKED __attribute__((packed)) 93 | #endif 94 | #ifndef __PACKED_STRUCT 95 | #define __PACKED_STRUCT struct __attribute__((packed)) 96 | #endif 97 | #ifndef __PACKED_UNION 98 | #define __PACKED_UNION union __attribute__((packed)) 99 | #endif 100 | #ifndef __UNALIGNED_UINT32 /* deprecated */ 101 | struct __attribute__((packed)) T_UINT32 { uint32_t v; }; 102 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 103 | #endif 104 | #ifndef __UNALIGNED_UINT16_WRITE 105 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 106 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val)) 107 | #endif 108 | #ifndef __UNALIGNED_UINT16_READ 109 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 110 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 111 | #endif 112 | #ifndef __UNALIGNED_UINT32_WRITE 113 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 114 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 115 | #endif 116 | #ifndef __UNALIGNED_UINT32_READ 117 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 118 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 119 | #endif 120 | #ifndef __ALIGNED 121 | #define __ALIGNED(x) __attribute__((aligned(x))) 122 | #endif 123 | #ifndef __RESTRICT 124 | #define __RESTRICT __restrict 125 | #endif 126 | #ifndef __COMPILER_BARRIER 127 | #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. 128 | #define __COMPILER_BARRIER() (void)0 129 | #endif 130 | 131 | 132 | /* 133 | * TASKING Compiler 134 | */ 135 | #elif defined ( __TASKING__ ) 136 | /* 137 | * The CMSIS functions have been implemented as intrinsics in the compiler. 138 | * Please use "carm -?i" to get an up to date list of all intrinsics, 139 | * Including the CMSIS ones. 140 | */ 141 | 142 | #ifndef __ASM 143 | #define __ASM __asm 144 | #endif 145 | #ifndef __INLINE 146 | #define __INLINE inline 147 | #endif 148 | #ifndef __STATIC_INLINE 149 | #define __STATIC_INLINE static inline 150 | #endif 151 | #ifndef __STATIC_FORCEINLINE 152 | #define __STATIC_FORCEINLINE __STATIC_INLINE 153 | #endif 154 | #ifndef __NO_RETURN 155 | #define __NO_RETURN __attribute__((noreturn)) 156 | #endif 157 | #ifndef __USED 158 | #define __USED __attribute__((used)) 159 | #endif 160 | #ifndef __WEAK 161 | #define __WEAK __attribute__((weak)) 162 | #endif 163 | #ifndef __PACKED 164 | #define __PACKED __packed__ 165 | #endif 166 | #ifndef __PACKED_STRUCT 167 | #define __PACKED_STRUCT struct __packed__ 168 | #endif 169 | #ifndef __PACKED_UNION 170 | #define __PACKED_UNION union __packed__ 171 | #endif 172 | #ifndef __UNALIGNED_UINT32 /* deprecated */ 173 | struct __packed__ T_UINT32 { uint32_t v; }; 174 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 175 | #endif 176 | #ifndef __UNALIGNED_UINT16_WRITE 177 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 178 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) 179 | #endif 180 | #ifndef __UNALIGNED_UINT16_READ 181 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 182 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 183 | #endif 184 | #ifndef __UNALIGNED_UINT32_WRITE 185 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 186 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 187 | #endif 188 | #ifndef __UNALIGNED_UINT32_READ 189 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 190 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 191 | #endif 192 | #ifndef __ALIGNED 193 | #define __ALIGNED(x) __align(x) 194 | #endif 195 | #ifndef __RESTRICT 196 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 197 | #define __RESTRICT 198 | #endif 199 | #ifndef __COMPILER_BARRIER 200 | #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. 201 | #define __COMPILER_BARRIER() (void)0 202 | #endif 203 | 204 | 205 | /* 206 | * COSMIC Compiler 207 | */ 208 | #elif defined ( __CSMC__ ) 209 | #include 210 | 211 | #ifndef __ASM 212 | #define __ASM _asm 213 | #endif 214 | #ifndef __INLINE 215 | #define __INLINE inline 216 | #endif 217 | #ifndef __STATIC_INLINE 218 | #define __STATIC_INLINE static inline 219 | #endif 220 | #ifndef __STATIC_FORCEINLINE 221 | #define __STATIC_FORCEINLINE __STATIC_INLINE 222 | #endif 223 | #ifndef __NO_RETURN 224 | // NO RETURN is automatically detected hence no warning here 225 | #define __NO_RETURN 226 | #endif 227 | #ifndef __USED 228 | #warning No compiler specific solution for __USED. __USED is ignored. 229 | #define __USED 230 | #endif 231 | #ifndef __WEAK 232 | #define __WEAK __weak 233 | #endif 234 | #ifndef __PACKED 235 | #define __PACKED @packed 236 | #endif 237 | #ifndef __PACKED_STRUCT 238 | #define __PACKED_STRUCT @packed struct 239 | #endif 240 | #ifndef __PACKED_UNION 241 | #define __PACKED_UNION @packed union 242 | #endif 243 | #ifndef __UNALIGNED_UINT32 /* deprecated */ 244 | @packed struct T_UINT32 { uint32_t v; }; 245 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 246 | #endif 247 | #ifndef __UNALIGNED_UINT16_WRITE 248 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 249 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) 250 | #endif 251 | #ifndef __UNALIGNED_UINT16_READ 252 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 253 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 254 | #endif 255 | #ifndef __UNALIGNED_UINT32_WRITE 256 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 257 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 258 | #endif 259 | #ifndef __UNALIGNED_UINT32_READ 260 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 261 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 262 | #endif 263 | #ifndef __ALIGNED 264 | #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored. 265 | #define __ALIGNED(x) 266 | #endif 267 | #ifndef __RESTRICT 268 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 269 | #define __RESTRICT 270 | #endif 271 | #ifndef __COMPILER_BARRIER 272 | #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. 273 | #define __COMPILER_BARRIER() (void)0 274 | #endif 275 | 276 | 277 | #else 278 | #error Unknown compiler. 279 | #endif 280 | 281 | 282 | #endif /* __CMSIS_COMPILER_H */ 283 | 284 | -------------------------------------------------------------------------------- /fw/sample_target/Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.3 5 | * @date 24. June 2019 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2019 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 ( 3U) /*!< [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 | -------------------------------------------------------------------------------- /fw/sample_target/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 | -------------------------------------------------------------------------------- /fw/sample_target/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l4xx_hal_def.h 4 | * @author MCD Application Team 5 | * @brief This file contains HAL common defines, enumeration, macros and 6 | * structures definitions. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2017 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef STM32L4xx_HAL_DEF_H 22 | #define STM32L4xx_HAL_DEF_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32l4xx.h" 30 | #include "Legacy/stm32_hal_legacy.h" /* Aliases file for old names compatibility */ 31 | #include 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | 35 | /** 36 | * @brief HAL Status structures definition 37 | */ 38 | typedef enum 39 | { 40 | HAL_OK = 0x00, 41 | HAL_ERROR = 0x01, 42 | HAL_BUSY = 0x02, 43 | HAL_TIMEOUT = 0x03 44 | } HAL_StatusTypeDef; 45 | 46 | /** 47 | * @brief HAL Lock structures definition 48 | */ 49 | typedef enum 50 | { 51 | HAL_UNLOCKED = 0x00, 52 | HAL_LOCKED = 0x01 53 | } HAL_LockTypeDef; 54 | 55 | /* Exported macros -----------------------------------------------------------*/ 56 | 57 | #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */ 58 | 59 | #define HAL_MAX_DELAY 0xFFFFFFFFU 60 | 61 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT)) 62 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U) 63 | 64 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ 65 | do{ \ 66 | (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ 67 | (__DMA_HANDLE__).Parent = (__HANDLE__); \ 68 | } while(0) 69 | 70 | /** @brief Reset the Handle's State field. 71 | * @param __HANDLE__: specifies the Peripheral Handle. 72 | * @note This macro can be used for the following purpose: 73 | * - When the Handle is declared as local variable; before passing it as parameter 74 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro 75 | * to set to 0 the Handle's "State" field. 76 | * Otherwise, "State" field may have any random value and the first time the function 77 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed 78 | * (i.e. HAL_PPP_MspInit() will not be executed). 79 | * - When there is a need to reconfigure the low level hardware: instead of calling 80 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). 81 | * In this later function, when the Handle's "State" field is set to 0, it will execute the function 82 | * HAL_PPP_MspInit() which will reconfigure the low level hardware. 83 | * @retval None 84 | */ 85 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0) 86 | 87 | #if (USE_RTOS == 1) 88 | /* Reserved for future use */ 89 | #error " USE_RTOS should be 0 in the current HAL release " 90 | #else 91 | #define __HAL_LOCK(__HANDLE__) \ 92 | do{ \ 93 | if((__HANDLE__)->Lock == HAL_LOCKED) \ 94 | { \ 95 | return HAL_BUSY; \ 96 | } \ 97 | else \ 98 | { \ 99 | (__HANDLE__)->Lock = HAL_LOCKED; \ 100 | } \ 101 | }while (0) 102 | 103 | #define __HAL_UNLOCK(__HANDLE__) \ 104 | do{ \ 105 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ 106 | }while (0) 107 | #endif /* USE_RTOS */ 108 | 109 | 110 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ 111 | #ifndef __weak 112 | #define __weak __attribute__((weak)) 113 | #endif 114 | #ifndef __packed 115 | #define __packed __attribute__((packed)) 116 | #endif 117 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ 118 | #ifndef __weak 119 | #define __weak __attribute__((weak)) 120 | #endif /* __weak */ 121 | #ifndef __packed 122 | #define __packed __attribute__((__packed__)) 123 | #endif /* __packed */ 124 | #endif /* __GNUC__ */ 125 | 126 | 127 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ 128 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ 129 | #ifndef __ALIGN_BEGIN 130 | #define __ALIGN_BEGIN 131 | #endif 132 | #ifndef __ALIGN_END 133 | #define __ALIGN_END __attribute__ ((aligned (4))) 134 | #endif 135 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ 136 | #ifndef __ALIGN_END 137 | #define __ALIGN_END __attribute__ ((aligned (4))) 138 | #endif /* __ALIGN_END */ 139 | #ifndef __ALIGN_BEGIN 140 | #define __ALIGN_BEGIN 141 | #endif /* __ALIGN_BEGIN */ 142 | #else 143 | #ifndef __ALIGN_END 144 | #define __ALIGN_END 145 | #endif /* __ALIGN_END */ 146 | #ifndef __ALIGN_BEGIN 147 | #if defined (__CC_ARM) /* ARM Compiler V5 */ 148 | #define __ALIGN_BEGIN __align(4) 149 | #elif defined (__ICCARM__) /* IAR Compiler */ 150 | #define __ALIGN_BEGIN 151 | #endif /* __CC_ARM */ 152 | #endif /* __ALIGN_BEGIN */ 153 | #endif /* __GNUC__ */ 154 | 155 | /** 156 | * @brief __RAM_FUNC definition 157 | */ 158 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) 159 | /* ARM Compiler V4/V5 and V6 160 | -------------------------- 161 | RAM functions are defined using the toolchain options. 162 | Functions that are executed in RAM should reside in a separate source module. 163 | Using the 'Options for File' dialog you can simply change the 'Code / Const' 164 | area of a module to a memory space in physical RAM. 165 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' 166 | dialog. 167 | */ 168 | #define __RAM_FUNC 169 | 170 | #elif defined ( __ICCARM__ ) 171 | /* ICCARM Compiler 172 | --------------- 173 | RAM functions are defined using a specific toolchain keyword "__ramfunc". 174 | */ 175 | #define __RAM_FUNC __ramfunc 176 | 177 | #elif defined ( __GNUC__ ) 178 | /* GNU Compiler 179 | ------------ 180 | RAM functions are defined using a specific toolchain attribute 181 | "__attribute__((section(".RamFunc")))". 182 | */ 183 | #define __RAM_FUNC __attribute__((section(".RamFunc"))) 184 | 185 | #endif 186 | 187 | /** 188 | * @brief __NOINLINE definition 189 | */ 190 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined ( __GNUC__ ) 191 | /* ARM V4/V5 and V6 & GNU Compiler 192 | ------------------------------- 193 | */ 194 | #define __NOINLINE __attribute__ ( (noinline) ) 195 | 196 | #elif defined ( __ICCARM__ ) 197 | /* ICCARM Compiler 198 | --------------- 199 | */ 200 | #define __NOINLINE _Pragma("optimize = no_inline") 201 | 202 | #endif 203 | 204 | 205 | #ifdef __cplusplus 206 | } 207 | #endif 208 | 209 | #endif /* STM32L4xx_HAL_DEF_H */ 210 | -------------------------------------------------------------------------------- /fw/sample_target/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_flash_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l4xx_hal_flash_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of FLASH HAL Extended 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 | /* Define to prevent recursive inclusion -------------------------------------*/ 19 | #ifndef STM32L4xx_HAL_FLASH_EX_H 20 | #define STM32L4xx_HAL_FLASH_EX_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "stm32l4xx_hal_def.h" 28 | 29 | /** @addtogroup STM32L4xx_HAL_Driver 30 | * @{ 31 | */ 32 | 33 | /** @addtogroup FLASHEx 34 | * @{ 35 | */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | 39 | /* Exported constants --------------------------------------------------------*/ 40 | #if defined (FLASH_CFGR_LVEN) 41 | /** @addtogroup FLASHEx_Exported_Constants 42 | * @{ 43 | */ 44 | /** @defgroup FLASHEx_LVE_PIN_CFG FLASHEx LVE pin configuration 45 | * @{ 46 | */ 47 | #define FLASH_LVE_PIN_CTRL 0x00000000U /*!< LVE FLASH pin controlled by power controller */ 48 | #define FLASH_LVE_PIN_FORCED FLASH_CFGR_LVEN /*!< LVE FLASH pin enforced to low (external SMPS used) */ 49 | /** 50 | * @} 51 | */ 52 | 53 | /** 54 | * @} 55 | */ 56 | #endif /* FLASH_CFGR_LVEN */ 57 | 58 | /* Exported macro ------------------------------------------------------------*/ 59 | 60 | /* Exported functions --------------------------------------------------------*/ 61 | /** @addtogroup FLASHEx_Exported_Functions 62 | * @{ 63 | */ 64 | 65 | /* Extended Program operation functions *************************************/ 66 | /** @addtogroup FLASHEx_Exported_Functions_Group1 67 | * @{ 68 | */ 69 | HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError); 70 | HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit); 71 | HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit); 72 | void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit); 73 | /** 74 | * @} 75 | */ 76 | 77 | #if defined (FLASH_CFGR_LVEN) 78 | /** @addtogroup FLASHEx_Exported_Functions_Group2 79 | * @{ 80 | */ 81 | HAL_StatusTypeDef HAL_FLASHEx_ConfigLVEPin(uint32_t ConfigLVE); 82 | /** 83 | * @} 84 | */ 85 | #endif /* FLASH_CFGR_LVEN */ 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | /* Private function ----------------------------------------------------------*/ 92 | /** @addtogroup FLASHEx_Private_Functions FLASHEx Private Functions 93 | * @{ 94 | */ 95 | void FLASH_PageErase(uint32_t Page, uint32_t Banks); 96 | void FLASH_FlushCaches(void); 97 | /** 98 | * @} 99 | */ 100 | 101 | /* Private macros ------------------------------------------------------------*/ 102 | /** 103 | @cond 0 104 | */ 105 | #if defined (FLASH_CFGR_LVEN) 106 | #define IS_FLASH_LVE_PIN(CFG) (((CFG) == FLASH_LVE_PIN_CTRL) || ((CFG) == FLASH_LVE_PIN_FORCED)) 107 | #endif /* FLASH_CFGR_LVEN */ 108 | /** 109 | @endcond 110 | */ 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /** 117 | * @} 118 | */ 119 | 120 | #ifdef __cplusplus 121 | } 122 | #endif 123 | 124 | #endif /* STM32L4xx_HAL_FLASH_EX_H */ 125 | 126 | -------------------------------------------------------------------------------- /fw/sample_target/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_flash_ramfunc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l4xx_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 STM32L4xx_FLASH_RAMFUNC_H 20 | #define STM32L4xx_FLASH_RAMFUNC_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "stm32l4xx_hal_def.h" 28 | 29 | /** @addtogroup STM32L4xx_HAL_Driver 30 | * @{ 31 | */ 32 | 33 | /** @addtogroup FLASH_RAMFUNC 34 | * @{ 35 | */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* Exported macro ------------------------------------------------------------*/ 39 | /* Exported functions --------------------------------------------------------*/ 40 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group1 45 | * @{ 46 | */ 47 | /* Peripheral Control functions ************************************************/ 48 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableRunPowerDown(void); 49 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableRunPowerDown(void); 50 | #if defined (STM32L4P5xx) || defined (STM32L4Q5xx) || defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx) 51 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_OB_DBankConfig(uint32_t DBankConfig); 52 | #endif 53 | /** 54 | * @} 55 | */ 56 | 57 | /** 58 | * @} 59 | */ 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | /** 66 | * @} 67 | */ 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* STM32L4xx_FLASH_RAMFUNC_H */ 74 | 75 | -------------------------------------------------------------------------------- /fw/sample_target/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_i2c_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l4xx_hal_i2c_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of I2C HAL Extended module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32L4xx_HAL_I2C_EX_H 21 | #define STM32L4xx_HAL_I2C_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32l4xx_hal_def.h" 29 | 30 | /** @addtogroup STM32L4xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup I2CEx 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* Exported constants --------------------------------------------------------*/ 40 | /** @defgroup I2CEx_Exported_Constants I2C Extended Exported Constants 41 | * @{ 42 | */ 43 | 44 | /** @defgroup I2CEx_Analog_Filter I2C Extended Analog Filter 45 | * @{ 46 | */ 47 | #define I2C_ANALOGFILTER_ENABLE 0x00000000U 48 | #define I2C_ANALOGFILTER_DISABLE I2C_CR1_ANFOFF 49 | /** 50 | * @} 51 | */ 52 | 53 | /** @defgroup I2CEx_FastModePlus I2C Extended Fast Mode Plus 54 | * @{ 55 | */ 56 | #define I2C_FMP_NOT_SUPPORTED 0xAAAA0000U /*!< Fast Mode Plus not supported */ 57 | #define I2C_FASTMODEPLUS_PB6 SYSCFG_CFGR1_I2C_PB6_FMP /*!< Enable Fast Mode Plus on PB6 */ 58 | #define I2C_FASTMODEPLUS_PB7 SYSCFG_CFGR1_I2C_PB7_FMP /*!< Enable Fast Mode Plus on PB7 */ 59 | #if defined(SYSCFG_CFGR1_I2C_PB8_FMP) 60 | #define I2C_FASTMODEPLUS_PB8 SYSCFG_CFGR1_I2C_PB8_FMP /*!< Enable Fast Mode Plus on PB8 */ 61 | #define I2C_FASTMODEPLUS_PB9 SYSCFG_CFGR1_I2C_PB9_FMP /*!< Enable Fast Mode Plus on PB9 */ 62 | #else 63 | #define I2C_FASTMODEPLUS_PB8 (uint32_t)(0x00000010U | I2C_FMP_NOT_SUPPORTED) /*!< Fast Mode Plus PB8 not supported */ 64 | #define I2C_FASTMODEPLUS_PB9 (uint32_t)(0x00000012U | I2C_FMP_NOT_SUPPORTED) /*!< Fast Mode Plus PB9 not supported */ 65 | #endif /* SYSCFG_CFGR1_I2C_PB8_FMP */ 66 | #define I2C_FASTMODEPLUS_I2C1 SYSCFG_CFGR1_I2C1_FMP /*!< Enable Fast Mode Plus on I2C1 pins */ 67 | #if defined(SYSCFG_CFGR1_I2C2_FMP) 68 | #define I2C_FASTMODEPLUS_I2C2 SYSCFG_CFGR1_I2C2_FMP /*!< Enable Fast Mode Plus on I2C2 pins */ 69 | #else 70 | #define I2C_FASTMODEPLUS_I2C2 (uint32_t)(0x00000200U | I2C_FMP_NOT_SUPPORTED) /*!< Fast Mode Plus I2C2 not supported */ 71 | #endif /* SYSCFG_CFGR1_I2C2_FMP */ 72 | #define I2C_FASTMODEPLUS_I2C3 SYSCFG_CFGR1_I2C3_FMP /*!< Enable Fast Mode Plus on I2C3 pins */ 73 | #if defined(SYSCFG_CFGR1_I2C4_FMP) 74 | #define I2C_FASTMODEPLUS_I2C4 SYSCFG_CFGR1_I2C4_FMP /*!< Enable Fast Mode Plus on I2C4 pins */ 75 | #else 76 | #define I2C_FASTMODEPLUS_I2C4 (uint32_t)(0x00000800U | I2C_FMP_NOT_SUPPORTED) /*!< Fast Mode Plus I2C4 not supported */ 77 | #endif /* SYSCFG_CFGR1_I2C4_FMP */ 78 | /** 79 | * @} 80 | */ 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | /* Exported macro ------------------------------------------------------------*/ 87 | /** @defgroup I2CEx_Exported_Macros I2C Extended Exported Macros 88 | * @{ 89 | */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /* Exported functions --------------------------------------------------------*/ 96 | /** @addtogroup I2CEx_Exported_Functions I2C Extended Exported Functions 97 | * @{ 98 | */ 99 | 100 | /** @addtogroup I2CEx_Exported_Functions_Group1 Filter Mode Functions 101 | * @{ 102 | */ 103 | /* Peripheral Control functions ************************************************/ 104 | HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter); 105 | HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter); 106 | /** 107 | * @} 108 | */ 109 | 110 | /** @addtogroup I2CEx_Exported_Functions_Group2 WakeUp Mode Functions 111 | * @{ 112 | */ 113 | HAL_StatusTypeDef HAL_I2CEx_EnableWakeUp(I2C_HandleTypeDef *hi2c); 114 | HAL_StatusTypeDef HAL_I2CEx_DisableWakeUp(I2C_HandleTypeDef *hi2c); 115 | /** 116 | * @} 117 | */ 118 | 119 | /** @addtogroup I2CEx_Exported_Functions_Group3 Fast Mode Plus Functions 120 | * @{ 121 | */ 122 | void HAL_I2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus); 123 | void HAL_I2CEx_DisableFastModePlus(uint32_t ConfigFastModePlus); 124 | /** 125 | * @} 126 | */ 127 | 128 | /** 129 | * @} 130 | */ 131 | 132 | /* Private constants ---------------------------------------------------------*/ 133 | /** @defgroup I2CEx_Private_Constants I2C Extended Private Constants 134 | * @{ 135 | */ 136 | 137 | /** 138 | * @} 139 | */ 140 | 141 | /* Private macros ------------------------------------------------------------*/ 142 | /** @defgroup I2CEx_Private_Macro I2C Extended Private Macros 143 | * @{ 144 | */ 145 | #define IS_I2C_ANALOG_FILTER(FILTER) (((FILTER) == I2C_ANALOGFILTER_ENABLE) || \ 146 | ((FILTER) == I2C_ANALOGFILTER_DISABLE)) 147 | 148 | #define IS_I2C_DIGITAL_FILTER(FILTER) ((FILTER) <= 0x0000000FU) 149 | 150 | #define IS_I2C_FASTMODEPLUS(__CONFIG__) ((((__CONFIG__) & I2C_FMP_NOT_SUPPORTED) != I2C_FMP_NOT_SUPPORTED) && \ 151 | ((((__CONFIG__) & (I2C_FASTMODEPLUS_PB6)) == I2C_FASTMODEPLUS_PB6) || \ 152 | (((__CONFIG__) & (I2C_FASTMODEPLUS_PB7)) == I2C_FASTMODEPLUS_PB7) || \ 153 | (((__CONFIG__) & (I2C_FASTMODEPLUS_PB8)) == I2C_FASTMODEPLUS_PB8) || \ 154 | (((__CONFIG__) & (I2C_FASTMODEPLUS_PB9)) == I2C_FASTMODEPLUS_PB9) || \ 155 | (((__CONFIG__) & (I2C_FASTMODEPLUS_I2C1)) == I2C_FASTMODEPLUS_I2C1) || \ 156 | (((__CONFIG__) & (I2C_FASTMODEPLUS_I2C2)) == I2C_FASTMODEPLUS_I2C2) || \ 157 | (((__CONFIG__) & (I2C_FASTMODEPLUS_I2C3)) == I2C_FASTMODEPLUS_I2C3) || \ 158 | (((__CONFIG__) & (I2C_FASTMODEPLUS_I2C4)) == I2C_FASTMODEPLUS_I2C4))) 159 | /** 160 | * @} 161 | */ 162 | 163 | /* Private Functions ---------------------------------------------------------*/ 164 | /** @defgroup I2CEx_Private_Functions I2C Extended Private Functions 165 | * @{ 166 | */ 167 | /* Private functions are defined in stm32l4xx_hal_i2c_ex.c file */ 168 | /** 169 | * @} 170 | */ 171 | 172 | /** 173 | * @} 174 | */ 175 | 176 | /** 177 | * @} 178 | */ 179 | 180 | #ifdef __cplusplus 181 | } 182 | #endif 183 | 184 | #endif /* STM32L4xx_HAL_I2C_EX_H */ 185 | -------------------------------------------------------------------------------- /fw/sample_target/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_pcd_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l4xx_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) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32L4xx_HAL_PCD_EX_H 21 | #define STM32L4xx_HAL_PCD_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif /* __cplusplus */ 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32l4xx_hal_def.h" 29 | 30 | #if defined (USB) || defined (USB_OTG_FS) 31 | /** @addtogroup STM32L4xx_HAL_Driver 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup PCDEx 36 | * @{ 37 | */ 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* Exported constants --------------------------------------------------------*/ 40 | /* Exported macros -----------------------------------------------------------*/ 41 | /* Exported functions --------------------------------------------------------*/ 42 | /** @addtogroup PCDEx_Exported_Functions PCDEx Exported Functions 43 | * @{ 44 | */ 45 | /** @addtogroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 46 | * @{ 47 | */ 48 | 49 | #if defined (USB_OTG_FS) 50 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size); 51 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size); 52 | #endif /* defined (USB_OTG_FS) */ 53 | 54 | #if defined (USB) 55 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, uint16_t ep_addr, 56 | uint16_t ep_kind, uint32_t pmaadress); 57 | #endif /* defined (USB) */ 58 | 59 | HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd); 60 | HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd); 61 | 62 | 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 | 67 | void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg); 68 | void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg); 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** 75 | * @} 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /** 83 | * @} 84 | */ 85 | #endif /* defined (USB) || defined (USB_OTG_FS) */ 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif /* __cplusplus */ 90 | 91 | 92 | #endif /* STM32L4xx_HAL_PCD_EX_H */ 93 | -------------------------------------------------------------------------------- /fw/sample_target/Drivers/STM32L4xx_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 | -------------------------------------------------------------------------------- /fw/sample_target/Drivers/STM32L4xx_HAL_Driver/License.md: -------------------------------------------------------------------------------- 1 | License.md file kept for legacy purpose 2 | -------------------------------------------------------------------------------- /fw/sample_target/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l4xx_hal_flash_ramfunc.c 4 | * @author MCD Application Team 5 | * @brief FLASH RAMFUNC driver. 6 | * This file provides a Flash firmware functions which should be 7 | * executed from internal SRAM 8 | * + FLASH HalfPage Programming 9 | * + FLASH Power Down in Run mode 10 | * 11 | * @verbatim 12 | ============================================================================== 13 | ##### Flash RAM functions ##### 14 | ============================================================================== 15 | 16 | *** ARM Compiler *** 17 | -------------------- 18 | [..] RAM functions are defined using the toolchain options. 19 | Functions that are executed in RAM should reside in a separate 20 | source module. Using the 'Options for File' dialog you can simply change 21 | the 'Code / Const' area of a module to a memory space in physical RAM. 22 | Available memory areas are declared in the 'Target' tab of the 23 | Options for Target' dialog. 24 | 25 | *** ICCARM Compiler *** 26 | ----------------------- 27 | [..] RAM functions are defined using a specific toolchain keyword "__ramfunc". 28 | 29 | *** GNU Compiler *** 30 | -------------------- 31 | [..] RAM functions are defined using a specific toolchain attribute 32 | "__attribute__((section(".RamFunc")))". 33 | 34 | @endverbatim 35 | ****************************************************************************** 36 | * @attention 37 | * 38 | * Copyright (c) 2017 STMicroelectronics. 39 | * All rights reserved. 40 | * 41 | * This software is licensed under terms that can be found in the LICENSE file in 42 | * the root directory of this software component. 43 | * If no LICENSE file comes with this software, it is provided AS-IS. 44 | ****************************************************************************** 45 | */ 46 | 47 | /* Includes ------------------------------------------------------------------*/ 48 | #include "stm32l4xx_hal.h" 49 | 50 | /** @addtogroup STM32L4xx_HAL_Driver 51 | * @{ 52 | */ 53 | 54 | /** @defgroup FLASH_RAMFUNC FLASH_RAMFUNC 55 | * @brief FLASH functions executed from RAM 56 | * @{ 57 | */ 58 | 59 | #ifdef HAL_FLASH_MODULE_ENABLED 60 | 61 | /* Private typedef -----------------------------------------------------------*/ 62 | /* Private define ------------------------------------------------------------*/ 63 | /* Private macro -------------------------------------------------------------*/ 64 | /* Private variables ---------------------------------------------------------*/ 65 | /* Private function prototypes -----------------------------------------------*/ 66 | /* Exported functions -------------------------------------------------------*/ 67 | 68 | /** @defgroup FLASH_RAMFUNC_Exported_Functions FLASH in RAM function Exported Functions 69 | * @{ 70 | */ 71 | 72 | /** @defgroup FLASH_RAMFUNC_Exported_Functions_Group1 Peripheral features functions 73 | * @brief Data transfers functions 74 | * 75 | @verbatim 76 | =============================================================================== 77 | ##### ramfunc functions ##### 78 | =============================================================================== 79 | [..] 80 | This subsection provides a set of functions that should be executed from RAM. 81 | 82 | @endverbatim 83 | * @{ 84 | */ 85 | 86 | /** 87 | * @brief Enable the Power down in Run Mode 88 | * @note This function should be called and executed from SRAM memory 89 | * @retval HAL status 90 | */ 91 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableRunPowerDown(void) 92 | { 93 | /* Enable the Power Down in Run mode*/ 94 | __HAL_FLASH_POWER_DOWN_ENABLE(); 95 | 96 | return HAL_OK; 97 | 98 | } 99 | 100 | /** 101 | * @brief Disable the Power down in Run Mode 102 | * @note This function should be called and executed from SRAM memory 103 | * @retval HAL status 104 | */ 105 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableRunPowerDown(void) 106 | { 107 | /* Disable the Power Down in Run mode*/ 108 | __HAL_FLASH_POWER_DOWN_DISABLE(); 109 | 110 | return HAL_OK; 111 | } 112 | 113 | #if defined (STM32L4P5xx) || defined (STM32L4Q5xx) || defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx) 114 | /** 115 | * @brief Program the FLASH DBANK User Option Byte. 116 | * 117 | * @note To configure the user option bytes, the option lock bit OPTLOCK must 118 | * be cleared with the call of the HAL_FLASH_OB_Unlock() function. 119 | * @note To modify the DBANK option byte, no PCROP region should be defined. 120 | * To deactivate PCROP, user should perform RDP changing 121 | * 122 | * @param DBankConfig The FLASH DBANK User Option Byte value. 123 | * This parameter can be one of the following values: 124 | * @arg OB_DBANK_128_BITS: Single-bank with 128-bits data 125 | * @arg OB_DBANK_64_BITS: Dual-bank with 64-bits data 126 | * 127 | * @retval HAL status 128 | */ 129 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_OB_DBankConfig(uint32_t DBankConfig) 130 | { 131 | uint32_t count, reg; 132 | HAL_StatusTypeDef status = HAL_ERROR; 133 | 134 | /* Process Locked */ 135 | __HAL_LOCK(&pFlash); 136 | 137 | /* Check if the PCROP is disabled */ 138 | reg = FLASH->PCROP1SR; 139 | if (reg > FLASH->PCROP1ER) 140 | { 141 | reg = FLASH->PCROP2SR; 142 | if (reg > FLASH->PCROP2ER) 143 | { 144 | /* Disable Flash prefetch */ 145 | __HAL_FLASH_PREFETCH_BUFFER_DISABLE(); 146 | 147 | if (READ_BIT(FLASH->ACR, FLASH_ACR_ICEN) != 0U) 148 | { 149 | /* Disable Flash instruction cache */ 150 | __HAL_FLASH_INSTRUCTION_CACHE_DISABLE(); 151 | 152 | /* Flush Flash instruction cache */ 153 | __HAL_FLASH_INSTRUCTION_CACHE_RESET(); 154 | } 155 | 156 | if (READ_BIT(FLASH->ACR, FLASH_ACR_DCEN) != 0U) 157 | { 158 | /* Disable Flash data cache */ 159 | __HAL_FLASH_DATA_CACHE_DISABLE(); 160 | 161 | /* Flush Flash data cache */ 162 | __HAL_FLASH_DATA_CACHE_RESET(); 163 | } 164 | 165 | /* Disable WRP zone 1 of 1st bank if needed */ 166 | reg = FLASH->WRP1AR; 167 | if (((reg & FLASH_WRP1AR_WRP1A_STRT) >> FLASH_WRP1AR_WRP1A_STRT_Pos) <= 168 | ((reg & FLASH_WRP1AR_WRP1A_END) >> FLASH_WRP1AR_WRP1A_END_Pos)) 169 | { 170 | MODIFY_REG(FLASH->WRP1AR, (FLASH_WRP1AR_WRP1A_STRT | FLASH_WRP1AR_WRP1A_END), FLASH_WRP1AR_WRP1A_STRT); 171 | } 172 | 173 | /* Disable WRP zone 2 of 1st bank if needed */ 174 | reg = FLASH->WRP1BR; 175 | if (((reg & FLASH_WRP1BR_WRP1B_STRT) >> FLASH_WRP1BR_WRP1B_STRT_Pos) <= 176 | ((reg & FLASH_WRP1BR_WRP1B_END) >> FLASH_WRP1BR_WRP1B_END_Pos)) 177 | { 178 | MODIFY_REG(FLASH->WRP1BR, (FLASH_WRP1BR_WRP1B_STRT | FLASH_WRP1BR_WRP1B_END), FLASH_WRP1BR_WRP1B_STRT); 179 | } 180 | 181 | /* Disable WRP zone 1 of 2nd bank if needed */ 182 | reg = FLASH->WRP2AR; 183 | if (((reg & FLASH_WRP2AR_WRP2A_STRT) >> FLASH_WRP2AR_WRP2A_STRT_Pos) <= 184 | ((reg & FLASH_WRP2AR_WRP2A_END) >> FLASH_WRP2AR_WRP2A_END_Pos)) 185 | { 186 | MODIFY_REG(FLASH->WRP2AR, (FLASH_WRP2AR_WRP2A_STRT | FLASH_WRP2AR_WRP2A_END), FLASH_WRP2AR_WRP2A_STRT); 187 | } 188 | 189 | /* Disable WRP zone 2 of 2nd bank if needed */ 190 | reg = FLASH->WRP2BR; 191 | if (((reg & FLASH_WRP2BR_WRP2B_STRT) >> FLASH_WRP2BR_WRP2B_STRT_Pos) <= 192 | ((reg & FLASH_WRP2BR_WRP2B_END) >> FLASH_WRP2BR_WRP2B_END_Pos)) 193 | { 194 | MODIFY_REG(FLASH->WRP2BR, (FLASH_WRP2BR_WRP2B_STRT | FLASH_WRP2BR_WRP2B_END), FLASH_WRP2BR_WRP2B_STRT); 195 | } 196 | 197 | /* Modify the DBANK user option byte */ 198 | MODIFY_REG(FLASH->OPTR, FLASH_OPTR_DBANK, DBankConfig); 199 | 200 | /* Set OPTSTRT Bit */ 201 | SET_BIT(FLASH->CR, FLASH_CR_OPTSTRT); 202 | 203 | /* Wait for last operation to be completed */ 204 | /* 8 is the number of required instruction cycles for the below loop statement (timeout expressed in ms) */ 205 | count = FLASH_TIMEOUT_VALUE * (SystemCoreClock / 8U / 1000U); 206 | do 207 | { 208 | if (count == 0U) 209 | { 210 | break; 211 | } 212 | count--; 213 | } while (__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY) != RESET); 214 | 215 | /* If the option byte program operation is completed, disable the OPTSTRT Bit */ 216 | CLEAR_BIT(FLASH->CR, FLASH_CR_OPTSTRT); 217 | 218 | /* Set the bit to force the option byte reloading */ 219 | SET_BIT(FLASH->CR, FLASH_CR_OBL_LAUNCH); 220 | } 221 | } 222 | 223 | /* Process Unlocked */ 224 | __HAL_UNLOCK(&pFlash); 225 | 226 | return status; 227 | } 228 | #endif 229 | 230 | /** 231 | * @} 232 | */ 233 | 234 | /** 235 | * @} 236 | */ 237 | #endif /* HAL_FLASH_MODULE_ENABLED */ 238 | 239 | 240 | 241 | /** 242 | * @} 243 | */ 244 | 245 | /** 246 | * @} 247 | */ 248 | 249 | 250 | 251 | 252 | -------------------------------------------------------------------------------- /fw/sample_target/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_exti.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l4xx_ll_exti.c 4 | * @author MCD Application Team 5 | * @brief EXTI LL module 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 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 | #if defined(USE_FULL_LL_DRIVER) 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "stm32l4xx_ll_exti.h" 22 | #ifdef USE_FULL_ASSERT 23 | #include "stm32_assert.h" 24 | #else 25 | #define assert_param(expr) ((void)0U) 26 | #endif 27 | 28 | /** @addtogroup STM32L4xx_LL_Driver 29 | * @{ 30 | */ 31 | 32 | #if defined (EXTI) 33 | 34 | /** @defgroup EXTI_LL EXTI 35 | * @{ 36 | */ 37 | 38 | /* Private types -------------------------------------------------------------*/ 39 | /* Private variables ---------------------------------------------------------*/ 40 | /* Private constants ---------------------------------------------------------*/ 41 | /* Private macros ------------------------------------------------------------*/ 42 | /** @addtogroup EXTI_LL_Private_Macros 43 | * @{ 44 | */ 45 | 46 | #define IS_LL_EXTI_LINE_0_31(__VALUE__) (((__VALUE__) & ~LL_EXTI_LINE_ALL_0_31) == 0x00000000U) 47 | #define IS_LL_EXTI_LINE_32_63(__VALUE__) (((__VALUE__) & ~LL_EXTI_LINE_ALL_32_63) == 0x00000000U) 48 | 49 | #define IS_LL_EXTI_MODE(__VALUE__) (((__VALUE__) == LL_EXTI_MODE_IT) \ 50 | || ((__VALUE__) == LL_EXTI_MODE_EVENT) \ 51 | || ((__VALUE__) == LL_EXTI_MODE_IT_EVENT)) 52 | 53 | 54 | #define IS_LL_EXTI_TRIGGER(__VALUE__) (((__VALUE__) == LL_EXTI_TRIGGER_NONE) \ 55 | || ((__VALUE__) == LL_EXTI_TRIGGER_RISING) \ 56 | || ((__VALUE__) == LL_EXTI_TRIGGER_FALLING) \ 57 | || ((__VALUE__) == LL_EXTI_TRIGGER_RISING_FALLING)) 58 | 59 | /** 60 | * @} 61 | */ 62 | 63 | /* Private function prototypes -----------------------------------------------*/ 64 | 65 | /* Exported functions --------------------------------------------------------*/ 66 | /** @addtogroup EXTI_LL_Exported_Functions 67 | * @{ 68 | */ 69 | 70 | /** @addtogroup EXTI_LL_EF_Init 71 | * @{ 72 | */ 73 | 74 | /** 75 | * @brief De-initialize the EXTI registers to their default reset values. 76 | * @retval An ErrorStatus enumeration value: 77 | * - 0x00: EXTI registers are de-initialized 78 | */ 79 | uint32_t LL_EXTI_DeInit(void) 80 | { 81 | /* Interrupt mask register set to default reset values */ 82 | LL_EXTI_WriteReg(IMR1, 0xFF820000U); 83 | /* Event mask register set to default reset values */ 84 | LL_EXTI_WriteReg(EMR1, 0x00000000U); 85 | /* Rising Trigger selection register set to default reset values */ 86 | LL_EXTI_WriteReg(RTSR1, 0x00000000U); 87 | /* Falling Trigger selection register set to default reset values */ 88 | LL_EXTI_WriteReg(FTSR1, 0x00000000U); 89 | /* Software interrupt event register set to default reset values */ 90 | LL_EXTI_WriteReg(SWIER1, 0x00000000U); 91 | /* Pending register clear */ 92 | LL_EXTI_WriteReg(PR1, 0x007DFFFFU); 93 | 94 | /* Interrupt mask register 2 set to default reset values */ 95 | #if defined(LL_EXTI_LINE_40) 96 | LL_EXTI_WriteReg(IMR2, 0x00000187U); 97 | #else 98 | LL_EXTI_WriteReg(IMR2, 0x00000087U); 99 | #endif 100 | /* Event mask register 2 set to default reset values */ 101 | LL_EXTI_WriteReg(EMR2, 0x00000000U); 102 | /* Rising Trigger selection register 2 set to default reset values */ 103 | LL_EXTI_WriteReg(RTSR2, 0x00000000U); 104 | /* Falling Trigger selection register 2 set to default reset values */ 105 | LL_EXTI_WriteReg(FTSR2, 0x00000000U); 106 | /* Software interrupt event register 2 set to default reset values */ 107 | LL_EXTI_WriteReg(SWIER2, 0x00000000U); 108 | /* Pending register 2 clear */ 109 | LL_EXTI_WriteReg(PR2, 0x00000078U); 110 | 111 | return 0x00u; 112 | } 113 | 114 | /** 115 | * @brief Initialize the EXTI registers according to the specified parameters in EXTI_InitStruct. 116 | * @param EXTI_InitStruct pointer to a @ref LL_EXTI_InitTypeDef structure. 117 | * @retval An ErrorStatus enumeration value: 118 | * - 0x00: EXTI registers are initialized 119 | * - any other value : wrong configuration 120 | */ 121 | uint32_t LL_EXTI_Init(LL_EXTI_InitTypeDef *EXTI_InitStruct) 122 | { 123 | uint32_t status = 0x00u; 124 | 125 | /* Check the parameters */ 126 | assert_param(IS_LL_EXTI_LINE_0_31(EXTI_InitStruct->Line_0_31)); 127 | assert_param(IS_LL_EXTI_LINE_32_63(EXTI_InitStruct->Line_32_63)); 128 | assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->LineCommand)); 129 | assert_param(IS_LL_EXTI_MODE(EXTI_InitStruct->Mode)); 130 | 131 | /* ENABLE LineCommand */ 132 | if (EXTI_InitStruct->LineCommand != DISABLE) 133 | { 134 | assert_param(IS_LL_EXTI_TRIGGER(EXTI_InitStruct->Trigger)); 135 | 136 | /* Configure EXTI Lines in range from 0 to 31 */ 137 | if (EXTI_InitStruct->Line_0_31 != LL_EXTI_LINE_NONE) 138 | { 139 | switch (EXTI_InitStruct->Mode) 140 | { 141 | case LL_EXTI_MODE_IT: 142 | /* First Disable Event on provided Lines */ 143 | LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31); 144 | /* Then Enable IT on provided Lines */ 145 | LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31); 146 | break; 147 | case LL_EXTI_MODE_EVENT: 148 | /* First Disable IT on provided Lines */ 149 | LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31); 150 | /* Then Enable Event on provided Lines */ 151 | LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31); 152 | break; 153 | case LL_EXTI_MODE_IT_EVENT: 154 | /* Directly Enable IT & Event on provided Lines */ 155 | LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31); 156 | LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31); 157 | break; 158 | default: 159 | status = 0x01u; 160 | break; 161 | } 162 | if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE) 163 | { 164 | switch (EXTI_InitStruct->Trigger) 165 | { 166 | case LL_EXTI_TRIGGER_RISING: 167 | /* First Disable Falling Trigger on provided Lines */ 168 | LL_EXTI_DisableFallingTrig_0_31(EXTI_InitStruct->Line_0_31); 169 | /* Then Enable Rising Trigger on provided Lines */ 170 | LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31); 171 | break; 172 | case LL_EXTI_TRIGGER_FALLING: 173 | /* First Disable Rising Trigger on provided Lines */ 174 | LL_EXTI_DisableRisingTrig_0_31(EXTI_InitStruct->Line_0_31); 175 | /* Then Enable Falling Trigger on provided Lines */ 176 | LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31); 177 | break; 178 | case LL_EXTI_TRIGGER_RISING_FALLING: 179 | LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31); 180 | LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31); 181 | break; 182 | default: 183 | status |= 0x02u; 184 | break; 185 | } 186 | } 187 | } 188 | /* Configure EXTI Lines in range from 32 to 63 */ 189 | if (EXTI_InitStruct->Line_32_63 != LL_EXTI_LINE_NONE) 190 | { 191 | switch (EXTI_InitStruct->Mode) 192 | { 193 | case LL_EXTI_MODE_IT: 194 | /* First Disable Event on provided Lines */ 195 | LL_EXTI_DisableEvent_32_63(EXTI_InitStruct->Line_32_63); 196 | /* Then Enable IT on provided Lines */ 197 | LL_EXTI_EnableIT_32_63(EXTI_InitStruct->Line_32_63); 198 | break; 199 | case LL_EXTI_MODE_EVENT: 200 | /* First Disable IT on provided Lines */ 201 | LL_EXTI_DisableIT_32_63(EXTI_InitStruct->Line_32_63); 202 | /* Then Enable Event on provided Lines */ 203 | LL_EXTI_EnableEvent_32_63(EXTI_InitStruct->Line_32_63); 204 | break; 205 | case LL_EXTI_MODE_IT_EVENT: 206 | /* Directly Enable IT & Event on provided Lines */ 207 | LL_EXTI_EnableIT_32_63(EXTI_InitStruct->Line_32_63); 208 | LL_EXTI_EnableEvent_32_63(EXTI_InitStruct->Line_32_63); 209 | break; 210 | default: 211 | status |= 0x04u; 212 | break; 213 | } 214 | if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE) 215 | { 216 | switch (EXTI_InitStruct->Trigger) 217 | { 218 | case LL_EXTI_TRIGGER_RISING: 219 | /* First Disable Falling Trigger on provided Lines */ 220 | LL_EXTI_DisableFallingTrig_32_63(EXTI_InitStruct->Line_32_63); 221 | /* Then Enable IT on provided Lines */ 222 | LL_EXTI_EnableRisingTrig_32_63(EXTI_InitStruct->Line_32_63); 223 | break; 224 | case LL_EXTI_TRIGGER_FALLING: 225 | /* First Disable Rising Trigger on provided Lines */ 226 | LL_EXTI_DisableRisingTrig_32_63(EXTI_InitStruct->Line_32_63); 227 | /* Then Enable Falling Trigger on provided Lines */ 228 | LL_EXTI_EnableFallingTrig_32_63(EXTI_InitStruct->Line_32_63); 229 | break; 230 | case LL_EXTI_TRIGGER_RISING_FALLING: 231 | LL_EXTI_EnableRisingTrig_32_63(EXTI_InitStruct->Line_32_63); 232 | LL_EXTI_EnableFallingTrig_32_63(EXTI_InitStruct->Line_32_63); 233 | break; 234 | default: 235 | status = ERROR; 236 | break; 237 | } 238 | } 239 | } 240 | } 241 | /* DISABLE LineCommand */ 242 | else 243 | { 244 | /* De-configure EXTI Lines in range from 0 to 31 */ 245 | LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31); 246 | LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31); 247 | /* De-configure EXTI Lines in range from 32 to 63 */ 248 | LL_EXTI_DisableIT_32_63(EXTI_InitStruct->Line_32_63); 249 | LL_EXTI_DisableEvent_32_63(EXTI_InitStruct->Line_32_63); 250 | } 251 | 252 | return status; 253 | } 254 | 255 | /** 256 | * @brief Set each @ref LL_EXTI_InitTypeDef field to default value. 257 | * @param EXTI_InitStruct Pointer to a @ref LL_EXTI_InitTypeDef structure. 258 | * @retval None 259 | */ 260 | void LL_EXTI_StructInit(LL_EXTI_InitTypeDef *EXTI_InitStruct) 261 | { 262 | EXTI_InitStruct->Line_0_31 = LL_EXTI_LINE_NONE; 263 | EXTI_InitStruct->Line_32_63 = LL_EXTI_LINE_NONE; 264 | EXTI_InitStruct->LineCommand = DISABLE; 265 | EXTI_InitStruct->Mode = LL_EXTI_MODE_IT; 266 | EXTI_InitStruct->Trigger = LL_EXTI_TRIGGER_FALLING; 267 | } 268 | 269 | /** 270 | * @} 271 | */ 272 | 273 | /** 274 | * @} 275 | */ 276 | 277 | /** 278 | * @} 279 | */ 280 | 281 | #endif /* defined (EXTI) */ 282 | 283 | /** 284 | * @} 285 | */ 286 | 287 | #endif /* USE_FULL_LL_DRIVER */ 288 | 289 | -------------------------------------------------------------------------------- /fw/sample_target/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_gpio.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l4xx_ll_gpio.c 4 | * @author MCD Application Team 5 | * @brief GPIO LL module 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 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 | #if defined(USE_FULL_LL_DRIVER) 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "stm32l4xx_ll_gpio.h" 22 | #include "stm32l4xx_ll_bus.h" 23 | #ifdef USE_FULL_ASSERT 24 | #include "stm32_assert.h" 25 | #else 26 | #define assert_param(expr) ((void)0U) 27 | #endif 28 | 29 | /** @addtogroup STM32L4xx_LL_Driver 30 | * @{ 31 | */ 32 | 33 | #if defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOF) || defined (GPIOG) || defined (GPIOH) || defined (GPIOI) 34 | 35 | /** @addtogroup GPIO_LL 36 | * @{ 37 | */ 38 | /** MISRA C:2012 deviation rule has been granted for following rules: 39 | * Rule-12.2 - Medium: RHS argument is in interval [0,INF] which is out of 40 | * range of the shift operator in following API : 41 | * LL_GPIO_Init 42 | */ 43 | 44 | /* Private types -------------------------------------------------------------*/ 45 | /* Private variables ---------------------------------------------------------*/ 46 | /* Private constants ---------------------------------------------------------*/ 47 | /* Private macros ------------------------------------------------------------*/ 48 | /** @addtogroup GPIO_LL_Private_Macros 49 | * @{ 50 | */ 51 | #define IS_LL_GPIO_PIN(__VALUE__) (((0x00u) < (__VALUE__)) && ((__VALUE__) <= (LL_GPIO_PIN_ALL))) 52 | 53 | #define IS_LL_GPIO_MODE(__VALUE__) (((__VALUE__) == LL_GPIO_MODE_INPUT) ||\ 54 | ((__VALUE__) == LL_GPIO_MODE_OUTPUT) ||\ 55 | ((__VALUE__) == LL_GPIO_MODE_ALTERNATE) ||\ 56 | ((__VALUE__) == LL_GPIO_MODE_ANALOG)) 57 | 58 | #define IS_LL_GPIO_OUTPUT_TYPE(__VALUE__) (((__VALUE__) == LL_GPIO_OUTPUT_PUSHPULL) ||\ 59 | ((__VALUE__) == LL_GPIO_OUTPUT_OPENDRAIN)) 60 | 61 | #define IS_LL_GPIO_SPEED(__VALUE__) (((__VALUE__) == LL_GPIO_SPEED_FREQ_LOW) ||\ 62 | ((__VALUE__) == LL_GPIO_SPEED_FREQ_MEDIUM) ||\ 63 | ((__VALUE__) == LL_GPIO_SPEED_FREQ_HIGH) ||\ 64 | ((__VALUE__) == LL_GPIO_SPEED_FREQ_VERY_HIGH)) 65 | 66 | #define IS_LL_GPIO_PULL(__VALUE__) (((__VALUE__) == LL_GPIO_PULL_NO) ||\ 67 | ((__VALUE__) == LL_GPIO_PULL_UP) ||\ 68 | ((__VALUE__) == LL_GPIO_PULL_DOWN)) 69 | 70 | #define IS_LL_GPIO_ALTERNATE(__VALUE__) (((__VALUE__) == LL_GPIO_AF_0 ) ||\ 71 | ((__VALUE__) == LL_GPIO_AF_1 ) ||\ 72 | ((__VALUE__) == LL_GPIO_AF_2 ) ||\ 73 | ((__VALUE__) == LL_GPIO_AF_3 ) ||\ 74 | ((__VALUE__) == LL_GPIO_AF_4 ) ||\ 75 | ((__VALUE__) == LL_GPIO_AF_5 ) ||\ 76 | ((__VALUE__) == LL_GPIO_AF_6 ) ||\ 77 | ((__VALUE__) == LL_GPIO_AF_7 ) ||\ 78 | ((__VALUE__) == LL_GPIO_AF_8 ) ||\ 79 | ((__VALUE__) == LL_GPIO_AF_9 ) ||\ 80 | ((__VALUE__) == LL_GPIO_AF_10 ) ||\ 81 | ((__VALUE__) == LL_GPIO_AF_11 ) ||\ 82 | ((__VALUE__) == LL_GPIO_AF_12 ) ||\ 83 | ((__VALUE__) == LL_GPIO_AF_13 ) ||\ 84 | ((__VALUE__) == LL_GPIO_AF_14 ) ||\ 85 | ((__VALUE__) == LL_GPIO_AF_15 )) 86 | /** 87 | * @} 88 | */ 89 | 90 | /* Private function prototypes -----------------------------------------------*/ 91 | 92 | /* Exported functions --------------------------------------------------------*/ 93 | /** @addtogroup GPIO_LL_Exported_Functions 94 | * @{ 95 | */ 96 | 97 | /** @addtogroup GPIO_LL_EF_Init 98 | * @{ 99 | */ 100 | 101 | /** 102 | * @brief De-initialize GPIO registers (Registers restored to their default values). 103 | * @param GPIOx GPIO Port 104 | * @retval An ErrorStatus enumeration value: 105 | * - SUCCESS: GPIO registers are de-initialized 106 | * - ERROR: Wrong GPIO Port 107 | */ 108 | ErrorStatus LL_GPIO_DeInit(GPIO_TypeDef *GPIOx) 109 | { 110 | ErrorStatus status = SUCCESS; 111 | 112 | /* Check the parameters */ 113 | assert_param(IS_GPIO_ALL_INSTANCE(GPIOx)); 114 | 115 | /* Force and Release reset on clock of GPIOx Port */ 116 | if (GPIOx == GPIOA) 117 | { 118 | LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOA); 119 | LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOA); 120 | } 121 | else if (GPIOx == GPIOB) 122 | { 123 | LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOB); 124 | LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOB); 125 | } 126 | else if (GPIOx == GPIOC) 127 | { 128 | LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOC); 129 | LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOC); 130 | } 131 | #if defined(GPIOD) 132 | else if (GPIOx == GPIOD) 133 | { 134 | LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOD); 135 | LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOD); 136 | } 137 | #endif /* GPIOD */ 138 | #if defined(GPIOE) 139 | else if (GPIOx == GPIOE) 140 | { 141 | LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOE); 142 | LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOE); 143 | } 144 | #endif /* GPIOE */ 145 | #if defined(GPIOF) 146 | else if (GPIOx == GPIOF) 147 | { 148 | LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOF); 149 | LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOF); 150 | } 151 | #endif /* GPIOF */ 152 | #if defined(GPIOG) 153 | else if (GPIOx == GPIOG) 154 | { 155 | LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOG); 156 | LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOG); 157 | } 158 | #endif /* GPIOG */ 159 | #if defined(GPIOH) 160 | else if (GPIOx == GPIOH) 161 | { 162 | LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOH); 163 | LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOH); 164 | } 165 | #endif /* GPIOH */ 166 | #if defined(GPIOI) 167 | else if (GPIOx == GPIOI) 168 | { 169 | LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOI); 170 | LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOI); 171 | } 172 | #endif /* GPIOI */ 173 | else 174 | { 175 | status = ERROR; 176 | } 177 | 178 | return (status); 179 | } 180 | 181 | /** 182 | * @brief Initialize GPIO registers according to the specified parameters in GPIO_InitStruct. 183 | * @param GPIOx GPIO Port 184 | * @param GPIO_InitStruct pointer to a @ref LL_GPIO_InitTypeDef structure 185 | * that contains the configuration information for the specified GPIO peripheral. 186 | * @retval An ErrorStatus enumeration value: 187 | * - SUCCESS: GPIO registers are initialized according to GPIO_InitStruct content 188 | * - ERROR: Not applicable 189 | */ 190 | ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct) 191 | { 192 | uint32_t pinpos; 193 | uint32_t currentpin; 194 | 195 | /* Check the parameters */ 196 | assert_param(IS_GPIO_ALL_INSTANCE(GPIOx)); 197 | assert_param(IS_LL_GPIO_PIN(GPIO_InitStruct->Pin)); 198 | assert_param(IS_LL_GPIO_MODE(GPIO_InitStruct->Mode)); 199 | assert_param(IS_LL_GPIO_PULL(GPIO_InitStruct->Pull)); 200 | 201 | /* ------------------------- Configure the port pins ---------------- */ 202 | /* Initialize pinpos on first pin set */ 203 | pinpos = POSITION_VAL(GPIO_InitStruct->Pin); 204 | 205 | /* Configure the port pins */ 206 | while (((GPIO_InitStruct->Pin) >> pinpos) != 0x00u) 207 | { 208 | /* Get current io position */ 209 | currentpin = (GPIO_InitStruct->Pin) & (0x00000001uL << pinpos); 210 | 211 | if (currentpin != 0x00u) 212 | { 213 | if ((GPIO_InitStruct->Mode == LL_GPIO_MODE_OUTPUT) || (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE)) 214 | { 215 | /* Check Speed mode parameters */ 216 | assert_param(IS_LL_GPIO_SPEED(GPIO_InitStruct->Speed)); 217 | 218 | /* Speed mode configuration */ 219 | LL_GPIO_SetPinSpeed(GPIOx, currentpin, GPIO_InitStruct->Speed); 220 | 221 | /* Check Output mode parameters */ 222 | assert_param(IS_LL_GPIO_OUTPUT_TYPE(GPIO_InitStruct->OutputType)); 223 | 224 | /* Output mode configuration*/ 225 | LL_GPIO_SetPinOutputType(GPIOx, GPIO_InitStruct->Pin, GPIO_InitStruct->OutputType); 226 | } 227 | 228 | /* Pull-up Pull down resistor configuration*/ 229 | LL_GPIO_SetPinPull(GPIOx, currentpin, GPIO_InitStruct->Pull); 230 | 231 | if (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE) 232 | { 233 | /* Check Alternate parameter */ 234 | assert_param(IS_LL_GPIO_ALTERNATE(GPIO_InitStruct->Alternate)); 235 | 236 | /* Speed mode configuration */ 237 | if (currentpin < LL_GPIO_PIN_8) 238 | { 239 | LL_GPIO_SetAFPin_0_7(GPIOx, currentpin, GPIO_InitStruct->Alternate); 240 | } 241 | else 242 | { 243 | LL_GPIO_SetAFPin_8_15(GPIOx, currentpin, GPIO_InitStruct->Alternate); 244 | } 245 | } 246 | 247 | /* Pin Mode configuration */ 248 | LL_GPIO_SetPinMode(GPIOx, currentpin, GPIO_InitStruct->Mode); 249 | } 250 | pinpos++; 251 | } 252 | 253 | return (SUCCESS); 254 | } 255 | 256 | /** 257 | * @brief Set each @ref LL_GPIO_InitTypeDef field to default value. 258 | * @param GPIO_InitStruct pointer to a @ref LL_GPIO_InitTypeDef structure 259 | * whose fields will be set to default values. 260 | * @retval None 261 | */ 262 | 263 | void LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct) 264 | { 265 | /* Reset GPIO init structure parameters values */ 266 | GPIO_InitStruct->Pin = LL_GPIO_PIN_ALL; 267 | GPIO_InitStruct->Mode = LL_GPIO_MODE_ANALOG; 268 | GPIO_InitStruct->Speed = LL_GPIO_SPEED_FREQ_LOW; 269 | GPIO_InitStruct->OutputType = LL_GPIO_OUTPUT_PUSHPULL; 270 | GPIO_InitStruct->Pull = LL_GPIO_PULL_NO; 271 | GPIO_InitStruct->Alternate = LL_GPIO_AF_0; 272 | } 273 | 274 | /** 275 | * @} 276 | */ 277 | 278 | /** 279 | * @} 280 | */ 281 | 282 | /** 283 | * @} 284 | */ 285 | 286 | #endif /* defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOF) || defined (GPIOG) || defined (GPIOH) || defined (GPIOI) */ 287 | 288 | /** 289 | * @} 290 | */ 291 | 292 | #endif /* USE_FULL_LL_DRIVER */ 293 | 294 | -------------------------------------------------------------------------------- /fw/sample_target/Makefile: -------------------------------------------------------------------------------- 1 | ########################################################################################################################## 2 | # File automatically-generated by tool: [projectgenerator] version: [3.15.2] date: [Sun Feb 20 15:05:08 PST 2022] 3 | ########################################################################################################################## 4 | 5 | # ------------------------------------------------ 6 | # Generic Makefile (based on gcc) 7 | # 8 | # ChangeLog : 9 | # 2017-02-10 - Several enhancements + project update mode 10 | # 2015-07-22 - first version 11 | # ------------------------------------------------ 12 | 13 | ###################################### 14 | # target 15 | ###################################### 16 | TARGET = sample_target 17 | 18 | 19 | ###################################### 20 | # building variables 21 | ###################################### 22 | # debug build? 23 | DEBUG = 1 24 | # optimization 25 | OPT = -Og 26 | 27 | 28 | ####################################### 29 | # paths 30 | ####################################### 31 | # Build path 32 | BUILD_DIR = build 33 | 34 | ###################################### 35 | # source 36 | ###################################### 37 | # C sources 38 | C_SOURCES = \ 39 | Core/Src/main.c \ 40 | Core/Src/gpio.c \ 41 | Core/Src/adc.c \ 42 | Core/Src/stm32l4xx_it.c \ 43 | Core/Src/stm32l4xx_hal_msp.c \ 44 | USB_DEVICE/App/usb_device.c \ 45 | USB_DEVICE/App/usbd_desc.c \ 46 | USB_DEVICE/App/usbd_cdc_if.c \ 47 | USB_DEVICE/Target/usbd_conf.c \ 48 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_utils.c \ 49 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_exti.c \ 50 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_gpio.c \ 51 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pcd.c \ 52 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pcd_ex.c \ 53 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_usb.c \ 54 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c \ 55 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c \ 56 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c \ 57 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c \ 58 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c \ 59 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c \ 60 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c \ 61 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c \ 62 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c \ 63 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c \ 64 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c \ 65 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c \ 66 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c \ 67 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c \ 68 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c \ 69 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_adc.c \ 70 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_dma.c \ 71 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \ 72 | Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \ 73 | Core/Src/system_stm32l4xx.c \ 74 | Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c \ 75 | Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c \ 76 | Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c \ 77 | Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c 78 | 79 | # ASM sources 80 | ASM_SOURCES = \ 81 | startup_stm32l412xx.s 82 | 83 | 84 | ####################################### 85 | # binaries 86 | ####################################### 87 | PREFIX = arm-none-eabi- 88 | # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx) 89 | # either it can be added to the PATH environment variable. 90 | ifdef GCC_PATH 91 | CC = $(GCC_PATH)/$(PREFIX)gcc 92 | AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp 93 | CP = $(GCC_PATH)/$(PREFIX)objcopy 94 | SZ = $(GCC_PATH)/$(PREFIX)size 95 | else 96 | CC = $(PREFIX)gcc 97 | AS = $(PREFIX)gcc -x assembler-with-cpp 98 | CP = $(PREFIX)objcopy 99 | SZ = $(PREFIX)size 100 | endif 101 | HEX = $(CP) -O ihex 102 | BIN = $(CP) -O binary -S 103 | 104 | ####################################### 105 | # CFLAGS 106 | ####################################### 107 | # cpu 108 | CPU = -mcpu=cortex-m4 109 | 110 | # fpu 111 | FPU = -mfpu=fpv4-sp-d16 112 | 113 | # float-abi 114 | FLOAT-ABI = -mfloat-abi=hard 115 | 116 | # mcu 117 | MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI) 118 | 119 | # macros for gcc 120 | # AS defines 121 | AS_DEFS = 122 | 123 | # C defines 124 | C_DEFS = \ 125 | -DUSE_FULL_LL_DRIVER \ 126 | -DUSE_HAL_DRIVER \ 127 | -DSTM32L412xx 128 | 129 | 130 | # AS includes 131 | AS_INCLUDES = 132 | 133 | # C includes 134 | C_INCLUDES = \ 135 | -ICore/Inc \ 136 | -IUSB_DEVICE/App \ 137 | -IUSB_DEVICE/Target \ 138 | -IDrivers/STM32L4xx_HAL_Driver/Inc \ 139 | -IDrivers/STM32L4xx_HAL_Driver/Inc/Legacy \ 140 | -IMiddlewares/ST/STM32_USB_Device_Library/Core/Inc \ 141 | -IMiddlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc \ 142 | -IDrivers/CMSIS/Device/ST/STM32L4xx/Include \ 143 | -IDrivers/CMSIS/Include 144 | 145 | 146 | # compile gcc flags 147 | ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections 148 | 149 | CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections 150 | 151 | ifeq ($(DEBUG), 1) 152 | CFLAGS += -g -gdwarf-2 153 | endif 154 | 155 | 156 | # Generate dependency information 157 | CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" 158 | 159 | 160 | ####################################### 161 | # LDFLAGS 162 | ####################################### 163 | # link script 164 | LDSCRIPT = STM32L412C8Tx_FLASH.ld 165 | 166 | # libraries 167 | LIBS = -lc -lm -lnosys 168 | LIBDIR = 169 | LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections 170 | 171 | # default action: build all 172 | all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin 173 | 174 | 175 | ####################################### 176 | # build the application 177 | ####################################### 178 | # list of objects 179 | OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) 180 | vpath %.c $(sort $(dir $(C_SOURCES))) 181 | # list of ASM program objects 182 | OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) 183 | vpath %.s $(sort $(dir $(ASM_SOURCES))) 184 | 185 | $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 186 | $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ 187 | 188 | $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) 189 | $(AS) -c $(CFLAGS) $< -o $@ 190 | 191 | $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile 192 | $(CC) $(OBJECTS) $(LDFLAGS) -o $@ 193 | $(SZ) $@ 194 | 195 | $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) 196 | $(HEX) $< $@ 197 | 198 | $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) 199 | $(BIN) $< $@ 200 | 201 | $(BUILD_DIR): 202 | mkdir $@ 203 | 204 | ####################################### 205 | # clean up 206 | ####################################### 207 | clean: 208 | -rm -fR $(BUILD_DIR) 209 | 210 | ####################################### 211 | # dependencies 212 | ####################################### 213 | -include $(wildcard $(BUILD_DIR)/*.d) 214 | 215 | # *** EOF *** -------------------------------------------------------------------------------- /fw/sample_target/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 component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USB_CDC_H 22 | #define __USB_CDC_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_ioreq.h" 30 | 31 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 32 | * @{ 33 | */ 34 | 35 | /** @defgroup usbd_cdc 36 | * @brief This file is the Header file for usbd_cdc.c 37 | * @{ 38 | */ 39 | 40 | 41 | /** @defgroup usbd_cdc_Exported_Defines 42 | * @{ 43 | */ 44 | #define CDC_IN_EP 0x81U /* EP1 for data IN */ 45 | #define CDC_OUT_EP 0x01U /* EP1 for data OUT */ 46 | #define CDC_CMD_EP 0x82U /* EP2 for CDC commands */ 47 | 48 | #ifndef CDC_HS_BINTERVAL 49 | #define CDC_HS_BINTERVAL 0x10U 50 | #endif /* CDC_HS_BINTERVAL */ 51 | 52 | #ifndef CDC_FS_BINTERVAL 53 | #define CDC_FS_BINTERVAL 0x10U 54 | #endif /* CDC_FS_BINTERVAL */ 55 | 56 | /* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */ 57 | #define CDC_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */ 58 | #define CDC_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */ 59 | #define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */ 60 | 61 | #define USB_CDC_CONFIG_DESC_SIZ 67U 62 | #define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE 63 | #define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE 64 | 65 | #define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE 66 | #define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE 67 | 68 | #define CDC_REQ_MAX_DATA_SIZE 0x7U 69 | /*---------------------------------------------------------------------*/ 70 | /* CDC definitions */ 71 | /*---------------------------------------------------------------------*/ 72 | #define CDC_SEND_ENCAPSULATED_COMMAND 0x00U 73 | #define CDC_GET_ENCAPSULATED_RESPONSE 0x01U 74 | #define CDC_SET_COMM_FEATURE 0x02U 75 | #define CDC_GET_COMM_FEATURE 0x03U 76 | #define CDC_CLEAR_COMM_FEATURE 0x04U 77 | #define CDC_SET_LINE_CODING 0x20U 78 | #define CDC_GET_LINE_CODING 0x21U 79 | #define CDC_SET_CONTROL_LINE_STATE 0x22U 80 | #define CDC_SEND_BREAK 0x23U 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | 87 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 88 | * @{ 89 | */ 90 | 91 | /** 92 | * @} 93 | */ 94 | typedef struct 95 | { 96 | uint32_t bitrate; 97 | uint8_t format; 98 | uint8_t paritytype; 99 | uint8_t datatype; 100 | } USBD_CDC_LineCodingTypeDef; 101 | 102 | typedef struct _USBD_CDC_Itf 103 | { 104 | int8_t (* Init)(void); 105 | int8_t (* DeInit)(void); 106 | int8_t (* Control)(uint8_t cmd, uint8_t *pbuf, uint16_t length); 107 | int8_t (* Receive)(uint8_t *Buf, uint32_t *Len); 108 | int8_t (* TransmitCplt)(uint8_t *Buf, uint32_t *Len, uint8_t epnum); 109 | } USBD_CDC_ItfTypeDef; 110 | 111 | 112 | typedef struct 113 | { 114 | uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32bits alignment */ 115 | uint8_t CmdOpCode; 116 | uint8_t CmdLength; 117 | uint8_t *RxBuffer; 118 | uint8_t *TxBuffer; 119 | uint32_t RxLength; 120 | uint32_t TxLength; 121 | 122 | __IO uint32_t TxState; 123 | __IO uint32_t RxState; 124 | } USBD_CDC_HandleTypeDef; 125 | 126 | 127 | 128 | /** @defgroup USBD_CORE_Exported_Macros 129 | * @{ 130 | */ 131 | 132 | /** 133 | * @} 134 | */ 135 | 136 | /** @defgroup USBD_CORE_Exported_Variables 137 | * @{ 138 | */ 139 | 140 | extern USBD_ClassTypeDef USBD_CDC; 141 | #define USBD_CDC_CLASS &USBD_CDC 142 | /** 143 | * @} 144 | */ 145 | 146 | /** @defgroup USB_CORE_Exported_Functions 147 | * @{ 148 | */ 149 | uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev, 150 | USBD_CDC_ItfTypeDef *fops); 151 | 152 | uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, 153 | uint32_t length); 154 | 155 | uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff); 156 | uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev); 157 | uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev); 158 | /** 159 | * @} 160 | */ 161 | 162 | #ifdef __cplusplus 163 | } 164 | #endif 165 | 166 | #endif /* __USB_CDC_H */ 167 | /** 168 | * @} 169 | */ 170 | 171 | /** 172 | * @} 173 | */ 174 | 175 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 176 | -------------------------------------------------------------------------------- /fw/sample_target/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_core.h 4 | * @author MCD Application Team 5 | * @brief Header file for usbd_core.c file 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2015 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USBD_CORE_H 22 | #define __USBD_CORE_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_conf.h" 30 | #include "usbd_def.h" 31 | #include "usbd_ioreq.h" 32 | #include "usbd_ctlreq.h" 33 | 34 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 35 | * @{ 36 | */ 37 | 38 | /** @defgroup USBD_CORE 39 | * @brief This file is the Header file for usbd_core.c file 40 | * @{ 41 | */ 42 | 43 | 44 | /** @defgroup USBD_CORE_Exported_Defines 45 | * @{ 46 | */ 47 | #ifndef USBD_DEBUG_LEVEL 48 | #define USBD_DEBUG_LEVEL 0U 49 | #endif /* USBD_DEBUG_LEVEL */ 50 | /** 51 | * @} 52 | */ 53 | 54 | 55 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 56 | * @{ 57 | */ 58 | 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | 65 | 66 | /** @defgroup USBD_CORE_Exported_Macros 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup USBD_CORE_Exported_Variables 75 | * @{ 76 | */ 77 | #define USBD_SOF USBD_LL_SOF 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @defgroup USBD_CORE_Exported_FunctionsPrototype 83 | * @{ 84 | */ 85 | USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id); 86 | USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev); 87 | USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev); 88 | USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev); 89 | USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass); 90 | 91 | USBD_StatusTypeDef USBD_RunTestMode(USBD_HandleTypeDef *pdev); 92 | USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx); 93 | USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx); 94 | 95 | USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup); 96 | USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata); 97 | USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata); 98 | 99 | USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev); 100 | USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef speed); 101 | USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev); 102 | USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev); 103 | 104 | USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev); 105 | USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum); 106 | USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum); 107 | 108 | USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev); 109 | USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev); 110 | 111 | /* USBD Low Level Driver */ 112 | USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev); 113 | USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev); 114 | USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev); 115 | USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev); 116 | 117 | USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, 118 | uint8_t ep_type, uint16_t ep_mps); 119 | 120 | USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 121 | USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 122 | USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 123 | USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 124 | USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr); 125 | 126 | USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, 127 | uint8_t *pbuf, uint32_t size); 128 | 129 | USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, 130 | uint8_t *pbuf, uint32_t size); 131 | 132 | uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 133 | uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 134 | 135 | void USBD_LL_Delay(uint32_t Delay); 136 | 137 | /** 138 | * @} 139 | */ 140 | 141 | #ifdef __cplusplus 142 | } 143 | #endif 144 | 145 | #endif /* __USBD_CORE_H */ 146 | 147 | /** 148 | * @} 149 | */ 150 | 151 | /** 152 | * @} 153 | */ 154 | 155 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /fw/sample_target/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 component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USB_REQUEST_H 22 | #define __USB_REQUEST_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_def.h" 30 | 31 | 32 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 33 | * @{ 34 | */ 35 | 36 | /** @defgroup USBD_REQ 37 | * @brief header file for the usbd_req.c file 38 | * @{ 39 | */ 40 | 41 | /** @defgroup USBD_REQ_Exported_Defines 42 | * @{ 43 | */ 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @defgroup USBD_REQ_Exported_Types 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | 58 | /** @defgroup USBD_REQ_Exported_Macros 59 | * @{ 60 | */ 61 | /** 62 | * @} 63 | */ 64 | 65 | /** @defgroup USBD_REQ_Exported_Variables 66 | * @{ 67 | */ 68 | /** 69 | * @} 70 | */ 71 | 72 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype 73 | * @{ 74 | */ 75 | 76 | USBD_StatusTypeDef USBD_StdDevReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 77 | USBD_StatusTypeDef USBD_StdItfReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 78 | USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 79 | 80 | void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 81 | void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata); 82 | void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len); 83 | 84 | /** 85 | * @} 86 | */ 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | #endif /* __USB_REQUEST_H */ 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | 103 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 104 | -------------------------------------------------------------------------------- /fw/sample_target/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 component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USBD_IOREQ_H 22 | #define __USBD_IOREQ_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_def.h" 30 | #include "usbd_core.h" 31 | 32 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 33 | * @{ 34 | */ 35 | 36 | /** @defgroup USBD_IOREQ 37 | * @brief header file for the usbd_ioreq.c file 38 | * @{ 39 | */ 40 | 41 | /** @defgroup USBD_IOREQ_Exported_Defines 42 | * @{ 43 | */ 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @defgroup USBD_IOREQ_Exported_Types 50 | * @{ 51 | */ 52 | 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | 59 | 60 | /** @defgroup USBD_IOREQ_Exported_Macros 61 | * @{ 62 | */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup USBD_IOREQ_Exported_Variables 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype 77 | * @{ 78 | */ 79 | 80 | USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev, 81 | uint8_t *pbuf, uint32_t len); 82 | 83 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, 84 | uint8_t *pbuf, uint32_t len); 85 | 86 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev, 87 | uint8_t *pbuf, uint32_t len); 88 | 89 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev, 90 | uint8_t *pbuf, uint32_t len); 91 | 92 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev); 93 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev); 94 | 95 | uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | #ifdef __cplusplus 102 | } 103 | #endif 104 | 105 | #endif /* __USBD_IOREQ_H */ 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | /** 112 | * @} 113 | */ 114 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 115 | -------------------------------------------------------------------------------- /fw/sample_target/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 component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "usbd_ioreq.h" 22 | 23 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 24 | * @{ 25 | */ 26 | 27 | 28 | /** @defgroup USBD_IOREQ 29 | * @brief control I/O requests module 30 | * @{ 31 | */ 32 | 33 | /** @defgroup USBD_IOREQ_Private_TypesDefinitions 34 | * @{ 35 | */ 36 | /** 37 | * @} 38 | */ 39 | 40 | 41 | /** @defgroup USBD_IOREQ_Private_Defines 42 | * @{ 43 | */ 44 | 45 | /** 46 | * @} 47 | */ 48 | 49 | 50 | /** @defgroup USBD_IOREQ_Private_Macros 51 | * @{ 52 | */ 53 | /** 54 | * @} 55 | */ 56 | 57 | 58 | /** @defgroup USBD_IOREQ_Private_Variables 59 | * @{ 60 | */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | 67 | /** @defgroup USBD_IOREQ_Private_FunctionPrototypes 68 | * @{ 69 | */ 70 | /** 71 | * @} 72 | */ 73 | 74 | 75 | /** @defgroup USBD_IOREQ_Private_Functions 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @brief USBD_CtlSendData 81 | * send data on the ctl pipe 82 | * @param pdev: device instance 83 | * @param buff: pointer to data buffer 84 | * @param len: length of data to be sent 85 | * @retval status 86 | */ 87 | USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev, 88 | uint8_t *pbuf, uint32_t len) 89 | { 90 | /* Set EP0 State */ 91 | pdev->ep0_state = USBD_EP0_DATA_IN; 92 | pdev->ep_in[0].total_length = len; 93 | 94 | #ifdef USBD_AVOID_PACKET_SPLIT_MPS 95 | pdev->ep_in[0].rem_length = 0U; 96 | #else 97 | pdev->ep_in[0].rem_length = len; 98 | #endif 99 | 100 | /* Start the transfer */ 101 | (void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len); 102 | 103 | return USBD_OK; 104 | } 105 | 106 | /** 107 | * @brief USBD_CtlContinueSendData 108 | * continue sending data on the ctl pipe 109 | * @param pdev: device instance 110 | * @param buff: pointer to data buffer 111 | * @param len: length of data to be sent 112 | * @retval status 113 | */ 114 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, 115 | uint8_t *pbuf, uint32_t len) 116 | { 117 | /* Start the next transfer */ 118 | (void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len); 119 | 120 | return USBD_OK; 121 | } 122 | 123 | /** 124 | * @brief USBD_CtlPrepareRx 125 | * receive data on the ctl pipe 126 | * @param pdev: device instance 127 | * @param buff: pointer to data buffer 128 | * @param len: length of data to be received 129 | * @retval status 130 | */ 131 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev, 132 | uint8_t *pbuf, uint32_t len) 133 | { 134 | /* Set EP0 State */ 135 | pdev->ep0_state = USBD_EP0_DATA_OUT; 136 | pdev->ep_out[0].total_length = len; 137 | 138 | #ifdef USBD_AVOID_PACKET_SPLIT_MPS 139 | pdev->ep_out[0].rem_length = 0U; 140 | #else 141 | pdev->ep_out[0].rem_length = len; 142 | #endif 143 | 144 | /* Start the transfer */ 145 | (void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len); 146 | 147 | return USBD_OK; 148 | } 149 | 150 | /** 151 | * @brief USBD_CtlContinueRx 152 | * continue receive data on the ctl pipe 153 | * @param pdev: device instance 154 | * @param buff: pointer to data buffer 155 | * @param len: length of data to be received 156 | * @retval status 157 | */ 158 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev, 159 | uint8_t *pbuf, uint32_t len) 160 | { 161 | (void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len); 162 | 163 | return USBD_OK; 164 | } 165 | 166 | /** 167 | * @brief USBD_CtlSendStatus 168 | * send zero lzngth packet on the ctl pipe 169 | * @param pdev: device instance 170 | * @retval status 171 | */ 172 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev) 173 | { 174 | /* Set EP0 State */ 175 | pdev->ep0_state = USBD_EP0_STATUS_IN; 176 | 177 | /* Start the transfer */ 178 | (void)USBD_LL_Transmit(pdev, 0x00U, NULL, 0U); 179 | 180 | return USBD_OK; 181 | } 182 | 183 | /** 184 | * @brief USBD_CtlReceiveStatus 185 | * receive zero lzngth packet on the ctl pipe 186 | * @param pdev: device instance 187 | * @retval status 188 | */ 189 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev) 190 | { 191 | /* Set EP0 State */ 192 | pdev->ep0_state = USBD_EP0_STATUS_OUT; 193 | 194 | /* Start the transfer */ 195 | (void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U); 196 | 197 | return USBD_OK; 198 | } 199 | 200 | /** 201 | * @brief USBD_GetRxCount 202 | * returns the received data length 203 | * @param pdev: device instance 204 | * @param ep_addr: endpoint address 205 | * @retval Rx Data blength 206 | */ 207 | uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr) 208 | { 209 | return USBD_LL_GetRxDataSize(pdev, ep_addr); 210 | } 211 | 212 | /** 213 | * @} 214 | */ 215 | 216 | 217 | /** 218 | * @} 219 | */ 220 | 221 | 222 | /** 223 | * @} 224 | */ 225 | 226 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 227 | -------------------------------------------------------------------------------- /fw/sample_target/STM32L412C8Tx_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | 5 | ** File : LinkerScript.ld 6 | ** 7 | ** Author : Auto-generated by System Workbench for STM32 8 | ** 9 | ** Abstract : Linker script for STM32L412C8Tx series 10 | ** 64Kbytes FLASH and 48Kbytes RAM 11 | ** 12 | ** Set heap size, stack size and stack location according 13 | ** to application requirements. 14 | ** 15 | ** Set memory bank area and size if external memory is used. 16 | ** 17 | ** Target : STMicroelectronics STM32 18 | ** 19 | ** Distribution: The file is distributed “as is,” without any warranty 20 | ** of any kind. 21 | ** 22 | ***************************************************************************** 23 | ** @attention 24 | ** 25 | **

© COPYRIGHT(c) 2019 STMicroelectronics

26 | ** 27 | ** Redistribution and use in source and binary forms, with or without modification, 28 | ** are permitted provided that the following conditions are met: 29 | ** 1. Redistributions of source code must retain the above copyright notice, 30 | ** this list of conditions and the following disclaimer. 31 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 32 | ** this list of conditions and the following disclaimer in the documentation 33 | ** and/or other materials provided with the distribution. 34 | ** 3. Neither the name of STMicroelectronics nor the names of its contributors 35 | ** may be used to endorse or promote products derived from this software 36 | ** without specific prior written permission. 37 | ** 38 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 41 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 42 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 43 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 44 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 45 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 47 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | ** 49 | ***************************************************************************** 50 | */ 51 | 52 | /* Entry Point */ 53 | ENTRY(Reset_Handler) 54 | 55 | /* Highest address of the user mode stack */ 56 | _estack = 0x2000A000; /* end of RAM */ 57 | /* Generate a link error if heap and stack don't fit into RAM */ 58 | _Min_Heap_Size = 0x200; /* required amount of heap */ 59 | _Min_Stack_Size = 0x400; /* required amount of stack */ 60 | 61 | /* Specify the memory areas */ 62 | MEMORY 63 | { 64 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 40K 65 | RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 8K 66 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 64K 67 | } 68 | 69 | /* Define output sections */ 70 | SECTIONS 71 | { 72 | /* The startup code goes first into FLASH */ 73 | .isr_vector : 74 | { 75 | . = ALIGN(8); 76 | KEEP(*(.isr_vector)) /* Startup code */ 77 | . = ALIGN(8); 78 | } >FLASH 79 | 80 | /* The program code and other data goes into FLASH */ 81 | .text : 82 | { 83 | . = ALIGN(8); 84 | *(.text) /* .text sections (code) */ 85 | *(.text*) /* .text* sections (code) */ 86 | *(.glue_7) /* glue arm to thumb code */ 87 | *(.glue_7t) /* glue thumb to arm code */ 88 | *(.eh_frame) 89 | 90 | KEEP (*(.init)) 91 | KEEP (*(.fini)) 92 | 93 | . = ALIGN(8); 94 | _etext = .; /* define a global symbols at end of code */ 95 | } >FLASH 96 | 97 | /* Constant data goes into FLASH */ 98 | .rodata : 99 | { 100 | . = ALIGN(8); 101 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 102 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 103 | . = ALIGN(8); 104 | } >FLASH 105 | 106 | .ARM.extab : 107 | { 108 | . = ALIGN(8); 109 | *(.ARM.extab* .gnu.linkonce.armextab.*) 110 | . = ALIGN(8); 111 | } >FLASH 112 | .ARM : { 113 | . = ALIGN(8); 114 | __exidx_start = .; 115 | *(.ARM.exidx*) 116 | __exidx_end = .; 117 | . = ALIGN(8); 118 | } >FLASH 119 | 120 | .preinit_array : 121 | { 122 | . = ALIGN(8); 123 | PROVIDE_HIDDEN (__preinit_array_start = .); 124 | KEEP (*(.preinit_array*)) 125 | PROVIDE_HIDDEN (__preinit_array_end = .); 126 | . = ALIGN(8); 127 | } >FLASH 128 | 129 | .init_array : 130 | { 131 | . = ALIGN(8); 132 | PROVIDE_HIDDEN (__init_array_start = .); 133 | KEEP (*(SORT(.init_array.*))) 134 | KEEP (*(.init_array*)) 135 | PROVIDE_HIDDEN (__init_array_end = .); 136 | . = ALIGN(8); 137 | } >FLASH 138 | .fini_array : 139 | { 140 | . = ALIGN(8); 141 | PROVIDE_HIDDEN (__fini_array_start = .); 142 | KEEP (*(SORT(.fini_array.*))) 143 | KEEP (*(.fini_array*)) 144 | PROVIDE_HIDDEN (__fini_array_end = .); 145 | . = ALIGN(8); 146 | } >FLASH 147 | 148 | /* used by the startup to initialize data */ 149 | _sidata = LOADADDR(.data); 150 | 151 | /* Initialized data sections goes into RAM, load LMA copy after code */ 152 | .data : 153 | { 154 | . = ALIGN(8); 155 | _sdata = .; /* create a global symbol at data start */ 156 | *(.data) /* .data sections */ 157 | *(.data*) /* .data* sections */ 158 | 159 | . = ALIGN(8); 160 | _edata = .; /* define a global symbol at data end */ 161 | } >RAM AT> FLASH 162 | 163 | 164 | /* Uninitialized data section */ 165 | . = ALIGN(4); 166 | .bss : 167 | { 168 | /* This is used by the startup in order to initialize the .bss secion */ 169 | _sbss = .; /* define a global symbol at bss start */ 170 | __bss_start__ = _sbss; 171 | *(.bss) 172 | *(.bss*) 173 | *(COMMON) 174 | 175 | . = ALIGN(4); 176 | _ebss = .; /* define a global symbol at bss end */ 177 | __bss_end__ = _ebss; 178 | } >RAM 179 | 180 | /* User_heap_stack section, used to check that there is enough RAM left */ 181 | ._user_heap_stack : 182 | { 183 | . = ALIGN(8); 184 | PROVIDE ( end = . ); 185 | PROVIDE ( _end = . ); 186 | . = . + _Min_Heap_Size; 187 | . = . + _Min_Stack_Size; 188 | . = ALIGN(8); 189 | } >RAM 190 | 191 | 192 | 193 | /* Remove information from the standard libraries */ 194 | /DISCARD/ : 195 | { 196 | libc.a ( * ) 197 | libm.a ( * ) 198 | libgcc.a ( * ) 199 | } 200 | 201 | .ARM.attributes 0 : { *(.ARM.attributes) } 202 | } 203 | 204 | 205 | -------------------------------------------------------------------------------- /fw/sample_target/USB_DEVICE/App/usb_device.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usb_device.c 5 | * @version : v2.0_Cube 6 | * @brief : This file implements the USB Device 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | 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 | extern USBD_DescriptorsTypeDef FS_Desc; 46 | 47 | /* 48 | * -- Insert your variables declaration here -- 49 | */ 50 | /* USER CODE BEGIN 0 */ 51 | 52 | /* USER CODE END 0 */ 53 | 54 | /* 55 | * -- Insert your external function declaration here -- 56 | */ 57 | /* USER CODE BEGIN 1 */ 58 | 59 | /* USER CODE END 1 */ 60 | 61 | /** 62 | * Init USB device Library, add supported class and start the library 63 | * @retval None 64 | */ 65 | void MX_USB_DEVICE_Init(void) 66 | { 67 | /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ 68 | 69 | /* USER CODE END USB_DEVICE_Init_PreTreatment */ 70 | 71 | /* Init Device Library, add supported class and start the library. */ 72 | if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) 73 | { 74 | Error_Handler(); 75 | } 76 | if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) 77 | { 78 | Error_Handler(); 79 | } 80 | if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK) 81 | { 82 | Error_Handler(); 83 | } 84 | if (USBD_Start(&hUsbDeviceFS) != USBD_OK) 85 | { 86 | Error_Handler(); 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 | -------------------------------------------------------------------------------- /fw/sample_target/USB_DEVICE/App/usb_device.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usb_device.h 5 | * @version : v2.0_Cube 6 | * @brief : Header for usb_device.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __USB_DEVICE__H__ 23 | #define __USB_DEVICE__H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32l4xx.h" 31 | #include "stm32l4xx_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 | -------------------------------------------------------------------------------- /fw/sample_target/USB_DEVICE/App/usbd_cdc_if.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_cdc_if.c 5 | * @version : v2.0_Cube 6 | * @brief : Usb device for Virtual Com Port. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "usbd_cdc_if.h" 23 | 24 | /* USER CODE BEGIN INCLUDE */ 25 | 26 | /* USER CODE END INCLUDE */ 27 | 28 | /* Private typedef -----------------------------------------------------------*/ 29 | /* Private define ------------------------------------------------------------*/ 30 | /* Private macro -------------------------------------------------------------*/ 31 | 32 | /* USER CODE BEGIN PV */ 33 | /* Private variables ---------------------------------------------------------*/ 34 | 35 | /* USER CODE END PV */ 36 | 37 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 38 | * @brief Usb device library. 39 | * @{ 40 | */ 41 | 42 | /** @addtogroup USBD_CDC_IF 43 | * @{ 44 | */ 45 | 46 | /** @defgroup USBD_CDC_IF_Private_TypesDefinitions USBD_CDC_IF_Private_TypesDefinitions 47 | * @brief Private types. 48 | * @{ 49 | */ 50 | 51 | /* USER CODE BEGIN PRIVATE_TYPES */ 52 | 53 | /* USER CODE END PRIVATE_TYPES */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @defgroup USBD_CDC_IF_Private_Defines USBD_CDC_IF_Private_Defines 60 | * @brief Private defines. 61 | * @{ 62 | */ 63 | 64 | /* USER CODE BEGIN PRIVATE_DEFINES */ 65 | /* USER CODE END PRIVATE_DEFINES */ 66 | 67 | /** 68 | * @} 69 | */ 70 | 71 | /** @defgroup USBD_CDC_IF_Private_Macros USBD_CDC_IF_Private_Macros 72 | * @brief Private macros. 73 | * @{ 74 | */ 75 | 76 | /* USER CODE BEGIN PRIVATE_MACRO */ 77 | 78 | /* USER CODE END PRIVATE_MACRO */ 79 | 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup USBD_CDC_IF_Private_Variables USBD_CDC_IF_Private_Variables 85 | * @brief Private variables. 86 | * @{ 87 | */ 88 | /* Create buffer for reception and transmission */ 89 | /* It's up to user to redefine and/or remove those define */ 90 | /** Received data over USB are stored in this buffer */ 91 | uint8_t UserRxBufferFS[APP_RX_DATA_SIZE]; 92 | 93 | /** Data to send over USB CDC are stored in this buffer */ 94 | uint8_t UserTxBufferFS[APP_TX_DATA_SIZE]; 95 | 96 | /* USER CODE BEGIN PRIVATE_VARIABLES */ 97 | 98 | /* USER CODE END PRIVATE_VARIABLES */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | /** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables 105 | * @brief Public variables. 106 | * @{ 107 | */ 108 | 109 | extern USBD_HandleTypeDef hUsbDeviceFS; 110 | 111 | /* USER CODE BEGIN EXPORTED_VARIABLES */ 112 | 113 | /* USER CODE END EXPORTED_VARIABLES */ 114 | 115 | /** 116 | * @} 117 | */ 118 | 119 | /** @defgroup USBD_CDC_IF_Private_FunctionPrototypes USBD_CDC_IF_Private_FunctionPrototypes 120 | * @brief Private functions declaration. 121 | * @{ 122 | */ 123 | 124 | static int8_t CDC_Init_FS(void); 125 | static int8_t CDC_DeInit_FS(void); 126 | static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length); 127 | static int8_t CDC_Receive_FS(uint8_t* pbuf, uint32_t *Len); 128 | static int8_t CDC_TransmitCplt_FS(uint8_t *pbuf, uint32_t *Len, uint8_t epnum); 129 | 130 | /* USER CODE BEGIN PRIVATE_FUNCTIONS_DECLARATION */ 131 | 132 | /* USER CODE END PRIVATE_FUNCTIONS_DECLARATION */ 133 | 134 | /** 135 | * @} 136 | */ 137 | 138 | USBD_CDC_ItfTypeDef USBD_Interface_fops_FS = 139 | { 140 | CDC_Init_FS, 141 | CDC_DeInit_FS, 142 | CDC_Control_FS, 143 | CDC_Receive_FS, 144 | CDC_TransmitCplt_FS 145 | }; 146 | 147 | /* Private functions ---------------------------------------------------------*/ 148 | /** 149 | * @brief Initializes the CDC media low layer over the FS USB IP 150 | * @retval USBD_OK if all operations are OK else USBD_FAIL 151 | */ 152 | static int8_t CDC_Init_FS(void) 153 | { 154 | /* USER CODE BEGIN 3 */ 155 | /* Set Application Buffers */ 156 | USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0); 157 | USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS); 158 | return (USBD_OK); 159 | /* USER CODE END 3 */ 160 | } 161 | 162 | /** 163 | * @brief DeInitializes the CDC media low layer 164 | * @retval USBD_OK if all operations are OK else USBD_FAIL 165 | */ 166 | static int8_t CDC_DeInit_FS(void) 167 | { 168 | /* USER CODE BEGIN 4 */ 169 | return (USBD_OK); 170 | /* USER CODE END 4 */ 171 | } 172 | 173 | /** 174 | * @brief Manage the CDC class requests 175 | * @param cmd: Command code 176 | * @param pbuf: Buffer containing command data (request parameters) 177 | * @param length: Number of data to be sent (in bytes) 178 | * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL 179 | */ 180 | static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) 181 | { 182 | /* USER CODE BEGIN 5 */ 183 | switch(cmd) 184 | { 185 | case CDC_SEND_ENCAPSULATED_COMMAND: 186 | 187 | break; 188 | 189 | case CDC_GET_ENCAPSULATED_RESPONSE: 190 | 191 | break; 192 | 193 | case CDC_SET_COMM_FEATURE: 194 | 195 | break; 196 | 197 | case CDC_GET_COMM_FEATURE: 198 | 199 | break; 200 | 201 | case CDC_CLEAR_COMM_FEATURE: 202 | 203 | break; 204 | 205 | /*******************************************************************************/ 206 | /* Line Coding Structure */ 207 | /*-----------------------------------------------------------------------------*/ 208 | /* Offset | Field | Size | Value | Description */ 209 | /* 0 | dwDTERate | 4 | Number |Data terminal rate, in bits per second*/ 210 | /* 4 | bCharFormat | 1 | Number | Stop bits */ 211 | /* 0 - 1 Stop bit */ 212 | /* 1 - 1.5 Stop bits */ 213 | /* 2 - 2 Stop bits */ 214 | /* 5 | bParityType | 1 | Number | Parity */ 215 | /* 0 - None */ 216 | /* 1 - Odd */ 217 | /* 2 - Even */ 218 | /* 3 - Mark */ 219 | /* 4 - Space */ 220 | /* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */ 221 | /*******************************************************************************/ 222 | case CDC_SET_LINE_CODING: 223 | 224 | break; 225 | 226 | case CDC_GET_LINE_CODING: 227 | 228 | break; 229 | 230 | case CDC_SET_CONTROL_LINE_STATE: 231 | 232 | break; 233 | 234 | case CDC_SEND_BREAK: 235 | 236 | break; 237 | 238 | default: 239 | break; 240 | } 241 | 242 | return (USBD_OK); 243 | /* USER CODE END 5 */ 244 | } 245 | 246 | /** 247 | * @brief Data received over USB OUT endpoint are sent over CDC interface 248 | * through this function. 249 | * 250 | * @note 251 | * This function will issue a NAK packet on any OUT packet received on 252 | * USB endpoint until exiting this function. If you exit this function 253 | * before transfer is complete on CDC interface (ie. using DMA controller) 254 | * it will result in receiving more data while previous ones are still 255 | * not sent. 256 | * 257 | * @param Buf: Buffer of data to be received 258 | * @param Len: Number of data received (in bytes) 259 | * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL 260 | */ 261 | static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len) 262 | { 263 | /* USER CODE BEGIN 6 */ 264 | USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); 265 | USBD_CDC_ReceivePacket(&hUsbDeviceFS); 266 | return (USBD_OK); 267 | /* USER CODE END 6 */ 268 | } 269 | 270 | /** 271 | * @brief CDC_Transmit_FS 272 | * Data to send over USB IN endpoint are sent over CDC interface 273 | * through this function. 274 | * @note 275 | * 276 | * 277 | * @param Buf: Buffer of data to be sent 278 | * @param Len: Number of data to be sent (in bytes) 279 | * @retval USBD_OK if all operations are OK else USBD_FAIL or USBD_BUSY 280 | */ 281 | uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len) 282 | { 283 | uint8_t result = USBD_OK; 284 | /* USER CODE BEGIN 7 */ 285 | USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData; 286 | if (hcdc->TxState != 0){ 287 | return USBD_BUSY; 288 | } 289 | USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len); 290 | result = USBD_CDC_TransmitPacket(&hUsbDeviceFS); 291 | /* USER CODE END 7 */ 292 | return result; 293 | } 294 | 295 | /** 296 | * @brief CDC_TransmitCplt_FS 297 | * Data transmitted callback 298 | * 299 | * @note 300 | * This function is IN transfer complete callback used to inform user that 301 | * the submitted Data is successfully sent over USB. 302 | * 303 | * @param Buf: Buffer of data to be received 304 | * @param Len: Number of data received (in bytes) 305 | * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL 306 | */ 307 | static int8_t CDC_TransmitCplt_FS(uint8_t *Buf, uint32_t *Len, uint8_t epnum) 308 | { 309 | uint8_t result = USBD_OK; 310 | /* USER CODE BEGIN 13 */ 311 | UNUSED(Buf); 312 | UNUSED(Len); 313 | UNUSED(epnum); 314 | /* USER CODE END 13 */ 315 | return result; 316 | } 317 | 318 | /* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */ 319 | 320 | /* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */ 321 | 322 | /** 323 | * @} 324 | */ 325 | 326 | /** 327 | * @} 328 | */ 329 | -------------------------------------------------------------------------------- /fw/sample_target/USB_DEVICE/App/usbd_cdc_if.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_cdc_if.h 5 | * @version : v2.0_Cube 6 | * @brief : Header for usbd_cdc_if.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __USBD_CDC_IF_H__ 23 | #define __USBD_CDC_IF_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "usbd_cdc.h" 31 | 32 | /* USER CODE BEGIN INCLUDE */ 33 | 34 | /* USER CODE END INCLUDE */ 35 | 36 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 37 | * @brief For Usb device. 38 | * @{ 39 | */ 40 | 41 | /** @defgroup USBD_CDC_IF USBD_CDC_IF 42 | * @brief Usb VCP device module 43 | * @{ 44 | */ 45 | 46 | /** @defgroup USBD_CDC_IF_Exported_Defines USBD_CDC_IF_Exported_Defines 47 | * @brief Defines. 48 | * @{ 49 | */ 50 | /* Define size for the receive and transmit buffer over CDC */ 51 | #define APP_RX_DATA_SIZE 1000 52 | #define APP_TX_DATA_SIZE 1000 53 | /* USER CODE BEGIN EXPORTED_DEFINES */ 54 | 55 | /* USER CODE END EXPORTED_DEFINES */ 56 | 57 | /** 58 | * @} 59 | */ 60 | 61 | /** @defgroup USBD_CDC_IF_Exported_Types USBD_CDC_IF_Exported_Types 62 | * @brief Types. 63 | * @{ 64 | */ 65 | 66 | /* USER CODE BEGIN EXPORTED_TYPES */ 67 | 68 | /* USER CODE END EXPORTED_TYPES */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup USBD_CDC_IF_Exported_Macros USBD_CDC_IF_Exported_Macros 75 | * @brief Aliases. 76 | * @{ 77 | */ 78 | 79 | /* USER CODE BEGIN EXPORTED_MACRO */ 80 | 81 | /* USER CODE END EXPORTED_MACRO */ 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | /** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables 88 | * @brief Public variables. 89 | * @{ 90 | */ 91 | 92 | /** CDC Interface callback. */ 93 | extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS; 94 | 95 | /* USER CODE BEGIN EXPORTED_VARIABLES */ 96 | 97 | /* USER CODE END EXPORTED_VARIABLES */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** @defgroup USBD_CDC_IF_Exported_FunctionsPrototype USBD_CDC_IF_Exported_FunctionsPrototype 104 | * @brief Public functions declaration. 105 | * @{ 106 | */ 107 | 108 | uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len); 109 | 110 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */ 111 | 112 | /* USER CODE END EXPORTED_FUNCTIONS */ 113 | 114 | /** 115 | * @} 116 | */ 117 | 118 | /** 119 | * @} 120 | */ 121 | 122 | /** 123 | * @} 124 | */ 125 | 126 | #ifdef __cplusplus 127 | } 128 | #endif 129 | 130 | #endif /* __USBD_CDC_IF_H__ */ 131 | 132 | -------------------------------------------------------------------------------- /fw/sample_target/USB_DEVICE/App/usbd_desc.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_desc.c 5 | * @version : v2.0_Cube 6 | * @brief : Header for usbd_conf.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* 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 | -------------------------------------------------------------------------------- /fw/sample_target/USB_DEVICE/Target/usbd_conf.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_conf.h 5 | * @version : v2.0_Cube 6 | * @brief : Header for usbd_conf.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __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 "stm32l4xx.h" 35 | #include "stm32l4xx_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 1U 75 | /*---------- -----------*/ 76 | #define USBD_SELF_POWERED 1U 77 | 78 | /****************************************/ 79 | /* #define for FS and HS identification */ 80 | #define DEVICE_FS 0 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros 87 | * @brief Aliases. 88 | * @{ 89 | */ 90 | 91 | /* Memory management macros */ 92 | 93 | /* Memory management macros make sure to use static memory allocation */ 94 | 95 | /** Alias for memory allocation. */ 96 | #define USBD_malloc (void *)USBD_static_malloc 97 | 98 | /** Alias for memory release. */ 99 | #define USBD_free USBD_static_free 100 | 101 | /** Alias for memory set. */ 102 | #define USBD_memset memset 103 | 104 | /** Alias for memory copy. */ 105 | #define USBD_memcpy memcpy 106 | 107 | /** Alias for delay. */ 108 | #define USBD_Delay HAL_Delay 109 | 110 | /* DEBUG macros */ 111 | 112 | #if (USBD_DEBUG_LEVEL > 0) 113 | #define USBD_UsrLog(...) printf(__VA_ARGS__);\ 114 | printf("\n"); 115 | #else 116 | #define USBD_UsrLog(...) 117 | #endif 118 | 119 | #if (USBD_DEBUG_LEVEL > 1) 120 | 121 | #define USBD_ErrLog(...) printf("ERROR: ") ;\ 122 | printf(__VA_ARGS__);\ 123 | printf("\n"); 124 | #else 125 | #define USBD_ErrLog(...) 126 | #endif 127 | 128 | #if (USBD_DEBUG_LEVEL > 2) 129 | #define USBD_DbgLog(...) printf("DEBUG : ") ;\ 130 | printf(__VA_ARGS__);\ 131 | printf("\n"); 132 | #else 133 | #define USBD_DbgLog(...) 134 | #endif 135 | 136 | /** 137 | * @} 138 | */ 139 | 140 | /** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types 141 | * @brief Types. 142 | * @{ 143 | */ 144 | 145 | /** 146 | * @} 147 | */ 148 | 149 | /** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype 150 | * @brief Declaration of public functions for Usb device. 151 | * @{ 152 | */ 153 | 154 | /* Exported functions -------------------------------------------------------*/ 155 | void *USBD_static_malloc(uint32_t size); 156 | void USBD_static_free(void *p); 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | /** 163 | * @} 164 | */ 165 | 166 | /** 167 | * @} 168 | */ 169 | 170 | #ifdef __cplusplus 171 | } 172 | #endif 173 | 174 | #endif /* __USBD_CONF__H__ */ 175 | 176 | -------------------------------------------------------------------------------- /fw/sample_target/sample_target.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_5 3 | ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,NbrOfConversionFlag,master 4 | ADC1.NbrOfConversionFlag=1 5 | ADC1.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE 6 | ADC1.Rank-0\#ChannelRegularConversion=1 7 | ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_2CYCLES_5 8 | ADC1.master=1 9 | File.Version=6 10 | GPIO.groupedBy= 11 | KeepUserPlacement=false 12 | Mcu.Family=STM32L4 13 | Mcu.IP0=ADC1 14 | Mcu.IP1=NVIC 15 | Mcu.IP2=RCC 16 | Mcu.IP3=SYS 17 | Mcu.IP4=USB 18 | Mcu.IP5=USB_DEVICE 19 | Mcu.IPNb=6 20 | Mcu.Name=STM32L412C8Tx 21 | Mcu.Package=LQFP48 22 | Mcu.Pin0=PA0 23 | Mcu.Pin1=PA1 24 | Mcu.Pin2=PB0 25 | Mcu.Pin3=PB1 26 | Mcu.Pin4=PA11 27 | Mcu.Pin5=PA12 28 | Mcu.Pin6=PH3-BOOT0 (BOOT0) 29 | Mcu.Pin7=VP_SYS_VS_Systick 30 | Mcu.Pin8=VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS 31 | Mcu.PinsNb=9 32 | Mcu.ThirdPartyNb=0 33 | Mcu.UserConstants= 34 | Mcu.UserName=STM32L412C8Tx 35 | MxCube.Version=6.4.0 36 | MxDb.Version=DB.6.0.40 37 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 38 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false 39 | NVIC.ForceEnableDMAVector=true 40 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 41 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false 42 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false 43 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false 44 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 45 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false 46 | NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true 47 | NVIC.USB_IRQn=true\:0\:0\:false\:false\:true\:false\:true 48 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 49 | PA0.Locked=true 50 | PA0.Signal=ADCx_IN5 51 | PA1.Locked=true 52 | PA1.Signal=ADCx_IN6 53 | PA11.Mode=Device 54 | PA11.Signal=USB_DM 55 | PA12.Mode=Device 56 | PA12.Signal=USB_DP 57 | PB0.GPIOParameters=GPIO_Label 58 | PB0.GPIO_Label=LED1 59 | PB0.Locked=true 60 | PB0.Signal=GPIO_Output 61 | PB1.GPIOParameters=GPIO_Label 62 | PB1.GPIO_Label=LED2 63 | PB1.Locked=true 64 | PB1.Signal=GPIO_Output 65 | PH3-BOOT0\ (BOOT0).GPIOParameters=GPIO_Label 66 | PH3-BOOT0\ (BOOT0).GPIO_Label=BOOT 67 | PH3-BOOT0\ (BOOT0).Locked=true 68 | PH3-BOOT0\ (BOOT0).Signal=GPIO_Input 69 | PinOutPanel.RotationAngle=0 70 | ProjectManager.AskForMigrate=true 71 | ProjectManager.BackupPrevious=false 72 | ProjectManager.CompilerOptimize=6 73 | ProjectManager.ComputerToolchain=false 74 | ProjectManager.CoupleFile=true 75 | ProjectManager.CustomerFirmwarePackage= 76 | ProjectManager.DefaultFWLocation=true 77 | ProjectManager.DeletePrevious=true 78 | ProjectManager.DeviceId=STM32L412C8Tx 79 | ProjectManager.FirmwarePackage=STM32Cube FW_L4 V1.17.1 80 | ProjectManager.FreePins=false 81 | ProjectManager.HalAssertFull=false 82 | ProjectManager.HeapSize=0x200 83 | ProjectManager.KeepUserCode=true 84 | ProjectManager.LastFirmware=true 85 | ProjectManager.LibraryCopy=1 86 | ProjectManager.MainLocation=Core/Src 87 | ProjectManager.NoMain=false 88 | ProjectManager.PreviousToolchain= 89 | ProjectManager.ProjectBuild=false 90 | ProjectManager.ProjectFileName=sample_target.ioc 91 | ProjectManager.ProjectName=sample_target 92 | ProjectManager.RegisterCallBack= 93 | ProjectManager.StackSize=0x400 94 | ProjectManager.TargetToolchain=Makefile 95 | ProjectManager.ToolChainLocation= 96 | ProjectManager.UnderRoot=false 97 | ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-LL-true,2-SystemClock_Config-RCC-false-LL-false,3-MX_ADC1_Init-ADC1-false-LL-true,4-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false 98 | RCC.ADCFreq_Value=80000000 99 | RCC.AHBFreq_Value=80000000 100 | RCC.APB1Freq_Value=80000000 101 | RCC.APB1TimFreq_Value=80000000 102 | RCC.APB2Freq_Value=80000000 103 | RCC.APB2TimFreq_Value=80000000 104 | RCC.CRSFreq_Value=48000000 105 | RCC.CortexFreq_Value=80000000 106 | RCC.FCLKCortexFreq_Value=80000000 107 | RCC.FamilyName=M 108 | RCC.HCLKFreq_Value=80000000 109 | RCC.HSE_VALUE=8000000 110 | RCC.HSI48_VALUE=48000000 111 | RCC.HSI_VALUE=16000000 112 | RCC.I2C1Freq_Value=80000000 113 | RCC.I2C2Freq_Value=80000000 114 | RCC.I2C3Freq_Value=80000000 115 | RCC.IPParameters=ADCFreq_Value,AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CRSFreq_Value,CortexFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI48_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPUART1Freq_Value,LSCOPinFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,MSIClockRange,MSI_VALUE,PLLN,PLLQoutputFreq_Value,PLLRCLKFreq_Value,PLLSourceVirtual,PWRFreq_Value,RNGFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USBFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value 116 | RCC.LPTIM1Freq_Value=80000000 117 | RCC.LPTIM2Freq_Value=80000000 118 | RCC.LPUART1Freq_Value=80000000 119 | RCC.LSCOPinFreq_Value=32000 120 | RCC.LSE_VALUE=32768 121 | RCC.LSI_VALUE=32000 122 | RCC.MCO1PinFreq_Value=80000000 123 | RCC.MSIClockRange=RCC_MSIRANGE_11 124 | RCC.MSI_VALUE=48000000 125 | RCC.PLLN=10 126 | RCC.PLLQoutputFreq_Value=80000000 127 | RCC.PLLRCLKFreq_Value=80000000 128 | RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSI 129 | RCC.PWRFreq_Value=80000000 130 | RCC.RNGFreq_Value=48000000 131 | RCC.SYSCLKFreq_VALUE=80000000 132 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK 133 | RCC.USART1Freq_Value=80000000 134 | RCC.USART2Freq_Value=80000000 135 | RCC.USART3Freq_Value=80000000 136 | RCC.USBFreq_Value=48000000 137 | RCC.VCOInputFreq_Value=16000000 138 | RCC.VCOOutputFreq_Value=160000000 139 | SH.ADCx_IN5.0=ADC1_IN5,IN5-Single-Ended 140 | SH.ADCx_IN5.ConfNb=1 141 | SH.ADCx_IN6.0=ADC1_IN6,IN6-Single-Ended 142 | SH.ADCx_IN6.ConfNb=1 143 | USB_DEVICE.CLASS_NAME_FS=CDC 144 | USB_DEVICE.IPParameters=VirtualMode,VirtualModeFS,CLASS_NAME_FS 145 | USB_DEVICE.VirtualMode=Cdc 146 | USB_DEVICE.VirtualModeFS=Cdc_FS 147 | VP_SYS_VS_Systick.Mode=SysTick 148 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 149 | VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Mode=CDC_FS 150 | VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Signal=USB_DEVICE_VS_USB_DEVICE_CDC_FS 151 | board=custom 152 | -------------------------------------------------------------------------------- /fw/swd_over_usb_c/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | .dep 3 | *.eep 4 | *.elf 5 | *.hex 6 | *.lss 7 | *.map 8 | *.sym 9 | -------------------------------------------------------------------------------- /fw/swd_over_usb_c/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) 5 | 6 | // Input CC1/CC2 7 | #define CC1 PA6 8 | #define CC2 PA5 9 | 10 | // Output CC1/CC2 Rpu's 11 | #define CC1_R2 PB1 // 10 kOhm 12 | #define CC1_R1 PB0 // 22 kOhm 13 | #define CC2_R2 PA0 // 22 kOhm 14 | #define CC2_R1 PA1 // 56 kOhm 15 | 16 | typedef enum { 17 | USB_500MA, 18 | USB_1500MA, 19 | USB_3000MA, 20 | } USBCurrent_t; 21 | 22 | // Current | CC1/CC2 In | CC1 Rpu | CC2 Rpu 23 | // 500mA | 0.42V | 10 kOhm | 22 kOhm 24 | // 1.5A | 0.94V | 22 kOhm | 56 kOhm 25 | // 3.0A | 1.69V | 10 kOhm | 22 kOhm 26 | 27 | void set_usb_current(USBCurrent_t current) { 28 | switch(current) { 29 | case USB_500MA: { 30 | PORTB |= _BV(CC1_R2); 31 | PORTB &= ~_BV(CC1_R1); 32 | PORTA |= _BV(CC2_R2); 33 | PORTA &= ~_BV(CC2_R1); 34 | break; 35 | } 36 | case USB_1500MA: { 37 | PORTB &= ~_BV(CC1_R2); 38 | PORTB |= _BV(CC1_R1); 39 | PORTA &= ~_BV(CC2_R2); 40 | PORTA |= _BV(CC2_R1); 41 | break; 42 | } 43 | case USB_3000MA: { 44 | PORTB |= _BV(CC1_R2); 45 | PORTB &= ~_BV(CC1_R1); 46 | PORTA &= ~_BV(CC2_R2); 47 | PORTA |= _BV(CC2_R1); 48 | break; 49 | } 50 | } 51 | } 52 | 53 | uint16_t adc_sample_mv(uint8_t channel) { 54 | ADMUX = channel; 55 | ADCSRA |= (1 << ADSC); // Start conversion 56 | 57 | // Wait for conversion to complete 58 | while(ADCSRA & (1 << ADSC)); 59 | 60 | uint16_t raw_adc_val = ADC; 61 | uint32_t adc_mv = ((uint32_t)raw_adc_val * 5000)/1024; 62 | 63 | return adc_mv; 64 | } 65 | 66 | // CC1/CC2 voltages for various USB C currents 67 | #define USB_CC_MV_500MA 200 68 | #define USB_CC_MV_1500MA 660 69 | #define USB_CC_MV_3000MA 1230 70 | 71 | USBCurrent_t get_cc_current(void) { 72 | // Read CC1/CC2 values for input current detection 73 | uint16_t cc1 = adc_sample_mv(CC1); 74 | uint16_t cc2 = adc_sample_mv(CC2); 75 | 76 | cc1 = MAX(cc1, cc2); 77 | 78 | USBCurrent_t curent; 79 | if (cc1 <= USB_CC_MV_1500MA) { 80 | curent = USB_500MA; 81 | } else if (cc1 <= USB_CC_MV_3000MA) { 82 | curent = USB_1500MA; 83 | } else { 84 | curent = USB_3000MA; 85 | } 86 | 87 | return curent; 88 | } 89 | 90 | int main(void) 91 | { 92 | // Set port B output 0 as output 93 | DDRA = _BV(CC2_R2) | _BV(CC2_R1); 94 | DDRB = _BV(CC1_R2) | _BV(CC1_R1); 95 | 96 | // ADC Enable with / 16 prescaler (62.5kHz) 97 | ADCSRA = (1 << ADEN) | 3; 98 | 99 | // Disable digital inputs on ADC pins 100 | DIDR0 |= _BV(CC1) | _BV(CC2); 101 | 102 | // Default to 500mA charge current to start 103 | set_usb_current(USB_500MA); 104 | 105 | while (1) { 106 | set_usb_current(get_cc_current()); 107 | _delay_ms(1000); 108 | } 109 | return 0; 110 | } 111 | -------------------------------------------------------------------------------- /hw/docs/rpu_calc.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvarop/debugotron/45d2a20c12693876ac24e1a4a6770e95fde100ab/hw/docs/rpu_calc.ods -------------------------------------------------------------------------------- /hw/sample_target/sample_target.kicad_prl: -------------------------------------------------------------------------------- 1 | { 2 | "board": { 3 | "active_layer": 0, 4 | "active_layer_preset": "", 5 | "auto_track_width": true, 6 | "hidden_nets": [], 7 | "high_contrast_mode": 0, 8 | "net_color_mode": 1, 9 | "opacity": { 10 | "pads": 1.0, 11 | "tracks": 1.0, 12 | "vias": 1.0, 13 | "zones": 0.6 14 | }, 15 | "ratsnest_display_mode": 0, 16 | "selection_filter": { 17 | "dimensions": true, 18 | "footprints": true, 19 | "graphics": true, 20 | "keepouts": true, 21 | "lockedItems": true, 22 | "otherItems": true, 23 | "pads": true, 24 | "text": true, 25 | "tracks": true, 26 | "vias": true, 27 | "zones": true 28 | }, 29 | "visible_items": [ 30 | 0, 31 | 1, 32 | 2, 33 | 3, 34 | 4, 35 | 5, 36 | 8, 37 | 9, 38 | 10, 39 | 11, 40 | 12, 41 | 13, 42 | 14, 43 | 15, 44 | 16, 45 | 17, 46 | 18, 47 | 19, 48 | 20, 49 | 21, 50 | 22, 51 | 23, 52 | 24, 53 | 25, 54 | 26, 55 | 27, 56 | 28, 57 | 29, 58 | 30, 59 | 32, 60 | 33, 61 | 34, 62 | 35, 63 | 36 64 | ], 65 | "visible_layers": "ffcffff_ffffffff", 66 | "zone_display_mode": 0 67 | }, 68 | "meta": { 69 | "filename": "sample_target.kicad_prl", 70 | "version": 3 71 | }, 72 | "project": { 73 | "files": [] 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /hw/sample_target/sample_target.kicad_pro: -------------------------------------------------------------------------------- 1 | { 2 | "board": { 3 | "design_settings": { 4 | "defaults": { 5 | "board_outline_line_width": 0.09999999999999999, 6 | "copper_line_width": 0.19999999999999998, 7 | "copper_text_italic": false, 8 | "copper_text_size_h": 1.5, 9 | "copper_text_size_v": 1.5, 10 | "copper_text_thickness": 0.3, 11 | "copper_text_upright": false, 12 | "courtyard_line_width": 0.049999999999999996, 13 | "dimension_precision": 4, 14 | "dimension_units": 3, 15 | "dimensions": { 16 | "arrow_length": 1270000, 17 | "extension_offset": 500000, 18 | "keep_text_aligned": true, 19 | "suppress_zeroes": false, 20 | "text_position": 0, 21 | "units_format": 1 22 | }, 23 | "fab_line_width": 0.09999999999999999, 24 | "fab_text_italic": false, 25 | "fab_text_size_h": 1.0, 26 | "fab_text_size_v": 1.0, 27 | "fab_text_thickness": 0.15, 28 | "fab_text_upright": false, 29 | "other_line_width": 0.15, 30 | "other_text_italic": false, 31 | "other_text_size_h": 1.0, 32 | "other_text_size_v": 1.0, 33 | "other_text_thickness": 0.15, 34 | "other_text_upright": false, 35 | "pads": { 36 | "drill": 0.0, 37 | "height": 0.65, 38 | "width": 0.7 39 | }, 40 | "silk_line_width": 0.15, 41 | "silk_text_italic": false, 42 | "silk_text_size_h": 1.0, 43 | "silk_text_size_v": 1.0, 44 | "silk_text_thickness": 0.15, 45 | "silk_text_upright": false, 46 | "zones": { 47 | "45_degree_only": false, 48 | "min_clearance": 0.17779999999999999 49 | } 50 | }, 51 | "diff_pair_dimensions": [ 52 | { 53 | "gap": 0.0, 54 | "via_gap": 0.0, 55 | "width": 0.0 56 | }, 57 | { 58 | "gap": 0.1524, 59 | "via_gap": 0.0, 60 | "width": 0.1524 61 | } 62 | ], 63 | "drc_exclusions": [], 64 | "meta": { 65 | "version": 2 66 | }, 67 | "rule_severities": { 68 | "annular_width": "error", 69 | "clearance": "error", 70 | "copper_edge_clearance": "error", 71 | "courtyards_overlap": "error", 72 | "diff_pair_gap_out_of_range": "error", 73 | "diff_pair_uncoupled_length_too_long": "error", 74 | "drill_out_of_range": "error", 75 | "duplicate_footprints": "warning", 76 | "extra_footprint": "warning", 77 | "footprint_type_mismatch": "error", 78 | "hole_clearance": "error", 79 | "hole_near_hole": "error", 80 | "invalid_outline": "error", 81 | "item_on_disabled_layer": "error", 82 | "items_not_allowed": "error", 83 | "length_out_of_range": "error", 84 | "malformed_courtyard": "error", 85 | "microvia_drill_out_of_range": "error", 86 | "missing_courtyard": "ignore", 87 | "missing_footprint": "warning", 88 | "net_conflict": "warning", 89 | "npth_inside_courtyard": "ignore", 90 | "padstack": "error", 91 | "pth_inside_courtyard": "ignore", 92 | "shorting_items": "error", 93 | "silk_over_copper": "warning", 94 | "silk_overlap": "warning", 95 | "skew_out_of_range": "error", 96 | "through_hole_pad_without_hole": "error", 97 | "too_many_vias": "error", 98 | "track_dangling": "warning", 99 | "track_width": "error", 100 | "tracks_crossing": "error", 101 | "unconnected_items": "error", 102 | "unresolved_variable": "error", 103 | "via_dangling": "warning", 104 | "zone_has_empty_net": "error", 105 | "zones_intersect": "error" 106 | }, 107 | "rules": { 108 | "allow_blind_buried_vias": false, 109 | "allow_microvias": false, 110 | "max_error": 0.005, 111 | "min_clearance": 0.0, 112 | "min_copper_edge_clearance": 0.0, 113 | "min_hole_clearance": 0.2032, 114 | "min_hole_to_hole": 0.2032, 115 | "min_microvia_diameter": 0.19999999999999998, 116 | "min_microvia_drill": 0.09999999999999999, 117 | "min_silk_clearance": 0.0, 118 | "min_through_hole_diameter": 0.254, 119 | "min_track_width": 0.15239999999999998, 120 | "min_via_annular_width": 0.127, 121 | "min_via_diameter": 0.508, 122 | "solder_mask_clearance": 0.0, 123 | "solder_mask_min_width": 0.0, 124 | "use_height_for_length_calcs": true 125 | }, 126 | "track_widths": [ 127 | 0.0, 128 | 0.1524, 129 | 0.2032, 130 | 0.254, 131 | 0.508 132 | ], 133 | "via_dimensions": [ 134 | { 135 | "diameter": 0.0, 136 | "drill": 0.0 137 | }, 138 | { 139 | "diameter": 0.508, 140 | "drill": 0.254 141 | } 142 | ], 143 | "zones_allow_external_fillets": false, 144 | "zones_use_no_outline": true 145 | }, 146 | "layer_presets": [] 147 | }, 148 | "boards": [], 149 | "cvpcb": { 150 | "equivalence_files": [] 151 | }, 152 | "erc": { 153 | "erc_exclusions": [], 154 | "meta": { 155 | "version": 0 156 | }, 157 | "pin_map": [ 158 | [ 159 | 0, 160 | 0, 161 | 0, 162 | 0, 163 | 0, 164 | 0, 165 | 1, 166 | 0, 167 | 0, 168 | 0, 169 | 0, 170 | 2 171 | ], 172 | [ 173 | 0, 174 | 2, 175 | 0, 176 | 1, 177 | 0, 178 | 0, 179 | 1, 180 | 0, 181 | 2, 182 | 2, 183 | 2, 184 | 2 185 | ], 186 | [ 187 | 0, 188 | 0, 189 | 0, 190 | 0, 191 | 0, 192 | 0, 193 | 1, 194 | 0, 195 | 1, 196 | 0, 197 | 1, 198 | 2 199 | ], 200 | [ 201 | 0, 202 | 1, 203 | 0, 204 | 0, 205 | 0, 206 | 0, 207 | 1, 208 | 1, 209 | 2, 210 | 1, 211 | 1, 212 | 2 213 | ], 214 | [ 215 | 0, 216 | 0, 217 | 0, 218 | 0, 219 | 0, 220 | 0, 221 | 1, 222 | 0, 223 | 0, 224 | 0, 225 | 0, 226 | 2 227 | ], 228 | [ 229 | 0, 230 | 0, 231 | 0, 232 | 0, 233 | 0, 234 | 0, 235 | 0, 236 | 0, 237 | 0, 238 | 0, 239 | 0, 240 | 2 241 | ], 242 | [ 243 | 1, 244 | 1, 245 | 1, 246 | 1, 247 | 1, 248 | 0, 249 | 1, 250 | 1, 251 | 1, 252 | 1, 253 | 1, 254 | 2 255 | ], 256 | [ 257 | 0, 258 | 0, 259 | 0, 260 | 1, 261 | 0, 262 | 0, 263 | 1, 264 | 0, 265 | 0, 266 | 0, 267 | 0, 268 | 2 269 | ], 270 | [ 271 | 0, 272 | 2, 273 | 1, 274 | 2, 275 | 0, 276 | 0, 277 | 1, 278 | 0, 279 | 2, 280 | 2, 281 | 2, 282 | 2 283 | ], 284 | [ 285 | 0, 286 | 2, 287 | 0, 288 | 1, 289 | 0, 290 | 0, 291 | 1, 292 | 0, 293 | 2, 294 | 0, 295 | 0, 296 | 2 297 | ], 298 | [ 299 | 0, 300 | 2, 301 | 1, 302 | 1, 303 | 0, 304 | 0, 305 | 1, 306 | 0, 307 | 2, 308 | 0, 309 | 0, 310 | 2 311 | ], 312 | [ 313 | 2, 314 | 2, 315 | 2, 316 | 2, 317 | 2, 318 | 2, 319 | 2, 320 | 2, 321 | 2, 322 | 2, 323 | 2, 324 | 2 325 | ] 326 | ], 327 | "rule_severities": { 328 | "bus_definition_conflict": "error", 329 | "bus_entry_needed": "error", 330 | "bus_label_syntax": "error", 331 | "bus_to_bus_conflict": "error", 332 | "bus_to_net_conflict": "error", 333 | "different_unit_footprint": "error", 334 | "different_unit_net": "error", 335 | "duplicate_reference": "error", 336 | "duplicate_sheet_names": "error", 337 | "extra_units": "error", 338 | "global_label_dangling": "warning", 339 | "hier_label_mismatch": "error", 340 | "label_dangling": "error", 341 | "lib_symbol_issues": "warning", 342 | "multiple_net_names": "warning", 343 | "net_not_bus_member": "warning", 344 | "no_connect_connected": "warning", 345 | "no_connect_dangling": "warning", 346 | "pin_not_connected": "error", 347 | "pin_not_driven": "error", 348 | "pin_to_pin": "warning", 349 | "power_pin_not_driven": "error", 350 | "similar_labels": "warning", 351 | "unannotated": "error", 352 | "unit_value_mismatch": "error", 353 | "unresolved_variable": "error", 354 | "wire_dangling": "error" 355 | } 356 | }, 357 | "libraries": { 358 | "pinned_footprint_libs": [], 359 | "pinned_symbol_libs": [] 360 | }, 361 | "meta": { 362 | "filename": "sample_target.kicad_pro", 363 | "version": 1 364 | }, 365 | "net_settings": { 366 | "classes": [ 367 | { 368 | "bus_width": 12.0, 369 | "clearance": 0.1524, 370 | "diff_pair_gap": 0.1524, 371 | "diff_pair_via_gap": 0.25, 372 | "diff_pair_width": 0.1524, 373 | "line_style": 0, 374 | "microvia_diameter": 0.508, 375 | "microvia_drill": 0.254, 376 | "name": "Default", 377 | "pcb_color": "rgba(0, 0, 0, 0.000)", 378 | "schematic_color": "rgba(0, 0, 0, 0.000)", 379 | "track_width": 0.1524, 380 | "via_diameter": 0.508, 381 | "via_drill": 0.254, 382 | "wire_width": 6.0 383 | } 384 | ], 385 | "meta": { 386 | "version": 2 387 | }, 388 | "net_colors": null 389 | }, 390 | "pcbnew": { 391 | "last_paths": { 392 | "gencad": "", 393 | "idf": "", 394 | "netlist": "", 395 | "specctra_dsn": "", 396 | "step": "", 397 | "vrml": "" 398 | }, 399 | "page_layout_descr_file": "" 400 | }, 401 | "schematic": { 402 | "annotate_start_num": 0, 403 | "drawing": { 404 | "default_line_thickness": 6.0, 405 | "default_text_size": 50.0, 406 | "field_names": [], 407 | "intersheets_ref_own_page": false, 408 | "intersheets_ref_prefix": "", 409 | "intersheets_ref_short": false, 410 | "intersheets_ref_show": false, 411 | "intersheets_ref_suffix": "", 412 | "junction_size_choice": 3, 413 | "label_size_ratio": 0.375, 414 | "pin_symbol_size": 25.0, 415 | "text_offset_ratio": 0.15 416 | }, 417 | "legacy_lib_dir": "", 418 | "legacy_lib_list": [], 419 | "meta": { 420 | "version": 1 421 | }, 422 | "net_format_name": "", 423 | "ngspice": { 424 | "fix_include_paths": true, 425 | "fix_passive_vals": false, 426 | "meta": { 427 | "version": 0 428 | }, 429 | "model_mode": 0, 430 | "workbook_filename": "" 431 | }, 432 | "page_layout_descr_file": "", 433 | "plot_directory": "", 434 | "spice_adjust_passive_values": false, 435 | "spice_external_command": "spice \"%I\"", 436 | "subpart_first_id": 65, 437 | "subpart_id_separator": 0 438 | }, 439 | "sheets": [ 440 | [ 441 | "88dc8cb9-2953-4bb2-909a-d09e1dbb0528", 442 | "" 443 | ] 444 | ], 445 | "text_variables": {} 446 | } 447 | -------------------------------------------------------------------------------- /hw/swd_over_c/swd_over_c.kicad_prl: -------------------------------------------------------------------------------- 1 | { 2 | "board": { 3 | "active_layer": 0, 4 | "active_layer_preset": "", 5 | "auto_track_width": true, 6 | "hidden_nets": [], 7 | "high_contrast_mode": 1, 8 | "net_color_mode": 1, 9 | "opacity": { 10 | "pads": 1.0, 11 | "tracks": 1.0, 12 | "vias": 1.0, 13 | "zones": 0.6 14 | }, 15 | "ratsnest_display_mode": 0, 16 | "selection_filter": { 17 | "dimensions": true, 18 | "footprints": true, 19 | "graphics": true, 20 | "keepouts": true, 21 | "lockedItems": false, 22 | "otherItems": true, 23 | "pads": true, 24 | "text": true, 25 | "tracks": true, 26 | "vias": true, 27 | "zones": true 28 | }, 29 | "visible_items": [ 30 | 0, 31 | 1, 32 | 2, 33 | 3, 34 | 4, 35 | 5, 36 | 8, 37 | 9, 38 | 10, 39 | 11, 40 | 12, 41 | 13, 42 | 14, 43 | 15, 44 | 16, 45 | 17, 46 | 18, 47 | 19, 48 | 20, 49 | 21, 50 | 22, 51 | 23, 52 | 24, 53 | 25, 54 | 26, 55 | 27, 56 | 28, 57 | 29, 58 | 30, 59 | 32, 60 | 33, 61 | 34, 62 | 35, 63 | 36 64 | ], 65 | "visible_layers": "7fcf1ff_80000007", 66 | "zone_display_mode": 0 67 | }, 68 | "meta": { 69 | "filename": "swd_over_c.kicad_prl", 70 | "version": 3 71 | }, 72 | "project": { 73 | "files": [] 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /hw/swd_over_c_pogo/swd_over_c_pogo.kicad_prl: -------------------------------------------------------------------------------- 1 | { 2 | "board": { 3 | "active_layer": 0, 4 | "active_layer_preset": "", 5 | "auto_track_width": true, 6 | "hidden_nets": [], 7 | "high_contrast_mode": 0, 8 | "net_color_mode": 1, 9 | "opacity": { 10 | "pads": 1.0, 11 | "tracks": 1.0, 12 | "vias": 1.0, 13 | "zones": 0.6 14 | }, 15 | "ratsnest_display_mode": 0, 16 | "selection_filter": { 17 | "dimensions": true, 18 | "footprints": true, 19 | "graphics": true, 20 | "keepouts": true, 21 | "lockedItems": false, 22 | "otherItems": true, 23 | "pads": true, 24 | "text": true, 25 | "tracks": true, 26 | "vias": true, 27 | "zones": true 28 | }, 29 | "visible_items": [ 30 | 0, 31 | 1, 32 | 2, 33 | 3, 34 | 4, 35 | 5, 36 | 8, 37 | 9, 38 | 10, 39 | 11, 40 | 12, 41 | 13, 42 | 14, 43 | 15, 44 | 16, 45 | 17, 46 | 18, 47 | 19, 48 | 20, 49 | 21, 50 | 22, 51 | 23, 52 | 24, 53 | 25, 54 | 26, 55 | 27, 56 | 28, 57 | 29, 58 | 30, 59 | 32, 60 | 33, 61 | 34, 62 | 35, 63 | 36 64 | ], 65 | "visible_layers": "7fcffff_80000001", 66 | "zone_display_mode": 0 67 | }, 68 | "meta": { 69 | "filename": "swd_over_c_pogo.kicad_prl", 70 | "version": 3 71 | }, 72 | "project": { 73 | "files": [] 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /hw/swd_switch/swd_switch.kicad_prl: -------------------------------------------------------------------------------- 1 | { 2 | "board": { 3 | "active_layer": 0, 4 | "active_layer_preset": "", 5 | "auto_track_width": true, 6 | "hidden_nets": [], 7 | "high_contrast_mode": 0, 8 | "net_color_mode": 1, 9 | "opacity": { 10 | "pads": 1.0, 11 | "tracks": 1.0, 12 | "vias": 1.0, 13 | "zones": 0.6 14 | }, 15 | "ratsnest_display_mode": 0, 16 | "selection_filter": { 17 | "dimensions": true, 18 | "footprints": true, 19 | "graphics": true, 20 | "keepouts": true, 21 | "lockedItems": false, 22 | "otherItems": true, 23 | "pads": true, 24 | "text": true, 25 | "tracks": true, 26 | "vias": true, 27 | "zones": true 28 | }, 29 | "visible_items": [ 30 | 0, 31 | 1, 32 | 2, 33 | 3, 34 | 4, 35 | 5, 36 | 8, 37 | 9, 38 | 10, 39 | 11, 40 | 12, 41 | 13, 42 | 14, 43 | 15, 44 | 16, 45 | 17, 46 | 18, 47 | 19, 48 | 20, 49 | 21, 50 | 22, 51 | 23, 52 | 24, 53 | 25, 54 | 26, 55 | 27, 56 | 28, 57 | 29, 58 | 30, 59 | 32, 60 | 33, 61 | 34, 62 | 35, 63 | 36 64 | ], 65 | "visible_layers": "7fcffff_80000007", 66 | "zone_display_mode": 1 67 | }, 68 | "meta": { 69 | "filename": "swd_switch.kicad_prl", 70 | "version": 3 71 | }, 72 | "project": { 73 | "files": [] 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /hw/swd_switch/swd_switch.kicad_pro: -------------------------------------------------------------------------------- 1 | { 2 | "board": { 3 | "design_settings": { 4 | "defaults": { 5 | "board_outline_line_width": 0.09999999999999999, 6 | "copper_line_width": 0.19999999999999998, 7 | "copper_text_italic": false, 8 | "copper_text_size_h": 1.5, 9 | "copper_text_size_v": 1.5, 10 | "copper_text_thickness": 0.3, 11 | "copper_text_upright": false, 12 | "courtyard_line_width": 0.049999999999999996, 13 | "dimension_precision": 4, 14 | "dimension_units": 3, 15 | "dimensions": { 16 | "arrow_length": 1270000, 17 | "extension_offset": 500000, 18 | "keep_text_aligned": true, 19 | "suppress_zeroes": false, 20 | "text_position": 0, 21 | "units_format": 1 22 | }, 23 | "fab_line_width": 0.09999999999999999, 24 | "fab_text_italic": false, 25 | "fab_text_size_h": 1.0, 26 | "fab_text_size_v": 1.0, 27 | "fab_text_thickness": 0.15, 28 | "fab_text_upright": false, 29 | "other_line_width": 0.15, 30 | "other_text_italic": false, 31 | "other_text_size_h": 1.0, 32 | "other_text_size_v": 1.0, 33 | "other_text_thickness": 0.15, 34 | "other_text_upright": false, 35 | "pads": { 36 | "drill": 0.0, 37 | "height": 3.0, 38 | "width": 3.0 39 | }, 40 | "silk_line_width": 0.15, 41 | "silk_text_italic": false, 42 | "silk_text_size_h": 1.0, 43 | "silk_text_size_v": 1.0, 44 | "silk_text_thickness": 0.15, 45 | "silk_text_upright": false, 46 | "zones": { 47 | "45_degree_only": false, 48 | "min_clearance": 0.254 49 | } 50 | }, 51 | "diff_pair_dimensions": [ 52 | { 53 | "gap": 0.0, 54 | "via_gap": 0.0, 55 | "width": 0.0 56 | } 57 | ], 58 | "drc_exclusions": [], 59 | "meta": { 60 | "version": 2 61 | }, 62 | "rule_severities": { 63 | "annular_width": "error", 64 | "clearance": "error", 65 | "copper_edge_clearance": "error", 66 | "courtyards_overlap": "error", 67 | "diff_pair_gap_out_of_range": "error", 68 | "diff_pair_uncoupled_length_too_long": "error", 69 | "drill_out_of_range": "error", 70 | "duplicate_footprints": "warning", 71 | "extra_footprint": "warning", 72 | "footprint_type_mismatch": "error", 73 | "hole_clearance": "error", 74 | "hole_near_hole": "error", 75 | "invalid_outline": "error", 76 | "item_on_disabled_layer": "error", 77 | "items_not_allowed": "error", 78 | "length_out_of_range": "error", 79 | "malformed_courtyard": "error", 80 | "microvia_drill_out_of_range": "error", 81 | "missing_courtyard": "ignore", 82 | "missing_footprint": "warning", 83 | "net_conflict": "warning", 84 | "npth_inside_courtyard": "ignore", 85 | "padstack": "error", 86 | "pth_inside_courtyard": "ignore", 87 | "shorting_items": "error", 88 | "silk_over_copper": "ignore", 89 | "silk_overlap": "ignore", 90 | "skew_out_of_range": "error", 91 | "through_hole_pad_without_hole": "error", 92 | "too_many_vias": "error", 93 | "track_dangling": "warning", 94 | "track_width": "error", 95 | "tracks_crossing": "error", 96 | "unconnected_items": "error", 97 | "unresolved_variable": "error", 98 | "via_dangling": "warning", 99 | "zone_has_empty_net": "error", 100 | "zones_intersect": "error" 101 | }, 102 | "rules": { 103 | "allow_blind_buried_vias": false, 104 | "allow_microvias": false, 105 | "max_error": 0.005, 106 | "min_clearance": 0.15239999999999998, 107 | "min_copper_edge_clearance": 0.15239999999999998, 108 | "min_hole_clearance": 0.15239999999999998, 109 | "min_hole_to_hole": 0.508, 110 | "min_microvia_diameter": 0.508, 111 | "min_microvia_drill": 0.254, 112 | "min_silk_clearance": 0.15239999999999998, 113 | "min_through_hole_diameter": 0.254, 114 | "min_track_width": 0.15239999999999998, 115 | "min_via_annular_width": 0.127, 116 | "min_via_diameter": 0.508, 117 | "solder_mask_clearance": 0.0, 118 | "solder_mask_min_width": 0.0, 119 | "use_height_for_length_calcs": true 120 | }, 121 | "track_widths": [ 122 | 0.0, 123 | 0.1524, 124 | 0.1778, 125 | 0.254, 126 | 0.381 127 | ], 128 | "via_dimensions": [ 129 | { 130 | "diameter": 0.0, 131 | "drill": 0.0 132 | }, 133 | { 134 | "diameter": 0.508, 135 | "drill": 0.254 136 | } 137 | ], 138 | "zones_allow_external_fillets": false, 139 | "zones_use_no_outline": true 140 | }, 141 | "layer_presets": [] 142 | }, 143 | "boards": [], 144 | "cvpcb": { 145 | "equivalence_files": [] 146 | }, 147 | "erc": { 148 | "erc_exclusions": [], 149 | "meta": { 150 | "version": 0 151 | }, 152 | "pin_map": [ 153 | [ 154 | 0, 155 | 0, 156 | 0, 157 | 0, 158 | 0, 159 | 0, 160 | 1, 161 | 0, 162 | 0, 163 | 0, 164 | 0, 165 | 2 166 | ], 167 | [ 168 | 0, 169 | 2, 170 | 0, 171 | 1, 172 | 0, 173 | 0, 174 | 1, 175 | 0, 176 | 2, 177 | 2, 178 | 2, 179 | 2 180 | ], 181 | [ 182 | 0, 183 | 0, 184 | 0, 185 | 0, 186 | 0, 187 | 0, 188 | 1, 189 | 0, 190 | 1, 191 | 0, 192 | 1, 193 | 2 194 | ], 195 | [ 196 | 0, 197 | 1, 198 | 0, 199 | 0, 200 | 0, 201 | 0, 202 | 1, 203 | 1, 204 | 2, 205 | 1, 206 | 1, 207 | 2 208 | ], 209 | [ 210 | 0, 211 | 0, 212 | 0, 213 | 0, 214 | 0, 215 | 0, 216 | 1, 217 | 0, 218 | 0, 219 | 0, 220 | 0, 221 | 2 222 | ], 223 | [ 224 | 0, 225 | 0, 226 | 0, 227 | 0, 228 | 0, 229 | 0, 230 | 0, 231 | 0, 232 | 0, 233 | 0, 234 | 0, 235 | 2 236 | ], 237 | [ 238 | 1, 239 | 1, 240 | 1, 241 | 1, 242 | 1, 243 | 0, 244 | 1, 245 | 1, 246 | 1, 247 | 1, 248 | 1, 249 | 2 250 | ], 251 | [ 252 | 0, 253 | 0, 254 | 0, 255 | 1, 256 | 0, 257 | 0, 258 | 1, 259 | 0, 260 | 0, 261 | 0, 262 | 0, 263 | 2 264 | ], 265 | [ 266 | 0, 267 | 2, 268 | 1, 269 | 2, 270 | 0, 271 | 0, 272 | 1, 273 | 0, 274 | 2, 275 | 2, 276 | 2, 277 | 2 278 | ], 279 | [ 280 | 0, 281 | 2, 282 | 0, 283 | 1, 284 | 0, 285 | 0, 286 | 1, 287 | 0, 288 | 2, 289 | 0, 290 | 0, 291 | 2 292 | ], 293 | [ 294 | 0, 295 | 2, 296 | 1, 297 | 1, 298 | 0, 299 | 0, 300 | 1, 301 | 0, 302 | 2, 303 | 0, 304 | 0, 305 | 2 306 | ], 307 | [ 308 | 2, 309 | 2, 310 | 2, 311 | 2, 312 | 2, 313 | 2, 314 | 2, 315 | 2, 316 | 2, 317 | 2, 318 | 2, 319 | 2 320 | ] 321 | ], 322 | "rule_severities": { 323 | "bus_definition_conflict": "error", 324 | "bus_entry_needed": "error", 325 | "bus_label_syntax": "error", 326 | "bus_to_bus_conflict": "error", 327 | "bus_to_net_conflict": "error", 328 | "different_unit_footprint": "error", 329 | "different_unit_net": "error", 330 | "duplicate_reference": "error", 331 | "duplicate_sheet_names": "error", 332 | "extra_units": "error", 333 | "global_label_dangling": "warning", 334 | "hier_label_mismatch": "error", 335 | "label_dangling": "error", 336 | "lib_symbol_issues": "warning", 337 | "multiple_net_names": "warning", 338 | "net_not_bus_member": "warning", 339 | "no_connect_connected": "warning", 340 | "no_connect_dangling": "warning", 341 | "pin_not_connected": "error", 342 | "pin_not_driven": "error", 343 | "pin_to_pin": "warning", 344 | "power_pin_not_driven": "error", 345 | "similar_labels": "warning", 346 | "unannotated": "error", 347 | "unit_value_mismatch": "error", 348 | "unresolved_variable": "error", 349 | "wire_dangling": "error" 350 | } 351 | }, 352 | "libraries": { 353 | "pinned_footprint_libs": [], 354 | "pinned_symbol_libs": [] 355 | }, 356 | "meta": { 357 | "filename": "swd_switch.kicad_pro", 358 | "version": 1 359 | }, 360 | "net_settings": { 361 | "classes": [ 362 | { 363 | "bus_width": 12.0, 364 | "clearance": 0.2, 365 | "diff_pair_gap": 0.25, 366 | "diff_pair_via_gap": 0.25, 367 | "diff_pair_width": 0.2, 368 | "line_style": 0, 369 | "microvia_diameter": 0.3, 370 | "microvia_drill": 0.1, 371 | "name": "Default", 372 | "pcb_color": "rgba(0, 0, 0, 0.000)", 373 | "schematic_color": "rgba(0, 0, 0, 0.000)", 374 | "track_width": 0.25, 375 | "via_diameter": 0.8, 376 | "via_drill": 0.4, 377 | "wire_width": 6.0 378 | } 379 | ], 380 | "meta": { 381 | "version": 2 382 | }, 383 | "net_colors": null 384 | }, 385 | "pcbnew": { 386 | "last_paths": { 387 | "gencad": "", 388 | "idf": "", 389 | "netlist": "", 390 | "specctra_dsn": "", 391 | "step": "", 392 | "vrml": "" 393 | }, 394 | "page_layout_descr_file": "" 395 | }, 396 | "schematic": { 397 | "annotate_start_num": 0, 398 | "drawing": { 399 | "default_bus_thickness": 12.0, 400 | "default_line_thickness": 6.0, 401 | "default_text_size": 50.0, 402 | "default_wire_thickness": 6.0, 403 | "field_names": [], 404 | "intersheets_ref_own_page": false, 405 | "intersheets_ref_prefix": "", 406 | "intersheets_ref_short": false, 407 | "intersheets_ref_show": false, 408 | "intersheets_ref_suffix": "", 409 | "junction_size_choice": 3, 410 | "label_size_ratio": 0.375, 411 | "pin_symbol_size": 25.0, 412 | "text_offset_ratio": 0.15 413 | }, 414 | "legacy_lib_dir": "", 415 | "legacy_lib_list": [], 416 | "meta": { 417 | "version": 1 418 | }, 419 | "net_format_name": "", 420 | "ngspice": { 421 | "fix_include_paths": true, 422 | "fix_passive_vals": false, 423 | "meta": { 424 | "version": 0 425 | }, 426 | "model_mode": 0, 427 | "workbook_filename": "" 428 | }, 429 | "page_layout_descr_file": "", 430 | "plot_directory": "", 431 | "spice_adjust_passive_values": false, 432 | "spice_external_command": "spice \"%I\"", 433 | "subpart_first_id": 65, 434 | "subpart_id_separator": 0 435 | }, 436 | "sheets": [ 437 | [ 438 | "66370187-6fbc-4b5c-bb27-b3ca76373d49", 439 | "" 440 | ] 441 | ], 442 | "text_variables": {} 443 | } 444 | -------------------------------------------------------------------------------- /hw/usb_switch/usb_switch.kicad_prl: -------------------------------------------------------------------------------- 1 | { 2 | "board": { 3 | "active_layer": 0, 4 | "active_layer_preset": "", 5 | "auto_track_width": true, 6 | "hidden_nets": [], 7 | "high_contrast_mode": 0, 8 | "net_color_mode": 1, 9 | "opacity": { 10 | "pads": 1.0, 11 | "tracks": 1.0, 12 | "vias": 1.0, 13 | "zones": 0.6 14 | }, 15 | "ratsnest_display_mode": 0, 16 | "selection_filter": { 17 | "dimensions": true, 18 | "footprints": true, 19 | "graphics": true, 20 | "keepouts": true, 21 | "lockedItems": true, 22 | "otherItems": true, 23 | "pads": true, 24 | "text": true, 25 | "tracks": true, 26 | "vias": true, 27 | "zones": true 28 | }, 29 | "visible_items": [ 30 | 0, 31 | 1, 32 | 2, 33 | 3, 34 | 4, 35 | 5, 36 | 8, 37 | 9, 38 | 10, 39 | 11, 40 | 12, 41 | 13, 42 | 14, 43 | 15, 44 | 16, 45 | 17, 46 | 18, 47 | 19, 48 | 20, 49 | 21, 50 | 22, 51 | 23, 52 | 24, 53 | 25, 54 | 26, 55 | 27, 56 | 28, 57 | 29, 58 | 30, 59 | 32, 60 | 33, 61 | 34, 62 | 35, 63 | 36 64 | ], 65 | "visible_layers": "7fdffef_80000007", 66 | "zone_display_mode": 1 67 | }, 68 | "meta": { 69 | "filename": "usb_switch.kicad_prl", 70 | "version": 3 71 | }, 72 | "project": { 73 | "files": [] 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /img/IMG_2371.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvarop/debugotron/45d2a20c12693876ac24e1a4a6770e95fde100ab/img/IMG_2371.jpg -------------------------------------------------------------------------------- /img/IMG_2372.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvarop/debugotron/45d2a20c12693876ac24e1a4a6770e95fde100ab/img/IMG_2372.jpg -------------------------------------------------------------------------------- /img/IMG_2373.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvarop/debugotron/45d2a20c12693876ac24e1a4a6770e95fde100ab/img/IMG_2373.jpg -------------------------------------------------------------------------------- /img/IMG_2376.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvarop/debugotron/45d2a20c12693876ac24e1a4a6770e95fde100ab/img/IMG_2376.jpg -------------------------------------------------------------------------------- /img/IMG_2380.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvarop/debugotron/45d2a20c12693876ac24e1a4a6770e95fde100ab/img/IMG_2380.jpg -------------------------------------------------------------------------------- /img/IMG_2494.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvarop/debugotron/45d2a20c12693876ac24e1a4a6770e95fde100ab/img/IMG_2494.jpg -------------------------------------------------------------------------------- /img/IMG_2495.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvarop/debugotron/45d2a20c12693876ac24e1a4a6770e95fde100ab/img/IMG_2495.jpg -------------------------------------------------------------------------------- /img/IMG_2498.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvarop/debugotron/45d2a20c12693876ac24e1a4a6770e95fde100ab/img/IMG_2498.jpg --------------------------------------------------------------------------------