diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml index 4db52bb8a..82e4b1f30 100644 --- a/.github/workflows/workflow.yaml +++ b/.github/workflows/workflow.yaml @@ -217,6 +217,8 @@ jobs: - platform: OpenBL602 variant: berry + #- platform: OpenBL602 + # variant: irRemoteESP steps: - name: Source checkout uses: actions/checkout@v4 diff --git a/platforms/BL602/bouffalo.mk b/platforms/BL602/bouffalo.mk index 3340666e6..4d9a7acdf 100644 --- a/platforms/BL602/bouffalo.mk +++ b/platforms/BL602/bouffalo.mk @@ -6,7 +6,8 @@ COMPONENT_ADD_INCLUDEDIRS += src/ src/httpserver/ src/httpclient/ src/cmnds/ src ## not be exported to project level COMPONENT_PRIV_INCLUDEDIRS := -CFLAGS += -DOBK_VARIANT=${OBK_VARIANT} +CPPFLAGS += -DOBK_VARIANT=${OBK_VARIANT} -Wno-undef +CXXFLAGS += -Wno-delete-non-virtual-dtor -Wno-error=format ## This component's src COMPONENT_SRCS := @@ -14,6 +15,6 @@ COMPONENT_SRCS := COMPONENT_OBJS := $(patsubst %.c,%.o, $(COMPONENT_SRCS)) COMPONENT_OBJS := $(patsubst %.S,%.o, $(COMPONENT_OBJS)) -COMPONENT_SRCDIRS := src/ src/jsmn src/httpserver src/httpclient src/cmnds src/logging src/hal/bl602 src/mqtt src/i2c src/cJSON src/base64 src/driver src/devicegroups src/bitmessage src/littlefs src/hal/generic libraries/berry/src src/berry src/berry/modules +COMPONENT_SRCDIRS := src/ src/jsmn src/httpserver src/httpclient src/cmnds src/logging src/hal/bl602 src/mqtt src/i2c src/cJSON src/base64 src/driver src/devicegroups src/bitmessage src/littlefs src/hal/generic libraries/berry/src src/berry src/berry/modules src/libraries/IRremoteESP8266/src COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive diff --git a/sdk/OpenBL602 b/sdk/OpenBL602 index 004656661..6f91cd2a9 160000 --- a/sdk/OpenBL602 +++ b/sdk/OpenBL602 @@ -1 +1 @@ -Subproject commit 0046566610e7197f508dea60bc8b3bd1b75bc692 +Subproject commit 6f91cd2a9f18da9e3f9d68d2e9d3a08cb6260a72 diff --git a/src/driver/drv_ir_new.cpp b/src/driver/drv_ir_new.cpp index 9f9b817e3..d8edde3aa 100644 --- a/src/driver/drv_ir_new.cpp +++ b/src/driver/drv_ir_new.cpp @@ -36,6 +36,10 @@ extern "C" { #include "../hal/realtek/hal_pinmap_realtek.h" void pwmout_start(pwmout_t* obj); void pwmout_stop(pwmout_t* obj); +#elif PLATFORM_BL602 +#include "bl602_timer.h" +#include "hosal_timer.h" +#define UINT32 uint32_t #endif // why can;t I call this? @@ -133,20 +137,27 @@ Print Serial; extern "C" void #if PLATFORM_BEKEN DRV_IR_ISR(UINT8 t) -#else +#elif PLATFORM_REALTEK DRV_IR_ISR() +#else +DRV_IR_ISR(void* arg) #endif ; extern void IR_ISR(); #if PLATFORM_BEKEN static UINT32 ir_chan = BKTIMER0; +static UINT32 ir_div = 1; +static UINT32 ir_periodus = 50; #elif PLATFORM_REALTEK static gtimer_t ir_timer; static UINT32 ir_chan = TIMER2; -#endif -static UINT32 ir_div = 1; static UINT32 ir_periodus = 50; +#elif PLATFORM_BL602 +static hosal_timer_dev_t ir_timer; +static UINT32 ir_chan = TIMER_CH0; +static UINT32 ir_periodus = 50; +#endif void timerConfigForReceive() { // nothing here` @@ -193,6 +204,13 @@ void _timerConfigForReceive() { ADDLOG_INFO(LOG_FEATURE_IR, (char *)"ir timer enabled %u", res); #elif PLATFORM_REALTEK gtimer_init(&ir_timer, ir_chan); +#elif PLATFORM_BL602 + ir_timer.port = ir_chan; + ir_timer.config.period = ir_periodus; + ir_timer.config.reload_mode = TIMER_RELOAD_PERIODIC; + ir_timer.config.cb = DRV_IR_ISR; + ir_timer.config.arg = NULL; + hosal_timer_init(&ir_timer); #endif } @@ -206,6 +224,8 @@ static void _timer_enable() { res = sddev_control((char *)TIMER_DEV_NAME, CMD_TIMER_UNIT_ENABLE, &ir_chan); #elif PLATFORM_REALTEK gtimer_start_periodical(&ir_timer, ir_periodus, (void*)&DRV_IR_ISR, (uint32_t)&ir_timer); +#elif PLATFORM_BL602 + hosal_timer_start(&ir_timer); #endif ADDLOG_INFO(LOG_FEATURE_IR, (char *)"ir timer enabled %u", res); } @@ -215,6 +235,9 @@ static void _timer_disable() { res = sddev_control((char *)TIMER_DEV_NAME, CMD_TIMER_UNIT_DISABLE, &ir_chan); #elif PLATFORM_REALTEK gtimer_stop(&ir_timer); +#elif PLATFORM_BL602 + hosal_timer_stop(&ir_timer); + hosal_timer_finalize(&ir_timer); #endif ADDLOG_INFO(LOG_FEATURE_IR, (char *)"ir timer disabled %u", res); } @@ -369,8 +392,10 @@ IRrecv *ourReceiver = NULL; extern "C" void #if PLATFORM_BEKEN DRV_IR_ISR(UINT8 t) -#else +#elif PLATFORM_REALTEK DRV_IR_ISR() +#else +DRV_IR_ISR(void* arg) #endif { int sending = 0; @@ -741,9 +766,15 @@ extern "C" void DRV_IR_Init() { int pin = -1; //9;// PWM3/25 int txpin = -1; //24;// PWM3/25 + bool pup = true; // allow user to change them pin = PIN_FindPinIndexForRole(IOR_IRRecv, pin); + if(pin == -1) + { + pin = PIN_FindPinIndexForRole(IOR_IRRecv_nPup, pin); + if(pin >= 0) pup = false; + } txpin = PIN_FindPinIndexForRole(IOR_IRSend, txpin); if (ourReceiver){ @@ -752,19 +783,19 @@ extern "C" void DRV_IR_Init() { delete temp; } ADDLOG_INFO(LOG_FEATURE_IR, (char *)"DRV_IR_Init: recv pin %i", pin); - if ((pin > 0) || (txpin > 0)) { + if ((pin >= 0) || (txpin >= 0)) { } else { _timer_disable(); } - if (pin > 0) { + if (pin >= 0) { // setup IRrecv pin as input //bk_gpio_config_input_pup((GPIO_INDEX)pin); // enabled by enableIRIn //TODO: we should specify buffer size (now set to 1024), timeout (now 90ms) and tolerance ourReceiver = new IRrecv(pin); - ourReceiver->enableIRIn(true);// try with pullup + ourReceiver->enableIRIn(pup); } if (pIRsend) { diff --git a/src/hal/bl602/hal_pins_bl602.c b/src/hal/bl602/hal_pins_bl602.c index b82e0cadf..d468f6d80 100644 --- a/src/hal/bl602/hal_pins_bl602.c +++ b/src/hal/bl602/hal_pins_bl602.c @@ -31,6 +31,7 @@ int HAL_PIN_ReadDigitalInput(int index) { return iVal; } void HAL_PIN_Setup_Input_Pulldown(int index) { + bl_gpio_enable_input(index, 0, 1); } void HAL_PIN_Setup_Input_Pullup(int index) { // int bl_gpio_enable_input(uint8_t pin, uint8_t pullup, uint8_t pulldown); @@ -67,7 +68,8 @@ void HAL_PIN_PWM_Start(int index, int freq) { //addLogAdv(LOG_INFO, LOG_FEATURE_MAIN,"HAL_PIN_PWM_Start: pin %i chose pwm %i\r\n",index,pwm); // Frequency must be between 2000 and 800000 - bl_pwm_init(pwm, index, 2000); + if(freq < 2000) freq = 2000; + bl_pwm_init(pwm, index, freq); bl_pwm_start(pwm); } diff --git a/src/httpserver/new_http.c b/src/httpserver/new_http.c index 8a7697238..a5f5a3610 100644 --- a/src/httpserver/new_http.c +++ b/src/httpserver/new_http.c @@ -554,6 +554,7 @@ const char* htmlPinRoleNames[] = { "PWM_ScriptOnly_n", "Counter_f", "Counter_r", + "IRRecv_nPup", "error", "error", "error", diff --git a/src/libraries/IRremoteESP8266/src/IRtimer.cpp b/src/libraries/IRremoteESP8266/src/IRtimer.cpp index 45ce14083..9794f9eeb 100644 --- a/src/libraries/IRremoteESP8266/src/IRtimer.cpp +++ b/src/libraries/IRremoteESP8266/src/IRtimer.cpp @@ -6,7 +6,7 @@ #endif -#if PLATFORM_BEKEN || PLATFORM_REALTEK +#if PLATFORM_BEKEN || PLATFORM_REALTEK || PLATFORM_BL602 //TODO extern unsigned long micros(void); extern unsigned long millis(void); diff --git a/src/libraries/IRremoteESP8266/src/digitalWriteFast.cpp b/src/libraries/IRremoteESP8266/src/digitalWriteFast.cpp index 233d7cd04..ac719f6a4 100644 --- a/src/libraries/IRremoteESP8266/src/digitalWriteFast.cpp +++ b/src/libraries/IRremoteESP8266/src/digitalWriteFast.cpp @@ -9,6 +9,9 @@ extern "C" { #else #include "../../../hal/hal_pins.h" #endif +#if PLATFORM_BL602 +#include "bl602_glb.h" +#endif } #include "digitalWriteFast.h" @@ -25,6 +28,8 @@ void digitalToggleFast(unsigned char P) { unsigned char digitalReadFast(unsigned char P) { #if PLATFORM_BEKEN return bk_gpio_input((GPIO_INDEX)P); +#elif PLATFORM_BL602 + return GLB_GPIO_Read((GLB_GPIO_Type)P); #else return HAL_PIN_ReadDigitalInput(P); #endif @@ -35,6 +40,8 @@ void digitalWriteFast(unsigned char P, unsigned char V) { //HAL_PIN_SetOutputValue(index, iVal); #if PLATFORM_BEKEN bk_gpio_output((GPIO_INDEX)P, V); +#elif PLATFORM_BL602 + GLB_GPIO_Write((GLB_GPIO_Type)P, V ? 1 : 0); #else HAL_PIN_SetOutputValue(P, V); #endif diff --git a/src/new_pins.h b/src/new_pins.h index ad8a154f1..e6f97a521 100644 --- a/src/new_pins.h +++ b/src/new_pins.h @@ -588,6 +588,13 @@ typedef enum ioRole_e { //iodetail:"file":"new_pins.h", //iodetail:"driver":""} IOR_Counter_r, + //iodetail:{"name":"IRRecv_nPup", + //iodetail:"title":"TODO", + //iodetail:"descr":"IRRecv without pull-up", + //iodetail:"enum":"IRRecv_nPup", + //iodetail:"file":"new_pins.h", + //iodetail:"driver":""} + IOR_IRRecv_nPup, //iodetail:{"name":"Total_Options", //iodetail:"title":"TODO", //iodetail:"descr":"Current total number of available IOR roles", diff --git a/src/obk_config.h b/src/obk_config.h index 912be1201..5e0bfbc2f 100644 --- a/src/obk_config.h +++ b/src/obk_config.h @@ -216,6 +216,15 @@ #define ENABLE_OBK_BERRY 1 #endif +//#if (OBK_VARIANT == OBK_VARIANT_IRREMOTEESP) +//#undef ENABLE_DRIVER_CHT83XX +//#undef ENABLE_DRIVER_DS1820 +//#undef ENABLE_DRIVER_CSE7766 +//#undef ENABLE_DRIVER_BL0937 +//#undef ENABLE_DRIVER_BL0942 +#define ENABLE_DRIVER_IRREMOTEESP 1 +//#endif + #elif PLATFORM_BEKEN //#define ENABLE_LFS_SPI 1 diff --git a/src/user_main.c b/src/user_main.c index 239104ff2..0c277015b 100644 --- a/src/user_main.c +++ b/src/user_main.c @@ -1114,7 +1114,8 @@ void Main_Init_AfterDelay_Unsafe(bool bStartAutoRunScripts) { CMD_Init_Delayed(); if (bStartAutoRunScripts) { - if (PIN_FindPinIndexForRole(IOR_IRRecv, -1) != -1 || PIN_FindPinIndexForRole(IOR_IRSend, -1) != -1) { + if (PIN_FindPinIndexForRole(IOR_IRRecv, -1) != -1 || PIN_FindPinIndexForRole(IOR_IRSend, -1) != -1 + || PIN_FindPinIndexForRole(IOR_IRRecv_nPup, -1) != -1) { // start IR driver 5 seconds after boot. It may affect wifi connect? // yet we also want it to start if no wifi for IR control... #ifndef OBK_DISABLE_ALL_DRIVERS