刚接触STM32,各位大侠,作为初学者有个小疑问求解,不要见怪,,,,
在《原子教你玩STM32》视频第三讲中, 原子用Printf 函数输出了GPIO各个寄存器的地址。
我的疑问是:1. 调用这个函数用什么 不用include "stdio.h"头文件。
2. 这个函数是怎么实现的,为什么可以从串口输出,为什么 无法使用GO to Definition of "Printf" 来查看定义
3. 例程中讲解的GPIO初始函数GPIO_Init(),为了清楚该函数的具体操作,我在stm32f10x_gpio.c , GPIO_Init()的定义处加了一行Printf,,编译通过,但为什么串口没输出了呢,好像停在了这一行。如果注释掉是可以的。如下:
void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)
{
uint32_t currentmode = 0x00, currentpin = 0x00, pinpos = 0x00, pos = 0x00;
uint32_t tmpreg = 0x00, pinmask = 0x00;
/* Check the parameters */
assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
assert_param(IS_GPIO_MODE(GPIO_InitStruct->GPIO_Mode));
assert_param(IS_GPIO_PIN(GPIO_InitStruct->GPIO_Pin));
/*---------------------------- GPIO Mode Configuration -----------------------*/
currentmode = ((uint32_t)GPIO_InitStruct->GPIO_Mode) & ((uint32_t)0x0F);
if ((((uint32_t)GPIO_InitStruct->GPIO_Mode) & ((uint32_t)0x10)) != 0x00)
{
/* Check the parameters */
assert_param(IS_GPIO_SPEED(GPIO_InitStruct->GPIO_Speed));
/* Output mode */
currentmode |= (uint32_t)GPIO_InitStruct->GPIO_Speed;
printf("the value of currentmode=%x\n",currentmode);
}
请不吝赐教!!
|