#include "Driver_GPIO.h" //---------------------FONCTION D'INITIALISATION-----------------// void MyGPIO_Init ( MyGPIO_Struct_TypeDef * GPIOStructPtr){ //INITIALISATION DE LA CLOCK CORRESPONDANT AU GPIO A, B ou C if (GPIOStructPtr->GPIO == GPIOA) { RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; } else if (GPIOStructPtr->GPIO == GPIOB) { RCC->APB2ENR |= RCC_APB2ENR_IOPBEN; } else if (GPIOStructPtr->GPIO == GPIOC) { RCC->APB2ENR |= RCC_APB2ENR_IOPCEN; } else if (GPIOStructPtr->GPIO == GPIOD) { RCC->APB2ENR |= RCC_APB2ENR_IOPDEN; } //CONFIGURATION DE LA PIN UTILISEE (voir table20 p9.1) if(GPIOStructPtr->GPIO_Pin < 8){ GPIOStructPtr->GPIO->CRL &= ~(0xF << (4 * GPIOStructPtr->GPIO_Pin)); GPIOStructPtr->GPIO->CRL |= (GPIOStructPtr->GPIO_Conf << (4 * GPIOStructPtr->GPIO_Pin)); } else { GPIOStructPtr->GPIO->CRH &= ~(0xF << (4 * GPIOStructPtr->GPIO_Pin - 8)); GPIOStructPtr->GPIO->CRH |= (GPIOStructPtr->GPIO_Conf << (4 * GPIOStructPtr->GPIO_Pin - 8)); } //CONFIGURATION DE L'ODR EN ENTREE (pull up et down uniquement) if(GPIOStructPtr->GPIO_Conf == In_PullUp){ GPIOStructPtr->GPIO->ODR = 0x1; } else if(GPIOStructPtr->GPIO_Conf == In_PullDown){ GPIOStructPtr->GPIO->ODR = 0x0; } } //----------------------------READ--------------------------// int MyGPIO_Read ( GPIO_TypeDef * GPIO , char GPIO_Pin ){ int etatbit; //On vérifie si la valeur lue dans l'IDR est un 0 ou un 1 if((GPIO->IDR & (1<BSRR |= (1 << GPIO_Pin); } //---------------------RESET-----------------// void MyGPIO_Reset ( GPIO_TypeDef * GPIO , char GPIO_Pin ){ GPIO->BRR = (1 << GPIO_Pin); //Pas besoin de | puisque les 0 n'impactent pas la fonction reset } //---------------------TOGGLE-----------------// void MyGPIO_Toggle ( GPIO_TypeDef * GPIO , char GPIO_Pin ){ GPIO->ODR ^= (1 << GPIO_Pin); }