Issue with adding callbacks with HAL_GpioInstallCallback()

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Issue with adding callbacks with HAL_GpioInstallCallback()

864件の閲覧回数
threeboystech
Contributor II

I found an issue when attempting to use multiple IRQ pins on a common port number when fsl_adaptoer_gpio code is present.

When configuring for multiple pins on the same port:

hal_gpio_pin_config_t pin1;

pin1.direction = kHAL_GpioDirectionIn;

pin1.pin = 1;

pin1.port = 0;

HAL_GpioInit(&tl_Pin1GPIOHandler, &pin1);

HAL_GpioInstallCallback(&tl_Pin1GPIOHandler,Pin1IrqEvent,0);

 

hal_gpio_pin_config_t pin2;

pin2.direction = kHAL_GpioDirectionIn;

pin2.pin = 2;

pin2.port = 0;

HAL_GpioInit(&tl_Pin2GPIOHandler, &pin2);

HAL_GpioInstallCallback(&tl_Pin2GPIOHandler,Pin2IrqEvent,0);

 

 

The existing HAL_GpioInstallCallback() code will overwrite the pin1

assignment from above. I had to modify the code so that the

HAL_GpioInstallCallback() would link list to the last entry to assign to.

 

hal_gpio_status_t HAL_GpioInstallCallback(hal_gpio_handle_t gpioHandle,

hal_gpio_callback_t callback,

void *callbackParam)

{

hal_gpio_state_t *gpioState;

hal_gpio_state_t *next;

 

assert(gpioHandle);

 

gpioState = (hal_gpio_state_t *)gpioHandle;

 

// need to scan to last link list entry to assign to

next = gpioState->next;

while( next != 0)

{

gpioState = next;

next = gpioState->next;

}

gpioState->callbackParam = callbackParam;

gpioState->callback = callback;

 

return kStatus_HAL_GpioSuccess;

}

 

 

ラベル(1)
タグ(1)
0 件の賞賛
返信
3 返答(返信)

819件の閲覧回数
threeboystech
Contributor II

The code was provided as part of the most recent SDK update: SDK_2_16_100_FRDM-MCXN236.zip
and I running on MCUXpresso version:  MCUXpresso IDE v24.9 [Build 25] [2024-09-26]

 

0 件の賞賛
返信

813件の閲覧回数
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @threeboystech 

While the APIs you used not the same with SDK from NXP official. 

For gpio, API from NXP SDK like below:

Alice_Yang_0-1734514415156.png

 

Please download from the link I send to you last time. Thanks.

 

BR

Alice

 

0 件の賞賛
返信

831件の閲覧回数
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @threeboystech 

Could you please tell me which lib/driver do you used? 

I recommend you use SDK, download from: https://mcuxpresso.nxp.com/en/select  

It includes drivers and demos. Please refer to them. Thanks.

 

BR

Alice 

 

0 件の賞賛
返信