diff options
Diffstat (limited to 'Core/Src/led.c')
-rw-r--r-- | Core/Src/led.c | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/Core/Src/led.c b/Core/Src/led.c deleted file mode 100644 index 1a5c58f..0000000 --- a/Core/Src/led.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * led.c - * - * Created on: 2 déc. 2020 - * Author: root - */ - -#include "led.h" - -void Led_init(LED_TypeDef *led, GPIO_TypeDef * port, uint16_t pn){ -led->gpioPort=port; -led->pin=pn; - -//Activation de l'horloge sur le port en question - -//déterminer le numéro du port 0--> GPIOA, 1-->GPIOB, etc. -uint8_t nb_port; -nb_port=(uint32_t)((uint32_t *)port - IOPPERIPH_BASE)/ (uint32_t)0x400; -//activation de l'hologe -RCC->IOPENR|=1<<nb_port; - -//configuration de la pin en sortie -led->gpioPort->MODER&=~(0b11<<2*pn); -led->gpioPort->MODER|=(0b01<<2*pn); -} - -uint8_t Led_isOn(LED_TypeDef *led){ -return ((led->gpioPort->ODR&(1<<led->pin))!=0); -} - -uint8_t Led_isOff(LED_TypeDef *led){ -return ((led->gpioPort->ODR&(1<<led->pin))==0); -} -void Led_turnOn(LED_TypeDef *led){ -led->gpioPort->ODR|=(1<<led->pin); -} - -void Led_turnOff(LED_TypeDef *led){ -led->gpioPort->ODR&=~(1<<led->pin); -} - -void Led_toggle(LED_TypeDef *led){ - led->gpioPort->ODR^=(1<<led->pin); -} |