forked from trocache/RefKEIL
40 lines
1 KiB
C
40 lines
1 KiB
C
#include "gpiodriver.h"
|
|
|
|
void MyGPIO_Init(MyGPIO_Struct_TypeDef * GPIOStructPtr)
|
|
{
|
|
RCC->APB2ENR |= (0x01 << 2) | (0x01 << 3) | (0x01 << 4);
|
|
volatile uint32_t * CRAny = GPIOStructPtr->GPIO_Pin > 0x08 ? &(GPIOStructPtr->GPIO->CRH):&(GPIOStructPtr->GPIO->CRL);
|
|
//setup high or low
|
|
*CRAny &= ~(0xF << (GPIOStructPtr->GPIO_Pin%8)*4); //reset
|
|
*CRAny |= (GPIOStructPtr->GPIO_Conf << (GPIOStructPtr->GPIO_Pin%8)*4); //set pin mode
|
|
//for input pull or push
|
|
if(!(GPIOStructPtr->GPIO_Conf%2) && (GPIOStructPtr->GPIO_Conf>0x04)) //si input mode et en pullpush
|
|
{
|
|
if(GPIOStructPtr->GPIO_Conf > In_PullDown)
|
|
{
|
|
GPIOStructPtr->GPIO->ODR &= ~(0x01 << GPIOStructPtr->GPIO_Pin);
|
|
} else{
|
|
GPIOStructPtr->GPIO->ODR |= (0x01 << GPIOStructPtr->GPIO_Pin);
|
|
}
|
|
}
|
|
}
|
|
|
|
int MyGPIO_Read(GPIO_TypeDef * GPIO, uint8_t GPIO_Pin)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
void MyGPIO_Set(GPIO_TypeDef * GPIO, uint8_t GPIO_Pin)
|
|
{
|
|
|
|
}
|
|
|
|
void MyGPIO_Reset(GPIO_TypeDef * GPIO, uint8_t GPIO_Pin)
|
|
{
|
|
|
|
}
|
|
|
|
void MyGPIO_Toggle(GPIO_TypeDef * GPIO, uint8_t GPIO_Pin)
|
|
{
|
|
|
|
}
|