/************************************************************************* * Description: Initialize the LED hardware * Returns: none * Notes: none *************************************************************************/ void led_init( void) { GPIO_InitTypeDef GPIO_InitStructure; GPIO_StructInit(&GPIO_InitStructure); /* Configure the Receive LED on MS/TP board */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOB, &GPIO_InitStructure); /* Configure the Transmit LED on MS/TP board */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOB, &GPIO_InitStructure); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); /* Configure the LD4 on Discovery board */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOC, &GPIO_InitStructure); /* Configure the LD3 on Discovery board */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOC, &GPIO_InitStructure); /* Enable the GPIO_LED Clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); led_tx_on(); led_rx_on(); led_ld3_on(); led_ld4_on(); }
/************************************************************************* * Description: Toggle the state of the LED * Returns: none * Notes: none *************************************************************************/ void led_tx_toggle( void) { if (led_tx_state()) { led_tx_off(); } else { led_tx_on(); } }
int main(void) { watchdog_init(); clock_init(); gpio_init(); led_init(); uart_init(); while (1) { led_tx_off(); led_rx_on(); sdelay(10000000); led_tx_on(); led_rx_off(); sdelay(10000000); uart_putchar('z'); } return 0; }
/************************************************************************* * Description: Turn on, and delay before going off. * Returns: none * Notes: none *************************************************************************/ void led_tx_on_interval( uint16_t interval_ms) { led_tx_on(); timer_interval_start(&Off_Delay_Timer_Tx, interval_ms); }