├── .gitignore ├── Drivers ├── CMSIS │ ├── Device │ │ └── ST │ │ │ └── STM32F1xx │ │ │ └── Include │ │ │ ├── stm32f1xx.h │ │ │ ├── stm32f103xb.h │ │ │ └── system_stm32f1xx.h │ └── Include │ │ ├── cmsis_version.h │ │ ├── tz_context.h │ │ └── cmsis_compiler.h └── STM32F1xx_HAL_Driver │ ├── Inc │ ├── stm32f1xx_hal_pcd_ex.h │ ├── stm32f1xx_hal_def.h │ ├── stm32f1xx_hal_flash.h │ └── stm32f1xx_hal_tim_ex.h │ └── Src │ ├── stm32f1xx_hal_gpio_ex.c │ └── stm32f1xx_hal_pcd_ex.c ├── Core ├── Inc │ ├── usb_parsing.h │ ├── ws2812b.h │ ├── gpio.h │ ├── spi.h │ ├── dma.h │ ├── stm32f1xx_it.h │ ├── main.h │ └── ws2812b_fx.h ├── Src │ ├── sysmem.c │ ├── dma.c │ ├── gpio.c │ ├── stm32f1xx_hal_msp.c │ ├── syscalls.c │ ├── spi.c │ ├── stm32f1xx_it.c │ ├── main.c │ ├── ws2812b.c │ └── usb_parsing.c └── Startup │ └── startup_stm32f103c8tx.s ├── README.md ├── LICENSE ├── .project ├── .settings └── language.settings.xml ├── Middlewares └── ST │ └── STM32_USB_Device_Library │ ├── Core │ ├── Inc │ │ ├── usbd_ctlreq.h │ │ ├── usbd_ioreq.h │ │ └── usbd_core.h │ └── Src │ │ └── usbd_ioreq.c │ └── Class │ └── CDC │ └── Inc │ └── usbd_cdc.h ├── USB_DEVICE ├── App │ ├── usb_device.h │ ├── usb_device.c │ ├── usbd_cdc_if.h │ ├── usbd_desc.h │ └── usbd_cdc_if.c └── Target │ └── usbd_conf.h ├── STM32F103C8Tx_FLASH.ld ├── WS2812B_C8.ioc ├── WS2812B_C8 Debug.launch └── .mxproject /.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | */Backup/ -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lamik/WS2812B_STM32_HAL/HEAD/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lamik/WS2812B_STM32_HAL/HEAD/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h -------------------------------------------------------------------------------- /Core/Inc/usb_parsing.h: -------------------------------------------------------------------------------- 1 | /* 2 | * usb_parsing.h 3 | * 4 | * The MIT License. 5 | * Created on: 15.11.2018 6 | * Author: Mateusz Salamon 7 | * www.msalamon.pl 8 | * mateusz@msalamon.pl 9 | */ 10 | 11 | #ifndef USB_PARSING_H_ 12 | #define USB_PARSING_H_ 13 | 14 | void USB_Parsing(void); 15 | 16 | #endif /* USB_PARSING_H_ */ 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | WS2812B diodes using STM32F103C8T6 MCU. 2 | 3 | www.msalamon.pl 4 | 5 | Diodes are driving by SPI interface with DMA. 6 | 7 | Library description: 8 | https://msalamon.pl/adresowalne-diody-ws2812b-na-stm32-cz-1/ 9 | 10 | https://msalamon.pl/adresowalne-diody-ws2812b-na-stm32-cz-2/ 11 | 12 | https://msalamon.pl/adresowalne-diody-ws2812b-na-stm32-cz-3/ 13 | 14 | The FX library is based od WS2812FX Arduino librarby by kitesurfer1404 - https://github.com/kitesurfer1404/WS2812FX 15 | 16 | 17 | -------------------------------------------------------------------------------- /Core/Inc/ws2812b.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ws2812b.h 3 | * 4 | * The MIT License. 5 | * Created on: 14.07.2017 6 | * Author: Mateusz Salamon 7 | * www.msalamon.pl 8 | * mateusz@msalamon.pl 9 | */ 10 | 11 | #ifndef WS2812B_H_ 12 | #define WS2812B_H_ 13 | 14 | // For 6 MHz SPI + DMA 15 | 16 | #define WS2812B_LEDS 35 17 | 18 | typedef struct ws2812b_color { 19 | uint8_t red, green, blue; 20 | } ws2812b_color; 21 | 22 | void WS2812B_Init(SPI_HandleTypeDef * spi_handler); 23 | void WS2812B_SetDiodeColor(int16_t diode_id, uint32_t color); 24 | void WS2812B_SetDiodeColorStruct(int16_t diode_id, ws2812b_color color); 25 | void WS2812B_SetDiodeRGB(int16_t diode_id, uint8_t R, uint8_t G, uint8_t B); 26 | void WS2812B_SetDiodeHSV(int16_t diode_id, uint16_t Hue, uint8_t Saturation, uint8_t Brightness); 27 | uint32_t WS2812B_GetColor(int16_t diode_id); 28 | uint8_t* WS2812B_GetPixels(void); 29 | void WS2812B_Refresh(); 30 | 31 | // color correction 32 | uint8_t sine8(uint8_t x); 33 | uint8_t gamma8(uint8_t x); 34 | #endif /* WS2812B_H_ */ 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Mateusz Salamon 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | WS2812B_C8 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | com.st.stm32cube.ide.mcu.MCUProjectNature 23 | com.st.stm32cube.ide.mcu.MCUCubeProjectNature 24 | org.eclipse.cdt.core.cnature 25 | com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAProjectNature 26 | com.st.stm32cube.ide.mcu.MCUAdvancedStructureProjectNature 27 | com.st.stm32cube.ide.mcu.MCUEndUserDisabledTrustZoneProjectNature 28 | com.st.stm32cube.ide.mcu.MCUSingleCpuProjectNature 29 | com.st.stm32cube.ide.mcu.MCURootProjectNature 30 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 31 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 32 | 33 | 34 | -------------------------------------------------------------------------------- /Core/Inc/gpio.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : gpio.h 4 | * Description : This file contains all the functions prototypes for 5 | * the gpio 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2020 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 __gpio_H 22 | #define __gpio_H 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "main.h" 29 | 30 | /* USER CODE BEGIN Includes */ 31 | 32 | /* USER CODE END Includes */ 33 | 34 | /* USER CODE BEGIN Private defines */ 35 | 36 | /* USER CODE END Private defines */ 37 | 38 | void MX_GPIO_Init(void); 39 | 40 | /* USER CODE BEGIN Prototypes */ 41 | 42 | /* USER CODE END Prototypes */ 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | #endif /*__ pinoutConfig_H */ 48 | 49 | /** 50 | * @} 51 | */ 52 | 53 | /** 54 | * @} 55 | */ 56 | 57 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 58 | -------------------------------------------------------------------------------- /Core/Src/sysmem.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file sysmem.c 4 | * @author Auto-generated by STM32CubeIDE 5 | * @brief STM32CubeIDE Minimal System Memory calls file 6 | * 7 | * For more information about which c-functions 8 | * need which of these lowlevel functions 9 | * please consult the Newlib libc-manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | *

© Copyright (c) 2020 STMicroelectronics. 14 | * All rights reserved.

15 | * 16 | * This software component is licensed by ST under BSD 3-Clause license, 17 | * the "License"; You may not use this file except in compliance with the 18 | * License. You may obtain a copy of the License at: 19 | * opensource.org/licenses/BSD-3-Clause 20 | * 21 | ****************************************************************************** 22 | */ 23 | 24 | /* Includes */ 25 | #include 26 | #include 27 | 28 | /* Variables */ 29 | extern int errno; 30 | register char * stack_ptr asm("sp"); 31 | 32 | /* Functions */ 33 | 34 | /** 35 | _sbrk 36 | Increase program data space. Malloc and related functions depend on this 37 | **/ 38 | caddr_t _sbrk(int incr) 39 | { 40 | extern char end asm("end"); 41 | static char *heap_end; 42 | char *prev_heap_end; 43 | 44 | if (heap_end == 0) 45 | heap_end = &end; 46 | 47 | prev_heap_end = heap_end; 48 | if (heap_end + incr > stack_ptr) 49 | { 50 | errno = ENOMEM; 51 | return (caddr_t) -1; 52 | } 53 | 54 | heap_end += incr; 55 | 56 | return (caddr_t) prev_heap_end; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /Core/Inc/spi.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : SPI.h 4 | * Description : This file provides code for the configuration 5 | * of the SPI instances. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2020 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 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __spi_H 21 | #define __spi_H 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "main.h" 28 | 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | extern SPI_HandleTypeDef hspi1; 34 | 35 | /* USER CODE BEGIN Private defines */ 36 | 37 | /* USER CODE END Private defines */ 38 | 39 | void MX_SPI1_Init(void); 40 | 41 | /* USER CODE BEGIN Prototypes */ 42 | 43 | /* USER CODE END Prototypes */ 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif /*__ spi_H */ 49 | 50 | /** 51 | * @} 52 | */ 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 59 | -------------------------------------------------------------------------------- /Core/Inc/dma.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : dma.h 4 | * Description : This file contains all the function prototypes for 5 | * the dma.c file 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2020 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 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __dma_H 21 | #define __dma_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "main.h" 29 | 30 | /* DMA memory to memory transfer handles -------------------------------------*/ 31 | 32 | /* USER CODE BEGIN Includes */ 33 | 34 | /* USER CODE END Includes */ 35 | 36 | /* USER CODE BEGIN Private defines */ 37 | 38 | /* USER CODE END Private defines */ 39 | 40 | void MX_DMA_Init(void); 41 | 42 | /* USER CODE BEGIN Prototypes */ 43 | 44 | /* USER CODE END Prototypes */ 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif /* __dma_H */ 51 | 52 | /** 53 | * @} 54 | */ 55 | 56 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 57 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.2 5 | * @date 19. April 2017 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /Core/Src/dma.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : dma.c 4 | * Description : This file provides code for the configuration 5 | * of all the requested memory to memory DMA transfers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2020 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 "dma.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | /*----------------------------------------------------------------------------*/ 28 | /* Configure DMA */ 29 | /*----------------------------------------------------------------------------*/ 30 | 31 | /* USER CODE BEGIN 1 */ 32 | 33 | /* USER CODE END 1 */ 34 | 35 | /** 36 | * Enable DMA controller clock 37 | */ 38 | void MX_DMA_Init(void) 39 | { 40 | 41 | /* DMA controller clock enable */ 42 | __HAL_RCC_DMA1_CLK_ENABLE(); 43 | 44 | /* DMA interrupt init */ 45 | /* DMA1_Channel3_IRQn interrupt configuration */ 46 | HAL_NVIC_SetPriority(DMA1_Channel3_IRQn, 1, 0); 47 | HAL_NVIC_EnableIRQ(DMA1_Channel3_IRQn); 48 | 49 | } 50 | 51 | /* USER CODE BEGIN 2 */ 52 | 53 | /* USER CODE END 2 */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** 60 | * @} 61 | */ 62 | 63 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 64 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f10x.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

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

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /** @addtogroup CMSIS 21 | * @{ 22 | */ 23 | 24 | /** @addtogroup stm32f10x_system 25 | * @{ 26 | */ 27 | 28 | /** 29 | * @brief Define to prevent recursive inclusion 30 | */ 31 | #ifndef __SYSTEM_STM32F10X_H 32 | #define __SYSTEM_STM32F10X_H 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /** @addtogroup STM32F10x_System_Includes 39 | * @{ 40 | */ 41 | 42 | /** 43 | * @} 44 | */ 45 | 46 | 47 | /** @addtogroup STM32F10x_System_Exported_types 48 | * @{ 49 | */ 50 | 51 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 52 | extern const uint8_t AHBPrescTable[16U]; /*!< AHB prescalers table values */ 53 | extern const uint8_t APBPrescTable[8U]; /*!< APB prescalers table values */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @addtogroup STM32F10x_System_Exported_Constants 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @addtogroup STM32F10x_System_Exported_Macros 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32F10x_System_Exported_Functions 76 | * @{ 77 | */ 78 | 79 | extern void SystemInit(void); 80 | extern void SystemCoreClockUpdate(void); 81 | /** 82 | * @} 83 | */ 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif /*__SYSTEM_STM32F10X_H */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 99 | -------------------------------------------------------------------------------- /Core/Inc/stm32f1xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f1xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

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

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F1xx_IT_H 23 | #define __STM32F1xx_IT_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Private includes ----------------------------------------------------------*/ 30 | /* USER CODE BEGIN Includes */ 31 | 32 | /* USER CODE END Includes */ 33 | 34 | /* Exported types ------------------------------------------------------------*/ 35 | /* USER CODE BEGIN ET */ 36 | 37 | /* USER CODE END ET */ 38 | 39 | /* Exported constants --------------------------------------------------------*/ 40 | /* USER CODE BEGIN EC */ 41 | 42 | /* USER CODE END EC */ 43 | 44 | /* Exported macro ------------------------------------------------------------*/ 45 | /* USER CODE BEGIN EM */ 46 | 47 | /* USER CODE END EM */ 48 | 49 | /* Exported functions prototypes ---------------------------------------------*/ 50 | void NMI_Handler(void); 51 | void HardFault_Handler(void); 52 | void MemManage_Handler(void); 53 | void BusFault_Handler(void); 54 | void UsageFault_Handler(void); 55 | void SVC_Handler(void); 56 | void DebugMon_Handler(void); 57 | void PendSV_Handler(void); 58 | void SysTick_Handler(void); 59 | void DMA1_Channel3_IRQHandler(void); 60 | void USB_LP_CAN1_RX0_IRQHandler(void); 61 | /* USER CODE BEGIN EFP */ 62 | 63 | /* USER CODE END EFP */ 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif /* __STM32F1xx_IT_H */ 70 | 71 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 72 | -------------------------------------------------------------------------------- /.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /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) 2020 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under BSD 3-Clause license, 14 | * the "License"; You may not use this file except in compliance with the 15 | * License. You may obtain a copy of the License at: 16 | * opensource.org/licenses/BSD-3-Clause 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __MAIN_H 24 | #define __MAIN_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f1xx_hal.h" 32 | 33 | /* Private includes ----------------------------------------------------------*/ 34 | /* USER CODE BEGIN Includes */ 35 | 36 | /* USER CODE END Includes */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* USER CODE BEGIN ET */ 40 | 41 | /* USER CODE END ET */ 42 | 43 | /* Exported constants --------------------------------------------------------*/ 44 | /* USER CODE BEGIN EC */ 45 | 46 | /* USER CODE END EC */ 47 | 48 | /* Exported macro ------------------------------------------------------------*/ 49 | /* USER CODE BEGIN EM */ 50 | 51 | /* USER CODE END EM */ 52 | 53 | /* Exported functions prototypes ---------------------------------------------*/ 54 | void Error_Handler(void); 55 | 56 | /* USER CODE BEGIN EFP */ 57 | 58 | /* USER CODE END EFP */ 59 | 60 | /* Private defines -----------------------------------------------------------*/ 61 | #define LED_Pin GPIO_PIN_13 62 | #define LED_GPIO_Port GPIOC 63 | #define TEST_Pin GPIO_PIN_0 64 | #define TEST_GPIO_Port GPIOA 65 | /* USER CODE BEGIN Private defines */ 66 | 67 | /* USER CODE END Private defines */ 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* __MAIN_H */ 74 | 75 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 76 | -------------------------------------------------------------------------------- /Core/Src/gpio.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : gpio.c 4 | * Description : This file provides code for the configuration 5 | * of all used GPIO pins. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2020 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 "gpio.h" 22 | /* USER CODE BEGIN 0 */ 23 | 24 | /* USER CODE END 0 */ 25 | 26 | /*----------------------------------------------------------------------------*/ 27 | /* Configure GPIO */ 28 | /*----------------------------------------------------------------------------*/ 29 | /* USER CODE BEGIN 1 */ 30 | 31 | /* USER CODE END 1 */ 32 | 33 | /** Configure pins as 34 | * Analog 35 | * Input 36 | * Output 37 | * EVENT_OUT 38 | * EXTI 39 | */ 40 | void MX_GPIO_Init(void) 41 | { 42 | 43 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 44 | 45 | /* GPIO Ports Clock Enable */ 46 | __HAL_RCC_GPIOC_CLK_ENABLE(); 47 | __HAL_RCC_GPIOD_CLK_ENABLE(); 48 | __HAL_RCC_GPIOA_CLK_ENABLE(); 49 | 50 | /*Configure GPIO pin Output Level */ 51 | HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET); 52 | 53 | /*Configure GPIO pin Output Level */ 54 | HAL_GPIO_WritePin(TEST_GPIO_Port, TEST_Pin, GPIO_PIN_RESET); 55 | 56 | /*Configure GPIO pin : PtPin */ 57 | GPIO_InitStruct.Pin = LED_Pin; 58 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 59 | GPIO_InitStruct.Pull = GPIO_NOPULL; 60 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 61 | HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct); 62 | 63 | /*Configure GPIO pin : PtPin */ 64 | GPIO_InitStruct.Pin = TEST_Pin; 65 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 66 | GPIO_InitStruct.Pull = GPIO_NOPULL; 67 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 68 | HAL_GPIO_Init(TEST_GPIO_Port, &GPIO_InitStruct); 69 | 70 | } 71 | 72 | /* USER CODE BEGIN 2 */ 73 | 74 | /* USER CODE END 2 */ 75 | 76 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 77 | -------------------------------------------------------------------------------- /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 | 81 | void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 82 | 83 | void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata); 84 | 85 | void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len); 86 | /** 87 | * @} 88 | */ 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /* __USB_REQUEST_H */ 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | 105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 106 | -------------------------------------------------------------------------------- /Core/Src/stm32f1xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * File Name : stm32f1xx_hal_msp.c 5 | * Description : This file provides code for the MSP Initialization 6 | * and de-Initialization codes. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2020 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under BSD 3-Clause license, 14 | * the "License"; You may not use this file except in compliance with the 15 | * License. You may obtain a copy of the License at: 16 | * opensource.org/licenses/BSD-3-Clause 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "main.h" 24 | /* USER CODE BEGIN Includes */ 25 | 26 | /* USER CODE END Includes */ 27 | 28 | /* Private typedef -----------------------------------------------------------*/ 29 | /* USER CODE BEGIN TD */ 30 | 31 | /* USER CODE END TD */ 32 | 33 | /* Private define ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN Define */ 35 | 36 | /* USER CODE END Define */ 37 | 38 | /* Private macro -------------------------------------------------------------*/ 39 | /* USER CODE BEGIN Macro */ 40 | 41 | /* USER CODE END Macro */ 42 | 43 | /* Private variables ---------------------------------------------------------*/ 44 | /* USER CODE BEGIN PV */ 45 | 46 | /* USER CODE END PV */ 47 | 48 | /* Private function prototypes -----------------------------------------------*/ 49 | /* USER CODE BEGIN PFP */ 50 | 51 | /* USER CODE END PFP */ 52 | 53 | /* External functions --------------------------------------------------------*/ 54 | /* USER CODE BEGIN ExternalFunctions */ 55 | 56 | /* USER CODE END ExternalFunctions */ 57 | 58 | /* USER CODE BEGIN 0 */ 59 | 60 | /* USER CODE END 0 */ 61 | /** 62 | * Initializes the Global MSP. 63 | */ 64 | void HAL_MspInit(void) 65 | { 66 | /* USER CODE BEGIN MspInit 0 */ 67 | 68 | /* USER CODE END MspInit 0 */ 69 | 70 | __HAL_RCC_AFIO_CLK_ENABLE(); 71 | __HAL_RCC_PWR_CLK_ENABLE(); 72 | 73 | /* System interrupt init*/ 74 | 75 | /** NOJTAG: JTAG-DP Disabled and SW-DP Enabled 76 | */ 77 | __HAL_AFIO_REMAP_SWJ_NOJTAG(); 78 | 79 | /* USER CODE BEGIN MspInit 1 */ 80 | 81 | /* USER CODE END MspInit 1 */ 82 | } 83 | 84 | /* USER CODE BEGIN 1 */ 85 | 86 | /* USER CODE END 1 */ 87 | 88 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 89 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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) 2020 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under Ultimate Liberty license 14 | * SLA0044, the "License"; You may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at: 16 | * www.st.com/SLA0044 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __USB_DEVICE__H__ 24 | #define __USB_DEVICE__H__ 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f1xx.h" 32 | #include "stm32f1xx_hal.h" 33 | #include "usbd_def.h" 34 | 35 | /* USER CODE BEGIN INCLUDE */ 36 | 37 | /* USER CODE END INCLUDE */ 38 | 39 | /** @addtogroup USBD_OTG_DRIVER 40 | * @{ 41 | */ 42 | 43 | /** @defgroup USBD_DEVICE USBD_DEVICE 44 | * @brief Device file for Usb otg low level driver. 45 | * @{ 46 | */ 47 | 48 | /** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables 49 | * @brief Public variables. 50 | * @{ 51 | */ 52 | 53 | /* Private variables ---------------------------------------------------------*/ 54 | /* USER CODE BEGIN PV */ 55 | 56 | /* USER CODE END PV */ 57 | 58 | /* Private function prototypes -----------------------------------------------*/ 59 | /* USER CODE BEGIN PFP */ 60 | 61 | /* USER CODE END PFP */ 62 | 63 | /* 64 | * -- Insert your variables declaration here -- 65 | */ 66 | /* USER CODE BEGIN VARIABLES */ 67 | 68 | /* USER CODE END VARIABLES */ 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype 74 | * @brief Declaration of public functions for Usb device. 75 | * @{ 76 | */ 77 | 78 | /** USB Device initialization function. */ 79 | void MX_USB_DEVICE_Init(void); 80 | 81 | /* 82 | * -- Insert functions declaration here -- 83 | */ 84 | /* USER CODE BEGIN FD */ 85 | 86 | /* USER CODE END FD */ 87 | /** 88 | * @} 89 | */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | #ifdef __cplusplus 100 | } 101 | #endif 102 | 103 | #endif /* __USB_DEVICE__H__ */ 104 | 105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 106 | -------------------------------------------------------------------------------- /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) 2020 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under Ultimate Liberty license 14 | * SLA0044, the "License"; You may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at: 16 | * www.st.com/SLA0044 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | 24 | #include "usb_device.h" 25 | #include "usbd_core.h" 26 | #include "usbd_desc.h" 27 | #include "usbd_cdc.h" 28 | #include "usbd_cdc_if.h" 29 | 30 | /* USER CODE BEGIN Includes */ 31 | 32 | /* USER CODE END Includes */ 33 | 34 | /* USER CODE BEGIN PV */ 35 | /* Private variables ---------------------------------------------------------*/ 36 | 37 | /* USER CODE END PV */ 38 | 39 | /* USER CODE BEGIN PFP */ 40 | /* Private function prototypes -----------------------------------------------*/ 41 | 42 | /* USER CODE END PFP */ 43 | 44 | /* USB Device Core handle declaration. */ 45 | USBD_HandleTypeDef hUsbDeviceFS; 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 | 89 | /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ 90 | 91 | /* USER CODE END USB_DEVICE_Init_PostTreatment */ 92 | } 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 103 | -------------------------------------------------------------------------------- /Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pcd_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_pcd_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of PCD HAL Extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

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

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef STM32F1xx_HAL_PCD_EX_H 22 | #define STM32F1xx_HAL_PCD_EX_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f1xx_hal_def.h" 30 | 31 | #if defined (USB) || defined (USB_OTG_FS) 32 | /** @addtogroup STM32F1xx_HAL_Driver 33 | * @{ 34 | */ 35 | 36 | /** @addtogroup PCDEx 37 | * @{ 38 | */ 39 | /* Exported types ------------------------------------------------------------*/ 40 | /* Exported constants --------------------------------------------------------*/ 41 | /* Exported macros -----------------------------------------------------------*/ 42 | /* Exported functions --------------------------------------------------------*/ 43 | /** @addtogroup PCDEx_Exported_Functions PCDEx Exported Functions 44 | * @{ 45 | */ 46 | /** @addtogroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 47 | * @{ 48 | */ 49 | 50 | #if defined (USB_OTG_FS) 51 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size); 52 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size); 53 | #endif /* defined (USB_OTG_FS) */ 54 | 55 | #if defined (USB) 56 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, 57 | uint16_t ep_addr, 58 | uint16_t ep_kind, 59 | uint32_t pmaadress); 60 | 61 | void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state); 62 | #endif /* defined (USB) */ 63 | void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg); 64 | void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg); 65 | 66 | /** 67 | * @} 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** 75 | * @} 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | #endif /* defined (USB) || defined (USB_OTG_FS) */ 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | 88 | #endif /* STM32F1xx_HAL_PCD_EX_H */ 89 | 90 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 91 | -------------------------------------------------------------------------------- /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, 82 | uint16_t len); 83 | 84 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, 85 | uint8_t *pbuf, 86 | uint16_t len); 87 | 88 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev, 89 | uint8_t *pbuf, 90 | uint16_t len); 91 | 92 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev, 93 | uint8_t *pbuf, 94 | uint16_t len); 95 | 96 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev); 97 | 98 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev); 99 | 100 | uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 101 | 102 | /** 103 | * @} 104 | */ 105 | 106 | #ifdef __cplusplus 107 | } 108 | #endif 109 | 110 | #endif /* __USBD_IOREQ_H */ 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /** 117 | * @} 118 | */ 119 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 120 | -------------------------------------------------------------------------------- /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) 2020 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under Ultimate Liberty license 14 | * SLA0044, the "License"; You may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at: 16 | * www.st.com/SLA0044 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __USBD_CDC_IF_H__ 24 | #define __USBD_CDC_IF_H__ 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "usbd_cdc.h" 32 | 33 | /* USER CODE BEGIN INCLUDE */ 34 | 35 | /* USER CODE END INCLUDE */ 36 | 37 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 38 | * @brief For Usb device. 39 | * @{ 40 | */ 41 | 42 | /** @defgroup USBD_CDC_IF USBD_CDC_IF 43 | * @brief Usb VCP device module 44 | * @{ 45 | */ 46 | 47 | /** @defgroup USBD_CDC_IF_Exported_Defines USBD_CDC_IF_Exported_Defines 48 | * @brief Defines. 49 | * @{ 50 | */ 51 | /* USER CODE BEGIN EXPORTED_DEFINES */ 52 | 53 | /* USER CODE END EXPORTED_DEFINES */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @defgroup USBD_CDC_IF_Exported_Types USBD_CDC_IF_Exported_Types 60 | * @brief Types. 61 | * @{ 62 | */ 63 | 64 | /* USER CODE BEGIN EXPORTED_TYPES */ 65 | 66 | /* USER CODE END EXPORTED_TYPES */ 67 | 68 | /** 69 | * @} 70 | */ 71 | 72 | /** @defgroup USBD_CDC_IF_Exported_Macros USBD_CDC_IF_Exported_Macros 73 | * @brief Aliases. 74 | * @{ 75 | */ 76 | 77 | /* USER CODE BEGIN EXPORTED_MACRO */ 78 | 79 | /* USER CODE END EXPORTED_MACRO */ 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | /** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables 86 | * @brief Public variables. 87 | * @{ 88 | */ 89 | 90 | /** CDC Interface callback. */ 91 | extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS; 92 | 93 | /* USER CODE BEGIN EXPORTED_VARIABLES */ 94 | 95 | /* USER CODE END EXPORTED_VARIABLES */ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | /** @defgroup USBD_CDC_IF_Exported_FunctionsPrototype USBD_CDC_IF_Exported_FunctionsPrototype 102 | * @brief Public functions declaration. 103 | * @{ 104 | */ 105 | 106 | uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len); 107 | 108 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */ 109 | 110 | /* USER CODE END EXPORTED_FUNCTIONS */ 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /** 117 | * @} 118 | */ 119 | 120 | /** 121 | * @} 122 | */ 123 | 124 | #ifdef __cplusplus 125 | } 126 | #endif 127 | 128 | #endif /* __USBD_CDC_IF_H__ */ 129 | 130 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 131 | -------------------------------------------------------------------------------- /Core/Src/syscalls.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file syscalls.c 4 | * @author Auto-generated by STM32CubeIDE 5 | * @brief STM32CubeIDE Minimal System calls file 6 | * 7 | * For more information about which c-functions 8 | * need which of these lowlevel functions 9 | * please consult the Newlib libc-manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | *

© Copyright (c) 2020 STMicroelectronics. 14 | * All rights reserved.

15 | * 16 | * This software component is licensed by ST under BSD 3-Clause license, 17 | * the "License"; You may not use this file except in compliance with the 18 | * License. You may obtain a copy of the License at: 19 | * opensource.org/licenses/BSD-3-Clause 20 | * 21 | ****************************************************************************** 22 | */ 23 | 24 | /* Includes */ 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | 35 | /* Variables */ 36 | //#undef errno 37 | extern int errno; 38 | extern int __io_putchar(int ch) __attribute__((weak)); 39 | extern int __io_getchar(void) __attribute__((weak)); 40 | 41 | register char * stack_ptr asm("sp"); 42 | 43 | char *__env[1] = { 0 }; 44 | char **environ = __env; 45 | 46 | 47 | /* Functions */ 48 | void initialise_monitor_handles() 49 | { 50 | } 51 | 52 | int _getpid(void) 53 | { 54 | return 1; 55 | } 56 | 57 | int _kill(int pid, int sig) 58 | { 59 | errno = EINVAL; 60 | return -1; 61 | } 62 | 63 | void _exit (int status) 64 | { 65 | _kill(status, -1); 66 | while (1) {} /* Make sure we hang here */ 67 | } 68 | 69 | __attribute__((weak)) int _read(int file, char *ptr, int len) 70 | { 71 | int DataIdx; 72 | 73 | for (DataIdx = 0; DataIdx < len; DataIdx++) 74 | { 75 | *ptr++ = __io_getchar(); 76 | } 77 | 78 | return len; 79 | } 80 | 81 | __attribute__((weak)) int _write(int file, char *ptr, int len) 82 | { 83 | int DataIdx; 84 | 85 | for (DataIdx = 0; DataIdx < len; DataIdx++) 86 | { 87 | __io_putchar(*ptr++); 88 | } 89 | return len; 90 | } 91 | 92 | int _close(int file) 93 | { 94 | return -1; 95 | } 96 | 97 | 98 | int _fstat(int file, struct stat *st) 99 | { 100 | st->st_mode = S_IFCHR; 101 | return 0; 102 | } 103 | 104 | int _isatty(int file) 105 | { 106 | return 1; 107 | } 108 | 109 | int _lseek(int file, int ptr, int dir) 110 | { 111 | return 0; 112 | } 113 | 114 | int _open(char *path, int flags, ...) 115 | { 116 | /* Pretend like we always fail */ 117 | return -1; 118 | } 119 | 120 | int _wait(int *status) 121 | { 122 | errno = ECHILD; 123 | return -1; 124 | } 125 | 126 | int _unlink(char *name) 127 | { 128 | errno = ENOENT; 129 | return -1; 130 | } 131 | 132 | int _times(struct tms *buf) 133 | { 134 | return -1; 135 | } 136 | 137 | int _stat(char *file, struct stat *st) 138 | { 139 | st->st_mode = S_IFCHR; 140 | return 0; 141 | } 142 | 143 | int _link(char *old, char *new) 144 | { 145 | errno = EMLINK; 146 | return -1; 147 | } 148 | 149 | int _fork(void) 150 | { 151 | errno = EAGAIN; 152 | return -1; 153 | } 154 | 155 | int _execve(char *name, char **argv, char **env) 156 | { 157 | errno = ENOMEM; 158 | return -1; 159 | } 160 | -------------------------------------------------------------------------------- /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) 2020 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under Ultimate Liberty license 14 | * SLA0044, the "License"; You may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at: 16 | * www.st.com/SLA0044 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __USBD_DESC__C__ 23 | #define __USBD_DESC__C__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "usbd_def.h" 31 | 32 | /* USER CODE BEGIN INCLUDE */ 33 | 34 | /* USER CODE END INCLUDE */ 35 | 36 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 37 | * @{ 38 | */ 39 | 40 | /** @defgroup USBD_DESC USBD_DESC 41 | * @brief Usb device descriptors module. 42 | * @{ 43 | */ 44 | 45 | /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants 46 | * @brief Constants. 47 | * @{ 48 | */ 49 | #define DEVICE_ID1 (UID_BASE) 50 | #define DEVICE_ID2 (UID_BASE + 0x4) 51 | #define DEVICE_ID3 (UID_BASE + 0x8) 52 | 53 | #define USB_SIZ_STRING_SERIAL 0x1A 54 | 55 | /* USER CODE BEGIN EXPORTED_CONSTANTS */ 56 | 57 | /* USER CODE END EXPORTED_CONSTANTS */ 58 | 59 | /** 60 | * @} 61 | */ 62 | 63 | /** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines 64 | * @brief Defines. 65 | * @{ 66 | */ 67 | 68 | /* USER CODE BEGIN EXPORTED_DEFINES */ 69 | 70 | /* USER CODE END EXPORTED_DEFINES */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions 77 | * @brief Types. 78 | * @{ 79 | */ 80 | 81 | /* USER CODE BEGIN EXPORTED_TYPES */ 82 | 83 | /* USER CODE END EXPORTED_TYPES */ 84 | 85 | /** 86 | * @} 87 | */ 88 | 89 | /** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros 90 | * @brief Aliases. 91 | * @{ 92 | */ 93 | 94 | /* USER CODE BEGIN EXPORTED_MACRO */ 95 | 96 | /* USER CODE END EXPORTED_MACRO */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables 103 | * @brief Public variables. 104 | * @{ 105 | */ 106 | 107 | /** Descriptor for the Usb device. */ 108 | extern USBD_DescriptorsTypeDef FS_Desc; 109 | 110 | /* USER CODE BEGIN EXPORTED_VARIABLES */ 111 | 112 | /* USER CODE END EXPORTED_VARIABLES */ 113 | 114 | /** 115 | * @} 116 | */ 117 | 118 | /** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype 119 | * @brief Public functions declaration. 120 | * @{ 121 | */ 122 | 123 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */ 124 | 125 | /* USER CODE END EXPORTED_FUNCTIONS */ 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /** 132 | * @} 133 | */ 134 | 135 | /** 136 | * @} 137 | */ 138 | 139 | #ifdef __cplusplus 140 | } 141 | #endif 142 | 143 | #endif /* __USBD_DESC__C__ */ 144 | 145 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 146 | -------------------------------------------------------------------------------- /Core/Src/spi.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : SPI.c 4 | * Description : This file provides code for the configuration 5 | * of the SPI instances. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2020 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 "spi.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | SPI_HandleTypeDef hspi1; 28 | DMA_HandleTypeDef hdma_spi1_tx; 29 | 30 | /* SPI1 init function */ 31 | void MX_SPI1_Init(void) 32 | { 33 | 34 | hspi1.Instance = SPI1; 35 | hspi1.Init.Mode = SPI_MODE_MASTER; 36 | hspi1.Init.Direction = SPI_DIRECTION_2LINES; 37 | hspi1.Init.DataSize = SPI_DATASIZE_8BIT; 38 | hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; 39 | hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; 40 | hspi1.Init.NSS = SPI_NSS_SOFT; 41 | hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8; 42 | hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; 43 | hspi1.Init.TIMode = SPI_TIMODE_DISABLE; 44 | hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; 45 | hspi1.Init.CRCPolynomial = 10; 46 | if (HAL_SPI_Init(&hspi1) != HAL_OK) 47 | { 48 | Error_Handler(); 49 | } 50 | 51 | } 52 | 53 | void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle) 54 | { 55 | 56 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 57 | if(spiHandle->Instance==SPI1) 58 | { 59 | /* USER CODE BEGIN SPI1_MspInit 0 */ 60 | 61 | /* USER CODE END SPI1_MspInit 0 */ 62 | /* SPI1 clock enable */ 63 | __HAL_RCC_SPI1_CLK_ENABLE(); 64 | 65 | __HAL_RCC_GPIOA_CLK_ENABLE(); 66 | /**SPI1 GPIO Configuration 67 | PA5 ------> SPI1_SCK 68 | PA7 ------> SPI1_MOSI 69 | */ 70 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7; 71 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 72 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; 73 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 74 | 75 | /* SPI1 DMA Init */ 76 | /* SPI1_TX Init */ 77 | hdma_spi1_tx.Instance = DMA1_Channel3; 78 | hdma_spi1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; 79 | hdma_spi1_tx.Init.PeriphInc = DMA_PINC_DISABLE; 80 | hdma_spi1_tx.Init.MemInc = DMA_MINC_ENABLE; 81 | hdma_spi1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; 82 | hdma_spi1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; 83 | hdma_spi1_tx.Init.Mode = DMA_CIRCULAR; 84 | hdma_spi1_tx.Init.Priority = DMA_PRIORITY_VERY_HIGH; 85 | if (HAL_DMA_Init(&hdma_spi1_tx) != HAL_OK) 86 | { 87 | Error_Handler(); 88 | } 89 | 90 | __HAL_LINKDMA(spiHandle,hdmatx,hdma_spi1_tx); 91 | 92 | /* USER CODE BEGIN SPI1_MspInit 1 */ 93 | 94 | /* USER CODE END SPI1_MspInit 1 */ 95 | } 96 | } 97 | 98 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle) 99 | { 100 | 101 | if(spiHandle->Instance==SPI1) 102 | { 103 | /* USER CODE BEGIN SPI1_MspDeInit 0 */ 104 | 105 | /* USER CODE END SPI1_MspDeInit 0 */ 106 | /* Peripheral clock disable */ 107 | __HAL_RCC_SPI1_CLK_DISABLE(); 108 | 109 | /**SPI1 GPIO Configuration 110 | PA5 ------> SPI1_SCK 111 | PA7 ------> SPI1_MOSI 112 | */ 113 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_7); 114 | 115 | /* SPI1 DMA DeInit */ 116 | HAL_DMA_DeInit(spiHandle->hdmatx); 117 | /* USER CODE BEGIN SPI1_MspDeInit 1 */ 118 | 119 | /* USER CODE END SPI1_MspDeInit 1 */ 120 | } 121 | } 122 | 123 | /* USER CODE BEGIN 1 */ 124 | 125 | /* USER CODE END 1 */ 126 | 127 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 128 | -------------------------------------------------------------------------------- /Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_gpio_ex.c 4 | * @author MCD Application Team 5 | * @brief GPIO Extension HAL module driver. 6 | * This file provides firmware functions to manage the following 7 | * functionalities of the General Purpose Input/Output (GPIO) extension peripheral. 8 | * + Extended features functions 9 | * 10 | @verbatim 11 | ============================================================================== 12 | ##### GPIO Peripheral extension features ##### 13 | ============================================================================== 14 | [..] GPIO module on STM32F1 family, manage also the AFIO register: 15 | (+) Possibility to use the EVENTOUT Cortex feature 16 | 17 | ##### How to use this driver ##### 18 | ============================================================================== 19 | [..] This driver provides functions to use EVENTOUT Cortex feature 20 | (#) Configure EVENTOUT Cortex feature using the function HAL_GPIOEx_ConfigEventout() 21 | (#) Activate EVENTOUT Cortex feature using the HAL_GPIOEx_EnableEventout() 22 | (#) Deactivate EVENTOUT Cortex feature using the HAL_GPIOEx_DisableEventout() 23 | 24 | @endverbatim 25 | ****************************************************************************** 26 | * @attention 27 | * 28 | *

© Copyright (c) 2016 STMicroelectronics. 29 | * All rights reserved.

30 | * 31 | * This software component is licensed by ST under BSD 3-Clause license, 32 | * the "License"; You may not use this file except in compliance with the 33 | * License. You may obtain a copy of the License at: 34 | * opensource.org/licenses/BSD-3-Clause 35 | * 36 | ****************************************************************************** 37 | */ 38 | 39 | /* Includes ------------------------------------------------------------------*/ 40 | #include "stm32f1xx_hal.h" 41 | 42 | /** @addtogroup STM32F1xx_HAL_Driver 43 | * @{ 44 | */ 45 | 46 | /** @defgroup GPIOEx GPIOEx 47 | * @brief GPIO HAL module driver 48 | * @{ 49 | */ 50 | 51 | #ifdef HAL_GPIO_MODULE_ENABLED 52 | 53 | /** @defgroup GPIOEx_Exported_Functions GPIOEx Exported Functions 54 | * @{ 55 | */ 56 | 57 | /** @defgroup GPIOEx_Exported_Functions_Group1 Extended features functions 58 | * @brief Extended features functions 59 | * 60 | @verbatim 61 | ============================================================================== 62 | ##### Extended features functions ##### 63 | ============================================================================== 64 | [..] This section provides functions allowing to: 65 | (+) Configure EVENTOUT Cortex feature using the function HAL_GPIOEx_ConfigEventout() 66 | (+) Activate EVENTOUT Cortex feature using the HAL_GPIOEx_EnableEventout() 67 | (+) Deactivate EVENTOUT Cortex feature using the HAL_GPIOEx_DisableEventout() 68 | 69 | @endverbatim 70 | * @{ 71 | */ 72 | 73 | /** 74 | * @brief Configures the port and pin on which the EVENTOUT Cortex signal will be connected. 75 | * @param GPIO_PortSource Select the port used to output the Cortex EVENTOUT signal. 76 | * This parameter can be a value of @ref GPIOEx_EVENTOUT_PORT. 77 | * @param GPIO_PinSource Select the pin used to output the Cortex EVENTOUT signal. 78 | * This parameter can be a value of @ref GPIOEx_EVENTOUT_PIN. 79 | * @retval None 80 | */ 81 | void HAL_GPIOEx_ConfigEventout(uint32_t GPIO_PortSource, uint32_t GPIO_PinSource) 82 | { 83 | /* Verify the parameters */ 84 | assert_param(IS_AFIO_EVENTOUT_PORT(GPIO_PortSource)); 85 | assert_param(IS_AFIO_EVENTOUT_PIN(GPIO_PinSource)); 86 | 87 | /* Apply the new configuration */ 88 | MODIFY_REG(AFIO->EVCR, (AFIO_EVCR_PORT) | (AFIO_EVCR_PIN), (GPIO_PortSource) | (GPIO_PinSource)); 89 | } 90 | 91 | /** 92 | * @brief Enables the Event Output. 93 | * @retval None 94 | */ 95 | void HAL_GPIOEx_EnableEventout(void) 96 | { 97 | SET_BIT(AFIO->EVCR, AFIO_EVCR_EVOE); 98 | } 99 | 100 | /** 101 | * @brief Disables the Event Output. 102 | * @retval None 103 | */ 104 | void HAL_GPIOEx_DisableEventout(void) 105 | { 106 | CLEAR_BIT(AFIO->EVCR, AFIO_EVCR_EVOE); 107 | } 108 | 109 | /** 110 | * @} 111 | */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | #endif /* HAL_GPIO_MODULE_ENABLED */ 118 | 119 | /** 120 | * @} 121 | */ 122 | 123 | /** 124 | * @} 125 | */ 126 | 127 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 128 | -------------------------------------------------------------------------------- /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) 2020 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under Ultimate Liberty license 14 | * SLA0044, the "License"; You may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at: 16 | * www.st.com/SLA0044 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __USBD_CONF__H__ 24 | #define __USBD_CONF__H__ 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include 32 | #include 33 | #include 34 | #include "main.h" 35 | #include "stm32f1xx.h" 36 | #include "stm32f1xx_hal.h" 37 | 38 | /* USER CODE BEGIN INCLUDE */ 39 | 40 | /* USER CODE END INCLUDE */ 41 | 42 | /** @addtogroup USBD_OTG_DRIVER 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 1 67 | /*---------- -----------*/ 68 | #define USBD_MAX_NUM_CONFIGURATION 1 69 | /*---------- -----------*/ 70 | #define USBD_MAX_STR_DESC_SIZ 512 71 | /*---------- -----------*/ 72 | #define USBD_DEBUG_LEVEL 0 73 | /*---------- -----------*/ 74 | #define USBD_SELF_POWERED 1 75 | /*---------- -----------*/ 76 | #define MAX_STATIC_ALLOC_SIZE 512 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 | /** Alias for memory allocation. */ 94 | #define USBD_malloc (uint32_t *)USBD_static_malloc 95 | 96 | /** Alias for memory release. */ 97 | #define USBD_free USBD_static_free 98 | 99 | /** Alias for memory set. */ 100 | #define USBD_memset /* Not used */ 101 | 102 | /** Alias for memory copy. */ 103 | #define USBD_memcpy /* Not used */ 104 | 105 | /** Alias for delay. */ 106 | #define USBD_Delay HAL_Delay 107 | 108 | /* For footprint reasons and since only one allocation is handled in the HID class 109 | driver, the malloc/free is changed into a static allocation method */ 110 | void *USBD_static_malloc(uint32_t size); 111 | void USBD_static_free(void *p); 112 | 113 | /* DEBUG macros */ 114 | 115 | #if (USBD_DEBUG_LEVEL > 0) 116 | #define USBD_UsrLog(...) printf(__VA_ARGS__);\ 117 | printf("\n"); 118 | #else 119 | #define USBD_UsrLog(...) 120 | #endif 121 | 122 | #if (USBD_DEBUG_LEVEL > 1) 123 | 124 | #define USBD_ErrLog(...) printf("ERROR: ") ;\ 125 | printf(__VA_ARGS__);\ 126 | printf("\n"); 127 | #else 128 | #define USBD_ErrLog(...) 129 | #endif 130 | 131 | #if (USBD_DEBUG_LEVEL > 2) 132 | #define USBD_DbgLog(...) printf("DEBUG : ") ;\ 133 | printf(__VA_ARGS__);\ 134 | printf("\n"); 135 | #else 136 | #define USBD_DbgLog(...) 137 | #endif 138 | 139 | /** 140 | * @} 141 | */ 142 | 143 | /** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types 144 | * @brief Types. 145 | * @{ 146 | */ 147 | 148 | /** 149 | * @} 150 | */ 151 | 152 | /** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype 153 | * @brief Declaration of public functions for Usb device. 154 | * @{ 155 | */ 156 | 157 | /* Exported functions -------------------------------------------------------*/ 158 | 159 | /** 160 | * @} 161 | */ 162 | 163 | /** 164 | * @} 165 | */ 166 | 167 | /** 168 | * @} 169 | */ 170 | 171 | #ifdef __cplusplus 172 | } 173 | #endif 174 | 175 | #endif /* __USBD_CONF__H__ */ 176 | 177 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 178 | -------------------------------------------------------------------------------- /Core/Inc/ws2812b_fx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ws2812b_fx.h 3 | * 4 | * Library based on Harm Aldick's Arduino library 5 | * https://github.com/kitesurfer1404/WS2812FX 6 | * 7 | * The MIT License. 8 | * Created on: 20.10.2018 9 | * Author: Mateusz Salamon 10 | * www.msalamon.pl 11 | * mateusz@msalamon.pl 12 | */ 13 | 14 | #ifndef WS2812B_FX_H_ 15 | #define WS2812B_FX_H_ 16 | 17 | #define DEFAULT_COLOR 0x00FF000000 18 | #define NUM_COLORS 3 19 | 20 | #define SPEED_MIN 10 21 | #define DEFAULT_SPEED 150 22 | #define SPEED_MAX 65535 23 | 24 | #define MODE_COUNT 58 25 | #define DEFAULT_MODE 0 26 | 27 | #define FADE_RATE 2 28 | 29 | // some common colors 30 | #define RED (uint32_t)0xFF0000 31 | #define GREEN (uint32_t)0x00FF00 32 | #define BLUE (uint32_t)0x0000FF 33 | #define WHITE (uint32_t)0xFFFFFF 34 | #define BLACK (uint32_t)0x000000 35 | #define YELLOW (uint32_t)0xFFFF00 36 | #define CYAN (uint32_t)0x00FFFF 37 | #define MAGENTA (uint32_t)0xFF00FF 38 | #define PURPLE (uint32_t)0x400080 39 | #define ORANGE (uint32_t)0xFF3000 40 | #define PINK (uint32_t)0xFF1493 41 | 42 | typedef enum { 43 | FX_OK = 0, 44 | FX_ERROR = 1 45 | } FX_STATUS; 46 | 47 | typedef enum { 48 | FX_MODE_STATIC, 49 | FX_MODE_WHITE_TO_COLOR, 50 | FX_MODE_BLACK_TO_COLOR, 51 | FX_MODE_BLINK, 52 | FX_MODE_BLINK_RAINBOW, 53 | FX_MODE_STROBE, 54 | FX_MODE_STROBE_RAINBOW, 55 | FX_MODE_BREATH, 56 | FX_MODE_COLOR_WIPE, 57 | FX_MODE_COLOR_WIPE_INV, 58 | FX_MODE_COLOR_WIPE_REV, 59 | FX_MODE_COLOR_WIPE_REV_INV, 60 | FX_MODE_COLOR_WIPE_RANDOM, 61 | FX_MODE_COLOR_SWEEP_RANDOM, 62 | FX_MODE_RANDOM_COLOR, 63 | FX_MODE_SINGLE_DYNAMIC, 64 | FX_MODE_MULTI_DYNAMIC, 65 | FX_MODE_RAINBOW, 66 | FX_MODE_RAINBOW_CYCLE, 67 | FX_MODE_FADE, 68 | FX_MODE_SCAN, 69 | FX_MODE_DUAL_SCAN, 70 | FX_MODE_THEATER_CHASE, 71 | FX_MODE_THEATER_CHASE_RAINBOW, 72 | FX_MODE_RUNNING_LIGHTS, 73 | FX_MODE_TWINKLE, 74 | FX_MODE_TWINKLE_RANDOM, 75 | FX_MODE_TWINKLE_FADE, 76 | FX_MODE_TWINKLE_FADE_RANDOM, 77 | FX_MODE_SPARKLE, 78 | FX_MODE_FLASH_SPARKLE, 79 | FX_MODE_HYPER_SPARKLE, 80 | FX_MODE_MULTI_STROBE, 81 | FX_MODE_CHASE_WHITE, 82 | FX_MODE_CHASE_COLOR, 83 | FX_MODE_CHASE_RANDOM, 84 | FX_MODE_CHASE_RAINBOW, 85 | FX_MODE_CHASE_FLASH, 86 | FX_MODE_CHASE_FLASH_RANDOM, 87 | FX_MODE_CHASE_RAINBOW_WHITE, 88 | FX_MODE_CHASE_BLACKOUT, 89 | FX_MODE_CHASE_BLACKOUT_RAINBOW, 90 | FX_MODE_RUNNING_COLOR, 91 | FX_MODE_RUNNING_RED_BLUE, 92 | FX_MODE_RUNNING_RANDOM, 93 | FX_MODE_LARSON_SCANNER, 94 | FX_MODE_COMET, 95 | FX_MODE_FIREWORKS, 96 | FX_MODE_FIREWORKS_RANDOM, 97 | FX_MODE_MERRY_CHRISTMAS, 98 | FX_MODE_FIRE_FLICKER, 99 | FX_MODE_FIRE_FLICKER_SOFT, 100 | FX_MODE_FIRE_FLICKER_INTENSE, 101 | FX_MODE_CIRCUS_COMBUSTUS, 102 | FX_MODE_HALLOWEEN, 103 | FX_MODE_BICOLOR_CHASE, 104 | FX_MODE_TRICOLOR_CHASE, 105 | FX_MODE_ICU, 106 | } fx_mode; 107 | 108 | FX_STATUS WS2812BFX_Init(uint16_t Segments); 109 | FX_STATUS WS2812BFX_SegmentIncrease(void); 110 | FX_STATUS WS2812BFX_SegmentDecrease(void); 111 | uint8_t WS2812BFX_GetSegmentsQuantity(void); 112 | 113 | void WS2812BFX_SysTickCallback(void); 114 | void WS2812BFX_Callback(void); 115 | 116 | FX_STATUS WS2812BFX_Start(uint16_t Segment); 117 | FX_STATUS WS2812BFX_Stop(uint16_t Segment); 118 | FX_STATUS WS2812BFX_IsRunning(uint16_t Segment, uint8_t *Running); 119 | 120 | FX_STATUS WS2812BFX_SetMode(uint16_t Segment, fx_mode Mode); 121 | FX_STATUS WS2812BFX_GetMode(uint16_t Segment, fx_mode *Mode); 122 | FX_STATUS WS2812BFX_NextMode(uint16_t Segment); 123 | FX_STATUS WS2812BFX_PrevMode(uint16_t Segment); 124 | FX_STATUS WS2812BFX_SetReverse(uint16_t Segment, uint8_t Reverse); 125 | FX_STATUS WS2812BFX_GetReverse(uint16_t Segment, uint8_t *Reverse); 126 | 127 | FX_STATUS WS2812BFX_SetSegmentSize(uint16_t Segment, uint16_t Start, uint16_t Stop); 128 | FX_STATUS WS2812BFX_GetSegmentSize(uint16_t Segment, uint16_t *Start, uint16_t *Stop); 129 | FX_STATUS WS2812BFX_SegmentIncreaseEnd(uint16_t Segment); 130 | FX_STATUS WS2812BFX_SegmentDecreaseEnd(uint16_t Segment); 131 | FX_STATUS WS2812BFX_SegmentIncreaseStart(uint16_t Segment); 132 | FX_STATUS WS2812BFX_SegmentDecreaseStart(uint16_t Segment); 133 | 134 | FX_STATUS WS2812BFX_SetSpeed(uint16_t Segment, uint16_t Speed); 135 | FX_STATUS WS2812BFX_GetSpeed(uint16_t Segment, uint16_t *Speed); 136 | FX_STATUS WS2812BFX_IncreaseSpeed(uint16_t Segment, uint16_t Speed); 137 | FX_STATUS WS2812BFX_DecreaseSpeed(uint16_t Segment, uint16_t Speed); 138 | 139 | void WS2812BFX_SetColorStruct(uint8_t id, ws2812b_color c); 140 | void WS2812BFX_SetColorRGB(uint8_t id, uint8_t r, uint8_t g, uint8_t b); 141 | FX_STATUS WS2812BFX_GetColorRGB(uint8_t id, uint8_t *r, uint8_t *g, uint8_t *b); 142 | void WS2812BFX_SetColorHSV(uint8_t id, uint16_t h, uint8_t s, uint8_t v); 143 | void WS2812BFX_SetColor(uint8_t id, uint32_t c); 144 | 145 | FX_STATUS WS2812BFX_SetAll(uint16_t Segment, uint32_t c); 146 | FX_STATUS WS2812BFX_SetAllRGB(uint16_t Segment, uint8_t r, uint8_t g, uint8_t b); 147 | 148 | void WS2812BFX_RGBtoHSV(uint8_t r, uint8_t g, uint8_t b, uint16_t *h, uint8_t *s, uint8_t *v); 149 | void WS2812BFX_HSVtoRGB(uint16_t h, uint8_t s, uint8_t v, uint8_t *r, uint8_t *g, uint8_t *b); 150 | 151 | #endif /* WS2812B_FX_H_ */ 152 | -------------------------------------------------------------------------------- /STM32F103C8Tx_FLASH.ld: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file LinkerScript.ld 4 | * @author Auto-generated by STM32CubeIDE 5 | * @brief Linker script for STM32F103C8Tx Device from STM32F1 series 6 | * 64Kbytes FLASH 7 | * 20Kbytes RAM 8 | * 9 | * Set heap size, stack size and stack location according 10 | * to application requirements. 11 | * 12 | * Set memory bank area and size if external memory is used 13 | ****************************************************************************** 14 | * @attention 15 | * 16 | *

© Copyright (c) 2020 STMicroelectronics. 17 | * All rights reserved.

18 | * 19 | * This software component is licensed by ST under BSD 3-Clause license, 20 | * the "License"; You may not use this file except in compliance with the 21 | * License. You may obtain a copy of the License at: 22 | * opensource.org/licenses/BSD-3-Clause 23 | * 24 | ****************************************************************************** 25 | */ 26 | 27 | /* Entry Point */ 28 | ENTRY(Reset_Handler) 29 | 30 | /* Highest address of the user mode stack */ 31 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ 32 | 33 | _Min_Heap_Size = 0x200 ; /* required amount of heap */ 34 | _Min_Stack_Size = 0x400 ; /* required amount of stack */ 35 | 36 | /* Memories definition */ 37 | MEMORY 38 | { 39 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K 40 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 64K 41 | } 42 | 43 | /* Sections */ 44 | SECTIONS 45 | { 46 | /* The startup code into "FLASH" Rom type memory */ 47 | .isr_vector : 48 | { 49 | . = ALIGN(4); 50 | KEEP(*(.isr_vector)) /* Startup code */ 51 | . = ALIGN(4); 52 | } >FLASH 53 | 54 | /* The program code and other data into "FLASH" Rom type memory */ 55 | .text : 56 | { 57 | . = ALIGN(4); 58 | *(.text) /* .text sections (code) */ 59 | *(.text*) /* .text* sections (code) */ 60 | *(.glue_7) /* glue arm to thumb code */ 61 | *(.glue_7t) /* glue thumb to arm code */ 62 | *(.eh_frame) 63 | 64 | KEEP (*(.init)) 65 | KEEP (*(.fini)) 66 | 67 | . = ALIGN(4); 68 | _etext = .; /* define a global symbols at end of code */ 69 | } >FLASH 70 | 71 | /* Constant data into "FLASH" Rom type memory */ 72 | .rodata : 73 | { 74 | . = ALIGN(4); 75 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 76 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 77 | . = ALIGN(4); 78 | } >FLASH 79 | 80 | .ARM.extab : { 81 | . = ALIGN(4); 82 | *(.ARM.extab* .gnu.linkonce.armextab.*) 83 | . = ALIGN(4); 84 | } >FLASH 85 | 86 | .ARM : { 87 | . = ALIGN(4); 88 | __exidx_start = .; 89 | *(.ARM.exidx*) 90 | __exidx_end = .; 91 | . = ALIGN(4); 92 | } >FLASH 93 | 94 | .preinit_array : 95 | { 96 | . = ALIGN(4); 97 | PROVIDE_HIDDEN (__preinit_array_start = .); 98 | KEEP (*(.preinit_array*)) 99 | PROVIDE_HIDDEN (__preinit_array_end = .); 100 | . = ALIGN(4); 101 | } >FLASH 102 | 103 | .init_array : 104 | { 105 | . = ALIGN(4); 106 | PROVIDE_HIDDEN (__init_array_start = .); 107 | KEEP (*(SORT(.init_array.*))) 108 | KEEP (*(.init_array*)) 109 | PROVIDE_HIDDEN (__init_array_end = .); 110 | . = ALIGN(4); 111 | } >FLASH 112 | 113 | .fini_array : 114 | { 115 | . = ALIGN(4); 116 | PROVIDE_HIDDEN (__fini_array_start = .); 117 | KEEP (*(SORT(.fini_array.*))) 118 | KEEP (*(.fini_array*)) 119 | PROVIDE_HIDDEN (__fini_array_end = .); 120 | . = ALIGN(4); 121 | } >FLASH 122 | 123 | /* Used by the startup to initialize data */ 124 | _sidata = LOADADDR(.data); 125 | 126 | /* Initialized data sections into "RAM" Ram type memory */ 127 | .data : 128 | { 129 | . = ALIGN(4); 130 | _sdata = .; /* create a global symbol at data start */ 131 | *(.data) /* .data sections */ 132 | *(.data*) /* .data* sections */ 133 | 134 | . = ALIGN(4); 135 | _edata = .; /* define a global symbol at data end */ 136 | 137 | } >RAM AT> FLASH 138 | 139 | /* Uninitialized data section into "RAM" Ram type memory */ 140 | . = ALIGN(4); 141 | .bss : 142 | { 143 | /* This is used by the startup in order to initialize the .bss section */ 144 | _sbss = .; /* define a global symbol at bss start */ 145 | __bss_start__ = _sbss; 146 | *(.bss) 147 | *(.bss*) 148 | *(COMMON) 149 | 150 | . = ALIGN(4); 151 | _ebss = .; /* define a global symbol at bss end */ 152 | __bss_end__ = _ebss; 153 | } >RAM 154 | 155 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ 156 | ._user_heap_stack : 157 | { 158 | . = ALIGN(8); 159 | PROVIDE ( end = . ); 160 | PROVIDE ( _end = . ); 161 | . = . + _Min_Heap_Size; 162 | . = . + _Min_Stack_Size; 163 | . = ALIGN(8); 164 | } >RAM 165 | 166 | /* Remove information from the compiler libraries */ 167 | /DISCARD/ : 168 | { 169 | libc.a ( * ) 170 | libm.a ( * ) 171 | libgcc.a ( * ) 172 | } 173 | 174 | .ARM.attributes 0 : { *(.ARM.attributes) } 175 | } 176 | -------------------------------------------------------------------------------- /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, uint16_t len) 89 | { 90 | /* Set EP0 State */ 91 | pdev->ep0_state = USBD_EP0_DATA_IN; 92 | pdev->ep_in[0].total_length = len; 93 | pdev->ep_in[0].rem_length = len; 94 | 95 | /* Start the transfer */ 96 | USBD_LL_Transmit(pdev, 0x00U, pbuf, len); 97 | 98 | return USBD_OK; 99 | } 100 | 101 | /** 102 | * @brief USBD_CtlContinueSendData 103 | * continue sending data on the ctl pipe 104 | * @param pdev: device instance 105 | * @param buff: pointer to data buffer 106 | * @param len: length of data to be sent 107 | * @retval status 108 | */ 109 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, 110 | uint8_t *pbuf, uint16_t len) 111 | { 112 | /* Start the next transfer */ 113 | USBD_LL_Transmit(pdev, 0x00U, pbuf, len); 114 | 115 | return USBD_OK; 116 | } 117 | 118 | /** 119 | * @brief USBD_CtlPrepareRx 120 | * receive data on the ctl pipe 121 | * @param pdev: device instance 122 | * @param buff: pointer to data buffer 123 | * @param len: length of data to be received 124 | * @retval status 125 | */ 126 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev, 127 | uint8_t *pbuf, uint16_t len) 128 | { 129 | /* Set EP0 State */ 130 | pdev->ep0_state = USBD_EP0_DATA_OUT; 131 | pdev->ep_out[0].total_length = len; 132 | pdev->ep_out[0].rem_length = len; 133 | 134 | /* Start the transfer */ 135 | USBD_LL_PrepareReceive(pdev, 0U, pbuf, len); 136 | 137 | return USBD_OK; 138 | } 139 | 140 | /** 141 | * @brief USBD_CtlContinueRx 142 | * continue receive data on the ctl pipe 143 | * @param pdev: device instance 144 | * @param buff: pointer to data buffer 145 | * @param len: length of data to be received 146 | * @retval status 147 | */ 148 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev, 149 | uint8_t *pbuf, uint16_t len) 150 | { 151 | USBD_LL_PrepareReceive(pdev, 0U, pbuf, len); 152 | 153 | return USBD_OK; 154 | } 155 | 156 | /** 157 | * @brief USBD_CtlSendStatus 158 | * send zero lzngth packet on the ctl pipe 159 | * @param pdev: device instance 160 | * @retval status 161 | */ 162 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev) 163 | { 164 | /* Set EP0 State */ 165 | pdev->ep0_state = USBD_EP0_STATUS_IN; 166 | 167 | /* Start the transfer */ 168 | USBD_LL_Transmit(pdev, 0x00U, NULL, 0U); 169 | 170 | return USBD_OK; 171 | } 172 | 173 | /** 174 | * @brief USBD_CtlReceiveStatus 175 | * receive zero lzngth packet on the ctl pipe 176 | * @param pdev: device instance 177 | * @retval status 178 | */ 179 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev) 180 | { 181 | /* Set EP0 State */ 182 | pdev->ep0_state = USBD_EP0_STATUS_OUT; 183 | 184 | /* Start the transfer */ 185 | USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U); 186 | 187 | return USBD_OK; 188 | } 189 | 190 | /** 191 | * @brief USBD_GetRxCount 192 | * returns the received data length 193 | * @param pdev: device instance 194 | * @param ep_addr: endpoint address 195 | * @retval Rx Data blength 196 | */ 197 | uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr) 198 | { 199 | return USBD_LL_GetRxDataSize(pdev, ep_addr); 200 | } 201 | 202 | /** 203 | * @} 204 | */ 205 | 206 | 207 | /** 208 | * @} 209 | */ 210 | 211 | 212 | /** 213 | * @} 214 | */ 215 | 216 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 217 | -------------------------------------------------------------------------------- /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 | USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, 117 | uint8_t ep_addr, 118 | uint8_t ep_type, 119 | uint16_t ep_mps); 120 | 121 | USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 122 | USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 123 | USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 124 | USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 125 | uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 126 | USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr); 127 | USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, 128 | uint8_t ep_addr, 129 | uint8_t *pbuf, 130 | uint16_t size); 131 | 132 | USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, 133 | uint8_t ep_addr, 134 | uint8_t *pbuf, 135 | uint16_t size); 136 | 137 | uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 138 | void USBD_LL_Delay(uint32_t Delay); 139 | 140 | /** 141 | * @} 142 | */ 143 | 144 | #ifdef __cplusplus 145 | } 146 | #endif 147 | 148 | #endif /* __USBD_CORE_H */ 149 | 150 | /** 151 | * @} 152 | */ 153 | 154 | /** 155 | * @} 156 | */ 157 | 158 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /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 | /*---------------------------------------------------------------------*/ 69 | /* CDC definitions */ 70 | /*---------------------------------------------------------------------*/ 71 | #define CDC_SEND_ENCAPSULATED_COMMAND 0x00U 72 | #define CDC_GET_ENCAPSULATED_RESPONSE 0x01U 73 | #define CDC_SET_COMM_FEATURE 0x02U 74 | #define CDC_GET_COMM_FEATURE 0x03U 75 | #define CDC_CLEAR_COMM_FEATURE 0x04U 76 | #define CDC_SET_LINE_CODING 0x20U 77 | #define CDC_GET_LINE_CODING 0x21U 78 | #define CDC_SET_CONTROL_LINE_STATE 0x22U 79 | #define CDC_SEND_BREAK 0x23U 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | 86 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 87 | * @{ 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | typedef struct 94 | { 95 | uint32_t bitrate; 96 | uint8_t format; 97 | uint8_t paritytype; 98 | uint8_t datatype; 99 | } USBD_CDC_LineCodingTypeDef; 100 | 101 | typedef struct _USBD_CDC_Itf 102 | { 103 | int8_t (* Init)(void); 104 | int8_t (* DeInit)(void); 105 | int8_t (* Control)(uint8_t cmd, uint8_t *pbuf, uint16_t length); 106 | int8_t (* Receive)(uint8_t *Buf, uint32_t *Len); 107 | 108 | } USBD_CDC_ItfTypeDef; 109 | 110 | 111 | typedef struct 112 | { 113 | uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32bits alignment */ 114 | uint8_t CmdOpCode; 115 | uint8_t CmdLength; 116 | uint8_t *RxBuffer; 117 | uint8_t *TxBuffer; 118 | uint32_t RxLength; 119 | uint32_t TxLength; 120 | 121 | __IO uint32_t TxState; 122 | __IO uint32_t RxState; 123 | } 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, 153 | uint8_t *pbuff, 154 | uint16_t length); 155 | 156 | uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, 157 | uint8_t *pbuff); 158 | 159 | uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev); 160 | 161 | uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev); 162 | /** 163 | * @} 164 | */ 165 | 166 | #ifdef __cplusplus 167 | } 168 | #endif 169 | 170 | #endif /* __USB_CDC_H */ 171 | /** 172 | * @} 173 | */ 174 | 175 | /** 176 | * @} 177 | */ 178 | 179 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 180 | -------------------------------------------------------------------------------- /WS2812B_C8.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | Dma.Request0=SPI1_TX 3 | Dma.RequestsNb=1 4 | Dma.SPI1_TX.0.Direction=DMA_MEMORY_TO_PERIPH 5 | Dma.SPI1_TX.0.Instance=DMA1_Channel3 6 | Dma.SPI1_TX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE 7 | Dma.SPI1_TX.0.MemInc=DMA_MINC_ENABLE 8 | Dma.SPI1_TX.0.Mode=DMA_CIRCULAR 9 | Dma.SPI1_TX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE 10 | Dma.SPI1_TX.0.PeriphInc=DMA_PINC_DISABLE 11 | Dma.SPI1_TX.0.Priority=DMA_PRIORITY_VERY_HIGH 12 | Dma.SPI1_TX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority 13 | File.Version=6 14 | KeepUserPlacement=false 15 | Mcu.Family=STM32F1 16 | Mcu.IP0=DMA 17 | Mcu.IP1=NVIC 18 | Mcu.IP2=RCC 19 | Mcu.IP3=SPI1 20 | Mcu.IP4=SYS 21 | Mcu.IP5=USB 22 | Mcu.IP6=USB_DEVICE 23 | Mcu.IPNb=7 24 | Mcu.Name=STM32F103C(8-B)Tx 25 | Mcu.Package=LQFP48 26 | Mcu.Pin0=PC13-TAMPER-RTC 27 | Mcu.Pin1=PD0-OSC_IN 28 | Mcu.Pin10=VP_SYS_VS_Systick 29 | Mcu.Pin11=VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS 30 | Mcu.Pin2=PD1-OSC_OUT 31 | Mcu.Pin3=PA0-WKUP 32 | Mcu.Pin4=PA5 33 | Mcu.Pin5=PA7 34 | Mcu.Pin6=PA11 35 | Mcu.Pin7=PA12 36 | Mcu.Pin8=PA13 37 | Mcu.Pin9=PA14 38 | Mcu.PinsNb=12 39 | Mcu.ThirdPartyNb=0 40 | Mcu.UserConstants= 41 | Mcu.UserName=STM32F103C8Tx 42 | MxCube.Version=5.6.0 43 | MxDb.Version=DB.5.0.60 44 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 45 | NVIC.DMA1_Channel3_IRQn=true\:1\:0\:true\:false\:true\:false\:true 46 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false 47 | NVIC.ForceEnableDMAVector=true 48 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 49 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false 50 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false 51 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false 52 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 53 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false 54 | NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true 55 | NVIC.USB_LP_CAN1_RX0_IRQn=true\:0\:0\:false\:false\:true\:false\:true 56 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 57 | PA0-WKUP.GPIOParameters=GPIO_Label 58 | PA0-WKUP.GPIO_Label=TEST 59 | PA0-WKUP.Locked=true 60 | PA0-WKUP.Signal=GPIO_Output 61 | PA11.Mode=Device 62 | PA11.Signal=USB_DM 63 | PA12.Mode=Device 64 | PA12.Signal=USB_DP 65 | PA13.Mode=Serial_Wire 66 | PA13.Signal=SYS_JTMS-SWDIO 67 | PA14.Mode=Serial_Wire 68 | PA14.Signal=SYS_JTCK-SWCLK 69 | PA5.Mode=TX_Only_Simplex_Unidirect_Master 70 | PA5.Signal=SPI1_SCK 71 | PA7.Mode=TX_Only_Simplex_Unidirect_Master 72 | PA7.Signal=SPI1_MOSI 73 | PC13-TAMPER-RTC.GPIOParameters=GPIO_Label 74 | PC13-TAMPER-RTC.GPIO_Label=LED 75 | PC13-TAMPER-RTC.Locked=true 76 | PC13-TAMPER-RTC.Signal=GPIO_Output 77 | PD0-OSC_IN.Mode=HSE-External-Oscillator 78 | PD0-OSC_IN.Signal=RCC_OSC_IN 79 | PD1-OSC_OUT.Mode=HSE-External-Oscillator 80 | PD1-OSC_OUT.Signal=RCC_OSC_OUT 81 | PinOutPanel.RotationAngle=0 82 | ProjectManager.AskForMigrate=true 83 | ProjectManager.BackupPrevious=false 84 | ProjectManager.CompilerOptimize=6 85 | ProjectManager.ComputerToolchain=false 86 | ProjectManager.CoupleFile=true 87 | ProjectManager.CustomerFirmwarePackage= 88 | ProjectManager.DefaultFWLocation=true 89 | ProjectManager.DeletePrevious=true 90 | ProjectManager.DeviceId=STM32F103C8Tx 91 | ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.8.0 92 | ProjectManager.FreePins=false 93 | ProjectManager.HalAssertFull=false 94 | ProjectManager.HeapSize=0x200 95 | ProjectManager.KeepUserCode=true 96 | ProjectManager.LastFirmware=true 97 | ProjectManager.LibraryCopy=1 98 | ProjectManager.MainLocation=Core/Src 99 | ProjectManager.NoMain=false 100 | ProjectManager.PreviousToolchain= 101 | ProjectManager.ProjectBuild=false 102 | ProjectManager.ProjectFileName=WS2812B_C8.ioc 103 | ProjectManager.ProjectName=WS2812B_C8 104 | ProjectManager.StackSize=0x400 105 | ProjectManager.TargetToolchain=STM32CubeIDE 106 | ProjectManager.ToolChainLocation= 107 | ProjectManager.UnderRoot=true 108 | ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_SPI1_Init-SPI1-false-HAL-true,5-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false 109 | RCC.ADCFreqValue=24000000 110 | RCC.AHBFreq_Value=48000000 111 | RCC.APB1CLKDivider=RCC_HCLK_DIV2 112 | RCC.APB1Freq_Value=24000000 113 | RCC.APB1TimFreq_Value=48000000 114 | RCC.APB2Freq_Value=48000000 115 | RCC.APB2TimFreq_Value=48000000 116 | RCC.FCLKCortexFreq_Value=48000000 117 | RCC.FamilyName=M 118 | RCC.HCLKFreq_Value=48000000 119 | RCC.IPParameters=ADCFreqValue,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,MCOFreq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,PLLMUL,PLLSourceVirtual,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,USBFreq_Value,VCOOutput2Freq_Value 120 | RCC.MCOFreq_Value=48000000 121 | RCC.PLLCLKFreq_Value=48000000 122 | RCC.PLLMCOFreq_Value=24000000 123 | RCC.PLLMUL=RCC_PLL_MUL6 124 | RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE 125 | RCC.SYSCLKFreq_VALUE=48000000 126 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK 127 | RCC.TimSysFreq_Value=48000000 128 | RCC.USBFreq_Value=48000000 129 | RCC.VCOOutput2Freq_Value=8000000 130 | SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_8 131 | SPI1.CalculateBaudRate=6.0 MBits/s 132 | SPI1.Direction=SPI_DIRECTION_2LINES 133 | SPI1.IPParameters=VirtualType,Mode,Direction,BaudRatePrescaler,CalculateBaudRate 134 | SPI1.Mode=SPI_MODE_MASTER 135 | SPI1.VirtualType=VM_MASTER 136 | USB_DEVICE.CLASS_NAME_FS=CDC 137 | USB_DEVICE.IPParameters=VirtualMode,VirtualModeFS,CLASS_NAME_FS 138 | USB_DEVICE.VirtualMode=Cdc 139 | USB_DEVICE.VirtualModeFS=Cdc_FS 140 | VP_SYS_VS_Systick.Mode=SysTick 141 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 142 | VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Mode=CDC_FS 143 | VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Signal=USB_DEVICE_VS_USB_DEVICE_CDC_FS 144 | board=custom 145 | isbadioc=false 146 | -------------------------------------------------------------------------------- /WS2812B_C8 Debug.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /Core/Src/stm32f1xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f1xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

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

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | #include "stm32f1xx_it.h" 24 | /* Private includes ----------------------------------------------------------*/ 25 | /* USER CODE BEGIN Includes */ 26 | /* USER CODE END Includes */ 27 | 28 | /* Private typedef -----------------------------------------------------------*/ 29 | /* USER CODE BEGIN TD */ 30 | 31 | /* USER CODE END TD */ 32 | 33 | /* Private define ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN PD */ 35 | 36 | /* USER CODE END PD */ 37 | 38 | /* Private macro -------------------------------------------------------------*/ 39 | /* USER CODE BEGIN PM */ 40 | 41 | /* USER CODE END PM */ 42 | 43 | /* Private variables ---------------------------------------------------------*/ 44 | /* USER CODE BEGIN PV */ 45 | 46 | /* USER CODE END PV */ 47 | 48 | /* Private function prototypes -----------------------------------------------*/ 49 | /* USER CODE BEGIN PFP */ 50 | 51 | /* USER CODE END PFP */ 52 | 53 | /* Private user code ---------------------------------------------------------*/ 54 | /* USER CODE BEGIN 0 */ 55 | 56 | /* USER CODE END 0 */ 57 | 58 | /* External variables --------------------------------------------------------*/ 59 | extern PCD_HandleTypeDef hpcd_USB_FS; 60 | extern DMA_HandleTypeDef hdma_spi1_tx; 61 | /* USER CODE BEGIN EV */ 62 | 63 | /* USER CODE END EV */ 64 | 65 | /******************************************************************************/ 66 | /* Cortex-M3 Processor Interruption and Exception Handlers */ 67 | /******************************************************************************/ 68 | /** 69 | * @brief This function handles Non maskable interrupt. 70 | */ 71 | void NMI_Handler(void) 72 | { 73 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 74 | 75 | /* USER CODE END NonMaskableInt_IRQn 0 */ 76 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 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 | HAL_SYSTICK_Callback(); 191 | /* USER CODE END SysTick_IRQn 1 */ 192 | } 193 | 194 | /******************************************************************************/ 195 | /* STM32F1xx 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_stm32f1xx.s). */ 199 | /******************************************************************************/ 200 | 201 | /** 202 | * @brief This function handles DMA1 channel3 global interrupt. 203 | */ 204 | void DMA1_Channel3_IRQHandler(void) 205 | { 206 | /* USER CODE BEGIN DMA1_Channel3_IRQn 0 */ 207 | 208 | /* USER CODE END DMA1_Channel3_IRQn 0 */ 209 | HAL_DMA_IRQHandler(&hdma_spi1_tx); 210 | /* USER CODE BEGIN DMA1_Channel3_IRQn 1 */ 211 | 212 | /* USER CODE END DMA1_Channel3_IRQn 1 */ 213 | } 214 | 215 | /** 216 | * @brief This function handles USB low priority or CAN RX0 interrupts. 217 | */ 218 | void USB_LP_CAN1_RX0_IRQHandler(void) 219 | { 220 | /* USER CODE BEGIN USB_LP_CAN1_RX0_IRQn 0 */ 221 | 222 | /* USER CODE END USB_LP_CAN1_RX0_IRQn 0 */ 223 | HAL_PCD_IRQHandler(&hpcd_USB_FS); 224 | /* USER CODE BEGIN USB_LP_CAN1_RX0_IRQn 1 */ 225 | 226 | /* USER CODE END USB_LP_CAN1_RX0_IRQn 1 */ 227 | } 228 | 229 | /* USER CODE BEGIN 1 */ 230 | 231 | /* USER CODE END 1 */ 232 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 233 | -------------------------------------------------------------------------------- /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) 2020 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | #include "dma.h" 24 | #include "spi.h" 25 | #include "usb_device.h" 26 | #include "gpio.h" 27 | 28 | /* Private includes ----------------------------------------------------------*/ 29 | /* USER CODE BEGIN Includes */ 30 | #include 31 | #include "ws2812b.h" 32 | #include "ws2812b_fx.h" 33 | #include "usb_parsing.h" 34 | /* USER CODE END Includes */ 35 | 36 | /* Private typedef -----------------------------------------------------------*/ 37 | /* USER CODE BEGIN PTD */ 38 | 39 | /* USER CODE END PTD */ 40 | 41 | /* Private define ------------------------------------------------------------*/ 42 | /* USER CODE BEGIN PD */ 43 | /* USER CODE END PD */ 44 | 45 | /* Private macro -------------------------------------------------------------*/ 46 | /* USER CODE BEGIN PM */ 47 | 48 | /* USER CODE END PM */ 49 | 50 | /* Private variables ---------------------------------------------------------*/ 51 | 52 | /* USER CODE BEGIN PV */ 53 | 54 | /* USER CODE END PV */ 55 | 56 | /* Private function prototypes -----------------------------------------------*/ 57 | void SystemClock_Config(void); 58 | /* USER CODE BEGIN PFP */ 59 | 60 | /* USER CODE END PFP */ 61 | 62 | /* Private user code ---------------------------------------------------------*/ 63 | /* USER CODE BEGIN 0 */ 64 | void USB_Parsing(void); 65 | /* USER CODE END 0 */ 66 | 67 | /** 68 | * @brief The application entry point. 69 | * @retval int 70 | */ 71 | int main(void) 72 | { 73 | /* USER CODE BEGIN 1 */ 74 | 75 | /* USER CODE END 1 */ 76 | 77 | /* MCU Configuration--------------------------------------------------------*/ 78 | 79 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 80 | HAL_Init(); 81 | 82 | /* USER CODE BEGIN Init */ 83 | 84 | /* USER CODE END Init */ 85 | 86 | /* Configure the system clock */ 87 | SystemClock_Config(); 88 | 89 | /* USER CODE BEGIN SysInit */ 90 | 91 | /* USER CODE END SysInit */ 92 | 93 | /* Initialize all configured peripherals */ 94 | MX_GPIO_Init(); 95 | MX_DMA_Init(); 96 | MX_SPI1_Init(); 97 | MX_USB_DEVICE_Init(); 98 | /* USER CODE BEGIN 2 */ 99 | WS2812B_Init(&hspi1); 100 | 101 | WS2812BFX_Init(3); // Start 3 segments 102 | 103 | WS2812BFX_SetSpeed(0, 5000); // Speed of segment 0 104 | WS2812BFX_SetSpeed(1, 2000); // Speed of segment 1 105 | WS2812BFX_SetSpeed(2, 500); // Speed of segment 2 106 | WS2812BFX_SetColorRGB(0, 32,0,64); // Set color 0 107 | WS2812BFX_SetColorRGB(1, 32,0,0); // Set color 1 108 | WS2812BFX_SetColorRGB(2, 0,64,0); // Set color 2 109 | WS2812BFX_SetMode(0, FX_MODE_WHITE_TO_COLOR); // Set mode segment 0 110 | 111 | WS2812BFX_SetColorRGB(0, 16,64,0); 112 | WS2812BFX_SetColorRGB(1, 0,32,64); 113 | WS2812BFX_SetColorRGB(2, 64,0,0); 114 | WS2812BFX_SetMode(1, FX_MODE_BLACK_TO_COLOR); // Set mode segment 1 115 | 116 | WS2812BFX_SetColorRGB(0, 16,64,0); 117 | WS2812BFX_SetColorRGB(1, 0,32,64); 118 | WS2812BFX_SetColorRGB(2, 64,0,0); 119 | WS2812BFX_SetMode(2, FX_MODE_COLOR_WIPE); // Set mode segment 2 120 | 121 | WS2812BFX_Start(0); // Start segment 0 122 | WS2812BFX_Start(1); // Start segment 1 123 | WS2812BFX_Start(2); // Start segment 2 124 | HAL_Delay(200); 125 | /* USER CODE END 2 */ 126 | 127 | /* Infinite loop */ 128 | /* USER CODE BEGIN WHILE */ 129 | while (1) 130 | { 131 | WS2812BFX_Callback(); // FX effects calllback 132 | 133 | USB_Parsing(); // USB communication parsing 134 | /* USER CODE END WHILE */ 135 | 136 | /* USER CODE BEGIN 3 */ 137 | } 138 | /* USER CODE END 3 */ 139 | } 140 | 141 | /** 142 | * @brief System Clock Configuration 143 | * @retval None 144 | */ 145 | void SystemClock_Config(void) 146 | { 147 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; 148 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; 149 | RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; 150 | 151 | /** Initializes the CPU, AHB and APB busses clocks 152 | */ 153 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; 154 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; 155 | RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; 156 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; 157 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 158 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; 159 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6; 160 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 161 | { 162 | Error_Handler(); 163 | } 164 | /** Initializes the CPU, AHB and APB busses clocks 165 | */ 166 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 167 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; 168 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 169 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 170 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; 171 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; 172 | 173 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) 174 | { 175 | Error_Handler(); 176 | } 177 | PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; 178 | PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL; 179 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) 180 | { 181 | Error_Handler(); 182 | } 183 | } 184 | 185 | /* USER CODE BEGIN 4 */ 186 | void HAL_SYSTICK_Callback(void) 187 | { 188 | WS2812BFX_SysTickCallback(); // FX effects software timers 189 | } 190 | /* USER CODE END 4 */ 191 | 192 | /** 193 | * @brief This function is executed in case of error occurrence. 194 | * @retval None 195 | */ 196 | void Error_Handler(void) 197 | { 198 | /* USER CODE BEGIN Error_Handler_Debug */ 199 | /* User can add his own implementation to report the HAL error return state */ 200 | 201 | /* USER CODE END Error_Handler_Debug */ 202 | } 203 | 204 | #ifdef USE_FULL_ASSERT 205 | /** 206 | * @brief Reports the name of the source file and the source line number 207 | * where the assert_param error has occurred. 208 | * @param file: pointer to the source file name 209 | * @param line: assert_param error line source number 210 | * @retval None 211 | */ 212 | void assert_failed(uint8_t *file, uint32_t line) 213 | { 214 | /* USER CODE BEGIN 6 */ 215 | /* User can add his own implementation to report the file name and line number, 216 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 217 | /* USER CODE END 6 */ 218 | } 219 | #endif /* USE_FULL_ASSERT */ 220 | 221 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 222 | -------------------------------------------------------------------------------- /Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_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 component is licensed by ST under BSD 3-Clause license, 14 | * the "License"; You may not use this file except in compliance with the 15 | * License. You may obtain a copy of the License at: 16 | * opensource.org/licenses/BSD-3-Clause 17 | * 18 | ****************************************************************************** 19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F1xx_HAL_DEF 23 | #define __STM32F1xx_HAL_DEF 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32f1xx.h" 31 | #if defined(USE_HAL_LEGACY) 32 | #include "Legacy/stm32_hal_legacy.h" 33 | #endif 34 | #include 35 | 36 | /* Exported types ------------------------------------------------------------*/ 37 | 38 | /** 39 | * @brief HAL Status structures definition 40 | */ 41 | typedef enum 42 | { 43 | HAL_OK = 0x00U, 44 | HAL_ERROR = 0x01U, 45 | HAL_BUSY = 0x02U, 46 | HAL_TIMEOUT = 0x03U 47 | } HAL_StatusTypeDef; 48 | 49 | /** 50 | * @brief HAL Lock structures definition 51 | */ 52 | typedef enum 53 | { 54 | HAL_UNLOCKED = 0x00U, 55 | HAL_LOCKED = 0x01U 56 | } HAL_LockTypeDef; 57 | 58 | /* Exported macro ------------------------------------------------------------*/ 59 | #define HAL_MAX_DELAY 0xFFFFFFFFU 60 | 61 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != 0U) 62 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U) 63 | 64 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ 65 | do{ \ 66 | (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ 67 | (__DMA_HANDLE__).Parent = (__HANDLE__); \ 68 | } while(0U) 69 | 70 | #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */ 71 | 72 | /** @brief Reset the Handle's State field. 73 | * @param __HANDLE__ specifies the Peripheral Handle. 74 | * @note This macro can be used for the following purpose: 75 | * - When the Handle is declared as local variable; before passing it as parameter 76 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro 77 | * to set to 0 the Handle's "State" field. 78 | * Otherwise, "State" field may have any random value and the first time the function 79 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed 80 | * (i.e. HAL_PPP_MspInit() will not be executed). 81 | * - When there is a need to reconfigure the low level hardware: instead of calling 82 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). 83 | * In this later function, when the Handle's "State" field is set to 0, it will execute the function 84 | * HAL_PPP_MspInit() which will reconfigure the low level hardware. 85 | * @retval None 86 | */ 87 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U) 88 | 89 | #if (USE_RTOS == 1U) 90 | /* Reserved for future use */ 91 | #error "USE_RTOS should be 0 in the current HAL release" 92 | #else 93 | #define __HAL_LOCK(__HANDLE__) \ 94 | do{ \ 95 | if((__HANDLE__)->Lock == HAL_LOCKED) \ 96 | { \ 97 | return HAL_BUSY; \ 98 | } \ 99 | else \ 100 | { \ 101 | (__HANDLE__)->Lock = HAL_LOCKED; \ 102 | } \ 103 | }while (0U) 104 | 105 | #define __HAL_UNLOCK(__HANDLE__) \ 106 | do{ \ 107 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ 108 | }while (0U) 109 | #endif /* USE_RTOS */ 110 | 111 | #if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ 112 | #ifndef __weak 113 | #define __weak __attribute__((weak)) 114 | #endif /* __weak */ 115 | #ifndef __packed 116 | #define __packed __attribute__((__packed__)) 117 | #endif /* __packed */ 118 | #endif /* __GNUC__ */ 119 | 120 | 121 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ 122 | #if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ 123 | #ifndef __ALIGN_END 124 | #define __ALIGN_END __attribute__ ((aligned (4))) 125 | #endif /* __ALIGN_END */ 126 | #ifndef __ALIGN_BEGIN 127 | #define __ALIGN_BEGIN 128 | #endif /* __ALIGN_BEGIN */ 129 | #else 130 | #ifndef __ALIGN_END 131 | #define __ALIGN_END 132 | #endif /* __ALIGN_END */ 133 | #ifndef __ALIGN_BEGIN 134 | #if defined (__CC_ARM) /* ARM Compiler */ 135 | #define __ALIGN_BEGIN __align(4) 136 | #elif defined (__ICCARM__) /* IAR Compiler */ 137 | #define __ALIGN_BEGIN 138 | #endif /* __CC_ARM */ 139 | #endif /* __ALIGN_BEGIN */ 140 | #endif /* __GNUC__ */ 141 | 142 | 143 | /** 144 | * @brief __RAM_FUNC definition 145 | */ 146 | #if defined ( __CC_ARM ) 147 | /* ARM Compiler 148 | ------------ 149 | RAM functions are defined using the toolchain options. 150 | Functions that are executed in RAM should reside in a separate source module. 151 | Using the 'Options for File' dialog you can simply change the 'Code / Const' 152 | area of a module to a memory space in physical RAM. 153 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' 154 | dialog. 155 | */ 156 | #define __RAM_FUNC 157 | 158 | #elif defined ( __ICCARM__ ) 159 | /* ICCARM Compiler 160 | --------------- 161 | RAM functions are defined using a specific toolchain keyword "__ramfunc". 162 | */ 163 | #define __RAM_FUNC __ramfunc 164 | 165 | #elif defined ( __GNUC__ ) 166 | /* GNU Compiler 167 | ------------ 168 | RAM functions are defined using a specific toolchain attribute 169 | "__attribute__((section(".RamFunc")))". 170 | */ 171 | #define __RAM_FUNC __attribute__((section(".RamFunc"))) 172 | 173 | #endif 174 | 175 | /** 176 | * @brief __NOINLINE definition 177 | */ 178 | #if defined ( __CC_ARM ) || defined ( __GNUC__ ) 179 | /* ARM & GNUCompiler 180 | ---------------- 181 | */ 182 | #define __NOINLINE __attribute__ ( (noinline) ) 183 | 184 | #elif defined ( __ICCARM__ ) 185 | /* ICCARM Compiler 186 | --------------- 187 | */ 188 | #define __NOINLINE _Pragma("optimize = no_inline") 189 | 190 | #endif 191 | 192 | #ifdef __cplusplus 193 | } 194 | #endif 195 | 196 | #endif /* ___STM32F1xx_HAL_DEF */ 197 | 198 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 199 | -------------------------------------------------------------------------------- /Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_pcd_ex.c 4 | * @author MCD Application Team 5 | * @brief PCD Extended HAL module driver. 6 | * This file provides firmware functions to manage the following 7 | * functionalities of the USB Peripheral Controller: 8 | * + Extended features functions 9 | * 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | *

© Copyright (c) 2016 STMicroelectronics. 14 | * All rights reserved.

15 | * 16 | * This software component is licensed by ST under BSD 3-Clause license, 17 | * the "License"; You may not use this file except in compliance with the 18 | * License. You may obtain a copy of the License at: 19 | * opensource.org/licenses/BSD-3-Clause 20 | * 21 | ****************************************************************************** 22 | */ 23 | 24 | /* Includes ------------------------------------------------------------------*/ 25 | #include "stm32f1xx_hal.h" 26 | 27 | /** @addtogroup STM32F1xx_HAL_Driver 28 | * @{ 29 | */ 30 | 31 | /** @defgroup PCDEx PCDEx 32 | * @brief PCD Extended HAL module driver 33 | * @{ 34 | */ 35 | 36 | #ifdef HAL_PCD_MODULE_ENABLED 37 | 38 | #if defined (USB) || defined (USB_OTG_FS) 39 | /* Private types -------------------------------------------------------------*/ 40 | /* Private variables ---------------------------------------------------------*/ 41 | /* Private constants ---------------------------------------------------------*/ 42 | /* Private macros ------------------------------------------------------------*/ 43 | /* Private functions ---------------------------------------------------------*/ 44 | /* Exported functions --------------------------------------------------------*/ 45 | 46 | /** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions 47 | * @{ 48 | */ 49 | 50 | /** @defgroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 51 | * @brief PCDEx control functions 52 | * 53 | @verbatim 54 | =============================================================================== 55 | ##### Extended features functions ##### 56 | =============================================================================== 57 | [..] This section provides functions allowing to: 58 | (+) Update FIFO configuration 59 | 60 | @endverbatim 61 | * @{ 62 | */ 63 | #if defined (USB_OTG_FS) 64 | /** 65 | * @brief Set Tx FIFO 66 | * @param hpcd PCD handle 67 | * @param fifo The number of Tx fifo 68 | * @param size Fifo size 69 | * @retval HAL status 70 | */ 71 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size) 72 | { 73 | uint8_t i; 74 | uint32_t Tx_Offset; 75 | 76 | /* TXn min size = 16 words. (n : Transmit FIFO index) 77 | When a TxFIFO is not used, the Configuration should be as follows: 78 | case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes) 79 | --> Txm can use the space allocated for Txn. 80 | case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes) 81 | --> Txn should be configured with the minimum space of 16 words 82 | The FIFO is used optimally when used TxFIFOs are allocated in the top 83 | of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones. 84 | When DMA is used 3n * FIFO locations should be reserved for internal DMA registers */ 85 | 86 | Tx_Offset = hpcd->Instance->GRXFSIZ; 87 | 88 | if (fifo == 0U) 89 | { 90 | hpcd->Instance->DIEPTXF0_HNPTXFSIZ = ((uint32_t)size << 16) | Tx_Offset; 91 | } 92 | else 93 | { 94 | Tx_Offset += (hpcd->Instance->DIEPTXF0_HNPTXFSIZ) >> 16; 95 | for (i = 0U; i < (fifo - 1U); i++) 96 | { 97 | Tx_Offset += (hpcd->Instance->DIEPTXF[i] >> 16); 98 | } 99 | 100 | /* Multiply Tx_Size by 2 to get higher performance */ 101 | hpcd->Instance->DIEPTXF[fifo - 1U] = ((uint32_t)size << 16) | Tx_Offset; 102 | } 103 | 104 | return HAL_OK; 105 | } 106 | 107 | /** 108 | * @brief Set Rx FIFO 109 | * @param hpcd PCD handle 110 | * @param size Size of Rx fifo 111 | * @retval HAL status 112 | */ 113 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size) 114 | { 115 | hpcd->Instance->GRXFSIZ = size; 116 | 117 | return HAL_OK; 118 | } 119 | #endif /* defined (USB_OTG_FS) */ 120 | #if defined (USB) 121 | /** 122 | * @brief Configure PMA for EP 123 | * @param hpcd Device instance 124 | * @param ep_addr endpoint address 125 | * @param ep_kind endpoint Kind 126 | * USB_SNG_BUF: Single Buffer used 127 | * USB_DBL_BUF: Double Buffer used 128 | * @param pmaadress: EP address in The PMA: In case of single buffer endpoint 129 | * this parameter is 16-bit value providing the address 130 | * in PMA allocated to endpoint. 131 | * In case of double buffer endpoint this parameter 132 | * is a 32-bit value providing the endpoint buffer 0 address 133 | * in the LSB part of 32-bit value and endpoint buffer 1 address 134 | * in the MSB part of 32-bit value. 135 | * @retval HAL status 136 | */ 137 | 138 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, 139 | uint16_t ep_addr, 140 | uint16_t ep_kind, 141 | uint32_t pmaadress) 142 | { 143 | PCD_EPTypeDef *ep; 144 | 145 | /* initialize ep structure*/ 146 | if ((0x80U & ep_addr) == 0x80U) 147 | { 148 | ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK]; 149 | } 150 | else 151 | { 152 | ep = &hpcd->OUT_ep[ep_addr]; 153 | } 154 | 155 | /* Here we check if the endpoint is single or double Buffer*/ 156 | if (ep_kind == PCD_SNG_BUF) 157 | { 158 | /* Single Buffer */ 159 | ep->doublebuffer = 0U; 160 | /* Configure the PMA */ 161 | ep->pmaadress = (uint16_t)pmaadress; 162 | } 163 | else /* USB_DBL_BUF */ 164 | { 165 | /* Double Buffer Endpoint */ 166 | ep->doublebuffer = 1U; 167 | /* Configure the PMA */ 168 | ep->pmaaddr0 = (uint16_t)(pmaadress & 0xFFFFU); 169 | ep->pmaaddr1 = (uint16_t)((pmaadress & 0xFFFF0000U) >> 16); 170 | } 171 | 172 | return HAL_OK; 173 | } 174 | 175 | /** 176 | * @brief Software Device Connection, 177 | * this function is not required by USB OTG FS peripheral, it is used 178 | * only by USB Device FS peripheral. 179 | * @param hpcd: PCD handle 180 | * @param state: connection state (0 : disconnected / 1: connected) 181 | * @retval None 182 | */ 183 | __weak void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state) 184 | { 185 | /* Prevent unused argument(s) compilation warning */ 186 | UNUSED(hpcd); 187 | UNUSED(state); 188 | /* NOTE : This function Should not be modified, when the callback is needed, 189 | the HAL_PCDEx_SetConnectionState could be implemented in the user file 190 | */ 191 | } 192 | #endif /* defined (USB) */ 193 | 194 | /** 195 | * @brief Send LPM message to user layer callback. 196 | * @param hpcd PCD handle 197 | * @param msg LPM message 198 | * @retval HAL status 199 | */ 200 | __weak void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg) 201 | { 202 | /* Prevent unused argument(s) compilation warning */ 203 | UNUSED(hpcd); 204 | UNUSED(msg); 205 | 206 | /* NOTE : This function should not be modified, when the callback is needed, 207 | the HAL_PCDEx_LPM_Callback could be implemented in the user file 208 | */ 209 | } 210 | 211 | /** 212 | * @brief Send BatteryCharging message to user layer callback. 213 | * @param hpcd PCD handle 214 | * @param msg LPM message 215 | * @retval HAL status 216 | */ 217 | __weak void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg) 218 | { 219 | /* Prevent unused argument(s) compilation warning */ 220 | UNUSED(hpcd); 221 | UNUSED(msg); 222 | 223 | /* NOTE : This function should not be modified, when the callback is needed, 224 | the HAL_PCDEx_BCD_Callback could be implemented in the user file 225 | */ 226 | } 227 | 228 | /** 229 | * @} 230 | */ 231 | 232 | /** 233 | * @} 234 | */ 235 | #endif /* defined (USB) || defined (USB_OTG_FS) */ 236 | #endif /* HAL_PCD_MODULE_ENABLED */ 237 | 238 | /** 239 | * @} 240 | */ 241 | 242 | /** 243 | * @} 244 | */ 245 | 246 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 247 | -------------------------------------------------------------------------------- /Core/Src/ws2812b.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ws2812b.c 3 | * 4 | * The MIT License. 5 | * Created on: 14.07.2017 6 | * Author: Mateusz Salamon 7 | * www.msalamon.pl 8 | * mateusz@msalamon.pl 9 | */ 10 | 11 | #include "stm32f1xx_hal.h" 12 | #include "spi.h" 13 | #include "dma.h" 14 | #include "gpio.h" 15 | #include "math.h" 16 | 17 | #include "ws2812b.h" 18 | 19 | #define zero 0b11000000 20 | #define one 0b11111000 21 | 22 | SPI_HandleTypeDef *hspi_ws2812b; 23 | ws2812b_color ws2812b_array[WS2812B_LEDS]; 24 | 25 | static uint8_t buffer[48]; 26 | static uint16_t CurrentLed; 27 | static uint8_t ResetSignal; 28 | 29 | void WS2812B_Init(SPI_HandleTypeDef * spi_handler) 30 | { 31 | hspi_ws2812b = spi_handler; 32 | } 33 | 34 | void WS2812B_SetDiodeColor(int16_t diode_id, uint32_t color) 35 | { 36 | if(diode_id >= WS2812B_LEDS || diode_id < 0) return; 37 | ws2812b_array[diode_id].red = ((color>>16)&0x000000FF); 38 | ws2812b_array[diode_id].green = ((color>>8)&0x000000FF); 39 | ws2812b_array[diode_id].blue = (color&0x000000FF); 40 | } 41 | 42 | void WS2812B_SetDiodeColorStruct(int16_t diode_id, ws2812b_color color) 43 | { 44 | if(diode_id >= WS2812B_LEDS || diode_id < 0) return; 45 | ws2812b_array[diode_id] = color; 46 | } 47 | 48 | void WS2812B_SetDiodeRGB(int16_t diode_id, uint8_t R, uint8_t G, uint8_t B) 49 | { 50 | if(diode_id >= WS2812B_LEDS || diode_id < 0) return; 51 | ws2812b_array[diode_id].red = R; 52 | ws2812b_array[diode_id].green = G; 53 | ws2812b_array[diode_id].blue = B; 54 | } 55 | 56 | uint32_t WS2812B_GetColor(int16_t diode_id) 57 | { 58 | uint32_t color = 0; 59 | color |= ((ws2812b_array[diode_id].red&0xFF)<<16); 60 | color |= ((ws2812b_array[diode_id].green&0xFF)<<8); 61 | color |= (ws2812b_array[diode_id].blue&0xFF); 62 | return color; 63 | } 64 | 65 | uint8_t* WS2812B_GetPixels(void) 66 | { 67 | return (uint8_t*)ws2812b_array; 68 | } 69 | // 70 | // Set diode with HSV model 71 | // 72 | // Hue 0-359 73 | // Saturation 0-255 74 | // Birghtness(Value) 0-255 75 | // 76 | void WS2812B_SetDiodeHSV(int16_t diode_id, uint16_t Hue, uint8_t Saturation, uint8_t Brightness) 77 | { 78 | if(diode_id >= WS2812B_LEDS || diode_id < 0) return; 79 | uint16_t Sector, Fracts, p, q, t; 80 | 81 | if(Saturation == 0) 82 | { 83 | ws2812b_array[diode_id].red = Brightness; 84 | ws2812b_array[diode_id].green = Brightness; 85 | ws2812b_array[diode_id]. blue = Brightness; 86 | } 87 | else 88 | { 89 | if(Hue >= 360) Hue = 359; 90 | 91 | Sector = Hue / 60; // Sector 0 to 5 92 | Fracts = Hue % 60; 93 | p = (Brightness * (255 - Saturation)) / 256; 94 | q = (Brightness * (255 - (Saturation * Fracts)/60)) / 256; 95 | t = (Brightness * (255 - (Saturation * (59 - Fracts))/60)) / 256; 96 | 97 | 98 | switch(Sector) 99 | { 100 | case 0: 101 | ws2812b_array[diode_id].red = Brightness; 102 | ws2812b_array[diode_id].green = (uint8_t)t; 103 | ws2812b_array[diode_id]. blue = (uint8_t)p; 104 | break; 105 | case 1: 106 | ws2812b_array[diode_id].red = (uint8_t)q; 107 | ws2812b_array[diode_id].green = Brightness; 108 | ws2812b_array[diode_id]. blue = (uint8_t)p; 109 | break; 110 | case 2: 111 | ws2812b_array[diode_id].red = (uint8_t)p; 112 | ws2812b_array[diode_id].green = Brightness; 113 | ws2812b_array[diode_id]. blue = (uint8_t)t; 114 | break; 115 | case 3: 116 | ws2812b_array[diode_id].red = (uint8_t)p; 117 | ws2812b_array[diode_id].green = (uint8_t)q; 118 | ws2812b_array[diode_id]. blue = Brightness; 119 | break; 120 | case 4: 121 | ws2812b_array[diode_id].red = (uint8_t)t; 122 | ws2812b_array[diode_id].green = (uint8_t)p; 123 | ws2812b_array[diode_id]. blue = Brightness; 124 | break; 125 | default: // case 5: 126 | ws2812b_array[diode_id].red = Brightness; 127 | ws2812b_array[diode_id].green = (uint8_t)p; 128 | ws2812b_array[diode_id]. blue = (uint8_t)q; 129 | break; 130 | } 131 | } 132 | } 133 | 134 | void WS2812B_Refresh() 135 | { 136 | CurrentLed = 0; 137 | ResetSignal = 0; 138 | 139 | for(uint8_t i = 0; i < 48; i++) 140 | buffer[i] = 0x00; 141 | HAL_SPI_Transmit_DMA(hspi_ws2812b, buffer, 48); // Additional 3 for reset signal 142 | while(HAL_DMA_STATE_READY != HAL_DMA_GetState(hspi_ws2812b->hdmatx)); 143 | 144 | } 145 | 146 | void HAL_SPI_TxHalfCpltCallback(SPI_HandleTypeDef *hspi) 147 | { 148 | if(hspi == hspi_ws2812b) 149 | { 150 | if(!ResetSignal) 151 | { 152 | for(uint8_t k = 0; k < 24; k++) // To 72 impulses of reset 153 | { 154 | buffer[k] = 0x00; 155 | } 156 | ResetSignal = 1; // End reset signal 157 | } 158 | else // LEDs Odd 1,3,5,7... 159 | { 160 | if(CurrentLed > WS2812B_LEDS) 161 | { 162 | HAL_SPI_DMAStop(hspi_ws2812b); 163 | } 164 | else 165 | { 166 | uint8_t j = 0; 167 | //GREEN 168 | for(int8_t k=7; k>=0; k--) 169 | { 170 | if((ws2812b_array[CurrentLed].green & (1<=0; k--) 179 | { 180 | if((ws2812b_array[CurrentLed].red & (1<=0; k--) 189 | { 190 | if((ws2812b_array[CurrentLed].blue & (1< WS2812B_LEDS) 207 | { 208 | HAL_SPI_DMAStop(hspi_ws2812b); 209 | } 210 | else 211 | { 212 | // Even LEDs 0,2,0 213 | uint8_t j = 24; 214 | //GREEN 215 | for(int8_t k=7; k>=0; k--) 216 | { 217 | if((ws2812b_array[CurrentLed].green & (1<=0; k--) 226 | { 227 | if((ws2812b_array[CurrentLed].red & (1<=0; k--) 236 | { 237 | if((ws2812b_array[CurrentLed].blue & (1< 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 (armclang) 39 | */ 40 | #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 41 | #include "cmsis_armclang.h" 42 | 43 | 44 | /* 45 | * GNU Compiler 46 | */ 47 | #elif defined ( __GNUC__ ) 48 | #include "cmsis_gcc.h" 49 | 50 | 51 | /* 52 | * IAR Compiler 53 | */ 54 | #elif defined ( __ICCARM__ ) 55 | #include 56 | 57 | 58 | /* 59 | * TI Arm Compiler 60 | */ 61 | #elif defined ( __TI_ARM__ ) 62 | #include 63 | 64 | #ifndef __ASM 65 | #define __ASM __asm 66 | #endif 67 | #ifndef __INLINE 68 | #define __INLINE inline 69 | #endif 70 | #ifndef __STATIC_INLINE 71 | #define __STATIC_INLINE static inline 72 | #endif 73 | #ifndef __STATIC_FORCEINLINE 74 | #define __STATIC_FORCEINLINE __STATIC_INLINE 75 | #endif 76 | #ifndef __NO_RETURN 77 | #define __NO_RETURN __attribute__((noreturn)) 78 | #endif 79 | #ifndef __USED 80 | #define __USED __attribute__((used)) 81 | #endif 82 | #ifndef __WEAK 83 | #define __WEAK __attribute__((weak)) 84 | #endif 85 | #ifndef __PACKED 86 | #define __PACKED __attribute__((packed)) 87 | #endif 88 | #ifndef __PACKED_STRUCT 89 | #define __PACKED_STRUCT struct __attribute__((packed)) 90 | #endif 91 | #ifndef __PACKED_UNION 92 | #define __PACKED_UNION union __attribute__((packed)) 93 | #endif 94 | #ifndef __UNALIGNED_UINT32 /* deprecated */ 95 | struct __attribute__((packed)) T_UINT32 { uint32_t v; }; 96 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 97 | #endif 98 | #ifndef __UNALIGNED_UINT16_WRITE 99 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 100 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val)) 101 | #endif 102 | #ifndef __UNALIGNED_UINT16_READ 103 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 104 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 105 | #endif 106 | #ifndef __UNALIGNED_UINT32_WRITE 107 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 108 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 109 | #endif 110 | #ifndef __UNALIGNED_UINT32_READ 111 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 112 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 113 | #endif 114 | #ifndef __ALIGNED 115 | #define __ALIGNED(x) __attribute__((aligned(x))) 116 | #endif 117 | #ifndef __RESTRICT 118 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 119 | #define __RESTRICT 120 | #endif 121 | 122 | 123 | /* 124 | * TASKING Compiler 125 | */ 126 | #elif defined ( __TASKING__ ) 127 | /* 128 | * The CMSIS functions have been implemented as intrinsics in the compiler. 129 | * Please use "carm -?i" to get an up to date list of all intrinsics, 130 | * Including the CMSIS ones. 131 | */ 132 | 133 | #ifndef __ASM 134 | #define __ASM __asm 135 | #endif 136 | #ifndef __INLINE 137 | #define __INLINE inline 138 | #endif 139 | #ifndef __STATIC_INLINE 140 | #define __STATIC_INLINE static inline 141 | #endif 142 | #ifndef __STATIC_FORCEINLINE 143 | #define __STATIC_FORCEINLINE __STATIC_INLINE 144 | #endif 145 | #ifndef __NO_RETURN 146 | #define __NO_RETURN __attribute__((noreturn)) 147 | #endif 148 | #ifndef __USED 149 | #define __USED __attribute__((used)) 150 | #endif 151 | #ifndef __WEAK 152 | #define __WEAK __attribute__((weak)) 153 | #endif 154 | #ifndef __PACKED 155 | #define __PACKED __packed__ 156 | #endif 157 | #ifndef __PACKED_STRUCT 158 | #define __PACKED_STRUCT struct __packed__ 159 | #endif 160 | #ifndef __PACKED_UNION 161 | #define __PACKED_UNION union __packed__ 162 | #endif 163 | #ifndef __UNALIGNED_UINT32 /* deprecated */ 164 | struct __packed__ T_UINT32 { uint32_t v; }; 165 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 166 | #endif 167 | #ifndef __UNALIGNED_UINT16_WRITE 168 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 169 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) 170 | #endif 171 | #ifndef __UNALIGNED_UINT16_READ 172 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 173 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 174 | #endif 175 | #ifndef __UNALIGNED_UINT32_WRITE 176 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 177 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 178 | #endif 179 | #ifndef __UNALIGNED_UINT32_READ 180 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 181 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 182 | #endif 183 | #ifndef __ALIGNED 184 | #define __ALIGNED(x) __align(x) 185 | #endif 186 | #ifndef __RESTRICT 187 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 188 | #define __RESTRICT 189 | #endif 190 | 191 | 192 | /* 193 | * COSMIC Compiler 194 | */ 195 | #elif defined ( __CSMC__ ) 196 | #include 197 | 198 | #ifndef __ASM 199 | #define __ASM _asm 200 | #endif 201 | #ifndef __INLINE 202 | #define __INLINE inline 203 | #endif 204 | #ifndef __STATIC_INLINE 205 | #define __STATIC_INLINE static inline 206 | #endif 207 | #ifndef __STATIC_FORCEINLINE 208 | #define __STATIC_FORCEINLINE __STATIC_INLINE 209 | #endif 210 | #ifndef __NO_RETURN 211 | // NO RETURN is automatically detected hence no warning here 212 | #define __NO_RETURN 213 | #endif 214 | #ifndef __USED 215 | #warning No compiler specific solution for __USED. __USED is ignored. 216 | #define __USED 217 | #endif 218 | #ifndef __WEAK 219 | #define __WEAK __weak 220 | #endif 221 | #ifndef __PACKED 222 | #define __PACKED @packed 223 | #endif 224 | #ifndef __PACKED_STRUCT 225 | #define __PACKED_STRUCT @packed struct 226 | #endif 227 | #ifndef __PACKED_UNION 228 | #define __PACKED_UNION @packed union 229 | #endif 230 | #ifndef __UNALIGNED_UINT32 /* deprecated */ 231 | @packed struct T_UINT32 { uint32_t v; }; 232 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 233 | #endif 234 | #ifndef __UNALIGNED_UINT16_WRITE 235 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 236 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) 237 | #endif 238 | #ifndef __UNALIGNED_UINT16_READ 239 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 240 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 241 | #endif 242 | #ifndef __UNALIGNED_UINT32_WRITE 243 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 244 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 245 | #endif 246 | #ifndef __UNALIGNED_UINT32_READ 247 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 248 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 249 | #endif 250 | #ifndef __ALIGNED 251 | #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored. 252 | #define __ALIGNED(x) 253 | #endif 254 | #ifndef __RESTRICT 255 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 256 | #define __RESTRICT 257 | #endif 258 | 259 | 260 | #else 261 | #error Unknown compiler. 262 | #endif 263 | 264 | 265 | #endif /* __CMSIS_COMPILER_H */ 266 | 267 | -------------------------------------------------------------------------------- /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) 2020 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under Ultimate Liberty license 14 | * SLA0044, the "License"; You may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at: 16 | * www.st.com/SLA0044 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "usbd_cdc_if.h" 24 | 25 | /* USER CODE BEGIN INCLUDE */ 26 | 27 | /* USER CODE END INCLUDE */ 28 | 29 | /* Private typedef -----------------------------------------------------------*/ 30 | /* Private define ------------------------------------------------------------*/ 31 | /* Private macro -------------------------------------------------------------*/ 32 | 33 | /* USER CODE BEGIN PV */ 34 | /* Private variables ---------------------------------------------------------*/ 35 | 36 | /* USER CODE END PV */ 37 | 38 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 39 | * @brief Usb device library. 40 | * @{ 41 | */ 42 | 43 | /** @addtogroup USBD_CDC_IF 44 | * @{ 45 | */ 46 | 47 | /** @defgroup USBD_CDC_IF_Private_TypesDefinitions USBD_CDC_IF_Private_TypesDefinitions 48 | * @brief Private types. 49 | * @{ 50 | */ 51 | 52 | /* USER CODE BEGIN PRIVATE_TYPES */ 53 | 54 | /* USER CODE END PRIVATE_TYPES */ 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | /** @defgroup USBD_CDC_IF_Private_Defines USBD_CDC_IF_Private_Defines 61 | * @brief Private defines. 62 | * @{ 63 | */ 64 | 65 | /* USER CODE BEGIN PRIVATE_DEFINES */ 66 | /* Define size for the receive and transmit buffer over CDC */ 67 | /* It's up to user to redefine and/or remove those define */ 68 | #define APP_RX_DATA_SIZE 1000 69 | #define APP_TX_DATA_SIZE 1000 70 | /* USER CODE END PRIVATE_DEFINES */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USBD_CDC_IF_Private_Macros USBD_CDC_IF_Private_Macros 77 | * @brief Private macros. 78 | * @{ 79 | */ 80 | 81 | /* USER CODE BEGIN PRIVATE_MACRO */ 82 | 83 | /* USER CODE END PRIVATE_MACRO */ 84 | 85 | /** 86 | * @} 87 | */ 88 | 89 | /** @defgroup USBD_CDC_IF_Private_Variables USBD_CDC_IF_Private_Variables 90 | * @brief Private variables. 91 | * @{ 92 | */ 93 | /* Create buffer for reception and transmission */ 94 | /* It's up to user to redefine and/or remove those define */ 95 | /** Received data over USB are stored in this buffer */ 96 | uint8_t UserRxBufferFS[APP_RX_DATA_SIZE]; 97 | 98 | /** Data to send over USB CDC are stored in this buffer */ 99 | uint8_t UserTxBufferFS[APP_TX_DATA_SIZE]; 100 | 101 | /* USER CODE BEGIN PRIVATE_VARIABLES */ 102 | 103 | /* USER CODE END PRIVATE_VARIABLES */ 104 | 105 | /** 106 | * @} 107 | */ 108 | 109 | /** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables 110 | * @brief Public variables. 111 | * @{ 112 | */ 113 | 114 | extern USBD_HandleTypeDef hUsbDeviceFS; 115 | 116 | /* USER CODE BEGIN EXPORTED_VARIABLES */ 117 | 118 | /* USER CODE END EXPORTED_VARIABLES */ 119 | 120 | /** 121 | * @} 122 | */ 123 | 124 | /** @defgroup USBD_CDC_IF_Private_FunctionPrototypes USBD_CDC_IF_Private_FunctionPrototypes 125 | * @brief Private functions declaration. 126 | * @{ 127 | */ 128 | 129 | static int8_t CDC_Init_FS(void); 130 | static int8_t CDC_DeInit_FS(void); 131 | static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length); 132 | static int8_t CDC_Receive_FS(uint8_t* pbuf, uint32_t *Len); 133 | 134 | /* USER CODE BEGIN PRIVATE_FUNCTIONS_DECLARATION */ 135 | 136 | /* USER CODE END PRIVATE_FUNCTIONS_DECLARATION */ 137 | 138 | /** 139 | * @} 140 | */ 141 | 142 | USBD_CDC_ItfTypeDef USBD_Interface_fops_FS = 143 | { 144 | CDC_Init_FS, 145 | CDC_DeInit_FS, 146 | CDC_Control_FS, 147 | CDC_Receive_FS 148 | }; 149 | 150 | /* Private functions ---------------------------------------------------------*/ 151 | /** 152 | * @brief Initializes the CDC media low layer over the FS USB IP 153 | * @retval USBD_OK if all operations are OK else USBD_FAIL 154 | */ 155 | static int8_t CDC_Init_FS(void) 156 | { 157 | /* USER CODE BEGIN 3 */ 158 | /* Set Application Buffers */ 159 | USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0); 160 | USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS); 161 | return (USBD_OK); 162 | /* USER CODE END 3 */ 163 | } 164 | 165 | /** 166 | * @brief DeInitializes the CDC media low layer 167 | * @retval USBD_OK if all operations are OK else USBD_FAIL 168 | */ 169 | static int8_t CDC_DeInit_FS(void) 170 | { 171 | /* USER CODE BEGIN 4 */ 172 | return (USBD_OK); 173 | /* USER CODE END 4 */ 174 | } 175 | 176 | /** 177 | * @brief Manage the CDC class requests 178 | * @param cmd: Command code 179 | * @param pbuf: Buffer containing command data (request parameters) 180 | * @param length: Number of data to be sent (in bytes) 181 | * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL 182 | */ 183 | static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) 184 | { 185 | /* USER CODE BEGIN 5 */ 186 | switch(cmd) 187 | { 188 | case CDC_SEND_ENCAPSULATED_COMMAND: 189 | 190 | break; 191 | 192 | case CDC_GET_ENCAPSULATED_RESPONSE: 193 | 194 | break; 195 | 196 | case CDC_SET_COMM_FEATURE: 197 | 198 | break; 199 | 200 | case CDC_GET_COMM_FEATURE: 201 | 202 | break; 203 | 204 | case CDC_CLEAR_COMM_FEATURE: 205 | 206 | break; 207 | 208 | /*******************************************************************************/ 209 | /* Line Coding Structure */ 210 | /*-----------------------------------------------------------------------------*/ 211 | /* Offset | Field | Size | Value | Description */ 212 | /* 0 | dwDTERate | 4 | Number |Data terminal rate, in bits per second*/ 213 | /* 4 | bCharFormat | 1 | Number | Stop bits */ 214 | /* 0 - 1 Stop bit */ 215 | /* 1 - 1.5 Stop bits */ 216 | /* 2 - 2 Stop bits */ 217 | /* 5 | bParityType | 1 | Number | Parity */ 218 | /* 0 - None */ 219 | /* 1 - Odd */ 220 | /* 2 - Even */ 221 | /* 3 - Mark */ 222 | /* 4 - Space */ 223 | /* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */ 224 | /*******************************************************************************/ 225 | case CDC_SET_LINE_CODING: 226 | 227 | break; 228 | 229 | case CDC_GET_LINE_CODING: 230 | 231 | break; 232 | 233 | case CDC_SET_CONTROL_LINE_STATE: 234 | 235 | break; 236 | 237 | case CDC_SEND_BREAK: 238 | 239 | break; 240 | 241 | default: 242 | break; 243 | } 244 | 245 | return (USBD_OK); 246 | /* USER CODE END 5 */ 247 | } 248 | 249 | /** 250 | * @brief Data received over USB OUT endpoint are sent over CDC interface 251 | * through this function. 252 | * 253 | * @note 254 | * This function will block any OUT packet reception on USB endpoint 255 | * untill exiting this function. If you exit this function before transfer 256 | * is complete on CDC interface (ie. using DMA controller) it will result 257 | * in receiving more data while previous ones are still not sent. 258 | * 259 | * @param Buf: Buffer of data to be received 260 | * @param Len: Number of data received (in bytes) 261 | * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL 262 | */ 263 | static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len) 264 | { 265 | /* USER CODE BEGIN 6 */ 266 | USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); 267 | USBD_CDC_ReceivePacket(&hUsbDeviceFS); 268 | return (USBD_OK); 269 | /* USER CODE END 6 */ 270 | } 271 | 272 | /** 273 | * @brief CDC_Transmit_FS 274 | * Data to send over USB IN endpoint are sent over CDC interface 275 | * through this function. 276 | * @note 277 | * 278 | * 279 | * @param Buf: Buffer of data to be sent 280 | * @param Len: Number of data to be sent (in bytes) 281 | * @retval USBD_OK if all operations are OK else USBD_FAIL or USBD_BUSY 282 | */ 283 | uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len) 284 | { 285 | uint8_t result = USBD_OK; 286 | /* USER CODE BEGIN 7 */ 287 | USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData; 288 | if (hcdc->TxState != 0){ 289 | return USBD_BUSY; 290 | } 291 | USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len); 292 | result = USBD_CDC_TransmitPacket(&hUsbDeviceFS); 293 | /* USER CODE END 7 */ 294 | return result; 295 | } 296 | 297 | /* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */ 298 | 299 | /* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */ 300 | 301 | /** 302 | * @} 303 | */ 304 | 305 | /** 306 | * @} 307 | */ 308 | 309 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 310 | -------------------------------------------------------------------------------- /Core/Src/usb_parsing.c: -------------------------------------------------------------------------------- 1 | /* 2 | * usb_parsing.c 3 | * 4 | * The MIT License. 5 | * Created on: 15.11.2018 6 | * Author: Mateusz Salamon 7 | * www.msalamon.pl 8 | * mateusz@msalamon.pl 9 | */ 10 | 11 | #include "stm32f1xx_hal.h" 12 | #include "usbd_cdc_if.h" 13 | #include 14 | #include 15 | 16 | #include "ws2812b.h" 17 | #include "ws2812b_fx.h" 18 | #include "usb_parsing.h" 19 | 20 | uint8_t USBDataRX[50]; // Array for receive USB messages 21 | uint8_t USBReceivedDataFlag; // Received USB data flag 22 | uint8_t USBDataTX[50]; // Array for transmission USB messages 23 | uint8_t USBDataLength; // USB message length 24 | 25 | void UnknownCommand(void) 26 | { 27 | USBDataLength = sprintf((char*)USBDataTX, "Unknown command\n\r"); 28 | } 29 | 30 | void ColorControl(void) 31 | { 32 | char *buf; 33 | int16_t Seg; 34 | uint8_t Color[3]; 35 | 36 | if((buf = strtok((char*)USBDataRX+1, ","))) // Segment number 37 | { 38 | Seg = atoi(buf); 39 | 40 | for(uint8_t i = 0; i < 3; i++) 41 | { 42 | if((buf = strtok(NULL, ","))) // Speed 43 | { 44 | Color[i] = atoi(buf); 45 | } 46 | else 47 | { 48 | USBDataLength = sprintf((char*)USBDataTX, "Color command error\n\r"); 49 | return; 50 | } 51 | } 52 | 53 | WS2812BFX_SetColorRGB(Seg, Color[0], Color[1], Color[2]); 54 | USBDataLength = sprintf((char*)USBDataTX, "ColorID:%d Value:%dR, %dG, %dB\n\r", Seg, Color[0], Color[1], Color[2]); 55 | return; 56 | } 57 | USBDataLength = sprintf((char*)USBDataTX, "Color command error\n\r"); 58 | } 59 | 60 | void SpeedControl(void) 61 | { 62 | char *buf; 63 | int16_t Seg; 64 | uint16_t Speed; 65 | 66 | if((buf = strtok((char*)USBDataRX+1, ","))) // Segment number 67 | { 68 | Seg = atoi(buf); 69 | 70 | if((buf = strtok(NULL, ","))) // Speed 71 | { 72 | if((Speed = atoi(buf)) > 0) 73 | { 74 | WS2812BFX_SetSpeed(Seg, Speed); 75 | USBDataLength = sprintf((char*)USBDataTX, "Segment:%d Speed:%d\n\r", Seg, Speed); 76 | return; 77 | } 78 | } 79 | } 80 | USBDataLength = sprintf((char*)USBDataTX, "Speed command error\n\r"); 81 | } 82 | 83 | void ModeControl(void) 84 | { 85 | char *buf; 86 | int16_t Seg; 87 | int16_t Mode; 88 | 89 | buf = strtok((char*)USBDataRX+1, ","); // Segment number 90 | Seg = atoi(buf); 91 | 92 | if((buf = strtok(NULL, ","))) 93 | { 94 | if(buf[0] == 'S') 95 | { 96 | WS2812BFX_Start(Seg); 97 | USBDataLength = sprintf((char*)USBDataTX, "Segment:%d Start\n\r", Seg); 98 | return; 99 | } 100 | else if(buf[0] == 'T') 101 | { 102 | WS2812BFX_Stop(Seg); 103 | USBDataLength = sprintf((char*)USBDataTX, "Segment:%d Stop\n\r", Seg); 104 | return; 105 | } 106 | else // Mode 107 | { 108 | if((Mode = atoi(buf)) > 0) 109 | { 110 | WS2812BFX_SetMode(Seg, Mode); 111 | 112 | USBDataLength = sprintf((char*)USBDataTX, "Segment:%d Mode:%d\n\r", Seg, Mode); 113 | return; 114 | } 115 | } 116 | } 117 | USBDataLength = sprintf((char*)USBDataTX, "mode command error\n\r"); 118 | } 119 | 120 | void SegmentsControl(void) 121 | { 122 | int16_t Seg; 123 | uint8_t mode_tmp; 124 | if(USBDataRX[1] == '-') 125 | { 126 | WS2812BFX_SegmentDecrease(); 127 | } 128 | else if(USBDataRX[1] == '+') 129 | { 130 | WS2812BFX_SegmentIncrease(); 131 | WS2812BFX_SetMode(WS2812BFX_GetSegmentsQuantity() - 1, rand()%MODE_COUNT); 132 | WS2812BFX_Start(WS2812BFX_GetSegmentsQuantity() - 1); 133 | } 134 | else if((Seg = atoi((char*)(USBDataRX+1))) > 0) 135 | { 136 | WS2812BFX_Init(Seg); 137 | } 138 | else 139 | { 140 | USBDataLength = sprintf((char*)USBDataTX, "Segment command error\n\r"); 141 | return; 142 | } 143 | WS2812BFX_GetMode(WS2812BFX_GetSegmentsQuantity()-1, &mode_tmp); 144 | USBDataLength = sprintf((char*)USBDataTX, "Segments:%d Last mode:%d\n\r", WS2812BFX_GetSegmentsQuantity(), mode_tmp); 145 | } 146 | 147 | void SegmentRangeControl(void) 148 | { 149 | char *buf; 150 | int16_t Seg; 151 | int16_t Start; 152 | int16_t End; 153 | 154 | buf = strtok((char*)USBDataRX+1, ","); // Segment number 155 | Seg = atoi(buf); 156 | 157 | if((buf = strtok(NULL, ","))) 158 | { 159 | if(buf[0] == 'R') // Range (Stanrt and Stop) 160 | { 161 | if((buf = strtok(NULL, ","))) // Speed 162 | { 163 | if((Start = atoi(buf)) > 0) 164 | { 165 | if((buf = strtok(NULL, ","))) // Speed 166 | { 167 | if((End = atoi(buf)) > 0) 168 | { 169 | WS2812BFX_SetSegmentSize(Seg, Start, End); 170 | USBDataLength = sprintf((char*)USBDataTX, "Segment:%d Range:%d - %d\n\r", Seg, Start, End); 171 | return; 172 | } 173 | else 174 | USBDataLength = sprintf((char*)USBDataTX, "Segment range End error\n\r"); 175 | return; 176 | } 177 | } 178 | else 179 | USBDataLength = sprintf((char*)USBDataTX, "Segment range Start error\n\r"); 180 | return; 181 | } 182 | } 183 | else if(buf[0] == 'S') //Start 184 | { 185 | if(buf[1] == '+') 186 | { 187 | WS2812BFX_SegmentIncreaseStart(Seg); 188 | USBDataLength = sprintf((char*)USBDataTX, "Segment:%d Start increase\n\r", Seg); 189 | return; 190 | } 191 | if(buf[1] == '-') 192 | { 193 | WS2812BFX_SegmentDecreaseStart(Seg); 194 | USBDataLength = sprintf((char*)USBDataTX, "Segment:%d Start decrease\n\r", Seg); 195 | return; 196 | } 197 | 198 | } 199 | else if(buf[0] == 'E') //END 200 | { 201 | if(buf[1] == '+') 202 | { 203 | WS2812BFX_SegmentIncreaseEnd(Seg); 204 | USBDataLength = sprintf((char*)USBDataTX, "Segment:%d End increase\n\r", Seg); 205 | return; 206 | } 207 | if(buf[1] == '-') 208 | { 209 | WS2812BFX_SegmentDecreaseEnd(Seg); 210 | USBDataLength = sprintf((char*)USBDataTX, "Segment:%d End decrease\n\r", Seg); 211 | return; 212 | } 213 | } 214 | } 215 | USBDataLength = sprintf((char*)USBDataTX, "Segment range command error\n\r"); 216 | } 217 | 218 | void PrintHelp(void) 219 | { 220 | 221 | USBDataLength = sprintf((char*)USBDataTX, "\033[2J\033[0;0H"); 222 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 223 | USBDataLength = sprintf((char*)USBDataTX, "==============HELP=============\n\r"); 224 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 225 | USBDataLength = sprintf((char*)USBDataTX, "Change Segments quantity:\n\r"); 226 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 227 | USBDataLength = sprintf((char*)USBDataTX, " 'Sx' Set x segments(1 - LEDs/2)\n\r"); 228 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 229 | USBDataLength = sprintf((char*)USBDataTX, " 'S+' add one segment\n\r"); 230 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 231 | USBDataLength = sprintf((char*)USBDataTX, " 'S-' remove one segment\n\r"); 232 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 233 | USBDataLength = sprintf((char*)USBDataTX, "Change Segments length:\n\r"); 234 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 235 | USBDataLength = sprintf((char*)USBDataTX, " 'Rx,S+' Increase start point x "); 236 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 237 | USBDataLength = sprintf((char*)USBDataTX, "segment\n\r"); 238 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 239 | USBDataLength = sprintf((char*)USBDataTX, " 'Rx,S-' Decrease start point x "); 240 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 241 | USBDataLength = sprintf((char*)USBDataTX, "segment\n\r"); 242 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 243 | USBDataLength = sprintf((char*)USBDataTX, " 'Rx,E+' Increase end point x "); 244 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 245 | USBDataLength = sprintf((char*)USBDataTX, "segment\n\r"); 246 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 247 | USBDataLength = sprintf((char*)USBDataTX, " 'Rx,E-' Decrease end point x "); 248 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 249 | USBDataLength = sprintf((char*)USBDataTX, "segment\n\r"); 250 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 251 | USBDataLength = sprintf((char*)USBDataTX, " 'Rx,R,y,z' Set start(y) and stop(z) po"); 252 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 253 | USBDataLength = sprintf((char*)USBDataTX, "int x segment\n\r"); 254 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 255 | USBDataLength = sprintf((char*)USBDataTX, "Change segment's mode:\n\r"); 256 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 257 | USBDataLength = sprintf((char*)USBDataTX, " 'Mx,S' Start segment x\n\r"); 258 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 259 | USBDataLength = sprintf((char*)USBDataTX, " 'Mx,T' Stop segment x\n\r"); 260 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 261 | USBDataLength = sprintf((char*)USBDataTX, " 'Mx,y' Set y mode for x segment\n\r"); 262 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 263 | USBDataLength = sprintf((char*)USBDataTX, "Change segment's speed:\n\r"); 264 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 265 | USBDataLength = sprintf((char*)USBDataTX, " 'Vx,y' Set y speed for x segment\n\r"); 266 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 267 | USBDataLength = sprintf((char*)USBDataTX, "Set color:\n\r"); 268 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 269 | USBDataLength = sprintf((char*)USBDataTX, " 'Cx,r,g,b' x - ColorID, rgb values\n\r"); 270 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 271 | USBDataLength = sprintf((char*)USBDataTX, "===============================\n\r"); 272 | while(USBD_BUSY == CDC_Transmit_FS(USBDataTX, USBDataLength)); 273 | } 274 | 275 | void USB_Parsing(void) 276 | { 277 | if(USBReceivedDataFlag == 1) 278 | { 279 | USBReceivedDataFlag = 0; 280 | 281 | switch (USBDataRX[0]) 282 | { 283 | case 'C': 284 | ColorControl(); 285 | break; 286 | 287 | case 'V': 288 | SpeedControl(); 289 | break; 290 | 291 | case 'M': 292 | ModeControl(); 293 | break; 294 | 295 | case 'S': 296 | SegmentsControl(); 297 | break; 298 | 299 | case 'R': 300 | SegmentRangeControl(); 301 | break; 302 | 303 | case 'H': 304 | PrintHelp(); 305 | break; 306 | default: 307 | UnknownCommand(); 308 | break; 309 | } 310 | 311 | CDC_Transmit_FS(USBDataTX, USBDataLength); // Send confirmation message 312 | } 313 | } 314 | -------------------------------------------------------------------------------- /Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_flash.h 4 | * @author MCD Application Team 5 | * @brief Header file of Flash HAL module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

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

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32F1xx_HAL_FLASH_H 22 | #define __STM32F1xx_HAL_FLASH_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f1xx_hal_def.h" 30 | 31 | /** @addtogroup STM32F1xx_HAL_Driver 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup FLASH 36 | * @{ 37 | */ 38 | 39 | /** @addtogroup FLASH_Private_Constants 40 | * @{ 41 | */ 42 | #define FLASH_TIMEOUT_VALUE 50000U /* 50 s */ 43 | /** 44 | * @} 45 | */ 46 | 47 | /** @addtogroup FLASH_Private_Macros 48 | * @{ 49 | */ 50 | 51 | #define IS_FLASH_TYPEPROGRAM(VALUE) (((VALUE) == FLASH_TYPEPROGRAM_HALFWORD) || \ 52 | ((VALUE) == FLASH_TYPEPROGRAM_WORD) || \ 53 | ((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD)) 54 | 55 | #if defined(FLASH_ACR_LATENCY) 56 | #define IS_FLASH_LATENCY(__LATENCY__) (((__LATENCY__) == FLASH_LATENCY_0) || \ 57 | ((__LATENCY__) == FLASH_LATENCY_1) || \ 58 | ((__LATENCY__) == FLASH_LATENCY_2)) 59 | 60 | #else 61 | #define IS_FLASH_LATENCY(__LATENCY__) ((__LATENCY__) == FLASH_LATENCY_0) 62 | #endif /* FLASH_ACR_LATENCY */ 63 | /** 64 | * @} 65 | */ 66 | 67 | /* Exported types ------------------------------------------------------------*/ 68 | /** @defgroup FLASH_Exported_Types FLASH Exported Types 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @brief FLASH Procedure structure definition 74 | */ 75 | typedef enum 76 | { 77 | FLASH_PROC_NONE = 0U, 78 | FLASH_PROC_PAGEERASE = 1U, 79 | FLASH_PROC_MASSERASE = 2U, 80 | FLASH_PROC_PROGRAMHALFWORD = 3U, 81 | FLASH_PROC_PROGRAMWORD = 4U, 82 | FLASH_PROC_PROGRAMDOUBLEWORD = 5U 83 | } FLASH_ProcedureTypeDef; 84 | 85 | /** 86 | * @brief FLASH handle Structure definition 87 | */ 88 | typedef struct 89 | { 90 | __IO FLASH_ProcedureTypeDef ProcedureOnGoing; /*!< Internal variable to indicate which procedure is ongoing or not in IT context */ 91 | 92 | __IO uint32_t DataRemaining; /*!< Internal variable to save the remaining pages to erase or half-word to program in IT context */ 93 | 94 | __IO uint32_t Address; /*!< Internal variable to save address selected for program or erase */ 95 | 96 | __IO uint64_t Data; /*!< Internal variable to save data to be programmed */ 97 | 98 | HAL_LockTypeDef Lock; /*!< FLASH locking object */ 99 | 100 | __IO uint32_t ErrorCode; /*!< FLASH error code 101 | This parameter can be a value of @ref FLASH_Error_Codes */ 102 | } FLASH_ProcessTypeDef; 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /* Exported constants --------------------------------------------------------*/ 109 | /** @defgroup FLASH_Exported_Constants FLASH Exported Constants 110 | * @{ 111 | */ 112 | 113 | /** @defgroup FLASH_Error_Codes FLASH Error Codes 114 | * @{ 115 | */ 116 | 117 | #define HAL_FLASH_ERROR_NONE 0x00U /*!< No error */ 118 | #define HAL_FLASH_ERROR_PROG 0x01U /*!< Programming error */ 119 | #define HAL_FLASH_ERROR_WRP 0x02U /*!< Write protection error */ 120 | #define HAL_FLASH_ERROR_OPTV 0x04U /*!< Option validity error */ 121 | 122 | /** 123 | * @} 124 | */ 125 | 126 | /** @defgroup FLASH_Type_Program FLASH Type Program 127 | * @{ 128 | */ 129 | #define FLASH_TYPEPROGRAM_HALFWORD 0x01U /*!ACR |= FLASH_ACR_HLFCYA) 183 | 184 | /** 185 | * @brief Disable the FLASH half cycle access. 186 | * @note half cycle access can only be used with a low-frequency clock of less than 187 | 8 MHz that can be obtained with the use of HSI or HSE but not of PLL. 188 | * @retval None 189 | */ 190 | #define __HAL_FLASH_HALF_CYCLE_ACCESS_DISABLE() (FLASH->ACR &= (~FLASH_ACR_HLFCYA)) 191 | 192 | /** 193 | * @} 194 | */ 195 | 196 | #if defined(FLASH_ACR_LATENCY) 197 | /** @defgroup FLASH_EM_Latency FLASH Latency 198 | * @brief macros to handle FLASH Latency 199 | * @{ 200 | */ 201 | 202 | /** 203 | * @brief Set the FLASH Latency. 204 | * @param __LATENCY__ FLASH Latency 205 | * The value of this parameter depend on device used within the same series 206 | * @retval None 207 | */ 208 | #define __HAL_FLASH_SET_LATENCY(__LATENCY__) (FLASH->ACR = (FLASH->ACR&(~FLASH_ACR_LATENCY)) | (__LATENCY__)) 209 | 210 | 211 | /** 212 | * @brief Get the FLASH Latency. 213 | * @retval FLASH Latency 214 | * The value of this parameter depend on device used within the same series 215 | */ 216 | #define __HAL_FLASH_GET_LATENCY() (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)) 217 | 218 | /** 219 | * @} 220 | */ 221 | 222 | #endif /* FLASH_ACR_LATENCY */ 223 | /** @defgroup FLASH_Prefetch FLASH Prefetch 224 | * @brief macros to handle FLASH Prefetch buffer 225 | * @{ 226 | */ 227 | /** 228 | * @brief Enable the FLASH prefetch buffer. 229 | * @retval None 230 | */ 231 | #define __HAL_FLASH_PREFETCH_BUFFER_ENABLE() (FLASH->ACR |= FLASH_ACR_PRFTBE) 232 | 233 | /** 234 | * @brief Disable the FLASH prefetch buffer. 235 | * @retval None 236 | */ 237 | #define __HAL_FLASH_PREFETCH_BUFFER_DISABLE() (FLASH->ACR &= (~FLASH_ACR_PRFTBE)) 238 | 239 | /** 240 | * @} 241 | */ 242 | 243 | /** 244 | * @} 245 | */ 246 | 247 | /* Include FLASH HAL Extended module */ 248 | #include "stm32f1xx_hal_flash_ex.h" 249 | 250 | /* Exported functions --------------------------------------------------------*/ 251 | /** @addtogroup FLASH_Exported_Functions 252 | * @{ 253 | */ 254 | 255 | /** @addtogroup FLASH_Exported_Functions_Group1 256 | * @{ 257 | */ 258 | /* IO operation functions *****************************************************/ 259 | HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data); 260 | HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data); 261 | 262 | /* FLASH IRQ handler function */ 263 | void HAL_FLASH_IRQHandler(void); 264 | /* Callbacks in non blocking modes */ 265 | void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue); 266 | void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue); 267 | 268 | /** 269 | * @} 270 | */ 271 | 272 | /** @addtogroup FLASH_Exported_Functions_Group2 273 | * @{ 274 | */ 275 | /* Peripheral Control functions ***********************************************/ 276 | HAL_StatusTypeDef HAL_FLASH_Unlock(void); 277 | HAL_StatusTypeDef HAL_FLASH_Lock(void); 278 | HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void); 279 | HAL_StatusTypeDef HAL_FLASH_OB_Lock(void); 280 | void HAL_FLASH_OB_Launch(void); 281 | 282 | /** 283 | * @} 284 | */ 285 | 286 | /** @addtogroup FLASH_Exported_Functions_Group3 287 | * @{ 288 | */ 289 | /* Peripheral State and Error functions ***************************************/ 290 | uint32_t HAL_FLASH_GetError(void); 291 | 292 | /** 293 | * @} 294 | */ 295 | 296 | /** 297 | * @} 298 | */ 299 | 300 | /* Private function -------------------------------------------------*/ 301 | /** @addtogroup FLASH_Private_Functions 302 | * @{ 303 | */ 304 | HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout); 305 | #if defined(FLASH_BANK2_END) 306 | HAL_StatusTypeDef FLASH_WaitForLastOperationBank2(uint32_t Timeout); 307 | #endif /* FLASH_BANK2_END */ 308 | 309 | /** 310 | * @} 311 | */ 312 | 313 | /** 314 | * @} 315 | */ 316 | 317 | /** 318 | * @} 319 | */ 320 | 321 | #ifdef __cplusplus 322 | } 323 | #endif 324 | 325 | #endif /* __STM32F1xx_HAL_FLASH_H */ 326 | 327 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 328 | 329 | -------------------------------------------------------------------------------- /Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_tim_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of TIM HAL Extended module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

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

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef STM32F1xx_HAL_TIM_EX_H 22 | #define STM32F1xx_HAL_TIM_EX_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f1xx_hal_def.h" 30 | 31 | /** @addtogroup STM32F1xx_HAL_Driver 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup TIMEx 36 | * @{ 37 | */ 38 | 39 | /* Exported types ------------------------------------------------------------*/ 40 | /** @defgroup TIMEx_Exported_Types TIM Extended Exported Types 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief TIM Hall sensor Configuration Structure definition 46 | */ 47 | 48 | typedef struct 49 | { 50 | uint32_t IC1Polarity; /*!< Specifies the active edge of the input signal. 51 | This parameter can be a value of @ref TIM_Input_Capture_Polarity */ 52 | 53 | uint32_t IC1Prescaler; /*!< Specifies the Input Capture Prescaler. 54 | This parameter can be a value of @ref TIM_Input_Capture_Prescaler */ 55 | 56 | uint32_t IC1Filter; /*!< Specifies the input capture filter. 57 | This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */ 58 | 59 | uint32_t Commutation_Delay; /*!< Specifies the pulse value to be loaded into the Capture Compare Register. 60 | This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */ 61 | } TIM_HallSensor_InitTypeDef; 62 | /** 63 | * @} 64 | */ 65 | /* End of exported types -----------------------------------------------------*/ 66 | 67 | /* Exported constants --------------------------------------------------------*/ 68 | /** @defgroup TIMEx_Exported_Constants TIM Extended Exported Constants 69 | * @{ 70 | */ 71 | 72 | /** @defgroup TIMEx_Remap TIM Extended Remapping 73 | * @{ 74 | */ 75 | /** 76 | * @} 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | /* End of exported constants -------------------------------------------------*/ 83 | 84 | /* Exported macro ------------------------------------------------------------*/ 85 | /** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros 86 | * @{ 87 | */ 88 | 89 | /** 90 | * @} 91 | */ 92 | /* End of exported macro -----------------------------------------------------*/ 93 | 94 | /* Private macro -------------------------------------------------------------*/ 95 | /** @defgroup TIMEx_Private_Macros TIM Extended Private Macros 96 | * @{ 97 | */ 98 | 99 | /** 100 | * @} 101 | */ 102 | /* End of private macro ------------------------------------------------------*/ 103 | 104 | /* Exported functions --------------------------------------------------------*/ 105 | /** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions 106 | * @{ 107 | */ 108 | 109 | /** @addtogroup TIMEx_Exported_Functions_Group1 Extended Timer Hall Sensor functions 110 | * @brief Timer Hall Sensor functions 111 | * @{ 112 | */ 113 | /* Timer Hall Sensor functions **********************************************/ 114 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, TIM_HallSensor_InitTypeDef *sConfig); 115 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim); 116 | 117 | void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim); 118 | void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim); 119 | 120 | /* Blocking mode: Polling */ 121 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim); 122 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim); 123 | /* Non-Blocking mode: Interrupt */ 124 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim); 125 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim); 126 | /* Non-Blocking mode: DMA */ 127 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length); 128 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim); 129 | /** 130 | * @} 131 | */ 132 | 133 | /** @addtogroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions 134 | * @brief Timer Complementary Output Compare functions 135 | * @{ 136 | */ 137 | /* Timer Complementary Output Compare functions *****************************/ 138 | /* Blocking mode: Polling */ 139 | HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel); 140 | HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel); 141 | 142 | /* Non-Blocking mode: Interrupt */ 143 | HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel); 144 | HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel); 145 | 146 | /* Non-Blocking mode: DMA */ 147 | HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length); 148 | HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel); 149 | /** 150 | * @} 151 | */ 152 | 153 | /** @addtogroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions 154 | * @brief Timer Complementary PWM functions 155 | * @{ 156 | */ 157 | /* Timer Complementary PWM functions ****************************************/ 158 | /* Blocking mode: Polling */ 159 | HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel); 160 | HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel); 161 | 162 | /* Non-Blocking mode: Interrupt */ 163 | HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel); 164 | HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel); 165 | /* Non-Blocking mode: DMA */ 166 | HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length); 167 | HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel); 168 | /** 169 | * @} 170 | */ 171 | 172 | /** @addtogroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions 173 | * @brief Timer Complementary One Pulse functions 174 | * @{ 175 | */ 176 | /* Timer Complementary One Pulse functions **********************************/ 177 | /* Blocking mode: Polling */ 178 | HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel); 179 | HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel); 180 | 181 | /* Non-Blocking mode: Interrupt */ 182 | HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel); 183 | HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel); 184 | /** 185 | * @} 186 | */ 187 | 188 | /** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions 189 | * @brief Peripheral Control functions 190 | * @{ 191 | */ 192 | /* Extended Control functions ************************************************/ 193 | HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger, 194 | uint32_t CommutationSource); 195 | HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger, 196 | uint32_t CommutationSource); 197 | HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger, 198 | uint32_t CommutationSource); 199 | HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim, 200 | TIM_MasterConfigTypeDef *sMasterConfig); 201 | HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim, 202 | TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig); 203 | HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap); 204 | /** 205 | * @} 206 | */ 207 | 208 | /** @addtogroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions 209 | * @brief Extended Callbacks functions 210 | * @{ 211 | */ 212 | /* Extended Callback **********************************************************/ 213 | void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim); 214 | void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim); 215 | void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim); 216 | /** 217 | * @} 218 | */ 219 | 220 | /** @addtogroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions 221 | * @brief Extended Peripheral State functions 222 | * @{ 223 | */ 224 | /* Extended Peripheral State functions ***************************************/ 225 | HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef *htim); 226 | /** 227 | * @} 228 | */ 229 | 230 | /** 231 | * @} 232 | */ 233 | /* End of exported functions -------------------------------------------------*/ 234 | 235 | /* Private functions----------------------------------------------------------*/ 236 | /** @addtogroup TIMEx_Private_Functions TIMEx Private Functions 237 | * @{ 238 | */ 239 | void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma); 240 | void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma); 241 | /** 242 | * @} 243 | */ 244 | /* End of private functions --------------------------------------------------*/ 245 | 246 | /** 247 | * @} 248 | */ 249 | 250 | /** 251 | * @} 252 | */ 253 | 254 | #ifdef __cplusplus 255 | } 256 | #endif 257 | 258 | 259 | #endif /* STM32F1xx_HAL_TIM_EX_H */ 260 | 261 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 262 | -------------------------------------------------------------------------------- /Core/Startup/startup_stm32f103c8tx.s: -------------------------------------------------------------------------------- 1 | /** 2 | *************** (C) COPYRIGHT 2017 STMicroelectronics ************************ 3 | * @file startup_stm32f103xb.s 4 | * @author MCD Application Team 5 | * @brief STM32F103xB Devices vector table for Atollic toolchain. 6 | * This module performs: 7 | * - Set the initial SP 8 | * - Set the initial PC == Reset_Handler, 9 | * - Set the vector table entries with the exceptions ISR address 10 | * - Configure the clock system 11 | * - Branches to main in the C library (which eventually 12 | * calls main()). 13 | * After Reset the Cortex-M3 processor is in Thread mode, 14 | * priority is Privileged, and the Stack is set to Main. 15 | ****************************************************************************** 16 | * @attention 17 | * 18 | *

© Copyright (c) 2017 STMicroelectronics. 19 | * All rights reserved.

20 | * 21 | * This software component is licensed by ST under BSD 3-Clause license, 22 | * the "License"; You may not use this file except in compliance with the 23 | * License. You may obtain a copy of the License at: 24 | * opensource.org/licenses/BSD-3-Clause 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | .syntax unified 30 | .cpu cortex-m3 31 | .fpu softvfp 32 | .thumb 33 | 34 | .global g_pfnVectors 35 | .global Default_Handler 36 | 37 | /* start address for the initialization values of the .data section. 38 | defined in linker script */ 39 | .word _sidata 40 | /* start address for the .data section. defined in linker script */ 41 | .word _sdata 42 | /* end address for the .data section. defined in linker script */ 43 | .word _edata 44 | /* start address for the .bss section. defined in linker script */ 45 | .word _sbss 46 | /* end address for the .bss section. defined in linker script */ 47 | .word _ebss 48 | 49 | .equ BootRAM, 0xF108F85F 50 | /** 51 | * @brief This is the code that gets called when the processor first 52 | * starts execution following a reset event. Only the absolutely 53 | * necessary set is performed, after which the application 54 | * supplied main() routine is called. 55 | * @param None 56 | * @retval : None 57 | */ 58 | 59 | .section .text.Reset_Handler 60 | .weak Reset_Handler 61 | .type Reset_Handler, %function 62 | Reset_Handler: 63 | 64 | /* Copy the data segment initializers from flash to SRAM */ 65 | movs r1, #0 66 | b LoopCopyDataInit 67 | 68 | CopyDataInit: 69 | ldr r3, =_sidata 70 | ldr r3, [r3, r1] 71 | str r3, [r0, r1] 72 | adds r1, r1, #4 73 | 74 | LoopCopyDataInit: 75 | ldr r0, =_sdata 76 | ldr r3, =_edata 77 | adds r2, r0, r1 78 | cmp r2, r3 79 | bcc CopyDataInit 80 | ldr r2, =_sbss 81 | b LoopFillZerobss 82 | /* Zero fill the bss segment. */ 83 | FillZerobss: 84 | movs r3, #0 85 | str r3, [r2], #4 86 | 87 | LoopFillZerobss: 88 | ldr r3, = _ebss 89 | cmp r2, r3 90 | bcc FillZerobss 91 | 92 | /* Call the clock system intitialization function.*/ 93 | bl SystemInit 94 | /* Call static constructors */ 95 | bl __libc_init_array 96 | /* Call the application's entry point.*/ 97 | bl main 98 | bx lr 99 | .size Reset_Handler, .-Reset_Handler 100 | 101 | /** 102 | * @brief This is the code that gets called when the processor receives an 103 | * unexpected interrupt. This simply enters an infinite loop, preserving 104 | * the system state for examination by a debugger. 105 | * 106 | * @param None 107 | * @retval : None 108 | */ 109 | .section .text.Default_Handler,"ax",%progbits 110 | Default_Handler: 111 | Infinite_Loop: 112 | b Infinite_Loop 113 | .size Default_Handler, .-Default_Handler 114 | /****************************************************************************** 115 | * 116 | * The minimal vector table for a Cortex M3. Note that the proper constructs 117 | * must be placed on this to ensure that it ends up at physical address 118 | * 0x0000.0000. 119 | * 120 | ******************************************************************************/ 121 | .section .isr_vector,"a",%progbits 122 | .type g_pfnVectors, %object 123 | .size g_pfnVectors, .-g_pfnVectors 124 | 125 | 126 | g_pfnVectors: 127 | 128 | .word _estack 129 | .word Reset_Handler 130 | .word NMI_Handler 131 | .word HardFault_Handler 132 | .word MemManage_Handler 133 | .word BusFault_Handler 134 | .word UsageFault_Handler 135 | .word 0 136 | .word 0 137 | .word 0 138 | .word 0 139 | .word SVC_Handler 140 | .word DebugMon_Handler 141 | .word 0 142 | .word PendSV_Handler 143 | .word SysTick_Handler 144 | .word WWDG_IRQHandler 145 | .word PVD_IRQHandler 146 | .word TAMPER_IRQHandler 147 | .word RTC_IRQHandler 148 | .word FLASH_IRQHandler 149 | .word RCC_IRQHandler 150 | .word EXTI0_IRQHandler 151 | .word EXTI1_IRQHandler 152 | .word EXTI2_IRQHandler 153 | .word EXTI3_IRQHandler 154 | .word EXTI4_IRQHandler 155 | .word DMA1_Channel1_IRQHandler 156 | .word DMA1_Channel2_IRQHandler 157 | .word DMA1_Channel3_IRQHandler 158 | .word DMA1_Channel4_IRQHandler 159 | .word DMA1_Channel5_IRQHandler 160 | .word DMA1_Channel6_IRQHandler 161 | .word DMA1_Channel7_IRQHandler 162 | .word ADC1_2_IRQHandler 163 | .word USB_HP_CAN1_TX_IRQHandler 164 | .word USB_LP_CAN1_RX0_IRQHandler 165 | .word CAN1_RX1_IRQHandler 166 | .word CAN1_SCE_IRQHandler 167 | .word EXTI9_5_IRQHandler 168 | .word TIM1_BRK_IRQHandler 169 | .word TIM1_UP_IRQHandler 170 | .word TIM1_TRG_COM_IRQHandler 171 | .word TIM1_CC_IRQHandler 172 | .word TIM2_IRQHandler 173 | .word TIM3_IRQHandler 174 | .word TIM4_IRQHandler 175 | .word I2C1_EV_IRQHandler 176 | .word I2C1_ER_IRQHandler 177 | .word I2C2_EV_IRQHandler 178 | .word I2C2_ER_IRQHandler 179 | .word SPI1_IRQHandler 180 | .word SPI2_IRQHandler 181 | .word USART1_IRQHandler 182 | .word USART2_IRQHandler 183 | .word USART3_IRQHandler 184 | .word EXTI15_10_IRQHandler 185 | .word RTC_Alarm_IRQHandler 186 | .word USBWakeUp_IRQHandler 187 | .word 0 188 | .word 0 189 | .word 0 190 | .word 0 191 | .word 0 192 | .word 0 193 | .word 0 194 | .word BootRAM /* @0x108. This is for boot in RAM mode for 195 | STM32F10x Medium Density devices. */ 196 | 197 | /******************************************************************************* 198 | * 199 | * Provide weak aliases for each Exception handler to the Default_Handler. 200 | * As they are weak aliases, any function with the same name will override 201 | * this definition. 202 | * 203 | *******************************************************************************/ 204 | 205 | .weak NMI_Handler 206 | .thumb_set NMI_Handler,Default_Handler 207 | 208 | .weak HardFault_Handler 209 | .thumb_set HardFault_Handler,Default_Handler 210 | 211 | .weak MemManage_Handler 212 | .thumb_set MemManage_Handler,Default_Handler 213 | 214 | .weak BusFault_Handler 215 | .thumb_set BusFault_Handler,Default_Handler 216 | 217 | .weak UsageFault_Handler 218 | .thumb_set UsageFault_Handler,Default_Handler 219 | 220 | .weak SVC_Handler 221 | .thumb_set SVC_Handler,Default_Handler 222 | 223 | .weak DebugMon_Handler 224 | .thumb_set DebugMon_Handler,Default_Handler 225 | 226 | .weak PendSV_Handler 227 | .thumb_set PendSV_Handler,Default_Handler 228 | 229 | .weak SysTick_Handler 230 | .thumb_set SysTick_Handler,Default_Handler 231 | 232 | .weak WWDG_IRQHandler 233 | .thumb_set WWDG_IRQHandler,Default_Handler 234 | 235 | .weak PVD_IRQHandler 236 | .thumb_set PVD_IRQHandler,Default_Handler 237 | 238 | .weak TAMPER_IRQHandler 239 | .thumb_set TAMPER_IRQHandler,Default_Handler 240 | 241 | .weak RTC_IRQHandler 242 | .thumb_set RTC_IRQHandler,Default_Handler 243 | 244 | .weak FLASH_IRQHandler 245 | .thumb_set FLASH_IRQHandler,Default_Handler 246 | 247 | .weak RCC_IRQHandler 248 | .thumb_set RCC_IRQHandler,Default_Handler 249 | 250 | .weak EXTI0_IRQHandler 251 | .thumb_set EXTI0_IRQHandler,Default_Handler 252 | 253 | .weak EXTI1_IRQHandler 254 | .thumb_set EXTI1_IRQHandler,Default_Handler 255 | 256 | .weak EXTI2_IRQHandler 257 | .thumb_set EXTI2_IRQHandler,Default_Handler 258 | 259 | .weak EXTI3_IRQHandler 260 | .thumb_set EXTI3_IRQHandler,Default_Handler 261 | 262 | .weak EXTI4_IRQHandler 263 | .thumb_set EXTI4_IRQHandler,Default_Handler 264 | 265 | .weak DMA1_Channel1_IRQHandler 266 | .thumb_set DMA1_Channel1_IRQHandler,Default_Handler 267 | 268 | .weak DMA1_Channel2_IRQHandler 269 | .thumb_set DMA1_Channel2_IRQHandler,Default_Handler 270 | 271 | .weak DMA1_Channel3_IRQHandler 272 | .thumb_set DMA1_Channel3_IRQHandler,Default_Handler 273 | 274 | .weak DMA1_Channel4_IRQHandler 275 | .thumb_set DMA1_Channel4_IRQHandler,Default_Handler 276 | 277 | .weak DMA1_Channel5_IRQHandler 278 | .thumb_set DMA1_Channel5_IRQHandler,Default_Handler 279 | 280 | .weak DMA1_Channel6_IRQHandler 281 | .thumb_set DMA1_Channel6_IRQHandler,Default_Handler 282 | 283 | .weak DMA1_Channel7_IRQHandler 284 | .thumb_set DMA1_Channel7_IRQHandler,Default_Handler 285 | 286 | .weak ADC1_2_IRQHandler 287 | .thumb_set ADC1_2_IRQHandler,Default_Handler 288 | 289 | .weak USB_HP_CAN1_TX_IRQHandler 290 | .thumb_set USB_HP_CAN1_TX_IRQHandler,Default_Handler 291 | 292 | .weak USB_LP_CAN1_RX0_IRQHandler 293 | .thumb_set USB_LP_CAN1_RX0_IRQHandler,Default_Handler 294 | 295 | .weak CAN1_RX1_IRQHandler 296 | .thumb_set CAN1_RX1_IRQHandler,Default_Handler 297 | 298 | .weak CAN1_SCE_IRQHandler 299 | .thumb_set CAN1_SCE_IRQHandler,Default_Handler 300 | 301 | .weak EXTI9_5_IRQHandler 302 | .thumb_set EXTI9_5_IRQHandler,Default_Handler 303 | 304 | .weak TIM1_BRK_IRQHandler 305 | .thumb_set TIM1_BRK_IRQHandler,Default_Handler 306 | 307 | .weak TIM1_UP_IRQHandler 308 | .thumb_set TIM1_UP_IRQHandler,Default_Handler 309 | 310 | .weak TIM1_TRG_COM_IRQHandler 311 | .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler 312 | 313 | .weak TIM1_CC_IRQHandler 314 | .thumb_set TIM1_CC_IRQHandler,Default_Handler 315 | 316 | .weak TIM2_IRQHandler 317 | .thumb_set TIM2_IRQHandler,Default_Handler 318 | 319 | .weak TIM3_IRQHandler 320 | .thumb_set TIM3_IRQHandler,Default_Handler 321 | 322 | .weak TIM4_IRQHandler 323 | .thumb_set TIM4_IRQHandler,Default_Handler 324 | 325 | .weak I2C1_EV_IRQHandler 326 | .thumb_set I2C1_EV_IRQHandler,Default_Handler 327 | 328 | .weak I2C1_ER_IRQHandler 329 | .thumb_set I2C1_ER_IRQHandler,Default_Handler 330 | 331 | .weak I2C2_EV_IRQHandler 332 | .thumb_set I2C2_EV_IRQHandler,Default_Handler 333 | 334 | .weak I2C2_ER_IRQHandler 335 | .thumb_set I2C2_ER_IRQHandler,Default_Handler 336 | 337 | .weak SPI1_IRQHandler 338 | .thumb_set SPI1_IRQHandler,Default_Handler 339 | 340 | .weak SPI2_IRQHandler 341 | .thumb_set SPI2_IRQHandler,Default_Handler 342 | 343 | .weak USART1_IRQHandler 344 | .thumb_set USART1_IRQHandler,Default_Handler 345 | 346 | .weak USART2_IRQHandler 347 | .thumb_set USART2_IRQHandler,Default_Handler 348 | 349 | .weak USART3_IRQHandler 350 | .thumb_set USART3_IRQHandler,Default_Handler 351 | 352 | .weak EXTI15_10_IRQHandler 353 | .thumb_set EXTI15_10_IRQHandler,Default_Handler 354 | 355 | .weak RTC_Alarm_IRQHandler 356 | .thumb_set RTC_Alarm_IRQHandler,Default_Handler 357 | 358 | .weak USBWakeUp_IRQHandler 359 | .thumb_set USBWakeUp_IRQHandler,Default_Handler 360 | 361 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 362 | 363 | -------------------------------------------------------------------------------- /.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousLibFiles] 2 | LibFiles=Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pcd.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pcd_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_usb.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_exti.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h;Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc/usbd_cdc.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usb.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pcd.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pcd_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_usb.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_exti.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h;Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc/usbd_cdc.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/cmsis_version.h;Drivers/CMSIS/Include/core_armv8mbl.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/mpu_armv7.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/tz_context.h; 3 | 4 | [PreviousUsedCubeIDEFiles] 5 | SourceFiles=Core\Src\main.c;Core\Src\gpio.c;Core\Src\dma.c;Core\Src\spi.c;USB_DEVICE\App\usb_device.c;USB_DEVICE\Target\usbd_conf.c;USB_DEVICE\App\usbd_desc.c;USB_DEVICE\App\usbd_cdc_if.c;Core\Src\stm32f1xx_it.c;Core\Src\stm32f1xx_hal_msp.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usb.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c;Core\Src/system_stm32f1xx.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usb.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c;Core\Src/system_stm32f1xx.c;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c; 6 | HeaderPath=Drivers\STM32F1xx_HAL_Driver\Inc;Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;Middlewares\ST\STM32_USB_Device_Library\Core\Inc;Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Inc;Drivers\CMSIS\Device\ST\STM32F1xx\Include;Drivers\CMSIS\Include;Core\Inc;USB_DEVICE\App;USB_DEVICE\Target; 7 | CDefines=USE_HAL_DRIVER;STM32F103xB;USE_HAL_DRIVER;USE_HAL_DRIVER; 8 | 9 | [PreviousGenFiles] 10 | AdvancedFolderStructure=true 11 | HeaderFileListSize=10 12 | HeaderFiles#0=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/Core/Inc/gpio.h 13 | HeaderFiles#1=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/Core/Inc/dma.h 14 | HeaderFiles#2=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/Core/Inc/spi.h 15 | HeaderFiles#3=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/USB_DEVICE/App/usb_device.h 16 | HeaderFiles#4=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/USB_DEVICE/Target/usbd_conf.h 17 | HeaderFiles#5=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/USB_DEVICE/App/usbd_desc.h 18 | HeaderFiles#6=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/USB_DEVICE/App/usbd_cdc_if.h 19 | HeaderFiles#7=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/Core/Inc/stm32f1xx_it.h 20 | HeaderFiles#8=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/Core/Inc/stm32f1xx_hal_conf.h 21 | HeaderFiles#9=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/Core/Inc/main.h 22 | HeaderFolderListSize=3 23 | HeaderPath#0=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/Core/Inc 24 | HeaderPath#1=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/USB_DEVICE/App 25 | HeaderPath#2=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/USB_DEVICE/Target 26 | HeaderFiles=; 27 | SourceFileListSize=10 28 | SourceFiles#0=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/Core/Src/gpio.c 29 | SourceFiles#1=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/Core/Src/dma.c 30 | SourceFiles#2=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/Core/Src/spi.c 31 | SourceFiles#3=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/USB_DEVICE/App/usb_device.c 32 | SourceFiles#4=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/USB_DEVICE/Target/usbd_conf.c 33 | SourceFiles#5=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/USB_DEVICE/App/usbd_desc.c 34 | SourceFiles#6=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/USB_DEVICE/App/usbd_cdc_if.c 35 | SourceFiles#7=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/Core/Src/stm32f1xx_it.c 36 | SourceFiles#8=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/Core/Src/stm32f1xx_hal_msp.c 37 | SourceFiles#9=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/Core/Src/main.c 38 | SourceFolderListSize=3 39 | SourcePath#0=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/Core/Src 40 | SourcePath#1=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/USB_DEVICE/App 41 | SourcePath#2=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/6. Adresowalne diody WS2812B na STM32/Kod/WS2812B/WS2812B_C8/USB_DEVICE/Target 42 | SourceFiles=; 43 | 44 | --------------------------------------------------------------------------------