Skip to content

Commit

Permalink
irq fix
Browse files Browse the repository at this point in the history
  • Loading branch information
NonPIayerCharacter committed Dec 26, 2024
1 parent b7b52dc commit 29f8db9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
36 changes: 13 additions & 23 deletions src/hal/rtl87x0c/hal_pins_rtl87x0c.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,76 +57,66 @@ int HAL_PIN_CanThisPinBePWM(int index)

void RTL_GPIO_Init(rtlPinMapping_t* pin)
{
if(pin->gpio != NULL)
if(pin->gpio != NULL || pin->irq != NULL)
{
return;
}
//if(pin->irq != NULL)
//{
// hal_pinmux_unregister(pin->pin, PID_GPIO);
// pin->irq = NULL;
//}
//if(pin->pwm != NULL)
//{
// pwmout_free(pin->pwm);
// pin->pwm = NULL;
//}
pin->gpio = os_malloc(sizeof(gpio_t));
memset(pin->gpio, 0, sizeof(gpio_t));
gpio_init(pin->gpio, pin->pin);
}

void HAL_PIN_SetOutputValue(int index, int iVal)
{
if(index >= g_numPins)
return;
rtlPinMapping_t* pin = g_pins + index;
if(index >= g_numPins || pin->gpio == NULL)
return;
gpio_write(pin->gpio, iVal ? 1 : 0);
}

int HAL_PIN_ReadDigitalInput(int index)
{
if(index >= g_numPins)
return 0;
rtlPinMapping_t* pin = g_pins + index;
if(index >= g_numPins || pin->gpio == NULL)
return 0;
return gpio_read(pin->gpio);
}

void HAL_PIN_Setup_Input_Pullup(int index)
{
if(index >= g_numPins)
return;
rtlPinMapping_t* pin = g_pins + index;
if(index >= g_numPins || pin->gpio == NULL)
return;
RTL_GPIO_Init(pin);
gpio_dir(pin->gpio, PIN_INPUT);
gpio_mode(pin->gpio, PullUp);
}

void HAL_PIN_Setup_Input_Pulldown(int index)
{
if(index >= g_numPins)
return;
rtlPinMapping_t* pin = g_pins + index;
if(index >= g_numPins || pin->gpio == NULL)
return;
RTL_GPIO_Init(pin);
gpio_dir(pin->gpio, PIN_INPUT);
gpio_mode(pin->gpio, PullDown);
}

void HAL_PIN_Setup_Input(int index)
{
if(index >= g_numPins)
return;
rtlPinMapping_t* pin = g_pins + index;
if(index >= g_numPins || pin->gpio == NULL)
return;
RTL_GPIO_Init(pin);
gpio_dir(pin->gpio, PIN_INPUT);
gpio_mode(pin->gpio, PullNone);
}

void HAL_PIN_Setup_Output(int index)
{
if(index >= g_numPins)
return;
rtlPinMapping_t* pin = g_pins + index;
if(index >= g_numPins || pin->gpio == NULL)
return;
RTL_GPIO_Init(pin);
gpio_dir(pin->gpio, PIN_OUTPUT);
gpio_mode(pin->gpio, PullUp);
Expand Down
1 change: 1 addition & 0 deletions src/obk_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
#define ENABLE_DRIVER_DHT 1
#define ENABLE_DRIVER_BL0942 1
#define ENABLE_DRIVER_BL0937 1
#define ENABLE_DRIVER_CSE7766 1

#else

Expand Down

0 comments on commit 29f8db9

Please sign in to comment.