Merge pull request #2285 from balanceTWK/rtt_master

[BSP] Fixed imxrt1050 gpio driver | 修复 imxrt1050 gpio 驱动
This commit is contained in:
Bernard Xiong 2019-01-28 05:54:13 +08:00 committed by GitHub
commit 8bcc2d1265
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 290 additions and 286 deletions

View File

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