KF32A156迷你EVB上的LED0每500ms闪烁一次
- void BoardGpioInit(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
-
- /* Configure PD12 LED1 output */
- GPIO_InitStructure.m_Mode = GPIO_MODE_OUT;
- GPIO_InitStructure.m_OpenDrain = GPIO_POD_PP;
- GPIO_InitStructure.m_PullDown = GPIO_NOPULL;
- GPIO_InitStructure.m_PullUp = GPIO_NOPULL;
- GPIO_InitStructure.m_Speed = GPIO_LOW_SPEED;
- GPIO_InitStructure.m_Pin = GPIO_PIN_MASK_12;
- GPIO_Configuration(GPIOD_SFR , &GPIO_InitStructure);
-
- /* Configure PH3 LED2 output */
- GPIO_InitStructure.m_Pin = GPIO_PIN_MASK_3;
- GPIO_Configuration(GPIOH_SFR , &GPIO_InitStructure);
-
- /* Configure PD7 user key input */
- GPIO_InitStructure.m_Mode = GPIO_MODE_IN;
- GPIO_InitStructure.m_Pin = GPIO_PIN_MASK_7;
- GPIO_Configuration(GPIOD_SFR , &GPIO_InitStructure);
- }
- /*******************************************************************************
- ** Main Functions **
- *******************************************************************************/
- /**
- * [url=home.php?mod=space&uid=247401]@brief[/url] :Main program
- * @param in :None
- * @param out :None
- * @retval :None
- */
- int main()
- {
- /* Initialize the system clock is 120M*/
- SystemInit(120);
- /* Setup SysTick Timer as delay function, and input frequency is 120M */
- systick_delay_init(120);
- /* Initialize the user IOs */
- BoardGpioInit();
- while(1)
- {
- /* Toggle LED1 */
- if (++TimingDelay >= 10)
- {
- TimingDelay = 0;
- GPIO_Toggle_Output_Data_Config(GPIOD_SFR, GPIO_PIN_MASK_12);
- }
- /* Turn ON/OFF the dedicate LED2 by user key */
- if (GPIO_Read_Input_Data_Bit(GPIOD_SFR, GPIO_PIN_MASK_7) == Bit_RESET)
- {
- GPIO_Set_Output_Data_Bits(GPIOH_SFR, GPIO_PIN_MASK_3, Bit_SET);
- }
- else
- {
- GPIO_Set_Output_Data_Bits(GPIOH_SFR, GPIO_PIN_MASK_3, Bit_RESET);
- }
- systick_delay_ms(50);
- }
- }
|