#include "stm32c0xx_hal.h"
/* Déclaration des fonctions */
void SystemClock_Config(void);
void led_jaune(void);
/* Fonction de commande de la LED jaune
Aucun paramètre et aucune valeur de retour.
*/
void led_jaune(void)
{
/* Allumer la LED sur PB1 */
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_SET);
HAL_Delay(500);
/* Éteindre la LED sur PB1 */
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_RESET);
HAL_Delay(500);
}
int main(void)
{
/* Initialisation de la bibliothèque HAL */
HAL_Init();
/* Configuration de l'horloge système */
SystemClock_Config();
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* Activation de l'horloge GPIOB */
__HAL_RCC_GPIOB_CLK_ENABLE();
/* Configuration de PB1 en sortie */
GPIO_InitStruct.Pin = GPIO_PIN_1;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
/* Application de la configuration */
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* Boucle principale */
while (1)
{
/* Appel de la fonction */
led_jaune();
}
}Loading
st-nucleo-c031c6
st-nucleo-c031c6