#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
#![allow(clippy::upper_case_acronyms)]
pub const CONFIG_SECTOR_LENGTH: usize = 4;
type USERID = u16;
pub enum AI2C1 {
ON = 0x1,
OFF = 0x0,
}
pub enum AI2C2 {
ON = 0x1,
OFF = 0x0,
}
pub enum PMDL1WAY {
ON = 0x1,
OFF = 0x0,
}
pub enum IOL1WAY {
ON = 0x1,
OFF = 0x0,
}
pub enum FUSBIDIO {
OFF = 0x0,
ON = 0x1,
}
pub enum FPLLIDIV {
DIV_1 = 0x0,
DIV_2 = 0x1,
DIV_3 = 0x2,
DIV_4 = 0x3,
DIV_5 = 0x4,
DIV_6 = 0x5,
DIV_10 = 0x6,
DIV_12 = 0x7,
}
pub enum FPLLMUL {
MUL_15 = 0x0,
MUL_16 = 0x1,
MUL_17 = 0x2,
MUL_18 = 0x3,
MUL_19 = 0x4,
MUL_20 = 0x5,
MUL_21 = 0x6,
MUL_24 = 0x7,
}
pub enum FPLLICLK {
PLL_POSC = 0x0,
PLL_FRC = 0x1,
}
pub enum UPLLIDIV {
DIV_1 = 0x0,
DIV_2 = 0x1,
DIV_3 = 0x2,
DIV_4 = 0x3,
DIV_5 = 0x4,
DIV_6 = 0x5,
DIV_10 = 0x6,
DIV_12 = 0x7,
}
pub enum UPLLEN {
ON = 0x0,
OFF = 0x1,
}
pub enum FPLLODIV {
DIV_1 = 0x0,
DIV_2 = 0x1,
DIV_4 = 0x2,
DIV_8 = 0x3,
DIV_16 = 0x4,
DIV_32 = 0x5,
DIV_64 = 0x6,
DIV_256 = 0x7,
}
pub enum BOREN {
OFF = 0x0,
ON = 0x1,
}
pub enum DSBOREN {
OFF = 0x0,
ON = 0x1,
}
pub enum DSWDTPS {
DSPS1 = 0x0,
DSPS2 = 0x1,
DSPS3 = 0x2,
DSPS4 = 0x3,
DSPS5 = 0x4,
DSPS6 = 0x5,
DSPS7 = 0x6,
DSPS8 = 0x7,
DSPS9 = 0x8,
DSPS10 = 0x9,
DSPS11 = 0xa,
DSPS12 = 0xb,
DSPS13 = 0xc,
DSPS14 = 0xd,
DSPS15 = 0xe,
DSPS16 = 0xf,
DSPS17 = 0x10,
DSPS18 = 0x11,
DSPS19 = 0x12,
DSPS20 = 0x13,
DSPS21 = 0x14,
DSPS22 = 0x15,
DSPS23 = 0x16,
DSPS24 = 0x17,
DSPS25 = 0x18,
DSPS26 = 0x19,
DSPS27 = 0x1a,
DSPS28 = 0x1b,
DSPS29 = 0x1c,
DSPS30 = 0x1d,
DSPS31 = 0x1e,
DSPS32 = 0x1f,
}
pub enum DSWDTOSC {
SOSC = 0x0,
LPRC = 0x1,
}
pub enum DSWDTEN {
OFF = 0x0,
ON = 0x1,
}
pub enum FDSEN {
OFF = 0x0,
ON = 0x1,
}
pub enum FNOSC {
FRC = 0x0,
SPLL = 0x1,
POSC = 0x2,
SOSC = 0x4,
LPRC = 0x5,
}
pub enum FSOSCEN {
OFF = 0x0,
ON = 0x1,
}
pub enum IESO {
OFF = 0x0,
ON = 0x1,
}
pub enum POSCMOD {
EC = 0x0,
XT = 0x1,
HS = 0x2,
OFF = 0x3,
}
pub enum OSCIOFNC {
OFF = 0x1,
ON = 0x0,
}
pub enum FPBDIV {
DIV_1 = 0x0,
DIV_2 = 0x1,
DIV_4 = 0x2,
DIV_8 = 0x3,
}
pub enum FCKSM {
CSECME = 0x0,
CSECMD = 0x1,
CSDCMD = 0x3,
}
pub enum WDTPS {
PS1 = 0x0,
PS2 = 0x1,
PS4 = 0x2,
PS8 = 0x3,
PS16 = 0x4,
PS32 = 0x5,
PS64 = 0x6,
PS128 = 0x7,
PS256 = 0x8,
PS512 = 0x9,
PS1024 = 0xa,
PS2048 = 0xb,
PS4096 = 0xc,
PS8192 = 0xd,
PS16384 = 0xe,
PS32768 = 0xf,
PS65536 = 0x10,
PS131072 = 0x11,
PS262144 = 0x12,
PS524288 = 0x13,
PS1048576 = 0x14,
}
pub enum WDTSPGM {
ON = 0x1,
OFF = 0x0,
}
pub enum WINDIS {
ON = 0x0,
OFF = 0x1,
}
pub enum FWDTEN {
OFF = 0x0,
ON = 0x1,
}
pub enum FWDTWINSZ {
WINSZ_75 = 0x0,
WINSZ_50 = 0x1,
WINSZ_37 = 0x2,
WINSZ_25 = 0x3,
}
pub enum DEBUG {
ON = 0x0,
OFF = 0x3,
}
pub enum JTAGEN {
ON = 0x1,
OFF = 0x0,
}
pub enum ICESEL {
ICS_PGx1 = 0x3,
ICS_PGx2 = 0x2,
ICS_PGx3 = 0x1,
ICS_PGx4 = 0x0,
}
pub enum PWP {
OFF = 0xff,
PWP4K = 0xfe,
PWP8K = 0xfd,
PWP12K = 0xfc,
PWP16K = 0xfb,
PWP20K = 0xfa,
PWP24K = 0xf9,
PWP28K = 0xf8,
PWP32K = 0xf7,
PWP36K = 0xf6,
PWP40K = 0xf5,
PWP44K = 0xf4,
PWP48K = 0xf3,
PWP52K = 0xf2,
PWP56K = 0xf1,
PWP60K = 0xf0,
PWP64K = 0xef,
PWP68K = 0xee,
PWP72K = 0xed,
PWP76K = 0xec,
PWP80K = 0xeb,
PWP84K = 0xea,
PWP88K = 0xe9,
PWP92K = 0xe8,
PWP96K = 0xe7,
PWP100K = 0xe6,
PWP104K = 0xe5,
PWP108K = 0xe4,
PWP112K = 0xe3,
PWP116K = 0xe2,
PWP120K = 0xe1,
PWP124K = 0xe0,
PWP128K = 0xdf,
PWP132K = 0xde,
PWP136K = 0xdd,
PWP140K = 0xdc,
PWP144K = 0xdb,
PWP148K = 0xda,
PWP152K = 0xd9,
PWP156K = 0xd8,
PWP160K = 0xd7,
PWP164K = 0xd6,
PWP168K = 0xd5,
PWP172K = 0xd4,
PWP176K = 0xd3,
PWP180K = 0xd2,
PWP184K = 0xd1,
PWP188K = 0xd0,
PWP192K = 0xcf,
PWP196K = 0xce,
PWP200K = 0xcd,
PWP204K = 0xcc,
PWP208K = 0xcb,
PWP212K = 0xca,
PWP216K = 0xc9,
PWP220K = 0xc8,
PWP224K = 0xc7,
PWP228K = 0xc6,
PWP232K = 0xc5,
PWP236K = 0xc4,
PWP240K = 0xc3,
PWP244K = 0xc2,
PWP248K = 0xc1,
PWP252K = 0xc0,
PWP256K = 0xbf,
}
pub enum SMCLR {
MCLR_POR = 0x0,
MCLR_NORM = 0x1,
}
pub enum BWP {
ON = 0x0,
OFF = 0x1,
}
pub enum CP {
ON = 0x0,
OFF = 0x1,
}
#[repr(C)]
pub struct ConfigSector {
DEVCFG3: u32,
DEVCFG2: u32,
DEVCFG1: u32,
DEVCFG0: u32,
}
impl ConfigSector {
pub const fn default() -> ConfigSectorBuilder {
ConfigSectorBuilder {
DEVCFG3: 0xffffffff,
DEVCFG2: 0xffffffff,
DEVCFG1: 0xffffffff,
DEVCFG0: 0xffffffff,
}
}
pub const fn into_array(self) -> [u32; CONFIG_SECTOR_LENGTH] {
[self.DEVCFG3, self.DEVCFG2, self.DEVCFG1, self.DEVCFG0]
}
}
pub struct ConfigSectorBuilder {
DEVCFG3: u32,
DEVCFG2: u32,
DEVCFG1: u32,
DEVCFG0: u32,
}
impl ConfigSectorBuilder {
pub const fn USERID(mut self, v: USERID) -> Self {
self.DEVCFG3 &= !0x0000ffff;
self.DEVCFG3 |= v as u32;
self
}
pub const fn AI2C1(mut self, v: AI2C1) -> Self {
self.DEVCFG3 &= !0x00400000;
self.DEVCFG3 |= (v as u32) << 22;
self
}
pub const fn AI2C2(mut self, v: AI2C2) -> Self {
self.DEVCFG3 &= !0x00800000;
self.DEVCFG3 |= (v as u32) << 23;
self
}
pub const fn PMDL1WAY(mut self, v: PMDL1WAY) -> Self {
self.DEVCFG3 &= !0x10000000;
self.DEVCFG3 |= (v as u32) << 28;
self
}
pub const fn IOL1WAY(mut self, v: IOL1WAY) -> Self {
self.DEVCFG3 &= !0x20000000;
self.DEVCFG3 |= (v as u32) << 29;
self
}
pub const fn FUSBIDIO(mut self, v: FUSBIDIO) -> Self {
self.DEVCFG3 &= !0x40000000;
self.DEVCFG3 |= (v as u32) << 30;
self
}
pub const fn FPLLIDIV(mut self, v: FPLLIDIV) -> Self {
self.DEVCFG2 &= !0x00000007;
self.DEVCFG2 |= v as u32;
self
}
pub const fn FPLLMUL(mut self, v: FPLLMUL) -> Self {
self.DEVCFG2 &= !0x00000070;
self.DEVCFG2 |= (v as u32) << 4;
self
}
pub const fn FPLLICLK(mut self, v: FPLLICLK) -> Self {
self.DEVCFG2 &= !0x00000080;
self.DEVCFG2 |= (v as u32) << 7;
self
}
pub const fn UPLLIDIV(mut self, v: UPLLIDIV) -> Self {
self.DEVCFG2 &= !0x00000700;
self.DEVCFG2 |= (v as u32) << 8;
self
}
pub const fn UPLLEN(mut self, v: UPLLEN) -> Self {
self.DEVCFG2 &= !0x00008000;
self.DEVCFG2 |= (v as u32) << 15;
self
}
pub const fn FPLLODIV(mut self, v: FPLLODIV) -> Self {
self.DEVCFG2 &= !0x00070000;
self.DEVCFG2 |= (v as u32) << 16;
self
}
pub const fn BOREN(mut self, v: BOREN) -> Self {
self.DEVCFG2 &= !0x00100000;
self.DEVCFG2 |= (v as u32) << 20;
self
}
pub const fn DSBOREN(mut self, v: DSBOREN) -> Self {
self.DEVCFG2 &= !0x00800000;
self.DEVCFG2 |= (v as u32) << 23;
self
}
pub const fn DSWDTPS(mut self, v: DSWDTPS) -> Self {
self.DEVCFG2 &= !0x1f000000;
self.DEVCFG2 |= (v as u32) << 24;
self
}
pub const fn DSWDTOSC(mut self, v: DSWDTOSC) -> Self {
self.DEVCFG2 &= !0x20000000;
self.DEVCFG2 |= (v as u32) << 29;
self
}
pub const fn DSWDTEN(mut self, v: DSWDTEN) -> Self {
self.DEVCFG2 &= !0x40000000;
self.DEVCFG2 |= (v as u32) << 30;
self
}
pub const fn FDSEN(mut self, v: FDSEN) -> Self {
self.DEVCFG2 &= !0x80000000;
self.DEVCFG2 |= (v as u32) << 31;
self
}
pub const fn FNOSC(mut self, v: FNOSC) -> Self {
self.DEVCFG1 &= !0x00000007;
self.DEVCFG1 |= v as u32;
self
}
pub const fn FSOSCEN(mut self, v: FSOSCEN) -> Self {
self.DEVCFG1 &= !0x00000020;
self.DEVCFG1 |= (v as u32) << 5;
self
}
pub const fn IESO(mut self, v: IESO) -> Self {
self.DEVCFG1 &= !0x00000080;
self.DEVCFG1 |= (v as u32) << 7;
self
}
pub const fn POSCMOD(mut self, v: POSCMOD) -> Self {
self.DEVCFG1 &= !0x00000300;
self.DEVCFG1 |= (v as u32) << 8;
self
}
pub const fn OSCIOFNC(mut self, v: OSCIOFNC) -> Self {
self.DEVCFG1 &= !0x00000400;
self.DEVCFG1 |= (v as u32) << 10;
self
}
pub const fn FPBDIV(mut self, v: FPBDIV) -> Self {
self.DEVCFG1 &= !0x00003000;
self.DEVCFG1 |= (v as u32) << 12;
self
}
pub const fn FCKSM(mut self, v: FCKSM) -> Self {
self.DEVCFG1 &= !0x0000c000;
self.DEVCFG1 |= (v as u32) << 14;
self
}
pub const fn WDTPS(mut self, v: WDTPS) -> Self {
self.DEVCFG1 &= !0x001f0000;
self.DEVCFG1 |= (v as u32) << 16;
self
}
pub const fn WDTSPGM(mut self, v: WDTSPGM) -> Self {
self.DEVCFG1 &= !0x00200000;
self.DEVCFG1 |= (v as u32) << 21;
self
}
pub const fn WINDIS(mut self, v: WINDIS) -> Self {
self.DEVCFG1 &= !0x00400000;
self.DEVCFG1 |= (v as u32) << 22;
self
}
pub const fn FWDTEN(mut self, v: FWDTEN) -> Self {
self.DEVCFG1 &= !0x00800000;
self.DEVCFG1 |= (v as u32) << 23;
self
}
pub const fn FWDTWINSZ(mut self, v: FWDTWINSZ) -> Self {
self.DEVCFG1 &= !0x03000000;
self.DEVCFG1 |= (v as u32) << 24;
self
}
pub const fn DEBUG(mut self, v: DEBUG) -> Self {
self.DEVCFG0 &= !0x00000003;
self.DEVCFG0 |= v as u32;
self
}
pub const fn JTAGEN(mut self, v: JTAGEN) -> Self {
self.DEVCFG0 &= !0x00000004;
self.DEVCFG0 |= (v as u32) << 2;
self
}
pub const fn ICESEL(mut self, v: ICESEL) -> Self {
self.DEVCFG0 &= !0x00000018;
self.DEVCFG0 |= (v as u32) << 3;
self
}
pub const fn PWP(mut self, v: PWP) -> Self {
self.DEVCFG0 &= !0x000ff000;
self.DEVCFG0 |= (v as u32) << 12;
self
}
pub const fn SMCLR(mut self, v: SMCLR) -> Self {
self.DEVCFG0 &= !0x00800000;
self.DEVCFG0 |= (v as u32) << 23;
self
}
pub const fn BWP(mut self, v: BWP) -> Self {
self.DEVCFG0 &= !0x01000000;
self.DEVCFG0 |= (v as u32) << 24;
self
}
pub const fn CP(mut self, v: CP) -> Self {
self.DEVCFG0 &= !0x10000000;
self.DEVCFG0 |= (v as u32) << 28;
self
}
pub const fn build(self) -> ConfigSector {
ConfigSector {
DEVCFG3: self.DEVCFG3,
DEVCFG2: self.DEVCFG2,
DEVCFG1: self.DEVCFG1,
DEVCFG0: self.DEVCFG0,
}
}
}