├── example └── test433 │ ├── 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 │ ├── .project │ ├── Core │ ├── Src │ │ ├── sys.c │ │ ├── stm32f1xx_hal_msp.c │ │ ├── sysmem.c │ │ ├── gpio.c │ │ ├── syscalls.c │ │ ├── main.c │ │ ├── stm32f1xx_it.c │ │ └── rf-barrier.c │ └── Inc │ │ ├── sys.h │ │ ├── gpio.h │ │ ├── micros.h │ │ ├── rf-barrier.h │ │ ├── stm32f1xx_it.h │ │ ├── main.h │ │ └── rf-barrier-timings.h │ ├── .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 │ ├── test433.ioc │ ├── test433 Debug.launch │ ├── STM32F103C8TX_FLASH.ld │ └── .mxproject ├── Src ├── rf-barrier.h ├── rf-barrier-timings.h └── rf-barrier.c └── README.md /example/test433/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leech001/RF-BARRIER/HEAD/example/test433/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h -------------------------------------------------------------------------------- /example/test433/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leech001/RF-BARRIER/HEAD/example/test433/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h -------------------------------------------------------------------------------- /example/test433/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | test433 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 | -------------------------------------------------------------------------------- /example/test433/Core/Src/sys.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : SYS.c 4 | * Description : This file provides code for the configuration 5 | * of the SYS instances. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2019 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 "sys.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | /* SYS init function */ 28 | void MX_SYS_Init(void) 29 | { 30 | 31 | /** NOJTAG: JTAG-DP Disabled and SW-DP Enabled 32 | */ 33 | __HAL_AFIO_REMAP_SWJ_NOJTAG(); 34 | 35 | } 36 | 37 | /* USER CODE BEGIN 1 */ 38 | 39 | /* USER CODE END 1 */ 40 | 41 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 42 | -------------------------------------------------------------------------------- /example/test433/Core/Inc/sys.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : SYS.h 4 | * Description : This file provides code for the configuration 5 | * of the SYS instances. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2019 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 __sys_H 21 | #define __sys_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 | /* USER CODE BEGIN Private defines */ 34 | 35 | /* USER CODE END Private defines */ 36 | 37 | void MX_SYS_Init(void); 38 | 39 | /* USER CODE BEGIN Prototypes */ 40 | 41 | /* USER CODE END Prototypes */ 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | #endif /*__ sys_H */ 47 | 48 | /** 49 | * @} 50 | */ 51 | 52 | /** 53 | * @} 54 | */ 55 | 56 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 57 | -------------------------------------------------------------------------------- /example/test433/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) 2019 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 | -------------------------------------------------------------------------------- /example/test433/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 | -------------------------------------------------------------------------------- /Src/rf-barrier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rf-barrier.h 3 | * 4 | * Created on: Nov 21, 2019 5 | * Author: Bulanov Konstantin 6 | */ 7 | 8 | #ifndef INC_RF_BARRIER_H_ 9 | #define INC_RF_BARRIER_H_ 10 | 11 | #include "main.h" 12 | 13 | // Debug 14 | #define RF_DEBUG 15 | 16 | // ===== CONFIG port and pin ======= 17 | #define TXPORT TX433_GPIO_Port 18 | #define TXPIN TX433_Pin 19 | 20 | #define RXPORT GPIOC 21 | #define RXPIN GPIO_PIN_15 22 | // ==================== 23 | 24 | typedef struct { 25 | uint8_t low; 26 | uint8_t high; 27 | } LowHigh_t; 28 | 29 | typedef struct { 30 | uint8_t repeat; 31 | LowHigh_t bit1; 32 | LowHigh_t bit2; 33 | } Bit_t; 34 | 35 | typedef struct { 36 | uint8_t nRepeatTransmit; 37 | uint16_t PulseLength; 38 | uint8_t CodeLength; 39 | uint8_t Invert; 40 | Bit_t Preamble; 41 | Bit_t Header; 42 | Bit_t Zero; 43 | Bit_t One; 44 | Bit_t Flt; 45 | Bit_t Tail; 46 | uint16_t nGuard; 47 | } Protocol_t; 48 | 49 | typedef struct { 50 | uint8_t Invert; // 0 if start bit from HIGH 51 | uint16_t Te; 52 | uint16_t TeDrv; 53 | uint16_t MaxPause; 54 | uint16_t PreambleLenght; // Length count in Te 55 | uint16_t HeaderLenght; 56 | uint8_t CodeLengh; 57 | uint16_t TailLenght; 58 | uint8_t PreambleCount; 59 | uint8_t Header; 60 | uint8_t BitCounter; 61 | uint8_t Tail; 62 | uint8_t BitArray[128]; 63 | uint8_t Repeat; 64 | uint8_t BatteryLow; 65 | uint8_t Btn2; 66 | uint8_t Btn1; 67 | uint8_t Btn0; 68 | uint8_t Btn3; 69 | uint32_t SerialNum; 70 | uint32_t Encrypt; 71 | } RF_t; 72 | 73 | Protocol_t proto_hcs301; 74 | Protocol_t proto_came12; 75 | Protocol_t proto_came24; 76 | 77 | RF_t hcs301; 78 | RF_t came12; 79 | RF_t nice12; 80 | 81 | void RF_send_bin(Protocol_t* protocol, const char* sCodeWord); 82 | void RF_send(Protocol_t* protocol, uint64_t code); 83 | void RF_transmit(Bit_t pulses, uint16_t length, uint8_t invert); 84 | 85 | void RX433_Int(void); 86 | uint8_t RF_Int(RF_t* data); 87 | 88 | 89 | #endif /* INC_RF_BARRIER_H_ */ 90 | -------------------------------------------------------------------------------- /example/test433/Core/Inc/micros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * micros.h 3 | * 4 | * Created on: Nov 18, 2019 5 | * Author: Bulanov Konstantin 6 | * 7 | * Contact information 8 | * ------------------- 9 | * 10 | * e-mail : leech001@gmail.com 11 | */ 12 | 13 | /* 14 | * |--------------------------------------------------------------------------------- 15 | * | Copyright (C) Bulanov Konstantin,2019 16 | * | 17 | * | This program is free software: you can redistribute it and/or modify 18 | * | it under the terms of the GNU General Public License as published by 19 | * | the Free Software Foundation, either version 3 of the License, or 20 | * | any later version. 21 | * | 22 | * | This program is distributed in the hope that it will be useful, 23 | * | but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 | * | GNU General Public License for more details. 26 | * | 27 | * | You should have received a copy of the GNU General Public License 28 | * | along with this program. If not, see . 29 | * | 30 | * | DWT and delay_us() algorithm used from https://istarik.ru/blog/stm32/131.html and https://github.com/stDstm/Example_STM32F103/tree/master/delay_micros_one_file 31 | * |--------------------------------------------------------------------------------- 32 | */ 33 | 34 | #ifndef INC_MICROS_H_ 35 | #define INC_MICROS_H_ 36 | 37 | #include "main.h" 38 | 39 | __STATIC_INLINE void DWT_Init(void) 40 | { 41 | CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; // разрешаем использовать счётчик 42 | DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; // запускаем счётчик 43 | } 44 | 45 | __STATIC_INLINE void delay_us(uint32_t us) 46 | { 47 | uint32_t us_count_tic = us * (SystemCoreClock / 1000000U); 48 | DWT->CYCCNT = 0U; 49 | while(DWT->CYCCNT < us_count_tic); 50 | } 51 | 52 | __STATIC_INLINE uint32_t micros(void){ 53 | return DWT->CYCCNT / (SystemCoreClock / 1000000U); 54 | } 55 | 56 | #endif /* INC_MICROS_H_ */ 57 | -------------------------------------------------------------------------------- /example/test433/Core/Inc/rf-barrier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rf-barrier.h 3 | * 4 | * Created on: Nov 21, 2019 5 | * Author: Bulanov Konstantin 6 | */ 7 | 8 | #ifndef INC_RF_BARRIER_H_ 9 | #define INC_RF_BARRIER_H_ 10 | 11 | #include "main.h" 12 | 13 | // Debug 14 | #define RF_DEBUG 15 | 16 | // ===== CONFIG port and pin ======= 17 | #define TXPORT TX433_GPIO_Port 18 | #define TXPIN TX433_Pin 19 | 20 | #define RXPORT GPIOC 21 | #define RXPIN GPIO_PIN_15 22 | // ==================== 23 | 24 | typedef struct { 25 | uint8_t low; 26 | uint8_t high; 27 | } LowHigh_t; 28 | 29 | typedef struct { 30 | uint8_t repeat; 31 | LowHigh_t bit1; 32 | LowHigh_t bit2; 33 | } Bit_t; 34 | 35 | typedef struct { 36 | uint8_t nRepeatTransmit; 37 | uint16_t PulseLength; 38 | uint8_t CodeLength; 39 | uint8_t Invert; 40 | Bit_t Preamble; 41 | Bit_t Header; 42 | Bit_t Zero; 43 | Bit_t One; 44 | Bit_t Flt; 45 | Bit_t Tail; 46 | uint16_t nGuard; 47 | } Protocol_t; 48 | 49 | typedef struct { 50 | uint8_t Invert; // 0 if start bit from HIGH 51 | uint16_t Te; 52 | uint16_t TeDrv; 53 | uint16_t MaxPause; 54 | uint16_t PreambleLenght; // Length count in Te 55 | uint16_t HeaderLenght; 56 | uint8_t CodeLengh; 57 | uint16_t TailLenght; 58 | uint8_t PreambleCount; 59 | uint8_t Header; 60 | uint8_t BitCounter; 61 | uint8_t Tail; 62 | uint8_t BitArray[128]; 63 | uint8_t Repeat; 64 | uint8_t BatteryLow; 65 | uint8_t Btn2; 66 | uint8_t Btn1; 67 | uint8_t Btn0; 68 | uint8_t Btn3; 69 | uint32_t SerialNum; 70 | uint32_t Encrypt; 71 | } RF_t; 72 | 73 | Protocol_t proto_hcs301; 74 | Protocol_t proto_came12; 75 | Protocol_t proto_came24; 76 | 77 | RF_t hcs301; 78 | RF_t came12; 79 | RF_t nice12; 80 | 81 | void RF_send_bin(Protocol_t* protocol, const char* sCodeWord); 82 | void RF_send(Protocol_t* protocol, uint64_t code); 83 | void RF_transmit(Bit_t pulses, uint16_t length, uint8_t invert); 84 | 85 | void RX433_Int(void); 86 | uint8_t RF_Int(RF_t* data); 87 | 88 | 89 | #endif /* INC_RF_BARRIER_H_ */ 90 | -------------------------------------------------------------------------------- /example/test433/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 | -------------------------------------------------------------------------------- /example/test433/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) 2019 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 USB_LP_CAN1_RX0_IRQHandler(void); 60 | void EXTI15_10_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 | -------------------------------------------------------------------------------- /example/test433/.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 | -------------------------------------------------------------------------------- /example/test433/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 | -------------------------------------------------------------------------------- /example/test433/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) 2019 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 RX433_Pin GPIO_PIN_15 64 | #define RX433_GPIO_Port GPIOC 65 | #define RX433_EXTI_IRQn EXTI15_10_IRQn 66 | #define RX433PWR_Pin GPIO_PIN_7 67 | #define RX433PWR_GPIO_Port GPIOA 68 | #define TX433PWR_Pin GPIO_PIN_0 69 | #define TX433PWR_GPIO_Port GPIOB 70 | #define TX433_Pin GPIO_PIN_12 71 | #define TX433_GPIO_Port GPIOB 72 | /* USER CODE BEGIN Private defines */ 73 | 74 | /* USER CODE END Private defines */ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif /* __MAIN_H */ 81 | 82 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 83 | -------------------------------------------------------------------------------- /example/test433/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) 2019 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 | -------------------------------------------------------------------------------- /example/test433/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 | -------------------------------------------------------------------------------- /example/test433/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) 2019 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 | -------------------------------------------------------------------------------- /example/test433/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) 2019 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 | -------------------------------------------------------------------------------- /example/test433/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 | -------------------------------------------------------------------------------- /example/test433/Core/Src/sysmem.c: -------------------------------------------------------------------------------- 1 | /** 2 | ***************************************************************************** 3 | ** 4 | ** File : sysmem.c 5 | ** 6 | ** Author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** Abstract : STM32CubeIDE Minimal System Memory calls file 9 | ** 10 | ** For more information about which c-functions 11 | ** need which of these lowlevel functions 12 | ** please consult the Newlib libc-manual 13 | ** 14 | ** Environment : STM32CubeIDE MCU 15 | ** 16 | ** Distribution: The file is distributed as is, without any warranty 17 | ** of any kind. 18 | ** 19 | ***************************************************************************** 20 | ** 21 | **

© COPYRIGHT(c) 2018 STMicroelectronics

22 | ** 23 | ** Redistribution and use in source and binary forms, with or without modification, 24 | ** are permitted provided that the following conditions are met: 25 | ** 1. Redistributions of source code must retain the above copyright notice, 26 | ** this list of conditions and the following disclaimer. 27 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 28 | ** this list of conditions and the following disclaimer in the documentation 29 | ** and/or other materials provided with the distribution. 30 | ** 3. Neither the name of STMicroelectronics nor the names of its contributors 31 | ** may be used to endorse or promote products derived from this software 32 | ** without specific prior written permission. 33 | ** 34 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 35 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 36 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 38 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 39 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 40 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 41 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 42 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 43 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 44 | ** 45 | ** 46 | ***************************************************************************** 47 | */ 48 | 49 | /* Includes */ 50 | #include 51 | #include 52 | 53 | /* Variables */ 54 | extern int errno; 55 | register char * stack_ptr asm("sp"); 56 | 57 | /* Functions */ 58 | 59 | /** 60 | _sbrk 61 | Increase program data space. Malloc and related functions depend on this 62 | **/ 63 | caddr_t _sbrk(int incr) 64 | { 65 | extern char end asm("end"); 66 | static char *heap_end; 67 | char *prev_heap_end; 68 | 69 | if (heap_end == 0) 70 | heap_end = &end; 71 | 72 | prev_heap_end = heap_end; 73 | if (heap_end + incr > stack_ptr) 74 | { 75 | errno = ENOMEM; 76 | return (caddr_t) -1; 77 | } 78 | 79 | heap_end += incr; 80 | 81 | return (caddr_t) prev_heap_end; 82 | } 83 | 84 | -------------------------------------------------------------------------------- /example/test433/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 | -------------------------------------------------------------------------------- /example/test433/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) 2019 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 | -------------------------------------------------------------------------------- /example/test433/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) 2019 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 | __HAL_RCC_GPIOB_CLK_ENABLE(); 50 | 51 | /*Configure GPIO pin Output Level */ 52 | HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET); 53 | 54 | /*Configure GPIO pin Output Level */ 55 | HAL_GPIO_WritePin(RX433PWR_GPIO_Port, RX433PWR_Pin, GPIO_PIN_RESET); 56 | 57 | /*Configure GPIO pin Output Level */ 58 | HAL_GPIO_WritePin(GPIOB, TX433PWR_Pin|TX433_Pin, GPIO_PIN_RESET); 59 | 60 | /*Configure GPIO pin : PtPin */ 61 | GPIO_InitStruct.Pin = LED_Pin; 62 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 63 | GPIO_InitStruct.Pull = GPIO_NOPULL; 64 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 65 | HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct); 66 | 67 | /*Configure GPIO pin : PtPin */ 68 | GPIO_InitStruct.Pin = RX433_Pin; 69 | GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; 70 | GPIO_InitStruct.Pull = GPIO_NOPULL; 71 | HAL_GPIO_Init(RX433_GPIO_Port, &GPIO_InitStruct); 72 | 73 | /*Configure GPIO pin : PtPin */ 74 | GPIO_InitStruct.Pin = RX433PWR_Pin; 75 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 76 | GPIO_InitStruct.Pull = GPIO_NOPULL; 77 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 78 | HAL_GPIO_Init(RX433PWR_GPIO_Port, &GPIO_InitStruct); 79 | 80 | /*Configure GPIO pins : PBPin PBPin */ 81 | GPIO_InitStruct.Pin = TX433PWR_Pin|TX433_Pin; 82 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 83 | GPIO_InitStruct.Pull = GPIO_NOPULL; 84 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 85 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 86 | 87 | /* EXTI interrupt init*/ 88 | HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0); 89 | HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); 90 | 91 | } 92 | 93 | /* USER CODE BEGIN 2 */ 94 | 95 | /* USER CODE END 2 */ 96 | 97 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 98 | -------------------------------------------------------------------------------- /example/test433/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) 2019 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 | -------------------------------------------------------------------------------- /Src/rf-barrier-timings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rf-barrier-timings.h 3 | * 4 | * Created on: Nov 21, 2019 5 | * Author: Bulanov Konstantin 6 | */ 7 | 8 | #ifndef INC_RF_BARRIER_TIMINGS_H_ 9 | #define INC_RF_BARRIER_TIMINGS_H_ 10 | 11 | // =============Receive======== 12 | // HCS301 13 | RF_t hcs301 = { 14 | .Invert= 1, 15 | .Te = 400, 16 | .TeDrv = 50, 17 | .MaxPause = 20000, 18 | .CodeLengh = 66, 19 | .PreambleLenght = 23, 20 | .HeaderLenght= 10 21 | }; 22 | 23 | // Came 12 24 | RF_t came12 = { 25 | .Invert= 0, 26 | .Te = 320, 27 | .TeDrv = 50, 28 | .MaxPause = 20000, 29 | .CodeLengh = 12, 30 | .PreambleLenght = 0, 31 | .HeaderLenght= 1 32 | }; 33 | 34 | // Nice 12 35 | RF_t nice12 = { 36 | .Invert= 0, 37 | .Te = 700, 38 | .TeDrv = 50, 39 | .MaxPause = 20000, 40 | .CodeLengh = 12, 41 | .PreambleLenght = 0, 42 | .HeaderLenght= 1 43 | }; 44 | 45 | 46 | // ========== Transmit =========== 47 | Protocol_t proto_hcs301 ={ 48 | .nRepeatTransmit = 1, // Repeat code 49 | .PulseLength = 400, 50 | .CodeLength = 66, 51 | .Invert = 1, // Start from HIGH 52 | 53 | .Preamble.repeat = 12, 54 | .Preamble.bit1.low = 1, 55 | .Preamble.bit1.high = 1, 56 | .Preamble.bit2.low = 0, 57 | .Preamble.bit2.high = 0, 58 | 59 | .Header.repeat = 9, // 9 not 10 when one low pulse send from Preamble. 60 | .Header.bit1.low = 1, 61 | .Header.bit1.high = 0, 62 | .Header.bit2.low = 0, 63 | .Header.bit2.high = 0, 64 | 65 | .Zero.repeat = 1, 66 | .Zero.bit1.low = 1, 67 | .Zero.bit1.high = 2, 68 | .Zero.bit2.low = 0, 69 | .Zero.bit2.high = 0, 70 | 71 | .One.repeat = 1, 72 | .One.bit1.low = 2, 73 | .One.bit1.high = 1, 74 | .One.bit2.low = 0, 75 | .One.bit2.high = 0, 76 | 77 | .Tail.repeat = 2, // 64 Code + 2 Tail = 66 bit (Keeloq) 78 | .Tail.bit1.low = 2, 79 | .Tail.bit1.high = 1, 80 | .Tail.bit2.low = 0, 81 | .Tail.bit2.high = 0, 82 | 83 | .nGuard = 39 84 | }; 85 | 86 | Protocol_t proto_came12 ={ 87 | .nRepeatTransmit = 4, // Repeat code 88 | .PulseLength = 320, 89 | .CodeLength = 12, 90 | .Invert = 0, 91 | 92 | .Preamble.repeat = 36, 93 | .Preamble.bit1.low = 1, 94 | .Preamble.bit1.high = 0, 95 | .Preamble.bit2.low = 0, 96 | .Preamble.bit2.high = 0, 97 | 98 | .Header.repeat = 1, 99 | .Header.bit1.low = 0, 100 | .Header.bit1.high = 1, 101 | .Header.bit2.low = 0, 102 | .Header.bit2.high = 0, 103 | 104 | .Zero.repeat = 1, 105 | .Zero.bit1.low = 1, 106 | .Zero.bit1.high = 2, 107 | .Zero.bit2.low = 0, 108 | .Zero.bit2.high = 0, 109 | 110 | .One.repeat = 1, 111 | .One.bit1.low = 2, 112 | .One.bit1.high = 1, 113 | .One.bit2.low = 0, 114 | .One.bit2.high = 0, 115 | 116 | .Tail.repeat = 0, 117 | .Tail.bit1.low = 0, 118 | .Tail.bit1.high = 0, 119 | .Tail.bit2.low = 0, 120 | .Tail.bit2.high = 0, 121 | 122 | .nGuard = 0 123 | }; 124 | 125 | Protocol_t proto_came24 ={ 126 | .nRepeatTransmit = 4, // Repeat code 127 | .PulseLength = 320, 128 | .CodeLength = 24, 129 | .Invert = 0, 130 | 131 | .Preamble.repeat = 36, 132 | .Preamble.bit1.low = 1, 133 | .Preamble.bit1.high = 0, 134 | .Preamble.bit2.low = 0, 135 | .Preamble.bit2.high = 0, 136 | 137 | .Header.repeat = 1, 138 | .Header.bit1.low = 0, 139 | .Header.bit1.high = 1, 140 | .Header.bit2.low = 0, 141 | .Header.bit2.high = 0, 142 | 143 | .Zero.repeat = 1, 144 | .Zero.bit1.low = 1, 145 | .Zero.bit1.high = 2, 146 | .Zero.bit2.low = 1, 147 | .Zero.bit2.high = 2, 148 | 149 | .One.repeat = 1, 150 | .One.bit1.low = 2, 151 | .One.bit1.high = 1, 152 | .One.bit2.low = 2, 153 | .One.bit2.high = 1, 154 | 155 | .Tail.repeat = 0, 156 | .Tail.bit1.low = 0, 157 | .Tail.bit1.high = 0, 158 | .Tail.bit2.low = 0, 159 | .Tail.bit2.high = 0, 160 | 161 | .nGuard = 0 162 | }; 163 | 164 | 165 | #endif /* INC_RF_BARRIER_TIMINGS_H_ */ 166 | -------------------------------------------------------------------------------- /example/test433/Core/Inc/rf-barrier-timings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rf-barrier-timings.h 3 | * 4 | * Created on: Nov 21, 2019 5 | * Author: Bulanov Konstantin 6 | */ 7 | 8 | #ifndef INC_RF_BARRIER_TIMINGS_H_ 9 | #define INC_RF_BARRIER_TIMINGS_H_ 10 | 11 | // =============Receive======== 12 | // HCS301 13 | RF_t hcs301 = { 14 | .Invert= 1, 15 | .Te = 400, 16 | .TeDrv = 50, 17 | .MaxPause = 20000, 18 | .CodeLengh = 66, 19 | .PreambleLenght = 23, 20 | .HeaderLenght= 10 21 | }; 22 | 23 | // Came 12 24 | RF_t came12 = { 25 | .Invert= 0, 26 | .Te = 320, 27 | .TeDrv = 50, 28 | .MaxPause = 20000, 29 | .CodeLengh = 12, 30 | .PreambleLenght = 0, 31 | .HeaderLenght= 1 32 | }; 33 | 34 | // Nice 12 35 | RF_t nice12 = { 36 | .Invert= 0, 37 | .Te = 700, 38 | .TeDrv = 50, 39 | .MaxPause = 20000, 40 | .CodeLengh = 12, 41 | .PreambleLenght = 0, 42 | .HeaderLenght= 1 43 | }; 44 | 45 | 46 | // ========== Transmit =========== 47 | Protocol_t proto_hcs301 ={ 48 | .nRepeatTransmit = 1, // Repeat code 49 | .PulseLength = 400, 50 | .CodeLength = 66, 51 | .Invert = 1, // Start from HIGH 52 | 53 | .Preamble.repeat = 12, 54 | .Preamble.bit1.low = 1, 55 | .Preamble.bit1.high = 1, 56 | .Preamble.bit2.low = 0, 57 | .Preamble.bit2.high = 0, 58 | 59 | .Header.repeat = 9, // 9 not 10 when one low pulse send from Preamble. 60 | .Header.bit1.low = 1, 61 | .Header.bit1.high = 0, 62 | .Header.bit2.low = 0, 63 | .Header.bit2.high = 0, 64 | 65 | .Zero.repeat = 1, 66 | .Zero.bit1.low = 1, 67 | .Zero.bit1.high = 2, 68 | .Zero.bit2.low = 0, 69 | .Zero.bit2.high = 0, 70 | 71 | .One.repeat = 1, 72 | .One.bit1.low = 2, 73 | .One.bit1.high = 1, 74 | .One.bit2.low = 0, 75 | .One.bit2.high = 0, 76 | 77 | .Tail.repeat = 2, // 64 Code + 2 Tail = 66 bit (Keeloq) 78 | .Tail.bit1.low = 2, 79 | .Tail.bit1.high = 1, 80 | .Tail.bit2.low = 0, 81 | .Tail.bit2.high = 0, 82 | 83 | .nGuard = 39 84 | }; 85 | 86 | Protocol_t proto_came12 ={ 87 | .nRepeatTransmit = 4, // Repeat code 88 | .PulseLength = 320, 89 | .CodeLength = 12, 90 | .Invert = 0, 91 | 92 | .Preamble.repeat = 36, 93 | .Preamble.bit1.low = 1, 94 | .Preamble.bit1.high = 0, 95 | .Preamble.bit2.low = 0, 96 | .Preamble.bit2.high = 0, 97 | 98 | .Header.repeat = 1, 99 | .Header.bit1.low = 0, 100 | .Header.bit1.high = 1, 101 | .Header.bit2.low = 0, 102 | .Header.bit2.high = 0, 103 | 104 | .Zero.repeat = 1, 105 | .Zero.bit1.low = 1, 106 | .Zero.bit1.high = 2, 107 | .Zero.bit2.low = 0, 108 | .Zero.bit2.high = 0, 109 | 110 | .One.repeat = 1, 111 | .One.bit1.low = 2, 112 | .One.bit1.high = 1, 113 | .One.bit2.low = 0, 114 | .One.bit2.high = 0, 115 | 116 | .Tail.repeat = 0, 117 | .Tail.bit1.low = 0, 118 | .Tail.bit1.high = 0, 119 | .Tail.bit2.low = 0, 120 | .Tail.bit2.high = 0, 121 | 122 | .nGuard = 0 123 | }; 124 | 125 | Protocol_t proto_came24 ={ 126 | .nRepeatTransmit = 4, // Repeat code 127 | .PulseLength = 320, 128 | .CodeLength = 24, 129 | .Invert = 0, 130 | 131 | .Preamble.repeat = 36, 132 | .Preamble.bit1.low = 1, 133 | .Preamble.bit1.high = 0, 134 | .Preamble.bit2.low = 0, 135 | .Preamble.bit2.high = 0, 136 | 137 | .Header.repeat = 1, 138 | .Header.bit1.low = 0, 139 | .Header.bit1.high = 1, 140 | .Header.bit2.low = 0, 141 | .Header.bit2.high = 0, 142 | 143 | .Zero.repeat = 1, 144 | .Zero.bit1.low = 1, 145 | .Zero.bit1.high = 2, 146 | .Zero.bit2.low = 1, 147 | .Zero.bit2.high = 2, 148 | 149 | .One.repeat = 1, 150 | .One.bit1.low = 2, 151 | .One.bit1.high = 1, 152 | .One.bit2.low = 2, 153 | .One.bit2.high = 1, 154 | 155 | .Tail.repeat = 0, 156 | .Tail.bit1.low = 0, 157 | .Tail.bit1.high = 0, 158 | .Tail.bit2.low = 0, 159 | .Tail.bit2.high = 0, 160 | 161 | .nGuard = 0 162 | }; 163 | 164 | 165 | #endif /* INC_RF_BARRIER_TIMINGS_H_ */ 166 | -------------------------------------------------------------------------------- /example/test433/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 | -------------------------------------------------------------------------------- /example/test433/Core/Src/syscalls.c: -------------------------------------------------------------------------------- 1 | /** 2 | ***************************************************************************** 3 | ** 4 | ** File : syscalls.c 5 | ** 6 | ** Author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** Abstract : STM32CubeIDE Minimal System calls file 9 | ** 10 | ** For more information about which c-functions 11 | ** need which of these lowlevel functions 12 | ** please consult the Newlib libc-manual 13 | ** 14 | ** Environment : STM32CubeIDE MCU 15 | ** 16 | ** Distribution: The file is distributed as is, without any warranty 17 | ** of any kind. 18 | ** 19 | ***************************************************************************** 20 | ** 21 | **

© COPYRIGHT(c) 2018 STMicroelectronics

22 | ** 23 | ** Redistribution and use in source and binary forms, with or without modification, 24 | ** are permitted provided that the following conditions are met: 25 | ** 1. Redistributions of source code must retain the above copyright notice, 26 | ** this list of conditions and the following disclaimer. 27 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 28 | ** this list of conditions and the following disclaimer in the documentation 29 | ** and/or other materials provided with the distribution. 30 | ** 3. Neither the name of STMicroelectronics nor the names of its contributors 31 | ** may be used to endorse or promote products derived from this software 32 | ** without specific prior written permission. 33 | ** 34 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 35 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 36 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 38 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 39 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 40 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 41 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 42 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 43 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 44 | ** 45 | ** 46 | ***************************************************************************** 47 | */ 48 | 49 | /* Includes */ 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | 59 | 60 | /* Variables */ 61 | //#undef errno 62 | extern int errno; 63 | extern int __io_putchar(int ch) __attribute__((weak)); 64 | extern int __io_getchar(void) __attribute__((weak)); 65 | 66 | register char * stack_ptr asm("sp"); 67 | 68 | char *__env[1] = { 0 }; 69 | char **environ = __env; 70 | 71 | 72 | /* Functions */ 73 | void initialise_monitor_handles() 74 | { 75 | } 76 | 77 | int _getpid(void) 78 | { 79 | return 1; 80 | } 81 | 82 | int _kill(int pid, int sig) 83 | { 84 | errno = EINVAL; 85 | return -1; 86 | } 87 | 88 | void _exit (int status) 89 | { 90 | _kill(status, -1); 91 | while (1) {} /* Make sure we hang here */ 92 | } 93 | 94 | __attribute__((weak)) int _read(int file, char *ptr, int len) 95 | { 96 | int DataIdx; 97 | 98 | for (DataIdx = 0; DataIdx < len; DataIdx++) 99 | { 100 | *ptr++ = __io_getchar(); 101 | } 102 | 103 | return len; 104 | } 105 | 106 | __attribute__((weak)) int _write(int file, char *ptr, int len) 107 | { 108 | int DataIdx; 109 | 110 | for (DataIdx = 0; DataIdx < len; DataIdx++) 111 | { 112 | __io_putchar(*ptr++); 113 | } 114 | return len; 115 | } 116 | 117 | int _close(int file) 118 | { 119 | return -1; 120 | } 121 | 122 | 123 | int _fstat(int file, struct stat *st) 124 | { 125 | st->st_mode = S_IFCHR; 126 | return 0; 127 | } 128 | 129 | int _isatty(int file) 130 | { 131 | return 1; 132 | } 133 | 134 | int _lseek(int file, int ptr, int dir) 135 | { 136 | return 0; 137 | } 138 | 139 | int _open(char *path, int flags, ...) 140 | { 141 | /* Pretend like we always fail */ 142 | return -1; 143 | } 144 | 145 | int _wait(int *status) 146 | { 147 | errno = ECHILD; 148 | return -1; 149 | } 150 | 151 | int _unlink(char *name) 152 | { 153 | errno = ENOENT; 154 | return -1; 155 | } 156 | 157 | int _times(struct tms *buf) 158 | { 159 | return -1; 160 | } 161 | 162 | int _stat(char *file, struct stat *st) 163 | { 164 | st->st_mode = S_IFCHR; 165 | return 0; 166 | } 167 | 168 | int _link(char *old, char *new) 169 | { 170 | errno = EMLINK; 171 | return -1; 172 | } 173 | 174 | int _fork(void) 175 | { 176 | errno = EAGAIN; 177 | return -1; 178 | } 179 | 180 | int _execve(char *name, char **argv, char **env) 181 | { 182 | errno = ENOMEM; 183 | return -1; 184 | } 185 | -------------------------------------------------------------------------------- /example/test433/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) 2019 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 | -------------------------------------------------------------------------------- /example/test433/test433.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | File.Version=6 3 | KeepUserPlacement=false 4 | Mcu.Family=STM32F1 5 | Mcu.IP0=NVIC 6 | Mcu.IP1=RCC 7 | Mcu.IP2=SYS 8 | Mcu.IP3=USB 9 | Mcu.IP4=USB_DEVICE 10 | Mcu.IPNb=5 11 | Mcu.Name=STM32F103C(8-B)Tx 12 | Mcu.Package=LQFP48 13 | Mcu.Pin0=PC13-TAMPER-RTC 14 | Mcu.Pin1=PC15-OSC32_OUT 15 | Mcu.Pin10=PA14 16 | Mcu.Pin11=VP_SYS_VS_Systick 17 | Mcu.Pin12=VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS 18 | Mcu.Pin2=PD0-OSC_IN 19 | Mcu.Pin3=PD1-OSC_OUT 20 | Mcu.Pin4=PA7 21 | Mcu.Pin5=PB0 22 | Mcu.Pin6=PB12 23 | Mcu.Pin7=PA11 24 | Mcu.Pin8=PA12 25 | Mcu.Pin9=PA13 26 | Mcu.PinsNb=13 27 | Mcu.ThirdPartyNb=0 28 | Mcu.UserConstants= 29 | Mcu.UserName=STM32F103C8Tx 30 | MxCube.Version=5.4.0 31 | MxDb.Version=DB.5.0.40 32 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 33 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false 34 | NVIC.EXTI15_10_IRQn=true\:0\:0\:false\:false\:true\:true\:true 35 | NVIC.ForceEnableDMAVector=true 36 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 37 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false 38 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false 39 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false 40 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 41 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false 42 | NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true 43 | NVIC.USB_LP_CAN1_RX0_IRQn=true\:0\:0\:false\:false\:true\:false\:true 44 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 45 | PA11.Mode=Device 46 | PA11.Signal=USB_DM 47 | PA12.Mode=Device 48 | PA12.Signal=USB_DP 49 | PA13.Mode=Serial_Wire 50 | PA13.Signal=SYS_JTMS-SWDIO 51 | PA14.Mode=Serial_Wire 52 | PA14.Signal=SYS_JTCK-SWCLK 53 | PA7.GPIOParameters=GPIO_Label 54 | PA7.GPIO_Label=RX433PWR 55 | PA7.Locked=true 56 | PA7.Signal=GPIO_Output 57 | PB0.GPIOParameters=GPIO_Label 58 | PB0.GPIO_Label=TX433PWR 59 | PB0.Locked=true 60 | PB0.Signal=GPIO_Output 61 | PB12.GPIOParameters=GPIO_Label 62 | PB12.GPIO_Label=TX433 63 | PB12.Locked=true 64 | PB12.Signal=GPIO_Output 65 | PC13-TAMPER-RTC.GPIOParameters=GPIO_Label 66 | PC13-TAMPER-RTC.GPIO_Label=LED 67 | PC13-TAMPER-RTC.Locked=true 68 | PC13-TAMPER-RTC.Signal=GPIO_Output 69 | PC15-OSC32_OUT.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI 70 | PC15-OSC32_OUT.GPIO_Label=RX433 71 | PC15-OSC32_OUT.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING 72 | PC15-OSC32_OUT.GPIO_PuPd=GPIO_NOPULL 73 | PC15-OSC32_OUT.Locked=true 74 | PC15-OSC32_OUT.Signal=GPXTI15 75 | PCC.Checker=false 76 | PCC.Line=STM32F103 77 | PCC.MCU=STM32F103C(8-B)Tx 78 | PCC.PartNumber=STM32F103C8Tx 79 | PCC.Seq0=0 80 | PCC.Series=STM32F1 81 | PCC.Temperature=25 82 | PCC.Vdd=3.3 83 | PD0-OSC_IN.Mode=HSE-External-Oscillator 84 | PD0-OSC_IN.Signal=RCC_OSC_IN 85 | PD1-OSC_OUT.Mode=HSE-External-Oscillator 86 | PD1-OSC_OUT.Signal=RCC_OSC_OUT 87 | PinOutPanel.RotationAngle=0 88 | ProjectManager.AskForMigrate=true 89 | ProjectManager.BackupPrevious=false 90 | ProjectManager.CompilerOptimize=6 91 | ProjectManager.ComputerToolchain=false 92 | ProjectManager.CoupleFile=true 93 | ProjectManager.CustomerFirmwarePackage= 94 | ProjectManager.DefaultFWLocation=true 95 | ProjectManager.DeletePrevious=true 96 | ProjectManager.DeviceId=STM32F103C8Tx 97 | ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.8.0 98 | ProjectManager.FreePins=false 99 | ProjectManager.HalAssertFull=false 100 | ProjectManager.HeapSize=0x400 101 | ProjectManager.KeepUserCode=true 102 | ProjectManager.LastFirmware=true 103 | ProjectManager.LibraryCopy=1 104 | ProjectManager.MainLocation=Core/Src 105 | ProjectManager.NoMain=false 106 | ProjectManager.PreviousToolchain= 107 | ProjectManager.ProjectBuild=false 108 | ProjectManager.ProjectFileName=test433.ioc 109 | ProjectManager.ProjectName=test433 110 | ProjectManager.StackSize=0x800 111 | ProjectManager.TargetToolchain=STM32CubeIDE 112 | ProjectManager.ToolChainLocation= 113 | ProjectManager.UnderRoot=true 114 | ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true 115 | RCC.ADCFreqValue=36000000 116 | RCC.AHBFreq_Value=72000000 117 | RCC.APB1CLKDivider=RCC_HCLK_DIV2 118 | RCC.APB1Freq_Value=36000000 119 | RCC.APB1TimFreq_Value=72000000 120 | RCC.APB2Freq_Value=72000000 121 | RCC.APB2TimFreq_Value=72000000 122 | RCC.FCLKCortexFreq_Value=72000000 123 | RCC.FamilyName=M 124 | RCC.HCLKFreq_Value=72000000 125 | 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,USBPrescaler,VCOOutput2Freq_Value 126 | RCC.MCOFreq_Value=72000000 127 | RCC.PLLCLKFreq_Value=72000000 128 | RCC.PLLMCOFreq_Value=36000000 129 | RCC.PLLMUL=RCC_PLL_MUL9 130 | RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE 131 | RCC.SYSCLKFreq_VALUE=72000000 132 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK 133 | RCC.TimSysFreq_Value=72000000 134 | RCC.USBFreq_Value=48000000 135 | RCC.USBPrescaler=RCC_USBCLKSOURCE_PLL_DIV1_5 136 | RCC.VCOOutput2Freq_Value=8000000 137 | SH.GPXTI15.0=GPIO_EXTI15 138 | SH.GPXTI15.ConfNb=1 139 | USB_DEVICE.CLASS_NAME_FS=CDC 140 | USB_DEVICE.IPParameters=VirtualMode,VirtualModeFS,CLASS_NAME_FS 141 | USB_DEVICE.VirtualMode=Cdc 142 | USB_DEVICE.VirtualModeFS=Cdc_FS 143 | VP_SYS_VS_Systick.Mode=SysTick 144 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 145 | VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Mode=CDC_FS 146 | VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Signal=USB_DEVICE_VS_USB_DEVICE_CDC_FS 147 | board=custom 148 | isbadioc=false 149 | -------------------------------------------------------------------------------- /example/test433/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 | -------------------------------------------------------------------------------- /example/test433/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 | -------------------------------------------------------------------------------- /example/test433/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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # STM32 HAL library for reading and sending code for radio frequency (RF) barrier (Came, Nice) simple code 12, 24 bit and HCS301 with keeloq 66 bit. 2 | 3 | ## English note 4 | A simple C library (STM32 HAL) for reading and sending code for radio frequency (RF) barrier (Came, Nice) simple code 12, 24 bit and HCS301 with keeloq 66 bit. 5 | This lib Gate use for control automation garage door and road barriers. Something similar to the rc-switch project https://github.com/sui77/rc-switch. 6 | 7 | Config you RXPORT and PIN with GPIO_EXTI: 8 | - External Interrupt Mode with Rising/Falling edge trigger detection; 9 | - no pull up no pull down. 10 | 11 | and add NVIC global interrupt for you RXPORT. 12 | 13 | Copy the library header and source file to the appropriate project directories (Inc, Src). 14 | 15 | Config you RXPORT and TXPORT on rf-barrier.h file 16 | ``` 17 | // ======= Config section ============= 18 | #define TXPORT TX433_GPIO_Port 19 | #define TXPIN TX433_Pin 20 | 21 | #define RXPORT GPIOC 22 | #define RXPIN GPIO_PIN_15 23 | // ==================================== 24 | ``` 25 | In the head file of your project (main.c), include the header file 26 | ``` 27 | / * USER CODE BEGIN Includes * / 28 | #include "micros.h" // https://github.com/leech001/micros 29 | #include "rf-barrier.h" 30 | / * USER CODE END Includes * / 31 | ``` 32 | add RXPIN receive interrupt 33 | ``` 34 | /* USER CODE BEGIN 0 */ 35 | void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { 36 | switch(GPIO_Pin){ 37 | case RXPIN: 38 | { 39 | RX433_Int(); 40 | } 41 | } 42 | } 43 | /* USER CODE END 0 */ 44 | ``` 45 | add in main function section for initial initialization of the DWT (Data Watchpoint and Trace unit) (https://github.com/leech001/micros) 46 | ``` 47 | / * USER CODE BEGIN 2 * / 48 | DWT_Init(); 49 | / * USER CODE END 2 * / 50 | ``` 51 | On this project setup is ready. 52 | After starting the program, information (code and etc.) will be available through the hcs301, came12, came24 structure 53 | ``` 54 | ... 55 | hcs301.SerialNum 56 | came12.SerialNum 57 | ... 58 | ``` 59 | To send binary code ("1001010") use function void RF_send_bin(Protocol_t* protocol, const char* sCodeWord); 60 | ``` 61 | RF_send_bin(&proto_came12, "111111111111"); 62 | ``` 63 | 64 | To send code ("1234") use function void RF_send(Protocol_t* protocol, uint64_t code); 65 | ``` 66 | RF_send(&proto_came12, 1234); 67 | ``` 68 | 69 | If RF_DUBUG is define on rf-barrier.h file, you can watch on USB serial port radio frequency (RF) diagram 70 | ``` 71 | Came 12 ____________________________________-_--_--_--_--_--_--_--_--_--_--_--_-- 72 | HCS301 -_-_-_-_-_-_-_-_-_-_-_-__________--_--_--_--_--_--_--_--_--_--_--_--_--_... 73 | ... 74 | ``` 75 | P.S. Came and Nice code algorithm from http://phreakerclub.com/forum/showthread.php?t=126 76 | 77 | ## Russian note 78 | Простая библиотека на Си (STM32 HAL) для считывания и отправки кодов от пультов (ворота, шлагбаумы и др.) как с обычной кодировкой Came, Nice 12 и 24 бит. так и кодировкой HCS301 с keeloq (пример https://ironlogic.ru/il_new.nsf/htm/ru_il100). 79 | Чем то похожа на проект rc-switch https://github.com/sui77/rc-switch 80 | 81 | Сконфигурируйте ваш порт и пин куда подключен модуль для приема кодов как порт с внешним прерыванием (GPIO_EXTI): 82 | - External Interrupt Mode with Rising/Falling edge trigger detection; 83 | - no pull up no pull down. 84 | 85 | Включите глобальное прерывание для данного порта (NVIC). 86 | 87 | Скопируйте заголовочный и исходный файл библиотеки в соответствующие директории проекта (Inc, Src). 88 | 89 | Определение ваши PORT и PIN порты куда подключен считыватель в файле rf-barrier.h file 90 | ``` 91 | // ======= Config section ============= 92 | #define TXPORT TX433_GPIO_Port 93 | #define TXPIN TX433_Pin 94 | 95 | #define RXPORT GPIOC 96 | #define RXPIN GPIO_PIN_15 97 | // ==================================== 98 | ``` 99 | В головном файл вашего проекта (main.c) подключите заголовочные файлы. 100 | ``` 101 | /* USER CODE BEGIN Includes */ 102 | #include "micros.h" // https://github.com/leech001/micros 103 | #include "rf-barrier.h" 104 | /* USER CODE END Includes */ 105 | ``` 106 | в секцию добавьте вызов прерывания для вашего пина где висит устройство для приема 107 | ``` 108 | /* USER CODE BEGIN 0 */ 109 | void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { 110 | switch(GPIO_Pin){ 111 | case RXPIN: 112 | { 113 | RX433_Int(); 114 | } 115 | } 116 | } 117 | /* USER CODE END 0 */ 118 | ``` 119 | добавьте в секцию функции int main(void) инициализацию DWT (Data Watchpoint and Trace unit) (https://github.com/leech001/micros) 120 | ``` 121 | /* USER CODE BEGIN 2 */ 122 | DWT_Init(); 123 | /* USER CODE END 2 */ 124 | ``` 125 | На этом настройка проекта закончена. 126 | После запуска программы информация о кодах и тд. от пультов поступающих при нажатии кнопок будет доступна через структуры hcs301, came12, came24. 127 | ``` 128 | ... 129 | hcs301.SerialNum 130 | came12.SerialNum 131 | ... 132 | ``` 133 | Для отправки бинарного кода ("1001010") используйте функцию void RF_send_bin(Protocol_t* protocol, const char* sCodeWord); 134 | ``` 135 | RF_send_bin(&proto_came12, "111111111111"); 136 | ``` 137 | 138 | Для отправки обычного кода ("1234") используйте функцию void RF_send(Protocol_t* protocol, uint64_t code); 139 | ``` 140 | RF_send(&proto_came12, 1234); 141 | ``` 142 | 143 | Если в файле rf-barrier.h определен дебагер (RF_DUBUG) вы сможете наблюдать через USB порт что то похожее на частотную радиограмму как это отправляется в эфир. 144 | Ничего умнее для визуализации сигнала придумать не смог :) 145 | ``` 146 | Came 12 ____________________________________-_--_--_--_--_--_--_--_--_--_--_--_-- 147 | HCS301 -_-_-_-_-_-_-_-_-_-_-_-__________--_--_--_--_--_--_--_--_--_--_--_--_--_... 148 | ... 149 | ``` 150 | P.S. Алгоритмы кодировок взяты вот от сюда http://phreakerclub.com/forum/showthread.php?t=126 151 | Отдельное спасибо CodePerfect за подробный разбор. 152 | -------------------------------------------------------------------------------- /example/test433/test433 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 | -------------------------------------------------------------------------------- /example/test433/STM32F103C8TX_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** File : LinkerScript.ld 5 | ** 6 | ** Author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** Abstract : Linker script for STM32F103C8Tx Device from STM32F1 series 9 | ** 64Kbytes FLASH 10 | ** 20Kbytes RAM 11 | ** 12 | ** Set heap size, stack size and stack location according 13 | ** to application requirements. 14 | ** 15 | ** Set memory bank area and size if external memory is used. 16 | ** 17 | ** Target : STMicroelectronics STM32 18 | ** 19 | ** Distribution: The file is distributed as is without any warranty 20 | ** of any kind. 21 | ** 22 | ***************************************************************************** 23 | ** @attention 24 | ** 25 | **

© COPYRIGHT(c) 2019 STMicroelectronics

26 | ** 27 | ** Redistribution and use in source and binary forms, with or without modification, 28 | ** are permitted provided that the following conditions are met: 29 | ** 1. Redistributions of source code must retain the above copyright notice, 30 | ** this list of conditions and the following disclaimer. 31 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 32 | ** this list of conditions and the following disclaimer in the documentation 33 | ** and/or other materials provided with the distribution. 34 | ** 3. Neither the name of STMicroelectronics nor the names of its contributors 35 | ** may be used to endorse or promote products derived from this software 36 | ** without specific prior written permission. 37 | ** 38 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 41 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 42 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 43 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 44 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 45 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 47 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | ** 49 | ***************************************************************************** 50 | */ 51 | 52 | /* Entry Point */ 53 | ENTRY(Reset_Handler) 54 | 55 | /* Highest address of the user mode stack */ 56 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ 57 | 58 | _Min_Heap_Size = 0x400 ; /* required amount of heap */ 59 | _Min_Stack_Size = 0x800 ; /* required amount of stack */ 60 | 61 | /* Memories definition */ 62 | MEMORY 63 | { 64 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K 65 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 64K 66 | } 67 | 68 | /* Sections */ 69 | SECTIONS 70 | { 71 | /* The startup code into "FLASH" Rom type memory */ 72 | .isr_vector : 73 | { 74 | . = ALIGN(4); 75 | KEEP(*(.isr_vector)) /* Startup code */ 76 | . = ALIGN(4); 77 | } >FLASH 78 | 79 | /* The program code and other data into "FLASH" Rom type memory */ 80 | .text : 81 | { 82 | . = ALIGN(4); 83 | *(.text) /* .text sections (code) */ 84 | *(.text*) /* .text* sections (code) */ 85 | *(.glue_7) /* glue arm to thumb code */ 86 | *(.glue_7t) /* glue thumb to arm code */ 87 | *(.eh_frame) 88 | 89 | KEEP (*(.init)) 90 | KEEP (*(.fini)) 91 | 92 | . = ALIGN(4); 93 | _etext = .; /* define a global symbols at end of code */ 94 | } >FLASH 95 | 96 | /* Constant data into "FLASH" Rom type memory */ 97 | .rodata : 98 | { 99 | . = ALIGN(4); 100 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 101 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 102 | . = ALIGN(4); 103 | } >FLASH 104 | 105 | .ARM.extab : { 106 | . = ALIGN(4); 107 | *(.ARM.extab* .gnu.linkonce.armextab.*) 108 | . = ALIGN(4); 109 | } >FLASH 110 | 111 | .ARM : { 112 | . = ALIGN(4); 113 | __exidx_start = .; 114 | *(.ARM.exidx*) 115 | __exidx_end = .; 116 | . = ALIGN(4); 117 | } >FLASH 118 | 119 | .preinit_array : 120 | { 121 | . = ALIGN(4); 122 | PROVIDE_HIDDEN (__preinit_array_start = .); 123 | KEEP (*(.preinit_array*)) 124 | PROVIDE_HIDDEN (__preinit_array_end = .); 125 | . = ALIGN(4); 126 | } >FLASH 127 | 128 | .init_array : 129 | { 130 | . = ALIGN(4); 131 | PROVIDE_HIDDEN (__init_array_start = .); 132 | KEEP (*(SORT(.init_array.*))) 133 | KEEP (*(.init_array*)) 134 | PROVIDE_HIDDEN (__init_array_end = .); 135 | . = ALIGN(4); 136 | } >FLASH 137 | 138 | .fini_array : 139 | { 140 | . = ALIGN(4); 141 | PROVIDE_HIDDEN (__fini_array_start = .); 142 | KEEP (*(SORT(.fini_array.*))) 143 | KEEP (*(.fini_array*)) 144 | PROVIDE_HIDDEN (__fini_array_end = .); 145 | . = ALIGN(4); 146 | } >FLASH 147 | 148 | /* Used by the startup to initialize data */ 149 | _sidata = LOADADDR(.data); 150 | 151 | /* Initialized data sections into "RAM" Ram type memory */ 152 | .data : 153 | { 154 | . = ALIGN(4); 155 | _sdata = .; /* create a global symbol at data start */ 156 | *(.data) /* .data sections */ 157 | *(.data*) /* .data* sections */ 158 | 159 | . = ALIGN(4); 160 | _edata = .; /* define a global symbol at data end */ 161 | 162 | } >RAM AT> FLASH 163 | 164 | /* Uninitialized data section into "RAM" Ram type memory */ 165 | . = ALIGN(4); 166 | .bss : 167 | { 168 | /* This is used by the startup in order to initialize the .bss section */ 169 | _sbss = .; /* define a global symbol at bss start */ 170 | __bss_start__ = _sbss; 171 | *(.bss) 172 | *(.bss*) 173 | *(COMMON) 174 | 175 | . = ALIGN(4); 176 | _ebss = .; /* define a global symbol at bss end */ 177 | __bss_end__ = _ebss; 178 | } >RAM 179 | 180 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ 181 | ._user_heap_stack : 182 | { 183 | . = ALIGN(8); 184 | PROVIDE ( end = . ); 185 | PROVIDE ( _end = . ); 186 | . = . + _Min_Heap_Size; 187 | . = . + _Min_Stack_Size; 188 | . = ALIGN(8); 189 | } >RAM 190 | 191 | /* Remove information from the compiler libraries */ 192 | /DISCARD/ : 193 | { 194 | libc.a ( * ) 195 | libm.a ( * ) 196 | libgcc.a ( * ) 197 | } 198 | 199 | .ARM.attributes 0 : { *(.ARM.attributes) } 200 | } 201 | -------------------------------------------------------------------------------- /example/test433/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) 2019 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 "usb_device.h" 24 | #include "gpio.h" 25 | 26 | /* Private includes ----------------------------------------------------------*/ 27 | /* USER CODE BEGIN Includes */ 28 | #include "micros.h" 29 | #include "rf-barrier.h" 30 | #include "usbd_cdc_if.h" 31 | /* USER CODE END Includes */ 32 | 33 | /* Private typedef -----------------------------------------------------------*/ 34 | /* USER CODE BEGIN PTD */ 35 | 36 | /* USER CODE END PTD */ 37 | 38 | /* Private define ------------------------------------------------------------*/ 39 | /* USER CODE BEGIN PD */ 40 | /* USER CODE END PD */ 41 | 42 | /* Private macro -------------------------------------------------------------*/ 43 | /* USER CODE BEGIN PM */ 44 | 45 | /* USER CODE END PM */ 46 | 47 | /* Private variables ---------------------------------------------------------*/ 48 | 49 | /* USER CODE BEGIN PV */ 50 | 51 | /* USER CODE END PV */ 52 | 53 | /* Private function prototypes -----------------------------------------------*/ 54 | void SystemClock_Config(void); 55 | /* USER CODE BEGIN PFP */ 56 | 57 | /* USER CODE END PFP */ 58 | 59 | /* Private user code ---------------------------------------------------------*/ 60 | /* USER CODE BEGIN 0 */ 61 | 62 | void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { 63 | switch(GPIO_Pin){ 64 | case RXPIN: 65 | { 66 | RX433_Int(); 67 | } 68 | } 69 | } 70 | 71 | /* USER CODE END 0 */ 72 | 73 | /** 74 | * @brief The application entry point. 75 | * @retval int 76 | */ 77 | int main(void) 78 | { 79 | /* USER CODE BEGIN 1 */ 80 | 81 | /* USER CODE END 1 */ 82 | 83 | 84 | /* MCU Configuration--------------------------------------------------------*/ 85 | 86 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 87 | HAL_Init(); 88 | 89 | /* USER CODE BEGIN Init */ 90 | 91 | /* USER CODE END Init */ 92 | 93 | /* Configure the system clock */ 94 | SystemClock_Config(); 95 | 96 | /* USER CODE BEGIN SysInit */ 97 | 98 | /* USER CODE END SysInit */ 99 | 100 | /* Initialize all configured peripherals */ 101 | MX_GPIO_Init(); 102 | MX_USB_DEVICE_Init(); 103 | /* USER CODE BEGIN 2 */ 104 | 105 | DWT_Init(); 106 | 107 | // came12_brute(); 108 | 109 | /* USER CODE END 2 */ 110 | 111 | /* Infinite loop */ 112 | /* USER CODE BEGIN WHILE */ 113 | while (1) 114 | { 115 | 116 | RF_send_bin(&proto_came12, "000000000000"); 117 | RF_send_bin(&proto_came12, "111111111111"); 118 | 119 | RF_send(&proto_came12, 0); 120 | RF_send(&proto_came12, 1); 121 | RF_send(&proto_came12, 2); 122 | RF_send(&proto_came12, 3); 123 | RF_send(&proto_came12, 4095); 124 | 125 | RF_send(&proto_came24, 0); 126 | RF_send(&proto_came24, 1); 127 | RF_send(&proto_came24, 2); 128 | RF_send(&proto_came24, 3); 129 | RF_send(&proto_came24, 16777215); 130 | 131 | RF_send(&proto_hcs301, 0); 132 | RF_send(&proto_hcs301, 1); 133 | RF_send(&proto_hcs301, 2); 134 | RF_send(&proto_hcs301, 3); 135 | RF_send(&proto_hcs301, 18446744073709551615); 136 | 137 | HAL_Delay(10000); 138 | 139 | 140 | /* USER CODE END WHILE */ 141 | 142 | /* USER CODE BEGIN 3 */ 143 | } 144 | /* USER CODE END 3 */ 145 | } 146 | 147 | /** 148 | * @brief System Clock Configuration 149 | * @retval None 150 | */ 151 | void SystemClock_Config(void) 152 | { 153 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; 154 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; 155 | RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; 156 | 157 | /** Initializes the CPU, AHB and APB busses clocks 158 | */ 159 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; 160 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; 161 | RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; 162 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; 163 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 164 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; 165 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; 166 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 167 | { 168 | Error_Handler(); 169 | } 170 | /** Initializes the CPU, AHB and APB busses clocks 171 | */ 172 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 173 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; 174 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 175 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 176 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; 177 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; 178 | 179 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) 180 | { 181 | Error_Handler(); 182 | } 183 | PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; 184 | PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5; 185 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) 186 | { 187 | Error_Handler(); 188 | } 189 | } 190 | 191 | /* USER CODE BEGIN 4 */ 192 | 193 | /* USER CODE END 4 */ 194 | 195 | /** 196 | * @brief This function is executed in case of error occurrence. 197 | * @retval None 198 | */ 199 | void Error_Handler(void) 200 | { 201 | /* USER CODE BEGIN Error_Handler_Debug */ 202 | /* User can add his own implementation to report the HAL error return state */ 203 | 204 | /* USER CODE END Error_Handler_Debug */ 205 | } 206 | 207 | #ifdef USE_FULL_ASSERT 208 | /** 209 | * @brief Reports the name of the source file and the source line number 210 | * where the assert_param error has occurred. 211 | * @param file: pointer to the source file name 212 | * @param line: assert_param error line source number 213 | * @retval None 214 | */ 215 | void assert_failed(uint8_t *file, uint32_t line) 216 | { 217 | /* USER CODE BEGIN 6 */ 218 | /* User can add his own implementation to report the file name and line number, 219 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 220 | /* USER CODE END 6 */ 221 | } 222 | #endif /* USE_FULL_ASSERT */ 223 | 224 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 225 | -------------------------------------------------------------------------------- /example/test433/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) 2019 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 | /* USER CODE BEGIN EV */ 61 | 62 | /* USER CODE END EV */ 63 | 64 | /******************************************************************************/ 65 | /* Cortex-M3 Processor Interruption and Exception Handlers */ 66 | /******************************************************************************/ 67 | /** 68 | * @brief This function handles Non maskable interrupt. 69 | */ 70 | void NMI_Handler(void) 71 | { 72 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 73 | 74 | /* USER CODE END NonMaskableInt_IRQn 0 */ 75 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 76 | 77 | /* USER CODE END NonMaskableInt_IRQn 1 */ 78 | } 79 | 80 | /** 81 | * @brief This function handles Hard fault interrupt. 82 | */ 83 | void HardFault_Handler(void) 84 | { 85 | /* USER CODE BEGIN HardFault_IRQn 0 */ 86 | 87 | /* USER CODE END HardFault_IRQn 0 */ 88 | while (1) 89 | { 90 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */ 91 | /* USER CODE END W1_HardFault_IRQn 0 */ 92 | } 93 | } 94 | 95 | /** 96 | * @brief This function handles Memory management fault. 97 | */ 98 | void MemManage_Handler(void) 99 | { 100 | /* USER CODE BEGIN MemoryManagement_IRQn 0 */ 101 | 102 | /* USER CODE END MemoryManagement_IRQn 0 */ 103 | while (1) 104 | { 105 | /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ 106 | /* USER CODE END W1_MemoryManagement_IRQn 0 */ 107 | } 108 | } 109 | 110 | /** 111 | * @brief This function handles Prefetch fault, memory access fault. 112 | */ 113 | void BusFault_Handler(void) 114 | { 115 | /* USER CODE BEGIN BusFault_IRQn 0 */ 116 | 117 | /* USER CODE END BusFault_IRQn 0 */ 118 | while (1) 119 | { 120 | /* USER CODE BEGIN W1_BusFault_IRQn 0 */ 121 | /* USER CODE END W1_BusFault_IRQn 0 */ 122 | } 123 | } 124 | 125 | /** 126 | * @brief This function handles Undefined instruction or illegal state. 127 | */ 128 | void UsageFault_Handler(void) 129 | { 130 | /* USER CODE BEGIN UsageFault_IRQn 0 */ 131 | 132 | /* USER CODE END UsageFault_IRQn 0 */ 133 | while (1) 134 | { 135 | /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ 136 | /* USER CODE END W1_UsageFault_IRQn 0 */ 137 | } 138 | } 139 | 140 | /** 141 | * @brief This function handles System service call via SWI instruction. 142 | */ 143 | void SVC_Handler(void) 144 | { 145 | /* USER CODE BEGIN SVCall_IRQn 0 */ 146 | 147 | /* USER CODE END SVCall_IRQn 0 */ 148 | /* USER CODE BEGIN SVCall_IRQn 1 */ 149 | 150 | /* USER CODE END SVCall_IRQn 1 */ 151 | } 152 | 153 | /** 154 | * @brief This function handles Debug monitor. 155 | */ 156 | void DebugMon_Handler(void) 157 | { 158 | /* USER CODE BEGIN DebugMonitor_IRQn 0 */ 159 | 160 | /* USER CODE END DebugMonitor_IRQn 0 */ 161 | /* USER CODE BEGIN DebugMonitor_IRQn 1 */ 162 | 163 | /* USER CODE END DebugMonitor_IRQn 1 */ 164 | } 165 | 166 | /** 167 | * @brief This function handles Pendable request for system service. 168 | */ 169 | void PendSV_Handler(void) 170 | { 171 | /* USER CODE BEGIN PendSV_IRQn 0 */ 172 | 173 | /* USER CODE END PendSV_IRQn 0 */ 174 | /* USER CODE BEGIN PendSV_IRQn 1 */ 175 | 176 | /* USER CODE END PendSV_IRQn 1 */ 177 | } 178 | 179 | /** 180 | * @brief This function handles System tick timer. 181 | */ 182 | void SysTick_Handler(void) 183 | { 184 | /* USER CODE BEGIN SysTick_IRQn 0 */ 185 | 186 | /* USER CODE END SysTick_IRQn 0 */ 187 | HAL_IncTick(); 188 | /* USER CODE BEGIN SysTick_IRQn 1 */ 189 | 190 | /* USER CODE END SysTick_IRQn 1 */ 191 | } 192 | 193 | /******************************************************************************/ 194 | /* STM32F1xx Peripheral Interrupt Handlers */ 195 | /* Add here the Interrupt Handlers for the used peripherals. */ 196 | /* For the available peripheral interrupt handler names, */ 197 | /* please refer to the startup file (startup_stm32f1xx.s). */ 198 | /******************************************************************************/ 199 | 200 | /** 201 | * @brief This function handles USB low priority or CAN RX0 interrupts. 202 | */ 203 | void USB_LP_CAN1_RX0_IRQHandler(void) 204 | { 205 | /* USER CODE BEGIN USB_LP_CAN1_RX0_IRQn 0 */ 206 | 207 | /* USER CODE END USB_LP_CAN1_RX0_IRQn 0 */ 208 | HAL_PCD_IRQHandler(&hpcd_USB_FS); 209 | /* USER CODE BEGIN USB_LP_CAN1_RX0_IRQn 1 */ 210 | 211 | /* USER CODE END USB_LP_CAN1_RX0_IRQn 1 */ 212 | } 213 | 214 | /** 215 | * @brief This function handles EXTI line[15:10] interrupts. 216 | */ 217 | void EXTI15_10_IRQHandler(void) 218 | { 219 | /* USER CODE BEGIN EXTI15_10_IRQn 0 */ 220 | 221 | /* USER CODE END EXTI15_10_IRQn 0 */ 222 | HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_15); 223 | /* USER CODE BEGIN EXTI15_10_IRQn 1 */ 224 | 225 | /* USER CODE END EXTI15_10_IRQn 1 */ 226 | } 227 | 228 | /* USER CODE BEGIN 1 */ 229 | 230 | /* USER CODE END 1 */ 231 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 232 | -------------------------------------------------------------------------------- /example/test433/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 | -------------------------------------------------------------------------------- /Src/rf-barrier.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rf-barrier.c 3 | * 4 | * Created on: Nov 21, 2019 5 | * Author: Bulanov Konstantin 6 | * 7 | * Contact information 8 | * ------------------- 9 | * 10 | * e-mail : leech001@gmail.com 11 | * 12 | * 13 | */ 14 | 15 | /* 16 | * |----------------------------------------------------------------------------------------------------------------------------------------------- 17 | * | Copyright (C) Bulanov Konstantin,2019 18 | * | 19 | * | This program is free software: you can redistribute it and/or modify 20 | * | it under the terms of the GNU General Public License as published by 21 | * | the Free Software Foundation, either version 3 of the License, or 22 | * | any later version. 23 | * | 24 | * | This program is distributed in the hope that it will be useful, 25 | * | but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * | GNU General Public License for more details. 28 | * | 29 | * | You should have received a copy of the GNU General Public License 30 | * | along with this program. If not, see . 31 | * | 32 | * | Came and Nice algorithm http://phreakerclub.com/forum/showthread.php?t=126 33 | * |------------------------------------------------------------------------------------------------------------------------------------------------ 34 | */ 35 | 36 | 37 | #include 38 | #include 39 | #include "micros.h" 40 | #include "rf-barrier.h" 41 | #include "rf-barrier-timings.h" 42 | 43 | 44 | #ifdef RF_DEBUG 45 | #include 46 | char str_code[512] = {0,}; 47 | #endif 48 | 49 | 50 | void RF_send_bin(Protocol_t* protocol, const char* sCodeWord) { 51 | uint64_t code = 0; 52 | for (const char* p = sCodeWord; *p; p++) { 53 | code <<= 1ULL; 54 | if (*p != '0'){ 55 | code |= 1ULL; 56 | } 57 | } 58 | RF_send(protocol, code); 59 | } 60 | 61 | void RF_send(Protocol_t* protocol, uint64_t code) { 62 | for (int nRepeat = 0; nRepeat < protocol->nRepeatTransmit; nRepeat++){ 63 | 64 | // Preamble 65 | RF_transmit(protocol->Preamble, protocol->PulseLength, protocol->Invert); 66 | 67 | // Header 68 | RF_transmit(protocol->Header, protocol->PulseLength, protocol->Invert); 69 | 70 | // Code 71 | for (int i = protocol->CodeLength-1; i >= 0; i--){ 72 | if (code & (1ULL << i)){ 73 | RF_transmit(protocol->One, protocol->PulseLength, protocol->Invert); 74 | }else{ 75 | RF_transmit(protocol->Zero, protocol->PulseLength, protocol->Invert); 76 | } 77 | } 78 | 79 | // Tail 80 | RF_transmit(protocol->Tail, protocol->PulseLength, protocol->Invert); 81 | 82 | #ifdef RF_DEBUG 83 | char usb_str[512]={0,}; 84 | sprintf(usb_str,"%s\r\n", str_code); 85 | CDC_Transmit_FS((unsigned char *) usb_str, (uint16_t) strlen(usb_str)); 86 | memset(str_code, '\0', sizeof(str_code)); 87 | #endif 88 | 89 | //Guard delay 90 | if (protocol->nGuard > 0){ 91 | HAL_GPIO_WritePin(TXPORT, TXPIN, GPIO_PIN_RESET); 92 | delay_us(protocol->PulseLength * protocol->nGuard); 93 | } 94 | } 95 | } 96 | 97 | void RF_transmit(Bit_t pulses, uint16_t length, uint8_t invert) { 98 | 99 | uint8_t bits[2][2] = {{pulses.bit1.low, pulses.bit1.high}, 100 | {pulses.bit2.low, pulses.bit2.high}}; 101 | uint8_t PulseOne; 102 | uint8_t PulseTwo; 103 | uint8_t LevelOne; 104 | uint8_t LevelTwo; 105 | 106 | for(int i=0; i < pulses.repeat; i++){ 107 | for (int i_bits = 0; i_bits < 2; i_bits++){ 108 | if(invert == 0){ 109 | PulseOne = bits[i_bits][0]; 110 | PulseTwo = bits[i_bits][1]; 111 | LevelOne = GPIO_PIN_RESET; 112 | LevelTwo = GPIO_PIN_SET; 113 | }else{ 114 | PulseOne = bits[i_bits][1]; 115 | PulseTwo = bits[i_bits][0]; 116 | LevelOne = GPIO_PIN_SET; 117 | LevelTwo = GPIO_PIN_RESET; 118 | } 119 | 120 | if (PulseOne > 0){ 121 | HAL_GPIO_WritePin(TXPORT, TXPIN, LevelOne); 122 | delay_us(length * PulseOne); 123 | 124 | #ifdef RF_DEBUG 125 | for(int i = 0; i < PulseOne; i++) 126 | if(LevelOne == 1){ 127 | sprintf(str_code,"%s-", str_code); 128 | }else{ 129 | sprintf(str_code,"%s_", str_code); 130 | } 131 | #endif 132 | } 133 | if (PulseTwo > 0){ 134 | HAL_GPIO_WritePin(TXPORT, TXPIN, LevelTwo); 135 | delay_us(length * PulseTwo); 136 | 137 | #ifdef RF_DEBUG 138 | for(int i = 0; i < PulseTwo; i++) 139 | if(LevelTwo == 1){ 140 | sprintf(str_code,"%s-", str_code); 141 | }else{ 142 | sprintf(str_code,"%s_", str_code); 143 | } 144 | #endif 145 | } 146 | } 147 | } 148 | } 149 | 150 | 151 | 152 | // ============================== Receive block ================================== 153 | 154 | uint32_t cur_timestamp; 155 | uint8_t cur_status; 156 | uint32_t last_change_time; 157 | uint32_t pulse_duration; 158 | 159 | #ifdef RF_DEBUG 160 | uint32_t timing[512] = {0,}; 161 | uint8_t timing_count = 0; 162 | #endif 163 | 164 | void RX433_Int(void){ 165 | 166 | // Calculate duration 167 | cur_timestamp = micros(); 168 | cur_status = HAL_GPIO_ReadPin(RXPORT, RXPIN); 169 | pulse_duration = cur_timestamp - last_change_time; 170 | last_change_time = cur_timestamp; 171 | 172 | #ifdef RF_DEBUG 173 | timing[timing_count] = pulse_duration; 174 | timing_count++; 175 | if (pulse_duration > 20000) 176 | { 177 | memset(timing, 0, sizeof(timing)); 178 | timing_count = 0; 179 | } 180 | #endif 181 | 182 | RF_Int(&came12); 183 | RF_Int(&nice12); 184 | RF_Int(&hcs301); 185 | 186 | } 187 | 188 | uint8_t RF_Int(RF_t* data){ 189 | 190 | // Big pause reset seek code 191 | if (pulse_duration > data->MaxPause){ 192 | data->PreambleCount = 0; 193 | return 0; 194 | } 195 | 196 | // Preamble 197 | if(data->PreambleCount < data->PreambleLenght){ 198 | if((pulse_duration > data->Te - data->TeDrv) && (pulse_duration < data->Te + data->TeDrv)){ 199 | data->PreambleCount ++; 200 | data->Header = 0; 201 | return 0; 202 | }else { 203 | data->PreambleCount = 0; 204 | } 205 | } 206 | 207 | // Header 208 | if(cur_status == (data->Invert == 0)? 0 : 1){ 209 | if(data->PreambleCount == data->PreambleLenght && data->Header == 0){ 210 | if((pulse_duration > data->Te * data->HeaderLenght - data->TeDrv * 4) && (pulse_duration < data->Te * data->HeaderLenght + data->TeDrv * 4)){ 211 | data->Header = 1; 212 | data->BitCounter = 0; 213 | return 0; 214 | }else { 215 | data->PreambleCount = 0; 216 | data->Header = 0; 217 | return 0; 218 | } 219 | } 220 | } 221 | 222 | // Code 223 | if(cur_status == (data->Invert == 0)? 1 : 0){ 224 | if(data->PreambleCount == data->PreambleLenght && data->Header == 1){ 225 | if((pulse_duration > data->Te - data->TeDrv) && (pulse_duration < data->Te * 2 + data->TeDrv)){ 226 | data->BitArray[65 - data->BitCounter] = (pulse_duration > data->Te * 3 / 2) ? 0 : 1; 227 | data->BitCounter++; 228 | if(data->BitCounter == data->CodeLengh){ 229 | // hсs301 230 | if(data->CodeLengh == 66){ 231 | data->Repeat = data->BitArray[0]; 232 | data->BatteryLow = data->BitArray[1]; 233 | data->Btn2 = data->BitArray[2]; 234 | data->Btn1 = data->BitArray[3]; 235 | data->Btn0 = data->BitArray[4]; 236 | data->Btn3 = data->BitArray[5]; 237 | 238 | data->SerialNum = 0; 239 | for(int i = 6; i < 34; i++){ 240 | data->SerialNum = (data->SerialNum << 1) + data->BitArray[i]; 241 | }; 242 | 243 | uint32_t Encrypt = 0; 244 | for(int i = 34; i < 66; i++){ 245 | Encrypt = (Encrypt << 1) + data->BitArray[i]; 246 | }; 247 | data->Encrypt = Encrypt; 248 | data->PreambleCount = 0; 249 | // Came, Nice 12 250 | }else if (data->CodeLengh == 12) { 251 | data->SerialNum = 0; 252 | for(int i = 0; i < 12; i++){ 253 | data->SerialNum = (data->SerialNum << 1) + data->BitArray[i]; 254 | }; 255 | } 256 | if(data->TailLenght){ 257 | return 0; 258 | }else { 259 | return 1; 260 | } 261 | } 262 | } 263 | else { 264 | data->PreambleCount = 0; 265 | } 266 | } 267 | } 268 | 269 | // Tail 270 | if(cur_status == (data->Invert == 0)? 0 : 1){ 271 | if(data->TailLenght > 0 && data->BitCounter == data->CodeLengh){ 272 | if((pulse_duration > data->Te * data->TailLenght - data->TeDrv * 4) && (pulse_duration < data->Te * data->TailLenght + data->TeDrv * 4)){ 273 | return 1; 274 | }else { 275 | return 0; 276 | } 277 | } 278 | } 279 | return 0; 280 | } 281 | 282 | -------------------------------------------------------------------------------- /example/test433/Core/Src/rf-barrier.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rf-barrier.c 3 | * 4 | * Created on: Nov 21, 2019 5 | * Author: Bulanov Konstantin 6 | * 7 | * Contact information 8 | * ------------------- 9 | * 10 | * e-mail : leech001@gmail.com 11 | * 12 | * 13 | */ 14 | 15 | /* 16 | * |----------------------------------------------------------------------------------------------------------------------------------------------- 17 | * | Copyright (C) Bulanov Konstantin,2019 18 | * | 19 | * | This program is free software: you can redistribute it and/or modify 20 | * | it under the terms of the GNU General Public License as published by 21 | * | the Free Software Foundation, either version 3 of the License, or 22 | * | any later version. 23 | * | 24 | * | This program is distributed in the hope that it will be useful, 25 | * | but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * | GNU General Public License for more details. 28 | * | 29 | * | You should have received a copy of the GNU General Public License 30 | * | along with this program. If not, see . 31 | * | 32 | * | Came and Nice algorithm http://phreakerclub.com/forum/showthread.php?t=126 33 | * |------------------------------------------------------------------------------------------------------------------------------------------------ 34 | */ 35 | 36 | 37 | #include 38 | #include 39 | #include "micros.h" 40 | #include "rf-barrier.h" 41 | #include "rf-barrier-timings.h" 42 | 43 | 44 | #ifdef RF_DEBUG 45 | #include 46 | char str_code[512] = {0,}; 47 | #endif 48 | 49 | 50 | void RF_send_bin(Protocol_t* protocol, const char* sCodeWord) { 51 | uint64_t code = 0; 52 | for (const char* p = sCodeWord; *p; p++) { 53 | code <<= 1ULL; 54 | if (*p != '0'){ 55 | code |= 1ULL; 56 | } 57 | } 58 | RF_send(protocol, code); 59 | } 60 | 61 | void RF_send(Protocol_t* protocol, uint64_t code) { 62 | for (int nRepeat = 0; nRepeat < protocol->nRepeatTransmit; nRepeat++){ 63 | 64 | // Preamble 65 | RF_transmit(protocol->Preamble, protocol->PulseLength, protocol->Invert); 66 | 67 | // Header 68 | RF_transmit(protocol->Header, protocol->PulseLength, protocol->Invert); 69 | 70 | // Code 71 | for (int i = protocol->CodeLength-1; i >= 0; i--){ 72 | if (code & (1ULL << i)){ 73 | RF_transmit(protocol->One, protocol->PulseLength, protocol->Invert); 74 | }else{ 75 | RF_transmit(protocol->Zero, protocol->PulseLength, protocol->Invert); 76 | } 77 | } 78 | 79 | // Tail 80 | RF_transmit(protocol->Tail, protocol->PulseLength, protocol->Invert); 81 | 82 | #ifdef RF_DEBUG 83 | char usb_str[512]={0,}; 84 | sprintf(usb_str,"%s\r\n", str_code); 85 | CDC_Transmit_FS((unsigned char *) usb_str, (uint16_t) strlen(usb_str)); 86 | memset(str_code, '\0', sizeof(str_code)); 87 | #endif 88 | 89 | //Guard delay 90 | if (protocol->nGuard > 0){ 91 | HAL_GPIO_WritePin(TXPORT, TXPIN, GPIO_PIN_RESET); 92 | delay_us(protocol->PulseLength * protocol->nGuard); 93 | } 94 | } 95 | } 96 | 97 | void RF_transmit(Bit_t pulses, uint16_t length, uint8_t invert) { 98 | 99 | uint8_t bits[2][2] = {{pulses.bit1.low, pulses.bit1.high}, 100 | {pulses.bit2.low, pulses.bit2.high}}; 101 | uint8_t PulseOne; 102 | uint8_t PulseTwo; 103 | uint8_t LevelOne; 104 | uint8_t LevelTwo; 105 | 106 | for(int i=0; i < pulses.repeat; i++){ 107 | for (int i_bits = 0; i_bits < 2; i_bits++){ 108 | if(invert == 0){ 109 | PulseOne = bits[i_bits][0]; 110 | PulseTwo = bits[i_bits][1]; 111 | LevelOne = GPIO_PIN_RESET; 112 | LevelTwo = GPIO_PIN_SET; 113 | }else{ 114 | PulseOne = bits[i_bits][1]; 115 | PulseTwo = bits[i_bits][0]; 116 | LevelOne = GPIO_PIN_SET; 117 | LevelTwo = GPIO_PIN_RESET; 118 | } 119 | 120 | if (PulseOne > 0){ 121 | HAL_GPIO_WritePin(TXPORT, TXPIN, LevelOne); 122 | delay_us(length * PulseOne); 123 | 124 | #ifdef RF_DEBUG 125 | for(int i = 0; i < PulseOne; i++) 126 | if(LevelOne == 1){ 127 | sprintf(str_code,"%s-", str_code); 128 | }else{ 129 | sprintf(str_code,"%s_", str_code); 130 | } 131 | #endif 132 | } 133 | if (PulseTwo > 0){ 134 | HAL_GPIO_WritePin(TXPORT, TXPIN, LevelTwo); 135 | delay_us(length * PulseTwo); 136 | 137 | #ifdef RF_DEBUG 138 | for(int i = 0; i < PulseTwo; i++) 139 | if(LevelTwo == 1){ 140 | sprintf(str_code,"%s-", str_code); 141 | }else{ 142 | sprintf(str_code,"%s_", str_code); 143 | } 144 | #endif 145 | } 146 | } 147 | } 148 | } 149 | 150 | 151 | 152 | // ============================== Receive block ================================== 153 | 154 | uint32_t cur_timestamp; 155 | uint8_t cur_status; 156 | uint32_t last_change_time; 157 | uint32_t pulse_duration; 158 | 159 | #ifdef RF_DEBUG 160 | uint32_t timing[512] = {0,}; 161 | uint8_t timing_count = 0; 162 | #endif 163 | 164 | void RX433_Int(void){ 165 | 166 | // Calculate duration 167 | cur_timestamp = micros(); 168 | cur_status = HAL_GPIO_ReadPin(RXPORT, RXPIN); 169 | pulse_duration = cur_timestamp - last_change_time; 170 | last_change_time = cur_timestamp; 171 | 172 | #ifdef RF_DEBUG 173 | timing[timing_count] = pulse_duration; 174 | timing_count++; 175 | if (pulse_duration > 20000) 176 | { 177 | memset(timing, 0, sizeof(timing)); 178 | timing_count = 0; 179 | } 180 | #endif 181 | 182 | RF_Int(&came12); 183 | RF_Int(&nice12); 184 | RF_Int(&hcs301); 185 | 186 | } 187 | 188 | uint8_t RF_Int(RF_t* data){ 189 | 190 | // Big pause reset seek code 191 | if (pulse_duration > data->MaxPause){ 192 | data->PreambleCount = 0; 193 | return 0; 194 | } 195 | 196 | // Preamble 197 | if(data->PreambleCount < data->PreambleLenght){ 198 | if((pulse_duration > data->Te - data->TeDrv) && (pulse_duration < data->Te + data->TeDrv)){ 199 | data->PreambleCount ++; 200 | data->Header = 0; 201 | return 0; 202 | }else { 203 | data->PreambleCount = 0; 204 | } 205 | } 206 | 207 | // Header 208 | if(cur_status == (data->Invert == 0)? 0 : 1){ 209 | if(data->PreambleCount == data->PreambleLenght && data->Header == 0){ 210 | if((pulse_duration > data->Te * data->HeaderLenght - data->TeDrv * 4) && (pulse_duration < data->Te * data->HeaderLenght + data->TeDrv * 4)){ 211 | data->Header = 1; 212 | data->BitCounter = 0; 213 | return 0; 214 | }else { 215 | data->PreambleCount = 0; 216 | data->Header = 0; 217 | return 0; 218 | } 219 | } 220 | } 221 | 222 | // Code 223 | if(cur_status == (data->Invert == 0)? 1 : 0){ 224 | if(data->PreambleCount == data->PreambleLenght && data->Header == 1){ 225 | if((pulse_duration > data->Te - data->TeDrv) && (pulse_duration < data->Te * 2 + data->TeDrv)){ 226 | data->BitArray[65 - data->BitCounter] = (pulse_duration > data->Te * 3 / 2) ? 0 : 1; 227 | data->BitCounter++; 228 | if(data->BitCounter == data->CodeLengh){ 229 | // hсs301 230 | if(data->CodeLengh == 66){ 231 | data->Repeat = data->BitArray[0]; 232 | data->BatteryLow = data->BitArray[1]; 233 | data->Btn2 = data->BitArray[2]; 234 | data->Btn1 = data->BitArray[3]; 235 | data->Btn0 = data->BitArray[4]; 236 | data->Btn3 = data->BitArray[5]; 237 | 238 | data->SerialNum = 0; 239 | for(int i = 6; i < 34; i++){ 240 | data->SerialNum = (data->SerialNum << 1) + data->BitArray[i]; 241 | }; 242 | 243 | uint32_t Encrypt = 0; 244 | for(int i = 34; i < 66; i++){ 245 | Encrypt = (Encrypt << 1) + data->BitArray[i]; 246 | }; 247 | data->Encrypt = Encrypt; 248 | data->PreambleCount = 0; 249 | // Came, Nice 12 250 | }else if (data->CodeLengh == 12) { 251 | data->SerialNum = 0; 252 | for(int i = 0; i < 12; i++){ 253 | data->SerialNum = (data->SerialNum << 1) + data->BitArray[i]; 254 | }; 255 | } 256 | if(data->TailLenght){ 257 | return 0; 258 | }else { 259 | return 1; 260 | } 261 | } 262 | } 263 | else { 264 | data->PreambleCount = 0; 265 | } 266 | } 267 | } 268 | 269 | // Tail 270 | if(cur_status == (data->Invert == 0)? 0 : 1){ 271 | if(data->TailLenght > 0 && data->BitCounter == data->CodeLengh){ 272 | if((pulse_duration > data->Te * data->TailLenght - data->TeDrv * 4) && (pulse_duration < data->Te * data->TailLenght + data->TeDrv * 4)){ 273 | return 1; 274 | }else { 275 | return 0; 276 | } 277 | } 278 | } 279 | return 0; 280 | } 281 | 282 | -------------------------------------------------------------------------------- /example/test433/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 | -------------------------------------------------------------------------------- /example/test433/.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousGenFiles] 2 | AdvancedFolderStructure=true 3 | HeaderFileListSize=9 4 | HeaderFiles#0=C:/Project/STM32/test433/Core/Inc/gpio.h 5 | HeaderFiles#1=C:/Project/STM32/test433/Core/Inc/sys.h 6 | HeaderFiles#2=C:/Project/STM32/test433/USB_DEVICE/App/usb_device.h 7 | HeaderFolderListSize=3 8 | HeaderPath#0=C:/Project/STM32/test433/Core/Inc 9 | SourceFileListSize=9 10 | SourceFiles#0=C:/Project/STM32/test433/Core/Src/gpio.c 11 | SourceFiles#1=C:/Project/STM32/test433/Core/Src/sys.c 12 | SourceFiles#2=C:/Project/STM32/test433/USB_DEVICE/App/usb_device.c 13 | SourceFolderListSize=3 14 | SourcePath#0=C:/Project/STM32/test433/Core/Src 15 | HeaderFiles#3=C:/Project/STM32/test433/USB_DEVICE/Target/usbd_conf.h 16 | HeaderFiles#4=C:/Project/STM32/test433/USB_DEVICE/App/usbd_desc.h 17 | SourceFiles#3=C:/Project/STM32/test433/USB_DEVICE/Target/usbd_conf.c 18 | SourceFiles#4=C:/Project/STM32/test433/USB_DEVICE/App/usbd_desc.c 19 | HeaderFiles#5=C:/Project/STM32/test433/USB_DEVICE/App/usbd_cdc_if.h 20 | HeaderFiles#6=C:/Project/STM32/test433/Core/Inc/stm32f1xx_it.h 21 | HeaderFiles#7=C:/Project/STM32/test433/Core/Inc/stm32f1xx_hal_conf.h 22 | HeaderFiles#8=C:/Project/STM32/test433/Core/Inc/main.h 23 | HeaderPath#1=C:/Project/STM32/test433/USB_DEVICE/App 24 | HeaderPath#2=C:/Project/STM32/test433/USB_DEVICE/Target 25 | HeaderFiles=; 26 | SourceFiles#5=C:/Project/STM32/test433/USB_DEVICE/App/usbd_cdc_if.c 27 | SourceFiles#6=C:/Project/STM32/test433/Core/Src/stm32f1xx_it.c 28 | SourceFiles#7=C:/Project/STM32/test433/Core/Src/stm32f1xx_hal_msp.c 29 | SourceFiles#8=C:/Project/STM32/test433/Core/Src/main.c 30 | SourcePath#1=C:/Project/STM32/test433/USB_DEVICE/App 31 | SourcePath#2=C:/Project/STM32/test433/USB_DEVICE/Target 32 | SourceFiles=; 33 | 34 | [PreviousLibFiles] 35 | 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_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_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_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; 36 | 37 | [PreviousUsedCubeIDEFiles] 38 | SourceFiles=Core\Src\main.c;Core\Src\gpio.c;Core\Src\sys.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_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_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; 39 | 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; 40 | CDefines=USE_HAL_DRIVER;STM32F103xB;USE_HAL_DRIVER;USE_HAL_DRIVER; 41 | 42 | -------------------------------------------------------------------------------- /example/test433/Drivers/CMSIS/Include/cmsis_compiler.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_compiler.h 3 | * @brief CMSIS compiler generic header file 4 | * @version V5.0.4 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2018 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #ifndef __CMSIS_COMPILER_H 26 | #define __CMSIS_COMPILER_H 27 | 28 | #include 29 | 30 | /* 31 | * Arm Compiler 4/5 32 | */ 33 | #if defined ( __CC_ARM ) 34 | #include "cmsis_armcc.h" 35 | 36 | 37 | /* 38 | * Arm Compiler 6 (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 | -------------------------------------------------------------------------------- /example/test433/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) 2019 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 | -------------------------------------------------------------------------------- /example/test433/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 | -------------------------------------------------------------------------------- /example/test433/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 | --------------------------------------------------------------------------------