[BSP] Fixed imxrt1050 gpio driver | 修复 imxrt1050 gpio 驱动

This commit is contained in:
BalanceTWK 2019-01-27 21:22:02 +08:00
parent 92b1502eec
commit 70738c3711
1 changed files with 48 additions and 44 deletions

View File

@ -222,9 +222,9 @@ void gpio_isr(GPIO_Type* base, rt_uint32_t gpio_pin)
{
if((GPIO_PortGetInterruptFlags(base) & (1 << gpio_pin)) != 0)
{
GPIO_PortClearInterruptFlags(base, gpio_pin);
if(rt1052_irq_map[gpio_pin].irq_info.hdr != RT_NULL)
GPIO_PortClearInterruptFlags(base, (1 << gpio_pin));
if (rt1052_irq_map[gpio_pin].irq_info.hdr != RT_NULL)
{
rt1052_irq_map[gpio_pin].irq_info.hdr(rt1052_irq_map[gpio_pin].irq_info.args);
}
@ -447,36 +447,36 @@ static void rt1052_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode)
{
case PIN_MODE_OUTPUT:
{
config_value = 0x1030U;
gpio.direction = kGPIO_DigitalOutput;
config_value = 0x0030U;/* Drive Strength R0/6 */
gpio.direction = kGPIO_DigitalOutput;
}
break;
break;
case PIN_MODE_INPUT:
{
config_value = 0x1030U;
gpio.direction = kGPIO_DigitalInput;
config_value = 0x0830U;/* Open Drain Enable */
gpio.direction = kGPIO_DigitalInput;
}
break;
case PIN_MODE_INPUT_PULLDOWN:
{
config_value = 0x1030U;
gpio.direction = kGPIO_DigitalInput;
}
break;
case PIN_MODE_INPUT_PULLUP:
{
config_value = 0x5030U;
gpio.direction = kGPIO_DigitalInput;
config_value = 0x3030U;/* 100K Ohm Pull Down */
gpio.direction = kGPIO_DigitalInput;
}
break;
case PIN_MODE_INPUT_PULLUP:
{
config_value = 0xB030U;/* 100K Ohm Pull Up */
gpio.direction = kGPIO_DigitalInput;
}
break;
case PIN_MODE_OUTPUT_OD:
{
config_value = 0x1830U;
gpio.direction = kGPIO_DigitalOutput;
config_value = 0x0830U;/* Open Drain Enable */
gpio.direction = kGPIO_DigitalOutput;
}
break;
}
@ -560,15 +560,14 @@ static rt_err_t rt1052_pin_irq_enable(struct rt_device *device, rt_base_t pin, r
{
gpio_pin_config_t gpio;
IRQn_Type irq_num;
rt_uint32_t config_value = 0x1b0a0;
struct rt1052_pin* pin_map = RT_NULL;
struct rt1052_irq* irq_map = RT_NULL;
pin_map = &rt1052_pin_map[pin];
irq_map = &rt1052_irq_map[rt1052_pin_map[pin].gpio_pin];
if(pin_map == RT_NULL || irq_map == RT_NULL)
rt_uint32_t config_value = 0;
struct rt1052_pin *pin_map = RT_NULL;
struct rt1052_irq *irq_map = RT_NULL;
pin_map = &rt1052_pin_map[pin];
irq_map = &rt1052_irq_map[rt1052_pin_map[pin].gpio_pin];
if (pin_map == RT_NULL || irq_map == RT_NULL)
{
return RT_ENOSYS;
}
@ -589,13 +588,13 @@ static rt_err_t rt1052_pin_irq_enable(struct rt_device *device, rt_base_t pin, r
if(rt1052_pin_map[pin].gpio != GPIO5)
{
CLOCK_EnableClock(kCLOCK_Iomuxc);
IOMUXC_SetPinMux(0x401F8010U + pin*4, 0x5U, 0, 0, 0, 0);
CLOCK_EnableClock(kCLOCK_Iomuxc);
IOMUXC_SetPinMux(0x401F8010U + pin * 4, 0x5U, 0, 0, 0, 1);
}
else
{
CLOCK_EnableClock(kCLOCK_IomuxcSnvs);
IOMUXC_SetPinMux(0x400A8000U + (pin-125)*4, 0x5U, 0, 0, 0, 0);
CLOCK_EnableClock(kCLOCK_IomuxcSnvs);
IOMUXC_SetPinMux(0x400A8000U + (pin - 125) * 4, 0x5U, 0, 0, 0, 1);
}
gpio.direction = kGPIO_DigitalInput;
@ -605,31 +604,36 @@ static rt_err_t rt1052_pin_irq_enable(struct rt_device *device, rt_base_t pin, r
{
case PIN_IRQ_MODE_RISING:
{
gpio.interruptMode = kGPIO_IntRisingEdge;
config_value = 0x3030U;/* 100K Ohm Pull Down */
gpio.interruptMode = kGPIO_IntRisingEdge;
}
break;
case PIN_IRQ_MODE_FALLING:
{
gpio.interruptMode = kGPIO_IntFallingEdge;
config_value = 0xB030U;/* 100K Ohm Pull Up */
gpio.interruptMode = kGPIO_IntFallingEdge;
}
break;
case PIN_IRQ_MODE_RISING_FALLING:
{
gpio.interruptMode = kGPIO_IntRisingOrFallingEdge;
config_value = 0x0830U;/* Open Drain Enable */
gpio.interruptMode = kGPIO_IntRisingOrFallingEdge;
}
break;
case PIN_IRQ_MODE_HIGH_LEVEL:
{
gpio.interruptMode = kGPIO_IntHighLevel;
config_value = 0x3030U;/* 100K Ohm Pull Down */
gpio.interruptMode = kGPIO_IntHighLevel;
}
break;
case PIN_IRQ_MODE_LOW_LEVEL:
{
gpio.interruptMode = kGPIO_IntLowLevel;
config_value = 0xB030U;/* 100K Ohm Pull Up */
gpio.interruptMode = kGPIO_IntLowLevel;
}
break;
}