Files
drivers/espradio/radio_esp32c3.go
T
Ayke van Laethem 8b3d323f1b espradio: implement support for wifi/BLE on the ESP32-C3
This is a work in progress. It does not yet work.
2024-01-27 19:47:47 +01:00

38 lines
1.1 KiB
Go

//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
}