From cea631ced02a3d23ace7f8f41554e053ae04dc18 Mon Sep 17 00:00:00 2001 From: keeramis Date: Thu, 4 Aug 2022 00:22:55 -0500 Subject: [PATCH] Address review comments --- dynalib/inc/dynalib.h | 2 +- hal/shared/demux.cpp | 6 +++--- hal/shared/demux.h | 3 ++- hal/src/trackerm/network/network.cpp | 11 +++-------- hal/src/tron/hal_platform_config.h | 1 + platform/MCU/rtl872x/inc/platform_config.h | 8 ++------ 6 files changed, 12 insertions(+), 19 deletions(-) diff --git a/dynalib/inc/dynalib.h b/dynalib/inc/dynalib.h index 357eb102be..7380c9d7ad 100644 --- a/dynalib/inc/dynalib.h +++ b/dynalib/inc/dynalib.h @@ -125,7 +125,7 @@ constexpr T2* dynalib_checked_cast(T2 *p) { #define __S(x) #x #define __SX(x) __S(x) - #if HAL_PLATFORM_DYNALIB_DYNAMIC_LOCATION + #if PLATFORM_ID == 32 || PLATFORM_ID == 28 #define DYNALIB_FN_IMPORT(index, tablename, name, counter) \ DYNALIB_STATIC_ASSERT(index == counter, "Index of the dynamically exported function has changed"); \ const char check_name_##tablename_##name[0]={}; /* this will fail if the name is already defined */ \ diff --git a/hal/shared/demux.cpp b/hal/shared/demux.cpp index 863cbb47e0..5fac3861a6 100644 --- a/hal/shared/demux.cpp +++ b/hal/shared/demux.cpp @@ -64,9 +64,9 @@ int Demux::write(uint8_t pin, uint8_t value) { #if HAL_PLATFORM_NRF52840 nrf_gpio_port_out_set(DEMUX_NRF_PORT, ((uint32_t)pin) << DEMUX_PINS_SHIFT); #elif HAL_PLATFORM_RTL872X - hal_gpio_write(DEMUX_C, pin >> 2); - hal_gpio_write(DEMUX_B, (pin >> 1) & 1); - hal_gpio_write(DEMUX_A, pin & 1); + hal_gpio_write(DEMUX_C, (pin & DEMUX_PIN_2_MASK) ? 1 : 0); + hal_gpio_write(DEMUX_B, (pin & DEMUX_PIN_1_MASK) ? 1 : 0); + hal_gpio_write(DEMUX_A, (pin & DEMUX_PIN_0_MASK) ? 1 : 0); #endif setPinValue(pin, 0); } diff --git a/hal/shared/demux.h b/hal/shared/demux.h index 8ca5687c53..5b180e93a9 100644 --- a/hal/shared/demux.h +++ b/hal/shared/demux.h @@ -33,11 +33,12 @@ #define DEMUX_MAX_PIN_COUNT 8 #if HAL_PLATFORM_NRF52840 #define DEMUX_NRF_PORT (NRF_P1) +#endif #define DEMUX_PIN_0_MASK 0x00000400 #define DEMUX_PIN_1_MASK 0x00000800 #define DEMUX_PIN_2_MASK 0x00001000 #define DEMUX_PINS_SHIFT (10) -#endif + namespace particle { diff --git a/hal/src/trackerm/network/network.cpp b/hal/src/trackerm/network/network.cpp index 372667e0c2..589475a683 100644 --- a/hal/src/trackerm/network/network.cpp +++ b/hal/src/trackerm/network/network.cpp @@ -191,12 +191,12 @@ int if_init_platform(void*) { ((PppNcpNetif*)pp3)->setCellularManager(cellularNetworkManager()); ((PppNcpNetif*)pp3)->init(); } - /* TODO: wl4 - ESP32 NCP Access Point */ - reserve_netif_index(); - reserve_netif_index(); (void)wl4; + reserve_netif_index(); // wl4 - NETWORK_INTERFACE_WIFI_STA = 5 + reserve_netif_index(); // wl5 - NETWORK_INTERFACE_WIFI_AP = 6 + auto m = mallinfo(); const size_t total = m.uordblks + m.fordblks; LOG(TRACE, "Heap: %lu/%lu Kbytes used", m.uordblks / 1000, total / 1000); @@ -211,8 +211,6 @@ struct netif* lwip_hook_ip4_route_src(const ip4_addr_t* src, const ip4_addr_t* d if (src == nullptr) { if (en2 && netifCanForwardIpv4(en2->interface())) { return en2->interface(); - } else if (wl3 && netifCanForwardIpv4(wl3->interface())) { - return wl3->interface(); } else if (pp3 && netifCanForwardIpv4(pp3->interface())) { return pp3->interface(); } @@ -236,9 +234,6 @@ unsigned char* rltk_wlan_get_gwmask(int idx) { void rltk_wlan_set_netif_info(int idx_wlan, void* dev, unsigned char* dev_addr) { LOG(INFO, "rltk_wlan_set_netif_info: %d, %02x:%02x:%02x:%02x:%02x:%02x", idx_wlan, dev_addr[0], dev_addr[1], dev_addr[2], dev_addr[3], dev_addr[4], dev_addr[5]); - if (wl3) { - memcpy(wl3->interface()->hwaddr, dev_addr, sizeof(wl3->interface()->hwaddr)); - } } void netif_rx(int idx, unsigned int len) { diff --git a/hal/src/tron/hal_platform_config.h b/hal/src/tron/hal_platform_config.h index 5c20d01a3b..3b42735c38 100644 --- a/hal/src/tron/hal_platform_config.h +++ b/hal/src/tron/hal_platform_config.h @@ -15,6 +15,7 @@ #define HAL_PLATFORM_USART_NUM (3) #define HAL_PLATFORM_NCP_COUNT (1) #define HAL_PLATFORM_BROKEN_MTU (1) +#define HAL_PLATFORM_WIFI (1) #define HAL_PLATFORM_WIFI_COMPAT (1) #define HAL_PLATFORM_RADIO_ANTENNA_INTERNAL (1) diff --git a/platform/MCU/rtl872x/inc/platform_config.h b/platform/MCU/rtl872x/inc/platform_config.h index 8ca53d4e1b..2e656c9fef 100644 --- a/platform/MCU/rtl872x/inc/platform_config.h +++ b/platform/MCU/rtl872x/inc/platform_config.h @@ -47,12 +47,8 @@ #define SYSTICK_IRQ_PRIORITY 7 //CORTEX_M33 Systick Interrupt -#if HAL_PLATFORM_RTL872X - #define INTERNAL_FLASH_SIZE (0x800000) -#else - #pragma message "PLATFORM_ID is " PREPSTRING(PLATFORM_ID) - #error "Unknown PLATFORM_ID" -#endif +// Currently works with platforms P2 and TrackerM +#define INTERNAL_FLASH_SIZE (0x800000) //Push Buttons, use interrupt HAL #define BUTTON1_PIN BTN