Files
mongoose/tutorials/stm32/portenta-h7/minimal/wifi.c
T
2026-05-22 15:39:25 +01:00

82 lines
2.9 KiB
C

// SPDX-FileCopyrightText: 2025 Cesanta Software Limited
// SPDX-License-Identifier: GPL-2.0-only or commercial
// Generated by Mongoose Wizard, https://mongoose.ws/wizard/
#include "hal.h"
#include "mongoose.h"
#ifndef WIFI_NAME
#define WIFI_NAME ""
#endif
#ifndef WIFI_PASS
#define WIFI_PASS ""
#endif
#ifndef WIFI_AP_NAME
#define WIFI_AP_NAME "Mongoose"
#endif
#ifndef WIFI_AP_PASS
#define WIFI_AP_PASS "mongoose"
#endif
#ifndef ENABLE_WIFI_AP
#define ENABLE_WIFI_AP 1
#endif
void hwspecific_sdio_init(void) {
hal_gpio_output(PWRPIN);
hal_gpio_write(PWRPIN, 0);
mg_delayms(100);
hal_sdmmc_init();
mg_delayms(1);
hal_gpio_write(PWRPIN, 1);
mg_delayms(50);
}
static void hwspecific_sdio_config(void *sdio, uint8_t cfg) {
(void) sdio;
if (cfg == 0) return hal_sdmmc_set_ds();
if (cfg == 1) return hal_sdmmc_set_hs();
}
static bool hwspecific_sdio_txn(void *sdio, uint8_t cmd, uint32_t arg, uint32_t *resp) {
(void) sdio;
return hal_sdmmc_transact(cmd, arg, resp);
}
static bool hwspecific_sdio_xfr(void *sdio, bool write, uint32_t arg, uint16_t blksz, uint32_t *data, uint32_t len, uint32_t *resp){
(void) sdio;
return hal_sdmmc_transfer(write, arg, blksz, data, len, resp);
}
static const struct mg_tcpip_sdio sdio = {NULL, hwspecific_sdio_config, hwspecific_sdio_txn, hwspecific_sdio_xfr};
// clang-format off
typedef enum {RESOURCE_IN_MEMORY,RESOURCE_IN_EXTERNAL_STORAGE} resource_location_t;
typedef struct {resource_location_t l;unsigned long sz;union{struct {unsigned long o;const char *f;}fs;struct {const char *m;}mem;}val;} resource_hnd_t;
#include "mbed/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/COMPONENT_WHD/resources/firmware/COMPONENT_4343W_FS/4343WA1_bin.c"
#include "mbed/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/COMPONENT_WHD/resources/firmware/COMPONENT_4343W_FS/4343WA1_clm_blob.c"
#include "mbed/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/COMPONENT_WHD/resources/nvram/wifi_nvram_image.h"
// clang-format on
static const struct mg_tcpip_driver_cyw_firmware fw = {
(const uint8_t *)wifi_firmware_image_data, (size_t)sizeof(wifi_firmware_image_data),
(const uint8_t *)wifi_nvram_image, (size_t)sizeof(wifi_nvram_image),
(const uint8_t *)wifi_firmware_clm_blob_image_data, (size_t)sizeof(wifi_firmware_clm_blob_image_data)};
void wifi_setconfig(void *data) {
struct mg_tcpip_driver_cyw_data *d = (struct mg_tcpip_driver_cyw_data *) data;
d->bus = (struct mg_tcpip_sdio *) &sdio;
d->fw = (struct mg_tcpip_driver_cyw_firmware *)&fw;
d->wifi.ssid = WIFI_NAME;
d->wifi.pass = WIFI_PASS;
d->wifi.apssid = WIFI_AP_NAME;
d->wifi.appass = WIFI_AP_PASS;
d->wifi.apip = MG_IPV4(192, 168, 111, 1);
d->wifi.apmask = MG_IPV4(255, 255, 255, 0);
d->wifi.security = 0;
d->wifi.apsecurity = 0;
d->wifi.apchannel = 10;
d->wifi.apmode = ENABLE_WIFI_AP;
d->hs = false;
}