/******************************************************************************
** Include Files
******************************************************************************/
#include "system_init.h"
#include "Board_GpioCfg.h"
/******************************************************************************
** Private variables
******************************************************************************/
static volatile uint32_t TimingDelay;
/*******************************************************************************
** Global Functions
*******************************************************************************/
/**
* @brief :Initialize the different GPIO ports
* @param[in] None
* @param[out] None
* @retval :None
*/
// 配置 PORTB 为输出模式
GPIOB->DDR |= 0xFF; // 设置前8位为输出
GPIOB->DR &= ~0xFF; // 设置输出低电平
// 使能 GPIOA 和 GPIOB 的时钟
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN | RCC_AHB1ENR_GPIOBEN;
void BoardGpioInit(void)
{
GPIO_Write_Mode_Bits(GPIOA_SFR, GPIO_PIN_MASK_0, GPIO_MODE_OUT); //LED1
GPIO_Write_Mode_Bits(GPIO_SFR, GPIO_PIN_MASK_11, GPIO_MODE_OUT); //LED2
}
/**
* @brief: Delay time
* @param[in] nms
* @param[out] None
* @retval : None
*/
void delay_ms(volatile uint32_t nms)
{
volatile uint32_t i, j;
for (i = 0; i < nms; i++)
{
j = 5000;
while (j--)
;
}
}
/*******************************************************************************
** Main Functions
*******************************************************************************/
int main()
{
/* Initialize the system clock is 72MHz*/
SystemInit(72U);
/* Setup SysTick Timer as delay function, and input frequency is 72MHz */
systick_delay_init(72U);
/* Initialize the user IOs */
BoardGpioInit();
while (1)
{
//GPIO_Write_Mode_Bits(GPIOA_SFR, GPIO_PIN_MASK_3, GPIO_MODE_OUT); //LED1
//GPIO_Write_Mode_Bits(GPIOF_SFR, GPIO_PIN_MASK_11, GPIO_MODE_OUT); //LED2
//GPIO_Write_Mode_Bits(GPIOA_SFR, GPIO_PIN_MASK_3, GPIO_MODE_OUT);
GPIO_Set_Output_Data_Bits(GPIOA_SFR, GPIO_PIN_MASK_3, Bit_SET);//LED1 H
//GPIO_Write_Mode_Bits(GPIOF_SFR, GPIO_PIN_MASK_11, GPIO_MODE_OUT);
GPIO_Set_Output_Data_Bits(GPIOF_SFR, GPIO_PIN_MASK_11, Bit_SET);//LED1 H
systick_delay_ms(200);
//GPIO_Write_Mode_Bits(GPIOA_SFR, GPIO_PIN_MASK_3, GPIO_MODE_OUT);
GPIO_Set_Output_Data_Bits(GPIOA_SFR, GPIO_PIN_MASK_3, Bit_RESET);//LED1 L
//GPIO_Write_Mode_Bits(GPIOF_SFR, GPIO_PIN_MASK_11, GPIO_MODE_OUT);
GPIO_Set_Output_Data_Bits(GPIOF_SFR, GPIO_PIN_MASK_11, Bit_SET);//LED2 H
systick_delay_ms(200);
//GPIO_Write_Mode_Bits(GPIOA_SFR, GPIO_PIN_MASK_3, GPIO_MODE_OUT);
GPIO_Set_Output_Data_Bits(GPIOA_SFR, GPIO_PIN_MASK_3, Bit_SET);//LED1 H
//GPIO_Write_Mode_Bits(GPIOF_SFR, GPIO_PIN_MASK_11, GPIO_MODE_OUT);
GPIO_Set_Output_Data_Bits(GPIOF_SFR, GPIO_PIN_MASK_11, Bit_RESET);//LED2 L
systick_delay_ms(200);
//GPIO_Write_Mode_Bits(GPIOA_SFR, GPIO_PIN_MASK_3, GPIO_MODE_OUT);
GPIO_Set_Output_Data_Bits(GPIOA_SFR, GPIO_PIN_MASK_3, Bit_RESET);//LED1 L
//GPIO_Write_Mode_Bits(GPIOF_SFR, GPIO_PIN_MASK_11, GPIO_MODE_OUT);
GPIO_Set_Output_Data_Bits(GPIOF_SFR, GPIO_PIN_MASK_11, Bit_RESET);//LED2 L
systick_delay_ms(200);
}
}
/**
* @brief : Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param[in] file pointer to the source file name
* @param[in] line assert_param error line source number
* @param[out] None
* @retval :None
*/
void check_failed(uint8_t *File, uint32_t Line)
{
/* User can add his own implementation to report the file name and line
number, ex: printf("Wrong parameters value: file %s on line %d\r\n",
file, line) */
/* Infinite loop */
while (1)
{
;
}
};
这段代码编译显示10:14:13 **** Incremental Build of configuration Debug for project GPIO_InputOutput ****
gmake -j16 all
Building file: ../main.c
../main.c:22:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
../main.c:23:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
../main.c:26:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
../main.c: In function 'BoardGpioInit':
../main.c:31:28: error: 'GPIO_SFR' undeclared (first use in this function)
../main.c:31:28: note: each undeclared identifier is reported only once for each function it appears in
gmake: *** [subdir.mk:26: main.o] Error 1
"gmake -j16 all" terminated with exit code 2. Build might be incomplete.
10:14:14 Build Failed. 5 errors, 0 warnings. (took 642ms)
修改正确发给我
最新发布