diff --git a/src/hal/w800/hal_adc_w800.c b/src/hal/w800/hal_adc_w800.c new file mode 100644 index 000000000..192a6cea1 --- /dev/null +++ b/src/hal/w800/hal_adc_w800.c @@ -0,0 +1,40 @@ +#include "../hal_adc.h" +#include "../../new_common.h" + + +static int adcToGpio[] = { + -1, // ADC0 - VBAT + 4, //GPIO4, // ADC1 + 5, //GPIO5, // ADC2 + 23,//GPIO23, // ADC3 + 2,//GPIO2, // ADC4 + 3,//GPIO3, // ADC5 + 12,//GPIO12, // ADC6 + 13,//GPIO13, // ADC7 +}; +static int c_adcToGpio = sizeof(adcToGpio)/sizeof(adcToGpio[0]); + +static uint16_t adcData[1]; + +static uint8_t gpioToAdc(int gpio) { + uint8_t i; + for ( i = 0; i < sizeof(adcToGpio); i++) { + if (adcToGpio[i] == gpio) + return i; + } + return -1; +} + +void HAL_ADC_Init(int pinNumber) { + +} + + + + +int HAL_ADC_Read(int pinNumber) +{ + + return -3; +} + diff --git a/src/hal/w800/hal_flashConfig_w800.c b/src/hal/w800/hal_flashConfig_w800.c new file mode 100644 index 000000000..a3a8be5b7 --- /dev/null +++ b/src/hal/w800/hal_flashConfig_w800.c @@ -0,0 +1,33 @@ +#include "../hal_flashConfig.h" + + +#include "../../logging/logging.h" + +static SemaphoreHandle_t config_mutex = 0; + + +int HAL_Configuration_ReadConfigMemory(void *target, int dataLen){ + + return dataLen; +} + + + + +int bekken_hal_flash_read(const unsigned int addr, void *dst, const unsigned int size) +{ + + + return 0; +} + + + + +int HAL_Configuration_SaveConfigMemory(void *src, int dataLen){ + + return dataLen; +} + + + diff --git a/src/hal/w800/hal_flashVars_w800.c b/src/hal/w800/hal_flashVars_w800.c new file mode 100644 index 000000000..d7febb2f8 --- /dev/null +++ b/src/hal/w800/hal_flashVars_w800.c @@ -0,0 +1,27 @@ + + +// call at startup +void HAL_FlashVars_IncreaseBootCount(){ +} +void HAL_FlashVars_SaveChannel(int index, int value) { +} + +// call once started (>30s?) +void HAL_FlashVars_SaveBootComplete(){ +} + +// call to return the number of boots since a HAL_FlashVars_SaveBootComplete +int HAL_FlashVars_GetBootFailures(){ + int diff = 0; + + return diff; +} + +int HAL_FlashVars_GetBootCount(){ + return 0; +} +int HAL_FlashVars_GetChannelValue(int ch){ + + return 0; +} + diff --git a/src/hal/w800/hal_generic_w800.c b/src/hal/w800/hal_generic_w800.c new file mode 100644 index 000000000..8663dbe42 --- /dev/null +++ b/src/hal/w800/hal_generic_w800.c @@ -0,0 +1,6 @@ + + + +void HAL_RebootModule() { + +} diff --git a/src/hal/w800/hal_main_w800.c b/src/hal/w800/hal_main_w800.c new file mode 100644 index 000000000..08e2baa5e --- /dev/null +++ b/src/hal/w800/hal_main_w800.c @@ -0,0 +1,30 @@ + +#include "../../new_common.h" +#include "../../logging/logging.h" + +#include +#include "wm_include.h" + +#define LOG_FEATURE LOG_FEATURE_MAIN + + +#define DEMO_TASK_PRIO 32 + +#define DEMO_TASK_SIZE 2048 +static OS_STK DemoTaskStk[DEMO_TASK_SIZE]; +#define DEMO_CONSOLE_BUF_SIZE 512 + +void user_main(void) +{ + Main_Init(); + + tls_os_task_create(NULL, NULL, + Main_OnEverySecond, + NULL, + (void *)DemoTaskStk, /* task's stack start address */ + DEMO_TASK_SIZE * sizeof(u32), /* task's stack size, unit:byte */ + DEMO_TASK_PRIO, + 0); +} + + diff --git a/src/hal/w800/hal_pins_w800.c b/src/hal/w800/hal_pins_w800.c new file mode 100644 index 000000000..0a05e84e7 --- /dev/null +++ b/src/hal/w800/hal_pins_w800.c @@ -0,0 +1,56 @@ + +#include "../../new_common.h" +#include "../../logging/logging.h" + + +static int PIN_GetPWMIndexForPinIndex(int pin) { + if(pin == 6) + return 0; + if(pin == 7) + return 1; + if(pin == 8) + return 2; + if(pin == 9) + return 3; + if(pin == 24) + return 4; + if(pin == 26) + return 5; + return -1; +} + +const char *HAL_PIN_GetPinNameAlias(int index) { + return 0; +} + +int HAL_PIN_CanThisPinBePWM(int index) { + + return 1; +} +void HAL_PIN_SetOutputValue(int index, int iVal) { + +} + +int HAL_PIN_ReadDigitalInput(int index) { + return 0; +} +void HAL_PIN_Setup_Input_Pullup(int index) { + +} +void HAL_PIN_Setup_Input(int index) { + +} +void HAL_PIN_Setup_Output(int index) { + +} +void HAL_PIN_PWM_Stop(int index) { + +} + +void HAL_PIN_PWM_Start(int index) { + +} +void HAL_PIN_PWM_Update(int index, int value) { + +} + diff --git a/src/hal/w800/hal_wifi_w800.c b/src/hal/w800/hal_wifi_w800.c new file mode 100644 index 000000000..a2c1b6b7d --- /dev/null +++ b/src/hal/w800/hal_wifi_w800.c @@ -0,0 +1,70 @@ +#include "../hal_wifi.h" + +#define LOG_FEATURE LOG_FEATURE_MAIN + +#include "../../new_common.h" +#include "../../logging/logging.h" +#include "lwip/netdb.h" + +static void (*g_wifiStatusCallback)(int code); + + +#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] +#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x " + +static char g_IP[3+3+3+3+1+1+1] = "unknown"; +static int g_bOpenAccessPointMode = 0; + +// This must return correct IP for both SOFT_AP and STATION modes, +// because, for example, javascript control panel requires it +const char *HAL_GetMyIPString(){ + + return g_IP; +} + +//////////////////// +// NOTE: this gets the STA mac +void getMAC(unsigned char *mac){ + net_get_if_macaddr(mac, net_get_sta_handle()); +} +int WiFI_SetMacAddress(char *mac) { + + return 0; +} + +void WiFI_GetMacAddress(char *mac) { + +} +const char *HAL_GetMACStr(char *macstr){ + unsigned char mac[6] = { 0, 1, 2, 3, 4, 5 }; + + sprintf(macstr, MACSTR, MAC2STR(mac)); + return macstr; +} + +void HAL_PrintNetworkInfo(){ + +} + + +void HAL_WiFi_SetupStatusCallback(void (*cb)(int code)) { + g_wifiStatusCallback = cb; + +} +void HAL_ConnectToWiFi(const char *oob_ssid,const char *connect_key) +{ + g_bOpenAccessPointMode = 0; + +} + + +int HAL_SetupWiFiOpenAccessPoint(const char *ssid) +{ + + + //dhcp_server_start(0); + //dhcp_server_stop(void); + + return 0; +} + diff --git a/src/httpserver/http_fns.c b/src/httpserver/http_fns.c index 0e39a926e..b751fb5b3 100644 --- a/src/httpserver/http_fns.c +++ b/src/httpserver/http_fns.c @@ -18,6 +18,8 @@ // nothing #elif PLATFORM_BL602 +#elif PLATFORM_W800 + #elif PLATFORM_XR809 #include #elif defined(PLATFORM_BK7231N) @@ -603,6 +605,8 @@ int http_fn_cfg_wifi(http_request_t *request) { #elif PLATFORM_XR809 poststr(request,"TODO XR809
"); +#elif PLATFORM_W800 + poststr(request,"TODO W800
"); #elif PLATFORM_BL602 poststr(request,"TODO BL602
"); #elif PLATFORM_BK7231T @@ -875,6 +879,8 @@ int http_fn_flash_read_tool(http_request_t *request) { res = flash_read(FLASH_INDEX_XR809, nowOfs, buffer, now); #elif PLATFORM_BL602 +#elif PLATFORM_W800 + #else res = bekken_hal_flash_read (nowOfs, buffer,now); #endif @@ -1628,6 +1634,8 @@ int http_fn_ota_exec(http_request_t *request) { #elif PLATFORM_BL602 +#elif PLATFORM_W800 + #elif PLATFORM_XR809 XR809_RequestOTAHTTP(tmpA); #else diff --git a/src/httpserver/rest_interface.c b/src/httpserver/rest_interface.c index d38adf2dd..46bca90e2 100644 --- a/src/httpserver/rest_interface.c +++ b/src/httpserver/rest_interface.c @@ -26,6 +26,7 @@ uint32_t flash_read(uint32_t flash, uint32_t addr,void *buf, uint32_t size); #define FLASH_INDEX_XR809 0 #elif PLATFORM_BL602 +#elif PLATFORM_W800 #else extern UINT32 flash_read(char *user_buf, UINT32 count, UINT32 address); #endif @@ -97,6 +98,11 @@ const char *obktype = "BL602"; const char * apppage2 = "';" " var obktype = 'BL602';" " var device = 'http://"; +#elif PLATFORM_W800 +const char *obktype = "W800"; +const char * apppage2 = "';" +" var obktype = 'W800';" +" var device = 'http://"; #else const char *obktype = "beken"; const char * apppage2 = "';" @@ -795,6 +801,8 @@ static int http_rest_post_flash(http_request_t *request, int startaddr){ #elif PLATFORM_BL602 +#elif PLATFORM_W800 + #else int total = 0; int towrite; @@ -894,6 +902,8 @@ static int http_rest_get_flash(http_request_t *request, int startaddr, int len){ res = flash_read(FLASH_INDEX_XR809, startaddr, buffer, readlen); #elif PLATFORM_BL602 res = 0; +#elif PLATFORM_W800 + res = 0; #else res = flash_read((char *)buffer, readlen, startaddr); #endif diff --git a/src/new_common.h b/src/new_common.h index d7c78ac8f..1dc15b751 100644 --- a/src/new_common.h +++ b/src/new_common.h @@ -31,6 +31,10 @@ #define DEVICENAME_PREFIX_FULL "OpenBL602" #define DEVICENAME_PREFIX_SHORT "obl" #define PLATFORM_MCU_NAME "BL602" +#elif PLATFORM_W800 +#define DEVICENAME_PREFIX_FULL "OpenW800" +#define DEVICENAME_PREFIX_SHORT "w800" +#define PLATFORM_MCU_NAME "W800" #else #error "You must define a platform.." This platform is not supported, error! @@ -141,6 +145,46 @@ OSStatus rtos_create_thread( beken_thread_t* thread, #include "kernel/os/os.h" +#elif PLATFORM_W800 + +#include +#include "wm_include.h" +#include +#include +#include +#include + +#define bk_printf printf +#define os_strcpy strcpy +#define os_malloc malloc +#define os_free free +#define os_memset memset + + +#define rtos_delay_milliseconds sys_msleep +#define delay_ms sys_msleep + +#define SemaphoreHandle_t xSemaphoreHandle + +#define os_strcpy strcpy + +#define kNoErr 0 //! No error occurred. +typedef void *beken_thread_arg_t; +typedef void *beken_thread_t; +typedef void (*beken_thread_function_t)( beken_thread_arg_t arg ); +typedef int OSStatus; + +#define BEKEN_DEFAULT_WORKER_PRIORITY (6) +#define BEKEN_APPLICATION_PRIORITY (7) + +// wrappers for XR809 threads to work like bekken +OSStatus rtos_delete_thread( beken_thread_t* thread ); +OSStatus rtos_create_thread( beken_thread_t* thread, + uint8_t priority, const char* name, + beken_thread_function_t function, + uint32_t stack_size, beken_thread_arg_t arg ); + + #else #include "gw_intf.h" diff --git a/src/new_pins.c b/src/new_pins.c index 2bc1ac516..71ae8ada5 100644 --- a/src/new_pins.c +++ b/src/new_pins.c @@ -997,6 +997,14 @@ void button_timer_thread(void *param) PIN_ticks(0); } } +#elif PLATFORM_W800 +void button_timer_thread(void *param) +{ + while(1) { + vTaskDelay(PIN_TMR_DURATION); + PIN_ticks(0); + } +} #elif PLATFORM_XR809 OS_Timer_t timer; #else @@ -1008,6 +1016,9 @@ void PIN_StartButtonScanThread(void) #elif PLATFORM_BL602 + xTaskCreate(button_timer_thread, "buttons", 1024, NULL, 15, NULL); +#elif PLATFORM_W800 + xTaskCreate(button_timer_thread, "buttons", 1024, NULL, 15, NULL); #elif PLATFORM_XR809 @@ -1042,4 +1053,4 @@ void PIN_AddCommands(void) CMD_RegisterCommand("setChannelType", NULL, CMD_SetChannelType, "qqqqqqqq", NULL); CMD_RegisterCommand("showChannelValues", NULL,CMD_ShowChannelValues, "log channel values", NULL); -} \ No newline at end of file +} diff --git a/src/obk_config.h b/src/obk_config.h index 1a019f790..eb0e23330 100644 --- a/src/obk_config.h +++ b/src/obk_config.h @@ -7,6 +7,9 @@ #if PLATFORM_XR809 +#elif PLATFORM_W800 + +#define OBK_DISABLE_ALL_DRIVERS 1 #elif WINDOWS #elif PLATFORM_BL602 @@ -25,4 +28,4 @@ #endif -#endif \ No newline at end of file +#endif diff --git a/src/user_main.c b/src/user_main.c index 9d87ab011..0acf8daa9 100644 --- a/src/user_main.c +++ b/src/user_main.c @@ -64,7 +64,8 @@ size_t xPortGetFreeHeapSize() { return 0; } #endif -#if PLATFORM_BL602 + +#if defined(PLATFORM_BL602) || defined(PLATFORM_W800)