import{ESP32C3ROM as t}from"./c.B9uCRr4V.js";import"./c.B2LvkjpK.js";class s extends t{constructor(){super(...arguments),this.CHIP_NAME="ESP32-C2",this.IMAGE_CHIP_ID=12,this.EFUSE_BASE=1610647552,this.MAC_EFUSE_REG=this.EFUSE_BASE+64,this.UART_CLKDIV_REG=1610612756,this.UART_CLKDIV_MASK=1048575,this.UART_DATE_REG_ADDR=1610612860,this.XTAL_CLK_DIVIDER=1,this.FLASH_WRITE_SIZE=1024,this.BOOTLOADER_FLASH_OFFSET=0,this.FLASH_SIZES={"1MB":0,"2MB":16,"4MB":32,"8MB":48,"16MB":64},this.SPI_REG_BASE=1610620928,this.SPI_USR_OFFS=24,this.SPI_USR1_OFFS=28,this.SPI_USR2_OFFS=32,this.SPI_MOSI_DLEN_OFFS=36,this.SPI_MISO_DLEN_OFFS=40,this.SPI_W0_OFFS=88}async getPkgVersion(t){const s=this.EFUSE_BASE+64+4;return await t.readReg(s)>>22&7}async getChipRevision(t){const s=this.EFUSE_BASE+64+4;return(await t.readReg(s)&3<<20)>>20}async getChipDescription(t){let s;const i=await this.getPkgVersion(t);s=0===i||1===i?"ESP32-C2":"unknown ESP32-C2";return s+=" (revision "+await this.getChipRevision(t)+")",s}async getChipFeatures(t){return["Wi-Fi","BLE"]}async getCrystalFreq(t){const s=await t.readReg(this.UART_CLKDIV_REG)&this.UART_CLKDIV_MASK,i=t.transport.baudrate*s/1e6/this.XTAL_CLK_DIVIDER;let e;return e=i>33?40:26,Math.abs(e-i)>1&&t.info("WARNING: Unsupported crystal in use"),e}async changeBaudRate(t){26===await this.getCrystalFreq(t)&&t.changeBaud()}_d2h(t){const s=(+t).toString(16);return 1===s.length?"0"+s:s}async readMac(t){let s=await t.readReg(this.MAC_EFUSE_REG);s>>>=0;let i=await t.readReg(this.MAC_EFUSE_REG+4);i=i>>>0&65535;const e=new Uint8Array(6);return e[0]=i>>8&255,e[1]=255&i,e[2]=s>>24&255,e[3]=s>>16&255,e[4]=s>>8&255,e[5]=255&s,this._d2h(e[0])+":"+this._d2h(e[1])+":"+this._d2h(e[2])+":"+this._d2h(e[3])+":"+this._d2h(e[4])+":"+this._d2h(e[5])}getEraseSize(t,s){return s}}export{s as ESP32C2ROM};
//# sourceMappingURL=c.BCOKJYg9.js.map
