forked from trocache/RefKEIL
43 lines
1.1 KiB
C
43 lines
1.1 KiB
C
#include "Driver_GPIO.h"
|
|
|
|
void MyGPIO_Init(MyGPIO_Struct_TypeDef * GPIOStructPtr) {
|
|
//Configurer les horloges
|
|
if(GPIOStructPtr->GPIO == GPIOA){
|
|
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN;//RCC->APB2ENR = 0x02;
|
|
}
|
|
else if(GPIOStructPtr->GPIO == GPIOB){
|
|
RCC->APB2ENR |= RCC_APB2ENR_IOPBEN;//RCC->APB2ENR = 0x03;
|
|
}
|
|
else if (GPIOStructPtr->GPIO == GPIOC){
|
|
RCC->APB2ENR |= RCC_APB2ENR_IOPCEN; //RCC->APB2ENR = 0x04;
|
|
}
|
|
//Initialiser le registre urilisé
|
|
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));
|
|
GPIOStructPtr->GPIO->CRH |= (GPIOStructPtr->GPIO_Conf << (4* GPIOStructPtr->GPIO_Pin));
|
|
}
|
|
}
|
|
|
|
int MyGPIO_Read(GPIO_TypeDef * GPIO, char GPIO_Pin){
|
|
if((GPIO->IDR) &= (1 << GPIO_Pin)!=0)
|
|
{
|
|
return 1;
|
|
}else{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void MyGPIO_Set(GPIO_TypeDef * GPIO, char GPIO_Pin){
|
|
|
|
}
|
|
|
|
void MyGPIO_Reset(GPIO_TypeDef * GPIO, char GPIO_Pin){
|
|
|
|
}
|
|
|
|
void MyGPIO_Toggle(GPIO_TypeDef * GPIO, char GPIO_Pin){
|
|
|
|
}
|