From 618b88829bad5ffe780e8d681bcd8c60bd3f6f32 Mon Sep 17 00:00:00 2001 From: David Crocker Date: Mon, 19 Sep 2022 18:13:09 +0100 Subject: Corrections to WiFi interface --- src/Config/Pins_Duet3_MB6HC.h | 14 +++++++------- src/Networking/ESP8266WiFi/WiFiInterface.cpp | 20 +++----------------- src/Platform/Platform.cpp | 6 +++++- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/Config/Pins_Duet3_MB6HC.h b/src/Config/Pins_Duet3_MB6HC.h index a8d8ae47..9d41ac77 100644 --- a/src/Config/Pins_Duet3_MB6HC.h +++ b/src/Config/Pins_Duet3_MB6HC.h @@ -14,7 +14,7 @@ #define IAP_CAN_LOADER_FILE "Duet3_CANiap32_" BOARD_SHORT_NAME ".bin" constexpr uint32_t IAP_IMAGE_START = 0x20458000; // last 32kb of RAM -#define WIFI_FIRMWARE_FILE "DuetWiFiServer_32S3.bin" +#define WIFI_FIRMWARE_FILE "DuetWiFiModule_32S3.bin" // Features definition // Networking support @@ -388,6 +388,9 @@ constexpr Pin APIN_SBC_SPI_SCK = PortCPin(24); constexpr Pin APIN_SBC_SPI_SS0 = PortCPin(25); constexpr GpioPinFunction SBCPinPeriphMode = GpioPinFunction::C; +constexpr Pin SbcTfrReadyPin = PortEPin(2); +// Note, the DMAC peripheral IDs are hard-coded in DataTransfer + // WiFi pins, mostly shared with the SBC interface #define ESP_SPI SPI1 #define ESP_SPI_INTERFACE_ID ID_SPI1 @@ -404,11 +407,11 @@ constexpr Pin APIN_SerialWiFi_TXD = PortDPin(19); constexpr Pin APIN_SerialWiFi_RXD = PortDPin(18); constexpr GpioPinFunction SerialWiFiPeriphMode = GpioPinFunction::C; -constexpr Pin EspResetPin = PortCPin(14); // Low on this in holds the WiFi module in reset (ESP_RESET) -constexpr Pin EspEnablePin = NoPin; // High to enable the WiFi module, low to power it down (ESP_CH_PD) +constexpr Pin EspResetPin = PortCPin(14); // Low on this in holds the WiFi module in reset (ESP_EN) constexpr Pin EspDataReadyPin = PortAPin(2); // Input from the WiFi module indicating that it wants to transfer data (ESP GPIO0) -constexpr Pin SamTfrReadyPin = PortEPin(2); // Output from the SAM to the WiFi module indicating we can accept a data transfer (ESP GPIO4 via 7474) +constexpr Pin SamTfrReadyPin = PortEPin(2); // Output from the SAM to the WiFi module indicating we can accept a data transfer (ESP GPIO8) constexpr Pin SamCsPin = PortCPin(25); // SPI NPCS pin, input from WiFi module +// Note, the DMAC peripheral IDs are hard-coded in WiFiInterface // CAN constexpr Pin APIN_CAN0_RX = PortBPin(3); @@ -426,9 +429,6 @@ constexpr unsigned int CanDeviceNumber = 1; // CAN-FD device number constexpr unsigned int SecondaryCanDeviceNumber = 0; // plan CAN device number #endif -constexpr Pin SbcTfrReadyPin = PortEPin(2); -// Note, the DMAC peripheral IDs are hard-coded in DataTransfer - // Timer allocation // Step timer is timer 0 aka TC0 channel 0. Also used as the CAN timestamp counter. #define STEP_TC (TC0) diff --git a/src/Networking/ESP8266WiFi/WiFiInterface.cpp b/src/Networking/ESP8266WiFi/WiFiInterface.cpp index 07ea4e6b..22ae7a52 100644 --- a/src/Networking/ESP8266WiFi/WiFiInterface.cpp +++ b/src/Networking/ESP8266WiFi/WiFiInterface.cpp @@ -40,6 +40,7 @@ static_assert(SsidLength == SsidBufferLength, "SSID lengths in NetworkDefs.h and # include # include +# include # define USE_PDC 0 // use SAM4 peripheral DMA controller # define USE_DMAC 0 // use SAM4 general DMA controller @@ -63,18 +64,6 @@ constexpr Pin APIN_ESP_SPI_MISO = EspMisoPin; constexpr Pin APIN_ESP_SPI_SCK = EspSclkPin; constexpr IRQn ESP_SPI_IRQn = WiFiSpiSercomIRQn; -#elif defined(__LPC17xx__) - -# define USE_PDC 0 // use SAM4 peripheral DMA controller -# define USE_DMAC 0 // use SAM4 general DMA controller -# define USE_DMAC_MANAGER 0 // use SAMD/SAME DMA controller via DmacManager module -# define USE_XDMAC 0 // use SAME7 XDMA controller - -// Compatibility with existing RRF Code -constexpr Pin APIN_ESP_SPI_MISO = SPI0_MOSI; -constexpr Pin APIN_ESP_SPI_SCK = SPI0_SCK; -constexpr SSPChannel ESP_SPI = SSP0; - #else # error Unknown board #endif @@ -1421,9 +1410,6 @@ static Pdc *spi_pdc; #if USE_XDMAC // XDMAC hardware -const uint32_t SPI0_XDMAC_TX_CH_NUM = 1; -const uint32_t SPI0_XDMAC_RX_CH_NUM = 2; - static xdmac_channel_config_t xdmac_tx_cfg, xdmac_rx_cfg; #endif @@ -1594,7 +1580,7 @@ static void spi_tx_dma_setup(const void *buf, uint32_t transferLength) noexcept XDMAC_CC_DIF_AHB_IF1 | XDMAC_CC_SAM_INCREMENTED_AM | XDMAC_CC_DAM_FIXED_AM | - XDMAC_CC_PERID(SPI0_XDMAC_TX_CH_NUM); + XDMAC_CC_PERID((uint32_t)DmaTrigSource::spi1tx); xdmac_tx_cfg.mbr_bc = 0; xdmac_tx_cfg.mbr_ds = 0; xdmac_tx_cfg.mbr_sus = 0; @@ -1655,7 +1641,7 @@ static void spi_rx_dma_setup(void *buf, uint32_t transferLength) noexcept XDMAC_CC_DIF_AHB_IF0 | XDMAC_CC_SAM_FIXED_AM | XDMAC_CC_DAM_INCREMENTED_AM | - XDMAC_CC_PERID(SPI0_XDMAC_RX_CH_NUM); + XDMAC_CC_PERID((uint32_t)DmaTrigSource::spi1rx); xdmac_rx_cfg.mbr_bc = 0; xdmac_tx_cfg.mbr_ds = 0; xdmac_rx_cfg.mbr_sus = 0; diff --git a/src/Platform/Platform.cpp b/src/Platform/Platform.cpp index e82780c4..0a91998c 100644 --- a/src/Platform/Platform.cpp +++ b/src/Platform/Platform.cpp @@ -270,6 +270,9 @@ constexpr ObjectModelTableEntry Platform::objectModelTable[] = #if HAS_VOLTAGE_MONITOR { "vIn", OBJECT_MODEL_FUNC(self, 2), ObjectModelEntryFlags::live }, #endif +#if HAS_WIFI_NETWORKING + { "wifiFirmwareFileName", OBJECT_MODEL_FUNC_NOSELF(WIFI_FIRMWARE_FILE), ObjectModelEntryFlags::none }, +#endif #if HAS_CPU_TEMP_SENSOR // 1. mcuTemp members { "current", OBJECT_MODEL_FUNC(self->GetMcuTemperatures().current, 1), ObjectModelEntryFlags::live }, @@ -357,7 +360,8 @@ constexpr ObjectModelTableEntry Platform::objectModelTable[] = constexpr uint8_t Platform::objectModelTableDescriptor[] = { 10, // number of sections - 9 + SUPPORT_ACCELEROMETERS + HAS_SBC_INTERFACE + HAS_MASS_STORAGE + HAS_VOLTAGE_MONITOR + HAS_12V_MONITOR + HAS_CPU_TEMP_SENSOR + SUPPORT_CAN_EXPANSION + SUPPORT_12864_LCD + MCU_HAS_UNIQUE_ID, // section 0: boards[0] + 9 + SUPPORT_ACCELEROMETERS + HAS_SBC_INTERFACE + HAS_MASS_STORAGE + HAS_VOLTAGE_MONITOR + HAS_12V_MONITOR + HAS_CPU_TEMP_SENSOR + + SUPPORT_CAN_EXPANSION + SUPPORT_DIRECT_LCD + MCU_HAS_UNIQUE_ID + HAS_WIFI_NETWORKING, // section 0: boards[0] #if HAS_CPU_TEMP_SENSOR 3, // section 1: mcuTemp #else -- cgit v1.2.3