espradio: implement support for wifi/BLE on the ESP32-C3

This is a work in progress. It does not yet work.
This commit is contained in:
Ayke van Laethem
2024-01-25 15:27:43 +01:00
parent 8642886f73
commit 8b3d323f1b
89 changed files with 21250 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
//go:build esp32c3
package espradio
import "device/esp"
func initHardware() error {
// See:
// https://github.com/esp-rs/esp-wifi/blob/main/esp-wifi/src/common_adapter/common_adapter_esp32c3.rs#L18
const (
SYSTEM_WIFIBB_RST = 1 << 0
SYSTEM_FE_RST = 1 << 1
SYSTEM_WIFIMAC_RST = 1 << 2
SYSTEM_BTBB_RST = 1 << 3 // Bluetooth Baseband
SYSTEM_BTMAC_RST = 1 << 4 // deprecated
SYSTEM_RW_BTMAC_RST = 1 << 9 // Bluetooth MAC
SYSTEM_RW_BTMAC_REG_RST = 1 << 11 // Bluetooth MAC Regsiters
SYSTEM_BTBB_REG_RST = 1 << 13 // Bluetooth Baseband Registers
)
const MODEM_RESET_FIELD_WHEN_PU = SYSTEM_WIFIBB_RST |
SYSTEM_FE_RST |
SYSTEM_WIFIMAC_RST |
SYSTEM_BTBB_RST |
SYSTEM_BTMAC_RST |
SYSTEM_RW_BTMAC_RST |
SYSTEM_RW_BTMAC_REG_RST |
SYSTEM_BTBB_REG_RST
esp.RTC_CNTL.DIG_PWC.ClearBits(esp.RTC_CNTL_DIG_PWC_WIFI_FORCE_PD)
esp.APB_CTRL.WIFI_RST_EN.SetBits(MODEM_RESET_FIELD_WHEN_PU)
esp.APB_CTRL.WIFI_RST_EN.ClearBits(MODEM_RESET_FIELD_WHEN_PU)
esp.RTC_CNTL.DIG_ISO.ClearBits(esp.RTC_CNTL_DIG_ISO_FORCE_OFF)
return nil
}