From 84ba0114f078fe1295657f54a1db377c5bccd0e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=98=82?= Date: Sat, 15 Jul 2023 14:55:29 +0800 Subject: [PATCH] auto apply patches --- package/ESP32/pika_hal_ESP32_GPIO.c | 12 ++++++++++-- .../PikaStdDevice/pika_hal_SOFT_SPI.c | 2 +- .../pikascript/pikascript-lib/time/_time.c | 13 +------------ src/PikaObj.c | 15 +++++++++++++++ src/PikaObj.h | 2 ++ 5 files changed, 29 insertions(+), 15 deletions(-) diff --git a/package/ESP32/pika_hal_ESP32_GPIO.c b/package/ESP32/pika_hal_ESP32_GPIO.c index 20153dc5a..f95190767 100644 --- a/package/ESP32/pika_hal_ESP32_GPIO.c +++ b/package/ESP32/pika_hal_ESP32_GPIO.c @@ -1,5 +1,5 @@ #include -#include "BaseObj.h" +#include "PikaObj.h" #include "dataStrs.h" #include "driver/gpio.h" #include "pika_hal_ESP32_common.h" @@ -12,6 +12,7 @@ int pika_hal_platform_GPIO_open(pika_dev* dev, char* name) { } memset(gpio, 0, sizeof(platform_data_GPIO)); gpio->gpioPort = getGpioPin(name); + pika_debug("gpio open port: %s -> %d", name, gpio->gpioPort); if (-1 == gpio->gpioPort) { pikaFree(gpio, sizeof(platform_data_GPIO)); return -1; @@ -45,6 +46,7 @@ int pika_hal_platform_GPIO_write(pika_dev* dev, void* buf, size_t count) { return -1; } gpio_set_level(gpio->gpioPort, *((uint32_t*)buf)); + // pika_debug("gpio write %d -> %d", gpio->gpioPort, *((uint32_t*)buf)); return 0; } @@ -53,6 +55,12 @@ int pika_hal_platform_GPIO_ioctl_enable(pika_dev* dev) { if (NULL == gpio) { return -1; } + pika_debug("gpio enable: %d", gpio->gpioPort); + pika_debug(" - mode: %d", gpio->io_conf.mode); + pika_debug(" - pull_up_en: %d", gpio->io_conf.pull_up_en); + pika_debug(" - pull_down_en: %d", gpio->io_conf.pull_down_en); + pika_debug(" - intr_type: %d", gpio->io_conf.intr_type); + pika_debug(" - pin_bit_mask: %lld", gpio->io_conf.pin_bit_mask); gpio_config(&gpio->io_conf); return 0; } @@ -85,7 +93,7 @@ int pika_hal_platform_GPIO_ioctl_config(pika_dev* dev, default: return -1; } - gpio->io_conf.pin_bit_mask = 1 << gpio->gpioPort; + gpio->io_conf.pin_bit_mask = 1ULL << gpio->gpioPort; switch (cfg->pull) { case PIKA_HAL_GPIO_PULL_UP: gpio->io_conf.pull_up_en = 1; diff --git a/port/linux/package/pikascript/pikascript-lib/PikaStdDevice/pika_hal_SOFT_SPI.c b/port/linux/package/pikascript/pikascript-lib/PikaStdDevice/pika_hal_SOFT_SPI.c index d34d2bfb3..f41c0a008 100644 --- a/port/linux/package/pikascript/pikascript-lib/PikaStdDevice/pika_hal_SOFT_SPI.c +++ b/port/linux/package/pikascript/pikascript-lib/PikaStdDevice/pika_hal_SOFT_SPI.c @@ -1,4 +1,4 @@ -#include "../PikaStdDevice/pika_hal.h" +#include "pika_hal.h" static int _GPIO_write(pika_dev* dev, uint32_t val) { return pika_hal_write(dev, &val, sizeof(val)); diff --git a/port/linux/package/pikascript/pikascript-lib/time/_time.c b/port/linux/package/pikascript/pikascript-lib/time/_time.c index 37e6bd34c..dd84141bf 100644 --- a/port/linux/package/pikascript/pikascript-lib/time/_time.c +++ b/port/linux/package/pikascript/pikascript-lib/time/_time.c @@ -12,18 +12,7 @@ extern volatile VMSignal g_PikaVMSignal; volatile int g_pika_local_timezone = 8; static void _do_sleep_ms_tick(uint32_t ms) { - int64_t tick = pika_platform_get_tick(); - while (1) { - pika_platform_thread_yield(); -#if PIKA_EVENT_ENABLE - if (!pika_GIL_isInit()) { - _VMEvent_pickupEvent(); - } -#endif - if (pika_platform_get_tick() - tick >= ms) { - break; - } - } + pika_sleep_ms(ms); } void _time_sleep_ms(PikaObj* self, int ms) { diff --git a/src/PikaObj.c b/src/PikaObj.c index e4958f841..64a0d2be9 100644 --- a/src/PikaObj.c +++ b/src/PikaObj.c @@ -4001,3 +4001,18 @@ int32_t objList_forEach(PikaObj* self, } return 0; } + +void pika_sleep_ms(uint32_t ms) { + int64_t tick = pika_platform_get_tick(); + while (1) { + pika_platform_thread_yield(); +#if PIKA_EVENT_ENABLE + if (!pika_GIL_isInit()) { + _VMEvent_pickupEvent(); + } +#endif + if (pika_platform_get_tick() - tick >= ms) { + break; + } + } +} diff --git a/src/PikaObj.h b/src/PikaObj.h index f1c36fad0..2e5a7109a 100644 --- a/src/PikaObj.h +++ b/src/PikaObj.h @@ -25,6 +25,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +#include #ifdef __cplusplus extern "C" { #endif @@ -775,6 +776,7 @@ int32_t objDict_forEach(PikaObj* self, Arg* valEach, void* context), void* context); +void pika_sleep_ms(uint32_t ms); #endif #ifdef __cplusplus