您好!
是否可以将任意参数传递给 GPIO ISR、而不是 GPIO 的默认索引?
我希望执行的操作与 SPI 传输完成回调中的操作基本相同、在该回调中、您可以通过 SPI_Transaction 结构传递任意参数
void *arg; /*!<要传递给回调函数的参数*/
除了调用引脚的索引之外、我没有找到任何与 GPIO ISR 类似的东西。 这是不可能的、并且您必须对要在 ISR 内部访问的任何变量进行硬编码、还是我错过了什么?
大家好
最大
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
您好!
是否可以将任意参数传递给 GPIO ISR、而不是 GPIO 的默认索引?
我希望执行的操作与 SPI 传输完成回调中的操作基本相同、在该回调中、您可以通过 SPI_Transaction 结构传递任意参数
void *arg; /*!<要传递给回调函数的参数*/
除了调用引脚的索引之外、我没有找到任何与 GPIO ISR 类似的东西。 这是不可能的、并且您必须对要在 ISR 内部访问的任何变量进行硬编码、还是我错过了什么?
大家好
最大
尊敬的 Max:
事实上、我最终找到了一种方法来做您描述的事情。
可以使用 GPIO_setUserArgg 和 GPIO_getUserArgg 方法。 下面是一个简短的示例:
volatile uint32_t GpioArgument1 = 0x12345678;
volatile uint32_t GpioArgument2 = 0x55555555;
/*
* ======== gpioButtonFxn0 ========
* Callback function for the GPIO interrupt on CONFIG_GPIO_BUTTON_0.
*
* Note: GPIO interrupts are cleared prior to invoking callbacks.
*/
void gpioButtonFxn0(uint_least8_t index)
{
volatile uint32_t number = (volatile uint32_t)GPIO_getUserArg(CONFIG_GPIO_BUTTON_0);
/* Toggle an LED */
GPIO_toggle(CONFIG_GPIO_LED_0);
}
/*
* ======== gpioButtonFxn1 ========
* Callback function for the GPIO interrupt on CONFIG_GPIO_BUTTON_1.
* This may not be used for all boards.
*
* Note: GPIO interrupts are cleared prior to invoking callbacks.
*/
void gpioButtonFxn1(uint_least8_t index)
{
volatile uint32_t number = (volatile uint32_t)GPIO_getUserArg(CONFIG_GPIO_BUTTON_1);
/* Toggle an LED */
GPIO_toggle(CONFIG_GPIO_LED_1);
}
//Somewhere in the code
GPIO_setUserArg(CONFIG_GPIO_BUTTON_0, (void *)GpioArgument1);
GPIO_setUserArg(CONFIG_GPIO_BUTTON_1, (void *)GpioArgument2);
但愿这有所帮助。
此致、
Arthur