diff --git a/src/hal/rtl87x0c/hal_pins_rtl87x0c.c b/src/hal/rtl87x0c/hal_pins_rtl87x0c.c index 425bfe1cc..42e70ddb1 100644 --- a/src/hal/rtl87x0c/hal_pins_rtl87x0c.c +++ b/src/hal/rtl87x0c/hal_pins_rtl87x0c.c @@ -57,20 +57,10 @@ 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); @@ -78,25 +68,25 @@ void RTL_GPIO_Init(rtlPinMapping_t* 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); @@ -104,9 +94,9 @@ void HAL_PIN_Setup_Input_Pullup(int index) 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); @@ -114,9 +104,9 @@ void HAL_PIN_Setup_Input_Pulldown(int index) 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); @@ -124,9 +114,9 @@ void HAL_PIN_Setup_Input(int index) 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); diff --git a/src/obk_config.h b/src/obk_config.h index b6dc1f745..fbdd9dac1 100644 --- a/src/obk_config.h +++ b/src/obk_config.h @@ -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