auto apply patches

This commit is contained in:
李昂 2023-07-15 14:55:29 +08:00
parent 0670172efd
commit 84ba0114f0
5 changed files with 29 additions and 15 deletions

View File

@ -1,5 +1,5 @@
#include <stdint.h>
#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;

View File

@ -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));

View File

@ -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) {

View File

@ -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;
}
}
}

View File

@ -25,6 +25,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <stdint.h>
#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