Skip to content

Commit

Permalink
fix: gpio irq没有双向触发.
Browse files Browse the repository at this point in the history
  • Loading branch information
wendal committed Jan 31, 2020
1 parent d59129f commit 504d77d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
13 changes: 3 additions & 10 deletions luat/modules/luat_lib_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,16 @@
#include "luat_malloc.h"

static int l_gpio_handler(lua_State *L, void* ptr) {
// 给 sys.publish方法发送数据
luat_gpio_t *gpio = (luat_gpio_t *)ptr;
lua_getglobal(L, "sys_pub");
if (!lua_isnil(L, -1)) {
lua_pushfstring(L, "IRQ_%d", (char)gpio->pin);
lua_pushinteger(L, luat_gpio_get(gpio->pin));
lua_call(L, 2, 0);
lua_pushinteger(L, 0);
return 1;
}
//else {
// luat_print("_G.sys_pub is nil\n");
// lua_pop(L, 1);
//}
lua_pushinteger(L, MSG_GPIO);
// lua_pushinteger(L, gpio->pin);
// lua_pushinteger(L, luat_gpio_get(gpio->pin));
// return 3;
// 给rtos.recv方法返回个空数据
lua_pushinteger(L, 0);
return 1;
}

Expand Down
4 changes: 2 additions & 2 deletions luat/rtt/luat_gpio_rtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ int luat_gpio_setup(luat_gpio_t* gpio) {
rt_pin_mode(gpio->pin, mode);
if (gpio->mode == Luat_GPIO_IRQ) {
int irq = 0;
if (irq == Luat_GPIO_RISING) {
if (gpio->irq == Luat_GPIO_RISING) {
irq = PIN_IRQ_MODE_RISING;
}
else if (irq == Luat_GPIO_FALLING) {
else if (gpio->irq == Luat_GPIO_FALLING) {
irq = PIN_IRQ_MODE_FALLING;
}
else {
Expand Down

0 comments on commit 504d77d

Please sign in to comment.