自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(12)
  • 收藏
  • 关注

原创 Mutex(互斥锁)、Semaphore(信号量)、Condition Variable(条件变量)区别

可以把Semaphore当成一个共享资源的数量(资源计数),当一个线程访问该共享资源时,会先检查是否有多余的资源可供使用,若有,将信号量减一,表示占用一份该资源,在完成资源的访问后,会归还该资源,同时将信号量加一,表示可用的该资源数量加一;:可以把mutex当成是一个临界区资源的钥匙,这把钥匙可以有所属权,不同进程想要访问该资源时,本质上是争夺钥匙的所属权,当一个线程争夺到所属权是,它会对该资源上锁,即Lock(mutex);可见无论如何实现,都会产生问题,这也就是条件变量底层实现所解决的问题。

2024-03-30 20:59:00 1008

原创 动态数码管

Main.c:#include "stm32f10x.h"#include "smg.h"uint16_t table[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //显示的数字uint16_t wei[] = {0x0fe,0x0fd,0x0fb,0x0f7,0x0ef,0x0df,0xff,0xff}; //在哪个数码管显示u8 i;void delay(int t){ int i,j; for(i=0;i&lt

2021-07-06 22:34:21 241

原创 静态数码管

Main.c:#include "stm32f10x.h"#include "smg.h"uint8_t table[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//无符号字符型,可用u8代替void delay(int t){ int i,j; for(i=0;i<t;i++) for(j=0;j<t;j++);}int main(){ u8 i; u16 temp; SMG_Init()

2021-07-06 22:32:16 204

原创 按键无中断

Main.c:#include "stm32f10x.h"#include "delay.h"#include "sys.h"#include "led.h"#include "key.h"int main(){ u8 temp; Led_Init(); Key_Init(); while(1) { temp=Key_Scan(temp); switch(temp) { case 0: LED1=LED2=LED3=LED4=1; break;

2021-07-06 18:24:22 151

原创 按键外中断控制

Main.c:#include "stm32f10x.h"#include "delay.h"#include "key.h"#include "led.h"#include "sys.h"int main(){ NVIC_Configuration(); Led_Init(); Key_Exti_Init(); while(1) { LED1=0;LED2=LED3=LED4=1;delay(400); LED2=0;LED1=LED3=LED4=1;delay(400)

2021-07-06 18:21:48 138

原创 ADC转换

Main.c:#include "stm32f10x.h"#include "usart.h"#include "delay.h"#include "hdg12864.h"#include "adc.h"/*讲num(0 - 4095)显示到显示屏的第一行第一列*/void display(u16 num){ u8 num_1, num_2, num_3, num_4; num_1 = num / 10; Draw_word(12 + num_1, 0, 2, 0, 16);

2021-07-01 22:04:58 396

原创 串口发送数据

Main.c:#include "stm32f10x.h"#include "usart.h"#include "delay.h"#include "stdio.h"extern u8 USART_RX_BUF[USART_REC_LEN]; //接受串口字符串的缓冲数组extern u16 USART_RX_STA; //接受状态标识,第15位接收完成的标志位(0表示接受未完成,1表示接受完成) //第14位表示是否接收到回车(0表示未接受到回车,1表示已接受到

2021-07-01 22:02:51 1346

原创 定时器输出PWM控制电机

main.c:#include "stm32f10x.h"#include "motor.h"#include "timer.h"#include "delay.h"#include "key.h"int main(){ u16 temp = 0; Motor_Init(); TIM1_PWM_Init(4999, 71); //arr这个参数用于确定占空比有关 Key_Init(); while(1) { temp = Key_Scan(); switc

2021-07-01 21:59:14 438

原创 定时器控制LED灯

main.c:#include "stm32f10x.h"#include "delay.h"#include "timer.h"#include "led.h"int main(){ delay_init(); NVIC_Configuration(); TIM2_Init(20000-1,7200-1); //7200个脉冲计时加1,0.1ms,数20000个数,就是2s TIM3_Init(10000-1,7200-1); //7200个脉冲计时加1,0.1ms,数10000个数

2021-07-01 21:55:31 1234

原创 外中断控制数码管显示

main.c:#include "stm32f10x.h"#include "delay.h"#include "key.h"#include "smg.h"#include "sys.h"uint16_t table[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};uint16_t dis, cnt = 0;int main(){ NVIC_Configuration(); SMG_Init(); Key_Exti

2021-07-01 21:51:30 1478

原创 数码管显示

主函数:#include "stm32f10x.h"#include "smg.h"uint16_t table[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};uint16_t dis[2];void delay(int t){ int i,j; for(i=0;i<t;i++) for(j=0;j<t;j++);}int main(){

2021-07-01 21:45:23 157

原创 流水灯通用配置

#include "stm32f10x.h" //main.cvoid delay(int t){ int i,j; for(i=0;i<t;i++) for(j=0;j<t;j++);}int main(){ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin

2021-07-01 21:40:35 122

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除