【STM32】GPIO控制LED(HAL库版)
STM32最新固件库v3.5/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c · 林何/STM32F103C8 - 码云 - 开源中国 (gitee.com)
STM32最新固件库v3.5/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_gpio.c · 林何/STM32F103C8 - 码云 - 开源中国 (gitee.com)
1.宏定义
/* ------------ GPIO registers bit address in the alias region ----------------*/
//AFIO:复用寄存器
#define AFIO_OFFSET (AFIO_BASE - PERIPH_BASE)/* --- EVENTCR Register -----*//* Alias word address of EVOE bit */
#define EVCR_OFFSET (AFIO_OFFSET + 0x00)
#define EVOE_BitNumber ((uint8_t)0x07)
#define EVCR_EVOE_BB (PERIPH_BB_BASE + (EVCR_OFFSET * 32) + (EVOE_BitNumber * 4))/* --- MAPR Register ---*/
/* Alias word address of MII_RMII_SEL bit */
#define MAPR_OFFSET (AFIO_OFFSET + 0x04)
#define MII_RMII_SEL_BitNumber ((u8)0x17)
#define MAPR_MII_RMII_SEL_BB (PERIPH_BB_BASE + (MAPR_OFFSET * 32) + (MII_RMII_SEL_BitNumber * 4))//位掩码
#define EVCR_PORTPINCONFIG_MASK ((uint16_t)0xFF80)
#define LSB_MASK ((uint16_t)0xFFFF)
#define DBGAFR_POSITION_MASK ((uint32_t)0x000F0000)
#define DBGAFR_SWJCFG_MASK ((uint32_t)0xF0FFFFFF)
#define DBGAFR_LOCATION_MASK ((uint32_t)0x00200000)
#define DBGAFR_NUMBITS_MASK ((uint32_t)0x00100000)
2..GPIO模块标准库
1.GPIO_DeInit


/*** @brief Deinitializes the GPIOx peripheral registers to their default reset values.* @param GPIOx: where x can be (A..G) to select the GPIO peripheral.* @retval None*/
void GPIO_DeInit(GPIO_TypeDef* GPIOx)
{/* Check the parameters */assert_param(IS_GPIO_ALL_PERIPH(GPIOx));if (GPIOx == GPIOA){RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOA, ENABLE);RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOA, DISABLE);}else if (GPIOx == GPIOB){RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOB, ENABLE);RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOB, DISABLE);}else if (GPIOx == GPIOC){RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOC, ENABLE);RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOC, DISABLE);}else if (GPIOx == GPIOD){RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOD, ENABLE);RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOD, DISABLE);} else if (GPIOx == GPIOE){RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOE, ENABLE);RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOE, DISABLE);} else if (GPIOx == GPIOF){RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOF, ENABLE);RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOF, DISABLE);}else{if (GPIOx == GPIOG){RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOG, ENABLE);RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOG, DISABLE);}}
}
2.GPIO_Init

1.参数1:GPIO_TypeDef*
表示哪一个端口是(CRL还是CRH还是IDR)
记录的是寄存器地址
定义在system.stm32f10x.h中【因为外部可能要使用到】

2.参数2:GPIO_InitTypeDef*
描述对GPIO的初始化(形容词)
定义在gpio.h



/** * @brief GPIO Init structure definition */typedef struct
{uint16_t GPIO_Pin; /*!< Specifies the GPIO pins to be configured.This parameter can be any value of @ref GPIO_pins_define */GPIOSpeed_TypeDef GPIO_Speed; /*!< Specifies the speed for the selected pins.This parameter can be a value of @ref GPIOSpeed_TypeDef */GPIOMode_TypeDef GPIO_Mode; /*!< Specifies the operating mode for the selected pins.This parameter can be a value of @ref GPIOMode_TypeDef */
}GPIO_InitTypeDef;
3.步骤1:GPIO Mode Configuration
输入模式全是0,输出模式全是1


速度初始化

/*---------------------------- GPIO Mode Configuration -----------------------*///取出bit0-bit3currentmode = ((uint32_t)GPIO_InitStruct->GPIO_Mode) & ((uint32_t)0x0F);if ((((uint32_t)GPIO_InitStruct->GPIO_Mode) & ((uint32_t)0x10)) != 0x00)//判断出等于1(输出模式)的进入{ /* Check the parameters */assert_param(IS_GPIO_SPEED(GPIO_InitStruct->GPIO_Speed));/* Output mode */currentmode |= (uint32_t)GPIO_InitStruct->GPIO_Speed;}
4.步骤2:GPIO CRL Configuration

/*---------------------------- GPIO CRL Configuration ------------------------*//* Configure the eight low port pins *///判断此时的控制器在CRL(bit0-bit7)还是CRH(bit7-bit15)if (((uint32_t)GPIO_InitStruct->GPIO_Pin & ((uint32_t)0x00FF)) != 0x00)//如果进入表示bit0-bit7有为1的,则表示要使用CRL{tmpreg = GPIOx->CRL;//pinpos < 0x08:表示从bit0-bit7开始找for (pinpos = 0x00; pinpos < 0x08; pinpos++){pos = ((uint32_t)0x01) << pinpos;/* Get the port pins position *///判断当前的Pin是哪一个currentpin = (GPIO_InitStruct->GPIO_Pin) & pos;if (currentpin == pos)//表示这位Pin是1,找到了{pos = pinpos << 2;/* Clear the corresponding low control register bits */pinmask = ((uint32_t)0x0F) << pos;tmpreg &= ~pinmask;//清零/* Write the mode configuration in the corresponding bits */tmpreg |= (currentmode << pos);/* Reset the corresponding ODR bit */if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPD){GPIOx->BRR = (((uint32_t)0x01) << pinpos);}else{/* Set the corresponding ODR bit */if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPU){GPIOx->BSRR = (((uint32_t)0x01) << pinpos);}}}}GPIOx->CRL = tmpreg;}

5.步骤3:GPIO CRH Configuration
/*---------------------------- GPIO CRH Configuration ------------------------*//* Configure the eight high port pins */if (GPIO_InitStruct->GPIO_Pin > 0x00FF){tmpreg = GPIOx->CRH;for (pinpos = 0x00; pinpos < 0x08; pinpos++){pos = (((uint32_t)0x01) << (pinpos + 0x08));/* Get the port pins position */currentpin = ((GPIO_InitStruct->GPIO_Pin) & pos);if (currentpin == pos){pos = pinpos << 2;/* Clear the corresponding high control register bits */pinmask = ((uint32_t)0x0F) << pos;tmpreg &= ~pinmask;/* Write the mode configuration in the corresponding bits */tmpreg |= (currentmode << pos);/* Reset the corresponding ODR bit */if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPD){GPIOx->BRR = (((uint32_t)0x01) << (pinpos + 0x08));}/* Set the corresponding ODR bit */if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPU){GPIOx->BSRR = (((uint32_t)0x01) << (pinpos + 0x08));}}}GPIOx->CRH = tmpreg;}
3.GPIO_StructInit
对GPIO初始化类型
GPIO_Pin_All:是用于判断此时这个GPIO是否初始化
/*** @brief Fills each GPIO_InitStruct member with its default value.* @param GPIO_InitStruct : pointer to a GPIO_InitTypeDef structure which will* be initialized.* @retval None*/
void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct)
{/* Reset GPIO init structure parameters values */
//GPIO_Pin_All:表示此时初始化到的这个pin是不存在的,表示此时还未指向GPIO_InitStruct->GPIO_Pin = GPIO_Pin_All;GPIO_InitStruct->GPIO_Speed = GPIO_Speed_2MHz;GPIO_InitStruct->GPIO_Mode = GPIO_Mode_IN_FLOATING;
}
4.GPIO_ReadInputDataBit
读取哪一个引脚的值
/*** @brief Reads the specified input port pin.* @param GPIOx: where x can be (A..G) to select the GPIO peripheral.* @param GPIO_Pin: specifies the port bit to read.* This parameter can be GPIO_Pin_x where x can be (0..15).* @retval The input port pin value.*/
uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
{uint8_t bitstatus = 0x00;/* Check the parameters */assert_param(IS_GPIO_ALL_PERIPH(GPIOx));assert_param(IS_GET_GPIO_PIN(GPIO_Pin)); if ((GPIOx->IDR & GPIO_Pin) != (uint32_t)Bit_RESET){bitstatus = (uint8_t)Bit_SET;}else{bitstatus = (uint8_t)Bit_RESET;}return bitstatus;
}
5.GPIO_ReadInputData
读取整个端口
/*** @brief Reads the specified GPIO input data port.* @param GPIOx: where x can be (A..G) to select the GPIO peripheral.* @retval GPIO input data port value.*/
uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx)
{/* Check the parameters */assert_param(IS_GPIO_ALL_PERIPH(GPIOx));return ((uint16_t)GPIOx->IDR);
}
6.GPIO_ReadOutputDataBit/GPIO_ReadOutputData
/*** @brief Reads the specified output data port bit.* @param GPIOx: where x can be (A..G) to select the GPIO peripheral.* @param GPIO_Pin: specifies the port bit to read.* This parameter can be GPIO_Pin_x where x can be (0..15).* @retval The output port pin value.*/
uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
{uint8_t bitstatus = 0x00;/* Check the parameters */assert_param(IS_GPIO_ALL_PERIPH(GPIOx));assert_param(IS_GET_GPIO_PIN(GPIO_Pin)); if ((GPIOx->ODR & GPIO_Pin) != (uint32_t)Bit_RESET){bitstatus = (uint8_t)Bit_SET;}else{bitstatus = (uint8_t)Bit_RESET;}return bitstatus;
}/*** @brief Reads the specified GPIO output data port.* @param GPIOx: where x can be (A..G) to select the GPIO peripheral.* @retval GPIO output data port value.*/
uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx)
{/* Check the parameters */assert_param(IS_GPIO_ALL_PERIPH(GPIOx));return ((uint16_t)GPIOx->ODR);
}
7. GPIO_EventOutputConfig
/*** @brief Selects the GPIO pin used as Event output.* @param GPIO_PortSource: selects the GPIO port to be used as source* for Event output.* This parameter can be GPIO_PortSourceGPIOx where x can be (A..E).* @param GPIO_PinSource: specifies the pin for the Event output.* This parameter can be GPIO_PinSourcex where x can be (0..15).* @retval None*/
void GPIO_EventOutputConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource)
{uint32_t tmpreg = 0x00;/* Check the parameters */assert_param(IS_GPIO_EVENTOUT_PORT_SOURCE(GPIO_PortSource));assert_param(IS_GPIO_PIN_SOURCE(GPIO_PinSource));tmpreg = AFIO->EVCR;/* Clear the PORT[6:4] and PIN[3:0] bits */tmpreg &= EVCR_PORTPINCONFIG_MASK;tmpreg |= (uint32_t)GPIO_PortSource << 0x04;tmpreg |= GPIO_PinSource;AFIO->EVCR = tmpreg;
}

8.GPIO_PinRemapConfig
当我们要使用的引脚不够时,就要将其他不需要使用到的引脚进行复用

void GPIO_PinRemapConfig(uint32_t GPIO_Remap, FunctionalState NewState)
{uint32_t tmp = 0x00, tmp1 = 0x00, tmpreg = 0x00, tmpmask = 0x00;/* Check the parameters */assert_param(IS_GPIO_REMAP(GPIO_Remap));assert_param(IS_FUNCTIONAL_STATE(NewState)); if((GPIO_Remap & 0x80000000) == 0x80000000){tmpreg = AFIO->MAPR2;}else{tmpreg = AFIO->MAPR;}tmpmask = (GPIO_Remap & DBGAFR_POSITION_MASK) >> 0x10;tmp = GPIO_Remap & LSB_MASK;if ((GPIO_Remap & (DBGAFR_LOCATION_MASK | DBGAFR_NUMBITS_MASK)) == (DBGAFR_LOCATION_MASK | DBGAFR_NUMBITS_MASK)){tmpreg &= DBGAFR_SWJCFG_MASK;AFIO->MAPR &= DBGAFR_SWJCFG_MASK;}else if ((GPIO_Remap & DBGAFR_NUMBITS_MASK) == DBGAFR_NUMBITS_MASK){tmp1 = ((uint32_t)0x03) << tmpmask;tmpreg &= ~tmp1;tmpreg |= ~DBGAFR_SWJCFG_MASK;}else{tmpreg &= ~(tmp << ((GPIO_Remap >> 0x15)*0x10));tmpreg |= ~DBGAFR_SWJCFG_MASK;}if (NewState != DISABLE){tmpreg |= (tmp << ((GPIO_Remap >> 0x15)*0x10));}if((GPIO_Remap & 0x80000000) == 0x80000000){AFIO->MAPR2 = tmpreg;}else{AFIO->MAPR = tmpreg;}
}
9.GPIO_EXTILineConfig
与外部中断有关
/*** @brief Selects the GPIO pin used as EXTI Line.* @param GPIO_PortSource: selects the GPIO port to be used as source for EXTI lines.* This parameter can be GPIO_PortSourceGPIOx where x can be (A..G).* @param GPIO_PinSource: specifies the EXTI line to be configured.* This parameter can be GPIO_PinSourcex where x can be (0..15).* @retval None*/
void GPIO_EXTILineConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource)
{uint32_t tmp = 0x00;/* Check the parameters */assert_param(IS_GPIO_EXTI_PORT_SOURCE(GPIO_PortSource));assert_param(IS_GPIO_PIN_SOURCE(GPIO_PinSource));tmp = ((uint32_t)0x0F) << (0x04 * (GPIO_PinSource & (uint8_t)0x03));AFIO->EXTICR[GPIO_PinSource >> 0x02] &= ~tmp;AFIO->EXTICR[GPIO_PinSource >> 0x02] |= (((uint32_t)GPIO_PortSource) << (0x04 * (GPIO_PinSource & (uint8_t)0x03)));
}
3.使用GPIO库函数点亮LED
1.接线
我们连接的是GPIOB8-GPIOB15
注意点:我们这里是反着接的【要将引脚一一对应】


2.代码实现
#include "led.h"
#include "stm32f10x.h" // Device headerstatic void delay(){unsigned int i=0,j=0;for(i=0;i<1000;i++){for(j=0;j<2000;j++){}}
}
/*
void led_init(){//因为RCC部分还没有定义结构体,所以还是按照原来的方式去操作RCC->APB2ENR = 0x00000008;GPIOB->CRH=0x33333333;GPIOB->ODR=0x00000000;
}void delay(){unsigned int i=0,j=0;for(i=0;i<1000;i++){for(j=0;j<2000;j++){}}
}
void led_flash(void){unsigned int i=0;for(i=0;i<3;i++){GPIOB->ODR = 0x00000000;//全亮delay();GPIOB->ODR = 0x0000ff00;//全灭delay();}
}*///硬件实际用到的是GPIOB8-GPIOB15
//使用标准库中的GPIO进行封装API来进行GPIO设置,以点亮LED//定义一个结构体:描述GPIO的速度,频率等
GPIO_InitTypeDef gpio_InitStructure;/**注意点:如果我们没有去操纵某一个引脚的时候默认上电后,灯全部亮
*/
void led_init(){//一、通过GPIO初始化来实现//记得一定要加上时钟RCC->APB2ENR=0x00000008;//单独设置//实际操纵寄存器去将GPB8设置为推挽输出模式,并且速率50MHZgpio_InitStructure.GPIO_Pin=GPIO_Pin_9;gpio_InitStructure.GPIO_Speed=GPIO_Speed_2MHz;gpio_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;//void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)GPIO_Init(GPIOB,&gpio_InitStructure);//二、设置LED亮,则需要输出模式//此时操纵一个引脚//操纵BSRR寄存器设置GPB8输出1,让LED点亮//void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)GPIO_SetBits(GPIOB,GPIO_Pin_9);}void led_flash(){unsigned int i=0;for(i=0;i<3;i++){GPIO_SetBits(GPIOB,GPIO_Pin_9);//GPB9亮delay();GPIO_SetBits(GPIOB,GPIO_Pin_9);//GPB9灭delay();}}相关文章:
【STM32】GPIO控制LED(HAL库版)
STM32最新固件库v3.5/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c 林何/STM32F103C8 - 码云 - 开源中国 (gitee.com) STM32最新固件库v3.5/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_gpio.c 林何/STM32F103C8 - 码云 - 开源中国 (gitee.…...
第27届亚洲国际动力传动与控制技术展览会盛大开幕,意大利国家展团闪耀回归
2023年10月24日,第27届亚洲国际动力传动与控制技术展览会(PTC ASIA)在上海新国际博览中心正式拉开帷幕。作为亚太地区动力传动行业的风向标,PTC ASIA致力于为来自世界各地的参展企业提供专业的采供、技术信息交互平台,…...
永恒之蓝漏洞 ms17_010 详解
文章目录 永恒之蓝 ms 17_0101.漏洞介绍1.1 影响版本1.2 漏洞原理 2.信息收集2.1 主机扫描2.2 端口扫描 3. 漏洞探测4. 漏洞利用5.后渗透阶段5.1创建新的管理员账户5.2开启远程桌面5.3蓝屏攻击 永恒之蓝 ms 17_010 1.漏洞介绍 永恒之蓝(ms17-010)爆发于…...
汽车托运全流程介绍
从来没有办理过小轿车托运的客户都很好奇究竟汽车是如何被托运的呢?整个托运的过程介绍又是怎样的呢?因为托运汽车装车时客户本人都不在场,看不到整个的托运过程。今天具体的捋顺下整个的操作过程。 托运汽车装车前的准备工作 1.整个车辆装载过程中需要用到2名拥有…...
【API篇】八、Flink窗口函数
文章目录 1、增量聚合之ReduceFunction2、增量聚合之AggregateFunction3、全窗口函数full window functions4、增量聚合函数搭配全窗口函数5、会话窗口动态获取间隔值6、触发器和移除器7、补充 //窗口操作 stream.keyBy(<key selector>).window(<window assigner>)…...
React JSX常用语法总结
React JSX语法 什么是React JSX JSX(javascript xml) 就是JavaScript和XML结合的一种格式,是JavaScript的语法扩展,只要把HTML代码写在JS中,就为JSX。用于动态构建用户界面的Javascript库,发送请求获取数据…...
DVWA-Cross Site Request Forgery (CSRF)
大部分网站都会要求用户登录后,使用相应的权限在网页中进行操作,比如发邮件、购物或者转账等都是基于特定用户权限的操作。浏览器会短期或长期地记住用户的登录信息,但是,如果这个登录信息被恶意利用呢?就有可能发生CSRF CSRF的英文全称为Cross Site Request Forgery,中文…...
浅谈安科瑞可编程电测仪表在老挝某项目的应用
摘要:本文介绍了安科瑞多功能电能表在老挝某项目的应用。AMC系列交流多功能仪表是一款专门为电力系统、工矿企业、公用事业和智能建筑用于电力监控而设计的智能电表。 Abstract:This article introduces the application of the multi-function energy …...
Java项目源码合集
以下只是源码合集的一部分,源码均已本地正常调试运行,如需请与我联系。 序号项目名称演示地址1springbootvue药店销售管理系统https://pan.baidu.com/s/1n-Vk5Pr5z7s3IcN3WsCkdg?pwdve6z 2基于ssm协同过滤技术的旅游景点购票系统https://pan.baidu.com…...
Python学习笔记--生成器
四、生成器 1、为什么需要生成器 通过上面的学习,可以知道列表生成式,我们可以直接创建一个列表。 但是,受到内存限制,列表容量肯定是有限的。而且,创建一个包含 1000 万个元素的列表,不仅占用很大的存储…...
【Python学习】—Python基础语法(五)
【Python学习】—Python基础语法(五) 一、循环的嵌套使用 二、九九乘法表 #外层循环表示行数 for i in range(1,10):#内层循环表示每一行的数据for j in range(1,i1):#输出每一行的内容print(f"{i} * {j} {i * j} \t",end"") #外层…...
【js】JavaScript清除所有(多个)定时器的方法:
文章目录 一、停止单个定时器二、暂停与恢复定时器三、使用Promise来管理定时器四、使用ES6特性管理定时器五、案例(定时获取页面列表数据) 一、停止单个定时器 #在某些情况下,我们可能只需要停止单个定时器。 #在JavaScript中,我…...
java实现周易64卦并返回对应的卦象(含百度百科链接)
《易经》是中华民族传统思想文化中自然哲学与人文实践的理论根源,是古代汉民族思想、智慧的结晶,被誉为“大道之源”,是古代帝王之学,政治家、军事家、商家的必修之术。 《易经》含盖万有,纲纪群伦,是中华…...
# 算法与程序的灵魂
文章目录 前言算法与程序的关系例子1:冒泡排序例子2:斐波那契数列算法优化与进阶总结 前言 大家好我是艾老虎尤,算法与程序是计算机科学中两个非常重要的概念。算法是解决问题的方法和步骤,而程序是算法的具体实现。在计算机科学…...
2023-10-21 美团2024秋招后端开发岗笔试题
1 考察dfs和拓扑排序 1.1 题目描述(如果拓扑排序不清楚可以去做一下lc 207. 课程表) 1.2 答案 import java.util.*;public class Meituan {static int m,n;public static void main(String[] args) {Scanner in new Scanner(System.in);m in.nextInt…...
汽车托运是怎样收费
汽车托运是如何收费的呢?一般来说,汽车托运的费用是会随着每公里来增加,目前的托运的每公里费用在1.2-1.8元之间,托运的距离越远那么它的托运单价费用就会越低,如果你运气好找到一家在搞活动的汽车托运公司,那么你就算…...
使用docker-compose私有化部署 GitLab
在软件开发和协作过程中,版本控制是至关重要的一环。GitLab 是一个功能强大的开源平台,提供了完整的代码管理功能,包括版本控制、问题跟踪以及持续集成等。这使得团队能够更高效地协作开发。前段时间翻阅笔记时,偶然发现了之前公司…...
Vue项目引入百度统计的正确操作步骤,亲测有效!
1、平台获取统计代码 2、在head和body中分别添加以下代码 head: <script>var _hmt _hmt || [];</script>body: <script>var _hmt _hmt || [];(function () {var hm document.createElement("script");hm.src "https://hm.baidu.com/hm.js…...
Keras中model.evaluate() 返回的是 loss value 和 metrics values
Keras官方文档: https://keras.io/models/model/#evaluate Keras中model.evaluate() 返回的是 损失值和训练时选定的指标值(例如,[AUC, , accuracy])。 训练时选定的指标值是指model.compile()里面metrics后面的值,ev…...
CSRF跨域请求伪造
1.SSRF服务端请求伪造(外网访问内网) SSRF(Server-Side Request Forgery:服务器端请求伪造) 是一种由攻击者构造形成由服务端发起请求的一个安全漏洞。一般情况下,SSRF是要目标网站的内部系统。(因为他是从内部系统访问的…...
基于算法竞赛的c++编程(28)结构体的进阶应用
结构体的嵌套与复杂数据组织 在C中,结构体可以嵌套使用,形成更复杂的数据结构。例如,可以通过嵌套结构体描述多层级数据关系: struct Address {string city;string street;int zipCode; };struct Employee {string name;int id;…...
Linux应用开发之网络套接字编程(实例篇)
服务端与客户端单连接 服务端代码 #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <arpa/inet.h> #include <pthread.h> …...
【人工智能】神经网络的优化器optimizer(二):Adagrad自适应学习率优化器
一.自适应梯度算法Adagrad概述 Adagrad(Adaptive Gradient Algorithm)是一种自适应学习率的优化算法,由Duchi等人在2011年提出。其核心思想是针对不同参数自动调整学习率,适合处理稀疏数据和不同参数梯度差异较大的场景。Adagrad通…...
pam_env.so模块配置解析
在PAM(Pluggable Authentication Modules)配置中, /etc/pam.d/su 文件相关配置含义如下: 配置解析 auth required pam_env.so1. 字段分解 字段值说明模块类型auth认证类模块,负责验证用户身份&am…...
vue3 字体颜色设置的多种方式
在Vue 3中设置字体颜色可以通过多种方式实现,这取决于你是想在组件内部直接设置,还是在CSS/SCSS/LESS等样式文件中定义。以下是几种常见的方法: 1. 内联样式 你可以直接在模板中使用style绑定来设置字体颜色。 <template><div :s…...
反射获取方法和属性
Java反射获取方法 在Java中,反射(Reflection)是一种强大的机制,允许程序在运行时访问和操作类的内部属性和方法。通过反射,可以动态地创建对象、调用方法、改变属性值,这在很多Java框架中如Spring和Hiberna…...
Rust 异步编程
Rust 异步编程 引言 Rust 是一种系统编程语言,以其高性能、安全性以及零成本抽象而著称。在多核处理器成为主流的今天,异步编程成为了一种提高应用性能、优化资源利用的有效手段。本文将深入探讨 Rust 异步编程的核心概念、常用库以及最佳实践。 异步编程基础 什么是异步…...
力扣-35.搜索插入位置
题目描述 给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。如果目标值不存在于数组中,返回它将会被按顺序插入的位置。 请必须使用时间复杂度为 O(log n) 的算法。 class Solution {public int searchInsert(int[] nums, …...
基于TurtleBot3在Gazebo地图实现机器人远程控制
1. TurtleBot3环境配置 # 下载TurtleBot3核心包 mkdir -p ~/catkin_ws/src cd ~/catkin_ws/src git clone -b noetic-devel https://github.com/ROBOTIS-GIT/turtlebot3.git git clone -b noetic https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git git clone -b noetic-dev…...
python读取SQLite表个并生成pdf文件
代码用于创建含50列的SQLite数据库并插入500行随机浮点数据,随后读取数据,通过ReportLab生成横向PDF表格,包含格式化(两位小数)及表头、网格线等美观样式。 # 导入所需库 import sqlite3 # 用于操作…...
