Exemple de contrôle d’une led sur le port PE8 avec un microcontrôleur STM32F407 :
void led_init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
// configuration en sortie
GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
}
void led_control(GPIO_PinState state_led)
{
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_8, state_led);
}
void led_toggle(void)
{
HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_8);
}
Related