static uint32_t last_capture = 0; uint32_t capture = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_1); uint32_t diff = capture - last_capture; last_capture = capture; if (diff > 0) { period = diff; } else { pulse_width = -diff; } } } int main(void) { HAL_Init(); _...
staticvoidNVIC_Configuration(void){NVIC_InitTypeDef NVIC_InitStructure;/* 配置NVIC为优先级组1 */NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);/* 配置中断源:按键1 */NVIC_InitStructure.NVIC_IRQChannel=KEY1_INT_EXTI_IRQ;/* 配置抢占优先级:1 */NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=1;/* ...
typedef unsigned int uint32_t; 为了方便使用我们把volatile和 unsigned int改改名,注意volatile是防止编译器优化代码的,毕竟我们的结构体最终要实打实的控制外设,任何优化可能出现意想不到的情况。 接下来就是要定义GPIO相关寄存器的结构体,因为太多了就简单写两个 typedef struct{ __IO CRL_Bit CRL; __IO CRH_...
typedef unsigned int uint32_t; void SetClockConfig(void); typedef struct { uint32_t HSION :1; uint32_t HSIRDY :1; uint32_t Reserved0 :1; uint32_t HSITRIM :5; uint32_t HSICAL :8; uint32_t HSEON :1; uint32_t HSERDY :1; uint32_t HSEBYP :1; uint32_t CSSON :...
整型:int short long 实型:float double STM32中的数据类型非常的多,常用的变量,文件中的定义如下: /* exact-width signed integer types */ typedef signed char int8_t; typedef signed short int int16_t; typedef signed int int32_t; typedef signed __int64 int64_t; ...
stm32的数据类型:1、uint16_t;2、uint32_t;3、u8;4、char。uint16_t是指,无符号短整型short int,即 typedef unsigned short int uint16_t,表示的数据范围是0 ~65535。
整型:int short long 实型:float double STM32中的数据类型非常的多,常用的变量,文件中的定义如下: /* exact-width signed integer types */ typedef signed char int8_t; typedef signed short int int16_t; typedef signed int int32_t; typedef signed __int64 int64_t; ...
int32_t : typedef signed int; uint32_t :typedef unsigned int; int64_t : typedef signed long uint64_t : typedef unsigned long 2.嵌入式编程中的无符号类型 unsigned char = uint8_t = u8 unsigned short = uint16_t = u16 unsigned int = uint32_t = u32 ...
typedef signed int int32_t; typedef signed __int64 int64_t; typedef unsigned char uint8_t; typedef unsigned short int uint16_t; typedef unsigned int uint32_t; typedefunsigned__int64uint64_t; stm32f10x.h 这个文件主要是为了兼容旧版本 ...
/**\fn int32_t LED_On (uint32_t num)\brief Turn on requested LED\param[in] num LED number\returns- \b 0: function succeeded- \b -1: function failed*/int32_t LED_On (uint32_t num) {int32_t retCode = 0;if (num < LED_COUNT) {GPIO_PinWrite(Pin_LED[num].port, Pin_LED...