当前位置:网站首页>蓝桥杯嵌入式学习总结(新版)
蓝桥杯嵌入式学习总结(新版)
2022-06-26 07:11:00 【Yinzz2】
1.LED
GPIO_output level 设置为 high
void led_show(uint16_t led,uint8_t state)
{
if(state == 1)
{
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_All,GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOC,led<<8,GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_RESET);
}
else
{
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_All,GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOC,led<<8,GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_RESET);
}
}2.KEY
GPIO输入设置为上拉,三行式按键消抖具体上其他博客了解
_Bool key_flag=0;
unsigned char Trg;
unsigned char Cont;
void key_read(void)
{
unsigned char ReadData = (KEYPORT)^0xff;
Trg = ReadData & ( ReadData ^ Cont );
Cont = ReadData;
}
//具体用法搜索三行式消抖
//inter.h
#ifndef _INTER_H_
#define _INTER_H_
#include "main.h"
#define KB1 HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_0)
#define KB2 HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_1)
#define KB3 HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_2)
#define KB4 HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0)
#define KEYPORT KB1 | (KB2 << 1) | (KB3 << 2) | (KB4 << 3) | 0xf0
void key_read(void);
extern unsigned char Trg;
extern unsigned char Cont;
extern _Bool key_flag;
#endif
//在主函数上记得加上
HAL_TIM_Base_Start_IT(&htim3);
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef * htim)
{
static uint16_t key_count =0;
if(htim->Instance == TIM3)
{
key_count++;
if(key_count==10)
{
key_count=0;
key_flag=1;
}
}
}
//定时器1ms触发一次,key_count为10时,相当于0.1s令key_flag置一
3.PWM输出
主要是在Cubemx开启选择 PWM Generation CH1 自己按照需求设置Period,Prescaler和Pulse
//主函数上加入 HAL_TIM_PWM_Start(&htim16,TIM_CHANNEL_1);
//设置占空比 __HAL_TIM_SetCompare(&htim16,TIM_CHANNEL_1,pa6duty);
//相当于一个周期内设置了pa6duty个脉冲数
//设置频率 __HAL_TIM_SetAutoreload(&htim16,2000-1);
//相当于设置一个周期内有2000个脉冲边栏推荐
- C implementation adds a progress bar display effect to the specified column of the GridView table in devaxpress - code implementation method
- 解决dialog 底部透明的问题
- How to publish function computing (FC) through cloud effect
- Dark red crystal meso-5,10,15,20-tetra (p-aminophenyl) cobalt porphyrin (co TAPP); Meso-5,10,15,20-tetra (p-aminophenyl) cobalt porphyrin no complex (TAPP co no) supplied by Qiyue
- QPS
- Redis series - redis startup, client day1-2
- Analysis report on market demand and investment competitiveness of China's cyclohexanone industry (2022 Edition)
- 【图像分割】基于最大主曲率实现视网膜眼底图像中的血管提取附matlab代码
- [image fusion] MRI-CT image fusion based on gradient energy, local energy and PCA fusion rules with matlab code
- SQL 查询语句
猜你喜欢

C#实现给DevExpress中GridView表格指定列添加进度条显示效果——代码实现方式

Rust中的过程宏
![[image detection] image saliency detection based on ITTI model with matlab code](/img/f3/a8b13431724059f8c8a77961778c67.png)
[image detection] image saliency detection based on ITTI model with matlab code

One chip realizes functions such as spray 𞓜 ws2812 drive | key touch | LED display | voice broadcast chip and simplifies the design of humidifier products

Tetradecanoxy tetraphenylporphyrin methacrylate mm-tpp-14c; Cetanoxy tetraphenyl porphyrin methacrylate mm-tpp-16c; Purple solid; Qiyue supply

Porphyrin based polyimide ppbpis (ppbpi-pa, ppbpi-pepa and ppbpi-pena); Crosslinked porphyrin based polyimide (ppbpi-pa-cr, ppbpi-pepa-cr, ppbpi-pena-cr) reagent

【推荐10个 让你轻松的 IDEA 插件,少些繁琐又重复的代码】

5,10,15,20-tetraphenylporphyrin (TPP) and metal complexes fetpp/mntpp/cutpp/zntpp/nitpp/cotpp/pttpp/pdtpp/cdtpp supplied by Qiyue

Redis系列——redis启动,客户端day1-2

高德地图使用自定义地图无效问题
随机推荐
QTreeWidget And QTableWidget
[image segmentation] blood vessel extraction from retinal fundus images based on maximum principal curvature with matlab code
少年,你可知 Kotlin 协程最初的样子?
5,10,15,20-tetra (4-bromophenyl) porphyrin (h2tppbr4) /5.2.15,10,15,20-tetra [4-[(3-aminophenyl) ethynyl] phenyl] porphyrin (tapepp) Qiyue porphyrin reagent
大厂面试TCP协议经典十五连问!22张图让你彻底弄明白
[cellular automata] Based on cellular automata, realize the traffic flow problem of expressway toll station, with matlab code
解决dialog 底部透明的问题
安装homebrew报错汇总
Cache usage
[path planning] robot path planning based on improved artificial potential field with matlab code
Redis series - redis startup, client day1-2
缓存使用
Es string type (text vs keyword) selection
Liujinhai, chief architect of zhongang Mining: according to the analysis of fluorite supply and demand, it is estimated that the fluorine coating market has great potential
Porphyrin based polyimide (ppbpis); Synthesis of crosslinked porphyrin based polyimides (ppbpi CRS) porphyrin products supplied by Qiyue biology
Crosslinked metalloporphyrin based polyimide ppbpi-h) PPBP Mn; PBP-Fe; PPBPI-Fe-CR; Ppbpi Mn CR product - supplied by Qiyue
Qt基础教程:QString
3,3 '- di (3,4-dicarboxyphenoxy) -4,4' - diphenylethynylbiphenyldianhydride (bpebpda) / porphyrin 2dcofs (H2P COF, ZNP COF and cup COF) supplied by Qiyue
How to choose securities companies for stock speculation? Is it safe to open a mobile account?
炒股怎么选择证券公司?手机开户安全么?