├── README.md ├── 2-1蜂鸣器 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ └── stm32f10x_usart.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ ├── main.c │ └── stm32f10x_it.h ├── 7-1串口发送 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_flash.c │ ├── stm32f10x_i2c.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── LED.h │ ├── Serial.h │ ├── OLED.h │ ├── Key.c │ ├── LED.c │ └── Serial.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ └── main.c ├── 1-1LED闪烁 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ └── stm32f10x_usart.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ ├── main.c │ └── stm32f10x_it.h ├── 2-2按键控制LED ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── LED.h │ ├── Key.c │ └── LED.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ ├── main.c │ └── stm32f10x_it.h ├── 2-3光敏控制蜂鸣器 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── LightSensor.h │ ├── Buzzer.h │ ├── LED.h │ ├── LightSensor.c │ ├── Buzzer.c │ ├── Key.c │ └── LED.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ ├── main.c │ └── stm32f10x_it.h ├── 3-1OLED显示屏 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── LED.h │ ├── OLED.h │ ├── Key.c │ └── LED.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ ├── main.c │ └── stm32f10x_it.h ├── 3-2光敏传感器计次 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── CountSensor.h │ ├── LED.h │ ├── OLED.h │ ├── Key.c │ ├── LED.c │ └── CountSensor.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ ├── main.c │ └── stm32f10x_it.h ├── 3-3编码器计次 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── Encoder.h │ ├── CountSensor.h │ ├── LED.h │ ├── OLED.h │ ├── Key.c │ ├── LED.c │ └── CountSensor.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ ├── main.c │ └── stm32f10x_it.h ├── 4-1定时器定时中断 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── System │ ├── Timer.h │ ├── Delay.h │ ├── Delay.c │ └── Timer.c ├── Library │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── LED.h │ ├── OLED.h │ ├── Key.c │ └── LED.c └── User │ ├── main.c │ └── stm32f10x_it.h ├── 4-2定时器外部时钟 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── LED.h │ ├── OLED.h │ ├── Key.c │ └── LED.c ├── System │ ├── Timer.h │ ├── Delay.h │ ├── Delay.c │ └── Timer.c └── User │ ├── main.c │ └── stm32f10x_it.h ├── 4-4PWM驱动舵机 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── PWM.h │ ├── Servo.h │ ├── LED.h │ ├── Servo.c │ ├── OLED.h │ ├── Key.c │ ├── LED.c │ └── PWM.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ ├── main.c │ └── stm32f10x_it.h ├── 4-8编码器接口测速 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── System │ ├── Timer.h │ ├── Delay.h │ ├── Delay.c │ └── Timer.c ├── Library │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── Encoder.h │ ├── LED.h │ ├── OLED.h │ ├── Key.c │ ├── LED.c │ └── Encoder.c └── User │ ├── main.c │ └── stm32f10x_it.h ├── 5-1AD单通道 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ └── stm32f10x_usart.c ├── Hardware │ ├── AD.h │ ├── Key.h │ ├── LED.h │ ├── OLED.h │ ├── Key.c │ ├── LED.c │ └── AD.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ └── main.c ├── 5-2AD多通道 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── AD.h │ ├── LED.h │ ├── OLED.h │ ├── Key.c │ ├── LED.c │ └── AD.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ └── main.c ├── 6-1DMA数据转运 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── LED.h │ ├── OLED.h │ ├── Key.c │ └── LED.c ├── System │ ├── Delay.h │ ├── MyDMA.h │ ├── Delay.c │ └── MyDMA.c └── User │ └── main.c ├── 7-2串口发送+接收 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── LED.h │ ├── Serial.h │ ├── OLED.h │ ├── Key.c │ └── LED.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ └── main.c ├── 4-5PWM驱动直流电机 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_flash.c │ ├── stm32f10x_i2c.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── Motor.h │ ├── PWM.h │ ├── LED.h │ ├── OLED.h │ ├── Motor.c │ ├── Key.c │ ├── LED.c │ └── PWM.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ └── main.c ├── 4-6输入捕获模式测频率 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_flash.c │ ├── stm32f10x_i2c.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── IC.h │ ├── PWM.h │ ├── LED.h │ ├── OLED.h │ ├── Key.c │ ├── LED.c │ ├── PWM.c │ └── IC.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ └── main.c ├── 6-2DMA+AD多通道 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_flash.c │ ├── stm32f10x_i2c.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── AD.h │ ├── LED.h │ ├── OLED.h │ ├── Key.c │ └── LED.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ └── main.c ├── 7-4串口收发文本数据包 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_flash.c │ ├── stm32f10x_i2c.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── LED.h │ ├── Serial.h │ ├── OLED.h │ ├── Key.c │ └── LED.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ └── main.c ├── 4-3PWM驱动LED呼吸灯 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── PWM.h │ ├── LED.h │ ├── OLED.h │ ├── Key.c │ ├── LED.c │ └── PWM.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ └── main.c ├── 4-7PWMI模式测频率占空比 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── IC.h │ ├── PWM.h │ ├── LED.h │ ├── OLED.h │ ├── Key.c │ ├── LED.c │ ├── PWM.c │ └── IC.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ └── main.c ├── 7-3串口收发HEX数据包 ├── keilkill.bat ├── Start │ └── stm32f10x.h ├── Library │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ └── stm32f10x_usart.c ├── Hardware │ ├── Key.h │ ├── LED.h │ ├── OLED.h │ ├── Serial.h │ ├── Key.c │ └── LED.c ├── System │ ├── Delay.h │ └── Delay.c └── User │ └── main.c └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # STM32Project 2 | STM32入门项目——基于最小系统板F103C8T6 3 | -------------------------------------------------------------------------------- /2-1蜂鸣器/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/2-1蜂鸣器/keilkill.bat -------------------------------------------------------------------------------- /7-1串口发送/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-1串口发送/keilkill.bat -------------------------------------------------------------------------------- /1-1LED闪烁/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/1-1LED闪烁/keilkill.bat -------------------------------------------------------------------------------- /2-2按键控制LED/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/2-2按键控制LED/keilkill.bat -------------------------------------------------------------------------------- /2-3光敏控制蜂鸣器/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/2-3光敏控制蜂鸣器/keilkill.bat -------------------------------------------------------------------------------- /3-1OLED显示屏/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/3-1OLED显示屏/keilkill.bat -------------------------------------------------------------------------------- /3-2光敏传感器计次/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/3-2光敏传感器计次/keilkill.bat -------------------------------------------------------------------------------- /3-3编码器计次/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/3-3编码器计次/keilkill.bat -------------------------------------------------------------------------------- /4-1定时器定时中断/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-1定时器定时中断/keilkill.bat -------------------------------------------------------------------------------- /4-2定时器外部时钟/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-2定时器外部时钟/keilkill.bat -------------------------------------------------------------------------------- /4-4PWM驱动舵机/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-4PWM驱动舵机/keilkill.bat -------------------------------------------------------------------------------- /4-8编码器接口测速/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-8编码器接口测速/keilkill.bat -------------------------------------------------------------------------------- /5-1AD单通道/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/5-1AD单通道/keilkill.bat -------------------------------------------------------------------------------- /5-2AD多通道/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/5-2AD多通道/keilkill.bat -------------------------------------------------------------------------------- /6-1DMA数据转运/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/6-1DMA数据转运/keilkill.bat -------------------------------------------------------------------------------- /7-2串口发送+接收/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-2串口发送+接收/keilkill.bat -------------------------------------------------------------------------------- /2-1蜂鸣器/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/2-1蜂鸣器/Start/stm32f10x.h -------------------------------------------------------------------------------- /4-5PWM驱动直流电机/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-5PWM驱动直流电机/keilkill.bat -------------------------------------------------------------------------------- /4-6输入捕获模式测频率/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-6输入捕获模式测频率/keilkill.bat -------------------------------------------------------------------------------- /6-2DMA+AD多通道/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/6-2DMA+AD多通道/keilkill.bat -------------------------------------------------------------------------------- /7-1串口发送/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-1串口发送/Start/stm32f10x.h -------------------------------------------------------------------------------- /7-4串口收发文本数据包/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-4串口收发文本数据包/keilkill.bat -------------------------------------------------------------------------------- /1-1LED闪烁/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/1-1LED闪烁/Start/stm32f10x.h -------------------------------------------------------------------------------- /2-2按键控制LED/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/2-2按键控制LED/Start/stm32f10x.h -------------------------------------------------------------------------------- /2-3光敏控制蜂鸣器/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/2-3光敏控制蜂鸣器/Start/stm32f10x.h -------------------------------------------------------------------------------- /3-1OLED显示屏/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/3-1OLED显示屏/Start/stm32f10x.h -------------------------------------------------------------------------------- /3-2光敏传感器计次/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/3-2光敏传感器计次/Start/stm32f10x.h -------------------------------------------------------------------------------- /3-3编码器计次/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/3-3编码器计次/Start/stm32f10x.h -------------------------------------------------------------------------------- /4-1定时器定时中断/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-1定时器定时中断/Start/stm32f10x.h -------------------------------------------------------------------------------- /4-2定时器外部时钟/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-2定时器外部时钟/Start/stm32f10x.h -------------------------------------------------------------------------------- /4-3PWM驱动LED呼吸灯/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-3PWM驱动LED呼吸灯/keilkill.bat -------------------------------------------------------------------------------- /4-4PWM驱动舵机/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-4PWM驱动舵机/Start/stm32f10x.h -------------------------------------------------------------------------------- /4-7PWMI模式测频率占空比/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-7PWMI模式测频率占空比/keilkill.bat -------------------------------------------------------------------------------- /4-8编码器接口测速/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-8编码器接口测速/Start/stm32f10x.h -------------------------------------------------------------------------------- /5-1AD单通道/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/5-1AD单通道/Start/stm32f10x.h -------------------------------------------------------------------------------- /5-2AD多通道/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/5-2AD多通道/Start/stm32f10x.h -------------------------------------------------------------------------------- /6-1DMA数据转运/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/6-1DMA数据转运/Start/stm32f10x.h -------------------------------------------------------------------------------- /7-2串口发送+接收/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-2串口发送+接收/Start/stm32f10x.h -------------------------------------------------------------------------------- /7-3串口收发HEX数据包/keilkill.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-3串口收发HEX数据包/keilkill.bat -------------------------------------------------------------------------------- /2-1蜂鸣器/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/2-1蜂鸣器/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /4-1定时器定时中断/System/Timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIMER_H 2 | #define __TIMER_H 3 | 4 | void Timer_Init(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /4-5PWM驱动直流电机/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-5PWM驱动直流电机/Start/stm32f10x.h -------------------------------------------------------------------------------- /4-6输入捕获模式测频率/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-6输入捕获模式测频率/Start/stm32f10x.h -------------------------------------------------------------------------------- /4-8编码器接口测速/System/Timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIMER_H 2 | #define __TIMER_H 3 | 4 | void Timer_Init(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /6-2DMA+AD多通道/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/6-2DMA+AD多通道/Start/stm32f10x.h -------------------------------------------------------------------------------- /7-4串口收发文本数据包/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-4串口收发文本数据包/Start/stm32f10x.h -------------------------------------------------------------------------------- /1-1LED闪烁/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/1-1LED闪烁/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /2-1蜂鸣器/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/2-1蜂鸣器/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /2-1蜂鸣器/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/2-1蜂鸣器/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /3-3编码器计次/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/3-3编码器计次/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /4-3PWM驱动LED呼吸灯/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-3PWM驱动LED呼吸灯/Start/stm32f10x.h -------------------------------------------------------------------------------- /4-7PWMI模式测频率占空比/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-7PWMI模式测频率占空比/Start/stm32f10x.h -------------------------------------------------------------------------------- /5-1AD单通道/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/5-1AD单通道/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /5-2AD多通道/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/5-2AD多通道/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /7-1串口发送/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-1串口发送/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /7-1串口发送/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-1串口发送/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /7-1串口发送/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-1串口发送/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /7-3串口收发HEX数据包/Start/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-3串口收发HEX数据包/Start/stm32f10x.h -------------------------------------------------------------------------------- /1-1LED闪烁/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/1-1LED闪烁/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /1-1LED闪烁/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/1-1LED闪烁/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /2-2按键控制LED/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/2-2按键控制LED/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /2-3光敏控制蜂鸣器/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/2-3光敏控制蜂鸣器/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /3-1OLED显示屏/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/3-1OLED显示屏/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /3-2光敏传感器计次/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/3-2光敏传感器计次/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /3-3编码器计次/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/3-3编码器计次/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /3-3编码器计次/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/3-3编码器计次/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /4-1定时器定时中断/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-1定时器定时中断/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /4-2定时器外部时钟/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-2定时器外部时钟/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /4-4PWM驱动舵机/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-4PWM驱动舵机/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /4-8编码器接口测速/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-8编码器接口测速/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /5-1AD单通道/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/5-1AD单通道/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /5-1AD单通道/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/5-1AD单通道/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /5-2AD多通道/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/5-2AD多通道/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /5-2AD多通道/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/5-2AD多通道/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /6-1DMA数据转运/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/6-1DMA数据转运/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /7-2串口发送+接收/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-2串口发送+接收/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /2-2按键控制LED/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/2-2按键控制LED/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /2-2按键控制LED/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/2-2按键控制LED/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /2-3光敏控制蜂鸣器/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/2-3光敏控制蜂鸣器/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /2-3光敏控制蜂鸣器/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/2-3光敏控制蜂鸣器/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /3-1OLED显示屏/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/3-1OLED显示屏/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /3-1OLED显示屏/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/3-1OLED显示屏/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /3-2光敏传感器计次/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/3-2光敏传感器计次/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /3-2光敏传感器计次/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/3-2光敏传感器计次/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /4-1定时器定时中断/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-1定时器定时中断/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /4-1定时器定时中断/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-1定时器定时中断/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /4-2定时器外部时钟/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-2定时器外部时钟/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /4-2定时器外部时钟/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-2定时器外部时钟/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /4-3PWM驱动LED呼吸灯/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-3PWM驱动LED呼吸灯/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /4-4PWM驱动舵机/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-4PWM驱动舵机/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /4-4PWM驱动舵机/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-4PWM驱动舵机/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /4-5PWM驱动直流电机/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-5PWM驱动直流电机/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /4-5PWM驱动直流电机/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-5PWM驱动直流电机/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /4-5PWM驱动直流电机/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-5PWM驱动直流电机/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /4-6输入捕获模式测频率/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-6输入捕获模式测频率/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /4-6输入捕获模式测频率/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-6输入捕获模式测频率/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /4-6输入捕获模式测频率/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-6输入捕获模式测频率/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /4-8编码器接口测速/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-8编码器接口测速/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /4-8编码器接口测速/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-8编码器接口测速/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /6-1DMA数据转运/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/6-1DMA数据转运/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /6-1DMA数据转运/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/6-1DMA数据转运/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /6-2DMA+AD多通道/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/6-2DMA+AD多通道/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /6-2DMA+AD多通道/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/6-2DMA+AD多通道/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /6-2DMA+AD多通道/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/6-2DMA+AD多通道/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /7-2串口发送+接收/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-2串口发送+接收/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /7-2串口发送+接收/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-2串口发送+接收/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /7-3串口收发HEX数据包/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-3串口收发HEX数据包/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /7-4串口收发文本数据包/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-4串口收发文本数据包/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /7-4串口收发文本数据包/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-4串口收发文本数据包/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /7-4串口收发文本数据包/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-4串口收发文本数据包/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /4-3PWM驱动LED呼吸灯/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-3PWM驱动LED呼吸灯/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /4-3PWM驱动LED呼吸灯/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-3PWM驱动LED呼吸灯/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /4-7PWMI模式测频率占空比/Library/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-7PWMI模式测频率占空比/Library/stm32f10x_i2c.c -------------------------------------------------------------------------------- /5-1AD单通道/Hardware/AD.h: -------------------------------------------------------------------------------- 1 | #ifndef __AD_H 2 | #define __AD_H 3 | 4 | void AD_Init(void); 5 | uint16_t AD_GetValue(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /7-1串口发送/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /7-3串口收发HEX数据包/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-3串口收发HEX数据包/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /7-3串口收发HEX数据包/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/7-3串口收发HEX数据包/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /2-2按键控制LED/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /2-3光敏控制蜂鸣器/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /3-1OLED显示屏/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /3-2光敏传感器计次/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /3-3编码器计次/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /4-1定时器定时中断/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /4-2定时器外部时钟/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /4-4PWM驱动舵机/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /4-5PWM驱动直流电机/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /4-6输入捕获模式测频率/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /4-7PWMI模式测频率占空比/Library/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-7PWMI模式测频率占空比/Library/stm32f10x_flash.c -------------------------------------------------------------------------------- /4-7PWMI模式测频率占空比/Library/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Grizi-ju/STM32Project/HEAD/4-7PWMI模式测频率占空比/Library/stm32f10x_usart.c -------------------------------------------------------------------------------- /4-8编码器接口测速/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /5-1AD单通道/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /5-2AD多通道/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /6-1DMA数据转运/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /6-2DMA+AD多通道/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /7-2串口发送+接收/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /7-4串口收发文本数据包/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /4-3PWM驱动LED呼吸灯/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /4-6输入捕获模式测频率/Hardware/IC.h: -------------------------------------------------------------------------------- 1 | #ifndef __IC_H 2 | #define __IC_H 3 | 4 | void IC_Init(void); 5 | uint32_t IC_GetFreq(void); 6 | 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /4-7PWMI模式测频率占空比/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /6-2DMA+AD多通道/Hardware/AD.h: -------------------------------------------------------------------------------- 1 | #ifndef __AD_H 2 | #define __AD_H 3 | 4 | extern uint16_t AD_Value[4]; 5 | 6 | void AD_Init(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /7-3串口收发HEX数据包/Hardware/Key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H 2 | #define __KEY_H 3 | 4 | void Key_Init(void); 5 | uint8_t Key_GetNum(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /5-2AD多通道/Hardware/AD.h: -------------------------------------------------------------------------------- 1 | #ifndef __AD_H 2 | #define __AD_H 3 | 4 | void AD_Init(void); 5 | uint16_t AD_GetValue(uint8_t ADC_Channel); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /3-3编码器计次/Hardware/Encoder.h: -------------------------------------------------------------------------------- 1 | #ifndef __Encoder_H 2 | #define __Encoder_H 3 | 4 | void Encoder_Init(void); 5 | int16_t Encoder_Get(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /4-2定时器外部时钟/System/Timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIMER_H 2 | #define __TIMER_H 3 | 4 | void Timer_Init(void); 5 | uint16_t Timer_GetCounter(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /4-4PWM驱动舵机/Hardware/PWM.h: -------------------------------------------------------------------------------- 1 | #ifndef __PWM_H 2 | #define __PWM_H 3 | 4 | void PWM_Init(void); 5 | void PWM_SetCompare2(uint16_t compare); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /4-4PWM驱动舵机/Hardware/Servo.h: -------------------------------------------------------------------------------- 1 | #ifndef __PWM_H 2 | #define __PWM_H 3 | 4 | void Servo_Init(void); 5 | void Servo_SetAngle(float angle); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /4-5PWM驱动直流电机/Hardware/Motor.h: -------------------------------------------------------------------------------- 1 | #ifndef __PWM_H 2 | #define __PWM_H 3 | 4 | void Motor_Init(void); 5 | void Motor_SetSpeed(int8_t speed); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /4-5PWM驱动直流电机/Hardware/PWM.h: -------------------------------------------------------------------------------- 1 | #ifndef __PWM_H 2 | #define __PWM_H 3 | 4 | void PWM_Init(void); 5 | void PWM_SetCompare3(uint16_t compare); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /4-8编码器接口测速/Hardware/Encoder.h: -------------------------------------------------------------------------------- 1 | #ifndef __ENCODER_H 2 | #define __ENCODER_H 3 | 4 | void Encoder_Init(void); 5 | int16_t Encoder_Get(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /4-3PWM驱动LED呼吸灯/Hardware/PWM.h: -------------------------------------------------------------------------------- 1 | #ifndef __PWM_H 2 | #define __PWM_H 3 | 4 | void PWM_Init(void); 5 | void PWM_SetCompare1(uint16_t compare); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /2-3光敏控制蜂鸣器/Hardware/LightSensor.h: -------------------------------------------------------------------------------- 1 | #ifndef __LIGHT_SENSOR_H 2 | #define __LIGHT_SENSOR_H 3 | 4 | void LightSensor_Init(void); 5 | uint8_t LightSensor_Get(void); 6 | 7 | #endif -------------------------------------------------------------------------------- /3-3编码器计次/Hardware/CountSensor.h: -------------------------------------------------------------------------------- 1 | #ifndef __CountSensor_H 2 | #define __CountSensor_H 3 | 4 | void CountSensor_Init(void); 5 | uint16_t CountSensor_Get(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /1-1LED闪烁/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /2-1蜂鸣器/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /3-2光敏传感器计次/Hardware/CountSensor.h: -------------------------------------------------------------------------------- 1 | #ifndef __CountSensor_H 2 | #define __CountSensor_H 3 | 4 | void CountSensor_Init(void); 5 | uint16_t CountSensor_Get(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /3-3编码器计次/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /5-1AD单通道/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /5-2AD多通道/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /7-1串口发送/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /2-2按键控制LED/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /2-3光敏控制蜂鸣器/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /3-1OLED显示屏/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /3-2光敏传感器计次/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /4-1定时器定时中断/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /4-2定时器外部时钟/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /4-3PWM驱动LED呼吸灯/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /4-4PWM驱动舵机/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /4-5PWM驱动直流电机/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /4-6输入捕获模式测频率/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /4-8编码器接口测速/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /6-1DMA数据转运/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /6-2DMA+AD多通道/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /7-2串口发送+接收/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /7-3串口收发HEX数据包/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /7-4串口收发文本数据包/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /4-7PWMI模式测频率占空比/Hardware/IC.h: -------------------------------------------------------------------------------- 1 | #ifndef __IC_H 2 | #define __IC_H 3 | 4 | void IC_Init(void); 5 | uint32_t IC_GetFreq(void); 6 | uint32_t IC_GetDuty(void); 7 | 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /4-7PWMI模式测频率占空比/System/Delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | void Delay_us(uint32_t us); 5 | void Delay_ms(uint32_t ms); 6 | void Delay_s(uint32_t s); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /6-1DMA数据转运/System/MyDMA.h: -------------------------------------------------------------------------------- 1 | #ifndef __MYDMA_H 2 | #define __MYDMA_H 3 | 4 | void MyDMA_Init(uint32_t AddrA, uint32_t AddrB, uint16_t Size); 5 | void MyDMA_Transfer(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /4-6输入捕获模式测频率/Hardware/PWM.h: -------------------------------------------------------------------------------- 1 | #ifndef __PWM_H 2 | #define __PWM_H 3 | 4 | void PWM_Init(void); 5 | void PWM_SetCompare1(uint16_t compare); 6 | void PWM_SetPrescaler(uint16_t Prescaler); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /4-7PWMI模式测频率占空比/Hardware/PWM.h: -------------------------------------------------------------------------------- 1 | #ifndef __PWM_H 2 | #define __PWM_H 3 | 4 | void PWM_Init(void); 5 | void PWM_SetCompare1(uint16_t compare); 6 | void PWM_SetPrescaler(uint16_t Prescaler); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /2-3光敏控制蜂鸣器/Hardware/Buzzer.h: -------------------------------------------------------------------------------- 1 | #ifndef __Buzzer_H 2 | #define __Buzzer_H 3 | 4 | void Buzzer_Init(void); 5 | void Buzzer_ON(void); 6 | void Buzzer_OFF(void); 7 | void Buzzer_Turn(void); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /3-3编码器计次/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED0_ON(void); 9 | void LED0_OFF(void); 10 | void LED0_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /5-1AD单通道/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED0_ON(void); 9 | void LED0_OFF(void); 10 | void LED0_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /5-2AD多通道/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED0_ON(void); 9 | void LED0_OFF(void); 10 | void LED0_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /7-1串口发送/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED0_ON(void); 9 | void LED0_OFF(void); 10 | void LED0_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /2-2按键控制LED/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED0_ON(void); 9 | void LED0_OFF(void); 10 | void LED0_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /2-3光敏控制蜂鸣器/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED0_ON(void); 9 | void LED0_OFF(void); 10 | void LED0_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /3-1OLED显示屏/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED0_ON(void); 9 | void LED0_OFF(void); 10 | void LED0_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /3-2光敏传感器计次/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED0_ON(void); 9 | void LED0_OFF(void); 10 | void LED0_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /4-1定时器定时中断/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED0_ON(void); 9 | void LED0_OFF(void); 10 | void LED0_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /4-2定时器外部时钟/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED0_ON(void); 9 | void LED0_OFF(void); 10 | void LED0_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /4-3PWM驱动LED呼吸灯/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED0_ON(void); 9 | void LED0_OFF(void); 10 | void LED0_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /4-4PWM驱动舵机/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED0_ON(void); 9 | void LED0_OFF(void); 10 | void LED0_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /4-5PWM驱动直流电机/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED0_ON(void); 9 | void LED0_OFF(void); 10 | void LED0_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /4-6输入捕获模式测频率/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED0_ON(void); 9 | void LED0_OFF(void); 10 | void LED0_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /4-8编码器接口测速/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED2_ON(void); 9 | void LED2_OFF(void); 10 | void LED2_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /6-1DMA数据转运/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED2_ON(void); 9 | void LED2_OFF(void); 10 | void LED2_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /6-2DMA+AD多通道/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED2_ON(void); 9 | void LED2_OFF(void); 10 | void LED2_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /7-2串口发送+接收/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED0_ON(void); 9 | void LED0_OFF(void); 10 | void LED0_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /7-3串口收发HEX数据包/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED0_ON(void); 9 | void LED0_OFF(void); 10 | void LED0_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /7-4串口收发文本数据包/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED0_ON(void); 9 | void LED0_OFF(void); 10 | void LED0_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /4-7PWMI模式测频率占空比/Hardware/LED.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H 2 | #define __LED_H 3 | 4 | void LED_Init(void); 5 | void LED1_ON(void); 6 | void LED1_OFF(void); 7 | void LED1_Turn(void); 8 | void LED0_ON(void); 9 | void LED0_OFF(void); 10 | void LED0_Turn(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /4-4PWM驱动舵机/Hardware/Servo.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "PWM.h" 3 | 4 | void Servo_Init(void) 5 | { 6 | PWM_Init(); 7 | } 8 | 9 | //0 500 10 | //180 2500 11 | 12 | void Servo_SetAngle(float angle) 13 | { 14 | PWM_SetCompare2(angle / 180 * 2000 +500); 15 | } -------------------------------------------------------------------------------- /3-2光敏传感器计次/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | #include "CountSensor.h" 5 | 6 | 7 | int main(void) 8 | { 9 | OLED_Init(); 10 | CountSensor_Init(); 11 | 12 | OLED_ShowString(1,1,"count:"); 13 | 14 | while (1) 15 | { 16 | 17 | OLED_ShowNum(1,7,CountSensor_Get(),5); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /3-3编码器计次/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | #include "Encoder.h" 5 | 6 | int8_t Num; 7 | 8 | int main(void) 9 | { 10 | OLED_Init(); 11 | Encoder_Init(); 12 | 13 | OLED_ShowString(1,1,"Num:"); 14 | 15 | while (1) 16 | { 17 | Num += Encoder_Get(); 18 | OLED_ShowSignedNum(1,5,Num,5); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /2-3光敏控制蜂鸣器/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "Buzzer.h" 4 | #include "LightSensor.h" 5 | 6 | int main(void) 7 | { 8 | Buzzer_Init(); 9 | LightSensor_Init(); 10 | 11 | while (1) 12 | { 13 | if(LightSensor_Get() == 1) 14 | { 15 | Buzzer_ON(); 16 | } 17 | else{ 18 | Buzzer_OFF(); 19 | } 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /2-2按键控制LED/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "LED.h" 4 | #include "Key.h" 5 | 6 | uint8_t KeyNum; 7 | 8 | int main(void) 9 | { 10 | LED_Init(); 11 | Key_Init(); 12 | 13 | while (1) 14 | { 15 | LED1_Turn(); 16 | KeyNum = Key_GetNum(); 17 | if (KeyNum == 1) 18 | { 19 | LED1_Turn(); 20 | } 21 | if (KeyNum == 2) 22 | { 23 | LED0_Turn(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /7-1串口发送/Hardware/Serial.h: -------------------------------------------------------------------------------- 1 | #ifndef __SERIAL_H 2 | #define __SERIAL_H 3 | 4 | #include 5 | 6 | void Serial_Init(void); 7 | void Serial_SendByte(uint16_t Byte); 8 | void Serial_SendArray(uint8_t *Array, uint16_t Length); 9 | void Serial_SendString(char *String); 10 | uint32_t Serial_Pow(uint32_t X, uint32_t Y); 11 | void Serial_SendNumber(uint32_t Number, uint8_t Length); 12 | int fputc(int ch, FILE *f); 13 | void Serial_Printf(char *format, ...); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /4-3PWM驱动LED呼吸灯/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | #include "PWM.h" 5 | 6 | uint8_t i; 7 | 8 | int main(void) 9 | { 10 | OLED_Init(); 11 | PWM_Init(); 12 | 13 | 14 | while (1) 15 | { 16 | for(i=0; i<=100; i++) 17 | { 18 | PWM_SetCompare1(i); 19 | Delay_ms(10); 20 | } 21 | for(i=0; i<=100; i++) 22 | { 23 | PWM_SetCompare1(100 - i); 24 | Delay_ms(10); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /7-2串口发送+接收/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | #include "Serial.h" 5 | 6 | uint8_t RxData; 7 | 8 | int main(void) 9 | { 10 | OLED_Init(); 11 | 12 | Serial_Init(); 13 | 14 | OLED_ShowString(1,1,"RxData:"); 15 | 16 | 17 | while (1) 18 | { 19 | if(Serial_GetRxFlag() == 1) 20 | { 21 | RxData = Serial_GetRxData(); 22 | Serial_SendByte(RxData); 23 | OLED_ShowHexNum(1,8 ,RxData,2); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /4-6输入捕获模式测频率/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | #include "PWM.h" 5 | #include "IC.h" 6 | 7 | 8 | int main(void) 9 | { 10 | OLED_Init(); 11 | PWM_Init(); 12 | IC_Init(); 13 | 14 | OLED_ShowString(1,1,"Freq:00000Hz"); 15 | 16 | PWM_SetCompare1(720 - 1); //Freq = 72M / (PSC + 1) /100 17 | PWM_SetPrescaler(50); //Duty = CCR / 100 18 | 19 | 20 | while (1) 21 | { 22 | OLED_ShowNum(1,6,IC_GetFreq(),5); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /7-2串口发送+接收/Hardware/Serial.h: -------------------------------------------------------------------------------- 1 | #ifndef __SERIAL_H 2 | #define __SERIAL_H 3 | 4 | #include 5 | 6 | void Serial_Init(void); 7 | void Serial_SendByte(uint16_t Byte); 8 | void Serial_SendArray(uint8_t *Array, uint16_t Length); 9 | void Serial_SendString(char *String); 10 | uint32_t Serial_Pow(uint32_t X, uint32_t Y); 11 | void Serial_SendNumber(uint32_t Number, uint8_t Length); 12 | int fputc(int ch, FILE *f); 13 | void Serial_Printf(char *format, ...); 14 | 15 | uint8_t Serial_GetRxFlag(void); 16 | uint8_t Serial_GetRxData(void); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /4-7PWMI模式测频率占空比/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | #include "PWM.h" 5 | #include "IC.h" 6 | 7 | 8 | int main(void) 9 | { 10 | OLED_Init(); 11 | PWM_Init(); 12 | IC_Init(); 13 | 14 | OLED_ShowString(1,1,"Freq:00000Hz"); 15 | OLED_ShowString(2,1,"Duty:00%"); 16 | 17 | PWM_SetCompare1(7200 - 1); //Freq = 72M / (PSC + 1) /100 18 | PWM_SetPrescaler(80); //Duty = CCR / 100 19 | 20 | 21 | while (1) 22 | { 23 | OLED_ShowNum(1,6,IC_GetFreq(),5); 24 | OLED_ShowNum(2,6,IC_GetDuty(),2); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /4-1定时器定时中断/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | #include "Timer.h" 5 | 6 | uint16_t Num; 7 | 8 | int main(void) 9 | { 10 | OLED_Init(); 11 | Timer_Init(); 12 | 13 | OLED_ShowString(1,1,"Num "); 14 | 15 | while (1) 16 | { 17 | OLED_ShowNum(1,5,Num,5); 18 | OLED_ShowNum(2,5,TIM_GetCounter(TIM2),5); 19 | } 20 | } 21 | 22 | void TIM2_IRQHandler(void) 23 | { 24 | if(TIM_GetITStatus(TIM2,TIM_IT_Update) == SET) 25 | { 26 | Num ++; 27 | TIM_ClearITPendingBit(TIM2,TIM_IT_Update); 28 | } 29 | 30 | } 31 | 32 | -------------------------------------------------------------------------------- /7-4串口收发文本数据包/Hardware/Serial.h: -------------------------------------------------------------------------------- 1 | #ifndef __SERIAL_H 2 | #define __SERIAL_H 3 | 4 | #include 5 | 6 | extern char Serial_RxPacket[]; 7 | extern uint8_t Serial_RxFlag; 8 | 9 | void Serial_Init(void); 10 | void Serial_SendByte(uint16_t Byte); 11 | void Serial_SendArray(uint8_t *Array, uint16_t Length); 12 | void Serial_SendString(char *String); 13 | uint32_t Serial_Pow(uint32_t X, uint32_t Y); 14 | void Serial_SendNumber(uint32_t Number, uint8_t Length); 15 | int fputc(int ch, FILE *f); 16 | void Serial_Printf(char *format, ...); 17 | 18 | //uint8_t Serial_GetRxFlag(void); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /2-3光敏控制蜂鸣器/Hardware/LightSensor.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LightSensor_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOB, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOB, GPIO_Pin_13); 14 | } 15 | 16 | uint8_t LightSensor_Get(void) 17 | { 18 | return GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_13); 19 | } 20 | 21 | -------------------------------------------------------------------------------- /4-4PWM驱动舵机/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | #include "Servo.h" 5 | #include "Key.h" 6 | 7 | uint8_t KeyNum; 8 | float Angle; 9 | 10 | int main(void) 11 | { 12 | OLED_Init(); 13 | Servo_Init(); 14 | Key_Init(); 15 | 16 | OLED_ShowString(1,1,"Angle:"); 17 | 18 | while (1) 19 | { 20 | KeyNum = Key_GetNum(); 21 | if(KeyNum == 1) 22 | { 23 | Angle += 30; 24 | if(Angle >= 180) 25 | { 26 | Angle = 0; 27 | } 28 | } 29 | Servo_SetAngle(Angle); 30 | OLED_ShowNum(1,7,Angle,3); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /6-2DMA+AD多通道/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | #include "AD.h" 5 | 6 | int main(void) 7 | { 8 | OLED_Init(); 9 | AD_Init(); 10 | 11 | OLED_ShowString(1, 1, "AD0:"); 12 | OLED_ShowString(2, 1, "AD1:"); 13 | OLED_ShowString(3, 1, "AD2:"); 14 | OLED_ShowString(4, 1, "AD3:"); 15 | 16 | while (1) 17 | { 18 | OLED_ShowNum(1, 5, AD_Value[0], 4); 19 | OLED_ShowNum(2, 5, AD_Value[1], 4); 20 | OLED_ShowNum(3, 5, AD_Value[2], 4); 21 | OLED_ShowNum(4, 5, AD_Value[3], 4); 22 | 23 | Delay_ms(100); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /4-5PWM驱动直流电机/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | #include "Motor.h" 5 | #include "Key.h" 6 | 7 | uint8_t KeyNum; 8 | int8_t Speed; 9 | 10 | int main(void) 11 | { 12 | OLED_Init(); 13 | Motor_Init(); 14 | Key_Init(); 15 | 16 | OLED_ShowString(1,1,"Speed:"); 17 | 18 | while (1) 19 | { 20 | KeyNum = Key_GetNum(); 21 | if(KeyNum == 1) 22 | { 23 | Speed += 20; 24 | if(Speed > 100) 25 | { 26 | Speed = -20; 27 | } 28 | Motor_SetSpeed(Speed); 29 | OLED_ShowSignedNum(1,7,Speed,3); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /4-8编码器接口测速/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | #include "Timer.h" 5 | #include "Encoder.h" 6 | 7 | int16_t Speed; 8 | 9 | int main(void) 10 | { 11 | OLED_Init(); 12 | Timer_Init(); 13 | Encoder_Init(); 14 | 15 | OLED_ShowString(1, 1, "Speed:"); 16 | 17 | while (1) 18 | { 19 | OLED_ShowSignedNum(1, 7, Speed, 5); 20 | } 21 | } 22 | 23 | void TIM2_IRQHandler(void) 24 | { 25 | if (TIM_GetITStatus(TIM2, TIM_IT_Update) == SET) 26 | { 27 | Speed = Encoder_Get(); 28 | TIM_ClearITPendingBit(TIM2, TIM_IT_Update); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /7-1串口发送/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /3-1OLED显示屏/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /3-2光敏传感器计次/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /3-3编码器计次/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /4-1定时器定时中断/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /4-2定时器外部时钟/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /4-4PWM驱动舵机/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /4-5PWM驱动直流电机/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /4-6输入捕获模式测频率/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /4-8编码器接口测速/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /5-1AD单通道/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /5-2AD多通道/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /6-1DMA数据转运/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /6-2DMA+AD多通道/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /7-2串口发送+接收/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /7-4串口收发文本数据包/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /4-3PWM驱动LED呼吸灯/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /4-7PWMI模式测频率占空比/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /7-3串口收发HEX数据包/Hardware/OLED.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | void OLED_Init(void); 5 | void OLED_Clear(void); 6 | void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char); 7 | void OLED_ShowString(uint8_t Line, uint8_t Column, char *String); 8 | void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 9 | void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length); 10 | void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 11 | void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /4-2定时器外部时钟/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | #include "Timer.h" 5 | 6 | uint16_t Num; 7 | 8 | int main(void) 9 | { 10 | OLED_Init(); 11 | Timer_Init(); 12 | 13 | OLED_ShowString(1,1,"Num "); 14 | OLED_ShowString(2,1,"CNT "); 15 | 16 | while (1) 17 | { 18 | OLED_ShowNum(1,5,Num,5); 19 | OLED_ShowNum(2,5,Timer_GetCounter(),5); 20 | } 21 | } 22 | 23 | void TIM2_IRQHandler(void) 24 | { 25 | if(TIM_GetITStatus(TIM2,TIM_IT_Update) == SET) 26 | { 27 | Num ++; 28 | TIM_ClearITPendingBit(TIM2,TIM_IT_Update); 29 | } 30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /7-3串口收发HEX数据包/Hardware/Serial.h: -------------------------------------------------------------------------------- 1 | #ifndef __SERIAL_H 2 | #define __SERIAL_H 3 | 4 | #include 5 | 6 | extern uint8_t Serial_RxPacket[]; 7 | extern uint8_t Serial_TxPacket[]; 8 | 9 | void Serial_Init(void); 10 | void Serial_SendByte(uint16_t Byte); 11 | void Serial_SendArray(uint8_t *Array, uint16_t Length); 12 | void Serial_SendString(char *String); 13 | uint32_t Serial_Pow(uint32_t X, uint32_t Y); 14 | void Serial_SendNumber(uint32_t Number, uint8_t Length); 15 | int fputc(int ch, FILE *f); 16 | void Serial_Printf(char *format, ...); 17 | 18 | uint8_t Serial_GetRxFlag(void); 19 | void Serial_SendPacket(void); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /3-1OLED显示屏/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | 5 | 6 | int main(void) 7 | { 8 | OLED_Init(); 9 | 10 | //OLED_ShowChar(1,1,'A'); 11 | //OLED_ShowString(1,1,"HelloTT!"); 12 | //OLED_ShowNum(2,1,5201314,7); 13 | //OLED_ShowString(3,1,"Love u always!"); 14 | //OLED_ShowSignedNum(2,9,-33,2); 15 | //OLED_ShowHexNum(3,1,0xAA55,4); 16 | //OLED_ShowBinNum(4,1,0xAA55,16); 17 | 18 | OLED_ShowString(1,4,"** **"); 19 | OLED_ShowString(2,3,"*******"); 20 | OLED_ShowString(3,4,"*****"); 21 | OLED_ShowString(4,6,"*"); 22 | 23 | while (1) 24 | { 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /2-1蜂鸣器/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | int main(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | 14 | while (1) 15 | { 16 | GPIO_ResetBits(GPIOB, GPIO_Pin_12); 17 | Delay_ms(100); 18 | GPIO_SetBits(GPIOB, GPIO_Pin_12); 19 | Delay_ms(100); 20 | GPIO_ResetBits(GPIOB, GPIO_Pin_12); 21 | Delay_ms(100); 22 | GPIO_SetBits(GPIOB, GPIO_Pin_12); 23 | Delay_ms(700); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /7-1串口发送/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | #include "Serial.h" 5 | 6 | 7 | int main(void) 8 | { 9 | OLED_Init(); 10 | 11 | Serial_Init(); 12 | 13 | Serial_SendByte(0x41); 14 | 15 | uint8_t MyArray[] = {0x42,0x43,0x44,0x45}; 16 | Serial_SendArray(MyArray,4); 17 | 18 | Serial_SendString("HelloWorld!\r\n"); 19 | 20 | Serial_SendNumber(12345,5); 21 | 22 | printf("Num=%d\r\n",666); 23 | 24 | char String[100]; 25 | sprintf(String,"Num=%d\r\n",666); 26 | Serial_SendString(String); 27 | 28 | Serial_Printf("Num=%d\r\n",666); 29 | 30 | //Serial_Printf("你好,世界"); //添加 --no--multibyte--chars 31 | 32 | 33 | while (1) 34 | { 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /5-1AD单通道/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | #include "AD.h" 5 | #include "LED.h" 6 | 7 | uint16_t ADValue; 8 | float Voltage; 9 | 10 | int main(void) 11 | { 12 | OLED_Init(); 13 | AD_Init(); 14 | LED_Init(); 15 | 16 | 17 | OLED_ShowString(1,1,"ADValue:"); 18 | OLED_ShowString(2,1,"Voltage:0.00V"); 19 | 20 | 21 | while (1) 22 | { 23 | ADValue = AD_GetValue(); 24 | Voltage = (float)ADValue / 4095 * 3.3; 25 | 26 | OLED_ShowNum(1,9,ADValue,4); 27 | OLED_ShowNum(2,9,Voltage,1); 28 | OLED_ShowNum(2,11,(uint16_t)(Voltage * 100) % 100,2); 29 | 30 | Delay_ms(100); 31 | 32 | if(ADValue < 4000) 33 | { 34 | LED1_ON(); 35 | } 36 | else 37 | { 38 | LED1_OFF(); 39 | } 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /4-5PWM驱动直流电机/Hardware/Motor.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "PWM.h" 3 | 4 | void Motor_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //引脚输出 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOA, &GPIO_InitStructure); 13 | 14 | PWM_Init(); 15 | } 16 | 17 | void Motor_SetSpeed(int8_t speed) 18 | { 19 | if(speed > 0) 20 | { 21 | GPIO_SetBits(GPIOA,GPIO_Pin_4); 22 | GPIO_ResetBits(GPIOA,GPIO_Pin_5); 23 | PWM_SetCompare3(speed); 24 | } 25 | else 26 | { 27 | GPIO_ResetBits(GPIOA,GPIO_Pin_4); 28 | GPIO_SetBits(GPIOA,GPIO_Pin_5); 29 | PWM_SetCompare3(-speed); 30 | } 31 | } -------------------------------------------------------------------------------- /2-1蜂鸣器/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /1-1LED闪烁/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /2-2按键控制LED/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /2-3光敏控制蜂鸣器/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /3-1OLED显示屏/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /3-2光敏传感器计次/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /3-3编码器计次/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /4-1定时器定时中断/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /4-2定时器外部时钟/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /4-4PWM驱动舵机/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /4-8编码器接口测速/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /5-1AD单通道/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /5-2AD多通道/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /6-1DMA数据转运/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /7-1串口发送/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /7-2串口发送+接收/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /4-3PWM驱动LED呼吸灯/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /4-5PWM驱动直流电机/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /4-6输入捕获模式测频率/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /4-7PWMI模式测频率占空比/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /6-2DMA+AD多通道/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /7-3串口收发HEX数据包/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /7-4串口收发文本数据包/System/Delay.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | /** 4 | * @brief 微秒级延时 5 | * @param xus 延时时长,范围:0~233015 6 | * @retval 无 7 | */ 8 | void Delay_us(uint32_t xus) 9 | { 10 | SysTick->LOAD = 72 * xus; //设置定时器重装值 11 | SysTick->VAL = 0x00; //清空当前计数值 12 | SysTick->CTRL = 0x00000005; //设置时钟源为HCLK,启动定时器 13 | while(!(SysTick->CTRL & 0x00010000)); //等待计数到0 14 | SysTick->CTRL = 0x00000004; //关闭定时器 15 | } 16 | 17 | /** 18 | * @brief 毫秒级延时 19 | * @param xms 延时时长,范围:0~4294967295 20 | * @retval 无 21 | */ 22 | void Delay_ms(uint32_t xms) 23 | { 24 | while(xms--) 25 | { 26 | Delay_us(1000); 27 | } 28 | } 29 | 30 | /** 31 | * @brief 秒级延时 32 | * @param xs 延时时长,范围:0~4294967295 33 | * @retval 无 34 | */ 35 | void Delay_s(uint32_t xs) 36 | { 37 | while(xs--) 38 | { 39 | Delay_ms(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /5-2AD多通道/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | #include "AD.h" 5 | #include "LED.h" 6 | 7 | uint16_t ADValue; 8 | float Voltage; 9 | uint8_t AD0,AD1,AD2,AD3; 10 | 11 | int main(void) 12 | { 13 | OLED_Init(); 14 | AD_Init(); 15 | LED_Init(); 16 | 17 | 18 | OLED_ShowString(1,1,"AD0:"); 19 | OLED_ShowString(2,1,"AD1:"); 20 | OLED_ShowString(3,1,"AD2:"); 21 | OLED_ShowString(4,1,"AD3:"); 22 | 23 | 24 | while (1) 25 | { 26 | AD0 = AD_GetValue(ADC_Channel_0); 27 | AD1 = AD_GetValue(ADC_Channel_1); 28 | AD2 = AD_GetValue(ADC_Channel_2); 29 | AD3 = AD_GetValue(ADC_Channel_3); 30 | 31 | 32 | OLED_ShowNum(1,5,AD0,4); 33 | OLED_ShowNum(2,5,AD1,4); 34 | OLED_ShowNum(2,5,AD2,4); 35 | OLED_ShowNum(2,5,AD3,4); 36 | 37 | Delay_ms(100); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /2-3光敏控制蜂鸣器/Hardware/Buzzer.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void Buzzer_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_7); 14 | } 15 | 16 | void Buzzer_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_7); 19 | } 20 | 21 | void Buzzer_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_7); 24 | } 25 | 26 | void Buzzer_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_7) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_7); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_7); 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /2-2按键控制LED/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /2-3光敏控制蜂鸣器/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /3-1OLED显示屏/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /3-2光敏传感器计次/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /3-3编码器计次/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /4-1定时器定时中断/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /4-2定时器外部时钟/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /4-4PWM驱动舵机/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /5-1AD单通道/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /5-2AD多通道/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /7-1串口发送/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /7-2串口发送+接收/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /4-3PWM驱动LED呼吸灯/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /4-5PWM驱动直流电机/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /4-6输入捕获模式测频率/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /4-7PWMI模式测频率占空比/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /4-8编码器接口测速/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_11; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_11) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_11) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /6-1DMA数据转运/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_11; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_11) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_11) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /6-2DMA+AD多通道/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_11; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_11) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_11) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /7-3串口收发HEX数据包/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /7-4串口收发文本数据包/Hardware/Key.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | void Key_Init(void) 5 | { 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOB, &GPIO_InitStructure); 13 | } 14 | 15 | uint8_t Key_GetNum(void) 16 | { 17 | uint8_t KeyNum = 0; 18 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0) 19 | { 20 | Delay_ms(20); 21 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0); 22 | Delay_ms(20); 23 | KeyNum = 1; 24 | } 25 | if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) 26 | { 27 | Delay_ms(20); 28 | while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0); 29 | Delay_ms(20); 30 | KeyNum = 2; 31 | } 32 | 33 | return KeyNum; 34 | } 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 xiaoju 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /1-1LED闪烁/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | 4 | int main(void){ 5 | 6 | GPIO_InitTypeDef GPIO_InitStructure; //变量应在主函数开头声明 7 | 8 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); //开启时钟 9 | 10 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 11 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; 12 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 13 | GPIO_Init(GPIOA,&GPIO_InitStructure); 14 | 15 | 16 | while(1) 17 | { 18 | GPIO_Write(GPIOA,~0x0001); // 0000 0000 0000 0001 19 | Delay_ms(100); 20 | GPIO_Write(GPIOA,~0x0002); // 0000 0000 0000 0010 21 | Delay_ms(100); 22 | GPIO_Write(GPIOA,~0x0004); // 0000 0000 0000 0100 23 | Delay_ms(100); 24 | GPIO_Write(GPIOA,~0x0008); // 0000 0000 0000 1000 25 | Delay_ms(100); 26 | GPIO_Write(GPIOA,~0x0010); // 0000 0000 0000 0001 27 | Delay_ms(100); 28 | GPIO_Write(GPIOA,~0x0020); // 0000 0000 0001 0000 29 | Delay_ms(100); 30 | GPIO_Write(GPIOA,~0x0040); // 0000 0000 0010 0000 31 | Delay_ms(100); 32 | GPIO_Write(GPIOA,~0x0080); // 0000 0000 0100 0000 33 | Delay_ms(100); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /7-4串口收发文本数据包/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | #include "Serial.h" 5 | #include "LED.h" 6 | #include 7 | 8 | 9 | int main(void) 10 | { 11 | OLED_Init(); 12 | LED_Init(); 13 | Serial_Init(); 14 | 15 | OLED_ShowString(1,1,"TxPacket:"); 16 | OLED_ShowString(1,1,"RxPacket:"); 17 | 18 | 19 | while (1) 20 | { 21 | if(Serial_RxFlag == 1) 22 | { 23 | OLED_ShowString(4,1," "); 24 | OLED_ShowString(4,1,Serial_RxPacket); 25 | 26 | if(strcmp(Serial_RxPacket,"LED_ON") == 0) 27 | { 28 | LED1_ON(); 29 | Serial_SendString("LED_ON_OK\r\n"); 30 | OLED_ShowString(2,1," "); 31 | OLED_ShowString(2,1,"LED_ON_OK"); 32 | } 33 | else if(strcmp(Serial_RxPacket,"LED_OFF") == 0) 34 | { 35 | LED1_OFF(); 36 | Serial_SendString("LED_OFF_OK\r\n"); 37 | OLED_ShowString(2,1," "); 38 | OLED_ShowString(2,1,"LED_OFF_OK"); 39 | } 40 | else 41 | { 42 | Serial_SendString("ERROR_CMD\r\n"); 43 | OLED_ShowString(2,1," "); 44 | OLED_ShowString(2,1,"ERROR_CMD"); 45 | } 46 | 47 | Serial_RxFlag = 0; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /3-3编码器计次/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_0); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED0_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 41 | } 42 | 43 | void LED0_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 46 | } 47 | 48 | void LED0_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_0) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /5-1AD单通道/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_0); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED0_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 41 | } 42 | 43 | void LED0_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 46 | } 47 | 48 | void LED0_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_0) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /5-2AD多通道/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_0); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED0_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 41 | } 42 | 43 | void LED0_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 46 | } 47 | 48 | void LED0_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_0) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /7-1串口发送/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_0); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED0_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 41 | } 42 | 43 | void LED0_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 46 | } 47 | 48 | void LED0_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_0) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /2-2按键控制LED/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_0); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED0_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 41 | } 42 | 43 | void LED0_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 46 | } 47 | 48 | void LED0_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_0) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /2-3光敏控制蜂鸣器/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_0); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED0_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 41 | } 42 | 43 | void LED0_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 46 | } 47 | 48 | void LED0_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_0) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /3-1OLED显示屏/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_0); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED0_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 41 | } 42 | 43 | void LED0_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 46 | } 47 | 48 | void LED0_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_0) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /3-2光敏传感器计次/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_0); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED0_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 41 | } 42 | 43 | void LED0_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 46 | } 47 | 48 | void LED0_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_0) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /4-1定时器定时中断/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_0); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED0_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 41 | } 42 | 43 | void LED0_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 46 | } 47 | 48 | void LED0_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_0) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /4-2定时器外部时钟/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_0); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED0_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 41 | } 42 | 43 | void LED0_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 46 | } 47 | 48 | void LED0_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_0) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /4-4PWM驱动舵机/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_0); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED0_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 41 | } 42 | 43 | void LED0_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 46 | } 47 | 48 | void LED0_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_0) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /4-5PWM驱动直流电机/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_0); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED0_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 41 | } 42 | 43 | void LED0_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 46 | } 47 | 48 | void LED0_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_0) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /4-6输入捕获模式测频率/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_0); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED0_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 41 | } 42 | 43 | void LED0_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 46 | } 47 | 48 | void LED0_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_0) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /4-8编码器接口测速/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_2); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED2_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_2); 41 | } 42 | 43 | void LED2_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_2); 46 | } 47 | 48 | void LED2_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_2) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_2); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_2); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /6-1DMA数据转运/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_2); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED2_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_2); 41 | } 42 | 43 | void LED2_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_2); 46 | } 47 | 48 | void LED2_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_2) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_2); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_2); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /6-2DMA+AD多通道/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_2); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED2_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_2); 41 | } 42 | 43 | void LED2_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_2); 46 | } 47 | 48 | void LED2_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_2) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_2); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_2); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /7-2串口发送+接收/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_0); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED0_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 41 | } 42 | 43 | void LED0_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 46 | } 47 | 48 | void LED0_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_0) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /7-3串口收发HEX数据包/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_0); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED0_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 41 | } 42 | 43 | void LED0_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 46 | } 47 | 48 | void LED0_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_0) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /7-4串口收发文本数据包/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_0); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED0_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 41 | } 42 | 43 | void LED0_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 46 | } 47 | 48 | void LED0_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_0) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /4-3PWM驱动LED呼吸灯/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_0); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED0_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 41 | } 42 | 43 | void LED0_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 46 | } 47 | 48 | void LED0_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_0) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /4-7PWMI模式测频率占空比/Hardware/LED.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void LED_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 6 | 7 | GPIO_InitTypeDef GPIO_InitStructure; 8 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; 10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 11 | GPIO_Init(GPIOA, &GPIO_InitStructure); 12 | 13 | GPIO_SetBits(GPIOA, GPIO_Pin_1 | GPIO_Pin_0); 14 | } 15 | 16 | void LED1_ON(void) 17 | { 18 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 19 | } 20 | 21 | void LED1_OFF(void) 22 | { 23 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 24 | } 25 | 26 | void LED1_Turn(void) 27 | { 28 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1) == 0) 29 | { 30 | GPIO_SetBits(GPIOA, GPIO_Pin_1); 31 | } 32 | else 33 | { 34 | GPIO_ResetBits(GPIOA, GPIO_Pin_1); 35 | } 36 | } 37 | 38 | void LED0_ON(void) 39 | { 40 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 41 | } 42 | 43 | void LED0_OFF(void) 44 | { 45 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 46 | } 47 | 48 | void LED0_Turn(void) 49 | { 50 | if (GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_0) == 0) 51 | { 52 | GPIO_SetBits(GPIOA, GPIO_Pin_0); 53 | } 54 | else 55 | { 56 | GPIO_ResetBits(GPIOA, GPIO_Pin_0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /7-3串口收发HEX数据包/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | #include "Serial.h" 5 | #include "Key.h" 6 | 7 | uint8_t RxData; 8 | uint8_t KeyNum; 9 | 10 | int main(void) 11 | { 12 | OLED_Init(); 13 | Key_Init(); 14 | Serial_Init(); 15 | 16 | OLED_ShowString(1,1,"TxPacket:"); 17 | OLED_ShowString(1,1,"RxPacket:"); 18 | 19 | Serial_TxPacket[0] = 0x01; 20 | Serial_TxPacket[1] = 0x02; 21 | Serial_TxPacket[2] = 0x03; 22 | Serial_TxPacket[3] = 0x04; 23 | 24 | 25 | while (1) 26 | { 27 | KeyNum = Key_GetNum(); 28 | if(KeyNum == 1) 29 | { 30 | Serial_TxPacket[0] ++; 31 | Serial_TxPacket[1] ++; 32 | Serial_TxPacket[2] ++; 33 | Serial_TxPacket[3] ++; 34 | 35 | Serial_SendPacket(); 36 | 37 | OLED_ShowHexNum(2,1,Serial_TxPacket[0],2); 38 | OLED_ShowHexNum(2,4,Serial_TxPacket[1],2); 39 | OLED_ShowHexNum(2,7,Serial_TxPacket[2],2); 40 | OLED_ShowHexNum(2,10,Serial_TxPacket[3],2); 41 | } 42 | 43 | if(Serial_GetRxFlag() == 1) 44 | { 45 | OLED_ShowHexNum(4,1,Serial_RxPacket[0],2); 46 | OLED_ShowHexNum(4,4,Serial_RxPacket[1],2); 47 | OLED_ShowHexNum(4,7,Serial_RxPacket[2],2); 48 | OLED_ShowHexNum(4,10,Serial_RxPacket[3],2); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /4-8编码器接口测速/System/Timer.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void Timer_Init(void) 4 | { 5 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); 6 | 7 | TIM_InternalClockConfig(TIM2); 8 | 9 | TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure; 10 | TIM_TimeBaseInitStructure.TIM_ClockDivision = TIM_CKD_DIV1; 11 | TIM_TimeBaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up; 12 | TIM_TimeBaseInitStructure.TIM_Period = 10000 - 1; 13 | TIM_TimeBaseInitStructure.TIM_Prescaler = 7200 - 1; 14 | TIM_TimeBaseInitStructure.TIM_RepetitionCounter = 0; 15 | TIM_TimeBaseInit(TIM2, &TIM_TimeBaseInitStructure); 16 | 17 | TIM_ClearFlag(TIM2, TIM_FLAG_Update); 18 | TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE); 19 | 20 | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); 21 | 22 | NVIC_InitTypeDef NVIC_InitStructure; 23 | NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn; 24 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 25 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; 26 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; 27 | NVIC_Init(&NVIC_InitStructure); 28 | 29 | TIM_Cmd(TIM2, ENABLE); 30 | } 31 | 32 | /* 33 | void TIM2_IRQHandler(void) 34 | { 35 | if (TIM_GetITStatus(TIM2, TIM_IT_Update) == SET) 36 | { 37 | 38 | TIM_ClearITPendingBit(TIM2, TIM_IT_Update); 39 | } 40 | } 41 | */ 42 | -------------------------------------------------------------------------------- /6-1DMA数据转运/System/MyDMA.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | uint16_t MyDMA_Size; 4 | 5 | void MyDMA_Init(uint32_t AddrA, uint32_t AddrB, uint16_t Size) 6 | { 7 | MyDMA_Size = Size; 8 | 9 | RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); 10 | 11 | DMA_InitTypeDef DMA_InitStructure; 12 | DMA_InitStructure.DMA_PeripheralBaseAddr = AddrA; 13 | DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; 14 | DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Enable; 15 | DMA_InitStructure.DMA_MemoryBaseAddr = AddrB; 16 | DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; 17 | DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; 18 | DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; 19 | DMA_InitStructure.DMA_BufferSize = Size; 20 | DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; 21 | DMA_InitStructure.DMA_M2M = DMA_M2M_Enable; 22 | DMA_InitStructure.DMA_Priority = DMA_Priority_Medium; 23 | DMA_Init(DMA1_Channel1, &DMA_InitStructure); 24 | 25 | DMA_Cmd(DMA1_Channel1, DISABLE); 26 | } 27 | 28 | void MyDMA_Transfer(void) 29 | { 30 | DMA_Cmd(DMA1_Channel1, DISABLE); 31 | DMA_SetCurrDataCounter(DMA1_Channel1, MyDMA_Size); 32 | DMA_Cmd(DMA1_Channel1, ENABLE); 33 | 34 | while (DMA_GetFlagStatus(DMA1_FLAG_TC1) == RESET); 35 | DMA_ClearFlag(DMA1_FLAG_TC1); 36 | } 37 | -------------------------------------------------------------------------------- /6-1DMA数据转运/User/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include "Delay.h" 3 | #include "OLED.h" 4 | #include "MyDMA.h" 5 | 6 | uint8_t DataA[] = {0x01, 0x02, 0x03, 0x04}; 7 | uint8_t DataB[] = {0, 0, 0, 0}; 8 | 9 | int main(void) 10 | { 11 | OLED_Init(); 12 | 13 | MyDMA_Init((uint32_t)DataA, (uint32_t)DataB, 4); 14 | 15 | OLED_ShowString(1, 1, "DataA"); 16 | OLED_ShowString(3, 1, "DataB"); 17 | OLED_ShowHexNum(1, 8, (uint32_t)DataA, 8); 18 | OLED_ShowHexNum(3, 8, (uint32_t)DataB, 8); 19 | 20 | while (1) 21 | { 22 | DataA[0] ++; 23 | DataA[1] ++; 24 | DataA[2] ++; 25 | DataA[3] ++; 26 | 27 | OLED_ShowHexNum(2, 1, DataA[0], 2); 28 | OLED_ShowHexNum(2, 4, DataA[1], 2); 29 | OLED_ShowHexNum(2, 7, DataA[2], 2); 30 | OLED_ShowHexNum(2, 10, DataA[3], 2); 31 | OLED_ShowHexNum(4, 1, DataB[0], 2); 32 | OLED_ShowHexNum(4, 4, DataB[1], 2); 33 | OLED_ShowHexNum(4, 7, DataB[2], 2); 34 | OLED_ShowHexNum(4, 10, DataB[3], 2); 35 | 36 | Delay_ms(1000); 37 | 38 | MyDMA_Transfer(); 39 | 40 | OLED_ShowHexNum(2, 1, DataA[0], 2); 41 | OLED_ShowHexNum(2, 4, DataA[1], 2); 42 | OLED_ShowHexNum(2, 7, DataA[2], 2); 43 | OLED_ShowHexNum(2, 10, DataA[3], 2); 44 | OLED_ShowHexNum(4, 1, DataB[0], 2); 45 | OLED_ShowHexNum(4, 4, DataB[1], 2); 46 | OLED_ShowHexNum(4, 7, DataB[2], 2); 47 | OLED_ShowHexNum(4, 10, DataB[3], 2); 48 | 49 | Delay_ms(1000); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /4-1定时器定时中断/System/Timer.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | //extern uint16_t Num; 4 | 5 | void Timer_Init(void) 6 | { 7 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); //RCC内部时钟 8 | 9 | TIM_InternalClockConfig(TIM2); //配置内部时钟 10 | 11 | TIM_TimeBaseInitTypeDef Tim_TimeBaseInitStructor; //时基单元 12 | Tim_TimeBaseInitStructor.TIM_ClockDivision = TIM_CKD_DIV1; 13 | Tim_TimeBaseInitStructor.TIM_CounterMode = TIM_CounterMode_Up; 14 | Tim_TimeBaseInitStructor.TIM_Period = 10000 - 1; 15 | Tim_TimeBaseInitStructor.TIM_Prescaler = 7200 -1; 16 | Tim_TimeBaseInitStructor.TIM_RepetitionCounter = 0; 17 | TIM_TimeBaseInit(TIM2,&Tim_TimeBaseInitStructor); 18 | 19 | TIM_ClearFlag(TIM2,TIM_FLAG_Update); //清除中断标志位,从0开始 20 | 21 | TIM_ITConfig(TIM2,TIM_IT_Update,ENABLE); //使能中断 22 | 23 | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //NVIC配置 24 | NVIC_InitTypeDef NVIC_InitStructure; 25 | NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn; 26 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 27 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; 28 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; 29 | NVIC_Init(&NVIC_InitStructure); 30 | 31 | TIM_Cmd(TIM2,ENABLE); //开启定时器 32 | } 33 | 34 | 35 | //void TIM2_IRQHandler(void) 36 | //{ 37 | // if(TIM_GetITStatus(TIM2,TIM_IT_Update) == SET) 38 | // { 39 | // Num ++; 40 | // TIM_ClearITPendingBit(TIM2,TIM_IT_Update); 41 | // } 42 | // 43 | //} 44 | -------------------------------------------------------------------------------- /4-5PWM驱动直流电机/Hardware/PWM.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void PWM_Init(void) 4 | { 5 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); //RCC内部时钟 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //引脚输出 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOA, &GPIO_InitStructure); 13 | 14 | TIM_InternalClockConfig(TIM2); 15 | 16 | TIM_TimeBaseInitTypeDef Tim_TimeBaseInitStructor; //时基单元 17 | Tim_TimeBaseInitStructor.TIM_ClockDivision = TIM_CKD_DIV1; 18 | Tim_TimeBaseInitStructor.TIM_CounterMode = TIM_CounterMode_Up; 19 | Tim_TimeBaseInitStructor.TIM_Period = 100 - 1; //ARR 20 | Tim_TimeBaseInitStructor.TIM_Prescaler = 720 -1; //PSC 21 | Tim_TimeBaseInitStructor.TIM_RepetitionCounter = 0; 22 | TIM_TimeBaseInit(TIM2,&Tim_TimeBaseInitStructor); 23 | 24 | TIM_OCInitTypeDef TIM_OCInitStructure; 25 | TIM_OCStructInit(&TIM_OCInitStructure); 26 | TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; 27 | TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; 28 | TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; 29 | TIM_OCInitStructure.TIM_Pulse = 0; //CCR 30 | TIM_OC3Init(TIM2,&TIM_OCInitStructure); 31 | 32 | TIM_Cmd(TIM2,ENABLE); //开启定时器 33 | 34 | } 35 | 36 | void PWM_SetCompare3(uint16_t compare) 37 | { 38 | TIM_SetCompare3(TIM2,compare); 39 | } -------------------------------------------------------------------------------- /4-3PWM驱动LED呼吸灯/Hardware/PWM.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void PWM_Init(void) 4 | { 5 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); //RCC内部时钟 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //引脚输出 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOA, &GPIO_InitStructure); 13 | 14 | TIM_InternalClockConfig(TIM2); 15 | 16 | TIM_TimeBaseInitTypeDef Tim_TimeBaseInitStructor; //时基单元 17 | Tim_TimeBaseInitStructor.TIM_ClockDivision = TIM_CKD_DIV1; 18 | Tim_TimeBaseInitStructor.TIM_CounterMode = TIM_CounterMode_Up; 19 | Tim_TimeBaseInitStructor.TIM_Period = 100 - 1; //ARR 20 | Tim_TimeBaseInitStructor.TIM_Prescaler = 720 -1; //PSC 21 | Tim_TimeBaseInitStructor.TIM_RepetitionCounter = 0; 22 | TIM_TimeBaseInit(TIM2,&Tim_TimeBaseInitStructor); 23 | 24 | TIM_OCInitTypeDef TIM_OCInitStructure; 25 | TIM_OCStructInit(&TIM_OCInitStructure); 26 | TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; 27 | TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; 28 | TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; 29 | TIM_OCInitStructure.TIM_Pulse = 90; //CCR 30 | TIM_OC1Init(TIM2,&TIM_OCInitStructure); 31 | 32 | TIM_Cmd(TIM2,ENABLE); //开启定时器 33 | 34 | } 35 | 36 | void PWM_SetCompare1(uint16_t compare) 37 | { 38 | TIM_SetCompare1(TIM2,compare); 39 | } -------------------------------------------------------------------------------- /5-1AD单通道/Hardware/AD.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | void AD_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); //开启时钟 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 7 | 8 | RCC_ADCCLKConfig(RCC_PCLK2_Div6); 9 | 10 | GPIO_InitTypeDef GPIO_InitStructure; //配置GPIO 11 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; 12 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; 13 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 14 | GPIO_Init(GPIOB, &GPIO_InitStructure); 15 | 16 | ADC_RegularChannelConfig(ADC1,ADC_Channel_0,1,ADC_SampleTime_55Cycles5); //选择输入通道 17 | 18 | ADC_InitTypeDef ADC_InitStructure; //初始化ADC 单次转换、非扫描模式 19 | ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; 20 | ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; 21 | ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; 22 | ADC_InitStructure.ADC_ScanConvMode = DISABLE; 23 | ADC_InitStructure.ADC_ContinuousConvMode = DISABLE; 24 | ADC_InitStructure.ADC_NbrOfChannel = 1; 25 | ADC_Init(ADC1,&ADC_InitStructure); 26 | 27 | ADC_Cmd(ADC1,ENABLE); //ADC上电 28 | 29 | ADC_ResetCalibration(ADC1); //复位校准 30 | while (ADC_GetResetCalibrationStatus(ADC1) == SET); 31 | ADC_StartCalibration(ADC1); 32 | while (ADC_GetCalibrationStatus(ADC1) == SET); 33 | 34 | } 35 | 36 | uint16_t AD_GetValue(void) 37 | { 38 | ADC_SoftwareStartConvCmd(ADC1,ENABLE); 39 | while (ADC_GetFlagStatus(ADC1,ADC_FLAG_EOC) == RESET); 40 | return ADC_GetConversionValue(ADC1); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /4-4PWM驱动舵机/Hardware/PWM.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void PWM_Init(void) 4 | { 5 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); //RCC内部时钟 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //引脚输出 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOA, &GPIO_InitStructure); 13 | 14 | TIM_InternalClockConfig(TIM2); 15 | 16 | TIM_TimeBaseInitTypeDef Tim_TimeBaseInitStructor; //时基单元 17 | Tim_TimeBaseInitStructor.TIM_ClockDivision = TIM_CKD_DIV1; 18 | Tim_TimeBaseInitStructor.TIM_CounterMode = TIM_CounterMode_Up; 19 | Tim_TimeBaseInitStructor.TIM_Period = 20000 - 1; //ARR 20 | Tim_TimeBaseInitStructor.TIM_Prescaler = 72 -1; //PSC 21 | Tim_TimeBaseInitStructor.TIM_RepetitionCounter = 0; 22 | TIM_TimeBaseInit(TIM2,&Tim_TimeBaseInitStructor); 23 | 24 | TIM_OCInitTypeDef TIM_OCInitStructure; 25 | TIM_OCStructInit(&TIM_OCInitStructure); 26 | TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; 27 | TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; 28 | TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; 29 | TIM_OCInitStructure.TIM_Pulse = 0; //CCR 30 | TIM_OC2Init(TIM2,&TIM_OCInitStructure); //通道2 31 | 32 | TIM_Cmd(TIM2,ENABLE); //开启定时器 33 | 34 | } 35 | 36 | void PWM_SetCompare2(uint16_t compare) 37 | { 38 | TIM_SetCompare2(TIM2,compare); 39 | } -------------------------------------------------------------------------------- /5-2AD多通道/Hardware/AD.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | void AD_Init(void) 4 | { 5 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); //开启时钟 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 7 | 8 | RCC_ADCCLKConfig(RCC_PCLK2_Div6); 9 | 10 | GPIO_InitTypeDef GPIO_InitStructure; //配置GPIO 11 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; 12 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; 13 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 14 | GPIO_Init(GPIOB, &GPIO_InitStructure); 15 | 16 | //ADC_RegularChannelConfig(ADC1,ADC_Channel_0,1,ADC_SampleTime_55Cycles5); //选择输入通道 17 | 18 | ADC_InitTypeDef ADC_InitStructure; //初始化ADC 单次转换、非扫描模式 19 | ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; 20 | ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; 21 | ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; 22 | ADC_InitStructure.ADC_ScanConvMode = DISABLE; 23 | ADC_InitStructure.ADC_ContinuousConvMode = DISABLE; 24 | ADC_InitStructure.ADC_NbrOfChannel = 1; 25 | ADC_Init(ADC1,&ADC_InitStructure); 26 | 27 | ADC_Cmd(ADC1,ENABLE); //ADC上电 28 | 29 | ADC_ResetCalibration(ADC1); //复位校准 30 | while (ADC_GetResetCalibrationStatus(ADC1) == SET); 31 | ADC_StartCalibration(ADC1); 32 | while (ADC_GetCalibrationStatus(ADC1) == SET); 33 | 34 | } 35 | 36 | uint16_t AD_GetValue(uint8_t ADC_Channel) 37 | { 38 | ADC_RegularChannelConfig(ADC1,ADC_Channel,1,ADC_SampleTime_55Cycles5); 39 | ADC_SoftwareStartConvCmd(ADC1,ENABLE); 40 | while (ADC_GetFlagStatus(ADC1,ADC_FLAG_EOC) == RESET); 41 | return ADC_GetConversionValue(ADC1); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /4-8编码器接口测速/Hardware/Encoder.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void Encoder_Init(void) 4 | { 5 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOA, &GPIO_InitStructure); 13 | 14 | TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure; 15 | TIM_TimeBaseInitStructure.TIM_ClockDivision = TIM_CKD_DIV1; 16 | TIM_TimeBaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up; 17 | TIM_TimeBaseInitStructure.TIM_Period = 65536 - 1; //ARR 18 | TIM_TimeBaseInitStructure.TIM_Prescaler = 1 - 1; //PSC 19 | TIM_TimeBaseInitStructure.TIM_RepetitionCounter = 0; 20 | TIM_TimeBaseInit(TIM3, &TIM_TimeBaseInitStructure); 21 | 22 | TIM_ICInitTypeDef TIM_ICInitStructure; 23 | TIM_ICStructInit(&TIM_ICInitStructure); 24 | TIM_ICInitStructure.TIM_Channel = TIM_Channel_1; 25 | TIM_ICInitStructure.TIM_ICFilter = 0xF; 26 | TIM_ICInit(TIM3, &TIM_ICInitStructure); 27 | TIM_ICInitStructure.TIM_Channel = TIM_Channel_2; 28 | TIM_ICInitStructure.TIM_ICFilter = 0xF; 29 | TIM_ICInit(TIM3, &TIM_ICInitStructure); 30 | 31 | TIM_EncoderInterfaceConfig(TIM3, TIM_EncoderMode_TI12, TIM_ICPolarity_Rising, TIM_ICPolarity_Rising); 32 | 33 | TIM_Cmd(TIM3, ENABLE); 34 | } 35 | 36 | int16_t Encoder_Get(void) 37 | { 38 | int16_t Temp; 39 | Temp = TIM_GetCounter(TIM3); 40 | TIM_SetCounter(TIM3, 0); 41 | return Temp; 42 | } 43 | -------------------------------------------------------------------------------- /4-6输入捕获模式测频率/Hardware/PWM.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void PWM_Init(void) 4 | { 5 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); //RCC内部时钟 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //引脚输出 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOA, &GPIO_InitStructure); 13 | 14 | TIM_InternalClockConfig(TIM2); 15 | 16 | TIM_TimeBaseInitTypeDef Tim_TimeBaseInitStructor; //时基单元 17 | Tim_TimeBaseInitStructor.TIM_ClockDivision = TIM_CKD_DIV1; 18 | Tim_TimeBaseInitStructor.TIM_CounterMode = TIM_CounterMode_Up; 19 | Tim_TimeBaseInitStructor.TIM_Period = 100 - 1; //ARR 20 | Tim_TimeBaseInitStructor.TIM_Prescaler = 720 -1; //PSC 21 | Tim_TimeBaseInitStructor.TIM_RepetitionCounter = 0; 22 | TIM_TimeBaseInit(TIM2,&Tim_TimeBaseInitStructor); 23 | 24 | TIM_OCInitTypeDef TIM_OCInitStructure; //输出 25 | TIM_OCStructInit(&TIM_OCInitStructure); 26 | TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; 27 | TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; 28 | TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; 29 | TIM_OCInitStructure.TIM_Pulse = 90; //CCR 30 | TIM_OC1Init(TIM2,&TIM_OCInitStructure); 31 | 32 | TIM_Cmd(TIM2,ENABLE); //开启定时器 33 | 34 | } 35 | 36 | void PWM_SetCompare1(uint16_t compare) 37 | { 38 | TIM_SetCompare1(TIM2,compare); 39 | } 40 | 41 | void PWM_SetPrescaler(uint16_t Prescaler) 42 | { 43 | TIM_PrescalerConfig(TIM2,Prescaler,TIM_PSCReloadMode_Immediate); 44 | } -------------------------------------------------------------------------------- /3-3编码器计次/Hardware/CountSensor.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | uint16_t CountSensor_count; 4 | 5 | void CountSensor_Init(void) 6 | { 7 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); //开启时钟 8 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); //开启AFIO时钟 9 | 10 | GPIO_InitTypeDef GPIO_InitStructure; //GPIO引脚配置 11 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 12 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14; 13 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 14 | GPIO_Init(GPIOB, &GPIO_InitStructure); 15 | 16 | GPIO_EXTILineConfig(GPIO_PortSourceGPIOB,GPIO_PinSource14); //AFIO外部中断引脚配置 17 | 18 | EXTI_InitTypeDef EXTI_InitStructure; //外部中断配置 14线路 下降沿触发 19 | EXTI_InitStructure.EXTI_Line = EXTI_Line14; 20 | EXTI_InitStructure.EXTI_LineCmd = ENABLE; 21 | EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; 22 | EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; 23 | EXTI_Init(&EXTI_InitStructure); 24 | 25 | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //NVIC配置 26 | NVIC_InitTypeDef NVIC_InitStructure; 27 | NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn; 28 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 29 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; 30 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; 31 | NVIC_Init(&NVIC_InitStructure); 32 | 33 | //外部中断信号从GPIO到AFIO,到EXTI,再到NVIC,最终通向CPU 34 | 35 | } 36 | 37 | uint16_t CountSensor_Get(void) 38 | { 39 | return CountSensor_count ++; 40 | } 41 | 42 | void EXTI15_10_IRQHandler(void) 43 | { 44 | if(EXTI_GetITStatus(EXTI_Line14) == SET) 45 | { 46 | CountSensor_count ++; 47 | EXTI_ClearFlag(EXTI_Line14); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /4-7PWMI模式测频率占空比/Hardware/PWM.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void PWM_Init(void) 4 | { 5 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); //RCC内部时钟 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //引脚输出 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOA, &GPIO_InitStructure); 13 | 14 | TIM_InternalClockConfig(TIM2); 15 | 16 | TIM_TimeBaseInitTypeDef Tim_TimeBaseInitStructor; //时基单元 17 | Tim_TimeBaseInitStructor.TIM_ClockDivision = TIM_CKD_DIV1; 18 | Tim_TimeBaseInitStructor.TIM_CounterMode = TIM_CounterMode_Up; 19 | Tim_TimeBaseInitStructor.TIM_Period = 100 - 1; //ARR 20 | Tim_TimeBaseInitStructor.TIM_Prescaler = 720 -1; //PSC 21 | Tim_TimeBaseInitStructor.TIM_RepetitionCounter = 0; 22 | TIM_TimeBaseInit(TIM2,&Tim_TimeBaseInitStructor); 23 | 24 | TIM_OCInitTypeDef TIM_OCInitStructure; //输出 25 | TIM_OCStructInit(&TIM_OCInitStructure); 26 | TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; 27 | TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; 28 | TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; 29 | TIM_OCInitStructure.TIM_Pulse = 90; //CCR 30 | TIM_OC1Init(TIM2,&TIM_OCInitStructure); 31 | 32 | TIM_Cmd(TIM2,ENABLE); //开启定时器 33 | 34 | } 35 | 36 | void PWM_SetCompare1(uint16_t compare) 37 | { 38 | TIM_SetCompare1(TIM2,compare); 39 | } 40 | 41 | void PWM_SetPrescaler(uint16_t Prescaler) 42 | { 43 | TIM_PrescalerConfig(TIM2,Prescaler,TIM_PSCReloadMode_Immediate); 44 | } -------------------------------------------------------------------------------- /3-2光敏传感器计次/Hardware/CountSensor.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | uint16_t CountSensor_count; 4 | 5 | void CountSensor_Init(void) 6 | { 7 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); //开启时钟 8 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); //开启AFIO时钟 9 | 10 | GPIO_InitTypeDef GPIO_InitStructure; //GPIO引脚配置 11 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 12 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14; 13 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 14 | GPIO_Init(GPIOB, &GPIO_InitStructure); 15 | 16 | GPIO_EXTILineConfig(GPIO_PortSourceGPIOB,GPIO_PinSource14); //AFIO外部中断引脚配置 17 | 18 | EXTI_InitTypeDef EXTI_InitStructure; //外部中断配置 14线路 下降沿触发 19 | EXTI_InitStructure.EXTI_Line = EXTI_Line14; 20 | EXTI_InitStructure.EXTI_LineCmd = ENABLE; 21 | EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; 22 | EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; 23 | EXTI_Init(&EXTI_InitStructure); 24 | 25 | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //NVIC配置 26 | NVIC_InitTypeDef NVIC_InitStructure; 27 | NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn; 28 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 29 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; 30 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; 31 | NVIC_Init(&NVIC_InitStructure); 32 | 33 | //外部中断信号从GPIO到AFIO,到EXTI,再到NVIC,最终通向CPU 34 | 35 | } 36 | 37 | uint16_t CountSensor_Get(void) 38 | { 39 | return CountSensor_count; 40 | } 41 | 42 | void EXTI15_10_IRQHandler(void) 43 | { 44 | if(EXTI_GetITStatus(EXTI_Line14) == SET) 45 | { 46 | CountSensor_count ++; 47 | EXTI_ClearITPendingBit(EXTI_Line14); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /4-6输入捕获模式测频率/Hardware/IC.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void IC_Init(void) 4 | { 5 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); //RCC内部时钟 TIM3 PA6 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //引脚输出 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOA, &GPIO_InitStructure); 13 | 14 | TIM_InternalClockConfig(TIM3); 15 | 16 | TIM_TimeBaseInitTypeDef Tim_TimeBaseInitStructor; //时基单元 17 | Tim_TimeBaseInitStructor.TIM_ClockDivision = TIM_CKD_DIV1; 18 | Tim_TimeBaseInitStructor.TIM_CounterMode = TIM_CounterMode_Up; 19 | Tim_TimeBaseInitStructor.TIM_Period = 65536 - 1; //ARR 20 | Tim_TimeBaseInitStructor.TIM_Prescaler = 72 -1; //PSC 21 | Tim_TimeBaseInitStructor.TIM_RepetitionCounter = 0; 22 | TIM_TimeBaseInit(TIM3,&Tim_TimeBaseInitStructor); 23 | 24 | TIM_ICInitTypeDef TIM_ICInitStructure; //输入 25 | TIM_ICInitStructure.TIM_Channel = TIM_Channel_1; 26 | TIM_ICInitStructure.TIM_ICFilter = 0xF; 27 | TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising; 28 | TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1; 29 | TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI; 30 | TIM_ICInit(TIM3,&TIM_ICInitStructure); 31 | 32 | TIM_SelectInputTrigger(TIM3,TIM_TS_TI1FP1); //触发源选择 33 | TIM_SelectSlaveMode(TIM3,TIM_SlaveMode_Reset); //从模式Reset 34 | 35 | TIM_Cmd(TIM3,ENABLE); //开启定时器 36 | } 37 | 38 | uint32_t IC_GetFreq(void) 39 | { 40 | return 1000000 / (TIM_GetCapture1(TIM3) + 1); 41 | } 42 | -------------------------------------------------------------------------------- /4-7PWMI模式测频率占空比/Hardware/IC.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | 3 | void IC_Init(void) 4 | { 5 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); //RCC内部时钟 TIM3 PA6 6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //引脚输出 7 | 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; 11 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 | GPIO_Init(GPIOA, &GPIO_InitStructure); 13 | 14 | TIM_InternalClockConfig(TIM3); 15 | 16 | TIM_TimeBaseInitTypeDef Tim_TimeBaseInitStructor; //时基单元 17 | Tim_TimeBaseInitStructor.TIM_ClockDivision = TIM_CKD_DIV1; 18 | Tim_TimeBaseInitStructor.TIM_CounterMode = TIM_CounterMode_Up; 19 | Tim_TimeBaseInitStructor.TIM_Period = 65536 - 1; //ARR 20 | Tim_TimeBaseInitStructor.TIM_Prescaler = 72 -1; //PSC 21 | Tim_TimeBaseInitStructor.TIM_RepetitionCounter = 0; 22 | TIM_TimeBaseInit(TIM3,&Tim_TimeBaseInitStructor); 23 | 24 | TIM_ICInitTypeDef TIM_ICInitStructure; //输入 25 | TIM_ICInitStructure.TIM_Channel = TIM_Channel_1; 26 | TIM_ICInitStructure.TIM_ICFilter = 0xF; 27 | TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising; 28 | TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1; 29 | TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI; 30 | TIM_ICInit(TIM3,&TIM_ICInitStructure); 31 | TIM_PWMIConfig(TIM3,&TIM_ICInitStructure); //PWMI 32 | 33 | TIM_SelectInputTrigger(TIM3,TIM_TS_TI1FP1); //触发源选择 34 | TIM_SelectSlaveMode(TIM3,TIM_SlaveMode_Reset); //从模式Reset 35 | 36 | TIM_Cmd(TIM3,ENABLE); //开启定时器 37 | } 38 | 39 | uint32_t IC_GetFreq(void) 40 | { 41 | return 1000000 / (TIM_GetCapture1(TIM3) + 1); 42 | } 43 | 44 | uint32_t IC_GetDuty(void) 45 | { 46 | return (TIM_GetCapture2(TIM3) + 1) * 100 / (TIM_GetCapture1(TIM3) + 1); 47 | } 48 | -------------------------------------------------------------------------------- /4-2定时器外部时钟/System/Timer.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | //extern uint16_t Num; 4 | 5 | void Timer_Init(void) 6 | { 7 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); //RCC内部时钟 8 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); 9 | 10 | GPIO_InitTypeDef GPIO_InitStructure; //GPIO引脚配置 11 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 12 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; 13 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 14 | GPIO_Init(GPIOA, &GPIO_InitStructure); 15 | 16 | 17 | TIM_ETRClockMode2Config(TIM2,TIM_ExtTRGPSC_OFF,TIM_ExtTRGPolarity_NonInverted, 0x00); //配置外部时钟 18 | 19 | TIM_TimeBaseInitTypeDef Tim_TimeBaseInitStructor; //时基单元 20 | Tim_TimeBaseInitStructor.TIM_ClockDivision = TIM_CKD_DIV1; 21 | Tim_TimeBaseInitStructor.TIM_CounterMode = TIM_CounterMode_Up; 22 | Tim_TimeBaseInitStructor.TIM_Period = 10 - 1; 23 | Tim_TimeBaseInitStructor.TIM_Prescaler = 1 -1; 24 | Tim_TimeBaseInitStructor.TIM_RepetitionCounter = 0; 25 | TIM_TimeBaseInit(TIM2,&Tim_TimeBaseInitStructor); 26 | 27 | TIM_ClearFlag(TIM2,TIM_FLAG_Update); //清除中断标志位,从0开始 28 | 29 | TIM_ITConfig(TIM2,TIM_IT_Update,ENABLE); //使能中断 30 | 31 | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //NVIC配置 32 | NVIC_InitTypeDef NVIC_InitStructure; 33 | NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn; 34 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 35 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; 36 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; 37 | NVIC_Init(&NVIC_InitStructure); 38 | 39 | TIM_Cmd(TIM2,ENABLE); //开启定时器 40 | } 41 | 42 | uint16_t Timer_GetCounter(void) 43 | { 44 | return TIM_GetCounter(TIM2); 45 | } 46 | 47 | //void TIM2_IRQHandler(void) 48 | //{ 49 | // if(TIM_GetITStatus(TIM2,TIM_IT_Update) == SET) 50 | // { 51 | // Num ++; 52 | // TIM_ClearITPendingBit(TIM2,TIM_IT_Update); 53 | // } 54 | // 55 | //} 56 | -------------------------------------------------------------------------------- /7-1串口发送/Hardware/Serial.c: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" // Device header 2 | #include 3 | #include 4 | 5 | void Serial_Init(void) 6 | { 7 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); 8 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 9 | 10 | GPIO_InitTypeDef GPIO_InitStructure; 11 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 12 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; 13 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 14 | GPIO_Init(GPIOA, &GPIO_InitStructure); 15 | 16 | USART_InitTypeDef USART_InitStructure; 17 | USART_InitStructure.USART_BaudRate = 9600; 18 | USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; 19 | USART_InitStructure.USART_Mode = USART_Mode_Tx; 20 | USART_InitStructure.USART_Parity = USART_Parity_No; 21 | USART_InitStructure.USART_StopBits = USART_StopBits_1; 22 | USART_InitStructure.USART_WordLength = USART_WordLength_8b; 23 | USART_Init(USART1,&USART_InitStructure); 24 | 25 | USART_Cmd(USART1,ENABLE); 26 | } 27 | 28 | void Serial_SendByte(uint8_t Byte) 29 | { 30 | USART_SendData(USART1,Byte); 31 | while (USART_GetFlagStatus(USART1,USART_FLAG_TXE) == RESET); 32 | } 33 | 34 | void Serial_SendArray(uint8_t *Array, uint16_t Length) 35 | { 36 | uint16_t i; 37 | for(i = 0; i < Length; i++) 38 | { 39 | Serial_SendByte(Array[i]); 40 | } 41 | } 42 | 43 | void Serial_SendString(char *String) 44 | { 45 | uint8_t i; 46 | for(i = 0; String[i] != '\0'; i ++) 47 | { 48 | Serial_SendByte(String[i]); 49 | } 50 | } 51 | 52 | uint32_t Serial_Pow(uint32_t X, uint32_t Y) 53 | { 54 | uint32_t Result = 1; 55 | while (Y --) 56 | { 57 | Result *= X; 58 | } 59 | return Result; 60 | } 61 | 62 | void Serial_SendNumber(uint32_t Number, uint8_t Length) 63 | { 64 | uint8_t i; 65 | for (i = 0; i < Length; i ++) 66 | { 67 | Serial_SendByte(Number / Serial_Pow(10, Length - i - 1) % 10 + '0'); 68 | } 69 | } 70 | 71 | int fputc(int ch, FILE *f) 72 | { 73 | Serial_SendByte(ch); 74 | return ch; 75 | } 76 | 77 | void Serial_Printf(char *format, ...) 78 | { 79 | char String[100]; 80 | va_list arg; 81 | va_start(arg, format); 82 | vsprintf(String, format, arg); 83 | va_end(arg); 84 | Serial_SendString(String); 85 | } 86 | 87 | -------------------------------------------------------------------------------- /1-1LED闪烁/User/stm32f10x_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_it.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_IT_H 24 | #define __STM32F10x_IT_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f10x.h" 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* Exported constants --------------------------------------------------------*/ 35 | /* Exported macro ------------------------------------------------------------*/ 36 | /* Exported functions ------------------------------------------------------- */ 37 | 38 | void NMI_Handler(void); 39 | void HardFault_Handler(void); 40 | void MemManage_Handler(void); 41 | void BusFault_Handler(void); 42 | void UsageFault_Handler(void); 43 | void SVC_Handler(void); 44 | void DebugMon_Handler(void); 45 | void PendSV_Handler(void); 46 | void SysTick_Handler(void); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* __STM32F10x_IT_H */ 53 | 54 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 55 | -------------------------------------------------------------------------------- /2-1蜂鸣器/User/stm32f10x_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_it.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_IT_H 24 | #define __STM32F10x_IT_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f10x.h" 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* Exported constants --------------------------------------------------------*/ 35 | /* Exported macro ------------------------------------------------------------*/ 36 | /* Exported functions ------------------------------------------------------- */ 37 | 38 | void NMI_Handler(void); 39 | void HardFault_Handler(void); 40 | void MemManage_Handler(void); 41 | void BusFault_Handler(void); 42 | void UsageFault_Handler(void); 43 | void SVC_Handler(void); 44 | void DebugMon_Handler(void); 45 | void PendSV_Handler(void); 46 | void SysTick_Handler(void); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* __STM32F10x_IT_H */ 53 | 54 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 55 | -------------------------------------------------------------------------------- /2-2按键控制LED/User/stm32f10x_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_it.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_IT_H 24 | #define __STM32F10x_IT_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f10x.h" 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* Exported constants --------------------------------------------------------*/ 35 | /* Exported macro ------------------------------------------------------------*/ 36 | /* Exported functions ------------------------------------------------------- */ 37 | 38 | void NMI_Handler(void); 39 | void HardFault_Handler(void); 40 | void MemManage_Handler(void); 41 | void BusFault_Handler(void); 42 | void UsageFault_Handler(void); 43 | void SVC_Handler(void); 44 | void DebugMon_Handler(void); 45 | void PendSV_Handler(void); 46 | void SysTick_Handler(void); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* __STM32F10x_IT_H */ 53 | 54 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 55 | -------------------------------------------------------------------------------- /2-3光敏控制蜂鸣器/User/stm32f10x_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_it.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_IT_H 24 | #define __STM32F10x_IT_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f10x.h" 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* Exported constants --------------------------------------------------------*/ 35 | /* Exported macro ------------------------------------------------------------*/ 36 | /* Exported functions ------------------------------------------------------- */ 37 | 38 | void NMI_Handler(void); 39 | void HardFault_Handler(void); 40 | void MemManage_Handler(void); 41 | void BusFault_Handler(void); 42 | void UsageFault_Handler(void); 43 | void SVC_Handler(void); 44 | void DebugMon_Handler(void); 45 | void PendSV_Handler(void); 46 | void SysTick_Handler(void); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* __STM32F10x_IT_H */ 53 | 54 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 55 | -------------------------------------------------------------------------------- /3-1OLED显示屏/User/stm32f10x_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_it.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_IT_H 24 | #define __STM32F10x_IT_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f10x.h" 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* Exported constants --------------------------------------------------------*/ 35 | /* Exported macro ------------------------------------------------------------*/ 36 | /* Exported functions ------------------------------------------------------- */ 37 | 38 | void NMI_Handler(void); 39 | void HardFault_Handler(void); 40 | void MemManage_Handler(void); 41 | void BusFault_Handler(void); 42 | void UsageFault_Handler(void); 43 | void SVC_Handler(void); 44 | void DebugMon_Handler(void); 45 | void PendSV_Handler(void); 46 | void SysTick_Handler(void); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* __STM32F10x_IT_H */ 53 | 54 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 55 | -------------------------------------------------------------------------------- /3-2光敏传感器计次/User/stm32f10x_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_it.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_IT_H 24 | #define __STM32F10x_IT_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f10x.h" 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* Exported constants --------------------------------------------------------*/ 35 | /* Exported macro ------------------------------------------------------------*/ 36 | /* Exported functions ------------------------------------------------------- */ 37 | 38 | void NMI_Handler(void); 39 | void HardFault_Handler(void); 40 | void MemManage_Handler(void); 41 | void BusFault_Handler(void); 42 | void UsageFault_Handler(void); 43 | void SVC_Handler(void); 44 | void DebugMon_Handler(void); 45 | void PendSV_Handler(void); 46 | void SysTick_Handler(void); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* __STM32F10x_IT_H */ 53 | 54 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 55 | -------------------------------------------------------------------------------- /3-3编码器计次/User/stm32f10x_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_it.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_IT_H 24 | #define __STM32F10x_IT_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f10x.h" 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* Exported constants --------------------------------------------------------*/ 35 | /* Exported macro ------------------------------------------------------------*/ 36 | /* Exported functions ------------------------------------------------------- */ 37 | 38 | void NMI_Handler(void); 39 | void HardFault_Handler(void); 40 | void MemManage_Handler(void); 41 | void BusFault_Handler(void); 42 | void UsageFault_Handler(void); 43 | void SVC_Handler(void); 44 | void DebugMon_Handler(void); 45 | void PendSV_Handler(void); 46 | void SysTick_Handler(void); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* __STM32F10x_IT_H */ 53 | 54 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 55 | -------------------------------------------------------------------------------- /4-1定时器定时中断/User/stm32f10x_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_it.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_IT_H 24 | #define __STM32F10x_IT_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f10x.h" 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* Exported constants --------------------------------------------------------*/ 35 | /* Exported macro ------------------------------------------------------------*/ 36 | /* Exported functions ------------------------------------------------------- */ 37 | 38 | void NMI_Handler(void); 39 | void HardFault_Handler(void); 40 | void MemManage_Handler(void); 41 | void BusFault_Handler(void); 42 | void UsageFault_Handler(void); 43 | void SVC_Handler(void); 44 | void DebugMon_Handler(void); 45 | void PendSV_Handler(void); 46 | void SysTick_Handler(void); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* __STM32F10x_IT_H */ 53 | 54 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 55 | -------------------------------------------------------------------------------- /4-2定时器外部时钟/User/stm32f10x_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_it.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_IT_H 24 | #define __STM32F10x_IT_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f10x.h" 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* Exported constants --------------------------------------------------------*/ 35 | /* Exported macro ------------------------------------------------------------*/ 36 | /* Exported functions ------------------------------------------------------- */ 37 | 38 | void NMI_Handler(void); 39 | void HardFault_Handler(void); 40 | void MemManage_Handler(void); 41 | void BusFault_Handler(void); 42 | void UsageFault_Handler(void); 43 | void SVC_Handler(void); 44 | void DebugMon_Handler(void); 45 | void PendSV_Handler(void); 46 | void SysTick_Handler(void); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* __STM32F10x_IT_H */ 53 | 54 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 55 | -------------------------------------------------------------------------------- /4-4PWM驱动舵机/User/stm32f10x_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_it.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_IT_H 24 | #define __STM32F10x_IT_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f10x.h" 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* Exported constants --------------------------------------------------------*/ 35 | /* Exported macro ------------------------------------------------------------*/ 36 | /* Exported functions ------------------------------------------------------- */ 37 | 38 | void NMI_Handler(void); 39 | void HardFault_Handler(void); 40 | void MemManage_Handler(void); 41 | void BusFault_Handler(void); 42 | void UsageFault_Handler(void); 43 | void SVC_Handler(void); 44 | void DebugMon_Handler(void); 45 | void PendSV_Handler(void); 46 | void SysTick_Handler(void); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* __STM32F10x_IT_H */ 53 | 54 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 55 | -------------------------------------------------------------------------------- /4-8编码器接口测速/User/stm32f10x_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_it.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_IT_H 24 | #define __STM32F10x_IT_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f10x.h" 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* Exported constants --------------------------------------------------------*/ 35 | /* Exported macro ------------------------------------------------------------*/ 36 | /* Exported functions ------------------------------------------------------- */ 37 | 38 | void NMI_Handler(void); 39 | void HardFault_Handler(void); 40 | void MemManage_Handler(void); 41 | void BusFault_Handler(void); 42 | void UsageFault_Handler(void); 43 | void SVC_Handler(void); 44 | void DebugMon_Handler(void); 45 | void PendSV_Handler(void); 46 | void SysTick_Handler(void); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* __STM32F10x_IT_H */ 53 | 54 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 55 | --------------------------------------------------------------------------------