From f17af2ba44ba87739069d958a2dd1cd2e57ab5ff Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Sun, 2 Apr 2023 13:14:50 -0400 Subject: [PATCH] Resolve ambiguities with the timer/counter code The goal was to add attiny85, but this ended up adding a lot more, too. The problem was with the TC16 module, which seems to be a bit ambiguous between the hardware description file and the datasheet. --- core_generator/src/gen.rs | 335 +++---- core_generator/src/main.rs | 2 +- src/cores/at90pwm161.rs | 1857 ++++++++++++++++++++++++++++++++++++ src/cores/atmega168.rs | 2 +- src/cores/atmega168a.rs | 4 +- src/cores/atmega168p.rs | 2 +- src/cores/atmega16u4.rs | 23 +- src/cores/atmega328.rs | 4 +- src/cores/atmega328p.rs | 2 +- src/cores/atmega32u4.rs | 23 +- src/cores/atmega406.rs | 1389 +++++++++++++++++++++++++++ src/cores/atmega48.rs | 2 +- src/cores/atmega48a.rs | 4 +- src/cores/atmega48p.rs | 2 +- src/cores/atmega48pa.rs | 6 +- src/cores/atmega88.rs | 4 +- src/cores/atmega88a.rs | 2 +- src/cores/atmega88p.rs | 4 +- src/cores/atmega88pa.rs | 6 +- src/cores/attiny11.rs | 282 ++++++ src/cores/attiny12.rs | 363 +++++++ src/cores/attiny1634.rs | 1746 +++++++++++++++++++++++++++++++++ src/cores/attiny20.rs | 1342 ++++++++++++++++++++++++++ src/cores/attiny2313.rs | 1038 ++++++++++++++++++++ src/cores/attiny2313a.rs | 1111 +++++++++++++++++++++ src/cores/attiny26.rs | 726 ++++++++++++++ src/cores/attiny261.rs | 1468 ++++++++++++++++++++++++++++ src/cores/attiny261a.rs | 1269 ++++++++++++++++++++++++ src/cores/attiny40.rs | 1461 ++++++++++++++++++++++++++++ src/cores/attiny4313.rs | 1111 +++++++++++++++++++++ src/cores/attiny461.rs | 1468 ++++++++++++++++++++++++++++ src/cores/attiny461a.rs | 1269 ++++++++++++++++++++++++ src/cores/attiny85.rs | 1115 ++++++++++++++++++++++ src/cores/attiny861.rs | 1470 ++++++++++++++++++++++++++++ src/cores/attiny861a.rs | 1271 ++++++++++++++++++++++++ src/cores/mod.rs | 72 ++ 36 files changed, 22070 insertions(+), 185 deletions(-) create mode 100644 src/cores/at90pwm161.rs create mode 100644 src/cores/atmega406.rs create mode 100644 src/cores/attiny11.rs create mode 100644 src/cores/attiny12.rs create mode 100644 src/cores/attiny1634.rs create mode 100644 src/cores/attiny20.rs create mode 100644 src/cores/attiny2313.rs create mode 100644 src/cores/attiny2313a.rs create mode 100644 src/cores/attiny26.rs create mode 100644 src/cores/attiny261.rs create mode 100644 src/cores/attiny261a.rs create mode 100644 src/cores/attiny40.rs create mode 100644 src/cores/attiny4313.rs create mode 100644 src/cores/attiny461.rs create mode 100644 src/cores/attiny461a.rs create mode 100644 src/cores/attiny85.rs create mode 100644 src/cores/attiny861.rs create mode 100644 src/cores/attiny861a.rs diff --git a/core_generator/src/gen.rs b/core_generator/src/gen.rs index a3a0d36..c298c41 100644 --- a/core_generator/src/gen.rs +++ b/core_generator/src/gen.rs @@ -205,180 +205,195 @@ pub fn write_usarts(mcu: &Mcu, w: &mut dyn Write) -> Result<(), io::Error> { } pub fn write_timers(mcu: &Mcu, w: &mut dyn Write) -> Result<(), io::Error> { - if let Some(tc) = mcu.module("TC8") { - // Timer/Counter, 8-bit. - const TYPE_NAME: &'static str = "Timer8"; - - let find_reg = |name: &'static str| { - tc.registers() - .find(|r| r.name.starts_with(name)) - .expect(&format!("could not find '{}' register", name)) - }; - let find_reg_suffix_optional = |name: &'static str, suffix: &'static str| { - tc.registers() + let find_reg = |group: &RegisterGroup, name: &'static str| { + group + .registers + .iter() + .find(|r| r.name.starts_with(name)) + .expect(&format!("could not find '{}' register", name)) + .clone() + }; + let find_reg_suffix_optional = + |group: &RegisterGroup, name: &'static str, suffix: &'static str| { + group + .registers + .iter() .find(|r| r.name.starts_with(name) && r.name.ends_with(suffix)) + .cloned() }; - let find_reg_suffix = |name: &'static str, suffix: &'static str| { - find_reg_suffix_optional(name, suffix) - .expect(&format!("could not find '{}' register", name)) - }; - let timer_number = find_reg("TIMSK") - .name - .chars() - .last() - .unwrap() - .to_digit(10) - .unwrap(); + let find_reg_suffix = |group: &RegisterGroup, name: &'static str, suffix: &'static str| { + find_reg_suffix_optional(group, name, suffix) + .expect(&format!("could not find '{} {}' register", name, suffix)) + .clone() + }; - // TODO: At the moment, we do not support 8 bit timers that don't have two compare - // registers. - let should_skip_timer = find_reg_suffix_optional("OCR", "B").is_none(); + if let Some(tc) = mcu.module("TC8") { + for group in tc.register_groups.iter() { + let timer_number = group.name.chars().last().unwrap().to_digit(10).unwrap(); - if !should_skip_timer { - writeln!(w, "/// 8-bit timer.")?; - writeln!(w, "pub struct {};", TYPE_NAME)?; - writeln!(w)?; - writeln!(w, "impl modules::Timer8 for {} {{", TYPE_NAME)?; - writeln!( - w, - " type CompareA = {};", - find_reg_suffix("OCR", "A").name - )?; - writeln!( - w, - " type CompareB = {};", - find_reg_suffix("OCR", "B").name - )?; - writeln!(w, " type Counter = {};", find_reg("TCNT").name)?; - writeln!( - w, - " type ControlA = {};", - find_reg_suffix("TCCR", "A").name - )?; - writeln!( - w, - " type ControlB = {};", - find_reg_suffix("TCCR", "B").name - )?; - writeln!(w, " type InterruptMask = {};", find_reg("TIMSK").name)?; - writeln!(w, " type InterruptFlag = {};", find_reg("TIFR").name)?; - writeln!( - w, - " const CS0: RegisterBits = Self::ControlB::CS00;" - )?; - writeln!( - w, - " const CS1: RegisterBits = Self::ControlB::CS01;" - )?; - writeln!( - w, - " const CS2: RegisterBits = Self::ControlB::CS02;" - )?; - writeln!( - w, - " const WGM0: RegisterBits = Self::ControlA::WGM00;" - )?; - writeln!( - w, - " const WGM1: RegisterBits = Self::ControlA::WGM01;" - )?; - writeln!( - w, - " const WGM2: RegisterBits = Self::ControlB::WGM020;" - )?; - writeln!(w, " const OCIEA: RegisterBits = Self::InterruptMask::OCIE{}A;", timer_number)?; - writeln!(w, "}}")?; + // Timer/Counter, 8-bit. + const TYPE_NAME: &'static str = "Timer8"; + + // TODO: At the moment, we do not support 8 bit timers that don't have two compare + // registers. + let should_skip_timer = find_reg_suffix_optional(&group, "OCR", "B").is_none(); + + if !should_skip_timer { + writeln!(w, "/// 8-bit timer.")?; + writeln!(w, "pub struct {};", TYPE_NAME)?; + writeln!(w)?; + writeln!(w, "impl modules::Timer8 for {} {{", TYPE_NAME)?; + writeln!( + w, + " type CompareA = {};", + find_reg_suffix(&group, "OCR", "A").name + )?; + writeln!( + w, + " type CompareB = {};", + find_reg_suffix(&group, "OCR", "B").name + )?; + writeln!(w, " type Counter = {};", find_reg(&group, "TCNT").name)?; + writeln!( + w, + " type ControlA = {};", + find_reg_suffix(&group, "TCCR", "A").name + )?; + writeln!( + w, + " type ControlB = {};", + find_reg_suffix(&group, "TCCR", "B").name + )?; + writeln!( + w, + " type InterruptMask = {};", + find_reg(&group, "TIMSK").name + )?; + writeln!( + w, + " type InterruptFlag = {};", + find_reg(&group, "TIFR").name + )?; + writeln!( + w, + " const CS0: RegisterBits = Self::ControlB::CS00;" + )?; + writeln!( + w, + " const CS1: RegisterBits = Self::ControlB::CS01;" + )?; + writeln!( + w, + " const CS2: RegisterBits = Self::ControlB::CS02;" + )?; + writeln!( + w, + " const WGM0: RegisterBits = Self::ControlA::WGM00;" + )?; + writeln!( + w, + " const WGM1: RegisterBits = Self::ControlA::WGM01;" + )?; + writeln!( + w, + " const WGM2: RegisterBits = Self::ControlB::WGM020;" + )?; + writeln!(w, " const OCIEA: RegisterBits = Self::InterruptMask::OCIE{}A;", timer_number)?; + writeln!(w, "}}")?; + } } } if let Some(tc) = mcu.module("TC16") { - // Timer/Counter, 16-bit. - const TYPE_NAME: &'static str = "Timer16"; + for group in tc.register_groups.iter() { + let timer_number = group.name.chars().last().unwrap().to_digit(10).unwrap(); - let find_reg = |name: &'static str| { - tc.registers() - .find(|r| r.name.starts_with(name)) - .expect(&format!("could not find '{}' register", name)) - }; - let find_reg_suffix = |name: &'static str, suffix: &'static str| { - tc.registers() - .find(|r| r.name.starts_with(name) && r.name.ends_with(suffix)) - .expect(&format!("could not find '{}' register", name)) - }; - let timer_number = find_reg("TIMSK") - .name - .chars() - .last() - .unwrap() - .to_digit(10) - .unwrap(); + if find_reg_suffix_optional(&group, "TCCR", "A").is_none() { + // ATTiny85 has a TC16 group set in the data file, but there's no 16 bit timer + // documented in the datasheet. As such, I have no idea what to do about the three + // control registers and am simply going to bail instead of making assumptions. + println!("Only one control register found for 16-bit counter. Skipping."); + continue; + } - writeln!(w, "/// 16-bit timer.")?; - writeln!(w, "pub struct {};", TYPE_NAME)?; - writeln!(w)?; - writeln!(w, "impl modules::Timer16 for {} {{", TYPE_NAME)?; - writeln!( - w, - " type CompareA = {};", - find_reg_suffix("OCR", "A").name - )?; - writeln!( - w, - " type CompareB = {};", - find_reg_suffix("OCR", "B").name - )?; - writeln!(w, " type Counter = {};", find_reg("TCNT").name)?; - writeln!( - w, - " type ControlA = {};", - find_reg_suffix("TCCR", "A").name - )?; - writeln!( - w, - " type ControlB = {};", - find_reg_suffix("TCCR", "B").name - )?; - writeln!( - w, - " type ControlC = {};", - find_reg_suffix("TCCR", "C").name - )?; - writeln!(w, " type InterruptMask = {};", find_reg("TIMSK").name)?; - writeln!(w, " type InterruptFlag = {};", find_reg("TIFR").name)?; - writeln!( - w, - " const CS0: RegisterBits = Self::ControlB::CS10;" - )?; - writeln!( - w, - " const CS1: RegisterBits = Self::ControlB::CS11;" - )?; - writeln!( - w, - " const CS2: RegisterBits = Self::ControlB::CS12;" - )?; - writeln!( - w, - " const WGM0: RegisterBits = Self::ControlA::WGM10;" - )?; - writeln!( - w, - " const WGM1: RegisterBits = Self::ControlA::WGM11;" - )?; - writeln!( - w, - " const WGM2: RegisterBits = Self::ControlB::WGM10;" - )?; - writeln!( - w, - " const WGM3: RegisterBits = Self::ControlB::WGM11;" - )?; - writeln!( + // Timer/Counter, 16-bit. + const TYPE_NAME: &'static str = "Timer16"; + + writeln!(w, "/// 16-bit timer.")?; + writeln!(w, "pub struct {};", TYPE_NAME)?; + writeln!(w)?; + writeln!(w, "impl modules::Timer16 for {} {{", TYPE_NAME)?; + writeln!( + w, + " type CompareA = {};", + find_reg_suffix(&group, "OCR", "A").name + )?; + writeln!( + w, + " type CompareB = {};", + find_reg_suffix(&group, "OCR", "B").name + )?; + writeln!(w, " type Counter = {};", find_reg(&group, "TCNT").name)?; + writeln!( + w, + " type ControlA = {};", + find_reg_suffix(&group, "TCCR", "A").name + )?; + writeln!( + w, + " type ControlB = {};", + find_reg_suffix(&group, "TCCR", "B").name + )?; + writeln!( + w, + " type ControlC = {};", + find_reg_suffix(&group, "TCCR", "C").name + )?; + writeln!( + w, + " type InterruptMask = {};", + find_reg(&group, "TIMSK").name + )?; + writeln!( + w, + " type InterruptFlag = {};", + find_reg(&group, "TIFR").name + )?; + writeln!( + w, + " const CS0: RegisterBits = Self::ControlB::CS10;" + )?; + writeln!( + w, + " const CS1: RegisterBits = Self::ControlB::CS11;" + )?; + writeln!( + w, + " const CS2: RegisterBits = Self::ControlB::CS12;" + )?; + writeln!( + w, + " const WGM0: RegisterBits = Self::ControlA::WGM10;" + )?; + writeln!( + w, + " const WGM1: RegisterBits = Self::ControlA::WGM11;" + )?; + writeln!( + w, + " const WGM2: RegisterBits = Self::ControlB::WGM10;" + )?; + writeln!( + w, + " const WGM3: RegisterBits = Self::ControlB::WGM11;" + )?; + writeln!( w, " const OCIEA: RegisterBits = Self::InterruptMask::OCIE{}A;", timer_number )?; - writeln!(w, "}}")?; + writeln!(w, "}}")?; + } } Ok(()) diff --git a/core_generator/src/main.rs b/core_generator/src/main.rs index 86a76e5..d0c2cb9 100644 --- a/core_generator/src/main.rs +++ b/core_generator/src/main.rs @@ -139,8 +139,8 @@ fn main() { fs::create_dir_all(&cores_path()).expect("could not create cores directory"); } - // let microcontrollers = vec![avr_mcu::microcontroller("atmega32u4")]; let microcontrollers = avr_mcu::microcontrollers(); + // let microcontrollers = vec![avr_mcu::microcontroller("atmega32u4")]; let (count_total, mut cores_successful, mut cores_failed) = (microcontrollers.len(), Vec::new(), Vec::new()); diff --git a/src/cores/at90pwm161.rs b/src/cores/at90pwm161.rs new file mode 100644 index 0000000..8892344 --- /dev/null +++ b/src/cores/at90pwm161.rs @@ -0,0 +1,1857 @@ +//! Core for AT90PWM161. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + pub const PSC2RB: RegisterBits = RegisterBits::new(0x80); + pub const PSC2RB0: RegisterBits = RegisterBits::new(1<<7); + + pub const PSC2RBA: RegisterBits = RegisterBits::new(0x40); + pub const PSC2RBA0: RegisterBits = RegisterBits::new(1<<6); + + pub const PSC0RB: RegisterBits = RegisterBits::new(0x20); + pub const PSC0RB0: RegisterBits = RegisterBits::new(1<<5); + + pub const PSCRV: RegisterBits = RegisterBits::new(0x10); + pub const PSCRV0: RegisterBits = RegisterBits::new(1<<4); + + pub const PSCINRB: RegisterBits = RegisterBits::new(0x8); + pub const PSCINRB0: RegisterBits = RegisterBits::new(1<<3); + + pub const BODLEVEL: RegisterBits = RegisterBits::new(0x7); + pub const BODLEVEL0: RegisterBits = RegisterBits::new(1<<0); + pub const BODLEVEL1: RegisterBits = RegisterBits::new(1<<1); + pub const BODLEVEL2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for EXTENDED { + type T = u8; + const ADDRESS: *mut u8 = 0x2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct HIGH; + +impl HIGH { + pub const RSTDISBL: RegisterBits = RegisterBits::new(0x80); + pub const RSTDISBL0: RegisterBits = RegisterBits::new(1<<7); + + pub const DWEN: RegisterBits = RegisterBits::new(0x40); + pub const DWEN0: RegisterBits = RegisterBits::new(1<<6); + + pub const SPIEN: RegisterBits = RegisterBits::new(0x20); + pub const SPIEN0: RegisterBits = RegisterBits::new(1<<5); + + pub const WDTON: RegisterBits = RegisterBits::new(0x10); + pub const WDTON0: RegisterBits = RegisterBits::new(1<<4); + + pub const EESAVE: RegisterBits = RegisterBits::new(0x8); + pub const EESAVE0: RegisterBits = RegisterBits::new(1<<3); + + pub const BOOTSZ: RegisterBits = RegisterBits::new(0x6); + pub const BOOTSZ0: RegisterBits = RegisterBits::new(1<<1); + pub const BOOTSZ1: RegisterBits = RegisterBits::new(1<<2); + + pub const BOOTRST: RegisterBits = RegisterBits::new(0x1); + pub const BOOTRST0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for HIGH { + type T = u8; + const ADDRESS: *mut u8 = 0x1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOW; + +impl LOW { + pub const CKDIV8: RegisterBits = RegisterBits::new(0x80); + pub const CKDIV80: RegisterBits = RegisterBits::new(1<<7); + + pub const CKOUT: RegisterBits = RegisterBits::new(0x40); + pub const CKOUT0: RegisterBits = RegisterBits::new(1<<6); + + pub const SUT_CKSEL: RegisterBits = RegisterBits::new(0x3f); + pub const SUT_CKSEL0: RegisterBits = RegisterBits::new(1<<0); + pub const SUT_CKSEL1: RegisterBits = RegisterBits::new(1<<1); + pub const SUT_CKSEL2: RegisterBits = RegisterBits::new(1<<2); + pub const SUT_CKSEL3: RegisterBits = RegisterBits::new(1<<3); + pub const SUT_CKSEL4: RegisterBits = RegisterBits::new(1<<4); + pub const SUT_CKSEL5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for LOW { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOCKBIT; + +impl LOCKBIT { + pub const LB: RegisterBits = RegisterBits::new(0x3); + pub const LB0: RegisterBits = RegisterBits::new(1<<0); + pub const LB1: RegisterBits = RegisterBits::new(1<<1); + + pub const BLB0: RegisterBits = RegisterBits::new(0xc); + pub const BLB00: RegisterBits = RegisterBits::new(1<<2); + pub const BLB01: RegisterBits = RegisterBits::new(1<<3); + + pub const BLB1: RegisterBits = RegisterBits::new(0x30); + pub const BLB10: RegisterBits = RegisterBits::new(1<<4); + pub const BLB11: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for LOCKBIT { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x25 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x24 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x23 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTD; + +impl PORTD { +} + +impl Register for PORTD { + type T = u8; + const ADDRESS: *mut u8 = 0x2b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRD; + +impl DDRD { +} + +impl Register for DDRD { + type T = u8; + const ADDRESS: *mut u8 = 0x2a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PIND; + +impl PIND { +} + +impl Register for PIND { + type T = u8; + const ADDRESS: *mut u8 = 0x29 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTE; + +impl PORTE { +} + +impl Register for PORTE { + type T = u8; + const ADDRESS: *mut u8 = 0x2e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRE; + +impl DDRE { +} + +impl Register for DDRE { + type T = u8; + const ADDRESS: *mut u8 = 0x2d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINE; + +impl PINE { +} + +impl Register for PINE { + type T = u8; + const ADDRESS: *mut u8 = 0x2c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DACH; + +impl DACH { + pub const DACH: RegisterBits = RegisterBits::new(0xff); + pub const DACH0: RegisterBits = RegisterBits::new(1<<0); + pub const DACH1: RegisterBits = RegisterBits::new(1<<1); + pub const DACH2: RegisterBits = RegisterBits::new(1<<2); + pub const DACH3: RegisterBits = RegisterBits::new(1<<3); + pub const DACH4: RegisterBits = RegisterBits::new(1<<4); + pub const DACH5: RegisterBits = RegisterBits::new(1<<5); + pub const DACH6: RegisterBits = RegisterBits::new(1<<6); + pub const DACH7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for DACH { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DACL; + +impl DACL { + pub const DACL: RegisterBits = RegisterBits::new(0xff); + pub const DACL0: RegisterBits = RegisterBits::new(1<<0); + pub const DACL1: RegisterBits = RegisterBits::new(1<<1); + pub const DACL2: RegisterBits = RegisterBits::new(1<<2); + pub const DACL3: RegisterBits = RegisterBits::new(1<<3); + pub const DACL4: RegisterBits = RegisterBits::new(1<<4); + pub const DACL5: RegisterBits = RegisterBits::new(1<<5); + pub const DACL6: RegisterBits = RegisterBits::new(1<<6); + pub const DACL7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for DACL { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DACON; + +impl DACON { + pub const DAATE: RegisterBits = RegisterBits::new(0x80); + pub const DAATE0: RegisterBits = RegisterBits::new(1<<7); + + pub const DATS: RegisterBits = RegisterBits::new(0x70); + pub const DATS0: RegisterBits = RegisterBits::new(1<<4); + pub const DATS1: RegisterBits = RegisterBits::new(1<<5); + pub const DATS2: RegisterBits = RegisterBits::new(1<<6); + + pub const DALA: RegisterBits = RegisterBits::new(0x4); + pub const DALA0: RegisterBits = RegisterBits::new(1<<2); + + pub const DAEN: RegisterBits = RegisterBits::new(0x1); + pub const DAEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for DACON { + type T = u8; + const ADDRESS: *mut u8 = 0x76 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPCR; + +impl SPCR { + pub const SPIE: RegisterBits = RegisterBits::new(0x80); + pub const SPIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const SPE: RegisterBits = RegisterBits::new(0x40); + pub const SPE0: RegisterBits = RegisterBits::new(1<<6); + + pub const DORD: RegisterBits = RegisterBits::new(0x20); + pub const DORD0: RegisterBits = RegisterBits::new(1<<5); + + pub const MSTR: RegisterBits = RegisterBits::new(0x10); + pub const MSTR0: RegisterBits = RegisterBits::new(1<<4); + + pub const CPOL: RegisterBits = RegisterBits::new(0x8); + pub const CPOL0: RegisterBits = RegisterBits::new(1<<3); + + pub const CPHA: RegisterBits = RegisterBits::new(0x4); + pub const CPHA0: RegisterBits = RegisterBits::new(1<<2); + + pub const SPR: RegisterBits = RegisterBits::new(0x3); + pub const SPR0: RegisterBits = RegisterBits::new(1<<0); + pub const SPR1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for SPCR { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPSR; + +impl SPSR { + pub const SPIF: RegisterBits = RegisterBits::new(0x80); + pub const SPIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WCOL: RegisterBits = RegisterBits::new(0x40); + pub const WCOL0: RegisterBits = RegisterBits::new(1<<6); + + pub const SPI2X: RegisterBits = RegisterBits::new(0x1); + pub const SPI2X0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SPSR { + type T = u8; + const ADDRESS: *mut u8 = 0x38 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPDR; + +impl SPDR { +} + +impl Register for SPDR { + type T = u8; + const ADDRESS: *mut u8 = 0x56 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct WDTCSR; + +impl WDTCSR { + pub const WDIF: RegisterBits = RegisterBits::new(0x80); + pub const WDIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WDIE: RegisterBits = RegisterBits::new(0x40); + pub const WDIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const WDP: RegisterBits = RegisterBits::new(0x27); + pub const WDP0: RegisterBits = RegisterBits::new(1<<0); + pub const WDP1: RegisterBits = RegisterBits::new(1<<1); + pub const WDP2: RegisterBits = RegisterBits::new(1<<2); + pub const WDP3: RegisterBits = RegisterBits::new(1<<5); + + pub const WDCE: RegisterBits = RegisterBits::new(0x10); + pub const WDCE0: RegisterBits = RegisterBits::new(1<<4); + + pub const WDE: RegisterBits = RegisterBits::new(0x8); + pub const WDE0: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for WDTCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x82 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EICRA; + +impl EICRA { + pub const ISC2: RegisterBits = RegisterBits::new(0x30); + pub const ISC20: RegisterBits = RegisterBits::new(1<<4); + pub const ISC21: RegisterBits = RegisterBits::new(1<<5); + + pub const ISC1: RegisterBits = RegisterBits::new(0xc); + pub const ISC10: RegisterBits = RegisterBits::new(1<<2); + pub const ISC11: RegisterBits = RegisterBits::new(1<<3); + + pub const ISC0: RegisterBits = RegisterBits::new(0x3); + pub const ISC00: RegisterBits = RegisterBits::new(1<<0); + pub const ISC01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for EICRA { + type T = u8; + const ADDRESS: *mut u8 = 0x89 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EIMSK; + +impl EIMSK { + pub const INT: RegisterBits = RegisterBits::new(0x7); + pub const INT0: RegisterBits = RegisterBits::new(1<<0); + pub const INT1: RegisterBits = RegisterBits::new(1<<1); + pub const INT2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for EIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x41 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EIFR; + +impl EIFR { + pub const INTF: RegisterBits = RegisterBits::new(0x7); + pub const INTF0: RegisterBits = RegisterBits::new(1<<0); + pub const INTF1: RegisterBits = RegisterBits::new(1<<1); + pub const INTF2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for EIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x40 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADMUX; + +impl ADMUX { + pub const REFS: RegisterBits = RegisterBits::new(0xc0); + pub const REFS0: RegisterBits = RegisterBits::new(1<<6); + pub const REFS1: RegisterBits = RegisterBits::new(1<<7); + + pub const ADLAR: RegisterBits = RegisterBits::new(0x20); + pub const ADLAR0: RegisterBits = RegisterBits::new(1<<5); + + pub const MUX: RegisterBits = RegisterBits::new(0xf); + pub const MUX0: RegisterBits = RegisterBits::new(1<<0); + pub const MUX1: RegisterBits = RegisterBits::new(1<<1); + pub const MUX2: RegisterBits = RegisterBits::new(1<<2); + pub const MUX3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for ADMUX { + type T = u8; + const ADDRESS: *mut u8 = 0x28 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADCSRA; + +impl ADCSRA { + pub const ADEN: RegisterBits = RegisterBits::new(0x80); + pub const ADEN0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADSC: RegisterBits = RegisterBits::new(0x40); + pub const ADSC0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADATE: RegisterBits = RegisterBits::new(0x20); + pub const ADATE0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADIF: RegisterBits = RegisterBits::new(0x10); + pub const ADIF0: RegisterBits = RegisterBits::new(1<<4); + + pub const ADIE: RegisterBits = RegisterBits::new(0x8); + pub const ADIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADPS: RegisterBits = RegisterBits::new(0x7); + pub const ADPS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADPS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADPS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x26 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x4c as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ADCSRB; + +impl ADCSRB { + pub const ADHSM: RegisterBits = RegisterBits::new(0x80); + pub const ADHSM0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADNCDIS: RegisterBits = RegisterBits::new(0x40); + pub const ADNCDIS0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADSSEN: RegisterBits = RegisterBits::new(0x10); + pub const ADSSEN0: RegisterBits = RegisterBits::new(1<<4); + + pub const ADTS: RegisterBits = RegisterBits::new(0xf); + pub const ADTS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADTS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADTS2: RegisterBits = RegisterBits::new(1<<2); + pub const ADTS3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for ADCSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + pub const ADC7D: RegisterBits = RegisterBits::new(0x80); + pub const ADC7D0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADC6D: RegisterBits = RegisterBits::new(0x40); + pub const ADC6D0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADC5D: RegisterBits = RegisterBits::new(0x20); + pub const ADC5D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC4D: RegisterBits = RegisterBits::new(0x10); + pub const ADC4D0: RegisterBits = RegisterBits::new(1<<4); + + pub const ADC3D: RegisterBits = RegisterBits::new(0x8); + pub const ADC3D0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADC2D: RegisterBits = RegisterBits::new(0x4); + pub const ADC2D0: RegisterBits = RegisterBits::new(1<<2); + + pub const ADC1D: RegisterBits = RegisterBits::new(0x2); + pub const ADC1D0: RegisterBits = RegisterBits::new(1<<1); + + pub const ADC0D: RegisterBits = RegisterBits::new(0x1); + pub const ADC0D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for DIDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x77 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + pub const ACMP1MD: RegisterBits = RegisterBits::new(0x8); + pub const ACMP1MD0: RegisterBits = RegisterBits::new(1<<3); + + pub const AMP0POSD: RegisterBits = RegisterBits::new(0x4); + pub const AMP0POSD0: RegisterBits = RegisterBits::new(1<<2); + + pub const ADC10D: RegisterBits = RegisterBits::new(0x2); + pub const ADC10D0: RegisterBits = RegisterBits::new(1<<1); + + pub const ADC9D: RegisterBits = RegisterBits::new(0x1); + pub const ADC9D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x78 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct AMP0CSR; + +impl AMP0CSR { + pub const AMP0EN: RegisterBits = RegisterBits::new(0x80); + pub const AMP0EN0: RegisterBits = RegisterBits::new(1<<7); + + pub const AMP0IS: RegisterBits = RegisterBits::new(0x40); + pub const AMP0IS0: RegisterBits = RegisterBits::new(1<<6); + + pub const AMP0G: RegisterBits = RegisterBits::new(0x30); + pub const AMP0G0: RegisterBits = RegisterBits::new(1<<4); + pub const AMP0G1: RegisterBits = RegisterBits::new(1<<5); + + pub const AMP0GS: RegisterBits = RegisterBits::new(0x8); + pub const AMP0GS0: RegisterBits = RegisterBits::new(1<<3); + + pub const AMP0TS: RegisterBits = RegisterBits::new(0x3); + pub const AMP0TS0: RegisterBits = RegisterBits::new(1<<0); + pub const AMP0TS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for AMP0CSR { + type T = u8; + const ADDRESS: *mut u8 = 0x79 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct AC3CON; + +impl AC3CON { + pub const AC3EN: RegisterBits = RegisterBits::new(0x80); + pub const AC3EN0: RegisterBits = RegisterBits::new(1<<7); + + pub const AC3IE: RegisterBits = RegisterBits::new(0x40); + pub const AC3IE0: RegisterBits = RegisterBits::new(1<<6); + + pub const AC3IS: RegisterBits = RegisterBits::new(0x30); + pub const AC3IS0: RegisterBits = RegisterBits::new(1<<4); + pub const AC3IS1: RegisterBits = RegisterBits::new(1<<5); + + pub const AC3OEA: RegisterBits = RegisterBits::new(0x8); + pub const AC3OEA0: RegisterBits = RegisterBits::new(1<<3); + + pub const AC3M: RegisterBits = RegisterBits::new(0x7); + pub const AC3M0: RegisterBits = RegisterBits::new(1<<0); + pub const AC3M1: RegisterBits = RegisterBits::new(1<<1); + pub const AC3M2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for AC3CON { + type T = u8; + const ADDRESS: *mut u8 = 0x7f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct AC1CON; + +impl AC1CON { + pub const AC1EN: RegisterBits = RegisterBits::new(0x80); + pub const AC1EN0: RegisterBits = RegisterBits::new(1<<7); + + pub const AC1IE: RegisterBits = RegisterBits::new(0x40); + pub const AC1IE0: RegisterBits = RegisterBits::new(1<<6); + + pub const AC1IS: RegisterBits = RegisterBits::new(0x30); + pub const AC1IS0: RegisterBits = RegisterBits::new(1<<4); + pub const AC1IS1: RegisterBits = RegisterBits::new(1<<5); + + pub const AC1M: RegisterBits = RegisterBits::new(0x7); + pub const AC1M0: RegisterBits = RegisterBits::new(1<<0); + pub const AC1M1: RegisterBits = RegisterBits::new(1<<1); + pub const AC1M2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for AC1CON { + type T = u8; + const ADDRESS: *mut u8 = 0x7d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct AC2CON; + +impl AC2CON { + pub const AC2EN: RegisterBits = RegisterBits::new(0x80); + pub const AC2EN0: RegisterBits = RegisterBits::new(1<<7); + + pub const AC2IE: RegisterBits = RegisterBits::new(0x40); + pub const AC2IE0: RegisterBits = RegisterBits::new(1<<6); + + pub const AC2IS: RegisterBits = RegisterBits::new(0x30); + pub const AC2IS0: RegisterBits = RegisterBits::new(1<<4); + pub const AC2IS1: RegisterBits = RegisterBits::new(1<<5); + + pub const AC2M: RegisterBits = RegisterBits::new(0x7); + pub const AC2M0: RegisterBits = RegisterBits::new(1<<0); + pub const AC2M1: RegisterBits = RegisterBits::new(1<<1); + pub const AC2M2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for AC2CON { + type T = u8; + const ADDRESS: *mut u8 = 0x7e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSR; + +impl ACSR { + pub const AC3IF: RegisterBits = RegisterBits::new(0x80); + pub const AC3IF0: RegisterBits = RegisterBits::new(1<<7); + + pub const AC2IF: RegisterBits = RegisterBits::new(0x40); + pub const AC2IF0: RegisterBits = RegisterBits::new(1<<6); + + pub const AC1IF: RegisterBits = RegisterBits::new(0x20); + pub const AC1IF0: RegisterBits = RegisterBits::new(1<<5); + + pub const AC3O: RegisterBits = RegisterBits::new(0x8); + pub const AC3O0: RegisterBits = RegisterBits::new(1<<3); + + pub const AC2O: RegisterBits = RegisterBits::new(0x4); + pub const AC2O0: RegisterBits = RegisterBits::new(1<<2); + + pub const AC1O: RegisterBits = RegisterBits::new(0x2); + pub const AC1O0: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for ACSR { + type T = u8; + const ADDRESS: *mut u8 = 0x20 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct AC3ECON; + +impl AC3ECON { + pub const AC3OI: RegisterBits = RegisterBits::new(0x20); + pub const AC3OI0: RegisterBits = RegisterBits::new(1<<5); + + pub const AC3OE: RegisterBits = RegisterBits::new(0x10); + pub const AC3OE0: RegisterBits = RegisterBits::new(1<<4); + + pub const AC3H: RegisterBits = RegisterBits::new(0x7); + pub const AC3H0: RegisterBits = RegisterBits::new(1<<0); + pub const AC3H1: RegisterBits = RegisterBits::new(1<<1); + pub const AC3H2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for AC3ECON { + type T = u8; + const ADDRESS: *mut u8 = 0x7c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct AC2ECON; + +impl AC2ECON { + pub const AC2OI: RegisterBits = RegisterBits::new(0x20); + pub const AC2OI0: RegisterBits = RegisterBits::new(1<<5); + + pub const AC2OE: RegisterBits = RegisterBits::new(0x10); + pub const AC2OE0: RegisterBits = RegisterBits::new(1<<4); + + pub const AC2H: RegisterBits = RegisterBits::new(0x7); + pub const AC2H0: RegisterBits = RegisterBits::new(1<<0); + pub const AC2H1: RegisterBits = RegisterBits::new(1<<1); + pub const AC2H2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for AC2ECON { + type T = u8; + const ADDRESS: *mut u8 = 0x7b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct AC1ECON; + +impl AC1ECON { + pub const AC1OI: RegisterBits = RegisterBits::new(0x20); + pub const AC1OI0: RegisterBits = RegisterBits::new(1<<5); + + pub const AC1OE: RegisterBits = RegisterBits::new(0x10); + pub const AC1OE0: RegisterBits = RegisterBits::new(1<<4); + + pub const AC1ICE: RegisterBits = RegisterBits::new(0x8); + pub const AC1ICE0: RegisterBits = RegisterBits::new(1<<3); + + pub const AC1H: RegisterBits = RegisterBits::new(0x7); + pub const AC1H0: RegisterBits = RegisterBits::new(1<<0); + pub const AC1H1: RegisterBits = RegisterBits::new(1<<1); + pub const AC1H2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for AC1ECON { + type T = u8; + const ADDRESS: *mut u8 = 0x7a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SREG; + +impl SREG { + pub const I: RegisterBits = RegisterBits::new(0x80); + pub const I0: RegisterBits = RegisterBits::new(1<<7); + + pub const T: RegisterBits = RegisterBits::new(0x40); + pub const T0: RegisterBits = RegisterBits::new(1<<6); + + pub const H: RegisterBits = RegisterBits::new(0x20); + pub const H0: RegisterBits = RegisterBits::new(1<<5); + + pub const S: RegisterBits = RegisterBits::new(0x10); + pub const S0: RegisterBits = RegisterBits::new(1<<4); + + pub const V: RegisterBits = RegisterBits::new(0x8); + pub const V0: RegisterBits = RegisterBits::new(1<<3); + + pub const N: RegisterBits = RegisterBits::new(0x4); + pub const N0: RegisterBits = RegisterBits::new(1<<2); + + pub const Z: RegisterBits = RegisterBits::new(0x2); + pub const Z0: RegisterBits = RegisterBits::new(1<<1); + + pub const C: RegisterBits = RegisterBits::new(0x1); + pub const C0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SREG { + type T = u8; + const ADDRESS: *mut u8 = 0x5f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SP; + +impl SP { +} + +impl Register for SP { + type T = u16; + const ADDRESS: *mut u16 = 0x5d as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const PUD: RegisterBits = RegisterBits::new(0x10); + pub const PUD0: RegisterBits = RegisterBits::new(1<<4); + + pub const RSTDIS: RegisterBits = RegisterBits::new(0x8); + pub const RSTDIS0: RegisterBits = RegisterBits::new(1<<3); + + pub const CKRC81: RegisterBits = RegisterBits::new(0x4); + pub const CKRC810: RegisterBits = RegisterBits::new(1<<2); + + pub const IVSEL: RegisterBits = RegisterBits::new(0x2); + pub const IVSEL0: RegisterBits = RegisterBits::new(1<<1); + + pub const IVCE: RegisterBits = RegisterBits::new(0x1); + pub const IVCE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUSR; + +impl MCUSR { + pub const WDRF: RegisterBits = RegisterBits::new(0x8); + pub const WDRF0: RegisterBits = RegisterBits::new(1<<3); + + pub const BORF: RegisterBits = RegisterBits::new(0x4); + pub const BORF0: RegisterBits = RegisterBits::new(1<<2); + + pub const EXTRF: RegisterBits = RegisterBits::new(0x2); + pub const EXTRF0: RegisterBits = RegisterBits::new(1<<1); + + pub const PORF: RegisterBits = RegisterBits::new(0x1); + pub const PORF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUSR { + type T = u8; + const ADDRESS: *mut u8 = 0x54 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCCAL; + +impl OSCCAL { + pub const OSCCAL: RegisterBits = RegisterBits::new(0xff); + pub const OSCCAL0: RegisterBits = RegisterBits::new(1<<0); + pub const OSCCAL1: RegisterBits = RegisterBits::new(1<<1); + pub const OSCCAL2: RegisterBits = RegisterBits::new(1<<2); + pub const OSCCAL3: RegisterBits = RegisterBits::new(1<<3); + pub const OSCCAL4: RegisterBits = RegisterBits::new(1<<4); + pub const OSCCAL5: RegisterBits = RegisterBits::new(1<<5); + pub const OSCCAL6: RegisterBits = RegisterBits::new(1<<6); + pub const OSCCAL7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OSCCAL { + type T = u8; + const ADDRESS: *mut u8 = 0x88 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKPR; + +impl CLKPR { + pub const CLKPCE: RegisterBits = RegisterBits::new(0x80); + pub const CLKPCE0: RegisterBits = RegisterBits::new(1<<7); + + pub const CLKPS: RegisterBits = RegisterBits::new(0xf); + pub const CLKPS0: RegisterBits = RegisterBits::new(1<<0); + pub const CLKPS1: RegisterBits = RegisterBits::new(1<<1); + pub const CLKPS2: RegisterBits = RegisterBits::new(1<<2); + pub const CLKPS3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CLKPR { + type T = u8; + const ADDRESS: *mut u8 = 0x83 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SMCR; + +impl SMCR { + pub const SM: RegisterBits = RegisterBits::new(0xe); + pub const SM0: RegisterBits = RegisterBits::new(1<<1); + pub const SM1: RegisterBits = RegisterBits::new(1<<2); + pub const SM2: RegisterBits = RegisterBits::new(1<<3); + + pub const SE: RegisterBits = RegisterBits::new(0x1); + pub const SE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SMCR { + type T = u8; + const ADDRESS: *mut u8 = 0x53 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR2; + +impl GPIOR2 { + pub const GPIOR: RegisterBits = RegisterBits::new(0xff); + pub const GPIOR0: RegisterBits = RegisterBits::new(1<<0); + pub const GPIOR1: RegisterBits = RegisterBits::new(1<<1); + pub const GPIOR2: RegisterBits = RegisterBits::new(1<<2); + pub const GPIOR3: RegisterBits = RegisterBits::new(1<<3); + pub const GPIOR4: RegisterBits = RegisterBits::new(1<<4); + pub const GPIOR5: RegisterBits = RegisterBits::new(1<<5); + pub const GPIOR6: RegisterBits = RegisterBits::new(1<<6); + pub const GPIOR7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for GPIOR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR1; + +impl GPIOR1 { + pub const GPIOR: RegisterBits = RegisterBits::new(0xff); + pub const GPIOR0: RegisterBits = RegisterBits::new(1<<0); + pub const GPIOR1: RegisterBits = RegisterBits::new(1<<1); + pub const GPIOR2: RegisterBits = RegisterBits::new(1<<2); + pub const GPIOR3: RegisterBits = RegisterBits::new(1<<3); + pub const GPIOR4: RegisterBits = RegisterBits::new(1<<4); + pub const GPIOR5: RegisterBits = RegisterBits::new(1<<5); + pub const GPIOR6: RegisterBits = RegisterBits::new(1<<6); + pub const GPIOR7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for GPIOR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x3a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR0; + +impl GPIOR0 { + pub const GPIOR07: RegisterBits = RegisterBits::new(0x80); + pub const GPIOR070: RegisterBits = RegisterBits::new(1<<7); + + pub const GPIOR06: RegisterBits = RegisterBits::new(0x40); + pub const GPIOR060: RegisterBits = RegisterBits::new(1<<6); + + pub const GPIOR05: RegisterBits = RegisterBits::new(0x20); + pub const GPIOR050: RegisterBits = RegisterBits::new(1<<5); + + pub const GPIOR04: RegisterBits = RegisterBits::new(0x10); + pub const GPIOR040: RegisterBits = RegisterBits::new(1<<4); + + pub const GPIOR03: RegisterBits = RegisterBits::new(0x8); + pub const GPIOR030: RegisterBits = RegisterBits::new(1<<3); + + pub const GPIOR02: RegisterBits = RegisterBits::new(0x4); + pub const GPIOR020: RegisterBits = RegisterBits::new(1<<2); + + pub const GPIOR01: RegisterBits = RegisterBits::new(0x2); + pub const GPIOR010: RegisterBits = RegisterBits::new(1<<1); + + pub const GPIOR00: RegisterBits = RegisterBits::new(0x1); + pub const GPIOR000: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for GPIOR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x39 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PLLCSR; + +impl PLLCSR { + pub const PLLF: RegisterBits = RegisterBits::new(0x3c); + pub const PLLF0: RegisterBits = RegisterBits::new(1<<2); + pub const PLLF1: RegisterBits = RegisterBits::new(1<<3); + pub const PLLF2: RegisterBits = RegisterBits::new(1<<4); + pub const PLLF3: RegisterBits = RegisterBits::new(1<<5); + + pub const PLLE: RegisterBits = RegisterBits::new(0x2); + pub const PLLE0: RegisterBits = RegisterBits::new(1<<1); + + pub const PLOCK: RegisterBits = RegisterBits::new(0x1); + pub const PLOCK0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PLLCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x87 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRPSC2: RegisterBits = RegisterBits::new(0x80); + pub const PRPSC20: RegisterBits = RegisterBits::new(1<<7); + + pub const PRPSCR: RegisterBits = RegisterBits::new(0x20); + pub const PRPSCR0: RegisterBits = RegisterBits::new(1<<5); + + pub const PRTIM1: RegisterBits = RegisterBits::new(0x10); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<4); + + pub const PRSPI: RegisterBits = RegisterBits::new(0x4); + pub const PRSPI0: RegisterBits = RegisterBits::new(1<<2); + + pub const PRADC: RegisterBits = RegisterBits::new(0x1); + pub const PRADC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PRR { + type T = u8; + const ADDRESS: *mut u8 = 0x86 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKCSR; + +impl CLKCSR { + pub const CLKCCE: RegisterBits = RegisterBits::new(0x80); + pub const CLKCCE0: RegisterBits = RegisterBits::new(1<<7); + + pub const CLKRDY: RegisterBits = RegisterBits::new(0x10); + pub const CLKRDY0: RegisterBits = RegisterBits::new(1<<4); + + pub const CLKC: RegisterBits = RegisterBits::new(0xf); + pub const CLKC0: RegisterBits = RegisterBits::new(1<<0); + pub const CLKC1: RegisterBits = RegisterBits::new(1<<1); + pub const CLKC2: RegisterBits = RegisterBits::new(1<<2); + pub const CLKC3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CLKCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x84 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKSELR; + +impl CLKSELR { + pub const COUT: RegisterBits = RegisterBits::new(0x40); + pub const COUT0: RegisterBits = RegisterBits::new(1<<6); + + pub const CSUT: RegisterBits = RegisterBits::new(0x30); + pub const CSUT0: RegisterBits = RegisterBits::new(1<<4); + pub const CSUT1: RegisterBits = RegisterBits::new(1<<5); + + pub const CKSEL: RegisterBits = RegisterBits::new(0xf); + pub const CKSEL0: RegisterBits = RegisterBits::new(1<<0); + pub const CKSEL1: RegisterBits = RegisterBits::new(1<<1); + pub const CKSEL2: RegisterBits = RegisterBits::new(1<<2); + pub const CKSEL3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CLKSELR { + type T = u8; + const ADDRESS: *mut u8 = 0x85 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct BGCCR; + +impl BGCCR { + pub const BGCC: RegisterBits = RegisterBits::new(0xf); + pub const BGCC0: RegisterBits = RegisterBits::new(1<<0); + pub const BGCC1: RegisterBits = RegisterBits::new(1<<1); + pub const BGCC2: RegisterBits = RegisterBits::new(1<<2); + pub const BGCC3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for BGCCR { + type T = u8; + const ADDRESS: *mut u8 = 0x81 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct BGCRR; + +impl BGCRR { + pub const BGCR: RegisterBits = RegisterBits::new(0xf); + pub const BGCR0: RegisterBits = RegisterBits::new(1<<0); + pub const BGCR1: RegisterBits = RegisterBits::new(1<<1); + pub const BGCR2: RegisterBits = RegisterBits::new(1<<2); + pub const BGCR3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for BGCRR { + type T = u8; + const ADDRESS: *mut u8 = 0x80 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEAR; + +impl EEAR { +} + +impl Register for EEAR { + type T = u16; + const ADDRESS: *mut u16 = 0x3e as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct EEDR; + +impl EEDR { +} + +impl Register for EEDR { + type T = u8; + const ADDRESS: *mut u8 = 0x3d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EECR; + +impl EECR { + pub const NVMBSY: RegisterBits = RegisterBits::new(0x80); + pub const NVMBSY0: RegisterBits = RegisterBits::new(1<<7); + + pub const EEPAGE: RegisterBits = RegisterBits::new(0x40); + pub const EEPAGE0: RegisterBits = RegisterBits::new(1<<6); + + pub const EEPM: RegisterBits = RegisterBits::new(0x30); + pub const EEPM0: RegisterBits = RegisterBits::new(1<<4); + pub const EEPM1: RegisterBits = RegisterBits::new(1<<5); + + pub const EERIE: RegisterBits = RegisterBits::new(0x8); + pub const EERIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const EEMWE: RegisterBits = RegisterBits::new(0x4); + pub const EEMWE0: RegisterBits = RegisterBits::new(1<<2); + + pub const EEWE: RegisterBits = RegisterBits::new(0x2); + pub const EEWE0: RegisterBits = RegisterBits::new(1<<1); + + pub const EERE: RegisterBits = RegisterBits::new(0x1); + pub const EERE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EECR { + type T = u8; + const ADDRESS: *mut u8 = 0x3c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PICR0; + +impl PICR0 { +} + +impl Register for PICR0 { + type T = u16; + const ADDRESS: *mut u16 = 0x68 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct PFRC0B; + +impl PFRC0B { + pub const PCAE0B: RegisterBits = RegisterBits::new(0x80); + pub const PCAE0B0: RegisterBits = RegisterBits::new(1<<7); + + pub const PISEL0B: RegisterBits = RegisterBits::new(0x40); + pub const PISEL0B0: RegisterBits = RegisterBits::new(1<<6); + + pub const PELEV0B: RegisterBits = RegisterBits::new(0x20); + pub const PELEV0B0: RegisterBits = RegisterBits::new(1<<5); + + pub const PFLTE0B: RegisterBits = RegisterBits::new(0x10); + pub const PFLTE0B0: RegisterBits = RegisterBits::new(1<<4); + + pub const PRFM0B: RegisterBits = RegisterBits::new(0xf); + pub const PRFM0B0: RegisterBits = RegisterBits::new(1<<0); + pub const PRFM0B1: RegisterBits = RegisterBits::new(1<<1); + pub const PRFM0B2: RegisterBits = RegisterBits::new(1<<2); + pub const PRFM0B3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for PFRC0B { + type T = u8; + const ADDRESS: *mut u8 = 0x63 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PFRC0A; + +impl PFRC0A { + pub const PCAE0A: RegisterBits = RegisterBits::new(0x80); + pub const PCAE0A0: RegisterBits = RegisterBits::new(1<<7); + + pub const PISEL0A: RegisterBits = RegisterBits::new(0x40); + pub const PISEL0A0: RegisterBits = RegisterBits::new(1<<6); + + pub const PELEV0A: RegisterBits = RegisterBits::new(0x20); + pub const PELEV0A0: RegisterBits = RegisterBits::new(1<<5); + + pub const PFLTE0A: RegisterBits = RegisterBits::new(0x10); + pub const PFLTE0A0: RegisterBits = RegisterBits::new(1<<4); + + pub const PRFM0A: RegisterBits = RegisterBits::new(0xf); + pub const PRFM0A0: RegisterBits = RegisterBits::new(1<<0); + pub const PRFM0A1: RegisterBits = RegisterBits::new(1<<1); + pub const PRFM0A2: RegisterBits = RegisterBits::new(1<<2); + pub const PRFM0A3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for PFRC0A { + type T = u8; + const ADDRESS: *mut u8 = 0x62 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCTL0; + +impl PCTL0 { + pub const PPRE0: RegisterBits = RegisterBits::new(0xc0); + pub const PPRE00: RegisterBits = RegisterBits::new(1<<6); + pub const PPRE01: RegisterBits = RegisterBits::new(1<<7); + + pub const PBFM0: RegisterBits = RegisterBits::new(0x24); + pub const PBFM00: RegisterBits = RegisterBits::new(1<<2); + pub const PBFM01: RegisterBits = RegisterBits::new(1<<5); + + pub const PAOC0B: RegisterBits = RegisterBits::new(0x10); + pub const PAOC0B0: RegisterBits = RegisterBits::new(1<<4); + + pub const PAOC0A: RegisterBits = RegisterBits::new(0x8); + pub const PAOC0A0: RegisterBits = RegisterBits::new(1<<3); + + pub const PCCYC0: RegisterBits = RegisterBits::new(0x2); + pub const PCCYC00: RegisterBits = RegisterBits::new(1<<1); + + pub const PRUN0: RegisterBits = RegisterBits::new(0x1); + pub const PRUN00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PCTL0 { + type T = u8; + const ADDRESS: *mut u8 = 0x32 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCNF0; + +impl PCNF0 { + pub const PFIFTY0: RegisterBits = RegisterBits::new(0x80); + pub const PFIFTY00: RegisterBits = RegisterBits::new(1<<7); + + pub const PALOCK0: RegisterBits = RegisterBits::new(0x40); + pub const PALOCK00: RegisterBits = RegisterBits::new(1<<6); + + pub const PLOCK0: RegisterBits = RegisterBits::new(0x20); + pub const PLOCK00: RegisterBits = RegisterBits::new(1<<5); + + pub const PMODE0: RegisterBits = RegisterBits::new(0x18); + pub const PMODE00: RegisterBits = RegisterBits::new(1<<3); + pub const PMODE01: RegisterBits = RegisterBits::new(1<<4); + + pub const POP0: RegisterBits = RegisterBits::new(0x4); + pub const POP00: RegisterBits = RegisterBits::new(1<<2); + + pub const PCLKSEL0: RegisterBits = RegisterBits::new(0x2); + pub const PCLKSEL00: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for PCNF0 { + type T = u8; + const ADDRESS: *mut u8 = 0x31 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0RB; + +impl OCR0RB { +} + +impl Register for OCR0RB { + type T = u16; + const ADDRESS: *mut u16 = 0x44 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR0SB; + +impl OCR0SB { +} + +impl Register for OCR0SB { + type T = u16; + const ADDRESS: *mut u16 = 0x42 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR0RA; + +impl OCR0RA { +} + +impl Register for OCR0RA { + type T = u16; + const ADDRESS: *mut u16 = 0x4a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR0SA; + +impl OCR0SA { +} + +impl Register for OCR0SA { + type T = u16; + const ADDRESS: *mut u16 = 0x60 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct PSOC0; + +impl PSOC0 { + pub const PISEL0A1: RegisterBits = RegisterBits::new(0x80); + pub const PISEL0A10: RegisterBits = RegisterBits::new(1<<7); + + pub const PISEL0B1: RegisterBits = RegisterBits::new(0x40); + pub const PISEL0B10: RegisterBits = RegisterBits::new(1<<6); + + pub const PSYNC0: RegisterBits = RegisterBits::new(0x30); + pub const PSYNC00: RegisterBits = RegisterBits::new(1<<4); + pub const PSYNC01: RegisterBits = RegisterBits::new(1<<5); + + pub const POEN0B: RegisterBits = RegisterBits::new(0x4); + pub const POEN0B0: RegisterBits = RegisterBits::new(1<<2); + + pub const POEN0A: RegisterBits = RegisterBits::new(0x1); + pub const POEN0A0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PSOC0 { + type T = u8; + const ADDRESS: *mut u8 = 0x6a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PIM0; + +impl PIM0 { + pub const PEVE0B: RegisterBits = RegisterBits::new(0x10); + pub const PEVE0B0: RegisterBits = RegisterBits::new(1<<4); + + pub const PEVE0A: RegisterBits = RegisterBits::new(0x8); + pub const PEVE0A0: RegisterBits = RegisterBits::new(1<<3); + + pub const PEOEPE0: RegisterBits = RegisterBits::new(0x2); + pub const PEOEPE00: RegisterBits = RegisterBits::new(1<<1); + + pub const PEOPE0: RegisterBits = RegisterBits::new(0x1); + pub const PEOPE00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PIM0 { + type T = u8; + const ADDRESS: *mut u8 = 0x2f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PIFR0; + +impl PIFR0 { + pub const POAC0B: RegisterBits = RegisterBits::new(0x80); + pub const POAC0B0: RegisterBits = RegisterBits::new(1<<7); + + pub const POAC0A: RegisterBits = RegisterBits::new(0x40); + pub const POAC0A0: RegisterBits = RegisterBits::new(1<<6); + + pub const PEV0B: RegisterBits = RegisterBits::new(0x10); + pub const PEV0B0: RegisterBits = RegisterBits::new(1<<4); + + pub const PEV0A: RegisterBits = RegisterBits::new(0x8); + pub const PEV0A0: RegisterBits = RegisterBits::new(1<<3); + + pub const PRN0: RegisterBits = RegisterBits::new(0x6); + pub const PRN00: RegisterBits = RegisterBits::new(1<<1); + pub const PRN01: RegisterBits = RegisterBits::new(1<<2); + + pub const PEOP0: RegisterBits = RegisterBits::new(0x1); + pub const PEOP00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PIFR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x30 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PICR2H; + +impl PICR2H { + pub const PCST2: RegisterBits = RegisterBits::new(0x80); + pub const PCST20: RegisterBits = RegisterBits::new(1<<7); + + pub const PICR21: RegisterBits = RegisterBits::new(0xc); + pub const PICR210: RegisterBits = RegisterBits::new(1<<2); + pub const PICR211: RegisterBits = RegisterBits::new(1<<3); + + pub const PICR2: RegisterBits = RegisterBits::new(0x3); + pub const PICR20: RegisterBits = RegisterBits::new(1<<0); + pub const PICR21: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for PICR2H { + type T = u8; + const ADDRESS: *mut u8 = 0x6d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PICR2L; + +impl PICR2L { +} + +impl Register for PICR2L { + type T = u8; + const ADDRESS: *mut u8 = 0x6c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PFRC2B; + +impl PFRC2B { + pub const PCAE2B: RegisterBits = RegisterBits::new(0x80); + pub const PCAE2B0: RegisterBits = RegisterBits::new(1<<7); + + pub const PISEL2B: RegisterBits = RegisterBits::new(0x40); + pub const PISEL2B0: RegisterBits = RegisterBits::new(1<<6); + + pub const PELEV2B: RegisterBits = RegisterBits::new(0x20); + pub const PELEV2B0: RegisterBits = RegisterBits::new(1<<5); + + pub const PFLTE2B: RegisterBits = RegisterBits::new(0x10); + pub const PFLTE2B0: RegisterBits = RegisterBits::new(1<<4); + + pub const PRFM2B: RegisterBits = RegisterBits::new(0xf); + pub const PRFM2B0: RegisterBits = RegisterBits::new(1<<0); + pub const PRFM2B1: RegisterBits = RegisterBits::new(1<<1); + pub const PRFM2B2: RegisterBits = RegisterBits::new(1<<2); + pub const PRFM2B3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for PFRC2B { + type T = u8; + const ADDRESS: *mut u8 = 0x67 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PFRC2A; + +impl PFRC2A { + pub const PCAE2A: RegisterBits = RegisterBits::new(0x80); + pub const PCAE2A0: RegisterBits = RegisterBits::new(1<<7); + + pub const PISEL2A: RegisterBits = RegisterBits::new(0x40); + pub const PISEL2A0: RegisterBits = RegisterBits::new(1<<6); + + pub const PELEV2A: RegisterBits = RegisterBits::new(0x20); + pub const PELEV2A0: RegisterBits = RegisterBits::new(1<<5); + + pub const PFLTE2A: RegisterBits = RegisterBits::new(0x10); + pub const PFLTE2A0: RegisterBits = RegisterBits::new(1<<4); + + pub const PRFM2A: RegisterBits = RegisterBits::new(0xf); + pub const PRFM2A0: RegisterBits = RegisterBits::new(1<<0); + pub const PRFM2A1: RegisterBits = RegisterBits::new(1<<1); + pub const PRFM2A2: RegisterBits = RegisterBits::new(1<<2); + pub const PRFM2A3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for PFRC2A { + type T = u8; + const ADDRESS: *mut u8 = 0x66 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCTL2; + +impl PCTL2 { + pub const PPRE2: RegisterBits = RegisterBits::new(0xc0); + pub const PPRE20: RegisterBits = RegisterBits::new(1<<6); + pub const PPRE21: RegisterBits = RegisterBits::new(1<<7); + + pub const PBFM2: RegisterBits = RegisterBits::new(0x20); + pub const PBFM20: RegisterBits = RegisterBits::new(1<<5); + + pub const PAOC2B: RegisterBits = RegisterBits::new(0x10); + pub const PAOC2B0: RegisterBits = RegisterBits::new(1<<4); + + pub const PAOC2A: RegisterBits = RegisterBits::new(0x8); + pub const PAOC2A0: RegisterBits = RegisterBits::new(1<<3); + + pub const PARUN2: RegisterBits = RegisterBits::new(0x4); + pub const PARUN20: RegisterBits = RegisterBits::new(1<<2); + + pub const PCCYC2: RegisterBits = RegisterBits::new(0x2); + pub const PCCYC20: RegisterBits = RegisterBits::new(1<<1); + + pub const PRUN2: RegisterBits = RegisterBits::new(0x1); + pub const PRUN20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PCTL2 { + type T = u8; + const ADDRESS: *mut u8 = 0x36 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCNF2; + +impl PCNF2 { + pub const PFIFTY2: RegisterBits = RegisterBits::new(0x80); + pub const PFIFTY20: RegisterBits = RegisterBits::new(1<<7); + + pub const PALOCK2: RegisterBits = RegisterBits::new(0x40); + pub const PALOCK20: RegisterBits = RegisterBits::new(1<<6); + + pub const PLOCK2: RegisterBits = RegisterBits::new(0x20); + pub const PLOCK20: RegisterBits = RegisterBits::new(1<<5); + + pub const PMODE2: RegisterBits = RegisterBits::new(0x18); + pub const PMODE20: RegisterBits = RegisterBits::new(1<<3); + pub const PMODE21: RegisterBits = RegisterBits::new(1<<4); + + pub const POP2: RegisterBits = RegisterBits::new(0x4); + pub const POP20: RegisterBits = RegisterBits::new(1<<2); + + pub const PCLKSEL2: RegisterBits = RegisterBits::new(0x2); + pub const PCLKSEL20: RegisterBits = RegisterBits::new(1<<1); + + pub const POME2: RegisterBits = RegisterBits::new(0x1); + pub const POME20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PCNF2 { + type T = u8; + const ADDRESS: *mut u8 = 0x35 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCNFE2; + +impl PCNFE2 { + pub const PASDLK2: RegisterBits = RegisterBits::new(0xe0); + pub const PASDLK20: RegisterBits = RegisterBits::new(1<<5); + pub const PASDLK21: RegisterBits = RegisterBits::new(1<<6); + pub const PASDLK22: RegisterBits = RegisterBits::new(1<<7); + + pub const PBFM21: RegisterBits = RegisterBits::new(0x10); + pub const PBFM210: RegisterBits = RegisterBits::new(1<<4); + + pub const PELEV2A1: RegisterBits = RegisterBits::new(0x8); + pub const PELEV2A10: RegisterBits = RegisterBits::new(1<<3); + + pub const PELEV2B1: RegisterBits = RegisterBits::new(0x4); + pub const PELEV2B10: RegisterBits = RegisterBits::new(1<<2); + + pub const PISEL2A1: RegisterBits = RegisterBits::new(0x2); + pub const PISEL2A10: RegisterBits = RegisterBits::new(1<<1); + + pub const PISEL2B1: RegisterBits = RegisterBits::new(0x1); + pub const PISEL2B10: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PCNFE2 { + type T = u8; + const ADDRESS: *mut u8 = 0x70 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2RB; + +impl OCR2RB { +} + +impl Register for OCR2RB { + type T = u16; + const ADDRESS: *mut u16 = 0x48 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR2SB; + +impl OCR2SB { +} + +impl Register for OCR2SB { + type T = u16; + const ADDRESS: *mut u16 = 0x46 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR2RA; + +impl OCR2RA { +} + +impl Register for OCR2RA { + type T = u16; + const ADDRESS: *mut u16 = 0x4e as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR2SA; + +impl OCR2SA { +} + +impl Register for OCR2SA { + type T = u16; + const ADDRESS: *mut u16 = 0x64 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct POM2; + +impl POM2 { + pub const POMV2B: RegisterBits = RegisterBits::new(0xf0); + pub const POMV2B0: RegisterBits = RegisterBits::new(1<<4); + pub const POMV2B1: RegisterBits = RegisterBits::new(1<<5); + pub const POMV2B2: RegisterBits = RegisterBits::new(1<<6); + pub const POMV2B3: RegisterBits = RegisterBits::new(1<<7); + + pub const POMV2A: RegisterBits = RegisterBits::new(0xf); + pub const POMV2A0: RegisterBits = RegisterBits::new(1<<0); + pub const POMV2A1: RegisterBits = RegisterBits::new(1<<1); + pub const POMV2A2: RegisterBits = RegisterBits::new(1<<2); + pub const POMV2A3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for POM2 { + type T = u8; + const ADDRESS: *mut u8 = 0x6f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PSOC2; + +impl PSOC2 { + pub const POS2: RegisterBits = RegisterBits::new(0xc0); + pub const POS20: RegisterBits = RegisterBits::new(1<<6); + pub const POS21: RegisterBits = RegisterBits::new(1<<7); + + pub const PSYNC2: RegisterBits = RegisterBits::new(0x30); + pub const PSYNC20: RegisterBits = RegisterBits::new(1<<4); + pub const PSYNC21: RegisterBits = RegisterBits::new(1<<5); + + pub const POEN2D: RegisterBits = RegisterBits::new(0x8); + pub const POEN2D0: RegisterBits = RegisterBits::new(1<<3); + + pub const POEN2B: RegisterBits = RegisterBits::new(0x4); + pub const POEN2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const POEN2C: RegisterBits = RegisterBits::new(0x2); + pub const POEN2C0: RegisterBits = RegisterBits::new(1<<1); + + pub const POEN2A: RegisterBits = RegisterBits::new(0x1); + pub const POEN2A0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PSOC2 { + type T = u8; + const ADDRESS: *mut u8 = 0x6e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PIM2; + +impl PIM2 { + pub const PSEIE2: RegisterBits = RegisterBits::new(0x20); + pub const PSEIE20: RegisterBits = RegisterBits::new(1<<5); + + pub const PEVE2B: RegisterBits = RegisterBits::new(0x10); + pub const PEVE2B0: RegisterBits = RegisterBits::new(1<<4); + + pub const PEVE2A: RegisterBits = RegisterBits::new(0x8); + pub const PEVE2A0: RegisterBits = RegisterBits::new(1<<3); + + pub const PEOEPE2: RegisterBits = RegisterBits::new(0x2); + pub const PEOEPE20: RegisterBits = RegisterBits::new(1<<1); + + pub const PEOPE2: RegisterBits = RegisterBits::new(0x1); + pub const PEOPE20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PIM2 { + type T = u8; + const ADDRESS: *mut u8 = 0x33 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PIFR2; + +impl PIFR2 { + pub const POAC2B: RegisterBits = RegisterBits::new(0x80); + pub const POAC2B0: RegisterBits = RegisterBits::new(1<<7); + + pub const POAC2A: RegisterBits = RegisterBits::new(0x40); + pub const POAC2A0: RegisterBits = RegisterBits::new(1<<6); + + pub const PSEI2: RegisterBits = RegisterBits::new(0x20); + pub const PSEI20: RegisterBits = RegisterBits::new(1<<5); + + pub const PEV2B: RegisterBits = RegisterBits::new(0x10); + pub const PEV2B0: RegisterBits = RegisterBits::new(1<<4); + + pub const PEV2A: RegisterBits = RegisterBits::new(0x8); + pub const PEV2A0: RegisterBits = RegisterBits::new(1<<3); + + pub const PRN2: RegisterBits = RegisterBits::new(0x6); + pub const PRN20: RegisterBits = RegisterBits::new(1<<1); + pub const PRN21: RegisterBits = RegisterBits::new(1<<2); + + pub const PEOP2: RegisterBits = RegisterBits::new(0x1); + pub const PEOP20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PIFR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x34 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PASDLY2; + +impl PASDLY2 { +} + +impl Register for PASDLY2 { + type T = u8; + const ADDRESS: *mut u8 = 0x71 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK1; + +impl TIMSK1 { + pub const ICIE1: RegisterBits = RegisterBits::new(0x20); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<5); + + pub const TOIE1: RegisterBits = RegisterBits::new(0x1); + pub const TOIE10: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x21 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR1; + +impl TIFR1 { + pub const ICF1: RegisterBits = RegisterBits::new(0x20); + pub const ICF10: RegisterBits = RegisterBits::new(1<<5); + + pub const TOV1: RegisterBits = RegisterBits::new(0x1); + pub const TOV10: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x22 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1B; + +impl TCCR1B { + pub const ICNC1: RegisterBits = RegisterBits::new(0x80); + pub const ICNC10: RegisterBits = RegisterBits::new(1<<7); + + pub const ICES1: RegisterBits = RegisterBits::new(0x40); + pub const ICES10: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM13: RegisterBits = RegisterBits::new(0x10); + pub const WGM130: RegisterBits = RegisterBits::new(1<<4); + + pub const CS1: RegisterBits = RegisterBits::new(0x7); + pub const CS10: RegisterBits = RegisterBits::new(1<<0); + pub const CS11: RegisterBits = RegisterBits::new(1<<1); + pub const CS12: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x8a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT1; + +impl TCNT1 { +} + +impl Register for TCNT1 { + type T = u16; + const ADDRESS: *mut u16 = 0x5a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x8c as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct SPMCSR; + +impl SPMCSR { + pub const SPMIE: RegisterBits = RegisterBits::new(0x80); + pub const SPMIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const RWWSB: RegisterBits = RegisterBits::new(0x40); + pub const RWWSB0: RegisterBits = RegisterBits::new(1<<6); + + pub const SIGRD: RegisterBits = RegisterBits::new(0x20); + pub const SIGRD0: RegisterBits = RegisterBits::new(1<<5); + + pub const RWWSRE: RegisterBits = RegisterBits::new(0x10); + pub const RWWSRE0: RegisterBits = RegisterBits::new(1<<4); + + pub const BLBSET: RegisterBits = RegisterBits::new(0x8); + pub const BLBSET0: RegisterBits = RegisterBits::new(1<<3); + + pub const PGWRT: RegisterBits = RegisterBits::new(0x4); + pub const PGWRT0: RegisterBits = RegisterBits::new(1<<2); + + pub const PGERS: RegisterBits = RegisterBits::new(0x2); + pub const PGERS0: RegisterBits = RegisterBits::new(1<<1); + + pub const SPMEN: RegisterBits = RegisterBits::new(0x1); + pub const SPMEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SPMCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x57 as *mut u8; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + +} + +pub struct Spi; + +impl modules::HardwareSpi for Spi { + type ControlRegister = SPCR; + type StatusRegister = SPSR; + type DataRegister = SPDR; +} + + diff --git a/src/cores/atmega168.rs b/src/cores/atmega168.rs index 5b893fe..27cf20a 100644 --- a/src/cores/atmega168.rs +++ b/src/cores/atmega168.rs @@ -1791,10 +1791,10 @@ pub mod port { pub struct Spi; impl modules::HardwareSpi for Spi { + type SerialDataOut = port::B3; type ChipSelect = port::B2; type SerialDataIn = port::B4; type Clock = port::B5; - type SerialDataOut = port::B3; type DataRegister = SPDR; type StatusRegister = SPSR; type ControlRegister = SPCR; diff --git a/src/cores/atmega168a.rs b/src/cores/atmega168a.rs index 9ee911f..b234531 100644 --- a/src/cores/atmega168a.rs +++ b/src/cores/atmega168a.rs @@ -1794,10 +1794,10 @@ pub mod port { pub struct Spi; impl modules::HardwareSpi for Spi { - type SerialDataOut = port::B3; - type ChipSelect = port::B2; type Clock = port::B5; type SerialDataIn = port::B4; + type SerialDataOut = port::B3; + type ChipSelect = port::B2; type DataRegister = SPDR; type StatusRegister = SPSR; type ControlRegister = SPCR; diff --git a/src/cores/atmega168p.rs b/src/cores/atmega168p.rs index 27d56a3..6a04217 100644 --- a/src/cores/atmega168p.rs +++ b/src/cores/atmega168p.rs @@ -1800,9 +1800,9 @@ pub mod port { pub struct Spi; impl modules::HardwareSpi for Spi { - type ChipSelect = port::B2; type SerialDataOut = port::B3; type SerialDataIn = port::B4; + type ChipSelect = port::B2; type Clock = port::B5; type DataRegister = SPDR; type StatusRegister = SPSR; diff --git a/src/cores/atmega16u4.rs b/src/cores/atmega16u4.rs index c9094bd..4458801 100644 --- a/src/cores/atmega16u4.rs +++ b/src/cores/atmega16u4.rs @@ -3315,8 +3315,8 @@ pub struct Spi; impl modules::HardwareSpi for Spi { type Clock = port::B1; - type SerialDataIn = port::B3; type ChipSelect = port::B0; + type SerialDataIn = port::B3; type SerialDataOut = port::B2; type ControlRegister = SPCR; type StatusRegister = SPSR; @@ -3375,4 +3375,25 @@ impl modules::Timer16 for Timer16 { const WGM3: RegisterBits = Self::ControlB::WGM11; const OCIEA: RegisterBits = Self::InterruptMask::OCIE3A; } +/// 16-bit timer. +pub struct Timer16; + +impl modules::Timer16 for Timer16 { + type CompareA = OCR1A; + type CompareB = OCR1B; + type Counter = TCNT1; + type ControlA = TCCR1A; + type ControlB = TCCR1B; + type ControlC = TCCR1C; + type InterruptMask = TIMSK1; + type InterruptFlag = TIFR1; + const CS0: RegisterBits = Self::ControlB::CS10; + const CS1: RegisterBits = Self::ControlB::CS11; + const CS2: RegisterBits = Self::ControlB::CS12; + const WGM0: RegisterBits = Self::ControlA::WGM10; + const WGM1: RegisterBits = Self::ControlA::WGM11; + const WGM2: RegisterBits = Self::ControlB::WGM10; + const WGM3: RegisterBits = Self::ControlB::WGM11; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE1A; +} diff --git a/src/cores/atmega328.rs b/src/cores/atmega328.rs index b482713..857d67b 100644 --- a/src/cores/atmega328.rs +++ b/src/cores/atmega328.rs @@ -2040,10 +2040,10 @@ pub mod port { pub struct Spi; impl modules::HardwareSpi for Spi { - type Clock = port::B5; + type SerialDataIn = port::B4; type SerialDataOut = port::B3; type ChipSelect = port::B2; - type SerialDataIn = port::B4; + type Clock = port::B5; type DataRegister = SPDR; type StatusRegister = SPSR; type ControlRegister = SPCR; diff --git a/src/cores/atmega328p.rs b/src/cores/atmega328p.rs index 828e815..8d9b16a 100644 --- a/src/cores/atmega328p.rs +++ b/src/cores/atmega328p.rs @@ -1802,8 +1802,8 @@ pub struct Spi; impl modules::HardwareSpi for Spi { type ChipSelect = port::B2; type SerialDataOut = port::B3; - type Clock = port::B5; type SerialDataIn = port::B4; + type Clock = port::B5; type DataRegister = SPDR; type StatusRegister = SPSR; type ControlRegister = SPCR; diff --git a/src/cores/atmega32u4.rs b/src/cores/atmega32u4.rs index 4aa4597..fa5b57c 100644 --- a/src/cores/atmega32u4.rs +++ b/src/cores/atmega32u4.rs @@ -2960,8 +2960,8 @@ pub struct Spi; impl modules::HardwareSpi for Spi { type SerialDataIn = port::B3; - type SerialDataOut = port::B2; type Clock = port::B1; + type SerialDataOut = port::B2; type ChipSelect = port::B0; type ControlRegister = SPCR; type StatusRegister = SPSR; @@ -3020,4 +3020,25 @@ impl modules::Timer16 for Timer16 { const WGM3: RegisterBits = Self::ControlB::WGM11; const OCIEA: RegisterBits = Self::InterruptMask::OCIE3A; } +/// 16-bit timer. +pub struct Timer16; + +impl modules::Timer16 for Timer16 { + type CompareA = OCR1A; + type CompareB = OCR1B; + type Counter = TCNT1; + type ControlA = TCCR1A; + type ControlB = TCCR1B; + type ControlC = TCCR1C; + type InterruptMask = TIMSK1; + type InterruptFlag = TIFR1; + const CS0: RegisterBits = Self::ControlB::CS10; + const CS1: RegisterBits = Self::ControlB::CS11; + const CS2: RegisterBits = Self::ControlB::CS12; + const WGM0: RegisterBits = Self::ControlA::WGM10; + const WGM1: RegisterBits = Self::ControlA::WGM11; + const WGM2: RegisterBits = Self::ControlB::WGM10; + const WGM3: RegisterBits = Self::ControlB::WGM11; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE1A; +} diff --git a/src/cores/atmega406.rs b/src/cores/atmega406.rs new file mode 100644 index 0000000..389e76a --- /dev/null +++ b/src/cores/atmega406.rs @@ -0,0 +1,1389 @@ +//! Core for ATmega406. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct HIGH; + +impl HIGH { + pub const OCDEN: RegisterBits = RegisterBits::new(0x2); + pub const OCDEN0: RegisterBits = RegisterBits::new(1<<1); + + pub const JTAGEN: RegisterBits = RegisterBits::new(0x1); + pub const JTAGEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for HIGH { + type T = u8; + const ADDRESS: *mut u8 = 0x1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOW; + +impl LOW { + pub const WDTON: RegisterBits = RegisterBits::new(0x80); + pub const WDTON0: RegisterBits = RegisterBits::new(1<<7); + + pub const EESAVE: RegisterBits = RegisterBits::new(0x40); + pub const EESAVE0: RegisterBits = RegisterBits::new(1<<6); + + pub const BOOTSZ: RegisterBits = RegisterBits::new(0x30); + pub const BOOTSZ0: RegisterBits = RegisterBits::new(1<<4); + pub const BOOTSZ1: RegisterBits = RegisterBits::new(1<<5); + + pub const BOOTRST: RegisterBits = RegisterBits::new(0x8); + pub const BOOTRST0: RegisterBits = RegisterBits::new(1<<3); + + pub const SUT_CKSEL: RegisterBits = RegisterBits::new(0x7); + pub const SUT_CKSEL0: RegisterBits = RegisterBits::new(1<<0); + pub const SUT_CKSEL1: RegisterBits = RegisterBits::new(1<<1); + pub const SUT_CKSEL2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for LOW { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOCKBIT; + +impl LOCKBIT { + pub const LB: RegisterBits = RegisterBits::new(0x3); + pub const LB0: RegisterBits = RegisterBits::new(1<<0); + pub const LB1: RegisterBits = RegisterBits::new(1<<1); + + pub const BLB0: RegisterBits = RegisterBits::new(0xc); + pub const BLB00: RegisterBits = RegisterBits::new(1<<2); + pub const BLB01: RegisterBits = RegisterBits::new(1<<3); + + pub const BLB1: RegisterBits = RegisterBits::new(0x30); + pub const BLB10: RegisterBits = RegisterBits::new(1<<4); + pub const BLB11: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for LOCKBIT { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct VADMUX; + +impl VADMUX { + pub const VADMUX: RegisterBits = RegisterBits::new(0xf); + pub const VADMUX0: RegisterBits = RegisterBits::new(1<<0); + pub const VADMUX1: RegisterBits = RegisterBits::new(1<<1); + pub const VADMUX2: RegisterBits = RegisterBits::new(1<<2); + pub const VADMUX3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for VADMUX { + type T = u8; + const ADDRESS: *mut u8 = 0x7c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct VADC; + +impl VADC { +} + +impl Register for VADC { + type T = u16; + const ADDRESS: *mut u16 = 0x78 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct VADCSR; + +impl VADCSR { + pub const VADEN: RegisterBits = RegisterBits::new(0x8); + pub const VADEN0: RegisterBits = RegisterBits::new(1<<3); + + pub const VADSC: RegisterBits = RegisterBits::new(0x4); + pub const VADSC0: RegisterBits = RegisterBits::new(1<<2); + + pub const VADCCIF: RegisterBits = RegisterBits::new(0x2); + pub const VADCCIF0: RegisterBits = RegisterBits::new(1<<1); + + pub const VADCCIE: RegisterBits = RegisterBits::new(0x1); + pub const VADCCIE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for VADCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x7a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EICRA; + +impl EICRA { + pub const ISC3: RegisterBits = RegisterBits::new(0xc0); + pub const ISC30: RegisterBits = RegisterBits::new(1<<6); + pub const ISC31: RegisterBits = RegisterBits::new(1<<7); + + pub const ISC2: RegisterBits = RegisterBits::new(0x30); + pub const ISC20: RegisterBits = RegisterBits::new(1<<4); + pub const ISC21: RegisterBits = RegisterBits::new(1<<5); + + pub const ISC1: RegisterBits = RegisterBits::new(0xc); + pub const ISC10: RegisterBits = RegisterBits::new(1<<2); + pub const ISC11: RegisterBits = RegisterBits::new(1<<3); + + pub const ISC0: RegisterBits = RegisterBits::new(0x3); + pub const ISC00: RegisterBits = RegisterBits::new(1<<0); + pub const ISC01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for EICRA { + type T = u8; + const ADDRESS: *mut u8 = 0x69 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EIMSK; + +impl EIMSK { + pub const INT: RegisterBits = RegisterBits::new(0xf); + pub const INT0: RegisterBits = RegisterBits::new(1<<0); + pub const INT1: RegisterBits = RegisterBits::new(1<<1); + pub const INT2: RegisterBits = RegisterBits::new(1<<2); + pub const INT3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for EIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x3d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EIFR; + +impl EIFR { + pub const INTF: RegisterBits = RegisterBits::new(0xf); + pub const INTF0: RegisterBits = RegisterBits::new(1<<0); + pub const INTF1: RegisterBits = RegisterBits::new(1<<1); + pub const INTF2: RegisterBits = RegisterBits::new(1<<2); + pub const INTF3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for EIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x3c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCICR; + +impl PCICR { + pub const PCIE: RegisterBits = RegisterBits::new(0x3); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for PCICR { + type T = u8; + const ADDRESS: *mut u8 = 0x68 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCIFR; + +impl PCIFR { + pub const PCIF: RegisterBits = RegisterBits::new(0x3); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for PCIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { +} + +impl Register for PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x6c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK0; + +impl PCMSK0 { +} + +impl Register for PCMSK0 { + type T = u8; + const ADDRESS: *mut u8 = 0x6b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1B; + +impl TCCR1B { + pub const CTC1: RegisterBits = RegisterBits::new(0x8); + pub const CTC10: RegisterBits = RegisterBits::new(1<<3); + + pub const CS1: RegisterBits = RegisterBits::new(0x7); + pub const CS10: RegisterBits = RegisterBits::new(1<<0); + pub const CS11: RegisterBits = RegisterBits::new(1<<1); + pub const CS12: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x81 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT1; + +impl TCNT1 { +} + +impl Register for TCNT1 { + type T = u16; + const ADDRESS: *mut u16 = 0x84 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1AL; + +impl OCR1AL { +} + +impl Register for OCR1AL { + type T = u8; + const ADDRESS: *mut u8 = 0x88 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1AH; + +impl OCR1AH { +} + +impl Register for OCR1AH { + type T = u8; + const ADDRESS: *mut u8 = 0x89 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK1; + +impl TIMSK1 { + pub const OCIE1A: RegisterBits = RegisterBits::new(0x2); + pub const OCIE1A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOIE1: RegisterBits = RegisterBits::new(0x1); + pub const TOIE10: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x6f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR1; + +impl TIFR1 { + pub const OCF1A: RegisterBits = RegisterBits::new(0x2); + pub const OCF1A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOV1: RegisterBits = RegisterBits::new(0x1); + pub const TOV10: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x36 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct WUTCSR; + +impl WUTCSR { + pub const WUTIF: RegisterBits = RegisterBits::new(0x80); + pub const WUTIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WUTIE: RegisterBits = RegisterBits::new(0x40); + pub const WUTIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const WUTCF: RegisterBits = RegisterBits::new(0x20); + pub const WUTCF0: RegisterBits = RegisterBits::new(1<<5); + + pub const WUTR: RegisterBits = RegisterBits::new(0x10); + pub const WUTR0: RegisterBits = RegisterBits::new(1<<4); + + pub const WUTE: RegisterBits = RegisterBits::new(0x8); + pub const WUTE0: RegisterBits = RegisterBits::new(1<<3); + + pub const WUTP: RegisterBits = RegisterBits::new(0x7); + pub const WUTP0: RegisterBits = RegisterBits::new(1<<0); + pub const WUTP1: RegisterBits = RegisterBits::new(1<<1); + pub const WUTP2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for WUTCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x62 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct BPPLR; + +impl BPPLR { + pub const BPPLE: RegisterBits = RegisterBits::new(0x2); + pub const BPPLE0: RegisterBits = RegisterBits::new(1<<1); + + pub const BPPL: RegisterBits = RegisterBits::new(0x1); + pub const BPPL0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for BPPLR { + type T = u8; + const ADDRESS: *mut u8 = 0xf8 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct BPCR; + +impl BPCR { + pub const DUVD: RegisterBits = RegisterBits::new(0x8); + pub const DUVD0: RegisterBits = RegisterBits::new(1<<3); + + pub const SCD: RegisterBits = RegisterBits::new(0x4); + pub const SCD0: RegisterBits = RegisterBits::new(1<<2); + + pub const DCD: RegisterBits = RegisterBits::new(0x2); + pub const DCD0: RegisterBits = RegisterBits::new(1<<1); + + pub const CCD: RegisterBits = RegisterBits::new(0x1); + pub const CCD0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for BPCR { + type T = u8; + const ADDRESS: *mut u8 = 0xf7 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CBPTR; + +impl CBPTR { + pub const SCPT: RegisterBits = RegisterBits::new(0xf0); + pub const SCPT0: RegisterBits = RegisterBits::new(1<<4); + pub const SCPT1: RegisterBits = RegisterBits::new(1<<5); + pub const SCPT2: RegisterBits = RegisterBits::new(1<<6); + pub const SCPT3: RegisterBits = RegisterBits::new(1<<7); + + pub const OCPT: RegisterBits = RegisterBits::new(0xf); + pub const OCPT0: RegisterBits = RegisterBits::new(1<<0); + pub const OCPT1: RegisterBits = RegisterBits::new(1<<1); + pub const OCPT2: RegisterBits = RegisterBits::new(1<<2); + pub const OCPT3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CBPTR { + type T = u8; + const ADDRESS: *mut u8 = 0xf6 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct BPOCD; + +impl BPOCD { + pub const DCDL: RegisterBits = RegisterBits::new(0xf0); + pub const DCDL0: RegisterBits = RegisterBits::new(1<<4); + pub const DCDL1: RegisterBits = RegisterBits::new(1<<5); + pub const DCDL2: RegisterBits = RegisterBits::new(1<<6); + pub const DCDL3: RegisterBits = RegisterBits::new(1<<7); + + pub const CCDL: RegisterBits = RegisterBits::new(0xf); + pub const CCDL0: RegisterBits = RegisterBits::new(1<<0); + pub const CCDL1: RegisterBits = RegisterBits::new(1<<1); + pub const CCDL2: RegisterBits = RegisterBits::new(1<<2); + pub const CCDL3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for BPOCD { + type T = u8; + const ADDRESS: *mut u8 = 0xf5 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct BPSCD; + +impl BPSCD { + pub const SCDL: RegisterBits = RegisterBits::new(0xf); + pub const SCDL0: RegisterBits = RegisterBits::new(1<<0); + pub const SCDL1: RegisterBits = RegisterBits::new(1<<1); + pub const SCDL2: RegisterBits = RegisterBits::new(1<<2); + pub const SCDL3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for BPSCD { + type T = u8; + const ADDRESS: *mut u8 = 0xf4 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct BPDUV; + +impl BPDUV { + pub const DUVT: RegisterBits = RegisterBits::new(0x30); + pub const DUVT0: RegisterBits = RegisterBits::new(1<<4); + pub const DUVT1: RegisterBits = RegisterBits::new(1<<5); + + pub const DUDL: RegisterBits = RegisterBits::new(0xf); + pub const DUDL0: RegisterBits = RegisterBits::new(1<<0); + pub const DUDL1: RegisterBits = RegisterBits::new(1<<1); + pub const DUDL2: RegisterBits = RegisterBits::new(1<<2); + pub const DUDL3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for BPDUV { + type T = u8; + const ADDRESS: *mut u8 = 0xf3 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct BPIR; + +impl BPIR { + pub const DUVIF: RegisterBits = RegisterBits::new(0x80); + pub const DUVIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const COCIF: RegisterBits = RegisterBits::new(0x40); + pub const COCIF0: RegisterBits = RegisterBits::new(1<<6); + + pub const DOCIF: RegisterBits = RegisterBits::new(0x20); + pub const DOCIF0: RegisterBits = RegisterBits::new(1<<5); + + pub const SCIF: RegisterBits = RegisterBits::new(0x10); + pub const SCIF0: RegisterBits = RegisterBits::new(1<<4); + + pub const DUVIE: RegisterBits = RegisterBits::new(0x8); + pub const DUVIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const COCIE: RegisterBits = RegisterBits::new(0x4); + pub const COCIE0: RegisterBits = RegisterBits::new(1<<2); + + pub const DOCIE: RegisterBits = RegisterBits::new(0x2); + pub const DOCIE0: RegisterBits = RegisterBits::new(1<<1); + + pub const SCIE: RegisterBits = RegisterBits::new(0x1); + pub const SCIE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for BPIR { + type T = u8; + const ADDRESS: *mut u8 = 0xf2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct FCSR; + +impl FCSR { + pub const PWMOC: RegisterBits = RegisterBits::new(0x20); + pub const PWMOC0: RegisterBits = RegisterBits::new(1<<5); + + pub const PWMOPC: RegisterBits = RegisterBits::new(0x10); + pub const PWMOPC0: RegisterBits = RegisterBits::new(1<<4); + + pub const CPS: RegisterBits = RegisterBits::new(0x8); + pub const CPS0: RegisterBits = RegisterBits::new(1<<3); + + pub const DFE: RegisterBits = RegisterBits::new(0x4); + pub const DFE0: RegisterBits = RegisterBits::new(1<<2); + + pub const CFE: RegisterBits = RegisterBits::new(0x2); + pub const CFE0: RegisterBits = RegisterBits::new(1<<1); + + pub const PFD: RegisterBits = RegisterBits::new(0x1); + pub const PFD0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for FCSR { + type T = u8; + const ADDRESS: *mut u8 = 0xf0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CADCSRA; + +impl CADCSRA { + pub const CADEN: RegisterBits = RegisterBits::new(0x80); + pub const CADEN0: RegisterBits = RegisterBits::new(1<<7); + + pub const CADUB: RegisterBits = RegisterBits::new(0x20); + pub const CADUB0: RegisterBits = RegisterBits::new(1<<5); + + pub const CADAS: RegisterBits = RegisterBits::new(0x18); + pub const CADAS0: RegisterBits = RegisterBits::new(1<<3); + pub const CADAS1: RegisterBits = RegisterBits::new(1<<4); + + pub const CADSI: RegisterBits = RegisterBits::new(0x6); + pub const CADSI0: RegisterBits = RegisterBits::new(1<<1); + pub const CADSI1: RegisterBits = RegisterBits::new(1<<2); + + pub const CADSE: RegisterBits = RegisterBits::new(0x1); + pub const CADSE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for CADCSRA { + type T = u8; + const ADDRESS: *mut u8 = 0xe4 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CADCSRB; + +impl CADCSRB { + pub const CADACIE: RegisterBits = RegisterBits::new(0x40); + pub const CADACIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const CADRCIE: RegisterBits = RegisterBits::new(0x20); + pub const CADRCIE0: RegisterBits = RegisterBits::new(1<<5); + + pub const CADICIE: RegisterBits = RegisterBits::new(0x10); + pub const CADICIE0: RegisterBits = RegisterBits::new(1<<4); + + pub const CADACIF: RegisterBits = RegisterBits::new(0x4); + pub const CADACIF0: RegisterBits = RegisterBits::new(1<<2); + + pub const CADRCIF: RegisterBits = RegisterBits::new(0x2); + pub const CADRCIF0: RegisterBits = RegisterBits::new(1<<1); + + pub const CADICIF: RegisterBits = RegisterBits::new(0x1); + pub const CADICIF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for CADCSRB { + type T = u8; + const ADDRESS: *mut u8 = 0xe5 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CADIC; + +impl CADIC { +} + +impl Register for CADIC { + type T = u16; + const ADDRESS: *mut u16 = 0xe8 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct CADAC3; + +impl CADAC3 { +} + +impl Register for CADAC3 { + type T = u8; + const ADDRESS: *mut u8 = 0xe3 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CADAC2; + +impl CADAC2 { +} + +impl Register for CADAC2 { + type T = u8; + const ADDRESS: *mut u8 = 0xe2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CADAC1; + +impl CADAC1 { +} + +impl Register for CADAC1 { + type T = u8; + const ADDRESS: *mut u8 = 0xe1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CADAC0; + +impl CADAC0 { +} + +impl Register for CADAC0 { + type T = u8; + const ADDRESS: *mut u8 = 0xe0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CADRCC; + +impl CADRCC { +} + +impl Register for CADRCC { + type T = u8; + const ADDRESS: *mut u8 = 0xe6 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CADRDC; + +impl CADRDC { +} + +impl Register for CADRDC { + type T = u8; + const ADDRESS: *mut u8 = 0xe7 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CBCR; + +impl CBCR { + pub const CBE: RegisterBits = RegisterBits::new(0xf); + pub const CBE0: RegisterBits = RegisterBits::new(1<<0); + pub const CBE1: RegisterBits = RegisterBits::new(1<<1); + pub const CBE2: RegisterBits = RegisterBits::new(1<<2); + pub const CBE3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CBCR { + type T = u8; + const ADDRESS: *mut u8 = 0xf1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SREG; + +impl SREG { + pub const I: RegisterBits = RegisterBits::new(0x80); + pub const I0: RegisterBits = RegisterBits::new(1<<7); + + pub const T: RegisterBits = RegisterBits::new(0x40); + pub const T0: RegisterBits = RegisterBits::new(1<<6); + + pub const H: RegisterBits = RegisterBits::new(0x20); + pub const H0: RegisterBits = RegisterBits::new(1<<5); + + pub const S: RegisterBits = RegisterBits::new(0x10); + pub const S0: RegisterBits = RegisterBits::new(1<<4); + + pub const V: RegisterBits = RegisterBits::new(0x8); + pub const V0: RegisterBits = RegisterBits::new(1<<3); + + pub const N: RegisterBits = RegisterBits::new(0x4); + pub const N0: RegisterBits = RegisterBits::new(1<<2); + + pub const Z: RegisterBits = RegisterBits::new(0x2); + pub const Z0: RegisterBits = RegisterBits::new(1<<1); + + pub const C: RegisterBits = RegisterBits::new(0x1); + pub const C0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SREG { + type T = u8; + const ADDRESS: *mut u8 = 0x5f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SP; + +impl SP { +} + +impl Register for SP { + type T = u16; + const ADDRESS: *mut u16 = 0x5d as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const JTD: RegisterBits = RegisterBits::new(0x80); + pub const JTD0: RegisterBits = RegisterBits::new(1<<7); + + pub const PUD: RegisterBits = RegisterBits::new(0x10); + pub const PUD0: RegisterBits = RegisterBits::new(1<<4); + + pub const IVSEL: RegisterBits = RegisterBits::new(0x2); + pub const IVSEL0: RegisterBits = RegisterBits::new(1<<1); + + pub const IVCE: RegisterBits = RegisterBits::new(0x1); + pub const IVCE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUSR; + +impl MCUSR { + pub const JTRF: RegisterBits = RegisterBits::new(0x10); + pub const JTRF0: RegisterBits = RegisterBits::new(1<<4); + + pub const WDRF: RegisterBits = RegisterBits::new(0x8); + pub const WDRF0: RegisterBits = RegisterBits::new(1<<3); + + pub const BODRF: RegisterBits = RegisterBits::new(0x4); + pub const BODRF0: RegisterBits = RegisterBits::new(1<<2); + + pub const EXTRF: RegisterBits = RegisterBits::new(0x2); + pub const EXTRF0: RegisterBits = RegisterBits::new(1<<1); + + pub const PORF: RegisterBits = RegisterBits::new(0x1); + pub const PORF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUSR { + type T = u8; + const ADDRESS: *mut u8 = 0x54 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct FOSCCAL; + +impl FOSCCAL { +} + +impl Register for FOSCCAL { + type T = u8; + const ADDRESS: *mut u8 = 0x66 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SMCR; + +impl SMCR { + pub const SM: RegisterBits = RegisterBits::new(0xe); + pub const SM0: RegisterBits = RegisterBits::new(1<<1); + pub const SM1: RegisterBits = RegisterBits::new(1<<2); + pub const SM2: RegisterBits = RegisterBits::new(1<<3); + + pub const SE: RegisterBits = RegisterBits::new(0x1); + pub const SE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SMCR { + type T = u8; + const ADDRESS: *mut u8 = 0x53 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR2; + +impl GPIOR2 { +} + +impl Register for GPIOR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x4b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR1; + +impl GPIOR1 { +} + +impl Register for GPIOR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x4a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR0; + +impl GPIOR0 { +} + +impl Register for GPIOR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x3e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CCSR; + +impl CCSR { + pub const XOE: RegisterBits = RegisterBits::new(0x2); + pub const XOE0: RegisterBits = RegisterBits::new(1<<1); + + pub const ACS: RegisterBits = RegisterBits::new(0x1); + pub const ACS0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for CCSR { + type T = u8; + const ADDRESS: *mut u8 = 0xc0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { +} + +impl Register for DIDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x7e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PRR0; + +impl PRR0 { + pub const PRTWI: RegisterBits = RegisterBits::new(0x8); + pub const PRTWI0: RegisterBits = RegisterBits::new(1<<3); + + pub const PRTIM1: RegisterBits = RegisterBits::new(0x4); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<2); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x2); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<1); + + pub const PRVADC: RegisterBits = RegisterBits::new(0x1); + pub const PRVADC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PRR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x64 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct WDTCSR; + +impl WDTCSR { + pub const WDIF: RegisterBits = RegisterBits::new(0x80); + pub const WDIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WDIE: RegisterBits = RegisterBits::new(0x40); + pub const WDIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const WDP: RegisterBits = RegisterBits::new(0x27); + pub const WDP0: RegisterBits = RegisterBits::new(1<<0); + pub const WDP1: RegisterBits = RegisterBits::new(1<<1); + pub const WDP2: RegisterBits = RegisterBits::new(1<<2); + pub const WDP3: RegisterBits = RegisterBits::new(1<<5); + + pub const WDCE: RegisterBits = RegisterBits::new(0x10); + pub const WDCE0: RegisterBits = RegisterBits::new(1<<4); + + pub const WDE: RegisterBits = RegisterBits::new(0x8); + pub const WDE0: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for WDTCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x60 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0A; + +impl TCCR0A { + pub const COM0A: RegisterBits = RegisterBits::new(0xc0); + pub const COM0A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM0A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM0B: RegisterBits = RegisterBits::new(0x30); + pub const COM0B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM0B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM0: RegisterBits = RegisterBits::new(0x3); + pub const WGM00: RegisterBits = RegisterBits::new(1<<0); + pub const WGM01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x44 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0B; + +impl TCCR0B { + pub const FOC0A: RegisterBits = RegisterBits::new(0x80); + pub const FOC0A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC0B: RegisterBits = RegisterBits::new(0x40); + pub const FOC0B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM02: RegisterBits = RegisterBits::new(0x8); + pub const WGM020: RegisterBits = RegisterBits::new(1<<3); + + pub const CS0: RegisterBits = RegisterBits::new(0x7); + pub const CS00: RegisterBits = RegisterBits::new(1<<0); + pub const CS01: RegisterBits = RegisterBits::new(1<<1); + pub const CS02: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x45 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0; + +impl TCNT0 { +} + +impl Register for TCNT0 { + type T = u8; + const ADDRESS: *mut u8 = 0x46 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0A; + +impl OCR0A { + pub const OCR0A: RegisterBits = RegisterBits::new(0xff); + pub const OCR0A0: RegisterBits = RegisterBits::new(1<<0); + pub const OCR0A1: RegisterBits = RegisterBits::new(1<<1); + pub const OCR0A2: RegisterBits = RegisterBits::new(1<<2); + pub const OCR0A3: RegisterBits = RegisterBits::new(1<<3); + pub const OCR0A4: RegisterBits = RegisterBits::new(1<<4); + pub const OCR0A5: RegisterBits = RegisterBits::new(1<<5); + pub const OCR0A6: RegisterBits = RegisterBits::new(1<<6); + pub const OCR0A7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x47 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0B; + +impl OCR0B { + pub const OCR0B: RegisterBits = RegisterBits::new(0xff); + pub const OCR0B0: RegisterBits = RegisterBits::new(1<<0); + pub const OCR0B1: RegisterBits = RegisterBits::new(1<<1); + pub const OCR0B2: RegisterBits = RegisterBits::new(1<<2); + pub const OCR0B3: RegisterBits = RegisterBits::new(1<<3); + pub const OCR0B4: RegisterBits = RegisterBits::new(1<<4); + pub const OCR0B5: RegisterBits = RegisterBits::new(1<<5); + pub const OCR0B6: RegisterBits = RegisterBits::new(1<<6); + pub const OCR0B7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x48 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK0; + +impl TIMSK0 { + pub const OCIE0B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE0B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCIE0A: RegisterBits = RegisterBits::new(0x2); + pub const OCIE0A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOIE0: RegisterBits = RegisterBits::new(0x1); + pub const TOIE00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK0 { + type T = u8; + const ADDRESS: *mut u8 = 0x6e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR0; + +impl TIFR0 { + pub const OCF0B: RegisterBits = RegisterBits::new(0x4); + pub const OCF0B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCF0A: RegisterBits = RegisterBits::new(0x2); + pub const OCF0A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOV0: RegisterBits = RegisterBits::new(0x1); + pub const TOV00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x35 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTA; + +impl PORTA { +} + +impl Register for PORTA { + type T = u8; + const ADDRESS: *mut u8 = 0x22 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRA; + +impl DDRA { +} + +impl Register for DDRA { + type T = u8; + const ADDRESS: *mut u8 = 0x21 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINA; + +impl PINA { +} + +impl Register for PINA { + type T = u8; + const ADDRESS: *mut u8 = 0x20 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x25 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x24 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x23 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTC; + +impl PORTC { +} + +impl Register for PORTC { + type T = u8; + const ADDRESS: *mut u8 = 0x28 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTD; + +impl PORTD { +} + +impl Register for PORTD { + type T = u8; + const ADDRESS: *mut u8 = 0x2b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRD; + +impl DDRD { +} + +impl Register for DDRD { + type T = u8; + const ADDRESS: *mut u8 = 0x2a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PIND; + +impl PIND { +} + +impl Register for PIND { + type T = u8; + const ADDRESS: *mut u8 = 0x29 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPMCSR; + +impl SPMCSR { + pub const SPMIE: RegisterBits = RegisterBits::new(0x80); + pub const SPMIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const RWWSB: RegisterBits = RegisterBits::new(0x40); + pub const RWWSB0: RegisterBits = RegisterBits::new(1<<6); + + pub const SIGRD: RegisterBits = RegisterBits::new(0x20); + pub const SIGRD0: RegisterBits = RegisterBits::new(1<<5); + + pub const RWWSRE: RegisterBits = RegisterBits::new(0x10); + pub const RWWSRE0: RegisterBits = RegisterBits::new(1<<4); + + pub const BLBSET: RegisterBits = RegisterBits::new(0x8); + pub const BLBSET0: RegisterBits = RegisterBits::new(1<<3); + + pub const PGWRT: RegisterBits = RegisterBits::new(0x4); + pub const PGWRT0: RegisterBits = RegisterBits::new(1<<2); + + pub const PGERS: RegisterBits = RegisterBits::new(0x2); + pub const PGERS0: RegisterBits = RegisterBits::new(1<<1); + + pub const SPMEN: RegisterBits = RegisterBits::new(0x1); + pub const SPMEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SPMCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x57 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWBCSR; + +impl TWBCSR { + pub const TWBCIF: RegisterBits = RegisterBits::new(0x80); + pub const TWBCIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const TWBCIE: RegisterBits = RegisterBits::new(0x40); + pub const TWBCIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const TWBDT: RegisterBits = RegisterBits::new(0x6); + pub const TWBDT0: RegisterBits = RegisterBits::new(1<<1); + pub const TWBDT1: RegisterBits = RegisterBits::new(1<<2); + + pub const TWBCIP: RegisterBits = RegisterBits::new(0x1); + pub const TWBCIP0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TWBCSR { + type T = u8; + const ADDRESS: *mut u8 = 0xbe as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWAMR; + +impl TWAMR { + pub const TWAM: RegisterBits = RegisterBits::new(0xfe); + pub const TWAM0: RegisterBits = RegisterBits::new(1<<1); + pub const TWAM1: RegisterBits = RegisterBits::new(1<<2); + pub const TWAM2: RegisterBits = RegisterBits::new(1<<3); + pub const TWAM3: RegisterBits = RegisterBits::new(1<<4); + pub const TWAM4: RegisterBits = RegisterBits::new(1<<5); + pub const TWAM5: RegisterBits = RegisterBits::new(1<<6); + pub const TWAM6: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for TWAMR { + type T = u8; + const ADDRESS: *mut u8 = 0xbd as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWBR; + +impl TWBR { +} + +impl Register for TWBR { + type T = u8; + const ADDRESS: *mut u8 = 0xb8 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWCR; + +impl TWCR { + pub const TWINT: RegisterBits = RegisterBits::new(0x80); + pub const TWINT0: RegisterBits = RegisterBits::new(1<<7); + + pub const TWEA: RegisterBits = RegisterBits::new(0x40); + pub const TWEA0: RegisterBits = RegisterBits::new(1<<6); + + pub const TWSTA: RegisterBits = RegisterBits::new(0x20); + pub const TWSTA0: RegisterBits = RegisterBits::new(1<<5); + + pub const TWSTO: RegisterBits = RegisterBits::new(0x10); + pub const TWSTO0: RegisterBits = RegisterBits::new(1<<4); + + pub const TWWC: RegisterBits = RegisterBits::new(0x8); + pub const TWWC0: RegisterBits = RegisterBits::new(1<<3); + + pub const TWEN: RegisterBits = RegisterBits::new(0x4); + pub const TWEN0: RegisterBits = RegisterBits::new(1<<2); + + pub const TWIE: RegisterBits = RegisterBits::new(0x1); + pub const TWIE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TWCR { + type T = u8; + const ADDRESS: *mut u8 = 0xbc as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSR; + +impl TWSR { + pub const TWS: RegisterBits = RegisterBits::new(0xf8); + pub const TWS0: RegisterBits = RegisterBits::new(1<<3); + pub const TWS1: RegisterBits = RegisterBits::new(1<<4); + pub const TWS2: RegisterBits = RegisterBits::new(1<<5); + pub const TWS3: RegisterBits = RegisterBits::new(1<<6); + pub const TWS4: RegisterBits = RegisterBits::new(1<<7); + + pub const TWPS: RegisterBits = RegisterBits::new(0x3); + pub const TWPS0: RegisterBits = RegisterBits::new(1<<0); + pub const TWPS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TWSR { + type T = u8; + const ADDRESS: *mut u8 = 0xb9 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWDR; + +impl TWDR { +} + +impl Register for TWDR { + type T = u8; + const ADDRESS: *mut u8 = 0xbb as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWAR; + +impl TWAR { + pub const TWA: RegisterBits = RegisterBits::new(0xfe); + pub const TWA0: RegisterBits = RegisterBits::new(1<<1); + pub const TWA1: RegisterBits = RegisterBits::new(1<<2); + pub const TWA2: RegisterBits = RegisterBits::new(1<<3); + pub const TWA3: RegisterBits = RegisterBits::new(1<<4); + pub const TWA4: RegisterBits = RegisterBits::new(1<<5); + pub const TWA5: RegisterBits = RegisterBits::new(1<<6); + pub const TWA6: RegisterBits = RegisterBits::new(1<<7); + + pub const TWGCE: RegisterBits = RegisterBits::new(0x1); + pub const TWGCE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TWAR { + type T = u8; + const ADDRESS: *mut u8 = 0xba as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct BGCRR; + +impl BGCRR { +} + +impl Register for BGCRR { + type T = u8; + const ADDRESS: *mut u8 = 0xd1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct BGCCR; + +impl BGCCR { + pub const BGD: RegisterBits = RegisterBits::new(0x80); + pub const BGD0: RegisterBits = RegisterBits::new(1<<7); + + pub const BGCC: RegisterBits = RegisterBits::new(0x3f); + pub const BGCC0: RegisterBits = RegisterBits::new(1<<0); + pub const BGCC1: RegisterBits = RegisterBits::new(1<<1); + pub const BGCC2: RegisterBits = RegisterBits::new(1<<2); + pub const BGCC3: RegisterBits = RegisterBits::new(1<<3); + pub const BGCC4: RegisterBits = RegisterBits::new(1<<4); + pub const BGCC5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for BGCCR { + type T = u8; + const ADDRESS: *mut u8 = 0xd0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEAR; + +impl EEAR { +} + +impl Register for EEAR { + type T = u16; + const ADDRESS: *mut u16 = 0x41 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct EEDR; + +impl EEDR { +} + +impl Register for EEDR { + type T = u8; + const ADDRESS: *mut u8 = 0x40 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EECR; + +impl EECR { + pub const EEPM: RegisterBits = RegisterBits::new(0x30); + pub const EEPM0: RegisterBits = RegisterBits::new(1<<4); + pub const EEPM1: RegisterBits = RegisterBits::new(1<<5); + + pub const EERIE: RegisterBits = RegisterBits::new(0x8); + pub const EERIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const EEMPE: RegisterBits = RegisterBits::new(0x4); + pub const EEMPE0: RegisterBits = RegisterBits::new(1<<2); + + pub const EEPE: RegisterBits = RegisterBits::new(0x2); + pub const EEPE0: RegisterBits = RegisterBits::new(1<<1); + + pub const EERE: RegisterBits = RegisterBits::new(0x1); + pub const EERE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EECR { + type T = u8; + const ADDRESS: *mut u8 = 0x3f as *mut u8; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + +} + +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR0A; + type CompareB = OCR0B; + type Counter = TCNT0; + type ControlA = TCCR0A; + type ControlB = TCCR0B; + type InterruptMask = TIMSK0; + type InterruptFlag = TIFR0; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE0A; +} + diff --git a/src/cores/atmega48.rs b/src/cores/atmega48.rs index 8f750cb..eb53db7 100644 --- a/src/cores/atmega48.rs +++ b/src/cores/atmega48.rs @@ -1773,10 +1773,10 @@ pub mod port { pub struct Spi; impl modules::HardwareSpi for Spi { + type SerialDataOut = port::B3; type SerialDataIn = port::B4; type ChipSelect = port::B2; type Clock = port::B5; - type SerialDataOut = port::B3; type DataRegister = SPDR; type StatusRegister = SPSR; type ControlRegister = SPCR; diff --git a/src/cores/atmega48a.rs b/src/cores/atmega48a.rs index e9d7050..5a4f656 100644 --- a/src/cores/atmega48a.rs +++ b/src/cores/atmega48a.rs @@ -1798,10 +1798,10 @@ pub mod port { pub struct Spi; impl modules::HardwareSpi for Spi { + type Clock = port::B5; + type ChipSelect = port::B2; type SerialDataOut = port::B3; type SerialDataIn = port::B4; - type ChipSelect = port::B2; - type Clock = port::B5; type DataRegister = SPDR; type StatusRegister = SPSR; type ControlRegister = SPCR; diff --git a/src/cores/atmega48p.rs b/src/cores/atmega48p.rs index ed8d6c7..934047a 100644 --- a/src/cores/atmega48p.rs +++ b/src/cores/atmega48p.rs @@ -1779,8 +1779,8 @@ pub mod port { pub struct Spi; impl modules::HardwareSpi for Spi { - type ChipSelect = port::B2; type SerialDataIn = port::B4; + type ChipSelect = port::B2; type Clock = port::B5; type SerialDataOut = port::B3; type DataRegister = SPDR; diff --git a/src/cores/atmega48pa.rs b/src/cores/atmega48pa.rs index 9e4db3d..453dd4b 100644 --- a/src/cores/atmega48pa.rs +++ b/src/cores/atmega48pa.rs @@ -1804,10 +1804,10 @@ pub mod port { pub struct Spi; impl modules::HardwareSpi for Spi { - type SerialDataOut = port::B3; - type SerialDataIn = port::B4; - type Clock = port::B5; type ChipSelect = port::B2; + type Clock = port::B5; + type SerialDataIn = port::B4; + type SerialDataOut = port::B3; type DataRegister = SPDR; type StatusRegister = SPSR; type ControlRegister = SPCR; diff --git a/src/cores/atmega88.rs b/src/cores/atmega88.rs index 6b2fd7e..28c2c57 100644 --- a/src/cores/atmega88.rs +++ b/src/cores/atmega88.rs @@ -1791,10 +1791,10 @@ pub mod port { pub struct Spi; impl modules::HardwareSpi for Spi { - type ChipSelect = port::B2; - type SerialDataOut = port::B3; type SerialDataIn = port::B4; type Clock = port::B5; + type ChipSelect = port::B2; + type SerialDataOut = port::B3; type DataRegister = SPDR; type StatusRegister = SPSR; type ControlRegister = SPCR; diff --git a/src/cores/atmega88a.rs b/src/cores/atmega88a.rs index 6e028c2..0dadc2c 100644 --- a/src/cores/atmega88a.rs +++ b/src/cores/atmega88a.rs @@ -1794,10 +1794,10 @@ pub mod port { pub struct Spi; impl modules::HardwareSpi for Spi { + type Clock = port::B5; type SerialDataOut = port::B3; type SerialDataIn = port::B4; type ChipSelect = port::B2; - type Clock = port::B5; type DataRegister = SPDR; type StatusRegister = SPSR; type ControlRegister = SPCR; diff --git a/src/cores/atmega88p.rs b/src/cores/atmega88p.rs index e62fcc5..0cb347c 100644 --- a/src/cores/atmega88p.rs +++ b/src/cores/atmega88p.rs @@ -1797,10 +1797,10 @@ pub mod port { pub struct Spi; impl modules::HardwareSpi for Spi { - type ChipSelect = port::B2; type Clock = port::B5; - type SerialDataOut = port::B3; + type ChipSelect = port::B2; type SerialDataIn = port::B4; + type SerialDataOut = port::B3; type DataRegister = SPDR; type StatusRegister = SPSR; type ControlRegister = SPCR; diff --git a/src/cores/atmega88pa.rs b/src/cores/atmega88pa.rs index b50fe6d..ab862fd 100644 --- a/src/cores/atmega88pa.rs +++ b/src/cores/atmega88pa.rs @@ -1800,10 +1800,10 @@ pub mod port { pub struct Spi; impl modules::HardwareSpi for Spi { - type SerialDataOut = port::B3; - type SerialDataIn = port::B4; - type ChipSelect = port::B2; type Clock = port::B5; + type ChipSelect = port::B2; + type SerialDataIn = port::B4; + type SerialDataOut = port::B3; type DataRegister = SPDR; type StatusRegister = SPSR; type ControlRegister = SPCR; diff --git a/src/cores/attiny11.rs b/src/cores/attiny11.rs new file mode 100644 index 0000000..e9203a2 --- /dev/null +++ b/src/cores/attiny11.rs @@ -0,0 +1,282 @@ +//! Core for ATtiny11. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct LOW; + +impl LOW { + pub const FSTRT: RegisterBits = RegisterBits::new(0x10); + pub const FSTRT0: RegisterBits = RegisterBits::new(1<<4); + + pub const RSTDISBL: RegisterBits = RegisterBits::new(0x8); + pub const RSTDISBL0: RegisterBits = RegisterBits::new(1<<3); + + pub const CKSEL: RegisterBits = RegisterBits::new(0x7); + pub const CKSEL0: RegisterBits = RegisterBits::new(1<<0); + pub const CKSEL1: RegisterBits = RegisterBits::new(1<<1); + pub const CKSEL2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for LOW { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOCKBIT; + +impl LOCKBIT { + pub const LB: RegisterBits = RegisterBits::new(0x6); + pub const LB0: RegisterBits = RegisterBits::new(1<<1); + pub const LB1: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for LOCKBIT { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSR; + +impl ACSR { + pub const ACD: RegisterBits = RegisterBits::new(0x80); + pub const ACD0: RegisterBits = RegisterBits::new(1<<7); + + pub const ACO: RegisterBits = RegisterBits::new(0x20); + pub const ACO0: RegisterBits = RegisterBits::new(1<<5); + + pub const ACI: RegisterBits = RegisterBits::new(0x10); + pub const ACI0: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIE: RegisterBits = RegisterBits::new(0x8); + pub const ACIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ACIS: RegisterBits = RegisterBits::new(0x3); + pub const ACIS0: RegisterBits = RegisterBits::new(1<<0); + pub const ACIS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for ACSR { + type T = u8; + const ADDRESS: *mut u8 = 0x8 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIMSK; + +impl GIMSK { + pub const INT0: RegisterBits = RegisterBits::new(0x40); + pub const INT00: RegisterBits = RegisterBits::new(1<<6); + + pub const PCIE: RegisterBits = RegisterBits::new(0x20); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIFR; + +impl GIFR { + pub const INTF0: RegisterBits = RegisterBits::new(0x40); + pub const INTF00: RegisterBits = RegisterBits::new(1<<6); + + pub const PCIF: RegisterBits = RegisterBits::new(0x20); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x3a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x18 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x17 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x16 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const TOIE0: RegisterBits = RegisterBits::new(0x2); + pub const TOIE00: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x39 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const TOV0: RegisterBits = RegisterBits::new(0x2); + pub const TOV00: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x38 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0; + +impl TCCR0 { + pub const CS02: RegisterBits = RegisterBits::new(0x4); + pub const CS020: RegisterBits = RegisterBits::new(1<<2); + + pub const CS01: RegisterBits = RegisterBits::new(0x2); + pub const CS010: RegisterBits = RegisterBits::new(1<<1); + + pub const CS00: RegisterBits = RegisterBits::new(0x1); + pub const CS000: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x33 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0; + +impl TCNT0 { +} + +impl Register for TCNT0 { + type T = u8; + const ADDRESS: *mut u8 = 0x32 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct WDTCR; + +impl WDTCR { + pub const WDTOE: RegisterBits = RegisterBits::new(0x10); + pub const WDTOE0: RegisterBits = RegisterBits::new(1<<4); + + pub const WDE: RegisterBits = RegisterBits::new(0x8); + pub const WDE0: RegisterBits = RegisterBits::new(1<<3); + + pub const WDP: RegisterBits = RegisterBits::new(0x7); + pub const WDP0: RegisterBits = RegisterBits::new(1<<0); + pub const WDP1: RegisterBits = RegisterBits::new(1<<1); + pub const WDP2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for WDTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x21 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SREG; + +impl SREG { + pub const I: RegisterBits = RegisterBits::new(0x80); + pub const I0: RegisterBits = RegisterBits::new(1<<7); + + pub const T: RegisterBits = RegisterBits::new(0x40); + pub const T0: RegisterBits = RegisterBits::new(1<<6); + + pub const H: RegisterBits = RegisterBits::new(0x20); + pub const H0: RegisterBits = RegisterBits::new(1<<5); + + pub const S: RegisterBits = RegisterBits::new(0x10); + pub const S0: RegisterBits = RegisterBits::new(1<<4); + + pub const V: RegisterBits = RegisterBits::new(0x8); + pub const V0: RegisterBits = RegisterBits::new(1<<3); + + pub const N: RegisterBits = RegisterBits::new(0x4); + pub const N0: RegisterBits = RegisterBits::new(1<<2); + + pub const Z: RegisterBits = RegisterBits::new(0x2); + pub const Z0: RegisterBits = RegisterBits::new(1<<1); + + pub const C: RegisterBits = RegisterBits::new(0x1); + pub const C0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SREG { + type T = u8; + const ADDRESS: *mut u8 = 0x3f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUSR; + +impl MCUSR { + pub const EXTRF: RegisterBits = RegisterBits::new(0x2); + pub const EXTRF0: RegisterBits = RegisterBits::new(1<<1); + + pub const PORF: RegisterBits = RegisterBits::new(0x1); + pub const PORF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUSR { + type T = u8; + const ADDRESS: *mut u8 = 0x34 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const SE: RegisterBits = RegisterBits::new(0x20); + pub const SE0: RegisterBits = RegisterBits::new(1<<5); + + pub const SM: RegisterBits = RegisterBits::new(0x10); + pub const SM0: RegisterBits = RegisterBits::new(1<<4); + + pub const ISC0: RegisterBits = RegisterBits::new(0x3); + pub const ISC00: RegisterBits = RegisterBits::new(1<<0); + pub const ISC01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x35 as *mut u8; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + +} + + diff --git a/src/cores/attiny12.rs b/src/cores/attiny12.rs new file mode 100644 index 0000000..cfac0ac --- /dev/null +++ b/src/cores/attiny12.rs @@ -0,0 +1,363 @@ +//! Core for ATtiny12. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct LOW; + +impl LOW { + pub const BODLEVEL: RegisterBits = RegisterBits::new(0x80); + pub const BODLEVEL0: RegisterBits = RegisterBits::new(1<<7); + + pub const BODEN: RegisterBits = RegisterBits::new(0x40); + pub const BODEN0: RegisterBits = RegisterBits::new(1<<6); + + pub const SPIEN: RegisterBits = RegisterBits::new(0x20); + pub const SPIEN0: RegisterBits = RegisterBits::new(1<<5); + + pub const RSTDISBL: RegisterBits = RegisterBits::new(0x10); + pub const RSTDISBL0: RegisterBits = RegisterBits::new(1<<4); + + pub const CKSEL: RegisterBits = RegisterBits::new(0xf); + pub const CKSEL0: RegisterBits = RegisterBits::new(1<<0); + pub const CKSEL1: RegisterBits = RegisterBits::new(1<<1); + pub const CKSEL2: RegisterBits = RegisterBits::new(1<<2); + pub const CKSEL3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for LOW { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOCKBIT; + +impl LOCKBIT { + pub const LB: RegisterBits = RegisterBits::new(0x6); + pub const LB0: RegisterBits = RegisterBits::new(1<<1); + pub const LB1: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for LOCKBIT { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSR; + +impl ACSR { + pub const ACD: RegisterBits = RegisterBits::new(0x80); + pub const ACD0: RegisterBits = RegisterBits::new(1<<7); + + pub const AINBG: RegisterBits = RegisterBits::new(0x40); + pub const AINBG0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACO: RegisterBits = RegisterBits::new(0x20); + pub const ACO0: RegisterBits = RegisterBits::new(1<<5); + + pub const ACI: RegisterBits = RegisterBits::new(0x10); + pub const ACI0: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIE: RegisterBits = RegisterBits::new(0x8); + pub const ACIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ACIS: RegisterBits = RegisterBits::new(0x3); + pub const ACIS0: RegisterBits = RegisterBits::new(1<<0); + pub const ACIS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for ACSR { + type T = u8; + const ADDRESS: *mut u8 = 0x8 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SREG; + +impl SREG { + pub const I: RegisterBits = RegisterBits::new(0x80); + pub const I0: RegisterBits = RegisterBits::new(1<<7); + + pub const T: RegisterBits = RegisterBits::new(0x40); + pub const T0: RegisterBits = RegisterBits::new(1<<6); + + pub const H: RegisterBits = RegisterBits::new(0x20); + pub const H0: RegisterBits = RegisterBits::new(1<<5); + + pub const S: RegisterBits = RegisterBits::new(0x10); + pub const S0: RegisterBits = RegisterBits::new(1<<4); + + pub const V: RegisterBits = RegisterBits::new(0x8); + pub const V0: RegisterBits = RegisterBits::new(1<<3); + + pub const N: RegisterBits = RegisterBits::new(0x4); + pub const N0: RegisterBits = RegisterBits::new(1<<2); + + pub const Z: RegisterBits = RegisterBits::new(0x2); + pub const Z0: RegisterBits = RegisterBits::new(1<<1); + + pub const C: RegisterBits = RegisterBits::new(0x1); + pub const C0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SREG { + type T = u8; + const ADDRESS: *mut u8 = 0x3f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const PUD: RegisterBits = RegisterBits::new(0x40); + pub const PUD0: RegisterBits = RegisterBits::new(1<<6); + + pub const SE: RegisterBits = RegisterBits::new(0x20); + pub const SE0: RegisterBits = RegisterBits::new(1<<5); + + pub const SM: RegisterBits = RegisterBits::new(0x10); + pub const SM0: RegisterBits = RegisterBits::new(1<<4); + + pub const ISC0: RegisterBits = RegisterBits::new(0x3); + pub const ISC00: RegisterBits = RegisterBits::new(1<<0); + pub const ISC01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x35 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUSR; + +impl MCUSR { + pub const WDRF: RegisterBits = RegisterBits::new(0x8); + pub const WDRF0: RegisterBits = RegisterBits::new(1<<3); + + pub const BORF: RegisterBits = RegisterBits::new(0x4); + pub const BORF0: RegisterBits = RegisterBits::new(1<<2); + + pub const EXTRF: RegisterBits = RegisterBits::new(0x2); + pub const EXTRF0: RegisterBits = RegisterBits::new(1<<1); + + pub const PORF: RegisterBits = RegisterBits::new(0x1); + pub const PORF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUSR { + type T = u8; + const ADDRESS: *mut u8 = 0x34 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCCAL; + +impl OSCCAL { + pub const OSCCAL: RegisterBits = RegisterBits::new(0xff); + pub const OSCCAL0: RegisterBits = RegisterBits::new(1<<0); + pub const OSCCAL1: RegisterBits = RegisterBits::new(1<<1); + pub const OSCCAL2: RegisterBits = RegisterBits::new(1<<2); + pub const OSCCAL3: RegisterBits = RegisterBits::new(1<<3); + pub const OSCCAL4: RegisterBits = RegisterBits::new(1<<4); + pub const OSCCAL5: RegisterBits = RegisterBits::new(1<<5); + pub const OSCCAL6: RegisterBits = RegisterBits::new(1<<6); + pub const OSCCAL7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OSCCAL { + type T = u8; + const ADDRESS: *mut u8 = 0x31 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIMSK; + +impl GIMSK { + pub const INT0: RegisterBits = RegisterBits::new(0x40); + pub const INT00: RegisterBits = RegisterBits::new(1<<6); + + pub const PCIE: RegisterBits = RegisterBits::new(0x20); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIFR; + +impl GIFR { + pub const INTF0: RegisterBits = RegisterBits::new(0x40); + pub const INTF00: RegisterBits = RegisterBits::new(1<<6); + + pub const PCIF: RegisterBits = RegisterBits::new(0x20); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x3a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEAR; + +impl EEAR { +} + +impl Register for EEAR { + type T = u8; + const ADDRESS: *mut u8 = 0x1e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEDR; + +impl EEDR { +} + +impl Register for EEDR { + type T = u8; + const ADDRESS: *mut u8 = 0x1d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EECR; + +impl EECR { + pub const EERIE: RegisterBits = RegisterBits::new(0x8); + pub const EERIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const EEMWE: RegisterBits = RegisterBits::new(0x4); + pub const EEMWE0: RegisterBits = RegisterBits::new(1<<2); + + pub const EEWE: RegisterBits = RegisterBits::new(0x2); + pub const EEWE0: RegisterBits = RegisterBits::new(1<<1); + + pub const EERE: RegisterBits = RegisterBits::new(0x1); + pub const EERE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EECR { + type T = u8; + const ADDRESS: *mut u8 = 0x1c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x18 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x17 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x16 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const TOIE0: RegisterBits = RegisterBits::new(0x2); + pub const TOIE00: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x39 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const TOV0: RegisterBits = RegisterBits::new(0x2); + pub const TOV00: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x38 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0; + +impl TCCR0 { + pub const CS02: RegisterBits = RegisterBits::new(0x4); + pub const CS020: RegisterBits = RegisterBits::new(1<<2); + + pub const CS01: RegisterBits = RegisterBits::new(0x2); + pub const CS010: RegisterBits = RegisterBits::new(1<<1); + + pub const CS00: RegisterBits = RegisterBits::new(0x1); + pub const CS000: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x33 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0; + +impl TCNT0 { +} + +impl Register for TCNT0 { + type T = u8; + const ADDRESS: *mut u8 = 0x32 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct WDTCR; + +impl WDTCR { + pub const WDTOE: RegisterBits = RegisterBits::new(0x10); + pub const WDTOE0: RegisterBits = RegisterBits::new(1<<4); + + pub const WDE: RegisterBits = RegisterBits::new(0x8); + pub const WDE0: RegisterBits = RegisterBits::new(1<<3); + + pub const WDP: RegisterBits = RegisterBits::new(0x7); + pub const WDP0: RegisterBits = RegisterBits::new(1<<0); + pub const WDP1: RegisterBits = RegisterBits::new(1<<1); + pub const WDP2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for WDTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x21 as *mut u8; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + +} + + diff --git a/src/cores/attiny1634.rs b/src/cores/attiny1634.rs new file mode 100644 index 0000000..3484930 --- /dev/null +++ b/src/cores/attiny1634.rs @@ -0,0 +1,1746 @@ +//! Core for ATtiny1634. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + pub const BODPD: RegisterBits = RegisterBits::new(0x18); + pub const BODPD0: RegisterBits = RegisterBits::new(1<<3); + pub const BODPD1: RegisterBits = RegisterBits::new(1<<4); + + pub const BODACT: RegisterBits = RegisterBits::new(0x6); + pub const BODACT0: RegisterBits = RegisterBits::new(1<<1); + pub const BODACT1: RegisterBits = RegisterBits::new(1<<2); + + pub const SELFPRGEN: RegisterBits = RegisterBits::new(0x1); + pub const SELFPRGEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EXTENDED { + type T = u8; + const ADDRESS: *mut u8 = 0x2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct HIGH; + +impl HIGH { + pub const RSTDISBL: RegisterBits = RegisterBits::new(0x80); + pub const RSTDISBL0: RegisterBits = RegisterBits::new(1<<7); + + pub const DWEN: RegisterBits = RegisterBits::new(0x40); + pub const DWEN0: RegisterBits = RegisterBits::new(1<<6); + + pub const SPIEN: RegisterBits = RegisterBits::new(0x20); + pub const SPIEN0: RegisterBits = RegisterBits::new(1<<5); + + pub const WDTON: RegisterBits = RegisterBits::new(0x10); + pub const WDTON0: RegisterBits = RegisterBits::new(1<<4); + + pub const EESAVE: RegisterBits = RegisterBits::new(0x8); + pub const EESAVE0: RegisterBits = RegisterBits::new(1<<3); + + pub const BODLEVEL: RegisterBits = RegisterBits::new(0x7); + pub const BODLEVEL0: RegisterBits = RegisterBits::new(1<<0); + pub const BODLEVEL1: RegisterBits = RegisterBits::new(1<<1); + pub const BODLEVEL2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for HIGH { + type T = u8; + const ADDRESS: *mut u8 = 0x1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOW; + +impl LOW { + pub const CKDIV8: RegisterBits = RegisterBits::new(0x80); + pub const CKDIV80: RegisterBits = RegisterBits::new(1<<7); + + pub const CKOUT: RegisterBits = RegisterBits::new(0x40); + pub const CKOUT0: RegisterBits = RegisterBits::new(1<<6); + + pub const SUT_CKSEL: RegisterBits = RegisterBits::new(0x1f); + pub const SUT_CKSEL0: RegisterBits = RegisterBits::new(1<<0); + pub const SUT_CKSEL1: RegisterBits = RegisterBits::new(1<<1); + pub const SUT_CKSEL2: RegisterBits = RegisterBits::new(1<<2); + pub const SUT_CKSEL3: RegisterBits = RegisterBits::new(1<<3); + pub const SUT_CKSEL4: RegisterBits = RegisterBits::new(1<<4); + +} + +impl Register for LOW { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOCKBIT; + +impl LOCKBIT { + pub const LB: RegisterBits = RegisterBits::new(0x3); + pub const LB0: RegisterBits = RegisterBits::new(1<<0); + pub const LB1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for LOCKBIT { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSCRA; + +impl TWSCRA { + pub const TWSHE: RegisterBits = RegisterBits::new(0x80); + pub const TWSHE0: RegisterBits = RegisterBits::new(1<<7); + + pub const TWDIE: RegisterBits = RegisterBits::new(0x20); + pub const TWDIE0: RegisterBits = RegisterBits::new(1<<5); + + pub const TWASIE: RegisterBits = RegisterBits::new(0x10); + pub const TWASIE0: RegisterBits = RegisterBits::new(1<<4); + + pub const TWEN: RegisterBits = RegisterBits::new(0x8); + pub const TWEN0: RegisterBits = RegisterBits::new(1<<3); + + pub const TWSIE: RegisterBits = RegisterBits::new(0x4); + pub const TWSIE0: RegisterBits = RegisterBits::new(1<<2); + + pub const TWPME: RegisterBits = RegisterBits::new(0x2); + pub const TWPME0: RegisterBits = RegisterBits::new(1<<1); + + pub const TWSME: RegisterBits = RegisterBits::new(0x1); + pub const TWSME0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TWSCRA { + type T = u8; + const ADDRESS: *mut u8 = 0x7f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSCRB; + +impl TWSCRB { + pub const TWAA: RegisterBits = RegisterBits::new(0x4); + pub const TWAA0: RegisterBits = RegisterBits::new(1<<2); + + pub const TWCMD: RegisterBits = RegisterBits::new(0x3); + pub const TWCMD0: RegisterBits = RegisterBits::new(1<<0); + pub const TWCMD1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TWSCRB { + type T = u8; + const ADDRESS: *mut u8 = 0x7e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSSRA; + +impl TWSSRA { + pub const TWDIF: RegisterBits = RegisterBits::new(0x80); + pub const TWDIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const TWASIF: RegisterBits = RegisterBits::new(0x40); + pub const TWASIF0: RegisterBits = RegisterBits::new(1<<6); + + pub const TWCH: RegisterBits = RegisterBits::new(0x20); + pub const TWCH0: RegisterBits = RegisterBits::new(1<<5); + + pub const TWRA: RegisterBits = RegisterBits::new(0x10); + pub const TWRA0: RegisterBits = RegisterBits::new(1<<4); + + pub const TWC: RegisterBits = RegisterBits::new(0x8); + pub const TWC0: RegisterBits = RegisterBits::new(1<<3); + + pub const TWBE: RegisterBits = RegisterBits::new(0x4); + pub const TWBE0: RegisterBits = RegisterBits::new(1<<2); + + pub const TWDIR: RegisterBits = RegisterBits::new(0x2); + pub const TWDIR0: RegisterBits = RegisterBits::new(1<<1); + + pub const TWAS: RegisterBits = RegisterBits::new(0x1); + pub const TWAS0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TWSSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x7d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSA; + +impl TWSA { + pub const TWSA: RegisterBits = RegisterBits::new(0xff); + pub const TWSA0: RegisterBits = RegisterBits::new(1<<0); + pub const TWSA1: RegisterBits = RegisterBits::new(1<<1); + pub const TWSA2: RegisterBits = RegisterBits::new(1<<2); + pub const TWSA3: RegisterBits = RegisterBits::new(1<<3); + pub const TWSA4: RegisterBits = RegisterBits::new(1<<4); + pub const TWSA5: RegisterBits = RegisterBits::new(1<<5); + pub const TWSA6: RegisterBits = RegisterBits::new(1<<6); + pub const TWSA7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for TWSA { + type T = u8; + const ADDRESS: *mut u8 = 0x7c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSD; + +impl TWSD { + pub const TWSD: RegisterBits = RegisterBits::new(0xff); + pub const TWSD0: RegisterBits = RegisterBits::new(1<<0); + pub const TWSD1: RegisterBits = RegisterBits::new(1<<1); + pub const TWSD2: RegisterBits = RegisterBits::new(1<<2); + pub const TWSD3: RegisterBits = RegisterBits::new(1<<3); + pub const TWSD4: RegisterBits = RegisterBits::new(1<<4); + pub const TWSD5: RegisterBits = RegisterBits::new(1<<5); + pub const TWSD6: RegisterBits = RegisterBits::new(1<<6); + pub const TWSD7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for TWSD { + type T = u8; + const ADDRESS: *mut u8 = 0x7a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSAM; + +impl TWSAM { +} + +impl Register for TWSAM { + type T = u8; + const ADDRESS: *mut u8 = 0x7b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTCR; + +impl PORTCR { + pub const BBMB: RegisterBits = RegisterBits::new(0x2); + pub const BBMB0: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for PORTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x33 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PUEB; + +impl PUEB { + pub const PUEB: RegisterBits = RegisterBits::new(0xf); + pub const PUEB0: RegisterBits = RegisterBits::new(1<<0); + pub const PUEB1: RegisterBits = RegisterBits::new(1<<1); + pub const PUEB2: RegisterBits = RegisterBits::new(1<<2); + pub const PUEB3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for PUEB { + type T = u8; + const ADDRESS: *mut u8 = 0x2e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x2c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x2b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x2d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTCR; + +impl PORTCR { + pub const BBMC: RegisterBits = RegisterBits::new(0x4); + pub const BBMC0: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PORTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x33 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PUEC; + +impl PUEC { + pub const PUEC: RegisterBits = RegisterBits::new(0x3f); + pub const PUEC0: RegisterBits = RegisterBits::new(1<<0); + pub const PUEC1: RegisterBits = RegisterBits::new(1<<1); + pub const PUEC2: RegisterBits = RegisterBits::new(1<<2); + pub const PUEC3: RegisterBits = RegisterBits::new(1<<3); + pub const PUEC4: RegisterBits = RegisterBits::new(1<<4); + pub const PUEC5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for PUEC { + type T = u8; + const ADDRESS: *mut u8 = 0x2a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTC; + +impl PORTC { +} + +impl Register for PORTC { + type T = u8; + const ADDRESS: *mut u8 = 0x29 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRC; + +impl DDRC { +} + +impl Register for DDRC { + type T = u8; + const ADDRESS: *mut u8 = 0x28 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINC; + +impl PINC { +} + +impl Register for PINC { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTCR; + +impl PORTCR { + pub const BBMA: RegisterBits = RegisterBits::new(0x1); + pub const BBMA0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PORTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x33 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PUEA; + +impl PUEA { + pub const PUEA: RegisterBits = RegisterBits::new(0xff); + pub const PUEA0: RegisterBits = RegisterBits::new(1<<0); + pub const PUEA1: RegisterBits = RegisterBits::new(1<<1); + pub const PUEA2: RegisterBits = RegisterBits::new(1<<2); + pub const PUEA3: RegisterBits = RegisterBits::new(1<<3); + pub const PUEA4: RegisterBits = RegisterBits::new(1<<4); + pub const PUEA5: RegisterBits = RegisterBits::new(1<<5); + pub const PUEA6: RegisterBits = RegisterBits::new(1<<6); + pub const PUEA7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for PUEA { + type T = u8; + const ADDRESS: *mut u8 = 0x32 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTA; + +impl PORTA { +} + +impl Register for PORTA { + type T = u8; + const ADDRESS: *mut u8 = 0x31 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRA; + +impl DDRA { +} + +impl Register for DDRA { + type T = u8; + const ADDRESS: *mut u8 = 0x30 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINA; + +impl PINA { +} + +impl Register for PINA { + type T = u8; + const ADDRESS: *mut u8 = 0x2f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADMUX; + +impl ADMUX { + pub const REFS: RegisterBits = RegisterBits::new(0xc0); + pub const REFS0: RegisterBits = RegisterBits::new(1<<6); + pub const REFS1: RegisterBits = RegisterBits::new(1<<7); + + pub const REFEN: RegisterBits = RegisterBits::new(0x20); + pub const REFEN0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC0EN: RegisterBits = RegisterBits::new(0x10); + pub const ADC0EN0: RegisterBits = RegisterBits::new(1<<4); + + pub const MUX: RegisterBits = RegisterBits::new(0xf); + pub const MUX0: RegisterBits = RegisterBits::new(1<<0); + pub const MUX1: RegisterBits = RegisterBits::new(1<<1); + pub const MUX2: RegisterBits = RegisterBits::new(1<<2); + pub const MUX3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for ADMUX { + type T = u8; + const ADDRESS: *mut u8 = 0x24 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADCSRA; + +impl ADCSRA { + pub const ADEN: RegisterBits = RegisterBits::new(0x80); + pub const ADEN0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADSC: RegisterBits = RegisterBits::new(0x40); + pub const ADSC0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADATE: RegisterBits = RegisterBits::new(0x20); + pub const ADATE0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADIF: RegisterBits = RegisterBits::new(0x10); + pub const ADIF0: RegisterBits = RegisterBits::new(1<<4); + + pub const ADIE: RegisterBits = RegisterBits::new(0x8); + pub const ADIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADPS: RegisterBits = RegisterBits::new(0x7); + pub const ADPS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADPS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADPS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x23 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x20 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ADCSRB; + +impl ADCSRB { + pub const VDEN: RegisterBits = RegisterBits::new(0x80); + pub const VDEN0: RegisterBits = RegisterBits::new(1<<7); + + pub const VDPD: RegisterBits = RegisterBits::new(0x40); + pub const VDPD0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADLAR: RegisterBits = RegisterBits::new(0x8); + pub const ADLAR0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADTS: RegisterBits = RegisterBits::new(0x7); + pub const ADTS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADTS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADTS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x22 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR2; + +impl DIDR2 { + pub const ADC11D: RegisterBits = RegisterBits::new(0x4); + pub const ADC11D0: RegisterBits = RegisterBits::new(1<<2); + + pub const ADC10D: RegisterBits = RegisterBits::new(0x2); + pub const ADC10D0: RegisterBits = RegisterBits::new(1<<1); + + pub const ADC9D: RegisterBits = RegisterBits::new(0x1); + pub const ADC9D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for DIDR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x62 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + pub const ADC8D: RegisterBits = RegisterBits::new(0x8); + pub const ADC8D0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADC7D: RegisterBits = RegisterBits::new(0x4); + pub const ADC7D0: RegisterBits = RegisterBits::new(1<<2); + + pub const ADC6D: RegisterBits = RegisterBits::new(0x2); + pub const ADC6D0: RegisterBits = RegisterBits::new(1<<1); + + pub const ADC5D: RegisterBits = RegisterBits::new(0x1); + pub const ADC5D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x61 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + pub const ADC4D: RegisterBits = RegisterBits::new(0x80); + pub const ADC4D0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADC3D: RegisterBits = RegisterBits::new(0x40); + pub const ADC3D0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADC2D: RegisterBits = RegisterBits::new(0x20); + pub const ADC2D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC1D: RegisterBits = RegisterBits::new(0x10); + pub const ADC1D0: RegisterBits = RegisterBits::new(1<<4); + + pub const ADC0D: RegisterBits = RegisterBits::new(0x8); + pub const ADC0D0: RegisterBits = RegisterBits::new(1<<3); + + pub const AIN1D: RegisterBits = RegisterBits::new(0x4); + pub const AIN1D0: RegisterBits = RegisterBits::new(1<<2); + + pub const AIN0D: RegisterBits = RegisterBits::new(0x2); + pub const AIN0D0: RegisterBits = RegisterBits::new(1<<1); + + pub const AREFD: RegisterBits = RegisterBits::new(0x1); + pub const AREFD0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for DIDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x60 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSRB; + +impl ACSRB { + pub const HSEL: RegisterBits = RegisterBits::new(0x80); + pub const HSEL0: RegisterBits = RegisterBits::new(1<<7); + + pub const HLEV: RegisterBits = RegisterBits::new(0x40); + pub const HLEV0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACLP: RegisterBits = RegisterBits::new(0x20); + pub const ACLP0: RegisterBits = RegisterBits::new(1<<5); + + pub const ACCE: RegisterBits = RegisterBits::new(0x8); + pub const ACCE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ACME: RegisterBits = RegisterBits::new(0x4); + pub const ACME0: RegisterBits = RegisterBits::new(1<<2); + + pub const ACIRS: RegisterBits = RegisterBits::new(0x3); + pub const ACIRS0: RegisterBits = RegisterBits::new(1<<0); + pub const ACIRS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for ACSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x25 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSRA; + +impl ACSRA { + pub const ACD: RegisterBits = RegisterBits::new(0x80); + pub const ACD0: RegisterBits = RegisterBits::new(1<<7); + + pub const ACBG: RegisterBits = RegisterBits::new(0x40); + pub const ACBG0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACO: RegisterBits = RegisterBits::new(0x20); + pub const ACO0: RegisterBits = RegisterBits::new(1<<5); + + pub const ACI: RegisterBits = RegisterBits::new(0x10); + pub const ACI0: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIE: RegisterBits = RegisterBits::new(0x8); + pub const ACIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ACIC: RegisterBits = RegisterBits::new(0x4); + pub const ACIC0: RegisterBits = RegisterBits::new(1<<2); + + pub const ACIS: RegisterBits = RegisterBits::new(0x3); + pub const ACIS0: RegisterBits = RegisterBits::new(1<<0); + pub const ACIS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for ACSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x26 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEAR; + +impl EEAR { +} + +impl Register for EEAR { + type T = u16; + const ADDRESS: *mut u16 = 0x3e as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct EEDR; + +impl EEDR { +} + +impl Register for EEDR { + type T = u8; + const ADDRESS: *mut u8 = 0x3d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EECR; + +impl EECR { + pub const EEPM: RegisterBits = RegisterBits::new(0x30); + pub const EEPM0: RegisterBits = RegisterBits::new(1<<4); + pub const EEPM1: RegisterBits = RegisterBits::new(1<<5); + + pub const EERIE: RegisterBits = RegisterBits::new(0x8); + pub const EERIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const EEMPE: RegisterBits = RegisterBits::new(0x4); + pub const EEMPE0: RegisterBits = RegisterBits::new(1<<2); + + pub const EEPE: RegisterBits = RegisterBits::new(0x2); + pub const EEPE0: RegisterBits = RegisterBits::new(1<<1); + + pub const EERE: RegisterBits = RegisterBits::new(0x1); + pub const EERE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EECR { + type T = u8; + const ADDRESS: *mut u8 = 0x3c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const TOIE1: RegisterBits = RegisterBits::new(0x80); + pub const TOIE10: RegisterBits = RegisterBits::new(1<<7); + + pub const OCIE1A: RegisterBits = RegisterBits::new(0x40); + pub const OCIE1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x20); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const ICIE1: RegisterBits = RegisterBits::new(0x8); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x5a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const TOV1: RegisterBits = RegisterBits::new(0x80); + pub const TOV10: RegisterBits = RegisterBits::new(1<<7); + + pub const OCF1A: RegisterBits = RegisterBits::new(0x40); + pub const OCF1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x20); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const ICF1: RegisterBits = RegisterBits::new(0x8); + pub const ICF10: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1A; + +impl TCCR1A { + pub const COM1A: RegisterBits = RegisterBits::new(0xc0); + pub const COM1A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM1A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM1B: RegisterBits = RegisterBits::new(0x30); + pub const COM1B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM1B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM1: RegisterBits = RegisterBits::new(0x3); + pub const WGM10: RegisterBits = RegisterBits::new(1<<0); + pub const WGM11: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x72 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1B; + +impl TCCR1B { + pub const ICNC1: RegisterBits = RegisterBits::new(0x80); + pub const ICNC10: RegisterBits = RegisterBits::new(1<<7); + + pub const ICES1: RegisterBits = RegisterBits::new(0x40); + pub const ICES10: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM1: RegisterBits = RegisterBits::new(0x18); + pub const WGM10: RegisterBits = RegisterBits::new(1<<3); + pub const WGM11: RegisterBits = RegisterBits::new(1<<4); + + pub const CS1: RegisterBits = RegisterBits::new(0x7); + pub const CS10: RegisterBits = RegisterBits::new(1<<0); + pub const CS11: RegisterBits = RegisterBits::new(1<<1); + pub const CS12: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x71 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1C; + +impl TCCR1C { + pub const FOC1A: RegisterBits = RegisterBits::new(0x80); + pub const FOC1A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC1B: RegisterBits = RegisterBits::new(0x40); + pub const FOC1B0: RegisterBits = RegisterBits::new(1<<6); + +} + +impl Register for TCCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x70 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT1; + +impl TCNT1 { +} + +impl Register for TCNT1 { + type T = u16; + const ADDRESS: *mut u16 = 0x6e as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x6c as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x6a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x68 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE0B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE0B0: RegisterBits = RegisterBits::new(1<<2); + + pub const TOIE0: RegisterBits = RegisterBits::new(0x2); + pub const TOIE00: RegisterBits = RegisterBits::new(1<<1); + + pub const OCIE0A: RegisterBits = RegisterBits::new(0x1); + pub const OCIE0A0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x5a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF0B: RegisterBits = RegisterBits::new(0x4); + pub const OCF0B0: RegisterBits = RegisterBits::new(1<<2); + + pub const TOV0: RegisterBits = RegisterBits::new(0x2); + pub const TOV00: RegisterBits = RegisterBits::new(1<<1); + + pub const OCF0A: RegisterBits = RegisterBits::new(0x1); + pub const OCF0A0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0B; + +impl OCR0B { +} + +impl Register for OCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x38 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0A; + +impl TCCR0A { + pub const COM0A: RegisterBits = RegisterBits::new(0xc0); + pub const COM0A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM0A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM0B: RegisterBits = RegisterBits::new(0x30); + pub const COM0B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM0B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM0: RegisterBits = RegisterBits::new(0x3); + pub const WGM00: RegisterBits = RegisterBits::new(1<<0); + pub const WGM01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0; + +impl TCNT0 { +} + +impl Register for TCNT0 { + type T = u8; + const ADDRESS: *mut u8 = 0x39 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0B; + +impl TCCR0B { + pub const FOC0A: RegisterBits = RegisterBits::new(0x80); + pub const FOC0A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC0B: RegisterBits = RegisterBits::new(0x40); + pub const FOC0B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM02: RegisterBits = RegisterBits::new(0x8); + pub const WGM020: RegisterBits = RegisterBits::new(1<<3); + + pub const CS0: RegisterBits = RegisterBits::new(0x7); + pub const CS00: RegisterBits = RegisterBits::new(1<<0); + pub const CS01: RegisterBits = RegisterBits::new(1<<1); + pub const CS02: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x3a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK2; + +impl PCMSK2 { + pub const PCINT: RegisterBits = RegisterBits::new(0x3f); + pub const PCINT0: RegisterBits = RegisterBits::new(1<<0); + pub const PCINT1: RegisterBits = RegisterBits::new(1<<1); + pub const PCINT2: RegisterBits = RegisterBits::new(1<<2); + pub const PCINT3: RegisterBits = RegisterBits::new(1<<3); + pub const PCINT4: RegisterBits = RegisterBits::new(1<<4); + pub const PCINT5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for PCMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x49 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { + pub const PCINT: RegisterBits = RegisterBits::new(0xf); + pub const PCINT0: RegisterBits = RegisterBits::new(1<<0); + pub const PCINT1: RegisterBits = RegisterBits::new(1<<1); + pub const PCINT2: RegisterBits = RegisterBits::new(1<<2); + pub const PCINT3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x48 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK0; + +impl PCMSK0 { + pub const PCINT: RegisterBits = RegisterBits::new(0xff); + pub const PCINT0: RegisterBits = RegisterBits::new(1<<0); + pub const PCINT1: RegisterBits = RegisterBits::new(1<<1); + pub const PCINT2: RegisterBits = RegisterBits::new(1<<2); + pub const PCINT3: RegisterBits = RegisterBits::new(1<<3); + pub const PCINT4: RegisterBits = RegisterBits::new(1<<4); + pub const PCINT5: RegisterBits = RegisterBits::new(1<<5); + pub const PCINT6: RegisterBits = RegisterBits::new(1<<6); + pub const PCINT7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for PCMSK0 { + type T = u8; + const ADDRESS: *mut u8 = 0x47 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIFR; + +impl GIFR { + pub const INTF0: RegisterBits = RegisterBits::new(0x40); + pub const INTF00: RegisterBits = RegisterBits::new(1<<6); + + pub const PCIF: RegisterBits = RegisterBits::new(0x38); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<3); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<4); + pub const PCIF2: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x5b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIMSK; + +impl GIMSK { + pub const INT0: RegisterBits = RegisterBits::new(0x40); + pub const INT00: RegisterBits = RegisterBits::new(1<<6); + + pub const PCIE: RegisterBits = RegisterBits::new(0x38); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<3); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<4); + pub const PCIE2: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x5c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTWI: RegisterBits = RegisterBits::new(0x40); + pub const PRTWI0: RegisterBits = RegisterBits::new(1<<6); + + pub const PRTIM1: RegisterBits = RegisterBits::new(0x20); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<5); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x10); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<4); + + pub const PRUSI: RegisterBits = RegisterBits::new(0x8); + pub const PRUSI0: RegisterBits = RegisterBits::new(1<<3); + + pub const PRUSART1: RegisterBits = RegisterBits::new(0x4); + pub const PRUSART10: RegisterBits = RegisterBits::new(1<<2); + + pub const PRUSART0: RegisterBits = RegisterBits::new(0x2); + pub const PRUSART00: RegisterBits = RegisterBits::new(1<<1); + + pub const PRADC: RegisterBits = RegisterBits::new(0x1); + pub const PRADC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PRR { + type T = u8; + const ADDRESS: *mut u8 = 0x54 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CCP; + +impl CCP { +} + +impl Register for CCP { + type T = u8; + const ADDRESS: *mut u8 = 0x4f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCCAL0; + +impl OSCCAL0 { +} + +impl Register for OSCCAL0 { + type T = u8; + const ADDRESS: *mut u8 = 0x63 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCCAL1; + +impl OSCCAL1 { +} + +impl Register for OSCCAL1 { + type T = u8; + const ADDRESS: *mut u8 = 0x66 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCTCAL0A; + +impl OSCTCAL0A { +} + +impl Register for OSCTCAL0A { + type T = u8; + const ADDRESS: *mut u8 = 0x64 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCTCAL0B; + +impl OSCTCAL0B { +} + +impl Register for OSCTCAL0B { + type T = u8; + const ADDRESS: *mut u8 = 0x65 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKPR; + +impl CLKPR { + pub const CLKPS: RegisterBits = RegisterBits::new(0xf); + pub const CLKPS0: RegisterBits = RegisterBits::new(1<<0); + pub const CLKPS1: RegisterBits = RegisterBits::new(1<<1); + pub const CLKPS2: RegisterBits = RegisterBits::new(1<<2); + pub const CLKPS3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CLKPR { + type T = u8; + const ADDRESS: *mut u8 = 0x53 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKSR; + +impl CLKSR { + pub const OSCRDY: RegisterBits = RegisterBits::new(0x80); + pub const OSCRDY0: RegisterBits = RegisterBits::new(1<<7); + + pub const CSTR: RegisterBits = RegisterBits::new(0x40); + pub const CSTR0: RegisterBits = RegisterBits::new(1<<6); + + pub const CKOUT_IO: RegisterBits = RegisterBits::new(0x20); + pub const CKOUT_IO0: RegisterBits = RegisterBits::new(1<<5); + + pub const SUT: RegisterBits = RegisterBits::new(0x10); + pub const SUT0: RegisterBits = RegisterBits::new(1<<4); + + pub const CKSEL: RegisterBits = RegisterBits::new(0xf); + pub const CKSEL0: RegisterBits = RegisterBits::new(1<<0); + pub const CKSEL1: RegisterBits = RegisterBits::new(1<<1); + pub const CKSEL2: RegisterBits = RegisterBits::new(1<<2); + pub const CKSEL3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CLKSR { + type T = u8; + const ADDRESS: *mut u8 = 0x52 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SREG; + +impl SREG { + pub const I: RegisterBits = RegisterBits::new(0x80); + pub const I0: RegisterBits = RegisterBits::new(1<<7); + + pub const T: RegisterBits = RegisterBits::new(0x40); + pub const T0: RegisterBits = RegisterBits::new(1<<6); + + pub const H: RegisterBits = RegisterBits::new(0x20); + pub const H0: RegisterBits = RegisterBits::new(1<<5); + + pub const S: RegisterBits = RegisterBits::new(0x10); + pub const S0: RegisterBits = RegisterBits::new(1<<4); + + pub const V: RegisterBits = RegisterBits::new(0x8); + pub const V0: RegisterBits = RegisterBits::new(1<<3); + + pub const N: RegisterBits = RegisterBits::new(0x4); + pub const N0: RegisterBits = RegisterBits::new(1<<2); + + pub const Z: RegisterBits = RegisterBits::new(0x2); + pub const Z0: RegisterBits = RegisterBits::new(1<<1); + + pub const C: RegisterBits = RegisterBits::new(0x1); + pub const C0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SREG { + type T = u8; + const ADDRESS: *mut u8 = 0x5f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SP; + +impl SP { +} + +impl Register for SP { + type T = u16; + const ADDRESS: *mut u16 = 0x5d as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const SM: RegisterBits = RegisterBits::new(0x60); + pub const SM0: RegisterBits = RegisterBits::new(1<<5); + pub const SM1: RegisterBits = RegisterBits::new(1<<6); + + pub const SE: RegisterBits = RegisterBits::new(0x10); + pub const SE0: RegisterBits = RegisterBits::new(1<<4); + + pub const ISC0: RegisterBits = RegisterBits::new(0x3); + pub const ISC00: RegisterBits = RegisterBits::new(1<<0); + pub const ISC01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x56 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUSR; + +impl MCUSR { + pub const WDRF: RegisterBits = RegisterBits::new(0x8); + pub const WDRF0: RegisterBits = RegisterBits::new(1<<3); + + pub const BORF: RegisterBits = RegisterBits::new(0x4); + pub const BORF0: RegisterBits = RegisterBits::new(1<<2); + + pub const EXTRF: RegisterBits = RegisterBits::new(0x2); + pub const EXTRF0: RegisterBits = RegisterBits::new(1<<1); + + pub const PORF: RegisterBits = RegisterBits::new(0x1); + pub const PORF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUSR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR2; + +impl GPIOR2 { +} + +impl Register for GPIOR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x36 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR1; + +impl GPIOR1 { +} + +impl Register for GPIOR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x35 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR0; + +impl GPIOR0 { +} + +impl Register for GPIOR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x34 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPMCSR; + +impl SPMCSR { + pub const RSIG: RegisterBits = RegisterBits::new(0x20); + pub const RSIG0: RegisterBits = RegisterBits::new(1<<5); + + pub const CTPB: RegisterBits = RegisterBits::new(0x10); + pub const CTPB0: RegisterBits = RegisterBits::new(1<<4); + + pub const RFLB: RegisterBits = RegisterBits::new(0x8); + pub const RFLB0: RegisterBits = RegisterBits::new(1<<3); + + pub const PGWRT: RegisterBits = RegisterBits::new(0x4); + pub const PGWRT0: RegisterBits = RegisterBits::new(1<<2); + + pub const PGERS: RegisterBits = RegisterBits::new(0x2); + pub const PGERS0: RegisterBits = RegisterBits::new(1<<1); + + pub const SPMEN: RegisterBits = RegisterBits::new(0x1); + pub const SPMEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SPMCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x57 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIBR; + +impl USIBR { +} + +impl Register for USIBR { + type T = u8; + const ADDRESS: *mut u8 = 0x4d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIDR; + +impl USIDR { +} + +impl Register for USIDR { + type T = u8; + const ADDRESS: *mut u8 = 0x4c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USISR; + +impl USISR { + pub const USISIF: RegisterBits = RegisterBits::new(0x80); + pub const USISIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIF: RegisterBits = RegisterBits::new(0x40); + pub const USIOIF0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIPF: RegisterBits = RegisterBits::new(0x20); + pub const USIPF0: RegisterBits = RegisterBits::new(1<<5); + + pub const USIDC: RegisterBits = RegisterBits::new(0x10); + pub const USIDC0: RegisterBits = RegisterBits::new(1<<4); + + pub const USICNT: RegisterBits = RegisterBits::new(0xf); + pub const USICNT0: RegisterBits = RegisterBits::new(1<<0); + pub const USICNT1: RegisterBits = RegisterBits::new(1<<1); + pub const USICNT2: RegisterBits = RegisterBits::new(1<<2); + pub const USICNT3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for USISR { + type T = u8; + const ADDRESS: *mut u8 = 0x4b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USICR; + +impl USICR { + pub const USISIE: RegisterBits = RegisterBits::new(0x80); + pub const USISIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIE: RegisterBits = RegisterBits::new(0x40); + pub const USIOIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIWM: RegisterBits = RegisterBits::new(0x30); + pub const USIWM0: RegisterBits = RegisterBits::new(1<<4); + pub const USIWM1: RegisterBits = RegisterBits::new(1<<5); + + pub const USICS: RegisterBits = RegisterBits::new(0xc); + pub const USICS0: RegisterBits = RegisterBits::new(1<<2); + pub const USICS1: RegisterBits = RegisterBits::new(1<<3); + + pub const USICLK: RegisterBits = RegisterBits::new(0x2); + pub const USICLK0: RegisterBits = RegisterBits::new(1<<1); + + pub const USITC: RegisterBits = RegisterBits::new(0x1); + pub const USITC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for USICR { + type T = u8; + const ADDRESS: *mut u8 = 0x4a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UDR0; + +impl UDR0 { +} + +impl Register for UDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x40 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UCSR0A; + +impl UCSR0A { + pub const RXC0: RegisterBits = RegisterBits::new(0x80); + pub const RXC00: RegisterBits = RegisterBits::new(1<<7); + + pub const TXC0: RegisterBits = RegisterBits::new(0x40); + pub const TXC00: RegisterBits = RegisterBits::new(1<<6); + + pub const UDRE0: RegisterBits = RegisterBits::new(0x20); + pub const UDRE00: RegisterBits = RegisterBits::new(1<<5); + + pub const FE0: RegisterBits = RegisterBits::new(0x10); + pub const FE00: RegisterBits = RegisterBits::new(1<<4); + + pub const DOR0: RegisterBits = RegisterBits::new(0x8); + pub const DOR00: RegisterBits = RegisterBits::new(1<<3); + + pub const UPE0: RegisterBits = RegisterBits::new(0x4); + pub const UPE00: RegisterBits = RegisterBits::new(1<<2); + + pub const U2X0: RegisterBits = RegisterBits::new(0x2); + pub const U2X00: RegisterBits = RegisterBits::new(1<<1); + + pub const MPCM0: RegisterBits = RegisterBits::new(0x1); + pub const MPCM00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for UCSR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x46 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UCSR0B; + +impl UCSR0B { + pub const RXCIE0: RegisterBits = RegisterBits::new(0x80); + pub const RXCIE00: RegisterBits = RegisterBits::new(1<<7); + + pub const TXCIE0: RegisterBits = RegisterBits::new(0x40); + pub const TXCIE00: RegisterBits = RegisterBits::new(1<<6); + + pub const UDRIE0: RegisterBits = RegisterBits::new(0x20); + pub const UDRIE00: RegisterBits = RegisterBits::new(1<<5); + + pub const RXEN0: RegisterBits = RegisterBits::new(0x10); + pub const RXEN00: RegisterBits = RegisterBits::new(1<<4); + + pub const TXEN0: RegisterBits = RegisterBits::new(0x8); + pub const TXEN00: RegisterBits = RegisterBits::new(1<<3); + + pub const UCSZ02: RegisterBits = RegisterBits::new(0x4); + pub const UCSZ020: RegisterBits = RegisterBits::new(1<<2); + + pub const RXB80: RegisterBits = RegisterBits::new(0x2); + pub const RXB800: RegisterBits = RegisterBits::new(1<<1); + + pub const TXB80: RegisterBits = RegisterBits::new(0x1); + pub const TXB800: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for UCSR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x45 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UCSR0C; + +impl UCSR0C { + pub const UMSEL0: RegisterBits = RegisterBits::new(0xc0); + pub const UMSEL00: RegisterBits = RegisterBits::new(1<<6); + pub const UMSEL01: RegisterBits = RegisterBits::new(1<<7); + + pub const UPM0: RegisterBits = RegisterBits::new(0x30); + pub const UPM00: RegisterBits = RegisterBits::new(1<<4); + pub const UPM01: RegisterBits = RegisterBits::new(1<<5); + + pub const USBS0: RegisterBits = RegisterBits::new(0x8); + pub const USBS00: RegisterBits = RegisterBits::new(1<<3); + + pub const UCSZ0: RegisterBits = RegisterBits::new(0x6); + pub const UCSZ00: RegisterBits = RegisterBits::new(1<<1); + pub const UCSZ01: RegisterBits = RegisterBits::new(1<<2); + + pub const UCPOL0: RegisterBits = RegisterBits::new(0x1); + pub const UCPOL00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for UCSR0C { + type T = u8; + const ADDRESS: *mut u8 = 0x44 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UCSR0D; + +impl UCSR0D { + pub const RXSIE0: RegisterBits = RegisterBits::new(0x80); + pub const RXSIE00: RegisterBits = RegisterBits::new(1<<7); + + pub const RXS0: RegisterBits = RegisterBits::new(0x40); + pub const RXS00: RegisterBits = RegisterBits::new(1<<6); + + pub const SFDE0: RegisterBits = RegisterBits::new(0x20); + pub const SFDE00: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for UCSR0D { + type T = u8; + const ADDRESS: *mut u8 = 0x43 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRR0; + +impl UBRR0 { +} + +impl Register for UBRR0 { + type T = u16; + const ADDRESS: *mut u16 = 0x41 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct UDR1; + +impl UDR1 { +} + +impl Register for UDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x73 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UCSR1A; + +impl UCSR1A { + pub const RXC1: RegisterBits = RegisterBits::new(0x80); + pub const RXC10: RegisterBits = RegisterBits::new(1<<7); + + pub const TXC1: RegisterBits = RegisterBits::new(0x40); + pub const TXC10: RegisterBits = RegisterBits::new(1<<6); + + pub const UDRE1: RegisterBits = RegisterBits::new(0x20); + pub const UDRE10: RegisterBits = RegisterBits::new(1<<5); + + pub const FE1: RegisterBits = RegisterBits::new(0x10); + pub const FE10: RegisterBits = RegisterBits::new(1<<4); + + pub const DOR1: RegisterBits = RegisterBits::new(0x8); + pub const DOR10: RegisterBits = RegisterBits::new(1<<3); + + pub const UPE1: RegisterBits = RegisterBits::new(0x4); + pub const UPE10: RegisterBits = RegisterBits::new(1<<2); + + pub const U2X1: RegisterBits = RegisterBits::new(0x2); + pub const U2X10: RegisterBits = RegisterBits::new(1<<1); + + pub const MPCM1: RegisterBits = RegisterBits::new(0x1); + pub const MPCM10: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for UCSR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x79 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UCSR1B; + +impl UCSR1B { + pub const RXCIE1: RegisterBits = RegisterBits::new(0x80); + pub const RXCIE10: RegisterBits = RegisterBits::new(1<<7); + + pub const TXCIE1: RegisterBits = RegisterBits::new(0x40); + pub const TXCIE10: RegisterBits = RegisterBits::new(1<<6); + + pub const UDRIE1: RegisterBits = RegisterBits::new(0x20); + pub const UDRIE10: RegisterBits = RegisterBits::new(1<<5); + + pub const RXEN1: RegisterBits = RegisterBits::new(0x10); + pub const RXEN10: RegisterBits = RegisterBits::new(1<<4); + + pub const TXEN1: RegisterBits = RegisterBits::new(0x8); + pub const TXEN10: RegisterBits = RegisterBits::new(1<<3); + + pub const UCSZ12: RegisterBits = RegisterBits::new(0x4); + pub const UCSZ120: RegisterBits = RegisterBits::new(1<<2); + + pub const RXB81: RegisterBits = RegisterBits::new(0x2); + pub const RXB810: RegisterBits = RegisterBits::new(1<<1); + + pub const TXB81: RegisterBits = RegisterBits::new(0x1); + pub const TXB810: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for UCSR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x78 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UCSR1C; + +impl UCSR1C { + pub const UMSEL1: RegisterBits = RegisterBits::new(0xc0); + pub const UMSEL10: RegisterBits = RegisterBits::new(1<<6); + pub const UMSEL11: RegisterBits = RegisterBits::new(1<<7); + + pub const UPM1: RegisterBits = RegisterBits::new(0x30); + pub const UPM10: RegisterBits = RegisterBits::new(1<<4); + pub const UPM11: RegisterBits = RegisterBits::new(1<<5); + + pub const USBS1: RegisterBits = RegisterBits::new(0x8); + pub const USBS10: RegisterBits = RegisterBits::new(1<<3); + + pub const UCSZ1: RegisterBits = RegisterBits::new(0x6); + pub const UCSZ10: RegisterBits = RegisterBits::new(1<<1); + pub const UCSZ11: RegisterBits = RegisterBits::new(1<<2); + + pub const UCPOL1: RegisterBits = RegisterBits::new(0x1); + pub const UCPOL10: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for UCSR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x77 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UCSR1D; + +impl UCSR1D { + pub const RXSIE1: RegisterBits = RegisterBits::new(0x80); + pub const RXSIE10: RegisterBits = RegisterBits::new(1<<7); + + pub const RXS1: RegisterBits = RegisterBits::new(0x40); + pub const RXS10: RegisterBits = RegisterBits::new(1<<6); + + pub const SFDE1: RegisterBits = RegisterBits::new(0x20); + pub const SFDE10: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for UCSR1D { + type T = u8; + const ADDRESS: *mut u8 = 0x76 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRR1; + +impl UBRR1 { +} + +impl Register for UBRR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x74 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct WDTCSR; + +impl WDTCSR { + pub const WDIF: RegisterBits = RegisterBits::new(0x80); + pub const WDIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WDIE: RegisterBits = RegisterBits::new(0x40); + pub const WDIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const WDP: RegisterBits = RegisterBits::new(0x27); + pub const WDP0: RegisterBits = RegisterBits::new(1<<0); + pub const WDP1: RegisterBits = RegisterBits::new(1<<1); + pub const WDP2: RegisterBits = RegisterBits::new(1<<2); + pub const WDP3: RegisterBits = RegisterBits::new(1<<5); + + pub const WDE: RegisterBits = RegisterBits::new(0x8); + pub const WDE0: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for WDTCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x50 as *mut u8; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + +} + +/// The USART0 module. +pub struct USART0; + +impl modules::HardwareUsart for USART0 { + type DataRegister = UDR0; + type ControlRegisterA = UCSR0A; + type ControlRegisterB = UCSR0B; + type ControlRegisterC = UCSR0C; + type ControlRegisterD = UCSR0D; + type BaudRateRegister = UBRR0; +} + +/// The USART1 module. +pub struct USART1; + +impl modules::HardwareUsart for USART1 { + type DataRegister = UDR1; + type ControlRegisterA = UCSR1A; + type ControlRegisterB = UCSR1B; + type ControlRegisterC = UCSR1C; + type ControlRegisterD = UCSR1D; + type BaudRateRegister = UBRR1; +} + +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR0A; + type CompareB = OCR0B; + type Counter = TCNT0; + type ControlA = TCCR0A; + type ControlB = TCCR0B; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE0A; +} +/// 16-bit timer. +pub struct Timer16; + +impl modules::Timer16 for Timer16 { + type CompareA = OCR1A; + type CompareB = OCR1B; + type Counter = TCNT1; + type ControlA = TCCR1A; + type ControlB = TCCR1B; + type ControlC = TCCR1C; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS10; + const CS1: RegisterBits = Self::ControlB::CS11; + const CS2: RegisterBits = Self::ControlB::CS12; + const WGM0: RegisterBits = Self::ControlA::WGM10; + const WGM1: RegisterBits = Self::ControlA::WGM11; + const WGM2: RegisterBits = Self::ControlB::WGM10; + const WGM3: RegisterBits = Self::ControlB::WGM11; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE1A; +} + diff --git a/src/cores/attiny20.rs b/src/cores/attiny20.rs new file mode 100644 index 0000000..af79d95 --- /dev/null +++ b/src/cores/attiny20.rs @@ -0,0 +1,1342 @@ +//! Core for ATtiny20. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct BYTE0; + +impl BYTE0 { + pub const BODLEVEL: RegisterBits = RegisterBits::new(0x70); + pub const BODLEVEL0: RegisterBits = RegisterBits::new(1<<4); + pub const BODLEVEL1: RegisterBits = RegisterBits::new(1<<5); + pub const BODLEVEL2: RegisterBits = RegisterBits::new(1<<6); + + pub const CKOUT: RegisterBits = RegisterBits::new(0x4); + pub const CKOUT0: RegisterBits = RegisterBits::new(1<<2); + + pub const WDTON: RegisterBits = RegisterBits::new(0x2); + pub const WDTON0: RegisterBits = RegisterBits::new(1<<1); + + pub const RSTDISBL: RegisterBits = RegisterBits::new(0x1); + pub const RSTDISBL0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for BYTE0 { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOCKBIT; + +impl LOCKBIT { + pub const LB: RegisterBits = RegisterBits::new(0x3); + pub const LB0: RegisterBits = RegisterBits::new(1<<0); + pub const LB1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for LOCKBIT { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTCR; + +impl PORTCR { + pub const BBMB: RegisterBits = RegisterBits::new(0x2); + pub const BBMB0: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for PORTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x8 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PUEB; + +impl PUEB { +} + +impl Register for PUEB { + type T = u8; + const ADDRESS: *mut u8 = 0x7 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x5 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x4 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x6 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTCR; + +impl PORTCR { + pub const BBMA: RegisterBits = RegisterBits::new(0x1); + pub const BBMA0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PORTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x8 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PUEA; + +impl PUEA { +} + +impl Register for PUEA { + type T = u8; + const ADDRESS: *mut u8 = 0x3 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTA; + +impl PORTA { +} + +impl Register for PORTA { + type T = u8; + const ADDRESS: *mut u8 = 0x2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRA; + +impl DDRA { +} + +impl Register for DDRA { + type T = u8; + const ADDRESS: *mut u8 = 0x1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINA; + +impl PINA { +} + +impl Register for PINA { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct WDTCSR; + +impl WDTCSR { + pub const WDIF: RegisterBits = RegisterBits::new(0x80); + pub const WDIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WDIE: RegisterBits = RegisterBits::new(0x40); + pub const WDIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const WDP: RegisterBits = RegisterBits::new(0x27); + pub const WDP0: RegisterBits = RegisterBits::new(1<<0); + pub const WDP1: RegisterBits = RegisterBits::new(1<<1); + pub const WDP2: RegisterBits = RegisterBits::new(1<<2); + pub const WDP3: RegisterBits = RegisterBits::new(1<<5); + + pub const WDE: RegisterBits = RegisterBits::new(0x8); + pub const WDE0: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for WDTCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x31 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADMUX; + +impl ADMUX { + pub const REFS: RegisterBits = RegisterBits::new(0x40); + pub const REFS0: RegisterBits = RegisterBits::new(1<<6); + + pub const MUX: RegisterBits = RegisterBits::new(0xf); + pub const MUX0: RegisterBits = RegisterBits::new(1<<0); + pub const MUX1: RegisterBits = RegisterBits::new(1<<1); + pub const MUX2: RegisterBits = RegisterBits::new(1<<2); + pub const MUX3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for ADMUX { + type T = u8; + const ADDRESS: *mut u8 = 0x10 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADCSRA; + +impl ADCSRA { + pub const ADEN: RegisterBits = RegisterBits::new(0x80); + pub const ADEN0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADSC: RegisterBits = RegisterBits::new(0x40); + pub const ADSC0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADATE: RegisterBits = RegisterBits::new(0x20); + pub const ADATE0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADIF: RegisterBits = RegisterBits::new(0x10); + pub const ADIF0: RegisterBits = RegisterBits::new(1<<4); + + pub const ADIE: RegisterBits = RegisterBits::new(0x8); + pub const ADIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADPS: RegisterBits = RegisterBits::new(0x7); + pub const ADPS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADPS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADPS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x12 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0xe as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ADCSRB; + +impl ADCSRB { + pub const ADLAR: RegisterBits = RegisterBits::new(0x8); + pub const ADLAR0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADTS: RegisterBits = RegisterBits::new(0x7); + pub const ADTS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADTS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADTS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x11 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + pub const ADC7D: RegisterBits = RegisterBits::new(0x80); + pub const ADC7D0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADC6D: RegisterBits = RegisterBits::new(0x40); + pub const ADC6D0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADC5D: RegisterBits = RegisterBits::new(0x20); + pub const ADC5D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC4D: RegisterBits = RegisterBits::new(0x10); + pub const ADC4D0: RegisterBits = RegisterBits::new(1<<4); + + pub const ADC3D: RegisterBits = RegisterBits::new(0x8); + pub const ADC3D0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADC2D: RegisterBits = RegisterBits::new(0x4); + pub const ADC2D0: RegisterBits = RegisterBits::new(1<<2); + + pub const ADC1D: RegisterBits = RegisterBits::new(0x2); + pub const ADC1D0: RegisterBits = RegisterBits::new(1<<1); + + pub const ADC0D: RegisterBits = RegisterBits::new(0x1); + pub const ADC0D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for DIDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0xd as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSRB; + +impl ACSRB { + pub const HSEL: RegisterBits = RegisterBits::new(0x80); + pub const HSEL0: RegisterBits = RegisterBits::new(1<<7); + + pub const HLEV: RegisterBits = RegisterBits::new(0x40); + pub const HLEV0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACME: RegisterBits = RegisterBits::new(0x4); + pub const ACME0: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ACSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x13 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSRA; + +impl ACSRA { + pub const ACD: RegisterBits = RegisterBits::new(0x80); + pub const ACD0: RegisterBits = RegisterBits::new(1<<7); + + pub const ACBG: RegisterBits = RegisterBits::new(0x40); + pub const ACBG0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACO: RegisterBits = RegisterBits::new(0x20); + pub const ACO0: RegisterBits = RegisterBits::new(1<<5); + + pub const ACI: RegisterBits = RegisterBits::new(0x10); + pub const ACI0: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIE: RegisterBits = RegisterBits::new(0x8); + pub const ACIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ACIC: RegisterBits = RegisterBits::new(0x4); + pub const ACIC0: RegisterBits = RegisterBits::new(1<<2); + + pub const ACIS: RegisterBits = RegisterBits::new(0x3); + pub const ACIS0: RegisterBits = RegisterBits::new(1<<0); + pub const ACIS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for ACSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x14 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CCP; + +impl CCP { +} + +impl Register for CCP { + type T = u8; + const ADDRESS: *mut u8 = 0x3c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SP; + +impl SP { +} + +impl Register for SP { + type T = u16; + const ADDRESS: *mut u16 = 0x3d as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct SREG; + +impl SREG { + pub const I: RegisterBits = RegisterBits::new(0x80); + pub const I0: RegisterBits = RegisterBits::new(1<<7); + + pub const T: RegisterBits = RegisterBits::new(0x40); + pub const T0: RegisterBits = RegisterBits::new(1<<6); + + pub const H: RegisterBits = RegisterBits::new(0x20); + pub const H0: RegisterBits = RegisterBits::new(1<<5); + + pub const S: RegisterBits = RegisterBits::new(0x10); + pub const S0: RegisterBits = RegisterBits::new(1<<4); + + pub const V: RegisterBits = RegisterBits::new(0x8); + pub const V0: RegisterBits = RegisterBits::new(1<<3); + + pub const N: RegisterBits = RegisterBits::new(0x4); + pub const N0: RegisterBits = RegisterBits::new(1<<2); + + pub const Z: RegisterBits = RegisterBits::new(0x2); + pub const Z0: RegisterBits = RegisterBits::new(1<<1); + + pub const C: RegisterBits = RegisterBits::new(0x1); + pub const C0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SREG { + type T = u8; + const ADDRESS: *mut u8 = 0x3f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKMSR; + +impl CLKMSR { + pub const CLKMS: RegisterBits = RegisterBits::new(0x3); + pub const CLKMS0: RegisterBits = RegisterBits::new(1<<0); + pub const CLKMS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for CLKMSR { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKPSR; + +impl CLKPSR { + pub const CLKPS: RegisterBits = RegisterBits::new(0xf); + pub const CLKPS0: RegisterBits = RegisterBits::new(1<<0); + pub const CLKPS1: RegisterBits = RegisterBits::new(1<<1); + pub const CLKPS2: RegisterBits = RegisterBits::new(1<<2); + pub const CLKPS3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CLKPSR { + type T = u8; + const ADDRESS: *mut u8 = 0x36 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCCAL; + +impl OSCCAL { + pub const OSCCAL: RegisterBits = RegisterBits::new(0xff); + pub const OSCCAL0: RegisterBits = RegisterBits::new(1<<0); + pub const OSCCAL1: RegisterBits = RegisterBits::new(1<<1); + pub const OSCCAL2: RegisterBits = RegisterBits::new(1<<2); + pub const OSCCAL3: RegisterBits = RegisterBits::new(1<<3); + pub const OSCCAL4: RegisterBits = RegisterBits::new(1<<4); + pub const OSCCAL5: RegisterBits = RegisterBits::new(1<<5); + pub const OSCCAL6: RegisterBits = RegisterBits::new(1<<6); + pub const OSCCAL7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OSCCAL { + type T = u8; + const ADDRESS: *mut u8 = 0x39 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTWI: RegisterBits = RegisterBits::new(0x10); + pub const PRTWI0: RegisterBits = RegisterBits::new(1<<4); + + pub const PRSPI: RegisterBits = RegisterBits::new(0x8); + pub const PRSPI0: RegisterBits = RegisterBits::new(1<<3); + + pub const PRTIM1: RegisterBits = RegisterBits::new(0x4); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<2); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x2); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<1); + + pub const PRADC: RegisterBits = RegisterBits::new(0x1); + pub const PRADC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PRR { + type T = u8; + const ADDRESS: *mut u8 = 0x35 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct RSTFLR; + +impl RSTFLR { + pub const WDRF: RegisterBits = RegisterBits::new(0x8); + pub const WDRF0: RegisterBits = RegisterBits::new(1<<3); + + pub const EXTRF: RegisterBits = RegisterBits::new(0x2); + pub const EXTRF0: RegisterBits = RegisterBits::new(1<<1); + + pub const PORF: RegisterBits = RegisterBits::new(0x1); + pub const PORF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for RSTFLR { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct NVMCSR; + +impl NVMCSR { + pub const NVMBSY: RegisterBits = RegisterBits::new(0x80); + pub const NVMBSY0: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for NVMCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x32 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct NVMCMD; + +impl NVMCMD { +} + +impl Register for NVMCMD { + type T = u8; + const ADDRESS: *mut u8 = 0x33 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const BODS: RegisterBits = RegisterBits::new(0x10); + pub const BODS0: RegisterBits = RegisterBits::new(1<<4); + + pub const SM: RegisterBits = RegisterBits::new(0xe); + pub const SM0: RegisterBits = RegisterBits::new(1<<1); + pub const SM1: RegisterBits = RegisterBits::new(1<<2); + pub const SM2: RegisterBits = RegisterBits::new(1<<3); + + pub const SE: RegisterBits = RegisterBits::new(0x1); + pub const SE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x3a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const ISC01: RegisterBits = RegisterBits::new(0x80); + pub const ISC010: RegisterBits = RegisterBits::new(1<<7); + + pub const ISC00: RegisterBits = RegisterBits::new(0x40); + pub const ISC000: RegisterBits = RegisterBits::new(1<<6); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x3a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { + pub const PCINT: RegisterBits = RegisterBits::new(0xf); + pub const PCINT0: RegisterBits = RegisterBits::new(1<<0); + pub const PCINT1: RegisterBits = RegisterBits::new(1<<1); + pub const PCINT2: RegisterBits = RegisterBits::new(1<<2); + pub const PCINT3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0xa as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK0; + +impl PCMSK0 { + pub const PCINT: RegisterBits = RegisterBits::new(0xff); + pub const PCINT0: RegisterBits = RegisterBits::new(1<<0); + pub const PCINT1: RegisterBits = RegisterBits::new(1<<1); + pub const PCINT2: RegisterBits = RegisterBits::new(1<<2); + pub const PCINT3: RegisterBits = RegisterBits::new(1<<3); + pub const PCINT4: RegisterBits = RegisterBits::new(1<<4); + pub const PCINT5: RegisterBits = RegisterBits::new(1<<5); + pub const PCINT6: RegisterBits = RegisterBits::new(1<<6); + pub const PCINT7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for PCMSK0 { + type T = u8; + const ADDRESS: *mut u8 = 0x9 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIFR; + +impl GIFR { + pub const PCIF: RegisterBits = RegisterBits::new(0x30); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<4); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<5); + + pub const INTF0: RegisterBits = RegisterBits::new(0x1); + pub const INTF00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for GIFR { + type T = u8; + const ADDRESS: *mut u8 = 0xb as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIMSK; + +impl GIMSK { + pub const PCIE: RegisterBits = RegisterBits::new(0x30); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<4); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<5); + + pub const INT0: RegisterBits = RegisterBits::new(0x1); + pub const INT00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for GIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0xc as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0A; + +impl TCCR0A { + pub const COM0A: RegisterBits = RegisterBits::new(0xc0); + pub const COM0A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM0A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM0B: RegisterBits = RegisterBits::new(0x30); + pub const COM0B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM0B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM0: RegisterBits = RegisterBits::new(0x3); + pub const WGM00: RegisterBits = RegisterBits::new(1<<0); + pub const WGM01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x19 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0B; + +impl TCCR0B { + pub const FOC0A: RegisterBits = RegisterBits::new(0x80); + pub const FOC0A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC0B: RegisterBits = RegisterBits::new(0x40); + pub const FOC0B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM02: RegisterBits = RegisterBits::new(0x8); + pub const WGM020: RegisterBits = RegisterBits::new(1<<3); + + pub const CS0: RegisterBits = RegisterBits::new(0x7); + pub const CS00: RegisterBits = RegisterBits::new(1<<0); + pub const CS01: RegisterBits = RegisterBits::new(1<<1); + pub const CS02: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x18 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const ICIE1: RegisterBits = RegisterBits::new(0x80); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<7); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x20); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const OCIE1A: RegisterBits = RegisterBits::new(0x10); + pub const OCIE1A0: RegisterBits = RegisterBits::new(1<<4); + + pub const TOIE: RegisterBits = RegisterBits::new(0x9); + pub const TOIE0: RegisterBits = RegisterBits::new(1<<0); + pub const TOIE1: RegisterBits = RegisterBits::new(1<<3); + + pub const OCIE0B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE0B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCIE0A: RegisterBits = RegisterBits::new(0x2); + pub const OCIE0A0: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x26 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const ICF1: RegisterBits = RegisterBits::new(0x80); + pub const ICF10: RegisterBits = RegisterBits::new(1<<7); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x20); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const OCF1A: RegisterBits = RegisterBits::new(0x10); + pub const OCF1A0: RegisterBits = RegisterBits::new(1<<4); + + pub const TOV: RegisterBits = RegisterBits::new(0x9); + pub const TOV0: RegisterBits = RegisterBits::new(1<<0); + pub const TOV1: RegisterBits = RegisterBits::new(1<<3); + + pub const OCF0B: RegisterBits = RegisterBits::new(0x4); + pub const OCF0B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCF0A: RegisterBits = RegisterBits::new(0x2); + pub const OCF0A0: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x25 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0; + +impl TCNT0 { +} + +impl Register for TCNT0 { + type T = u8; + const ADDRESS: *mut u8 = 0x17 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x16 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0B; + +impl OCR0B { +} + +impl Register for OCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x15 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSCRA; + +impl TWSCRA { + pub const TWSHE: RegisterBits = RegisterBits::new(0x80); + pub const TWSHE0: RegisterBits = RegisterBits::new(1<<7); + + pub const TWDIE: RegisterBits = RegisterBits::new(0x20); + pub const TWDIE0: RegisterBits = RegisterBits::new(1<<5); + + pub const TWASIE: RegisterBits = RegisterBits::new(0x10); + pub const TWASIE0: RegisterBits = RegisterBits::new(1<<4); + + pub const TWEN: RegisterBits = RegisterBits::new(0x8); + pub const TWEN0: RegisterBits = RegisterBits::new(1<<3); + + pub const TWSIE: RegisterBits = RegisterBits::new(0x4); + pub const TWSIE0: RegisterBits = RegisterBits::new(1<<2); + + pub const TWPME: RegisterBits = RegisterBits::new(0x2); + pub const TWPME0: RegisterBits = RegisterBits::new(1<<1); + + pub const TWSME: RegisterBits = RegisterBits::new(0x1); + pub const TWSME0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TWSCRA { + type T = u8; + const ADDRESS: *mut u8 = 0x2d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSCRB; + +impl TWSCRB { + pub const TWAA: RegisterBits = RegisterBits::new(0x4); + pub const TWAA0: RegisterBits = RegisterBits::new(1<<2); + + pub const TWCMD: RegisterBits = RegisterBits::new(0x3); + pub const TWCMD0: RegisterBits = RegisterBits::new(1<<0); + pub const TWCMD1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TWSCRB { + type T = u8; + const ADDRESS: *mut u8 = 0x2c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSSRA; + +impl TWSSRA { +} + +impl Register for TWSSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x2b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSA; + +impl TWSA { + pub const TWSA: RegisterBits = RegisterBits::new(0xff); + pub const TWSA0: RegisterBits = RegisterBits::new(1<<0); + pub const TWSA1: RegisterBits = RegisterBits::new(1<<1); + pub const TWSA2: RegisterBits = RegisterBits::new(1<<2); + pub const TWSA3: RegisterBits = RegisterBits::new(1<<3); + pub const TWSA4: RegisterBits = RegisterBits::new(1<<4); + pub const TWSA5: RegisterBits = RegisterBits::new(1<<5); + pub const TWSA6: RegisterBits = RegisterBits::new(1<<6); + pub const TWSA7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for TWSA { + type T = u8; + const ADDRESS: *mut u8 = 0x2a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSD; + +impl TWSD { + pub const TWSD: RegisterBits = RegisterBits::new(0xff); + pub const TWSD0: RegisterBits = RegisterBits::new(1<<0); + pub const TWSD1: RegisterBits = RegisterBits::new(1<<1); + pub const TWSD2: RegisterBits = RegisterBits::new(1<<2); + pub const TWSD3: RegisterBits = RegisterBits::new(1<<3); + pub const TWSD4: RegisterBits = RegisterBits::new(1<<4); + pub const TWSD5: RegisterBits = RegisterBits::new(1<<5); + pub const TWSD6: RegisterBits = RegisterBits::new(1<<6); + pub const TWSD7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for TWSD { + type T = u8; + const ADDRESS: *mut u8 = 0x28 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSAM; + +impl TWSAM { +} + +impl Register for TWSAM { + type T = u8; + const ADDRESS: *mut u8 = 0x29 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1A; + +impl TCCR1A { + pub const COM1A: RegisterBits = RegisterBits::new(0xc0); + pub const COM1A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM1A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM1B: RegisterBits = RegisterBits::new(0x30); + pub const COM1B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM1B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM1: RegisterBits = RegisterBits::new(0x3); + pub const WGM10: RegisterBits = RegisterBits::new(1<<0); + pub const WGM11: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x24 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1B; + +impl TCCR1B { + pub const ICNC1: RegisterBits = RegisterBits::new(0x80); + pub const ICNC10: RegisterBits = RegisterBits::new(1<<7); + + pub const ICES1: RegisterBits = RegisterBits::new(0x40); + pub const ICES10: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM1: RegisterBits = RegisterBits::new(0x18); + pub const WGM10: RegisterBits = RegisterBits::new(1<<3); + pub const WGM11: RegisterBits = RegisterBits::new(1<<4); + + pub const CS1: RegisterBits = RegisterBits::new(0x7); + pub const CS10: RegisterBits = RegisterBits::new(1<<0); + pub const CS11: RegisterBits = RegisterBits::new(1<<1); + pub const CS12: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x23 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1C; + +impl TCCR1C { + pub const FOC1A: RegisterBits = RegisterBits::new(0x80); + pub const FOC1A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC1B: RegisterBits = RegisterBits::new(0x40); + pub const FOC1B0: RegisterBits = RegisterBits::new(1<<6); + +} + +impl Register for TCCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x22 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT1; + +impl TCNT1 { +} + +impl Register for TCNT1 { + type T = u16; + const ADDRESS: *mut u16 = 0x20 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x1e as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x1c as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x1a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const ICIE1: RegisterBits = RegisterBits::new(0x80); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<7); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x20); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const OCIE1A: RegisterBits = RegisterBits::new(0x10); + pub const OCIE1A0: RegisterBits = RegisterBits::new(1<<4); + + pub const TOIE: RegisterBits = RegisterBits::new(0x9); + pub const TOIE0: RegisterBits = RegisterBits::new(1<<0); + pub const TOIE1: RegisterBits = RegisterBits::new(1<<3); + + pub const OCIE0B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE0B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCIE0A: RegisterBits = RegisterBits::new(0x2); + pub const OCIE0A0: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x26 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const ICF1: RegisterBits = RegisterBits::new(0x80); + pub const ICF10: RegisterBits = RegisterBits::new(1<<7); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x20); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const OCF1A: RegisterBits = RegisterBits::new(0x10); + pub const OCF1A0: RegisterBits = RegisterBits::new(1<<4); + + pub const TOV: RegisterBits = RegisterBits::new(0x9); + pub const TOV0: RegisterBits = RegisterBits::new(1<<0); + pub const TOV1: RegisterBits = RegisterBits::new(1<<3); + + pub const OCF0B: RegisterBits = RegisterBits::new(0x4); + pub const OCF0B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCF0A: RegisterBits = RegisterBits::new(0x2); + pub const OCF0A0: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x25 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPCR; + +impl SPCR { + pub const SPIE: RegisterBits = RegisterBits::new(0x80); + pub const SPIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const SPE: RegisterBits = RegisterBits::new(0x40); + pub const SPE0: RegisterBits = RegisterBits::new(1<<6); + + pub const DORD: RegisterBits = RegisterBits::new(0x20); + pub const DORD0: RegisterBits = RegisterBits::new(1<<5); + + pub const MSTR: RegisterBits = RegisterBits::new(0x10); + pub const MSTR0: RegisterBits = RegisterBits::new(1<<4); + + pub const CPOL: RegisterBits = RegisterBits::new(0x8); + pub const CPOL0: RegisterBits = RegisterBits::new(1<<3); + + pub const CPHA: RegisterBits = RegisterBits::new(0x4); + pub const CPHA0: RegisterBits = RegisterBits::new(1<<2); + + pub const SPR: RegisterBits = RegisterBits::new(0x3); + pub const SPR0: RegisterBits = RegisterBits::new(1<<0); + pub const SPR1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for SPCR { + type T = u8; + const ADDRESS: *mut u8 = 0x30 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPSR; + +impl SPSR { + pub const SPIF: RegisterBits = RegisterBits::new(0x80); + pub const SPIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WCOL: RegisterBits = RegisterBits::new(0x40); + pub const WCOL0: RegisterBits = RegisterBits::new(1<<6); + + pub const SPI2X: RegisterBits = RegisterBits::new(0x1); + pub const SPI2X0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SPSR { + type T = u8; + const ADDRESS: *mut u8 = 0x2f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPDR; + +impl SPDR { +} + +impl Register for SPDR { + type T = u8; + const ADDRESS: *mut u8 = 0x2e as *mut u8; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + + pub struct B0; + + impl Pin for B0 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEB; + /// Data Direction Register, Port B. + type DDR = DDRB; + /// Port B Data register. + type PIN = PINB; + /// Input Pins, Port B. + type PORT = PORTB; + /// PB0 + const MASK: u8 = 1<<0; + } + + pub struct B1; + + impl Pin for B1 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEB; + /// Data Direction Register, Port B. + type DDR = DDRB; + /// Port B Data register. + type PIN = PINB; + /// Input Pins, Port B. + type PORT = PORTB; + /// PB1 + const MASK: u8 = 1<<1; + } + + pub struct B2; + + impl Pin for B2 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEB; + /// Data Direction Register, Port B. + type DDR = DDRB; + /// Port B Data register. + type PIN = PINB; + /// Input Pins, Port B. + type PORT = PORTB; + /// PB2 + const MASK: u8 = 1<<2; + } + + pub struct B3; + + impl Pin for B3 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEB; + /// Data Direction Register, Port B. + type DDR = DDRB; + /// Port B Data register. + type PIN = PINB; + /// Input Pins, Port B. + type PORT = PORTB; + /// PB3 + const MASK: u8 = 1<<3; + } + + pub struct A0; + + impl Pin for A0 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEA; + /// Port A Data Register. + type PORT = PORTA; + /// Data Direction Register, Port A. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA0 + const MASK: u8 = 1<<0; + } + + pub struct A1; + + impl Pin for A1 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEA; + /// Port A Data Register. + type PORT = PORTA; + /// Data Direction Register, Port A. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA1 + const MASK: u8 = 1<<1; + } + + pub struct A2; + + impl Pin for A2 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEA; + /// Port A Data Register. + type PORT = PORTA; + /// Data Direction Register, Port A. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA2 + const MASK: u8 = 1<<2; + } + + pub struct A3; + + impl Pin for A3 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEA; + /// Port A Data Register. + type PORT = PORTA; + /// Data Direction Register, Port A. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA3 + const MASK: u8 = 1<<3; + } + + pub struct A4; + + impl Pin for A4 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEA; + /// Port A Data Register. + type PORT = PORTA; + /// Data Direction Register, Port A. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA4 + const MASK: u8 = 1<<4; + } + + pub struct A5; + + impl Pin for A5 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEA; + /// Port A Data Register. + type PORT = PORTA; + /// Data Direction Register, Port A. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA5 + const MASK: u8 = 1<<5; + } + + pub struct A6; + + impl Pin for A6 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEA; + /// Port A Data Register. + type PORT = PORTA; + /// Data Direction Register, Port A. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA6 + const MASK: u8 = 1<<6; + } + + pub struct A7; + + impl Pin for A7 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEA; + /// Port A Data Register. + type PORT = PORTA; + /// Data Direction Register, Port A. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA7 + const MASK: u8 = 1<<7; + } + +} + +pub struct Spi; + +impl modules::HardwareSpi for Spi { + type SerialDataOut = port::B1; + type ChipSelect = port::A6; + type Clock = port::A7; + type SerialDataIn = port::B2; + type ControlRegister = SPCR; + type StatusRegister = SPSR; + type DataRegister = SPDR; +} + +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR0A; + type CompareB = OCR0B; + type Counter = TCNT0; + type ControlA = TCCR0A; + type ControlB = TCCR0B; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE0A; +} +/// 16-bit timer. +pub struct Timer16; + +impl modules::Timer16 for Timer16 { + type CompareA = OCR1A; + type CompareB = OCR1B; + type Counter = TCNT1; + type ControlA = TCCR1A; + type ControlB = TCCR1B; + type ControlC = TCCR1C; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS10; + const CS1: RegisterBits = Self::ControlB::CS11; + const CS2: RegisterBits = Self::ControlB::CS12; + const WGM0: RegisterBits = Self::ControlA::WGM10; + const WGM1: RegisterBits = Self::ControlA::WGM11; + const WGM2: RegisterBits = Self::ControlB::WGM10; + const WGM3: RegisterBits = Self::ControlB::WGM11; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE1A; +} + diff --git a/src/cores/attiny2313.rs b/src/cores/attiny2313.rs new file mode 100644 index 0000000..8a3dac0 --- /dev/null +++ b/src/cores/attiny2313.rs @@ -0,0 +1,1038 @@ +//! Core for ATtiny2313. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + pub const SELFPRGEN: RegisterBits = RegisterBits::new(0x1); + pub const SELFPRGEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EXTENDED { + type T = u8; + const ADDRESS: *mut u8 = 0x2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct HIGH; + +impl HIGH { + pub const DWEN: RegisterBits = RegisterBits::new(0x80); + pub const DWEN0: RegisterBits = RegisterBits::new(1<<7); + + pub const EESAVE: RegisterBits = RegisterBits::new(0x40); + pub const EESAVE0: RegisterBits = RegisterBits::new(1<<6); + + pub const SPIEN: RegisterBits = RegisterBits::new(0x20); + pub const SPIEN0: RegisterBits = RegisterBits::new(1<<5); + + pub const WDTON: RegisterBits = RegisterBits::new(0x10); + pub const WDTON0: RegisterBits = RegisterBits::new(1<<4); + + pub const BODLEVEL: RegisterBits = RegisterBits::new(0xe); + pub const BODLEVEL0: RegisterBits = RegisterBits::new(1<<1); + pub const BODLEVEL1: RegisterBits = RegisterBits::new(1<<2); + pub const BODLEVEL2: RegisterBits = RegisterBits::new(1<<3); + + pub const RSTDISBL: RegisterBits = RegisterBits::new(0x1); + pub const RSTDISBL0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for HIGH { + type T = u8; + const ADDRESS: *mut u8 = 0x1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOW; + +impl LOW { + pub const CKDIV8: RegisterBits = RegisterBits::new(0x80); + pub const CKDIV80: RegisterBits = RegisterBits::new(1<<7); + + pub const CKOUT: RegisterBits = RegisterBits::new(0x40); + pub const CKOUT0: RegisterBits = RegisterBits::new(1<<6); + + pub const SUT_CKSEL: RegisterBits = RegisterBits::new(0x3f); + pub const SUT_CKSEL0: RegisterBits = RegisterBits::new(1<<0); + pub const SUT_CKSEL1: RegisterBits = RegisterBits::new(1<<1); + pub const SUT_CKSEL2: RegisterBits = RegisterBits::new(1<<2); + pub const SUT_CKSEL3: RegisterBits = RegisterBits::new(1<<3); + pub const SUT_CKSEL4: RegisterBits = RegisterBits::new(1<<4); + pub const SUT_CKSEL5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for LOW { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOCKBIT; + +impl LOCKBIT { + pub const LB: RegisterBits = RegisterBits::new(0x3); + pub const LB0: RegisterBits = RegisterBits::new(1<<0); + pub const LB1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for LOCKBIT { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x38 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x36 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTD; + +impl PORTD { +} + +impl Register for PORTD { + type T = u8; + const ADDRESS: *mut u8 = 0x32 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRD; + +impl DDRD { +} + +impl Register for DDRD { + type T = u8; + const ADDRESS: *mut u8 = 0x31 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PIND; + +impl PIND { +} + +impl Register for PIND { + type T = u8; + const ADDRESS: *mut u8 = 0x30 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTA; + +impl PORTA { +} + +impl Register for PORTA { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRA; + +impl DDRA { +} + +impl Register for DDRA { + type T = u8; + const ADDRESS: *mut u8 = 0x3a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINA; + +impl PINA { +} + +impl Register for PINA { + type T = u8; + const ADDRESS: *mut u8 = 0x39 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE0B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE0B0: RegisterBits = RegisterBits::new(1<<2); + + pub const TOIE0: RegisterBits = RegisterBits::new(0x2); + pub const TOIE00: RegisterBits = RegisterBits::new(1<<1); + + pub const OCIE0A: RegisterBits = RegisterBits::new(0x1); + pub const OCIE0A0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF0B: RegisterBits = RegisterBits::new(0x4); + pub const OCF0B0: RegisterBits = RegisterBits::new(1<<2); + + pub const TOV0: RegisterBits = RegisterBits::new(0x2); + pub const TOV00: RegisterBits = RegisterBits::new(1<<1); + + pub const OCF0A: RegisterBits = RegisterBits::new(0x1); + pub const OCF0A0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0B; + +impl OCR0B { +} + +impl Register for OCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x5c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x56 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0A; + +impl TCCR0A { + pub const COM0A: RegisterBits = RegisterBits::new(0xc0); + pub const COM0A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM0A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM0B: RegisterBits = RegisterBits::new(0x30); + pub const COM0B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM0B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM0: RegisterBits = RegisterBits::new(0x3); + pub const WGM00: RegisterBits = RegisterBits::new(1<<0); + pub const WGM01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0; + +impl TCNT0 { +} + +impl Register for TCNT0 { + type T = u8; + const ADDRESS: *mut u8 = 0x52 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0B; + +impl TCCR0B { + pub const FOC0A: RegisterBits = RegisterBits::new(0x80); + pub const FOC0A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC0B: RegisterBits = RegisterBits::new(0x40); + pub const FOC0B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM02: RegisterBits = RegisterBits::new(0x8); + pub const WGM020: RegisterBits = RegisterBits::new(1<<3); + + pub const CS0: RegisterBits = RegisterBits::new(0x7); + pub const CS00: RegisterBits = RegisterBits::new(1<<0); + pub const CS01: RegisterBits = RegisterBits::new(1<<1); + pub const CS02: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x53 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const TOIE1: RegisterBits = RegisterBits::new(0x80); + pub const TOIE10: RegisterBits = RegisterBits::new(1<<7); + + pub const OCIE1A: RegisterBits = RegisterBits::new(0x40); + pub const OCIE1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x20); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const ICIE1: RegisterBits = RegisterBits::new(0x8); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const TOV1: RegisterBits = RegisterBits::new(0x80); + pub const TOV10: RegisterBits = RegisterBits::new(1<<7); + + pub const OCF1A: RegisterBits = RegisterBits::new(0x40); + pub const OCF1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x20); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const ICF1: RegisterBits = RegisterBits::new(0x8); + pub const ICF10: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1A; + +impl TCCR1A { + pub const COM1A: RegisterBits = RegisterBits::new(0xc0); + pub const COM1A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM1A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM1B: RegisterBits = RegisterBits::new(0x30); + pub const COM1B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM1B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM1: RegisterBits = RegisterBits::new(0x3); + pub const WGM10: RegisterBits = RegisterBits::new(1<<0); + pub const WGM11: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x4f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1B; + +impl TCCR1B { + pub const ICNC1: RegisterBits = RegisterBits::new(0x80); + pub const ICNC10: RegisterBits = RegisterBits::new(1<<7); + + pub const ICES1: RegisterBits = RegisterBits::new(0x40); + pub const ICES10: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM1: RegisterBits = RegisterBits::new(0x18); + pub const WGM10: RegisterBits = RegisterBits::new(1<<3); + pub const WGM11: RegisterBits = RegisterBits::new(1<<4); + + pub const CS1: RegisterBits = RegisterBits::new(0x7); + pub const CS10: RegisterBits = RegisterBits::new(1<<0); + pub const CS11: RegisterBits = RegisterBits::new(1<<1); + pub const CS12: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x4e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1C; + +impl TCCR1C { + pub const FOC1A: RegisterBits = RegisterBits::new(0x80); + pub const FOC1A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC1B: RegisterBits = RegisterBits::new(0x40); + pub const FOC1B0: RegisterBits = RegisterBits::new(1<<6); + +} + +impl Register for TCCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x42 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT1; + +impl TCNT1 { +} + +impl Register for TCNT1 { + type T = u16; + const ADDRESS: *mut u16 = 0x4c as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x4a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x48 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x44 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct WDTCR; + +impl WDTCR { + pub const WDIF: RegisterBits = RegisterBits::new(0x80); + pub const WDIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WDIE: RegisterBits = RegisterBits::new(0x40); + pub const WDIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const WDP: RegisterBits = RegisterBits::new(0x27); + pub const WDP0: RegisterBits = RegisterBits::new(1<<0); + pub const WDP1: RegisterBits = RegisterBits::new(1<<1); + pub const WDP2: RegisterBits = RegisterBits::new(1<<2); + pub const WDP3: RegisterBits = RegisterBits::new(1<<5); + + pub const WDCE: RegisterBits = RegisterBits::new(0x10); + pub const WDCE0: RegisterBits = RegisterBits::new(1<<4); + + pub const WDE: RegisterBits = RegisterBits::new(0x8); + pub const WDE0: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for WDTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x41 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIMSK; + +impl GIMSK { + pub const INT: RegisterBits = RegisterBits::new(0xc0); + pub const INT0: RegisterBits = RegisterBits::new(1<<6); + pub const INT1: RegisterBits = RegisterBits::new(1<<7); + + pub const PCIE: RegisterBits = RegisterBits::new(0x20); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x5b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EIFR; + +impl EIFR { + pub const INTF: RegisterBits = RegisterBits::new(0xc0); + pub const INTF0: RegisterBits = RegisterBits::new(1<<6); + pub const INTF1: RegisterBits = RegisterBits::new(1<<7); + + pub const PCIF: RegisterBits = RegisterBits::new(0x20); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for EIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x5a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UDR; + +impl UDR { +} + +impl Register for UDR { + type T = u8; + const ADDRESS: *mut u8 = 0x2c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UCSRA; + +impl UCSRA { + pub const RXC: RegisterBits = RegisterBits::new(0x80); + pub const RXC0: RegisterBits = RegisterBits::new(1<<7); + + pub const TXC: RegisterBits = RegisterBits::new(0x40); + pub const TXC0: RegisterBits = RegisterBits::new(1<<6); + + pub const UDRE: RegisterBits = RegisterBits::new(0x20); + pub const UDRE0: RegisterBits = RegisterBits::new(1<<5); + + pub const FE: RegisterBits = RegisterBits::new(0x10); + pub const FE0: RegisterBits = RegisterBits::new(1<<4); + + pub const DOR: RegisterBits = RegisterBits::new(0x8); + pub const DOR0: RegisterBits = RegisterBits::new(1<<3); + + pub const UPE: RegisterBits = RegisterBits::new(0x4); + pub const UPE0: RegisterBits = RegisterBits::new(1<<2); + + pub const U2X: RegisterBits = RegisterBits::new(0x2); + pub const U2X0: RegisterBits = RegisterBits::new(1<<1); + + pub const MPCM: RegisterBits = RegisterBits::new(0x1); + pub const MPCM0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for UCSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x2b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UCSRB; + +impl UCSRB { + pub const RXCIE: RegisterBits = RegisterBits::new(0x80); + pub const RXCIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const TXCIE: RegisterBits = RegisterBits::new(0x40); + pub const TXCIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const UDRIE: RegisterBits = RegisterBits::new(0x20); + pub const UDRIE0: RegisterBits = RegisterBits::new(1<<5); + + pub const RXEN: RegisterBits = RegisterBits::new(0x10); + pub const RXEN0: RegisterBits = RegisterBits::new(1<<4); + + pub const TXEN: RegisterBits = RegisterBits::new(0x8); + pub const TXEN0: RegisterBits = RegisterBits::new(1<<3); + + pub const UCSZ2: RegisterBits = RegisterBits::new(0x4); + pub const UCSZ20: RegisterBits = RegisterBits::new(1<<2); + + pub const RXB8: RegisterBits = RegisterBits::new(0x2); + pub const RXB80: RegisterBits = RegisterBits::new(1<<1); + + pub const TXB8: RegisterBits = RegisterBits::new(0x1); + pub const TXB80: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for UCSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x2a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UCSRC; + +impl UCSRC { + pub const UMSEL: RegisterBits = RegisterBits::new(0x40); + pub const UMSEL0: RegisterBits = RegisterBits::new(1<<6); + + pub const UPM: RegisterBits = RegisterBits::new(0x30); + pub const UPM0: RegisterBits = RegisterBits::new(1<<4); + pub const UPM1: RegisterBits = RegisterBits::new(1<<5); + + pub const USBS: RegisterBits = RegisterBits::new(0x8); + pub const USBS0: RegisterBits = RegisterBits::new(1<<3); + + pub const UCSZ: RegisterBits = RegisterBits::new(0x6); + pub const UCSZ0: RegisterBits = RegisterBits::new(1<<1); + pub const UCSZ1: RegisterBits = RegisterBits::new(1<<2); + + pub const UCPOL: RegisterBits = RegisterBits::new(0x1); + pub const UCPOL0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for UCSRC { + type T = u8; + const ADDRESS: *mut u8 = 0x23 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRRH; + +impl UBRRH { +} + +impl Register for UBRRH { + type T = u8; + const ADDRESS: *mut u8 = 0x22 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRRL; + +impl UBRRL { +} + +impl Register for UBRRL { + type T = u8; + const ADDRESS: *mut u8 = 0x29 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSR; + +impl ACSR { + pub const ACD: RegisterBits = RegisterBits::new(0x80); + pub const ACD0: RegisterBits = RegisterBits::new(1<<7); + + pub const ACBG: RegisterBits = RegisterBits::new(0x40); + pub const ACBG0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACO: RegisterBits = RegisterBits::new(0x20); + pub const ACO0: RegisterBits = RegisterBits::new(1<<5); + + pub const ACI: RegisterBits = RegisterBits::new(0x10); + pub const ACI0: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIE: RegisterBits = RegisterBits::new(0x8); + pub const ACIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ACIC: RegisterBits = RegisterBits::new(0x4); + pub const ACIC0: RegisterBits = RegisterBits::new(1<<2); + + pub const ACIS: RegisterBits = RegisterBits::new(0x3); + pub const ACIS0: RegisterBits = RegisterBits::new(1<<0); + pub const ACIS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for ACSR { + type T = u8; + const ADDRESS: *mut u8 = 0x28 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR; + +impl DIDR { +} + +impl Register for DIDR { + type T = u8; + const ADDRESS: *mut u8 = 0x21 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEAR; + +impl EEAR { +} + +impl Register for EEAR { + type T = u8; + const ADDRESS: *mut u8 = 0x3e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEDR; + +impl EEDR { +} + +impl Register for EEDR { + type T = u8; + const ADDRESS: *mut u8 = 0x3d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EECR; + +impl EECR { + pub const EEPM: RegisterBits = RegisterBits::new(0x30); + pub const EEPM0: RegisterBits = RegisterBits::new(1<<4); + pub const EEPM1: RegisterBits = RegisterBits::new(1<<5); + + pub const EERIE: RegisterBits = RegisterBits::new(0x8); + pub const EERIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const EEMPE: RegisterBits = RegisterBits::new(0x4); + pub const EEMPE0: RegisterBits = RegisterBits::new(1<<2); + + pub const EEPE: RegisterBits = RegisterBits::new(0x2); + pub const EEPE0: RegisterBits = RegisterBits::new(1<<1); + + pub const EERE: RegisterBits = RegisterBits::new(0x1); + pub const EERE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EECR { + type T = u8; + const ADDRESS: *mut u8 = 0x3c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SREG; + +impl SREG { + pub const I: RegisterBits = RegisterBits::new(0x80); + pub const I0: RegisterBits = RegisterBits::new(1<<7); + + pub const T: RegisterBits = RegisterBits::new(0x40); + pub const T0: RegisterBits = RegisterBits::new(1<<6); + + pub const H: RegisterBits = RegisterBits::new(0x20); + pub const H0: RegisterBits = RegisterBits::new(1<<5); + + pub const S: RegisterBits = RegisterBits::new(0x10); + pub const S0: RegisterBits = RegisterBits::new(1<<4); + + pub const V: RegisterBits = RegisterBits::new(0x8); + pub const V0: RegisterBits = RegisterBits::new(1<<3); + + pub const N: RegisterBits = RegisterBits::new(0x4); + pub const N0: RegisterBits = RegisterBits::new(1<<2); + + pub const Z: RegisterBits = RegisterBits::new(0x2); + pub const Z0: RegisterBits = RegisterBits::new(1<<1); + + pub const C: RegisterBits = RegisterBits::new(0x1); + pub const C0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SREG { + type T = u8; + const ADDRESS: *mut u8 = 0x5f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPL; + +impl SPL { +} + +impl Register for SPL { + type T = u8; + const ADDRESS: *mut u8 = 0x5d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPMCSR; + +impl SPMCSR { + pub const CTPB: RegisterBits = RegisterBits::new(0x10); + pub const CTPB0: RegisterBits = RegisterBits::new(1<<4); + + pub const RFLB: RegisterBits = RegisterBits::new(0x8); + pub const RFLB0: RegisterBits = RegisterBits::new(1<<3); + + pub const PGWRT: RegisterBits = RegisterBits::new(0x4); + pub const PGWRT0: RegisterBits = RegisterBits::new(1<<2); + + pub const PGERS: RegisterBits = RegisterBits::new(0x2); + pub const PGERS0: RegisterBits = RegisterBits::new(1<<1); + + pub const SPMEN: RegisterBits = RegisterBits::new(0x1); + pub const SPMEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SPMCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x57 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const PUD: RegisterBits = RegisterBits::new(0x80); + pub const PUD0: RegisterBits = RegisterBits::new(1<<7); + + pub const SM: RegisterBits = RegisterBits::new(0x50); + pub const SM0: RegisterBits = RegisterBits::new(1<<4); + pub const SM1: RegisterBits = RegisterBits::new(1<<6); + + pub const SE: RegisterBits = RegisterBits::new(0x20); + pub const SE0: RegisterBits = RegisterBits::new(1<<5); + + pub const ISC1: RegisterBits = RegisterBits::new(0xc); + pub const ISC10: RegisterBits = RegisterBits::new(1<<2); + pub const ISC11: RegisterBits = RegisterBits::new(1<<3); + + pub const ISC0: RegisterBits = RegisterBits::new(0x3); + pub const ISC00: RegisterBits = RegisterBits::new(1<<0); + pub const ISC01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUSR; + +impl MCUSR { + pub const WDRF: RegisterBits = RegisterBits::new(0x8); + pub const WDRF0: RegisterBits = RegisterBits::new(1<<3); + + pub const BORF: RegisterBits = RegisterBits::new(0x4); + pub const BORF0: RegisterBits = RegisterBits::new(1<<2); + + pub const EXTRF: RegisterBits = RegisterBits::new(0x2); + pub const EXTRF0: RegisterBits = RegisterBits::new(1<<1); + + pub const PORF: RegisterBits = RegisterBits::new(0x1); + pub const PORF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUSR { + type T = u8; + const ADDRESS: *mut u8 = 0x54 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCCAL; + +impl OSCCAL { + pub const OSCCAL: RegisterBits = RegisterBits::new(0xff); + pub const OSCCAL0: RegisterBits = RegisterBits::new(1<<0); + pub const OSCCAL1: RegisterBits = RegisterBits::new(1<<1); + pub const OSCCAL2: RegisterBits = RegisterBits::new(1<<2); + pub const OSCCAL3: RegisterBits = RegisterBits::new(1<<3); + pub const OSCCAL4: RegisterBits = RegisterBits::new(1<<4); + pub const OSCCAL5: RegisterBits = RegisterBits::new(1<<5); + pub const OSCCAL6: RegisterBits = RegisterBits::new(1<<6); + pub const OSCCAL7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OSCCAL { + type T = u8; + const ADDRESS: *mut u8 = 0x51 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKPR; + +impl CLKPR { + pub const CLKPCE: RegisterBits = RegisterBits::new(0x80); + pub const CLKPCE0: RegisterBits = RegisterBits::new(1<<7); + + pub const CLKPS: RegisterBits = RegisterBits::new(0xf); + pub const CLKPS0: RegisterBits = RegisterBits::new(1<<0); + pub const CLKPS1: RegisterBits = RegisterBits::new(1<<1); + pub const CLKPS2: RegisterBits = RegisterBits::new(1<<2); + pub const CLKPS3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CLKPR { + type T = u8; + const ADDRESS: *mut u8 = 0x46 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK; + +impl PCMSK { +} + +impl Register for PCMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x40 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR2; + +impl GPIOR2 { +} + +impl Register for GPIOR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x35 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR1; + +impl GPIOR1 { +} + +impl Register for GPIOR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x34 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR0; + +impl GPIOR0 { +} + +impl Register for GPIOR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x33 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIDR; + +impl USIDR { +} + +impl Register for USIDR { + type T = u8; + const ADDRESS: *mut u8 = 0x2f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USISR; + +impl USISR { + pub const USISIF: RegisterBits = RegisterBits::new(0x80); + pub const USISIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIF: RegisterBits = RegisterBits::new(0x40); + pub const USIOIF0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIPF: RegisterBits = RegisterBits::new(0x20); + pub const USIPF0: RegisterBits = RegisterBits::new(1<<5); + + pub const USIDC: RegisterBits = RegisterBits::new(0x10); + pub const USIDC0: RegisterBits = RegisterBits::new(1<<4); + + pub const USICNT: RegisterBits = RegisterBits::new(0xf); + pub const USICNT0: RegisterBits = RegisterBits::new(1<<0); + pub const USICNT1: RegisterBits = RegisterBits::new(1<<1); + pub const USICNT2: RegisterBits = RegisterBits::new(1<<2); + pub const USICNT3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for USISR { + type T = u8; + const ADDRESS: *mut u8 = 0x2e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USICR; + +impl USICR { + pub const USISIE: RegisterBits = RegisterBits::new(0x80); + pub const USISIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIE: RegisterBits = RegisterBits::new(0x40); + pub const USIOIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIWM: RegisterBits = RegisterBits::new(0x30); + pub const USIWM0: RegisterBits = RegisterBits::new(1<<4); + pub const USIWM1: RegisterBits = RegisterBits::new(1<<5); + + pub const USICS: RegisterBits = RegisterBits::new(0xc); + pub const USICS0: RegisterBits = RegisterBits::new(1<<2); + pub const USICS1: RegisterBits = RegisterBits::new(1<<3); + + pub const USICLK: RegisterBits = RegisterBits::new(0x2); + pub const USICLK0: RegisterBits = RegisterBits::new(1<<1); + + pub const USITC: RegisterBits = RegisterBits::new(0x1); + pub const USITC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for USICR { + type T = u8; + const ADDRESS: *mut u8 = 0x2d as *mut u8; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + +} + +/// The USART module. +pub struct USART; + +impl modules::HardwareUsart for USART { + type DataRegister = UDR; + type ControlRegisterA = UCSRA; + type ControlRegisterB = UCSRB; + type ControlRegisterC = UCSRC; + type BaudRateRegister = UBRRH; + type BaudRateRegister = UBRRL; +} + +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR0A; + type CompareB = OCR0B; + type Counter = TCNT0; + type ControlA = TCCR0A; + type ControlB = TCCR0B; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE0A; +} +/// 16-bit timer. +pub struct Timer16; + +impl modules::Timer16 for Timer16 { + type CompareA = OCR1A; + type CompareB = OCR1B; + type Counter = TCNT1; + type ControlA = TCCR1A; + type ControlB = TCCR1B; + type ControlC = TCCR1C; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS10; + const CS1: RegisterBits = Self::ControlB::CS11; + const CS2: RegisterBits = Self::ControlB::CS12; + const WGM0: RegisterBits = Self::ControlA::WGM10; + const WGM1: RegisterBits = Self::ControlA::WGM11; + const WGM2: RegisterBits = Self::ControlB::WGM10; + const WGM3: RegisterBits = Self::ControlB::WGM11; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE1A; +} + diff --git a/src/cores/attiny2313a.rs b/src/cores/attiny2313a.rs new file mode 100644 index 0000000..c4b52f6 --- /dev/null +++ b/src/cores/attiny2313a.rs @@ -0,0 +1,1111 @@ +//! Core for ATtiny2313A. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + pub const SELFPRGEN: RegisterBits = RegisterBits::new(0x1); + pub const SELFPRGEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EXTENDED { + type T = u8; + const ADDRESS: *mut u8 = 0x2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct HIGH; + +impl HIGH { + pub const DWEN: RegisterBits = RegisterBits::new(0x80); + pub const DWEN0: RegisterBits = RegisterBits::new(1<<7); + + pub const EESAVE: RegisterBits = RegisterBits::new(0x40); + pub const EESAVE0: RegisterBits = RegisterBits::new(1<<6); + + pub const SPIEN: RegisterBits = RegisterBits::new(0x20); + pub const SPIEN0: RegisterBits = RegisterBits::new(1<<5); + + pub const WDTON: RegisterBits = RegisterBits::new(0x10); + pub const WDTON0: RegisterBits = RegisterBits::new(1<<4); + + pub const BODLEVEL: RegisterBits = RegisterBits::new(0xe); + pub const BODLEVEL0: RegisterBits = RegisterBits::new(1<<1); + pub const BODLEVEL1: RegisterBits = RegisterBits::new(1<<2); + pub const BODLEVEL2: RegisterBits = RegisterBits::new(1<<3); + + pub const RSTDISBL: RegisterBits = RegisterBits::new(0x1); + pub const RSTDISBL0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for HIGH { + type T = u8; + const ADDRESS: *mut u8 = 0x1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOW; + +impl LOW { + pub const CKDIV8: RegisterBits = RegisterBits::new(0x80); + pub const CKDIV80: RegisterBits = RegisterBits::new(1<<7); + + pub const CKOUT: RegisterBits = RegisterBits::new(0x40); + pub const CKOUT0: RegisterBits = RegisterBits::new(1<<6); + + pub const SUT_CKSEL: RegisterBits = RegisterBits::new(0x3f); + pub const SUT_CKSEL0: RegisterBits = RegisterBits::new(1<<0); + pub const SUT_CKSEL1: RegisterBits = RegisterBits::new(1<<1); + pub const SUT_CKSEL2: RegisterBits = RegisterBits::new(1<<2); + pub const SUT_CKSEL3: RegisterBits = RegisterBits::new(1<<3); + pub const SUT_CKSEL4: RegisterBits = RegisterBits::new(1<<4); + pub const SUT_CKSEL5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for LOW { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOCKBIT; + +impl LOCKBIT { + pub const LB: RegisterBits = RegisterBits::new(0x3); + pub const LB0: RegisterBits = RegisterBits::new(1<<0); + pub const LB1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for LOCKBIT { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x38 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x36 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTD; + +impl PORTD { +} + +impl Register for PORTD { + type T = u8; + const ADDRESS: *mut u8 = 0x32 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRD; + +impl DDRD { +} + +impl Register for DDRD { + type T = u8; + const ADDRESS: *mut u8 = 0x31 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PIND; + +impl PIND { +} + +impl Register for PIND { + type T = u8; + const ADDRESS: *mut u8 = 0x30 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTA; + +impl PORTA { +} + +impl Register for PORTA { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRA; + +impl DDRA { +} + +impl Register for DDRA { + type T = u8; + const ADDRESS: *mut u8 = 0x3a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINA; + +impl PINA { +} + +impl Register for PINA { + type T = u8; + const ADDRESS: *mut u8 = 0x39 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE0B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE0B0: RegisterBits = RegisterBits::new(1<<2); + + pub const TOIE0: RegisterBits = RegisterBits::new(0x2); + pub const TOIE00: RegisterBits = RegisterBits::new(1<<1); + + pub const OCIE0A: RegisterBits = RegisterBits::new(0x1); + pub const OCIE0A0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF0B: RegisterBits = RegisterBits::new(0x4); + pub const OCF0B0: RegisterBits = RegisterBits::new(1<<2); + + pub const TOV0: RegisterBits = RegisterBits::new(0x2); + pub const TOV00: RegisterBits = RegisterBits::new(1<<1); + + pub const OCF0A: RegisterBits = RegisterBits::new(0x1); + pub const OCF0A0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0B; + +impl OCR0B { +} + +impl Register for OCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x5c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x56 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0A; + +impl TCCR0A { + pub const COM0A: RegisterBits = RegisterBits::new(0xc0); + pub const COM0A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM0A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM0B: RegisterBits = RegisterBits::new(0x30); + pub const COM0B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM0B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM0: RegisterBits = RegisterBits::new(0x3); + pub const WGM00: RegisterBits = RegisterBits::new(1<<0); + pub const WGM01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0; + +impl TCNT0 { +} + +impl Register for TCNT0 { + type T = u8; + const ADDRESS: *mut u8 = 0x52 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0B; + +impl TCCR0B { + pub const FOC0A: RegisterBits = RegisterBits::new(0x80); + pub const FOC0A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC0B: RegisterBits = RegisterBits::new(0x40); + pub const FOC0B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM02: RegisterBits = RegisterBits::new(0x8); + pub const WGM020: RegisterBits = RegisterBits::new(1<<3); + + pub const CS0: RegisterBits = RegisterBits::new(0x7); + pub const CS00: RegisterBits = RegisterBits::new(1<<0); + pub const CS01: RegisterBits = RegisterBits::new(1<<1); + pub const CS02: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x53 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const TOIE1: RegisterBits = RegisterBits::new(0x80); + pub const TOIE10: RegisterBits = RegisterBits::new(1<<7); + + pub const OCIE1A: RegisterBits = RegisterBits::new(0x40); + pub const OCIE1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x20); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const ICIE1: RegisterBits = RegisterBits::new(0x8); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const TOV1: RegisterBits = RegisterBits::new(0x80); + pub const TOV10: RegisterBits = RegisterBits::new(1<<7); + + pub const OCF1A: RegisterBits = RegisterBits::new(0x40); + pub const OCF1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x20); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const ICF1: RegisterBits = RegisterBits::new(0x8); + pub const ICF10: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1A; + +impl TCCR1A { + pub const COM1A: RegisterBits = RegisterBits::new(0xc0); + pub const COM1A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM1A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM1B: RegisterBits = RegisterBits::new(0x30); + pub const COM1B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM1B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM1: RegisterBits = RegisterBits::new(0x3); + pub const WGM10: RegisterBits = RegisterBits::new(1<<0); + pub const WGM11: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x4f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1B; + +impl TCCR1B { + pub const ICNC1: RegisterBits = RegisterBits::new(0x80); + pub const ICNC10: RegisterBits = RegisterBits::new(1<<7); + + pub const ICES1: RegisterBits = RegisterBits::new(0x40); + pub const ICES10: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM1: RegisterBits = RegisterBits::new(0x18); + pub const WGM10: RegisterBits = RegisterBits::new(1<<3); + pub const WGM11: RegisterBits = RegisterBits::new(1<<4); + + pub const CS1: RegisterBits = RegisterBits::new(0x7); + pub const CS10: RegisterBits = RegisterBits::new(1<<0); + pub const CS11: RegisterBits = RegisterBits::new(1<<1); + pub const CS12: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x4e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1C; + +impl TCCR1C { + pub const FOC1A: RegisterBits = RegisterBits::new(0x80); + pub const FOC1A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC1B: RegisterBits = RegisterBits::new(0x40); + pub const FOC1B0: RegisterBits = RegisterBits::new(1<<6); + +} + +impl Register for TCCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x42 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT1; + +impl TCNT1 { +} + +impl Register for TCNT1 { + type T = u16; + const ADDRESS: *mut u16 = 0x4c as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x4a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x48 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x44 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct WDTCR; + +impl WDTCR { + pub const WDIF: RegisterBits = RegisterBits::new(0x80); + pub const WDIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WDIE: RegisterBits = RegisterBits::new(0x40); + pub const WDIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const WDP: RegisterBits = RegisterBits::new(0x27); + pub const WDP0: RegisterBits = RegisterBits::new(1<<0); + pub const WDP1: RegisterBits = RegisterBits::new(1<<1); + pub const WDP2: RegisterBits = RegisterBits::new(1<<2); + pub const WDP3: RegisterBits = RegisterBits::new(1<<5); + + pub const WDCE: RegisterBits = RegisterBits::new(0x10); + pub const WDCE0: RegisterBits = RegisterBits::new(1<<4); + + pub const WDE: RegisterBits = RegisterBits::new(0x8); + pub const WDE0: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for WDTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x41 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UDR; + +impl UDR { +} + +impl Register for UDR { + type T = u8; + const ADDRESS: *mut u8 = 0x2c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UCSRA; + +impl UCSRA { + pub const RXC: RegisterBits = RegisterBits::new(0x80); + pub const RXC0: RegisterBits = RegisterBits::new(1<<7); + + pub const TXC: RegisterBits = RegisterBits::new(0x40); + pub const TXC0: RegisterBits = RegisterBits::new(1<<6); + + pub const UDRE: RegisterBits = RegisterBits::new(0x20); + pub const UDRE0: RegisterBits = RegisterBits::new(1<<5); + + pub const FE: RegisterBits = RegisterBits::new(0x10); + pub const FE0: RegisterBits = RegisterBits::new(1<<4); + + pub const DOR: RegisterBits = RegisterBits::new(0x8); + pub const DOR0: RegisterBits = RegisterBits::new(1<<3); + + pub const UPE: RegisterBits = RegisterBits::new(0x4); + pub const UPE0: RegisterBits = RegisterBits::new(1<<2); + + pub const U2X: RegisterBits = RegisterBits::new(0x2); + pub const U2X0: RegisterBits = RegisterBits::new(1<<1); + + pub const MPCM: RegisterBits = RegisterBits::new(0x1); + pub const MPCM0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for UCSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x2b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UCSRB; + +impl UCSRB { + pub const RXCIE: RegisterBits = RegisterBits::new(0x80); + pub const RXCIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const TXCIE: RegisterBits = RegisterBits::new(0x40); + pub const TXCIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const UDRIE: RegisterBits = RegisterBits::new(0x20); + pub const UDRIE0: RegisterBits = RegisterBits::new(1<<5); + + pub const RXEN: RegisterBits = RegisterBits::new(0x10); + pub const RXEN0: RegisterBits = RegisterBits::new(1<<4); + + pub const TXEN: RegisterBits = RegisterBits::new(0x8); + pub const TXEN0: RegisterBits = RegisterBits::new(1<<3); + + pub const UCSZ2: RegisterBits = RegisterBits::new(0x4); + pub const UCSZ20: RegisterBits = RegisterBits::new(1<<2); + + pub const RXB8: RegisterBits = RegisterBits::new(0x2); + pub const RXB80: RegisterBits = RegisterBits::new(1<<1); + + pub const TXB8: RegisterBits = RegisterBits::new(0x1); + pub const TXB80: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for UCSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x2a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UCSRC; + +impl UCSRC { + pub const UMSEL: RegisterBits = RegisterBits::new(0xc0); + pub const UMSEL0: RegisterBits = RegisterBits::new(1<<6); + pub const UMSEL1: RegisterBits = RegisterBits::new(1<<7); + + pub const UPM: RegisterBits = RegisterBits::new(0x30); + pub const UPM0: RegisterBits = RegisterBits::new(1<<4); + pub const UPM1: RegisterBits = RegisterBits::new(1<<5); + + pub const USBS: RegisterBits = RegisterBits::new(0x8); + pub const USBS0: RegisterBits = RegisterBits::new(1<<3); + + pub const UCSZ: RegisterBits = RegisterBits::new(0x6); + pub const UCSZ0: RegisterBits = RegisterBits::new(1<<1); + pub const UCSZ1: RegisterBits = RegisterBits::new(1<<2); + + pub const UCPOL: RegisterBits = RegisterBits::new(0x1); + pub const UCPOL0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for UCSRC { + type T = u8; + const ADDRESS: *mut u8 = 0x23 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRRH; + +impl UBRRH { +} + +impl Register for UBRRH { + type T = u8; + const ADDRESS: *mut u8 = 0x22 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRRL; + +impl UBRRL { +} + +impl Register for UBRRL { + type T = u8; + const ADDRESS: *mut u8 = 0x29 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSR; + +impl ACSR { + pub const ACD: RegisterBits = RegisterBits::new(0x80); + pub const ACD0: RegisterBits = RegisterBits::new(1<<7); + + pub const ACBG: RegisterBits = RegisterBits::new(0x40); + pub const ACBG0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACO: RegisterBits = RegisterBits::new(0x20); + pub const ACO0: RegisterBits = RegisterBits::new(1<<5); + + pub const ACI: RegisterBits = RegisterBits::new(0x10); + pub const ACI0: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIE: RegisterBits = RegisterBits::new(0x8); + pub const ACIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ACIC: RegisterBits = RegisterBits::new(0x4); + pub const ACIC0: RegisterBits = RegisterBits::new(1<<2); + + pub const ACIS: RegisterBits = RegisterBits::new(0x3); + pub const ACIS0: RegisterBits = RegisterBits::new(1<<0); + pub const ACIS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for ACSR { + type T = u8; + const ADDRESS: *mut u8 = 0x28 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR; + +impl DIDR { +} + +impl Register for DIDR { + type T = u8; + const ADDRESS: *mut u8 = 0x21 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEAR; + +impl EEAR { +} + +impl Register for EEAR { + type T = u8; + const ADDRESS: *mut u8 = 0x3e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEDR; + +impl EEDR { +} + +impl Register for EEDR { + type T = u8; + const ADDRESS: *mut u8 = 0x3d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EECR; + +impl EECR { + pub const EEPM: RegisterBits = RegisterBits::new(0x30); + pub const EEPM0: RegisterBits = RegisterBits::new(1<<4); + pub const EEPM1: RegisterBits = RegisterBits::new(1<<5); + + pub const EERIE: RegisterBits = RegisterBits::new(0x8); + pub const EERIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const EEMPE: RegisterBits = RegisterBits::new(0x4); + pub const EEMPE0: RegisterBits = RegisterBits::new(1<<2); + + pub const EEPE: RegisterBits = RegisterBits::new(0x2); + pub const EEPE0: RegisterBits = RegisterBits::new(1<<1); + + pub const EERE: RegisterBits = RegisterBits::new(0x1); + pub const EERE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EECR { + type T = u8; + const ADDRESS: *mut u8 = 0x3c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIDR; + +impl USIDR { +} + +impl Register for USIDR { + type T = u8; + const ADDRESS: *mut u8 = 0x2f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USISR; + +impl USISR { + pub const USISIF: RegisterBits = RegisterBits::new(0x80); + pub const USISIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIF: RegisterBits = RegisterBits::new(0x40); + pub const USIOIF0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIPF: RegisterBits = RegisterBits::new(0x20); + pub const USIPF0: RegisterBits = RegisterBits::new(1<<5); + + pub const USIDC: RegisterBits = RegisterBits::new(0x10); + pub const USIDC0: RegisterBits = RegisterBits::new(1<<4); + + pub const USICNT: RegisterBits = RegisterBits::new(0xf); + pub const USICNT0: RegisterBits = RegisterBits::new(1<<0); + pub const USICNT1: RegisterBits = RegisterBits::new(1<<1); + pub const USICNT2: RegisterBits = RegisterBits::new(1<<2); + pub const USICNT3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for USISR { + type T = u8; + const ADDRESS: *mut u8 = 0x2e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USICR; + +impl USICR { + pub const USISIE: RegisterBits = RegisterBits::new(0x80); + pub const USISIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIE: RegisterBits = RegisterBits::new(0x40); + pub const USIOIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIWM: RegisterBits = RegisterBits::new(0x30); + pub const USIWM0: RegisterBits = RegisterBits::new(1<<4); + pub const USIWM1: RegisterBits = RegisterBits::new(1<<5); + + pub const USICS: RegisterBits = RegisterBits::new(0xc); + pub const USICS0: RegisterBits = RegisterBits::new(1<<2); + pub const USICS1: RegisterBits = RegisterBits::new(1<<3); + + pub const USICLK: RegisterBits = RegisterBits::new(0x2); + pub const USICLK0: RegisterBits = RegisterBits::new(1<<1); + + pub const USITC: RegisterBits = RegisterBits::new(0x1); + pub const USITC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for USICR { + type T = u8; + const ADDRESS: *mut u8 = 0x2d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIMSK; + +impl GIMSK { + pub const INT: RegisterBits = RegisterBits::new(0xc0); + pub const INT0: RegisterBits = RegisterBits::new(1<<6); + pub const INT1: RegisterBits = RegisterBits::new(1<<7); + + pub const PCIE: RegisterBits = RegisterBits::new(0x20); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x5b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIFR; + +impl GIFR { + pub const INTF: RegisterBits = RegisterBits::new(0xc0); + pub const INTF0: RegisterBits = RegisterBits::new(1<<6); + pub const INTF1: RegisterBits = RegisterBits::new(1<<7); + + pub const PCIF: RegisterBits = RegisterBits::new(0x38); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<3); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<4); + pub const PCIF2: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x5a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK2; + +impl PCMSK2 { + pub const PCINT: RegisterBits = RegisterBits::new(0x7f); + pub const PCINT0: RegisterBits = RegisterBits::new(1<<0); + pub const PCINT1: RegisterBits = RegisterBits::new(1<<1); + pub const PCINT2: RegisterBits = RegisterBits::new(1<<2); + pub const PCINT3: RegisterBits = RegisterBits::new(1<<3); + pub const PCINT4: RegisterBits = RegisterBits::new(1<<4); + pub const PCINT5: RegisterBits = RegisterBits::new(1<<5); + pub const PCINT6: RegisterBits = RegisterBits::new(1<<6); + +} + +impl Register for PCMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x25 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { + pub const PCINT: RegisterBits = RegisterBits::new(0x7); + pub const PCINT0: RegisterBits = RegisterBits::new(1<<0); + pub const PCINT1: RegisterBits = RegisterBits::new(1<<1); + pub const PCINT2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x24 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK0; + +impl PCMSK0 { +} + +impl Register for PCMSK0 { + type T = u8; + const ADDRESS: *mut u8 = 0x40 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SREG; + +impl SREG { + pub const I: RegisterBits = RegisterBits::new(0x80); + pub const I0: RegisterBits = RegisterBits::new(1<<7); + + pub const T: RegisterBits = RegisterBits::new(0x40); + pub const T0: RegisterBits = RegisterBits::new(1<<6); + + pub const H: RegisterBits = RegisterBits::new(0x20); + pub const H0: RegisterBits = RegisterBits::new(1<<5); + + pub const S: RegisterBits = RegisterBits::new(0x10); + pub const S0: RegisterBits = RegisterBits::new(1<<4); + + pub const V: RegisterBits = RegisterBits::new(0x8); + pub const V0: RegisterBits = RegisterBits::new(1<<3); + + pub const N: RegisterBits = RegisterBits::new(0x4); + pub const N0: RegisterBits = RegisterBits::new(1<<2); + + pub const Z: RegisterBits = RegisterBits::new(0x2); + pub const Z0: RegisterBits = RegisterBits::new(1<<1); + + pub const C: RegisterBits = RegisterBits::new(0x1); + pub const C0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SREG { + type T = u8; + const ADDRESS: *mut u8 = 0x5f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPL; + +impl SPL { +} + +impl Register for SPL { + type T = u8; + const ADDRESS: *mut u8 = 0x5d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPMCSR; + +impl SPMCSR { + pub const CTPB: RegisterBits = RegisterBits::new(0x10); + pub const CTPB0: RegisterBits = RegisterBits::new(1<<4); + + pub const RFLB: RegisterBits = RegisterBits::new(0x8); + pub const RFLB0: RegisterBits = RegisterBits::new(1<<3); + + pub const PGWRT: RegisterBits = RegisterBits::new(0x4); + pub const PGWRT0: RegisterBits = RegisterBits::new(1<<2); + + pub const PGERS: RegisterBits = RegisterBits::new(0x2); + pub const PGERS0: RegisterBits = RegisterBits::new(1<<1); + + pub const SPMEN: RegisterBits = RegisterBits::new(0x1); + pub const SPMEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SPMCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x57 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const PUD: RegisterBits = RegisterBits::new(0x80); + pub const PUD0: RegisterBits = RegisterBits::new(1<<7); + + pub const SM: RegisterBits = RegisterBits::new(0x50); + pub const SM0: RegisterBits = RegisterBits::new(1<<4); + pub const SM1: RegisterBits = RegisterBits::new(1<<6); + + pub const SE: RegisterBits = RegisterBits::new(0x20); + pub const SE0: RegisterBits = RegisterBits::new(1<<5); + + pub const ISC1: RegisterBits = RegisterBits::new(0xc); + pub const ISC10: RegisterBits = RegisterBits::new(1<<2); + pub const ISC11: RegisterBits = RegisterBits::new(1<<3); + + pub const ISC0: RegisterBits = RegisterBits::new(0x3); + pub const ISC00: RegisterBits = RegisterBits::new(1<<0); + pub const ISC01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUSR; + +impl MCUSR { + pub const WDRF: RegisterBits = RegisterBits::new(0x8); + pub const WDRF0: RegisterBits = RegisterBits::new(1<<3); + + pub const BORF: RegisterBits = RegisterBits::new(0x4); + pub const BORF0: RegisterBits = RegisterBits::new(1<<2); + + pub const EXTRF: RegisterBits = RegisterBits::new(0x2); + pub const EXTRF0: RegisterBits = RegisterBits::new(1<<1); + + pub const PORF: RegisterBits = RegisterBits::new(0x1); + pub const PORF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUSR { + type T = u8; + const ADDRESS: *mut u8 = 0x54 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCCAL; + +impl OSCCAL { + pub const OSCCAL: RegisterBits = RegisterBits::new(0xff); + pub const OSCCAL0: RegisterBits = RegisterBits::new(1<<0); + pub const OSCCAL1: RegisterBits = RegisterBits::new(1<<1); + pub const OSCCAL2: RegisterBits = RegisterBits::new(1<<2); + pub const OSCCAL3: RegisterBits = RegisterBits::new(1<<3); + pub const OSCCAL4: RegisterBits = RegisterBits::new(1<<4); + pub const OSCCAL5: RegisterBits = RegisterBits::new(1<<5); + pub const OSCCAL6: RegisterBits = RegisterBits::new(1<<6); + pub const OSCCAL7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OSCCAL { + type T = u8; + const ADDRESS: *mut u8 = 0x51 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKPR; + +impl CLKPR { + pub const CLKPCE: RegisterBits = RegisterBits::new(0x80); + pub const CLKPCE0: RegisterBits = RegisterBits::new(1<<7); + + pub const CLKPS: RegisterBits = RegisterBits::new(0xf); + pub const CLKPS0: RegisterBits = RegisterBits::new(1<<0); + pub const CLKPS1: RegisterBits = RegisterBits::new(1<<1); + pub const CLKPS2: RegisterBits = RegisterBits::new(1<<2); + pub const CLKPS3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CLKPR { + type T = u8; + const ADDRESS: *mut u8 = 0x46 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR2; + +impl GPIOR2 { +} + +impl Register for GPIOR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x35 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR1; + +impl GPIOR1 { +} + +impl Register for GPIOR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x34 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR0; + +impl GPIOR0 { +} + +impl Register for GPIOR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x33 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTIM: RegisterBits = RegisterBits::new(0xc); + pub const PRTIM0: RegisterBits = RegisterBits::new(1<<2); + pub const PRTIM1: RegisterBits = RegisterBits::new(1<<3); + + pub const PRUSI: RegisterBits = RegisterBits::new(0x2); + pub const PRUSI0: RegisterBits = RegisterBits::new(1<<1); + + pub const PRUSART: RegisterBits = RegisterBits::new(0x1); + pub const PRUSART0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PRR { + type T = u8; + const ADDRESS: *mut u8 = 0x26 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct BODCR; + +impl BODCR { + pub const BPDS: RegisterBits = RegisterBits::new(0x2); + pub const BPDS0: RegisterBits = RegisterBits::new(1<<1); + + pub const BPDSE: RegisterBits = RegisterBits::new(0x1); + pub const BPDSE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for BODCR { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + +} + +/// The USART module. +pub struct USART; + +impl modules::HardwareUsart for USART { + type DataRegister = UDR; + type ControlRegisterA = UCSRA; + type ControlRegisterB = UCSRB; + type ControlRegisterC = UCSRC; + type BaudRateRegister = UBRRH; + type BaudRateRegister = UBRRL; +} + +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR0A; + type CompareB = OCR0B; + type Counter = TCNT0; + type ControlA = TCCR0A; + type ControlB = TCCR0B; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE0A; +} +/// 16-bit timer. +pub struct Timer16; + +impl modules::Timer16 for Timer16 { + type CompareA = OCR1A; + type CompareB = OCR1B; + type Counter = TCNT1; + type ControlA = TCCR1A; + type ControlB = TCCR1B; + type ControlC = TCCR1C; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS10; + const CS1: RegisterBits = Self::ControlB::CS11; + const CS2: RegisterBits = Self::ControlB::CS12; + const WGM0: RegisterBits = Self::ControlA::WGM10; + const WGM1: RegisterBits = Self::ControlA::WGM11; + const WGM2: RegisterBits = Self::ControlB::WGM10; + const WGM3: RegisterBits = Self::ControlB::WGM11; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE1A; +} + diff --git a/src/cores/attiny26.rs b/src/cores/attiny26.rs new file mode 100644 index 0000000..66404ae --- /dev/null +++ b/src/cores/attiny26.rs @@ -0,0 +1,726 @@ +//! Core for ATtiny26. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct HIGH; + +impl HIGH { + pub const RSTDISBL: RegisterBits = RegisterBits::new(0x10); + pub const RSTDISBL0: RegisterBits = RegisterBits::new(1<<4); + + pub const SPIEN: RegisterBits = RegisterBits::new(0x8); + pub const SPIEN0: RegisterBits = RegisterBits::new(1<<3); + + pub const EESAVE: RegisterBits = RegisterBits::new(0x4); + pub const EESAVE0: RegisterBits = RegisterBits::new(1<<2); + + pub const BODLEVEL: RegisterBits = RegisterBits::new(0x2); + pub const BODLEVEL0: RegisterBits = RegisterBits::new(1<<1); + + pub const BODEN: RegisterBits = RegisterBits::new(0x1); + pub const BODEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for HIGH { + type T = u8; + const ADDRESS: *mut u8 = 0x1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOW; + +impl LOW { + pub const CKOPT: RegisterBits = RegisterBits::new(0x40); + pub const CKOPT0: RegisterBits = RegisterBits::new(1<<6); + + pub const PLLCK_SUT_CKSEL: RegisterBits = RegisterBits::new(0xbf); + pub const PLLCK_SUT_CKSEL0: RegisterBits = RegisterBits::new(1<<0); + pub const PLLCK_SUT_CKSEL1: RegisterBits = RegisterBits::new(1<<1); + pub const PLLCK_SUT_CKSEL2: RegisterBits = RegisterBits::new(1<<2); + pub const PLLCK_SUT_CKSEL3: RegisterBits = RegisterBits::new(1<<3); + pub const PLLCK_SUT_CKSEL4: RegisterBits = RegisterBits::new(1<<4); + pub const PLLCK_SUT_CKSEL5: RegisterBits = RegisterBits::new(1<<5); + pub const PLLCK_SUT_CKSEL6: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for LOW { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOCKBIT; + +impl LOCKBIT { + pub const LB: RegisterBits = RegisterBits::new(0x3); + pub const LB0: RegisterBits = RegisterBits::new(1<<0); + pub const LB1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for LOCKBIT { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADMUX; + +impl ADMUX { + pub const REFS: RegisterBits = RegisterBits::new(0xc0); + pub const REFS0: RegisterBits = RegisterBits::new(1<<6); + pub const REFS1: RegisterBits = RegisterBits::new(1<<7); + + pub const ADLAR: RegisterBits = RegisterBits::new(0x20); + pub const ADLAR0: RegisterBits = RegisterBits::new(1<<5); + + pub const MUX: RegisterBits = RegisterBits::new(0x1f); + pub const MUX0: RegisterBits = RegisterBits::new(1<<0); + pub const MUX1: RegisterBits = RegisterBits::new(1<<1); + pub const MUX2: RegisterBits = RegisterBits::new(1<<2); + pub const MUX3: RegisterBits = RegisterBits::new(1<<3); + pub const MUX4: RegisterBits = RegisterBits::new(1<<4); + +} + +impl Register for ADMUX { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADCSR; + +impl ADCSR { + pub const ADEN: RegisterBits = RegisterBits::new(0x80); + pub const ADEN0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADSC: RegisterBits = RegisterBits::new(0x40); + pub const ADSC0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADFR: RegisterBits = RegisterBits::new(0x20); + pub const ADFR0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADIF: RegisterBits = RegisterBits::new(0x10); + pub const ADIF0: RegisterBits = RegisterBits::new(1<<4); + + pub const ADIE: RegisterBits = RegisterBits::new(0x8); + pub const ADIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADPS: RegisterBits = RegisterBits::new(0x7); + pub const ADPS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADPS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADPS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x26 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x24 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ACSR; + +impl ACSR { + pub const ACD: RegisterBits = RegisterBits::new(0x80); + pub const ACD0: RegisterBits = RegisterBits::new(1<<7); + + pub const ACBG: RegisterBits = RegisterBits::new(0x40); + pub const ACBG0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACO: RegisterBits = RegisterBits::new(0x20); + pub const ACO0: RegisterBits = RegisterBits::new(1<<5); + + pub const ACI: RegisterBits = RegisterBits::new(0x10); + pub const ACI0: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIE: RegisterBits = RegisterBits::new(0x8); + pub const ACIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ACME: RegisterBits = RegisterBits::new(0x4); + pub const ACME0: RegisterBits = RegisterBits::new(1<<2); + + pub const ACIS: RegisterBits = RegisterBits::new(0x3); + pub const ACIS0: RegisterBits = RegisterBits::new(1<<0); + pub const ACIS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for ACSR { + type T = u8; + const ADDRESS: *mut u8 = 0x28 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIDR; + +impl USIDR { +} + +impl Register for USIDR { + type T = u8; + const ADDRESS: *mut u8 = 0x2f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USISR; + +impl USISR { + pub const USISIF: RegisterBits = RegisterBits::new(0x80); + pub const USISIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIF: RegisterBits = RegisterBits::new(0x40); + pub const USIOIF0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIPF: RegisterBits = RegisterBits::new(0x20); + pub const USIPF0: RegisterBits = RegisterBits::new(1<<5); + + pub const USIDC: RegisterBits = RegisterBits::new(0x10); + pub const USIDC0: RegisterBits = RegisterBits::new(1<<4); + + pub const USICNT: RegisterBits = RegisterBits::new(0xf); + pub const USICNT0: RegisterBits = RegisterBits::new(1<<0); + pub const USICNT1: RegisterBits = RegisterBits::new(1<<1); + pub const USICNT2: RegisterBits = RegisterBits::new(1<<2); + pub const USICNT3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for USISR { + type T = u8; + const ADDRESS: *mut u8 = 0x2e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USICR; + +impl USICR { + pub const USISIE: RegisterBits = RegisterBits::new(0x80); + pub const USISIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIE: RegisterBits = RegisterBits::new(0x40); + pub const USIOIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIWM: RegisterBits = RegisterBits::new(0x30); + pub const USIWM0: RegisterBits = RegisterBits::new(1<<4); + pub const USIWM1: RegisterBits = RegisterBits::new(1<<5); + + pub const USICS: RegisterBits = RegisterBits::new(0xc); + pub const USICS0: RegisterBits = RegisterBits::new(1<<2); + pub const USICS1: RegisterBits = RegisterBits::new(1<<3); + + pub const USICLK: RegisterBits = RegisterBits::new(0x2); + pub const USICLK0: RegisterBits = RegisterBits::new(1<<1); + + pub const USITC: RegisterBits = RegisterBits::new(0x1); + pub const USITC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for USICR { + type T = u8; + const ADDRESS: *mut u8 = 0x2d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTA; + +impl PORTA { +} + +impl Register for PORTA { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRA; + +impl DDRA { +} + +impl Register for DDRA { + type T = u8; + const ADDRESS: *mut u8 = 0x3a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINA; + +impl PINA { +} + +impl Register for PINA { + type T = u8; + const ADDRESS: *mut u8 = 0x39 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x38 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x36 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEAR; + +impl EEAR { +} + +impl Register for EEAR { + type T = u8; + const ADDRESS: *mut u8 = 0x3e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEDR; + +impl EEDR { +} + +impl Register for EEDR { + type T = u8; + const ADDRESS: *mut u8 = 0x3d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EECR; + +impl EECR { + pub const EERIE: RegisterBits = RegisterBits::new(0x8); + pub const EERIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const EEMWE: RegisterBits = RegisterBits::new(0x4); + pub const EEMWE0: RegisterBits = RegisterBits::new(1<<2); + + pub const EEWE: RegisterBits = RegisterBits::new(0x2); + pub const EEWE0: RegisterBits = RegisterBits::new(1<<1); + + pub const EERE: RegisterBits = RegisterBits::new(0x1); + pub const EERE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EECR { + type T = u8; + const ADDRESS: *mut u8 = 0x3c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct WDTCR; + +impl WDTCR { + pub const WDCE: RegisterBits = RegisterBits::new(0x10); + pub const WDCE0: RegisterBits = RegisterBits::new(1<<4); + + pub const WDE: RegisterBits = RegisterBits::new(0x8); + pub const WDE0: RegisterBits = RegisterBits::new(1<<3); + + pub const WDP: RegisterBits = RegisterBits::new(0x7); + pub const WDP0: RegisterBits = RegisterBits::new(1<<0); + pub const WDP1: RegisterBits = RegisterBits::new(1<<1); + pub const WDP2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for WDTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x41 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SREG; + +impl SREG { + pub const I: RegisterBits = RegisterBits::new(0x80); + pub const I0: RegisterBits = RegisterBits::new(1<<7); + + pub const T: RegisterBits = RegisterBits::new(0x40); + pub const T0: RegisterBits = RegisterBits::new(1<<6); + + pub const H: RegisterBits = RegisterBits::new(0x20); + pub const H0: RegisterBits = RegisterBits::new(1<<5); + + pub const S: RegisterBits = RegisterBits::new(0x10); + pub const S0: RegisterBits = RegisterBits::new(1<<4); + + pub const V: RegisterBits = RegisterBits::new(0x8); + pub const V0: RegisterBits = RegisterBits::new(1<<3); + + pub const N: RegisterBits = RegisterBits::new(0x4); + pub const N0: RegisterBits = RegisterBits::new(1<<2); + + pub const Z: RegisterBits = RegisterBits::new(0x2); + pub const Z0: RegisterBits = RegisterBits::new(1<<1); + + pub const C: RegisterBits = RegisterBits::new(0x1); + pub const C0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SREG { + type T = u8; + const ADDRESS: *mut u8 = 0x5f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SP; + +impl SP { +} + +impl Register for SP { + type T = u8; + const ADDRESS: *mut u8 = 0x5d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const PUD: RegisterBits = RegisterBits::new(0x40); + pub const PUD0: RegisterBits = RegisterBits::new(1<<6); + + pub const SE: RegisterBits = RegisterBits::new(0x20); + pub const SE0: RegisterBits = RegisterBits::new(1<<5); + + pub const SM: RegisterBits = RegisterBits::new(0x18); + pub const SM0: RegisterBits = RegisterBits::new(1<<3); + pub const SM1: RegisterBits = RegisterBits::new(1<<4); + + pub const ISC0: RegisterBits = RegisterBits::new(0x3); + pub const ISC00: RegisterBits = RegisterBits::new(1<<0); + pub const ISC01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUSR; + +impl MCUSR { + pub const WDRF: RegisterBits = RegisterBits::new(0x8); + pub const WDRF0: RegisterBits = RegisterBits::new(1<<3); + + pub const BORF: RegisterBits = RegisterBits::new(0x4); + pub const BORF0: RegisterBits = RegisterBits::new(1<<2); + + pub const EXTRF: RegisterBits = RegisterBits::new(0x2); + pub const EXTRF0: RegisterBits = RegisterBits::new(1<<1); + + pub const PORF: RegisterBits = RegisterBits::new(0x1); + pub const PORF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUSR { + type T = u8; + const ADDRESS: *mut u8 = 0x54 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCCAL; + +impl OSCCAL { + pub const OSCCAL: RegisterBits = RegisterBits::new(0xff); + pub const OSCCAL0: RegisterBits = RegisterBits::new(1<<0); + pub const OSCCAL1: RegisterBits = RegisterBits::new(1<<1); + pub const OSCCAL2: RegisterBits = RegisterBits::new(1<<2); + pub const OSCCAL3: RegisterBits = RegisterBits::new(1<<3); + pub const OSCCAL4: RegisterBits = RegisterBits::new(1<<4); + pub const OSCCAL5: RegisterBits = RegisterBits::new(1<<5); + pub const OSCCAL6: RegisterBits = RegisterBits::new(1<<6); + pub const OSCCAL7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OSCCAL { + type T = u8; + const ADDRESS: *mut u8 = 0x51 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const TOIE0: RegisterBits = RegisterBits::new(0x2); + pub const TOIE00: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const TOV0: RegisterBits = RegisterBits::new(0x2); + pub const TOV00: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0; + +impl TCCR0 { + pub const PSR0: RegisterBits = RegisterBits::new(0x8); + pub const PSR00: RegisterBits = RegisterBits::new(1<<3); + + pub const CS0: RegisterBits = RegisterBits::new(0x7); + pub const CS00: RegisterBits = RegisterBits::new(1<<0); + pub const CS01: RegisterBits = RegisterBits::new(1<<1); + pub const CS02: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x53 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0; + +impl TCNT0 { +} + +impl Register for TCNT0 { + type T = u8; + const ADDRESS: *mut u8 = 0x52 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1A; + +impl TCCR1A { + pub const COM1A: RegisterBits = RegisterBits::new(0xc0); + pub const COM1A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM1A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM1B: RegisterBits = RegisterBits::new(0x30); + pub const COM1B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM1B1: RegisterBits = RegisterBits::new(1<<5); + + pub const FOC1A: RegisterBits = RegisterBits::new(0x8); + pub const FOC1A0: RegisterBits = RegisterBits::new(1<<3); + + pub const FOC1B: RegisterBits = RegisterBits::new(0x4); + pub const FOC1B0: RegisterBits = RegisterBits::new(1<<2); + + pub const PWM1A: RegisterBits = RegisterBits::new(0x2); + pub const PWM1A0: RegisterBits = RegisterBits::new(1<<1); + + pub const PWM1B: RegisterBits = RegisterBits::new(0x1); + pub const PWM1B0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1B; + +impl TCCR1B { + pub const CTC1: RegisterBits = RegisterBits::new(0x80); + pub const CTC10: RegisterBits = RegisterBits::new(1<<7); + + pub const PSR1: RegisterBits = RegisterBits::new(0x40); + pub const PSR10: RegisterBits = RegisterBits::new(1<<6); + + pub const CS1: RegisterBits = RegisterBits::new(0xf); + pub const CS10: RegisterBits = RegisterBits::new(1<<0); + pub const CS11: RegisterBits = RegisterBits::new(1<<1); + pub const CS12: RegisterBits = RegisterBits::new(1<<2); + pub const CS13: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for TCCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x4f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT1; + +impl TCNT1 { +} + +impl Register for TCNT1 { + type T = u8; + const ADDRESS: *mut u8 = 0x4e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x4d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x4c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1C; + +impl OCR1C { +} + +impl Register for OCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x4b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE1A: RegisterBits = RegisterBits::new(0x40); + pub const OCIE1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x20); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const TOIE1: RegisterBits = RegisterBits::new(0x4); + pub const TOIE10: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF1A: RegisterBits = RegisterBits::new(0x40); + pub const OCF1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x20); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const TOV1: RegisterBits = RegisterBits::new(0x4); + pub const TOV10: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PLLCSR; + +impl PLLCSR { + pub const PCKE: RegisterBits = RegisterBits::new(0x4); + pub const PCKE0: RegisterBits = RegisterBits::new(1<<2); + + pub const PLLE: RegisterBits = RegisterBits::new(0x2); + pub const PLLE0: RegisterBits = RegisterBits::new(1<<1); + + pub const PLOCK: RegisterBits = RegisterBits::new(0x1); + pub const PLOCK0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PLLCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x49 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIMSK; + +impl GIMSK { + pub const INT0: RegisterBits = RegisterBits::new(0x40); + pub const INT00: RegisterBits = RegisterBits::new(1<<6); + + pub const PCIE: RegisterBits = RegisterBits::new(0x30); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<4); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x5b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIFR; + +impl GIFR { + pub const INTF0: RegisterBits = RegisterBits::new(0x40); + pub const INTF00: RegisterBits = RegisterBits::new(1<<6); + + pub const PCIF: RegisterBits = RegisterBits::new(0x20); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x5a as *mut u8; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + +} + +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR1A; + type CompareB = OCR1B; + type Counter = TCNT1; + type ControlA = TCCR1A; + type ControlB = TCCR1B; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE1A; +} + diff --git a/src/cores/attiny261.rs b/src/cores/attiny261.rs new file mode 100644 index 0000000..7d191cd --- /dev/null +++ b/src/cores/attiny261.rs @@ -0,0 +1,1468 @@ +//! Core for ATtiny261. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + pub const SELFPRGEN: RegisterBits = RegisterBits::new(0x1); + pub const SELFPRGEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EXTENDED { + type T = u8; + const ADDRESS: *mut u8 = 0x2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct HIGH; + +impl HIGH { + pub const RSTDISBL: RegisterBits = RegisterBits::new(0x80); + pub const RSTDISBL0: RegisterBits = RegisterBits::new(1<<7); + + pub const DWEN: RegisterBits = RegisterBits::new(0x40); + pub const DWEN0: RegisterBits = RegisterBits::new(1<<6); + + pub const SPIEN: RegisterBits = RegisterBits::new(0x20); + pub const SPIEN0: RegisterBits = RegisterBits::new(1<<5); + + pub const WDTON: RegisterBits = RegisterBits::new(0x10); + pub const WDTON0: RegisterBits = RegisterBits::new(1<<4); + + pub const EESAVE: RegisterBits = RegisterBits::new(0x8); + pub const EESAVE0: RegisterBits = RegisterBits::new(1<<3); + + pub const BODLEVEL: RegisterBits = RegisterBits::new(0x7); + pub const BODLEVEL0: RegisterBits = RegisterBits::new(1<<0); + pub const BODLEVEL1: RegisterBits = RegisterBits::new(1<<1); + pub const BODLEVEL2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for HIGH { + type T = u8; + const ADDRESS: *mut u8 = 0x1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOW; + +impl LOW { + pub const CKDIV8: RegisterBits = RegisterBits::new(0x80); + pub const CKDIV80: RegisterBits = RegisterBits::new(1<<7); + + pub const CKOUT: RegisterBits = RegisterBits::new(0x40); + pub const CKOUT0: RegisterBits = RegisterBits::new(1<<6); + + pub const SUT_CKSEL: RegisterBits = RegisterBits::new(0x3f); + pub const SUT_CKSEL0: RegisterBits = RegisterBits::new(1<<0); + pub const SUT_CKSEL1: RegisterBits = RegisterBits::new(1<<1); + pub const SUT_CKSEL2: RegisterBits = RegisterBits::new(1<<2); + pub const SUT_CKSEL3: RegisterBits = RegisterBits::new(1<<3); + pub const SUT_CKSEL4: RegisterBits = RegisterBits::new(1<<4); + pub const SUT_CKSEL5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for LOW { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOCKBIT; + +impl LOCKBIT { + pub const LB: RegisterBits = RegisterBits::new(0x3); + pub const LB0: RegisterBits = RegisterBits::new(1<<0); + pub const LB1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for LOCKBIT { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTA; + +impl PORTA { +} + +impl Register for PORTA { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRA; + +impl DDRA { +} + +impl Register for DDRA { + type T = u8; + const ADDRESS: *mut u8 = 0x3a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINA; + +impl PINA { +} + +impl Register for PINA { + type T = u8; + const ADDRESS: *mut u8 = 0x39 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x38 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x36 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADMUX; + +impl ADMUX { + pub const REFS: RegisterBits = RegisterBits::new(0xc0); + pub const REFS0: RegisterBits = RegisterBits::new(1<<6); + pub const REFS1: RegisterBits = RegisterBits::new(1<<7); + + pub const ADLAR: RegisterBits = RegisterBits::new(0x20); + pub const ADLAR0: RegisterBits = RegisterBits::new(1<<5); + + pub const MUX: RegisterBits = RegisterBits::new(0x1f); + pub const MUX0: RegisterBits = RegisterBits::new(1<<0); + pub const MUX1: RegisterBits = RegisterBits::new(1<<1); + pub const MUX2: RegisterBits = RegisterBits::new(1<<2); + pub const MUX3: RegisterBits = RegisterBits::new(1<<3); + pub const MUX4: RegisterBits = RegisterBits::new(1<<4); + +} + +impl Register for ADMUX { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADCSRA; + +impl ADCSRA { + pub const ADEN: RegisterBits = RegisterBits::new(0x80); + pub const ADEN0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADSC: RegisterBits = RegisterBits::new(0x40); + pub const ADSC0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADATE: RegisterBits = RegisterBits::new(0x20); + pub const ADATE0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADIF: RegisterBits = RegisterBits::new(0x10); + pub const ADIF0: RegisterBits = RegisterBits::new(1<<4); + + pub const ADIE: RegisterBits = RegisterBits::new(0x8); + pub const ADIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADPS: RegisterBits = RegisterBits::new(0x7); + pub const ADPS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADPS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADPS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x26 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x24 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ADCSRB; + +impl ADCSRB { + pub const BIN: RegisterBits = RegisterBits::new(0x80); + pub const BIN0: RegisterBits = RegisterBits::new(1<<7); + + pub const GSEL: RegisterBits = RegisterBits::new(0x40); + pub const GSEL0: RegisterBits = RegisterBits::new(1<<6); + + pub const IPR: RegisterBits = RegisterBits::new(0x20); + pub const IPR0: RegisterBits = RegisterBits::new(1<<5); + + pub const REFS2: RegisterBits = RegisterBits::new(0x10); + pub const REFS20: RegisterBits = RegisterBits::new(1<<4); + + pub const MUX5: RegisterBits = RegisterBits::new(0x8); + pub const MUX50: RegisterBits = RegisterBits::new(1<<3); + + pub const ADTS: RegisterBits = RegisterBits::new(0x7); + pub const ADTS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADTS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADTS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x23 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + pub const ADC10D: RegisterBits = RegisterBits::new(0x80); + pub const ADC10D0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADC9D: RegisterBits = RegisterBits::new(0x40); + pub const ADC9D0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADC8D: RegisterBits = RegisterBits::new(0x20); + pub const ADC8D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC7D: RegisterBits = RegisterBits::new(0x10); + pub const ADC7D0: RegisterBits = RegisterBits::new(1<<4); + +} + +impl Register for DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x22 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + pub const ADC6D: RegisterBits = RegisterBits::new(0x80); + pub const ADC6D0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADC5D: RegisterBits = RegisterBits::new(0x40); + pub const ADC5D0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADC4D: RegisterBits = RegisterBits::new(0x20); + pub const ADC4D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC3D: RegisterBits = RegisterBits::new(0x10); + pub const ADC3D0: RegisterBits = RegisterBits::new(1<<4); + + pub const AREFD: RegisterBits = RegisterBits::new(0x8); + pub const AREFD0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADC2D: RegisterBits = RegisterBits::new(0x4); + pub const ADC2D0: RegisterBits = RegisterBits::new(1<<2); + + pub const ADC1D: RegisterBits = RegisterBits::new(0x2); + pub const ADC1D0: RegisterBits = RegisterBits::new(1<<1); + + pub const ADC0D: RegisterBits = RegisterBits::new(0x1); + pub const ADC0D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for DIDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x21 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSRB; + +impl ACSRB { + pub const HSEL: RegisterBits = RegisterBits::new(0x80); + pub const HSEL0: RegisterBits = RegisterBits::new(1<<7); + + pub const HLEV: RegisterBits = RegisterBits::new(0x40); + pub const HLEV0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACM: RegisterBits = RegisterBits::new(0x7); + pub const ACM0: RegisterBits = RegisterBits::new(1<<0); + pub const ACM1: RegisterBits = RegisterBits::new(1<<1); + pub const ACM2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ACSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x29 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSRA; + +impl ACSRA { + pub const ACD: RegisterBits = RegisterBits::new(0x80); + pub const ACD0: RegisterBits = RegisterBits::new(1<<7); + + pub const ACBG: RegisterBits = RegisterBits::new(0x40); + pub const ACBG0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACO: RegisterBits = RegisterBits::new(0x20); + pub const ACO0: RegisterBits = RegisterBits::new(1<<5); + + pub const ACI: RegisterBits = RegisterBits::new(0x10); + pub const ACI0: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIE: RegisterBits = RegisterBits::new(0x8); + pub const ACIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ACME: RegisterBits = RegisterBits::new(0x4); + pub const ACME0: RegisterBits = RegisterBits::new(1<<2); + + pub const ACIS: RegisterBits = RegisterBits::new(0x3); + pub const ACIS0: RegisterBits = RegisterBits::new(1<<0); + pub const ACIS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for ACSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x28 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIPP; + +impl USIPP { +} + +impl Register for USIPP { + type T = u8; + const ADDRESS: *mut u8 = 0x31 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIBR; + +impl USIBR { +} + +impl Register for USIBR { + type T = u8; + const ADDRESS: *mut u8 = 0x30 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIDR; + +impl USIDR { +} + +impl Register for USIDR { + type T = u8; + const ADDRESS: *mut u8 = 0x2f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USISR; + +impl USISR { + pub const USISIF: RegisterBits = RegisterBits::new(0x80); + pub const USISIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIF: RegisterBits = RegisterBits::new(0x40); + pub const USIOIF0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIPF: RegisterBits = RegisterBits::new(0x20); + pub const USIPF0: RegisterBits = RegisterBits::new(1<<5); + + pub const USIDC: RegisterBits = RegisterBits::new(0x10); + pub const USIDC0: RegisterBits = RegisterBits::new(1<<4); + + pub const USICNT: RegisterBits = RegisterBits::new(0xf); + pub const USICNT0: RegisterBits = RegisterBits::new(1<<0); + pub const USICNT1: RegisterBits = RegisterBits::new(1<<1); + pub const USICNT2: RegisterBits = RegisterBits::new(1<<2); + pub const USICNT3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for USISR { + type T = u8; + const ADDRESS: *mut u8 = 0x2e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USICR; + +impl USICR { + pub const USISIE: RegisterBits = RegisterBits::new(0x80); + pub const USISIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIE: RegisterBits = RegisterBits::new(0x40); + pub const USIOIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIWM: RegisterBits = RegisterBits::new(0x30); + pub const USIWM0: RegisterBits = RegisterBits::new(1<<4); + pub const USIWM1: RegisterBits = RegisterBits::new(1<<5); + + pub const USICS: RegisterBits = RegisterBits::new(0xc); + pub const USICS0: RegisterBits = RegisterBits::new(1<<2); + pub const USICS1: RegisterBits = RegisterBits::new(1<<3); + + pub const USICLK: RegisterBits = RegisterBits::new(0x2); + pub const USICLK0: RegisterBits = RegisterBits::new(1<<1); + + pub const USITC: RegisterBits = RegisterBits::new(0x1); + pub const USITC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for USICR { + type T = u8; + const ADDRESS: *mut u8 = 0x2d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEAR; + +impl EEAR { +} + +impl Register for EEAR { + type T = u16; + const ADDRESS: *mut u16 = 0x3e as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct EEDR; + +impl EEDR { +} + +impl Register for EEDR { + type T = u8; + const ADDRESS: *mut u8 = 0x3d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EECR; + +impl EECR { + pub const EEPM: RegisterBits = RegisterBits::new(0x30); + pub const EEPM0: RegisterBits = RegisterBits::new(1<<4); + pub const EEPM1: RegisterBits = RegisterBits::new(1<<5); + + pub const EERIE: RegisterBits = RegisterBits::new(0x8); + pub const EERIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const EEMPE: RegisterBits = RegisterBits::new(0x4); + pub const EEMPE0: RegisterBits = RegisterBits::new(1<<2); + + pub const EEPE: RegisterBits = RegisterBits::new(0x2); + pub const EEPE0: RegisterBits = RegisterBits::new(1<<1); + + pub const EERE: RegisterBits = RegisterBits::new(0x1); + pub const EERE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EECR { + type T = u8; + const ADDRESS: *mut u8 = 0x3c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct WDTCR; + +impl WDTCR { + pub const WDIF: RegisterBits = RegisterBits::new(0x80); + pub const WDIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WDIE: RegisterBits = RegisterBits::new(0x40); + pub const WDIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const WDP: RegisterBits = RegisterBits::new(0x27); + pub const WDP0: RegisterBits = RegisterBits::new(1<<0); + pub const WDP1: RegisterBits = RegisterBits::new(1<<1); + pub const WDP2: RegisterBits = RegisterBits::new(1<<2); + pub const WDP3: RegisterBits = RegisterBits::new(1<<5); + + pub const WDCE: RegisterBits = RegisterBits::new(0x10); + pub const WDCE0: RegisterBits = RegisterBits::new(1<<4); + + pub const WDE: RegisterBits = RegisterBits::new(0x8); + pub const WDE0: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for WDTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x41 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE0A: RegisterBits = RegisterBits::new(0x10); + pub const OCIE0A0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCIE0B: RegisterBits = RegisterBits::new(0x8); + pub const OCIE0B0: RegisterBits = RegisterBits::new(1<<3); + + pub const TOIE0: RegisterBits = RegisterBits::new(0x2); + pub const TOIE00: RegisterBits = RegisterBits::new(1<<1); + + pub const TICIE0: RegisterBits = RegisterBits::new(0x1); + pub const TICIE00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF0A: RegisterBits = RegisterBits::new(0x10); + pub const OCF0A0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCF0B: RegisterBits = RegisterBits::new(0x8); + pub const OCF0B0: RegisterBits = RegisterBits::new(1<<3); + + pub const TOV0: RegisterBits = RegisterBits::new(0x2); + pub const TOV00: RegisterBits = RegisterBits::new(1<<1); + + pub const ICF0: RegisterBits = RegisterBits::new(0x1); + pub const ICF00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0A; + +impl TCCR0A { + pub const TCW0: RegisterBits = RegisterBits::new(0x80); + pub const TCW00: RegisterBits = RegisterBits::new(1<<7); + + pub const ICEN0: RegisterBits = RegisterBits::new(0x40); + pub const ICEN00: RegisterBits = RegisterBits::new(1<<6); + + pub const ICNC0: RegisterBits = RegisterBits::new(0x20); + pub const ICNC00: RegisterBits = RegisterBits::new(1<<5); + + pub const ICES0: RegisterBits = RegisterBits::new(0x10); + pub const ICES00: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIC0: RegisterBits = RegisterBits::new(0x8); + pub const ACIC00: RegisterBits = RegisterBits::new(1<<3); + + pub const WGM00: RegisterBits = RegisterBits::new(0x1); + pub const WGM000: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x35 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0B; + +impl TCCR0B { + pub const TSM: RegisterBits = RegisterBits::new(0x10); + pub const TSM0: RegisterBits = RegisterBits::new(1<<4); + + pub const PSR0: RegisterBits = RegisterBits::new(0x8); + pub const PSR00: RegisterBits = RegisterBits::new(1<<3); + + pub const CS0: RegisterBits = RegisterBits::new(0x7); + pub const CS00: RegisterBits = RegisterBits::new(1<<0); + pub const CS01: RegisterBits = RegisterBits::new(1<<1); + pub const CS02: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x53 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0H; + +impl TCNT0H { +} + +impl Register for TCNT0H { + type T = u8; + const ADDRESS: *mut u8 = 0x34 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0L; + +impl TCNT0L { +} + +impl Register for TCNT0L { + type T = u8; + const ADDRESS: *mut u8 = 0x52 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x33 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0B; + +impl OCR0B { +} + +impl Register for OCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x32 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1A; + +impl TCCR1A { + pub const COM1A: RegisterBits = RegisterBits::new(0xc0); + pub const COM1A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM1A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM1B: RegisterBits = RegisterBits::new(0x30); + pub const COM1B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM1B1: RegisterBits = RegisterBits::new(1<<5); + + pub const FOC1A: RegisterBits = RegisterBits::new(0x8); + pub const FOC1A0: RegisterBits = RegisterBits::new(1<<3); + + pub const FOC1B: RegisterBits = RegisterBits::new(0x4); + pub const FOC1B0: RegisterBits = RegisterBits::new(1<<2); + + pub const PWM1A: RegisterBits = RegisterBits::new(0x2); + pub const PWM1A0: RegisterBits = RegisterBits::new(1<<1); + + pub const PWM1B: RegisterBits = RegisterBits::new(0x1); + pub const PWM1B0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1B; + +impl TCCR1B { + pub const PSR1: RegisterBits = RegisterBits::new(0x40); + pub const PSR10: RegisterBits = RegisterBits::new(1<<6); + + pub const DTPS1: RegisterBits = RegisterBits::new(0x30); + pub const DTPS10: RegisterBits = RegisterBits::new(1<<4); + pub const DTPS11: RegisterBits = RegisterBits::new(1<<5); + + pub const CS1: RegisterBits = RegisterBits::new(0xf); + pub const CS10: RegisterBits = RegisterBits::new(1<<0); + pub const CS11: RegisterBits = RegisterBits::new(1<<1); + pub const CS12: RegisterBits = RegisterBits::new(1<<2); + pub const CS13: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for TCCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x4f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1C; + +impl TCCR1C { + pub const COM1A1S: RegisterBits = RegisterBits::new(0x80); + pub const COM1A1S0: RegisterBits = RegisterBits::new(1<<7); + + pub const COM1A0S: RegisterBits = RegisterBits::new(0x40); + pub const COM1A0S0: RegisterBits = RegisterBits::new(1<<6); + + pub const COM1B1S: RegisterBits = RegisterBits::new(0x20); + pub const COM1B1S0: RegisterBits = RegisterBits::new(1<<5); + + pub const COM1B0S: RegisterBits = RegisterBits::new(0x10); + pub const COM1B0S0: RegisterBits = RegisterBits::new(1<<4); + + pub const COM1D: RegisterBits = RegisterBits::new(0xc); + pub const COM1D0: RegisterBits = RegisterBits::new(1<<2); + pub const COM1D1: RegisterBits = RegisterBits::new(1<<3); + + pub const FOC1D: RegisterBits = RegisterBits::new(0x2); + pub const FOC1D0: RegisterBits = RegisterBits::new(1<<1); + + pub const PWM1D: RegisterBits = RegisterBits::new(0x1); + pub const PWM1D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x47 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1D; + +impl TCCR1D { + pub const FPIE1: RegisterBits = RegisterBits::new(0x80); + pub const FPIE10: RegisterBits = RegisterBits::new(1<<7); + + pub const FPEN1: RegisterBits = RegisterBits::new(0x40); + pub const FPEN10: RegisterBits = RegisterBits::new(1<<6); + + pub const FPNC1: RegisterBits = RegisterBits::new(0x20); + pub const FPNC10: RegisterBits = RegisterBits::new(1<<5); + + pub const FPES1: RegisterBits = RegisterBits::new(0x10); + pub const FPES10: RegisterBits = RegisterBits::new(1<<4); + + pub const FPAC1: RegisterBits = RegisterBits::new(0x8); + pub const FPAC10: RegisterBits = RegisterBits::new(1<<3); + + pub const FPF1: RegisterBits = RegisterBits::new(0x4); + pub const FPF10: RegisterBits = RegisterBits::new(1<<2); + + pub const WGM1: RegisterBits = RegisterBits::new(0x3); + pub const WGM10: RegisterBits = RegisterBits::new(1<<0); + pub const WGM11: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR1D { + type T = u8; + const ADDRESS: *mut u8 = 0x46 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1E; + +impl TCCR1E { + pub const OC1OE: RegisterBits = RegisterBits::new(0x3f); + pub const OC1OE0: RegisterBits = RegisterBits::new(1<<0); + pub const OC1OE1: RegisterBits = RegisterBits::new(1<<1); + pub const OC1OE2: RegisterBits = RegisterBits::new(1<<2); + pub const OC1OE3: RegisterBits = RegisterBits::new(1<<3); + pub const OC1OE4: RegisterBits = RegisterBits::new(1<<4); + pub const OC1OE5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for TCCR1E { + type T = u8; + const ADDRESS: *mut u8 = 0x20 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT1; + +impl TCNT1 { +} + +impl Register for TCNT1 { + type T = u8; + const ADDRESS: *mut u8 = 0x4e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TC1H; + +impl TC1H { +} + +impl Register for TC1H { + type T = u8; + const ADDRESS: *mut u8 = 0x45 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x4d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x4c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1C; + +impl OCR1C { +} + +impl Register for OCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x4b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1D; + +impl OCR1D { +} + +impl Register for OCR1D { + type T = u8; + const ADDRESS: *mut u8 = 0x4a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE1D: RegisterBits = RegisterBits::new(0x80); + pub const OCIE1D0: RegisterBits = RegisterBits::new(1<<7); + + pub const OCIE1A: RegisterBits = RegisterBits::new(0x40); + pub const OCIE1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x20); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const TOIE1: RegisterBits = RegisterBits::new(0x4); + pub const TOIE10: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF1D: RegisterBits = RegisterBits::new(0x80); + pub const OCF1D0: RegisterBits = RegisterBits::new(1<<7); + + pub const OCF1A: RegisterBits = RegisterBits::new(0x40); + pub const OCF1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x20); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const TOV1: RegisterBits = RegisterBits::new(0x4); + pub const TOV10: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DT1; + +impl DT1 { + pub const DT1H: RegisterBits = RegisterBits::new(0xf0); + pub const DT1H0: RegisterBits = RegisterBits::new(1<<4); + pub const DT1H1: RegisterBits = RegisterBits::new(1<<5); + pub const DT1H2: RegisterBits = RegisterBits::new(1<<6); + pub const DT1H3: RegisterBits = RegisterBits::new(1<<7); + + pub const DT1L: RegisterBits = RegisterBits::new(0xf); + pub const DT1L0: RegisterBits = RegisterBits::new(1<<0); + pub const DT1L1: RegisterBits = RegisterBits::new(1<<1); + pub const DT1L2: RegisterBits = RegisterBits::new(1<<2); + pub const DT1L3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for DT1 { + type T = u8; + const ADDRESS: *mut u8 = 0x44 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPMCSR; + +impl SPMCSR { + pub const CTPB: RegisterBits = RegisterBits::new(0x10); + pub const CTPB0: RegisterBits = RegisterBits::new(1<<4); + + pub const RFLB: RegisterBits = RegisterBits::new(0x8); + pub const RFLB0: RegisterBits = RegisterBits::new(1<<3); + + pub const PGWRT: RegisterBits = RegisterBits::new(0x4); + pub const PGWRT0: RegisterBits = RegisterBits::new(1<<2); + + pub const PGERS: RegisterBits = RegisterBits::new(0x2); + pub const PGERS0: RegisterBits = RegisterBits::new(1<<1); + + pub const SPMEN: RegisterBits = RegisterBits::new(0x1); + pub const SPMEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SPMCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x57 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const ISC01: RegisterBits = RegisterBits::new(0x2); + pub const ISC010: RegisterBits = RegisterBits::new(1<<1); + + pub const ISC00: RegisterBits = RegisterBits::new(0x1); + pub const ISC000: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIMSK; + +impl GIMSK { + pub const INT: RegisterBits = RegisterBits::new(0xc0); + pub const INT0: RegisterBits = RegisterBits::new(1<<6); + pub const INT1: RegisterBits = RegisterBits::new(1<<7); + + pub const PCIE: RegisterBits = RegisterBits::new(0x30); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<4); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x5b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIFR; + +impl GIFR { + pub const INTF: RegisterBits = RegisterBits::new(0xc0); + pub const INTF0: RegisterBits = RegisterBits::new(1<<6); + pub const INTF1: RegisterBits = RegisterBits::new(1<<7); + + pub const PCIF: RegisterBits = RegisterBits::new(0x20); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x5a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { +} + +impl Register for PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x42 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK0; + +impl PCMSK0 { +} + +impl Register for PCMSK0 { + type T = u8; + const ADDRESS: *mut u8 = 0x43 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SREG; + +impl SREG { + pub const I: RegisterBits = RegisterBits::new(0x80); + pub const I0: RegisterBits = RegisterBits::new(1<<7); + + pub const T: RegisterBits = RegisterBits::new(0x40); + pub const T0: RegisterBits = RegisterBits::new(1<<6); + + pub const H: RegisterBits = RegisterBits::new(0x20); + pub const H0: RegisterBits = RegisterBits::new(1<<5); + + pub const S: RegisterBits = RegisterBits::new(0x10); + pub const S0: RegisterBits = RegisterBits::new(1<<4); + + pub const V: RegisterBits = RegisterBits::new(0x8); + pub const V0: RegisterBits = RegisterBits::new(1<<3); + + pub const N: RegisterBits = RegisterBits::new(0x4); + pub const N0: RegisterBits = RegisterBits::new(1<<2); + + pub const Z: RegisterBits = RegisterBits::new(0x2); + pub const Z0: RegisterBits = RegisterBits::new(1<<1); + + pub const C: RegisterBits = RegisterBits::new(0x1); + pub const C0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SREG { + type T = u8; + const ADDRESS: *mut u8 = 0x5f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x4); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<2); + + pub const PRUSI: RegisterBits = RegisterBits::new(0x2); + pub const PRUSI0: RegisterBits = RegisterBits::new(1<<1); + + pub const PRADC: RegisterBits = RegisterBits::new(0x1); + pub const PRADC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PRR { + type T = u8; + const ADDRESS: *mut u8 = 0x56 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPL; + +impl SPL { +} + +impl Register for SPL { + type T = u8; + const ADDRESS: *mut u8 = 0x5d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const PUD: RegisterBits = RegisterBits::new(0x40); + pub const PUD0: RegisterBits = RegisterBits::new(1<<6); + + pub const SE: RegisterBits = RegisterBits::new(0x20); + pub const SE0: RegisterBits = RegisterBits::new(1<<5); + + pub const SM: RegisterBits = RegisterBits::new(0x18); + pub const SM0: RegisterBits = RegisterBits::new(1<<3); + pub const SM1: RegisterBits = RegisterBits::new(1<<4); + + pub const ISC0: RegisterBits = RegisterBits::new(0x3); + pub const ISC00: RegisterBits = RegisterBits::new(1<<0); + pub const ISC01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUSR; + +impl MCUSR { + pub const WDRF: RegisterBits = RegisterBits::new(0x8); + pub const WDRF0: RegisterBits = RegisterBits::new(1<<3); + + pub const BORF: RegisterBits = RegisterBits::new(0x4); + pub const BORF0: RegisterBits = RegisterBits::new(1<<2); + + pub const EXTRF: RegisterBits = RegisterBits::new(0x2); + pub const EXTRF0: RegisterBits = RegisterBits::new(1<<1); + + pub const PORF: RegisterBits = RegisterBits::new(0x1); + pub const PORF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUSR { + type T = u8; + const ADDRESS: *mut u8 = 0x54 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCCAL; + +impl OSCCAL { + pub const OSCCAL: RegisterBits = RegisterBits::new(0xff); + pub const OSCCAL0: RegisterBits = RegisterBits::new(1<<0); + pub const OSCCAL1: RegisterBits = RegisterBits::new(1<<1); + pub const OSCCAL2: RegisterBits = RegisterBits::new(1<<2); + pub const OSCCAL3: RegisterBits = RegisterBits::new(1<<3); + pub const OSCCAL4: RegisterBits = RegisterBits::new(1<<4); + pub const OSCCAL5: RegisterBits = RegisterBits::new(1<<5); + pub const OSCCAL6: RegisterBits = RegisterBits::new(1<<6); + pub const OSCCAL7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OSCCAL { + type T = u8; + const ADDRESS: *mut u8 = 0x51 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKPR; + +impl CLKPR { + pub const CLKPCE: RegisterBits = RegisterBits::new(0x80); + pub const CLKPCE0: RegisterBits = RegisterBits::new(1<<7); + + pub const CLKPS: RegisterBits = RegisterBits::new(0xf); + pub const CLKPS0: RegisterBits = RegisterBits::new(1<<0); + pub const CLKPS1: RegisterBits = RegisterBits::new(1<<1); + pub const CLKPS2: RegisterBits = RegisterBits::new(1<<2); + pub const CLKPS3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CLKPR { + type T = u8; + const ADDRESS: *mut u8 = 0x48 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PLLCSR; + +impl PLLCSR { + pub const LSM: RegisterBits = RegisterBits::new(0x80); + pub const LSM0: RegisterBits = RegisterBits::new(1<<7); + + pub const PCKE: RegisterBits = RegisterBits::new(0x4); + pub const PCKE0: RegisterBits = RegisterBits::new(1<<2); + + pub const PLLE: RegisterBits = RegisterBits::new(0x2); + pub const PLLE0: RegisterBits = RegisterBits::new(1<<1); + + pub const PLOCK: RegisterBits = RegisterBits::new(0x1); + pub const PLOCK0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PLLCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x49 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DWDR; + +impl DWDR { +} + +impl Register for DWDR { + type T = u8; + const ADDRESS: *mut u8 = 0x40 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR2; + +impl GPIOR2 { +} + +impl Register for GPIOR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x2c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR1; + +impl GPIOR1 { +} + +impl Register for GPIOR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x2b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR0; + +impl GPIOR0 { +} + +impl Register for GPIOR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x2a as *mut u8; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + + pub struct A0; + + impl Pin for A0 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA0 + const MASK: u8 = 1<<0; + } + + pub struct A1; + + impl Pin for A1 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA1 + const MASK: u8 = 1<<1; + } + + pub struct A2; + + impl Pin for A2 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA2 + const MASK: u8 = 1<<2; + } + + pub struct A3; + + impl Pin for A3 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA3 + const MASK: u8 = 1<<3; + } + + pub struct A4; + + impl Pin for A4 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA4 + const MASK: u8 = 1<<4; + } + + pub struct A5; + + impl Pin for A5 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA5 + const MASK: u8 = 1<<5; + } + + pub struct A6; + + impl Pin for A6 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA6 + const MASK: u8 = 1<<6; + } + + pub struct A7; + + impl Pin for A7 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA7 + const MASK: u8 = 1<<7; + } + + pub struct B0; + + impl Pin for B0 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB0 + const MASK: u8 = 1<<0; + } + + pub struct B1; + + impl Pin for B1 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB1 + const MASK: u8 = 1<<1; + } + + pub struct B2; + + impl Pin for B2 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB2 + const MASK: u8 = 1<<2; + } + + pub struct B3; + + impl Pin for B3 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB3 + const MASK: u8 = 1<<3; + } + + pub struct B4; + + impl Pin for B4 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB4 + const MASK: u8 = 1<<4; + } + + pub struct B5; + + impl Pin for B5 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB5 + const MASK: u8 = 1<<5; + } + + pub struct B6; + + impl Pin for B6 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB6 + const MASK: u8 = 1<<6; + } + + pub struct B7; + + impl Pin for B7 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB7 + const MASK: u8 = 1<<7; + } + +} + +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR0A; + type CompareB = OCR0B; + type Counter = TCNT0H; + type ControlA = TCCR0A; + type ControlB = TCCR0B; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE0A; +} +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR1A; + type CompareB = OCR1B; + type Counter = TCNT1; + type ControlA = TCCR1A; + type ControlB = TCCR1B; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE1A; +} + diff --git a/src/cores/attiny261a.rs b/src/cores/attiny261a.rs new file mode 100644 index 0000000..37acf2e --- /dev/null +++ b/src/cores/attiny261a.rs @@ -0,0 +1,1269 @@ +//! Core for ATtiny261A. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + pub const SELFPRGEN: RegisterBits = RegisterBits::new(0x1); + pub const SELFPRGEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EXTENDED { + type T = u8; + const ADDRESS: *mut u8 = 0x2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct HIGH; + +impl HIGH { + pub const RSTDISBL: RegisterBits = RegisterBits::new(0x80); + pub const RSTDISBL0: RegisterBits = RegisterBits::new(1<<7); + + pub const DWEN: RegisterBits = RegisterBits::new(0x40); + pub const DWEN0: RegisterBits = RegisterBits::new(1<<6); + + pub const SPIEN: RegisterBits = RegisterBits::new(0x20); + pub const SPIEN0: RegisterBits = RegisterBits::new(1<<5); + + pub const WDTON: RegisterBits = RegisterBits::new(0x10); + pub const WDTON0: RegisterBits = RegisterBits::new(1<<4); + + pub const EESAVE: RegisterBits = RegisterBits::new(0x8); + pub const EESAVE0: RegisterBits = RegisterBits::new(1<<3); + + pub const BODLEVEL: RegisterBits = RegisterBits::new(0x7); + pub const BODLEVEL0: RegisterBits = RegisterBits::new(1<<0); + pub const BODLEVEL1: RegisterBits = RegisterBits::new(1<<1); + pub const BODLEVEL2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for HIGH { + type T = u8; + const ADDRESS: *mut u8 = 0x1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOW; + +impl LOW { + pub const CKDIV8: RegisterBits = RegisterBits::new(0x80); + pub const CKDIV80: RegisterBits = RegisterBits::new(1<<7); + + pub const CKOUT: RegisterBits = RegisterBits::new(0x40); + pub const CKOUT0: RegisterBits = RegisterBits::new(1<<6); + + pub const SUT_CKSEL: RegisterBits = RegisterBits::new(0x3f); + pub const SUT_CKSEL0: RegisterBits = RegisterBits::new(1<<0); + pub const SUT_CKSEL1: RegisterBits = RegisterBits::new(1<<1); + pub const SUT_CKSEL2: RegisterBits = RegisterBits::new(1<<2); + pub const SUT_CKSEL3: RegisterBits = RegisterBits::new(1<<3); + pub const SUT_CKSEL4: RegisterBits = RegisterBits::new(1<<4); + pub const SUT_CKSEL5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for LOW { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOCKBIT; + +impl LOCKBIT { + pub const LB: RegisterBits = RegisterBits::new(0x3); + pub const LB0: RegisterBits = RegisterBits::new(1<<0); + pub const LB1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for LOCKBIT { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTA; + +impl PORTA { +} + +impl Register for PORTA { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRA; + +impl DDRA { +} + +impl Register for DDRA { + type T = u8; + const ADDRESS: *mut u8 = 0x3a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINA; + +impl PINA { +} + +impl Register for PINA { + type T = u8; + const ADDRESS: *mut u8 = 0x39 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x38 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x36 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADMUX; + +impl ADMUX { + pub const REFS: RegisterBits = RegisterBits::new(0xc0); + pub const REFS0: RegisterBits = RegisterBits::new(1<<6); + pub const REFS1: RegisterBits = RegisterBits::new(1<<7); + + pub const ADLAR: RegisterBits = RegisterBits::new(0x20); + pub const ADLAR0: RegisterBits = RegisterBits::new(1<<5); + + pub const MUX: RegisterBits = RegisterBits::new(0x1f); + pub const MUX0: RegisterBits = RegisterBits::new(1<<0); + pub const MUX1: RegisterBits = RegisterBits::new(1<<1); + pub const MUX2: RegisterBits = RegisterBits::new(1<<2); + pub const MUX3: RegisterBits = RegisterBits::new(1<<3); + pub const MUX4: RegisterBits = RegisterBits::new(1<<4); + +} + +impl Register for ADMUX { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADCSRA; + +impl ADCSRA { + pub const ADEN: RegisterBits = RegisterBits::new(0x80); + pub const ADEN0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADSC: RegisterBits = RegisterBits::new(0x40); + pub const ADSC0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADATE: RegisterBits = RegisterBits::new(0x20); + pub const ADATE0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADIF: RegisterBits = RegisterBits::new(0x10); + pub const ADIF0: RegisterBits = RegisterBits::new(1<<4); + + pub const ADIE: RegisterBits = RegisterBits::new(0x8); + pub const ADIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADPS: RegisterBits = RegisterBits::new(0x7); + pub const ADPS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADPS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADPS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x26 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x24 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ADCSRB; + +impl ADCSRB { + pub const BIN: RegisterBits = RegisterBits::new(0x80); + pub const BIN0: RegisterBits = RegisterBits::new(1<<7); + + pub const GSEL: RegisterBits = RegisterBits::new(0x40); + pub const GSEL0: RegisterBits = RegisterBits::new(1<<6); + + pub const IPR: RegisterBits = RegisterBits::new(0x20); + pub const IPR0: RegisterBits = RegisterBits::new(1<<5); + + pub const REFS2: RegisterBits = RegisterBits::new(0x10); + pub const REFS20: RegisterBits = RegisterBits::new(1<<4); + + pub const MUX5: RegisterBits = RegisterBits::new(0x8); + pub const MUX50: RegisterBits = RegisterBits::new(1<<3); + + pub const ADTS: RegisterBits = RegisterBits::new(0x7); + pub const ADTS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADTS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADTS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x23 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + pub const ADC10D: RegisterBits = RegisterBits::new(0x80); + pub const ADC10D0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADC9D: RegisterBits = RegisterBits::new(0x40); + pub const ADC9D0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADC8D: RegisterBits = RegisterBits::new(0x20); + pub const ADC8D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC7D: RegisterBits = RegisterBits::new(0x10); + pub const ADC7D0: RegisterBits = RegisterBits::new(1<<4); + +} + +impl Register for DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x22 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + pub const ADC6D: RegisterBits = RegisterBits::new(0x80); + pub const ADC6D0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADC5D: RegisterBits = RegisterBits::new(0x40); + pub const ADC5D0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADC4D: RegisterBits = RegisterBits::new(0x20); + pub const ADC4D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC3D: RegisterBits = RegisterBits::new(0x10); + pub const ADC3D0: RegisterBits = RegisterBits::new(1<<4); + + pub const AREFD: RegisterBits = RegisterBits::new(0x8); + pub const AREFD0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADC2D: RegisterBits = RegisterBits::new(0x4); + pub const ADC2D0: RegisterBits = RegisterBits::new(1<<2); + + pub const ADC1D: RegisterBits = RegisterBits::new(0x2); + pub const ADC1D0: RegisterBits = RegisterBits::new(1<<1); + + pub const ADC0D: RegisterBits = RegisterBits::new(0x1); + pub const ADC0D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for DIDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x21 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSRB; + +impl ACSRB { + pub const HSEL: RegisterBits = RegisterBits::new(0x80); + pub const HSEL0: RegisterBits = RegisterBits::new(1<<7); + + pub const HLEV: RegisterBits = RegisterBits::new(0x40); + pub const HLEV0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACM: RegisterBits = RegisterBits::new(0x7); + pub const ACM0: RegisterBits = RegisterBits::new(1<<0); + pub const ACM1: RegisterBits = RegisterBits::new(1<<1); + pub const ACM2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ACSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x29 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSRA; + +impl ACSRA { + pub const ACD: RegisterBits = RegisterBits::new(0x80); + pub const ACD0: RegisterBits = RegisterBits::new(1<<7); + + pub const ACBG: RegisterBits = RegisterBits::new(0x40); + pub const ACBG0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACO: RegisterBits = RegisterBits::new(0x20); + pub const ACO0: RegisterBits = RegisterBits::new(1<<5); + + pub const ACI: RegisterBits = RegisterBits::new(0x10); + pub const ACI0: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIE: RegisterBits = RegisterBits::new(0x8); + pub const ACIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ACME: RegisterBits = RegisterBits::new(0x4); + pub const ACME0: RegisterBits = RegisterBits::new(1<<2); + + pub const ACIS: RegisterBits = RegisterBits::new(0x3); + pub const ACIS0: RegisterBits = RegisterBits::new(1<<0); + pub const ACIS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for ACSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x28 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIPP; + +impl USIPP { +} + +impl Register for USIPP { + type T = u8; + const ADDRESS: *mut u8 = 0x31 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIBR; + +impl USIBR { +} + +impl Register for USIBR { + type T = u8; + const ADDRESS: *mut u8 = 0x30 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIDR; + +impl USIDR { +} + +impl Register for USIDR { + type T = u8; + const ADDRESS: *mut u8 = 0x2f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USISR; + +impl USISR { + pub const USISIF: RegisterBits = RegisterBits::new(0x80); + pub const USISIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIF: RegisterBits = RegisterBits::new(0x40); + pub const USIOIF0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIPF: RegisterBits = RegisterBits::new(0x20); + pub const USIPF0: RegisterBits = RegisterBits::new(1<<5); + + pub const USIDC: RegisterBits = RegisterBits::new(0x10); + pub const USIDC0: RegisterBits = RegisterBits::new(1<<4); + + pub const USICNT: RegisterBits = RegisterBits::new(0xf); + pub const USICNT0: RegisterBits = RegisterBits::new(1<<0); + pub const USICNT1: RegisterBits = RegisterBits::new(1<<1); + pub const USICNT2: RegisterBits = RegisterBits::new(1<<2); + pub const USICNT3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for USISR { + type T = u8; + const ADDRESS: *mut u8 = 0x2e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USICR; + +impl USICR { + pub const USISIE: RegisterBits = RegisterBits::new(0x80); + pub const USISIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIE: RegisterBits = RegisterBits::new(0x40); + pub const USIOIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIWM: RegisterBits = RegisterBits::new(0x30); + pub const USIWM0: RegisterBits = RegisterBits::new(1<<4); + pub const USIWM1: RegisterBits = RegisterBits::new(1<<5); + + pub const USICS: RegisterBits = RegisterBits::new(0xc); + pub const USICS0: RegisterBits = RegisterBits::new(1<<2); + pub const USICS1: RegisterBits = RegisterBits::new(1<<3); + + pub const USICLK: RegisterBits = RegisterBits::new(0x2); + pub const USICLK0: RegisterBits = RegisterBits::new(1<<1); + + pub const USITC: RegisterBits = RegisterBits::new(0x1); + pub const USITC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for USICR { + type T = u8; + const ADDRESS: *mut u8 = 0x2d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEAR; + +impl EEAR { +} + +impl Register for EEAR { + type T = u16; + const ADDRESS: *mut u16 = 0x3e as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct EEDR; + +impl EEDR { +} + +impl Register for EEDR { + type T = u8; + const ADDRESS: *mut u8 = 0x3d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EECR; + +impl EECR { + pub const EEPM: RegisterBits = RegisterBits::new(0x30); + pub const EEPM0: RegisterBits = RegisterBits::new(1<<4); + pub const EEPM1: RegisterBits = RegisterBits::new(1<<5); + + pub const EERIE: RegisterBits = RegisterBits::new(0x8); + pub const EERIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const EEMPE: RegisterBits = RegisterBits::new(0x4); + pub const EEMPE0: RegisterBits = RegisterBits::new(1<<2); + + pub const EEPE: RegisterBits = RegisterBits::new(0x2); + pub const EEPE0: RegisterBits = RegisterBits::new(1<<1); + + pub const EERE: RegisterBits = RegisterBits::new(0x1); + pub const EERE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EECR { + type T = u8; + const ADDRESS: *mut u8 = 0x3c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct WDTCR; + +impl WDTCR { + pub const WDIF: RegisterBits = RegisterBits::new(0x80); + pub const WDIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WDIE: RegisterBits = RegisterBits::new(0x40); + pub const WDIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const WDP: RegisterBits = RegisterBits::new(0x27); + pub const WDP0: RegisterBits = RegisterBits::new(1<<0); + pub const WDP1: RegisterBits = RegisterBits::new(1<<1); + pub const WDP2: RegisterBits = RegisterBits::new(1<<2); + pub const WDP3: RegisterBits = RegisterBits::new(1<<5); + + pub const WDCE: RegisterBits = RegisterBits::new(0x10); + pub const WDCE0: RegisterBits = RegisterBits::new(1<<4); + + pub const WDE: RegisterBits = RegisterBits::new(0x8); + pub const WDE0: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for WDTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x41 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE0A: RegisterBits = RegisterBits::new(0x10); + pub const OCIE0A0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCIE0B: RegisterBits = RegisterBits::new(0x8); + pub const OCIE0B0: RegisterBits = RegisterBits::new(1<<3); + + pub const TOIE0: RegisterBits = RegisterBits::new(0x2); + pub const TOIE00: RegisterBits = RegisterBits::new(1<<1); + + pub const TICIE0: RegisterBits = RegisterBits::new(0x1); + pub const TICIE00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF0A: RegisterBits = RegisterBits::new(0x10); + pub const OCF0A0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCF0B: RegisterBits = RegisterBits::new(0x8); + pub const OCF0B0: RegisterBits = RegisterBits::new(1<<3); + + pub const TOV0: RegisterBits = RegisterBits::new(0x2); + pub const TOV00: RegisterBits = RegisterBits::new(1<<1); + + pub const ICF0: RegisterBits = RegisterBits::new(0x1); + pub const ICF00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0A; + +impl TCCR0A { + pub const TCW0: RegisterBits = RegisterBits::new(0x80); + pub const TCW00: RegisterBits = RegisterBits::new(1<<7); + + pub const ICEN0: RegisterBits = RegisterBits::new(0x40); + pub const ICEN00: RegisterBits = RegisterBits::new(1<<6); + + pub const ICNC0: RegisterBits = RegisterBits::new(0x20); + pub const ICNC00: RegisterBits = RegisterBits::new(1<<5); + + pub const ICES0: RegisterBits = RegisterBits::new(0x10); + pub const ICES00: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIC0: RegisterBits = RegisterBits::new(0x8); + pub const ACIC00: RegisterBits = RegisterBits::new(1<<3); + + pub const WGM00: RegisterBits = RegisterBits::new(0x1); + pub const WGM000: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x35 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0B; + +impl TCCR0B { + pub const TSM: RegisterBits = RegisterBits::new(0x10); + pub const TSM0: RegisterBits = RegisterBits::new(1<<4); + + pub const PSR0: RegisterBits = RegisterBits::new(0x8); + pub const PSR00: RegisterBits = RegisterBits::new(1<<3); + + pub const CS0: RegisterBits = RegisterBits::new(0x7); + pub const CS00: RegisterBits = RegisterBits::new(1<<0); + pub const CS01: RegisterBits = RegisterBits::new(1<<1); + pub const CS02: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x53 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0H; + +impl TCNT0H { +} + +impl Register for TCNT0H { + type T = u8; + const ADDRESS: *mut u8 = 0x34 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0L; + +impl TCNT0L { +} + +impl Register for TCNT0L { + type T = u8; + const ADDRESS: *mut u8 = 0x52 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x33 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0B; + +impl OCR0B { +} + +impl Register for OCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x32 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1A; + +impl TCCR1A { + pub const COM1A: RegisterBits = RegisterBits::new(0xc0); + pub const COM1A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM1A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM1B: RegisterBits = RegisterBits::new(0x30); + pub const COM1B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM1B1: RegisterBits = RegisterBits::new(1<<5); + + pub const FOC1A: RegisterBits = RegisterBits::new(0x8); + pub const FOC1A0: RegisterBits = RegisterBits::new(1<<3); + + pub const FOC1B: RegisterBits = RegisterBits::new(0x4); + pub const FOC1B0: RegisterBits = RegisterBits::new(1<<2); + + pub const PWM1A: RegisterBits = RegisterBits::new(0x2); + pub const PWM1A0: RegisterBits = RegisterBits::new(1<<1); + + pub const PWM1B: RegisterBits = RegisterBits::new(0x1); + pub const PWM1B0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1B; + +impl TCCR1B { + pub const PWM1X: RegisterBits = RegisterBits::new(0x80); + pub const PWM1X0: RegisterBits = RegisterBits::new(1<<7); + + pub const PSR1: RegisterBits = RegisterBits::new(0x40); + pub const PSR10: RegisterBits = RegisterBits::new(1<<6); + + pub const DTPS1: RegisterBits = RegisterBits::new(0x30); + pub const DTPS10: RegisterBits = RegisterBits::new(1<<4); + pub const DTPS11: RegisterBits = RegisterBits::new(1<<5); + + pub const CS1: RegisterBits = RegisterBits::new(0xf); + pub const CS10: RegisterBits = RegisterBits::new(1<<0); + pub const CS11: RegisterBits = RegisterBits::new(1<<1); + pub const CS12: RegisterBits = RegisterBits::new(1<<2); + pub const CS13: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for TCCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x4f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1C; + +impl TCCR1C { + pub const COM1A1S: RegisterBits = RegisterBits::new(0x80); + pub const COM1A1S0: RegisterBits = RegisterBits::new(1<<7); + + pub const COM1A0S: RegisterBits = RegisterBits::new(0x40); + pub const COM1A0S0: RegisterBits = RegisterBits::new(1<<6); + + pub const COM1B1S: RegisterBits = RegisterBits::new(0x20); + pub const COM1B1S0: RegisterBits = RegisterBits::new(1<<5); + + pub const COM1B0S: RegisterBits = RegisterBits::new(0x10); + pub const COM1B0S0: RegisterBits = RegisterBits::new(1<<4); + + pub const COM1D: RegisterBits = RegisterBits::new(0xc); + pub const COM1D0: RegisterBits = RegisterBits::new(1<<2); + pub const COM1D1: RegisterBits = RegisterBits::new(1<<3); + + pub const FOC1D: RegisterBits = RegisterBits::new(0x2); + pub const FOC1D0: RegisterBits = RegisterBits::new(1<<1); + + pub const PWM1D: RegisterBits = RegisterBits::new(0x1); + pub const PWM1D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x47 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1D; + +impl TCCR1D { + pub const FPIE1: RegisterBits = RegisterBits::new(0x80); + pub const FPIE10: RegisterBits = RegisterBits::new(1<<7); + + pub const FPEN1: RegisterBits = RegisterBits::new(0x40); + pub const FPEN10: RegisterBits = RegisterBits::new(1<<6); + + pub const FPNC1: RegisterBits = RegisterBits::new(0x20); + pub const FPNC10: RegisterBits = RegisterBits::new(1<<5); + + pub const FPES1: RegisterBits = RegisterBits::new(0x10); + pub const FPES10: RegisterBits = RegisterBits::new(1<<4); + + pub const FPAC1: RegisterBits = RegisterBits::new(0x8); + pub const FPAC10: RegisterBits = RegisterBits::new(1<<3); + + pub const FPF1: RegisterBits = RegisterBits::new(0x4); + pub const FPF10: RegisterBits = RegisterBits::new(1<<2); + + pub const WGM1: RegisterBits = RegisterBits::new(0x3); + pub const WGM10: RegisterBits = RegisterBits::new(1<<0); + pub const WGM11: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR1D { + type T = u8; + const ADDRESS: *mut u8 = 0x46 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1E; + +impl TCCR1E { + pub const OC1OE: RegisterBits = RegisterBits::new(0x3f); + pub const OC1OE0: RegisterBits = RegisterBits::new(1<<0); + pub const OC1OE1: RegisterBits = RegisterBits::new(1<<1); + pub const OC1OE2: RegisterBits = RegisterBits::new(1<<2); + pub const OC1OE3: RegisterBits = RegisterBits::new(1<<3); + pub const OC1OE4: RegisterBits = RegisterBits::new(1<<4); + pub const OC1OE5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for TCCR1E { + type T = u8; + const ADDRESS: *mut u8 = 0x20 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT1; + +impl TCNT1 { +} + +impl Register for TCNT1 { + type T = u8; + const ADDRESS: *mut u8 = 0x4e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TC1H; + +impl TC1H { +} + +impl Register for TC1H { + type T = u8; + const ADDRESS: *mut u8 = 0x45 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x4d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x4c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1C; + +impl OCR1C { +} + +impl Register for OCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x4b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1D; + +impl OCR1D { +} + +impl Register for OCR1D { + type T = u8; + const ADDRESS: *mut u8 = 0x4a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE1D: RegisterBits = RegisterBits::new(0x80); + pub const OCIE1D0: RegisterBits = RegisterBits::new(1<<7); + + pub const OCIE1A: RegisterBits = RegisterBits::new(0x40); + pub const OCIE1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x20); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const TOIE1: RegisterBits = RegisterBits::new(0x4); + pub const TOIE10: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF1D: RegisterBits = RegisterBits::new(0x80); + pub const OCF1D0: RegisterBits = RegisterBits::new(1<<7); + + pub const OCF1A: RegisterBits = RegisterBits::new(0x40); + pub const OCF1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x20); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const TOV1: RegisterBits = RegisterBits::new(0x4); + pub const TOV10: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DT1; + +impl DT1 { + pub const DT1H: RegisterBits = RegisterBits::new(0xf0); + pub const DT1H0: RegisterBits = RegisterBits::new(1<<4); + pub const DT1H1: RegisterBits = RegisterBits::new(1<<5); + pub const DT1H2: RegisterBits = RegisterBits::new(1<<6); + pub const DT1H3: RegisterBits = RegisterBits::new(1<<7); + + pub const DT1L: RegisterBits = RegisterBits::new(0xf); + pub const DT1L0: RegisterBits = RegisterBits::new(1<<0); + pub const DT1L1: RegisterBits = RegisterBits::new(1<<1); + pub const DT1L2: RegisterBits = RegisterBits::new(1<<2); + pub const DT1L3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for DT1 { + type T = u8; + const ADDRESS: *mut u8 = 0x44 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPMCSR; + +impl SPMCSR { + pub const CTPB: RegisterBits = RegisterBits::new(0x10); + pub const CTPB0: RegisterBits = RegisterBits::new(1<<4); + + pub const RFLB: RegisterBits = RegisterBits::new(0x8); + pub const RFLB0: RegisterBits = RegisterBits::new(1<<3); + + pub const PGWRT: RegisterBits = RegisterBits::new(0x4); + pub const PGWRT0: RegisterBits = RegisterBits::new(1<<2); + + pub const PGERS: RegisterBits = RegisterBits::new(0x2); + pub const PGERS0: RegisterBits = RegisterBits::new(1<<1); + + pub const SPMEN: RegisterBits = RegisterBits::new(0x1); + pub const SPMEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SPMCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x57 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const ISC01: RegisterBits = RegisterBits::new(0x2); + pub const ISC010: RegisterBits = RegisterBits::new(1<<1); + + pub const ISC00: RegisterBits = RegisterBits::new(0x1); + pub const ISC000: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIMSK; + +impl GIMSK { + pub const INT: RegisterBits = RegisterBits::new(0xc0); + pub const INT0: RegisterBits = RegisterBits::new(1<<6); + pub const INT1: RegisterBits = RegisterBits::new(1<<7); + + pub const PCIE: RegisterBits = RegisterBits::new(0x30); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<4); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x5b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIFR; + +impl GIFR { + pub const INTF: RegisterBits = RegisterBits::new(0xc0); + pub const INTF0: RegisterBits = RegisterBits::new(1<<6); + pub const INTF1: RegisterBits = RegisterBits::new(1<<7); + + pub const PCIF: RegisterBits = RegisterBits::new(0x20); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x5a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { +} + +impl Register for PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x42 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK0; + +impl PCMSK0 { +} + +impl Register for PCMSK0 { + type T = u8; + const ADDRESS: *mut u8 = 0x43 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SREG; + +impl SREG { + pub const I: RegisterBits = RegisterBits::new(0x80); + pub const I0: RegisterBits = RegisterBits::new(1<<7); + + pub const T: RegisterBits = RegisterBits::new(0x40); + pub const T0: RegisterBits = RegisterBits::new(1<<6); + + pub const H: RegisterBits = RegisterBits::new(0x20); + pub const H0: RegisterBits = RegisterBits::new(1<<5); + + pub const S: RegisterBits = RegisterBits::new(0x10); + pub const S0: RegisterBits = RegisterBits::new(1<<4); + + pub const V: RegisterBits = RegisterBits::new(0x8); + pub const V0: RegisterBits = RegisterBits::new(1<<3); + + pub const N: RegisterBits = RegisterBits::new(0x4); + pub const N0: RegisterBits = RegisterBits::new(1<<2); + + pub const Z: RegisterBits = RegisterBits::new(0x2); + pub const Z0: RegisterBits = RegisterBits::new(1<<1); + + pub const C: RegisterBits = RegisterBits::new(0x1); + pub const C0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SREG { + type T = u8; + const ADDRESS: *mut u8 = 0x5f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x4); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<2); + + pub const PRUSI: RegisterBits = RegisterBits::new(0x2); + pub const PRUSI0: RegisterBits = RegisterBits::new(1<<1); + + pub const PRADC: RegisterBits = RegisterBits::new(0x1); + pub const PRADC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PRR { + type T = u8; + const ADDRESS: *mut u8 = 0x56 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPL; + +impl SPL { +} + +impl Register for SPL { + type T = u8; + const ADDRESS: *mut u8 = 0x5d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const BODS: RegisterBits = RegisterBits::new(0x80); + pub const BODS0: RegisterBits = RegisterBits::new(1<<7); + + pub const PUD: RegisterBits = RegisterBits::new(0x40); + pub const PUD0: RegisterBits = RegisterBits::new(1<<6); + + pub const SE: RegisterBits = RegisterBits::new(0x20); + pub const SE0: RegisterBits = RegisterBits::new(1<<5); + + pub const SM: RegisterBits = RegisterBits::new(0x18); + pub const SM0: RegisterBits = RegisterBits::new(1<<3); + pub const SM1: RegisterBits = RegisterBits::new(1<<4); + + pub const BODSE: RegisterBits = RegisterBits::new(0x4); + pub const BODSE0: RegisterBits = RegisterBits::new(1<<2); + + pub const ISC0: RegisterBits = RegisterBits::new(0x3); + pub const ISC00: RegisterBits = RegisterBits::new(1<<0); + pub const ISC01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUSR; + +impl MCUSR { + pub const WDRF: RegisterBits = RegisterBits::new(0x8); + pub const WDRF0: RegisterBits = RegisterBits::new(1<<3); + + pub const BORF: RegisterBits = RegisterBits::new(0x4); + pub const BORF0: RegisterBits = RegisterBits::new(1<<2); + + pub const EXTRF: RegisterBits = RegisterBits::new(0x2); + pub const EXTRF0: RegisterBits = RegisterBits::new(1<<1); + + pub const PORF: RegisterBits = RegisterBits::new(0x1); + pub const PORF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUSR { + type T = u8; + const ADDRESS: *mut u8 = 0x54 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCCAL; + +impl OSCCAL { + pub const OSCCAL: RegisterBits = RegisterBits::new(0xff); + pub const OSCCAL0: RegisterBits = RegisterBits::new(1<<0); + pub const OSCCAL1: RegisterBits = RegisterBits::new(1<<1); + pub const OSCCAL2: RegisterBits = RegisterBits::new(1<<2); + pub const OSCCAL3: RegisterBits = RegisterBits::new(1<<3); + pub const OSCCAL4: RegisterBits = RegisterBits::new(1<<4); + pub const OSCCAL5: RegisterBits = RegisterBits::new(1<<5); + pub const OSCCAL6: RegisterBits = RegisterBits::new(1<<6); + pub const OSCCAL7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OSCCAL { + type T = u8; + const ADDRESS: *mut u8 = 0x51 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKPR; + +impl CLKPR { + pub const CLKPCE: RegisterBits = RegisterBits::new(0x80); + pub const CLKPCE0: RegisterBits = RegisterBits::new(1<<7); + + pub const CLKPS: RegisterBits = RegisterBits::new(0xf); + pub const CLKPS0: RegisterBits = RegisterBits::new(1<<0); + pub const CLKPS1: RegisterBits = RegisterBits::new(1<<1); + pub const CLKPS2: RegisterBits = RegisterBits::new(1<<2); + pub const CLKPS3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CLKPR { + type T = u8; + const ADDRESS: *mut u8 = 0x48 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PLLCSR; + +impl PLLCSR { + pub const LSM: RegisterBits = RegisterBits::new(0x80); + pub const LSM0: RegisterBits = RegisterBits::new(1<<7); + + pub const PCKE: RegisterBits = RegisterBits::new(0x4); + pub const PCKE0: RegisterBits = RegisterBits::new(1<<2); + + pub const PLLE: RegisterBits = RegisterBits::new(0x2); + pub const PLLE0: RegisterBits = RegisterBits::new(1<<1); + + pub const PLOCK: RegisterBits = RegisterBits::new(0x1); + pub const PLOCK0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PLLCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x49 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DWDR; + +impl DWDR { +} + +impl Register for DWDR { + type T = u8; + const ADDRESS: *mut u8 = 0x40 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR2; + +impl GPIOR2 { +} + +impl Register for GPIOR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x2c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR1; + +impl GPIOR1 { +} + +impl Register for GPIOR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x2b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR0; + +impl GPIOR0 { +} + +impl Register for GPIOR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x2a as *mut u8; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + +} + +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR0A; + type CompareB = OCR0B; + type Counter = TCNT0H; + type ControlA = TCCR0A; + type ControlB = TCCR0B; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE0A; +} +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR1A; + type CompareB = OCR1B; + type Counter = TCNT1; + type ControlA = TCCR1A; + type ControlB = TCCR1B; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE1A; +} + diff --git a/src/cores/attiny40.rs b/src/cores/attiny40.rs new file mode 100644 index 0000000..baea887 --- /dev/null +++ b/src/cores/attiny40.rs @@ -0,0 +1,1461 @@ +//! Core for ATtiny40. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct BYTE0; + +impl BYTE0 { + pub const BODLEVEL: RegisterBits = RegisterBits::new(0x70); + pub const BODLEVEL0: RegisterBits = RegisterBits::new(1<<4); + pub const BODLEVEL1: RegisterBits = RegisterBits::new(1<<5); + pub const BODLEVEL2: RegisterBits = RegisterBits::new(1<<6); + + pub const CKOUT: RegisterBits = RegisterBits::new(0x4); + pub const CKOUT0: RegisterBits = RegisterBits::new(1<<2); + + pub const WDTON: RegisterBits = RegisterBits::new(0x2); + pub const WDTON0: RegisterBits = RegisterBits::new(1<<1); + + pub const RSTDISBL: RegisterBits = RegisterBits::new(0x1); + pub const RSTDISBL0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for BYTE0 { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOCKBIT; + +impl LOCKBIT { + pub const LB: RegisterBits = RegisterBits::new(0x3); + pub const LB0: RegisterBits = RegisterBits::new(1<<0); + pub const LB1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for LOCKBIT { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct WDTCSR; + +impl WDTCSR { + pub const WDIF: RegisterBits = RegisterBits::new(0x80); + pub const WDIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WDIE: RegisterBits = RegisterBits::new(0x40); + pub const WDIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const WDP: RegisterBits = RegisterBits::new(0x27); + pub const WDP0: RegisterBits = RegisterBits::new(1<<0); + pub const WDP1: RegisterBits = RegisterBits::new(1<<1); + pub const WDP2: RegisterBits = RegisterBits::new(1<<2); + pub const WDP3: RegisterBits = RegisterBits::new(1<<5); + + pub const WDE: RegisterBits = RegisterBits::new(0x8); + pub const WDE0: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for WDTCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x31 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADMUX; + +impl ADMUX { + pub const REFS: RegisterBits = RegisterBits::new(0x40); + pub const REFS0: RegisterBits = RegisterBits::new(1<<6); + + pub const MUX: RegisterBits = RegisterBits::new(0xf); + pub const MUX0: RegisterBits = RegisterBits::new(1<<0); + pub const MUX1: RegisterBits = RegisterBits::new(1<<1); + pub const MUX2: RegisterBits = RegisterBits::new(1<<2); + pub const MUX3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for ADMUX { + type T = u8; + const ADDRESS: *mut u8 = 0x10 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADCSRA; + +impl ADCSRA { + pub const ADEN: RegisterBits = RegisterBits::new(0x80); + pub const ADEN0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADSC: RegisterBits = RegisterBits::new(0x40); + pub const ADSC0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADATE: RegisterBits = RegisterBits::new(0x20); + pub const ADATE0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADIF: RegisterBits = RegisterBits::new(0x10); + pub const ADIF0: RegisterBits = RegisterBits::new(1<<4); + + pub const ADIE: RegisterBits = RegisterBits::new(0x8); + pub const ADIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADPS: RegisterBits = RegisterBits::new(0x7); + pub const ADPS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADPS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADPS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x12 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0xe as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ADCSRB; + +impl ADCSRB { + pub const ADLAR: RegisterBits = RegisterBits::new(0x8); + pub const ADLAR0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADTS: RegisterBits = RegisterBits::new(0x7); + pub const ADTS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADTS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADTS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x11 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + pub const ADC7D: RegisterBits = RegisterBits::new(0x80); + pub const ADC7D0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADC6D: RegisterBits = RegisterBits::new(0x40); + pub const ADC6D0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADC5D: RegisterBits = RegisterBits::new(0x20); + pub const ADC5D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC4D: RegisterBits = RegisterBits::new(0x10); + pub const ADC4D0: RegisterBits = RegisterBits::new(1<<4); + + pub const ADC3D: RegisterBits = RegisterBits::new(0x8); + pub const ADC3D0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADC2D: RegisterBits = RegisterBits::new(0x4); + pub const ADC2D0: RegisterBits = RegisterBits::new(1<<2); + + pub const ADC1D: RegisterBits = RegisterBits::new(0x2); + pub const ADC1D0: RegisterBits = RegisterBits::new(1<<1); + + pub const ADC0D: RegisterBits = RegisterBits::new(0x1); + pub const ADC0D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for DIDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0xd as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSRB; + +impl ACSRB { + pub const HSEL: RegisterBits = RegisterBits::new(0x80); + pub const HSEL0: RegisterBits = RegisterBits::new(1<<7); + + pub const HLEV: RegisterBits = RegisterBits::new(0x40); + pub const HLEV0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACME: RegisterBits = RegisterBits::new(0x4); + pub const ACME0: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ACSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x13 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSRA; + +impl ACSRA { + pub const ACD: RegisterBits = RegisterBits::new(0x80); + pub const ACD0: RegisterBits = RegisterBits::new(1<<7); + + pub const ACBG: RegisterBits = RegisterBits::new(0x40); + pub const ACBG0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACO: RegisterBits = RegisterBits::new(0x20); + pub const ACO0: RegisterBits = RegisterBits::new(1<<5); + + pub const ACI: RegisterBits = RegisterBits::new(0x10); + pub const ACI0: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIE: RegisterBits = RegisterBits::new(0x8); + pub const ACIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ACIC: RegisterBits = RegisterBits::new(0x4); + pub const ACIC0: RegisterBits = RegisterBits::new(1<<2); + + pub const ACIS: RegisterBits = RegisterBits::new(0x3); + pub const ACIS0: RegisterBits = RegisterBits::new(1<<0); + pub const ACIS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for ACSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x14 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSCRA; + +impl TWSCRA { + pub const TWSHE: RegisterBits = RegisterBits::new(0x80); + pub const TWSHE0: RegisterBits = RegisterBits::new(1<<7); + + pub const TWDIE: RegisterBits = RegisterBits::new(0x20); + pub const TWDIE0: RegisterBits = RegisterBits::new(1<<5); + + pub const TWASIE: RegisterBits = RegisterBits::new(0x10); + pub const TWASIE0: RegisterBits = RegisterBits::new(1<<4); + + pub const TWEN: RegisterBits = RegisterBits::new(0x8); + pub const TWEN0: RegisterBits = RegisterBits::new(1<<3); + + pub const TWSIE: RegisterBits = RegisterBits::new(0x4); + pub const TWSIE0: RegisterBits = RegisterBits::new(1<<2); + + pub const TWPME: RegisterBits = RegisterBits::new(0x2); + pub const TWPME0: RegisterBits = RegisterBits::new(1<<1); + + pub const TWSME: RegisterBits = RegisterBits::new(0x1); + pub const TWSME0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TWSCRA { + type T = u8; + const ADDRESS: *mut u8 = 0x2d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSCRB; + +impl TWSCRB { + pub const TWAA: RegisterBits = RegisterBits::new(0x4); + pub const TWAA0: RegisterBits = RegisterBits::new(1<<2); + + pub const TWCMD: RegisterBits = RegisterBits::new(0x3); + pub const TWCMD0: RegisterBits = RegisterBits::new(1<<0); + pub const TWCMD1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TWSCRB { + type T = u8; + const ADDRESS: *mut u8 = 0x2c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSSRA; + +impl TWSSRA { +} + +impl Register for TWSSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x2b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSA; + +impl TWSA { + pub const TWSA: RegisterBits = RegisterBits::new(0xff); + pub const TWSA0: RegisterBits = RegisterBits::new(1<<0); + pub const TWSA1: RegisterBits = RegisterBits::new(1<<1); + pub const TWSA2: RegisterBits = RegisterBits::new(1<<2); + pub const TWSA3: RegisterBits = RegisterBits::new(1<<3); + pub const TWSA4: RegisterBits = RegisterBits::new(1<<4); + pub const TWSA5: RegisterBits = RegisterBits::new(1<<5); + pub const TWSA6: RegisterBits = RegisterBits::new(1<<6); + pub const TWSA7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for TWSA { + type T = u8; + const ADDRESS: *mut u8 = 0x2a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSD; + +impl TWSD { + pub const TWSD: RegisterBits = RegisterBits::new(0xff); + pub const TWSD0: RegisterBits = RegisterBits::new(1<<0); + pub const TWSD1: RegisterBits = RegisterBits::new(1<<1); + pub const TWSD2: RegisterBits = RegisterBits::new(1<<2); + pub const TWSD3: RegisterBits = RegisterBits::new(1<<3); + pub const TWSD4: RegisterBits = RegisterBits::new(1<<4); + pub const TWSD5: RegisterBits = RegisterBits::new(1<<5); + pub const TWSD6: RegisterBits = RegisterBits::new(1<<6); + pub const TWSD7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for TWSD { + type T = u8; + const ADDRESS: *mut u8 = 0x28 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TWSAM; + +impl TWSAM { +} + +impl Register for TWSAM { + type T = u8; + const ADDRESS: *mut u8 = 0x29 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CCP; + +impl CCP { +} + +impl Register for CCP { + type T = u8; + const ADDRESS: *mut u8 = 0x3c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SP; + +impl SP { +} + +impl Register for SP { + type T = u16; + const ADDRESS: *mut u16 = 0x3d as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct SREG; + +impl SREG { + pub const I: RegisterBits = RegisterBits::new(0x80); + pub const I0: RegisterBits = RegisterBits::new(1<<7); + + pub const T: RegisterBits = RegisterBits::new(0x40); + pub const T0: RegisterBits = RegisterBits::new(1<<6); + + pub const H: RegisterBits = RegisterBits::new(0x20); + pub const H0: RegisterBits = RegisterBits::new(1<<5); + + pub const S: RegisterBits = RegisterBits::new(0x10); + pub const S0: RegisterBits = RegisterBits::new(1<<4); + + pub const V: RegisterBits = RegisterBits::new(0x8); + pub const V0: RegisterBits = RegisterBits::new(1<<3); + + pub const N: RegisterBits = RegisterBits::new(0x4); + pub const N0: RegisterBits = RegisterBits::new(1<<2); + + pub const Z: RegisterBits = RegisterBits::new(0x2); + pub const Z0: RegisterBits = RegisterBits::new(1<<1); + + pub const C: RegisterBits = RegisterBits::new(0x1); + pub const C0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SREG { + type T = u8; + const ADDRESS: *mut u8 = 0x3f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKMSR; + +impl CLKMSR { + pub const CLKMS: RegisterBits = RegisterBits::new(0x3); + pub const CLKMS0: RegisterBits = RegisterBits::new(1<<0); + pub const CLKMS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for CLKMSR { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKPSR; + +impl CLKPSR { + pub const CLKPS: RegisterBits = RegisterBits::new(0xf); + pub const CLKPS0: RegisterBits = RegisterBits::new(1<<0); + pub const CLKPS1: RegisterBits = RegisterBits::new(1<<1); + pub const CLKPS2: RegisterBits = RegisterBits::new(1<<2); + pub const CLKPS3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CLKPSR { + type T = u8; + const ADDRESS: *mut u8 = 0x36 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCCAL; + +impl OSCCAL { + pub const OSCCAL: RegisterBits = RegisterBits::new(0xff); + pub const OSCCAL0: RegisterBits = RegisterBits::new(1<<0); + pub const OSCCAL1: RegisterBits = RegisterBits::new(1<<1); + pub const OSCCAL2: RegisterBits = RegisterBits::new(1<<2); + pub const OSCCAL3: RegisterBits = RegisterBits::new(1<<3); + pub const OSCCAL4: RegisterBits = RegisterBits::new(1<<4); + pub const OSCCAL5: RegisterBits = RegisterBits::new(1<<5); + pub const OSCCAL6: RegisterBits = RegisterBits::new(1<<6); + pub const OSCCAL7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OSCCAL { + type T = u8; + const ADDRESS: *mut u8 = 0x39 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTWI: RegisterBits = RegisterBits::new(0x10); + pub const PRTWI0: RegisterBits = RegisterBits::new(1<<4); + + pub const PRSPI: RegisterBits = RegisterBits::new(0x8); + pub const PRSPI0: RegisterBits = RegisterBits::new(1<<3); + + pub const PRTIM1: RegisterBits = RegisterBits::new(0x4); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<2); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x2); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<1); + + pub const PRADC: RegisterBits = RegisterBits::new(0x1); + pub const PRADC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PRR { + type T = u8; + const ADDRESS: *mut u8 = 0x35 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct RSTFLR; + +impl RSTFLR { + pub const WDRF: RegisterBits = RegisterBits::new(0x8); + pub const WDRF0: RegisterBits = RegisterBits::new(1<<3); + + pub const EXTRF: RegisterBits = RegisterBits::new(0x2); + pub const EXTRF0: RegisterBits = RegisterBits::new(1<<1); + + pub const PORF: RegisterBits = RegisterBits::new(0x1); + pub const PORF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for RSTFLR { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct NVMCSR; + +impl NVMCSR { + pub const NVMBSY: RegisterBits = RegisterBits::new(0x80); + pub const NVMBSY0: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for NVMCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x32 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct NVMCMD; + +impl NVMCMD { +} + +impl Register for NVMCMD { + type T = u8; + const ADDRESS: *mut u8 = 0x33 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const BODS: RegisterBits = RegisterBits::new(0x10); + pub const BODS0: RegisterBits = RegisterBits::new(1<<4); + + pub const SM: RegisterBits = RegisterBits::new(0xe); + pub const SM0: RegisterBits = RegisterBits::new(1<<1); + pub const SM1: RegisterBits = RegisterBits::new(1<<2); + pub const SM2: RegisterBits = RegisterBits::new(1<<3); + + pub const SE: RegisterBits = RegisterBits::new(0x1); + pub const SE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x3a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct RAMAR; + +impl RAMAR { +} + +impl Register for RAMAR { + type T = u8; + const ADDRESS: *mut u8 = 0x20 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct RAMDR; + +impl RAMDR { +} + +impl Register for RAMDR { + type T = u8; + const ADDRESS: *mut u8 = 0x1f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const ISC01: RegisterBits = RegisterBits::new(0x80); + pub const ISC010: RegisterBits = RegisterBits::new(1<<7); + + pub const ISC00: RegisterBits = RegisterBits::new(0x40); + pub const ISC000: RegisterBits = RegisterBits::new(1<<6); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x3a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIMSK; + +impl GIMSK { + pub const INT0: RegisterBits = RegisterBits::new(0x1); + pub const INT00: RegisterBits = RegisterBits::new(1<<0); + + pub const PCIE: RegisterBits = RegisterBits::new(0x70); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<4); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<5); + pub const PCIE2: RegisterBits = RegisterBits::new(1<<6); + +} + +impl Register for GIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0xc as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIFR; + +impl GIFR { + pub const INTF0: RegisterBits = RegisterBits::new(0x1); + pub const INTF00: RegisterBits = RegisterBits::new(1<<0); + + pub const PCIF: RegisterBits = RegisterBits::new(0x70); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<4); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<5); + pub const PCIF2: RegisterBits = RegisterBits::new(1<<6); + +} + +impl Register for GIFR { + type T = u8; + const ADDRESS: *mut u8 = 0xb as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK2; + +impl PCMSK2 { + pub const PCINT: RegisterBits = RegisterBits::new(0x3f); + pub const PCINT0: RegisterBits = RegisterBits::new(1<<0); + pub const PCINT1: RegisterBits = RegisterBits::new(1<<1); + pub const PCINT2: RegisterBits = RegisterBits::new(1<<2); + pub const PCINT3: RegisterBits = RegisterBits::new(1<<3); + pub const PCINT4: RegisterBits = RegisterBits::new(1<<4); + pub const PCINT5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for PCMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x1a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { + pub const PCINT: RegisterBits = RegisterBits::new(0xf); + pub const PCINT0: RegisterBits = RegisterBits::new(1<<0); + pub const PCINT1: RegisterBits = RegisterBits::new(1<<1); + pub const PCINT2: RegisterBits = RegisterBits::new(1<<2); + pub const PCINT3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0xa as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK0; + +impl PCMSK0 { + pub const PCINT: RegisterBits = RegisterBits::new(0xff); + pub const PCINT0: RegisterBits = RegisterBits::new(1<<0); + pub const PCINT1: RegisterBits = RegisterBits::new(1<<1); + pub const PCINT2: RegisterBits = RegisterBits::new(1<<2); + pub const PCINT3: RegisterBits = RegisterBits::new(1<<3); + pub const PCINT4: RegisterBits = RegisterBits::new(1<<4); + pub const PCINT5: RegisterBits = RegisterBits::new(1<<5); + pub const PCINT6: RegisterBits = RegisterBits::new(1<<6); + pub const PCINT7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for PCMSK0 { + type T = u8; + const ADDRESS: *mut u8 = 0x9 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTCR; + +impl PORTCR { + pub const ADC11D: RegisterBits = RegisterBits::new(0x80); + pub const ADC11D0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADC10D: RegisterBits = RegisterBits::new(0x40); + pub const ADC10D0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADC9D: RegisterBits = RegisterBits::new(0x20); + pub const ADC9D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC8D: RegisterBits = RegisterBits::new(0x10); + pub const ADC8D0: RegisterBits = RegisterBits::new(1<<4); + + pub const BBMC: RegisterBits = RegisterBits::new(0x4); + pub const BBMC0: RegisterBits = RegisterBits::new(1<<2); + + pub const BBMB: RegisterBits = RegisterBits::new(0x2); + pub const BBMB0: RegisterBits = RegisterBits::new(1<<1); + + pub const BBMA: RegisterBits = RegisterBits::new(0x1); + pub const BBMA0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PORTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x8 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PUEB; + +impl PUEB { +} + +impl Register for PUEB { + type T = u8; + const ADDRESS: *mut u8 = 0x7 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x5 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x4 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x6 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTCR; + +impl PORTCR { + pub const ADC11D: RegisterBits = RegisterBits::new(0x80); + pub const ADC11D0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADC10D: RegisterBits = RegisterBits::new(0x40); + pub const ADC10D0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADC9D: RegisterBits = RegisterBits::new(0x20); + pub const ADC9D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC8D: RegisterBits = RegisterBits::new(0x10); + pub const ADC8D0: RegisterBits = RegisterBits::new(1<<4); + + pub const BBMC: RegisterBits = RegisterBits::new(0x4); + pub const BBMC0: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PORTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x8 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PUEC; + +impl PUEC { +} + +impl Register for PUEC { + type T = u8; + const ADDRESS: *mut u8 = 0x1e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTC; + +impl PORTC { +} + +impl Register for PORTC { + type T = u8; + const ADDRESS: *mut u8 = 0x1d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRC; + +impl DDRC { +} + +impl Register for DDRC { + type T = u8; + const ADDRESS: *mut u8 = 0x1c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINC; + +impl PINC { +} + +impl Register for PINC { + type T = u8; + const ADDRESS: *mut u8 = 0x1b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTCR; + +impl PORTCR { + pub const BBMA: RegisterBits = RegisterBits::new(0x1); + pub const BBMA0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PORTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x8 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PUEA; + +impl PUEA { +} + +impl Register for PUEA { + type T = u8; + const ADDRESS: *mut u8 = 0x3 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTA; + +impl PORTA { +} + +impl Register for PORTA { + type T = u8; + const ADDRESS: *mut u8 = 0x2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRA; + +impl DDRA { +} + +impl Register for DDRA { + type T = u8; + const ADDRESS: *mut u8 = 0x1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINA; + +impl PINA { +} + +impl Register for PINA { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0A; + +impl TCCR0A { + pub const COM0A: RegisterBits = RegisterBits::new(0xc0); + pub const COM0A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM0A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM0B: RegisterBits = RegisterBits::new(0x30); + pub const COM0B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM0B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM0: RegisterBits = RegisterBits::new(0x3); + pub const WGM00: RegisterBits = RegisterBits::new(1<<0); + pub const WGM01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x19 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0B; + +impl TCCR0B { + pub const FOC0A: RegisterBits = RegisterBits::new(0x80); + pub const FOC0A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC0B: RegisterBits = RegisterBits::new(0x40); + pub const FOC0B0: RegisterBits = RegisterBits::new(1<<6); + + pub const TSM: RegisterBits = RegisterBits::new(0x20); + pub const TSM0: RegisterBits = RegisterBits::new(1<<5); + + pub const PSR: RegisterBits = RegisterBits::new(0x10); + pub const PSR0: RegisterBits = RegisterBits::new(1<<4); + + pub const WGM02: RegisterBits = RegisterBits::new(0x8); + pub const WGM020: RegisterBits = RegisterBits::new(1<<3); + + pub const CS0: RegisterBits = RegisterBits::new(0x7); + pub const CS00: RegisterBits = RegisterBits::new(1<<0); + pub const CS01: RegisterBits = RegisterBits::new(1<<1); + pub const CS02: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x18 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1A; + +impl TCCR1A { + pub const TCW1: RegisterBits = RegisterBits::new(0x80); + pub const TCW10: RegisterBits = RegisterBits::new(1<<7); + + pub const ICEN1: RegisterBits = RegisterBits::new(0x40); + pub const ICEN10: RegisterBits = RegisterBits::new(1<<6); + + pub const ICNC1: RegisterBits = RegisterBits::new(0x20); + pub const ICNC10: RegisterBits = RegisterBits::new(1<<5); + + pub const ICES1: RegisterBits = RegisterBits::new(0x10); + pub const ICES10: RegisterBits = RegisterBits::new(1<<4); + + pub const CTC1: RegisterBits = RegisterBits::new(0x8); + pub const CTC10: RegisterBits = RegisterBits::new(1<<3); + + pub const CS1: RegisterBits = RegisterBits::new(0x7); + pub const CS10: RegisterBits = RegisterBits::new(1<<0); + pub const CS11: RegisterBits = RegisterBits::new(1<<1); + pub const CS12: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x24 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT1H; + +impl TCNT1H { +} + +impl Register for TCNT1H { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT1L; + +impl TCNT1L { +} + +impl Register for TCNT1L { + type T = u8; + const ADDRESS: *mut u8 = 0x23 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x22 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x21 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const ICIE1: RegisterBits = RegisterBits::new(0x80); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<7); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x20); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const OCIE1A: RegisterBits = RegisterBits::new(0x10); + pub const OCIE1A0: RegisterBits = RegisterBits::new(1<<4); + + pub const TOIE: RegisterBits = RegisterBits::new(0x9); + pub const TOIE0: RegisterBits = RegisterBits::new(1<<0); + pub const TOIE1: RegisterBits = RegisterBits::new(1<<3); + + pub const OCIE0B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE0B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCIE0A: RegisterBits = RegisterBits::new(0x2); + pub const OCIE0A0: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x26 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const ICF1: RegisterBits = RegisterBits::new(0x80); + pub const ICF10: RegisterBits = RegisterBits::new(1<<7); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x20); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const OCF1A: RegisterBits = RegisterBits::new(0x10); + pub const OCF1A0: RegisterBits = RegisterBits::new(1<<4); + + pub const TOV: RegisterBits = RegisterBits::new(0x9); + pub const TOV0: RegisterBits = RegisterBits::new(1<<0); + pub const TOV1: RegisterBits = RegisterBits::new(1<<3); + + pub const OCF0B: RegisterBits = RegisterBits::new(0x4); + pub const OCF0B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCF0A: RegisterBits = RegisterBits::new(0x2); + pub const OCF0A0: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x25 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0; + +impl TCNT0 { +} + +impl Register for TCNT0 { + type T = u8; + const ADDRESS: *mut u8 = 0x17 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x16 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0B; + +impl OCR0B { +} + +impl Register for OCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x15 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPCR; + +impl SPCR { + pub const SPIE: RegisterBits = RegisterBits::new(0x80); + pub const SPIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const SPE: RegisterBits = RegisterBits::new(0x40); + pub const SPE0: RegisterBits = RegisterBits::new(1<<6); + + pub const DORD: RegisterBits = RegisterBits::new(0x20); + pub const DORD0: RegisterBits = RegisterBits::new(1<<5); + + pub const MSTR: RegisterBits = RegisterBits::new(0x10); + pub const MSTR0: RegisterBits = RegisterBits::new(1<<4); + + pub const CPOL: RegisterBits = RegisterBits::new(0x8); + pub const CPOL0: RegisterBits = RegisterBits::new(1<<3); + + pub const CPHA: RegisterBits = RegisterBits::new(0x4); + pub const CPHA0: RegisterBits = RegisterBits::new(1<<2); + + pub const SPR: RegisterBits = RegisterBits::new(0x3); + pub const SPR0: RegisterBits = RegisterBits::new(1<<0); + pub const SPR1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for SPCR { + type T = u8; + const ADDRESS: *mut u8 = 0x30 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPSR; + +impl SPSR { + pub const SPIF: RegisterBits = RegisterBits::new(0x80); + pub const SPIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WCOL: RegisterBits = RegisterBits::new(0x40); + pub const WCOL0: RegisterBits = RegisterBits::new(1<<6); + + pub const SPI2X: RegisterBits = RegisterBits::new(0x1); + pub const SPI2X0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SPSR { + type T = u8; + const ADDRESS: *mut u8 = 0x2f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPDR; + +impl SPDR { +} + +impl Register for SPDR { + type T = u8; + const ADDRESS: *mut u8 = 0x2e as *mut u8; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + + pub struct B0; + + impl Pin for B0 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEB; + /// Data Direction Register, Port B. + type DDR = DDRB; + /// Port B Data register. + type PIN = PINB; + /// Input Pins, Port B. + type PORT = PORTB; + /// PB0 + const MASK: u8 = 1<<0; + } + + pub struct B1; + + impl Pin for B1 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEB; + /// Data Direction Register, Port B. + type DDR = DDRB; + /// Port B Data register. + type PIN = PINB; + /// Input Pins, Port B. + type PORT = PORTB; + /// PB1 + const MASK: u8 = 1<<1; + } + + pub struct B2; + + impl Pin for B2 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEB; + /// Data Direction Register, Port B. + type DDR = DDRB; + /// Port B Data register. + type PIN = PINB; + /// Input Pins, Port B. + type PORT = PORTB; + /// PB2 + const MASK: u8 = 1<<2; + } + + pub struct B3; + + impl Pin for B3 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEB; + /// Data Direction Register, Port B. + type DDR = DDRB; + /// Port B Data register. + type PIN = PINB; + /// Input Pins, Port B. + type PORT = PORTB; + /// PB3 + const MASK: u8 = 1<<3; + } + + pub struct C0; + + impl Pin for C0 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEC; + /// Port C Data Register. + type PORT = PORTC; + /// Data Direction Register, Port C. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC0 + const MASK: u8 = 1<<0; + } + + pub struct C1; + + impl Pin for C1 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEC; + /// Port C Data Register. + type PORT = PORTC; + /// Data Direction Register, Port C. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC1 + const MASK: u8 = 1<<1; + } + + pub struct C2; + + impl Pin for C2 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEC; + /// Port C Data Register. + type PORT = PORTC; + /// Data Direction Register, Port C. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC2 + const MASK: u8 = 1<<2; + } + + pub struct C3; + + impl Pin for C3 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEC; + /// Port C Data Register. + type PORT = PORTC; + /// Data Direction Register, Port C. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC3 + const MASK: u8 = 1<<3; + } + + pub struct C4; + + impl Pin for C4 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEC; + /// Port C Data Register. + type PORT = PORTC; + /// Data Direction Register, Port C. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC4 + const MASK: u8 = 1<<4; + } + + pub struct C5; + + impl Pin for C5 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEC; + /// Port C Data Register. + type PORT = PORTC; + /// Data Direction Register, Port C. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC5 + const MASK: u8 = 1<<5; + } + + pub struct A0; + + impl Pin for A0 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEA; + /// Port A Data Register. + type PORT = PORTA; + /// Data Direction Register, Port A. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA0 + const MASK: u8 = 1<<0; + } + + pub struct A1; + + impl Pin for A1 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEA; + /// Port A Data Register. + type PORT = PORTA; + /// Data Direction Register, Port A. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA1 + const MASK: u8 = 1<<1; + } + + pub struct A2; + + impl Pin for A2 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEA; + /// Port A Data Register. + type PORT = PORTA; + /// Data Direction Register, Port A. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA2 + const MASK: u8 = 1<<2; + } + + pub struct A3; + + impl Pin for A3 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEA; + /// Port A Data Register. + type PORT = PORTA; + /// Data Direction Register, Port A. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA3 + const MASK: u8 = 1<<3; + } + + pub struct A4; + + impl Pin for A4 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEA; + /// Port A Data Register. + type PORT = PORTA; + /// Data Direction Register, Port A. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA4 + const MASK: u8 = 1<<4; + } + + pub struct A5; + + impl Pin for A5 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEA; + /// Port A Data Register. + type PORT = PORTA; + /// Data Direction Register, Port A. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA5 + const MASK: u8 = 1<<5; + } + + pub struct A6; + + impl Pin for A6 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEA; + /// Port A Data Register. + type PORT = PORTA; + /// Data Direction Register, Port A. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA6 + const MASK: u8 = 1<<6; + } + + pub struct A7; + + impl Pin for A7 { + /// Port Control Register. + type PORTC = PORTCR; + /// Pull-up Enable Control Register. + type PUE = PUEA; + /// Port A Data Register. + type PORT = PORTA; + /// Data Direction Register, Port A. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA7 + const MASK: u8 = 1<<7; + } + +} + +pub struct Spi; + +impl modules::HardwareSpi for Spi { + type Clock = port::C1; + type SerialDataOut = port::C4; + type SerialDataIn = port::C2; + type ChipSelect = port::C0; + type ControlRegister = SPCR; + type StatusRegister = SPSR; + type DataRegister = SPDR; +} + +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR1A; + type CompareB = OCR1B; + type Counter = TCNT1H; + type ControlA = TCCR0A; + type ControlB = TCCR0B; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE0A; +} + diff --git a/src/cores/attiny4313.rs b/src/cores/attiny4313.rs new file mode 100644 index 0000000..a219276 --- /dev/null +++ b/src/cores/attiny4313.rs @@ -0,0 +1,1111 @@ +//! Core for ATtiny4313. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + pub const SELFPRGEN: RegisterBits = RegisterBits::new(0x1); + pub const SELFPRGEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EXTENDED { + type T = u8; + const ADDRESS: *mut u8 = 0x2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct HIGH; + +impl HIGH { + pub const DWEN: RegisterBits = RegisterBits::new(0x80); + pub const DWEN0: RegisterBits = RegisterBits::new(1<<7); + + pub const EESAVE: RegisterBits = RegisterBits::new(0x40); + pub const EESAVE0: RegisterBits = RegisterBits::new(1<<6); + + pub const SPIEN: RegisterBits = RegisterBits::new(0x20); + pub const SPIEN0: RegisterBits = RegisterBits::new(1<<5); + + pub const WDTON: RegisterBits = RegisterBits::new(0x10); + pub const WDTON0: RegisterBits = RegisterBits::new(1<<4); + + pub const BODLEVEL: RegisterBits = RegisterBits::new(0xe); + pub const BODLEVEL0: RegisterBits = RegisterBits::new(1<<1); + pub const BODLEVEL1: RegisterBits = RegisterBits::new(1<<2); + pub const BODLEVEL2: RegisterBits = RegisterBits::new(1<<3); + + pub const RSTDISBL: RegisterBits = RegisterBits::new(0x1); + pub const RSTDISBL0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for HIGH { + type T = u8; + const ADDRESS: *mut u8 = 0x1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOW; + +impl LOW { + pub const CKDIV8: RegisterBits = RegisterBits::new(0x80); + pub const CKDIV80: RegisterBits = RegisterBits::new(1<<7); + + pub const CKOUT: RegisterBits = RegisterBits::new(0x40); + pub const CKOUT0: RegisterBits = RegisterBits::new(1<<6); + + pub const SUT_CKSEL: RegisterBits = RegisterBits::new(0x3f); + pub const SUT_CKSEL0: RegisterBits = RegisterBits::new(1<<0); + pub const SUT_CKSEL1: RegisterBits = RegisterBits::new(1<<1); + pub const SUT_CKSEL2: RegisterBits = RegisterBits::new(1<<2); + pub const SUT_CKSEL3: RegisterBits = RegisterBits::new(1<<3); + pub const SUT_CKSEL4: RegisterBits = RegisterBits::new(1<<4); + pub const SUT_CKSEL5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for LOW { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOCKBIT; + +impl LOCKBIT { + pub const LB: RegisterBits = RegisterBits::new(0x3); + pub const LB0: RegisterBits = RegisterBits::new(1<<0); + pub const LB1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for LOCKBIT { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x38 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x36 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTD; + +impl PORTD { +} + +impl Register for PORTD { + type T = u8; + const ADDRESS: *mut u8 = 0x32 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRD; + +impl DDRD { +} + +impl Register for DDRD { + type T = u8; + const ADDRESS: *mut u8 = 0x31 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PIND; + +impl PIND { +} + +impl Register for PIND { + type T = u8; + const ADDRESS: *mut u8 = 0x30 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTA; + +impl PORTA { +} + +impl Register for PORTA { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRA; + +impl DDRA { +} + +impl Register for DDRA { + type T = u8; + const ADDRESS: *mut u8 = 0x3a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINA; + +impl PINA { +} + +impl Register for PINA { + type T = u8; + const ADDRESS: *mut u8 = 0x39 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE0B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE0B0: RegisterBits = RegisterBits::new(1<<2); + + pub const TOIE0: RegisterBits = RegisterBits::new(0x2); + pub const TOIE00: RegisterBits = RegisterBits::new(1<<1); + + pub const OCIE0A: RegisterBits = RegisterBits::new(0x1); + pub const OCIE0A0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF0B: RegisterBits = RegisterBits::new(0x4); + pub const OCF0B0: RegisterBits = RegisterBits::new(1<<2); + + pub const TOV0: RegisterBits = RegisterBits::new(0x2); + pub const TOV00: RegisterBits = RegisterBits::new(1<<1); + + pub const OCF0A: RegisterBits = RegisterBits::new(0x1); + pub const OCF0A0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0B; + +impl OCR0B { +} + +impl Register for OCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x5c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x56 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0A; + +impl TCCR0A { + pub const COM0A: RegisterBits = RegisterBits::new(0xc0); + pub const COM0A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM0A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM0B: RegisterBits = RegisterBits::new(0x30); + pub const COM0B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM0B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM0: RegisterBits = RegisterBits::new(0x3); + pub const WGM00: RegisterBits = RegisterBits::new(1<<0); + pub const WGM01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0; + +impl TCNT0 { +} + +impl Register for TCNT0 { + type T = u8; + const ADDRESS: *mut u8 = 0x52 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0B; + +impl TCCR0B { + pub const FOC0A: RegisterBits = RegisterBits::new(0x80); + pub const FOC0A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC0B: RegisterBits = RegisterBits::new(0x40); + pub const FOC0B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM02: RegisterBits = RegisterBits::new(0x8); + pub const WGM020: RegisterBits = RegisterBits::new(1<<3); + + pub const CS0: RegisterBits = RegisterBits::new(0x7); + pub const CS00: RegisterBits = RegisterBits::new(1<<0); + pub const CS01: RegisterBits = RegisterBits::new(1<<1); + pub const CS02: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x53 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const TOIE1: RegisterBits = RegisterBits::new(0x80); + pub const TOIE10: RegisterBits = RegisterBits::new(1<<7); + + pub const OCIE1A: RegisterBits = RegisterBits::new(0x40); + pub const OCIE1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x20); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const ICIE1: RegisterBits = RegisterBits::new(0x8); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const TOV1: RegisterBits = RegisterBits::new(0x80); + pub const TOV10: RegisterBits = RegisterBits::new(1<<7); + + pub const OCF1A: RegisterBits = RegisterBits::new(0x40); + pub const OCF1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x20); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const ICF1: RegisterBits = RegisterBits::new(0x8); + pub const ICF10: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1A; + +impl TCCR1A { + pub const COM1A: RegisterBits = RegisterBits::new(0xc0); + pub const COM1A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM1A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM1B: RegisterBits = RegisterBits::new(0x30); + pub const COM1B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM1B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM1: RegisterBits = RegisterBits::new(0x3); + pub const WGM10: RegisterBits = RegisterBits::new(1<<0); + pub const WGM11: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x4f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1B; + +impl TCCR1B { + pub const ICNC1: RegisterBits = RegisterBits::new(0x80); + pub const ICNC10: RegisterBits = RegisterBits::new(1<<7); + + pub const ICES1: RegisterBits = RegisterBits::new(0x40); + pub const ICES10: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM1: RegisterBits = RegisterBits::new(0x18); + pub const WGM10: RegisterBits = RegisterBits::new(1<<3); + pub const WGM11: RegisterBits = RegisterBits::new(1<<4); + + pub const CS1: RegisterBits = RegisterBits::new(0x7); + pub const CS10: RegisterBits = RegisterBits::new(1<<0); + pub const CS11: RegisterBits = RegisterBits::new(1<<1); + pub const CS12: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x4e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1C; + +impl TCCR1C { + pub const FOC1A: RegisterBits = RegisterBits::new(0x80); + pub const FOC1A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC1B: RegisterBits = RegisterBits::new(0x40); + pub const FOC1B0: RegisterBits = RegisterBits::new(1<<6); + +} + +impl Register for TCCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x42 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT1; + +impl TCNT1 { +} + +impl Register for TCNT1 { + type T = u16; + const ADDRESS: *mut u16 = 0x4c as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x4a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x48 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x44 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct WDTCR; + +impl WDTCR { + pub const WDIF: RegisterBits = RegisterBits::new(0x80); + pub const WDIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WDIE: RegisterBits = RegisterBits::new(0x40); + pub const WDIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const WDP: RegisterBits = RegisterBits::new(0x27); + pub const WDP0: RegisterBits = RegisterBits::new(1<<0); + pub const WDP1: RegisterBits = RegisterBits::new(1<<1); + pub const WDP2: RegisterBits = RegisterBits::new(1<<2); + pub const WDP3: RegisterBits = RegisterBits::new(1<<5); + + pub const WDCE: RegisterBits = RegisterBits::new(0x10); + pub const WDCE0: RegisterBits = RegisterBits::new(1<<4); + + pub const WDE: RegisterBits = RegisterBits::new(0x8); + pub const WDE0: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for WDTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x41 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UDR; + +impl UDR { +} + +impl Register for UDR { + type T = u8; + const ADDRESS: *mut u8 = 0x2c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UCSRA; + +impl UCSRA { + pub const RXC: RegisterBits = RegisterBits::new(0x80); + pub const RXC0: RegisterBits = RegisterBits::new(1<<7); + + pub const TXC: RegisterBits = RegisterBits::new(0x40); + pub const TXC0: RegisterBits = RegisterBits::new(1<<6); + + pub const UDRE: RegisterBits = RegisterBits::new(0x20); + pub const UDRE0: RegisterBits = RegisterBits::new(1<<5); + + pub const FE: RegisterBits = RegisterBits::new(0x10); + pub const FE0: RegisterBits = RegisterBits::new(1<<4); + + pub const DOR: RegisterBits = RegisterBits::new(0x8); + pub const DOR0: RegisterBits = RegisterBits::new(1<<3); + + pub const UPE: RegisterBits = RegisterBits::new(0x4); + pub const UPE0: RegisterBits = RegisterBits::new(1<<2); + + pub const U2X: RegisterBits = RegisterBits::new(0x2); + pub const U2X0: RegisterBits = RegisterBits::new(1<<1); + + pub const MPCM: RegisterBits = RegisterBits::new(0x1); + pub const MPCM0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for UCSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x2b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UCSRB; + +impl UCSRB { + pub const RXCIE: RegisterBits = RegisterBits::new(0x80); + pub const RXCIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const TXCIE: RegisterBits = RegisterBits::new(0x40); + pub const TXCIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const UDRIE: RegisterBits = RegisterBits::new(0x20); + pub const UDRIE0: RegisterBits = RegisterBits::new(1<<5); + + pub const RXEN: RegisterBits = RegisterBits::new(0x10); + pub const RXEN0: RegisterBits = RegisterBits::new(1<<4); + + pub const TXEN: RegisterBits = RegisterBits::new(0x8); + pub const TXEN0: RegisterBits = RegisterBits::new(1<<3); + + pub const UCSZ2: RegisterBits = RegisterBits::new(0x4); + pub const UCSZ20: RegisterBits = RegisterBits::new(1<<2); + + pub const RXB8: RegisterBits = RegisterBits::new(0x2); + pub const RXB80: RegisterBits = RegisterBits::new(1<<1); + + pub const TXB8: RegisterBits = RegisterBits::new(0x1); + pub const TXB80: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for UCSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x2a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UCSRC; + +impl UCSRC { + pub const UMSEL: RegisterBits = RegisterBits::new(0xc0); + pub const UMSEL0: RegisterBits = RegisterBits::new(1<<6); + pub const UMSEL1: RegisterBits = RegisterBits::new(1<<7); + + pub const UPM: RegisterBits = RegisterBits::new(0x30); + pub const UPM0: RegisterBits = RegisterBits::new(1<<4); + pub const UPM1: RegisterBits = RegisterBits::new(1<<5); + + pub const USBS: RegisterBits = RegisterBits::new(0x8); + pub const USBS0: RegisterBits = RegisterBits::new(1<<3); + + pub const UCSZ: RegisterBits = RegisterBits::new(0x6); + pub const UCSZ0: RegisterBits = RegisterBits::new(1<<1); + pub const UCSZ1: RegisterBits = RegisterBits::new(1<<2); + + pub const UCPOL: RegisterBits = RegisterBits::new(0x1); + pub const UCPOL0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for UCSRC { + type T = u8; + const ADDRESS: *mut u8 = 0x23 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRRH; + +impl UBRRH { +} + +impl Register for UBRRH { + type T = u8; + const ADDRESS: *mut u8 = 0x22 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRRL; + +impl UBRRL { +} + +impl Register for UBRRL { + type T = u8; + const ADDRESS: *mut u8 = 0x29 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSR; + +impl ACSR { + pub const ACD: RegisterBits = RegisterBits::new(0x80); + pub const ACD0: RegisterBits = RegisterBits::new(1<<7); + + pub const ACBG: RegisterBits = RegisterBits::new(0x40); + pub const ACBG0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACO: RegisterBits = RegisterBits::new(0x20); + pub const ACO0: RegisterBits = RegisterBits::new(1<<5); + + pub const ACI: RegisterBits = RegisterBits::new(0x10); + pub const ACI0: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIE: RegisterBits = RegisterBits::new(0x8); + pub const ACIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ACIC: RegisterBits = RegisterBits::new(0x4); + pub const ACIC0: RegisterBits = RegisterBits::new(1<<2); + + pub const ACIS: RegisterBits = RegisterBits::new(0x3); + pub const ACIS0: RegisterBits = RegisterBits::new(1<<0); + pub const ACIS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for ACSR { + type T = u8; + const ADDRESS: *mut u8 = 0x28 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR; + +impl DIDR { +} + +impl Register for DIDR { + type T = u8; + const ADDRESS: *mut u8 = 0x21 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEAR; + +impl EEAR { +} + +impl Register for EEAR { + type T = u8; + const ADDRESS: *mut u8 = 0x3e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEDR; + +impl EEDR { +} + +impl Register for EEDR { + type T = u8; + const ADDRESS: *mut u8 = 0x3d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EECR; + +impl EECR { + pub const EEPM: RegisterBits = RegisterBits::new(0x30); + pub const EEPM0: RegisterBits = RegisterBits::new(1<<4); + pub const EEPM1: RegisterBits = RegisterBits::new(1<<5); + + pub const EERIE: RegisterBits = RegisterBits::new(0x8); + pub const EERIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const EEMPE: RegisterBits = RegisterBits::new(0x4); + pub const EEMPE0: RegisterBits = RegisterBits::new(1<<2); + + pub const EEPE: RegisterBits = RegisterBits::new(0x2); + pub const EEPE0: RegisterBits = RegisterBits::new(1<<1); + + pub const EERE: RegisterBits = RegisterBits::new(0x1); + pub const EERE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EECR { + type T = u8; + const ADDRESS: *mut u8 = 0x3c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIDR; + +impl USIDR { +} + +impl Register for USIDR { + type T = u8; + const ADDRESS: *mut u8 = 0x2f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USISR; + +impl USISR { + pub const USISIF: RegisterBits = RegisterBits::new(0x80); + pub const USISIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIF: RegisterBits = RegisterBits::new(0x40); + pub const USIOIF0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIPF: RegisterBits = RegisterBits::new(0x20); + pub const USIPF0: RegisterBits = RegisterBits::new(1<<5); + + pub const USIDC: RegisterBits = RegisterBits::new(0x10); + pub const USIDC0: RegisterBits = RegisterBits::new(1<<4); + + pub const USICNT: RegisterBits = RegisterBits::new(0xf); + pub const USICNT0: RegisterBits = RegisterBits::new(1<<0); + pub const USICNT1: RegisterBits = RegisterBits::new(1<<1); + pub const USICNT2: RegisterBits = RegisterBits::new(1<<2); + pub const USICNT3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for USISR { + type T = u8; + const ADDRESS: *mut u8 = 0x2e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USICR; + +impl USICR { + pub const USISIE: RegisterBits = RegisterBits::new(0x80); + pub const USISIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIE: RegisterBits = RegisterBits::new(0x40); + pub const USIOIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIWM: RegisterBits = RegisterBits::new(0x30); + pub const USIWM0: RegisterBits = RegisterBits::new(1<<4); + pub const USIWM1: RegisterBits = RegisterBits::new(1<<5); + + pub const USICS: RegisterBits = RegisterBits::new(0xc); + pub const USICS0: RegisterBits = RegisterBits::new(1<<2); + pub const USICS1: RegisterBits = RegisterBits::new(1<<3); + + pub const USICLK: RegisterBits = RegisterBits::new(0x2); + pub const USICLK0: RegisterBits = RegisterBits::new(1<<1); + + pub const USITC: RegisterBits = RegisterBits::new(0x1); + pub const USITC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for USICR { + type T = u8; + const ADDRESS: *mut u8 = 0x2d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIMSK; + +impl GIMSK { + pub const INT: RegisterBits = RegisterBits::new(0xc0); + pub const INT0: RegisterBits = RegisterBits::new(1<<6); + pub const INT1: RegisterBits = RegisterBits::new(1<<7); + + pub const PCIE: RegisterBits = RegisterBits::new(0x20); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x5b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIFR; + +impl GIFR { + pub const INTF: RegisterBits = RegisterBits::new(0xc0); + pub const INTF0: RegisterBits = RegisterBits::new(1<<6); + pub const INTF1: RegisterBits = RegisterBits::new(1<<7); + + pub const PCIF: RegisterBits = RegisterBits::new(0x38); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<3); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<4); + pub const PCIF2: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x5a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK2; + +impl PCMSK2 { + pub const PCINT: RegisterBits = RegisterBits::new(0x7f); + pub const PCINT0: RegisterBits = RegisterBits::new(1<<0); + pub const PCINT1: RegisterBits = RegisterBits::new(1<<1); + pub const PCINT2: RegisterBits = RegisterBits::new(1<<2); + pub const PCINT3: RegisterBits = RegisterBits::new(1<<3); + pub const PCINT4: RegisterBits = RegisterBits::new(1<<4); + pub const PCINT5: RegisterBits = RegisterBits::new(1<<5); + pub const PCINT6: RegisterBits = RegisterBits::new(1<<6); + +} + +impl Register for PCMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x25 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { + pub const PCINT: RegisterBits = RegisterBits::new(0x7); + pub const PCINT0: RegisterBits = RegisterBits::new(1<<0); + pub const PCINT1: RegisterBits = RegisterBits::new(1<<1); + pub const PCINT2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x24 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK0; + +impl PCMSK0 { +} + +impl Register for PCMSK0 { + type T = u8; + const ADDRESS: *mut u8 = 0x40 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SREG; + +impl SREG { + pub const I: RegisterBits = RegisterBits::new(0x80); + pub const I0: RegisterBits = RegisterBits::new(1<<7); + + pub const T: RegisterBits = RegisterBits::new(0x40); + pub const T0: RegisterBits = RegisterBits::new(1<<6); + + pub const H: RegisterBits = RegisterBits::new(0x20); + pub const H0: RegisterBits = RegisterBits::new(1<<5); + + pub const S: RegisterBits = RegisterBits::new(0x10); + pub const S0: RegisterBits = RegisterBits::new(1<<4); + + pub const V: RegisterBits = RegisterBits::new(0x8); + pub const V0: RegisterBits = RegisterBits::new(1<<3); + + pub const N: RegisterBits = RegisterBits::new(0x4); + pub const N0: RegisterBits = RegisterBits::new(1<<2); + + pub const Z: RegisterBits = RegisterBits::new(0x2); + pub const Z0: RegisterBits = RegisterBits::new(1<<1); + + pub const C: RegisterBits = RegisterBits::new(0x1); + pub const C0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SREG { + type T = u8; + const ADDRESS: *mut u8 = 0x5f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SP; + +impl SP { +} + +impl Register for SP { + type T = u16; + const ADDRESS: *mut u16 = 0x5d as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct SPMCSR; + +impl SPMCSR { + pub const CTPB: RegisterBits = RegisterBits::new(0x10); + pub const CTPB0: RegisterBits = RegisterBits::new(1<<4); + + pub const RFLB: RegisterBits = RegisterBits::new(0x8); + pub const RFLB0: RegisterBits = RegisterBits::new(1<<3); + + pub const PGWRT: RegisterBits = RegisterBits::new(0x4); + pub const PGWRT0: RegisterBits = RegisterBits::new(1<<2); + + pub const PGERS: RegisterBits = RegisterBits::new(0x2); + pub const PGERS0: RegisterBits = RegisterBits::new(1<<1); + + pub const SPMEN: RegisterBits = RegisterBits::new(0x1); + pub const SPMEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SPMCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x57 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const PUD: RegisterBits = RegisterBits::new(0x80); + pub const PUD0: RegisterBits = RegisterBits::new(1<<7); + + pub const SM: RegisterBits = RegisterBits::new(0x50); + pub const SM0: RegisterBits = RegisterBits::new(1<<4); + pub const SM1: RegisterBits = RegisterBits::new(1<<6); + + pub const SE: RegisterBits = RegisterBits::new(0x20); + pub const SE0: RegisterBits = RegisterBits::new(1<<5); + + pub const ISC1: RegisterBits = RegisterBits::new(0xc); + pub const ISC10: RegisterBits = RegisterBits::new(1<<2); + pub const ISC11: RegisterBits = RegisterBits::new(1<<3); + + pub const ISC0: RegisterBits = RegisterBits::new(0x3); + pub const ISC00: RegisterBits = RegisterBits::new(1<<0); + pub const ISC01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUSR; + +impl MCUSR { + pub const WDRF: RegisterBits = RegisterBits::new(0x8); + pub const WDRF0: RegisterBits = RegisterBits::new(1<<3); + + pub const BORF: RegisterBits = RegisterBits::new(0x4); + pub const BORF0: RegisterBits = RegisterBits::new(1<<2); + + pub const EXTRF: RegisterBits = RegisterBits::new(0x2); + pub const EXTRF0: RegisterBits = RegisterBits::new(1<<1); + + pub const PORF: RegisterBits = RegisterBits::new(0x1); + pub const PORF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUSR { + type T = u8; + const ADDRESS: *mut u8 = 0x54 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCCAL; + +impl OSCCAL { + pub const OSCCAL: RegisterBits = RegisterBits::new(0xff); + pub const OSCCAL0: RegisterBits = RegisterBits::new(1<<0); + pub const OSCCAL1: RegisterBits = RegisterBits::new(1<<1); + pub const OSCCAL2: RegisterBits = RegisterBits::new(1<<2); + pub const OSCCAL3: RegisterBits = RegisterBits::new(1<<3); + pub const OSCCAL4: RegisterBits = RegisterBits::new(1<<4); + pub const OSCCAL5: RegisterBits = RegisterBits::new(1<<5); + pub const OSCCAL6: RegisterBits = RegisterBits::new(1<<6); + pub const OSCCAL7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OSCCAL { + type T = u8; + const ADDRESS: *mut u8 = 0x51 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKPR; + +impl CLKPR { + pub const CLKPCE: RegisterBits = RegisterBits::new(0x80); + pub const CLKPCE0: RegisterBits = RegisterBits::new(1<<7); + + pub const CLKPS: RegisterBits = RegisterBits::new(0xf); + pub const CLKPS0: RegisterBits = RegisterBits::new(1<<0); + pub const CLKPS1: RegisterBits = RegisterBits::new(1<<1); + pub const CLKPS2: RegisterBits = RegisterBits::new(1<<2); + pub const CLKPS3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CLKPR { + type T = u8; + const ADDRESS: *mut u8 = 0x46 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR2; + +impl GPIOR2 { +} + +impl Register for GPIOR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x35 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR1; + +impl GPIOR1 { +} + +impl Register for GPIOR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x34 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR0; + +impl GPIOR0 { +} + +impl Register for GPIOR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x33 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTIM: RegisterBits = RegisterBits::new(0xc); + pub const PRTIM0: RegisterBits = RegisterBits::new(1<<2); + pub const PRTIM1: RegisterBits = RegisterBits::new(1<<3); + + pub const PRUSI: RegisterBits = RegisterBits::new(0x2); + pub const PRUSI0: RegisterBits = RegisterBits::new(1<<1); + + pub const PRUSART: RegisterBits = RegisterBits::new(0x1); + pub const PRUSART0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PRR { + type T = u8; + const ADDRESS: *mut u8 = 0x26 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct BODCR; + +impl BODCR { + pub const BPDS: RegisterBits = RegisterBits::new(0x2); + pub const BPDS0: RegisterBits = RegisterBits::new(1<<1); + + pub const BPDSE: RegisterBits = RegisterBits::new(0x1); + pub const BPDSE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for BODCR { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + +} + +/// The USART module. +pub struct USART; + +impl modules::HardwareUsart for USART { + type DataRegister = UDR; + type ControlRegisterA = UCSRA; + type ControlRegisterB = UCSRB; + type ControlRegisterC = UCSRC; + type BaudRateRegister = UBRRH; + type BaudRateRegister = UBRRL; +} + +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR0A; + type CompareB = OCR0B; + type Counter = TCNT0; + type ControlA = TCCR0A; + type ControlB = TCCR0B; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE0A; +} +/// 16-bit timer. +pub struct Timer16; + +impl modules::Timer16 for Timer16 { + type CompareA = OCR1A; + type CompareB = OCR1B; + type Counter = TCNT1; + type ControlA = TCCR1A; + type ControlB = TCCR1B; + type ControlC = TCCR1C; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS10; + const CS1: RegisterBits = Self::ControlB::CS11; + const CS2: RegisterBits = Self::ControlB::CS12; + const WGM0: RegisterBits = Self::ControlA::WGM10; + const WGM1: RegisterBits = Self::ControlA::WGM11; + const WGM2: RegisterBits = Self::ControlB::WGM10; + const WGM3: RegisterBits = Self::ControlB::WGM11; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE1A; +} + diff --git a/src/cores/attiny461.rs b/src/cores/attiny461.rs new file mode 100644 index 0000000..21b36bc --- /dev/null +++ b/src/cores/attiny461.rs @@ -0,0 +1,1468 @@ +//! Core for ATtiny461. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + pub const SELFPRGEN: RegisterBits = RegisterBits::new(0x1); + pub const SELFPRGEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EXTENDED { + type T = u8; + const ADDRESS: *mut u8 = 0x2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct HIGH; + +impl HIGH { + pub const RSTDISBL: RegisterBits = RegisterBits::new(0x80); + pub const RSTDISBL0: RegisterBits = RegisterBits::new(1<<7); + + pub const DWEN: RegisterBits = RegisterBits::new(0x40); + pub const DWEN0: RegisterBits = RegisterBits::new(1<<6); + + pub const SPIEN: RegisterBits = RegisterBits::new(0x20); + pub const SPIEN0: RegisterBits = RegisterBits::new(1<<5); + + pub const WDTON: RegisterBits = RegisterBits::new(0x10); + pub const WDTON0: RegisterBits = RegisterBits::new(1<<4); + + pub const EESAVE: RegisterBits = RegisterBits::new(0x8); + pub const EESAVE0: RegisterBits = RegisterBits::new(1<<3); + + pub const BODLEVEL: RegisterBits = RegisterBits::new(0x7); + pub const BODLEVEL0: RegisterBits = RegisterBits::new(1<<0); + pub const BODLEVEL1: RegisterBits = RegisterBits::new(1<<1); + pub const BODLEVEL2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for HIGH { + type T = u8; + const ADDRESS: *mut u8 = 0x1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOW; + +impl LOW { + pub const CKDIV8: RegisterBits = RegisterBits::new(0x80); + pub const CKDIV80: RegisterBits = RegisterBits::new(1<<7); + + pub const CKOUT: RegisterBits = RegisterBits::new(0x40); + pub const CKOUT0: RegisterBits = RegisterBits::new(1<<6); + + pub const SUT_CKSEL: RegisterBits = RegisterBits::new(0x3f); + pub const SUT_CKSEL0: RegisterBits = RegisterBits::new(1<<0); + pub const SUT_CKSEL1: RegisterBits = RegisterBits::new(1<<1); + pub const SUT_CKSEL2: RegisterBits = RegisterBits::new(1<<2); + pub const SUT_CKSEL3: RegisterBits = RegisterBits::new(1<<3); + pub const SUT_CKSEL4: RegisterBits = RegisterBits::new(1<<4); + pub const SUT_CKSEL5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for LOW { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOCKBIT; + +impl LOCKBIT { + pub const LB: RegisterBits = RegisterBits::new(0x3); + pub const LB0: RegisterBits = RegisterBits::new(1<<0); + pub const LB1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for LOCKBIT { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTA; + +impl PORTA { +} + +impl Register for PORTA { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRA; + +impl DDRA { +} + +impl Register for DDRA { + type T = u8; + const ADDRESS: *mut u8 = 0x3a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINA; + +impl PINA { +} + +impl Register for PINA { + type T = u8; + const ADDRESS: *mut u8 = 0x39 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x38 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x36 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADMUX; + +impl ADMUX { + pub const REFS: RegisterBits = RegisterBits::new(0xc0); + pub const REFS0: RegisterBits = RegisterBits::new(1<<6); + pub const REFS1: RegisterBits = RegisterBits::new(1<<7); + + pub const ADLAR: RegisterBits = RegisterBits::new(0x20); + pub const ADLAR0: RegisterBits = RegisterBits::new(1<<5); + + pub const MUX: RegisterBits = RegisterBits::new(0x1f); + pub const MUX0: RegisterBits = RegisterBits::new(1<<0); + pub const MUX1: RegisterBits = RegisterBits::new(1<<1); + pub const MUX2: RegisterBits = RegisterBits::new(1<<2); + pub const MUX3: RegisterBits = RegisterBits::new(1<<3); + pub const MUX4: RegisterBits = RegisterBits::new(1<<4); + +} + +impl Register for ADMUX { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADCSRA; + +impl ADCSRA { + pub const ADEN: RegisterBits = RegisterBits::new(0x80); + pub const ADEN0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADSC: RegisterBits = RegisterBits::new(0x40); + pub const ADSC0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADATE: RegisterBits = RegisterBits::new(0x20); + pub const ADATE0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADIF: RegisterBits = RegisterBits::new(0x10); + pub const ADIF0: RegisterBits = RegisterBits::new(1<<4); + + pub const ADIE: RegisterBits = RegisterBits::new(0x8); + pub const ADIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADPS: RegisterBits = RegisterBits::new(0x7); + pub const ADPS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADPS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADPS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x26 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x24 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ADCSRB; + +impl ADCSRB { + pub const BIN: RegisterBits = RegisterBits::new(0x80); + pub const BIN0: RegisterBits = RegisterBits::new(1<<7); + + pub const GSEL: RegisterBits = RegisterBits::new(0x40); + pub const GSEL0: RegisterBits = RegisterBits::new(1<<6); + + pub const IPR: RegisterBits = RegisterBits::new(0x20); + pub const IPR0: RegisterBits = RegisterBits::new(1<<5); + + pub const REFS2: RegisterBits = RegisterBits::new(0x10); + pub const REFS20: RegisterBits = RegisterBits::new(1<<4); + + pub const MUX5: RegisterBits = RegisterBits::new(0x8); + pub const MUX50: RegisterBits = RegisterBits::new(1<<3); + + pub const ADTS: RegisterBits = RegisterBits::new(0x7); + pub const ADTS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADTS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADTS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x23 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + pub const ADC10D: RegisterBits = RegisterBits::new(0x80); + pub const ADC10D0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADC9D: RegisterBits = RegisterBits::new(0x40); + pub const ADC9D0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADC8D: RegisterBits = RegisterBits::new(0x20); + pub const ADC8D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC7D: RegisterBits = RegisterBits::new(0x10); + pub const ADC7D0: RegisterBits = RegisterBits::new(1<<4); + +} + +impl Register for DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x22 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + pub const ADC6D: RegisterBits = RegisterBits::new(0x80); + pub const ADC6D0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADC5D: RegisterBits = RegisterBits::new(0x40); + pub const ADC5D0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADC4D: RegisterBits = RegisterBits::new(0x20); + pub const ADC4D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC3D: RegisterBits = RegisterBits::new(0x10); + pub const ADC3D0: RegisterBits = RegisterBits::new(1<<4); + + pub const AREFD: RegisterBits = RegisterBits::new(0x8); + pub const AREFD0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADC2D: RegisterBits = RegisterBits::new(0x4); + pub const ADC2D0: RegisterBits = RegisterBits::new(1<<2); + + pub const ADC1D: RegisterBits = RegisterBits::new(0x2); + pub const ADC1D0: RegisterBits = RegisterBits::new(1<<1); + + pub const ADC0D: RegisterBits = RegisterBits::new(0x1); + pub const ADC0D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for DIDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x21 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSRB; + +impl ACSRB { + pub const HSEL: RegisterBits = RegisterBits::new(0x80); + pub const HSEL0: RegisterBits = RegisterBits::new(1<<7); + + pub const HLEV: RegisterBits = RegisterBits::new(0x40); + pub const HLEV0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACM: RegisterBits = RegisterBits::new(0x7); + pub const ACM0: RegisterBits = RegisterBits::new(1<<0); + pub const ACM1: RegisterBits = RegisterBits::new(1<<1); + pub const ACM2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ACSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x29 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSRA; + +impl ACSRA { + pub const ACD: RegisterBits = RegisterBits::new(0x80); + pub const ACD0: RegisterBits = RegisterBits::new(1<<7); + + pub const ACBG: RegisterBits = RegisterBits::new(0x40); + pub const ACBG0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACO: RegisterBits = RegisterBits::new(0x20); + pub const ACO0: RegisterBits = RegisterBits::new(1<<5); + + pub const ACI: RegisterBits = RegisterBits::new(0x10); + pub const ACI0: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIE: RegisterBits = RegisterBits::new(0x8); + pub const ACIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ACME: RegisterBits = RegisterBits::new(0x4); + pub const ACME0: RegisterBits = RegisterBits::new(1<<2); + + pub const ACIS: RegisterBits = RegisterBits::new(0x3); + pub const ACIS0: RegisterBits = RegisterBits::new(1<<0); + pub const ACIS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for ACSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x28 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIPP; + +impl USIPP { +} + +impl Register for USIPP { + type T = u8; + const ADDRESS: *mut u8 = 0x31 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIBR; + +impl USIBR { +} + +impl Register for USIBR { + type T = u8; + const ADDRESS: *mut u8 = 0x30 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIDR; + +impl USIDR { +} + +impl Register for USIDR { + type T = u8; + const ADDRESS: *mut u8 = 0x2f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USISR; + +impl USISR { + pub const USISIF: RegisterBits = RegisterBits::new(0x80); + pub const USISIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIF: RegisterBits = RegisterBits::new(0x40); + pub const USIOIF0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIPF: RegisterBits = RegisterBits::new(0x20); + pub const USIPF0: RegisterBits = RegisterBits::new(1<<5); + + pub const USIDC: RegisterBits = RegisterBits::new(0x10); + pub const USIDC0: RegisterBits = RegisterBits::new(1<<4); + + pub const USICNT: RegisterBits = RegisterBits::new(0xf); + pub const USICNT0: RegisterBits = RegisterBits::new(1<<0); + pub const USICNT1: RegisterBits = RegisterBits::new(1<<1); + pub const USICNT2: RegisterBits = RegisterBits::new(1<<2); + pub const USICNT3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for USISR { + type T = u8; + const ADDRESS: *mut u8 = 0x2e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USICR; + +impl USICR { + pub const USISIE: RegisterBits = RegisterBits::new(0x80); + pub const USISIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIE: RegisterBits = RegisterBits::new(0x40); + pub const USIOIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIWM: RegisterBits = RegisterBits::new(0x30); + pub const USIWM0: RegisterBits = RegisterBits::new(1<<4); + pub const USIWM1: RegisterBits = RegisterBits::new(1<<5); + + pub const USICS: RegisterBits = RegisterBits::new(0xc); + pub const USICS0: RegisterBits = RegisterBits::new(1<<2); + pub const USICS1: RegisterBits = RegisterBits::new(1<<3); + + pub const USICLK: RegisterBits = RegisterBits::new(0x2); + pub const USICLK0: RegisterBits = RegisterBits::new(1<<1); + + pub const USITC: RegisterBits = RegisterBits::new(0x1); + pub const USITC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for USICR { + type T = u8; + const ADDRESS: *mut u8 = 0x2d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEAR; + +impl EEAR { +} + +impl Register for EEAR { + type T = u16; + const ADDRESS: *mut u16 = 0x3e as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct EEDR; + +impl EEDR { +} + +impl Register for EEDR { + type T = u8; + const ADDRESS: *mut u8 = 0x3d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EECR; + +impl EECR { + pub const EEPM: RegisterBits = RegisterBits::new(0x30); + pub const EEPM0: RegisterBits = RegisterBits::new(1<<4); + pub const EEPM1: RegisterBits = RegisterBits::new(1<<5); + + pub const EERIE: RegisterBits = RegisterBits::new(0x8); + pub const EERIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const EEMPE: RegisterBits = RegisterBits::new(0x4); + pub const EEMPE0: RegisterBits = RegisterBits::new(1<<2); + + pub const EEPE: RegisterBits = RegisterBits::new(0x2); + pub const EEPE0: RegisterBits = RegisterBits::new(1<<1); + + pub const EERE: RegisterBits = RegisterBits::new(0x1); + pub const EERE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EECR { + type T = u8; + const ADDRESS: *mut u8 = 0x3c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct WDTCR; + +impl WDTCR { + pub const WDIF: RegisterBits = RegisterBits::new(0x80); + pub const WDIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WDIE: RegisterBits = RegisterBits::new(0x40); + pub const WDIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const WDP: RegisterBits = RegisterBits::new(0x27); + pub const WDP0: RegisterBits = RegisterBits::new(1<<0); + pub const WDP1: RegisterBits = RegisterBits::new(1<<1); + pub const WDP2: RegisterBits = RegisterBits::new(1<<2); + pub const WDP3: RegisterBits = RegisterBits::new(1<<5); + + pub const WDCE: RegisterBits = RegisterBits::new(0x10); + pub const WDCE0: RegisterBits = RegisterBits::new(1<<4); + + pub const WDE: RegisterBits = RegisterBits::new(0x8); + pub const WDE0: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for WDTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x41 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE0A: RegisterBits = RegisterBits::new(0x10); + pub const OCIE0A0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCIE0B: RegisterBits = RegisterBits::new(0x8); + pub const OCIE0B0: RegisterBits = RegisterBits::new(1<<3); + + pub const TOIE0: RegisterBits = RegisterBits::new(0x2); + pub const TOIE00: RegisterBits = RegisterBits::new(1<<1); + + pub const TICIE0: RegisterBits = RegisterBits::new(0x1); + pub const TICIE00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF0A: RegisterBits = RegisterBits::new(0x10); + pub const OCF0A0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCF0B: RegisterBits = RegisterBits::new(0x8); + pub const OCF0B0: RegisterBits = RegisterBits::new(1<<3); + + pub const TOV0: RegisterBits = RegisterBits::new(0x2); + pub const TOV00: RegisterBits = RegisterBits::new(1<<1); + + pub const ICF0: RegisterBits = RegisterBits::new(0x1); + pub const ICF00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0A; + +impl TCCR0A { + pub const TCW0: RegisterBits = RegisterBits::new(0x80); + pub const TCW00: RegisterBits = RegisterBits::new(1<<7); + + pub const ICEN0: RegisterBits = RegisterBits::new(0x40); + pub const ICEN00: RegisterBits = RegisterBits::new(1<<6); + + pub const ICNC0: RegisterBits = RegisterBits::new(0x20); + pub const ICNC00: RegisterBits = RegisterBits::new(1<<5); + + pub const ICES0: RegisterBits = RegisterBits::new(0x10); + pub const ICES00: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIC0: RegisterBits = RegisterBits::new(0x8); + pub const ACIC00: RegisterBits = RegisterBits::new(1<<3); + + pub const WGM00: RegisterBits = RegisterBits::new(0x1); + pub const WGM000: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x35 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0B; + +impl TCCR0B { + pub const TSM: RegisterBits = RegisterBits::new(0x10); + pub const TSM0: RegisterBits = RegisterBits::new(1<<4); + + pub const PSR0: RegisterBits = RegisterBits::new(0x8); + pub const PSR00: RegisterBits = RegisterBits::new(1<<3); + + pub const CS0: RegisterBits = RegisterBits::new(0x7); + pub const CS00: RegisterBits = RegisterBits::new(1<<0); + pub const CS01: RegisterBits = RegisterBits::new(1<<1); + pub const CS02: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x53 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0H; + +impl TCNT0H { +} + +impl Register for TCNT0H { + type T = u8; + const ADDRESS: *mut u8 = 0x34 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0L; + +impl TCNT0L { +} + +impl Register for TCNT0L { + type T = u8; + const ADDRESS: *mut u8 = 0x52 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x33 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0B; + +impl OCR0B { +} + +impl Register for OCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x32 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1A; + +impl TCCR1A { + pub const COM1A: RegisterBits = RegisterBits::new(0xc0); + pub const COM1A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM1A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM1B: RegisterBits = RegisterBits::new(0x30); + pub const COM1B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM1B1: RegisterBits = RegisterBits::new(1<<5); + + pub const FOC1A: RegisterBits = RegisterBits::new(0x8); + pub const FOC1A0: RegisterBits = RegisterBits::new(1<<3); + + pub const FOC1B: RegisterBits = RegisterBits::new(0x4); + pub const FOC1B0: RegisterBits = RegisterBits::new(1<<2); + + pub const PWM1A: RegisterBits = RegisterBits::new(0x2); + pub const PWM1A0: RegisterBits = RegisterBits::new(1<<1); + + pub const PWM1B: RegisterBits = RegisterBits::new(0x1); + pub const PWM1B0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1B; + +impl TCCR1B { + pub const PSR1: RegisterBits = RegisterBits::new(0x40); + pub const PSR10: RegisterBits = RegisterBits::new(1<<6); + + pub const DTPS1: RegisterBits = RegisterBits::new(0x30); + pub const DTPS10: RegisterBits = RegisterBits::new(1<<4); + pub const DTPS11: RegisterBits = RegisterBits::new(1<<5); + + pub const CS1: RegisterBits = RegisterBits::new(0xf); + pub const CS10: RegisterBits = RegisterBits::new(1<<0); + pub const CS11: RegisterBits = RegisterBits::new(1<<1); + pub const CS12: RegisterBits = RegisterBits::new(1<<2); + pub const CS13: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for TCCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x4f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1C; + +impl TCCR1C { + pub const COM1A1S: RegisterBits = RegisterBits::new(0x80); + pub const COM1A1S0: RegisterBits = RegisterBits::new(1<<7); + + pub const COM1A0S: RegisterBits = RegisterBits::new(0x40); + pub const COM1A0S0: RegisterBits = RegisterBits::new(1<<6); + + pub const COM1B1S: RegisterBits = RegisterBits::new(0x20); + pub const COM1B1S0: RegisterBits = RegisterBits::new(1<<5); + + pub const COM1B0S: RegisterBits = RegisterBits::new(0x10); + pub const COM1B0S0: RegisterBits = RegisterBits::new(1<<4); + + pub const COM1D: RegisterBits = RegisterBits::new(0xc); + pub const COM1D0: RegisterBits = RegisterBits::new(1<<2); + pub const COM1D1: RegisterBits = RegisterBits::new(1<<3); + + pub const FOC1D: RegisterBits = RegisterBits::new(0x2); + pub const FOC1D0: RegisterBits = RegisterBits::new(1<<1); + + pub const PWM1D: RegisterBits = RegisterBits::new(0x1); + pub const PWM1D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x47 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1D; + +impl TCCR1D { + pub const FPIE1: RegisterBits = RegisterBits::new(0x80); + pub const FPIE10: RegisterBits = RegisterBits::new(1<<7); + + pub const FPEN1: RegisterBits = RegisterBits::new(0x40); + pub const FPEN10: RegisterBits = RegisterBits::new(1<<6); + + pub const FPNC1: RegisterBits = RegisterBits::new(0x20); + pub const FPNC10: RegisterBits = RegisterBits::new(1<<5); + + pub const FPES1: RegisterBits = RegisterBits::new(0x10); + pub const FPES10: RegisterBits = RegisterBits::new(1<<4); + + pub const FPAC1: RegisterBits = RegisterBits::new(0x8); + pub const FPAC10: RegisterBits = RegisterBits::new(1<<3); + + pub const FPF1: RegisterBits = RegisterBits::new(0x4); + pub const FPF10: RegisterBits = RegisterBits::new(1<<2); + + pub const WGM1: RegisterBits = RegisterBits::new(0x3); + pub const WGM10: RegisterBits = RegisterBits::new(1<<0); + pub const WGM11: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR1D { + type T = u8; + const ADDRESS: *mut u8 = 0x46 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1E; + +impl TCCR1E { + pub const OC1OE: RegisterBits = RegisterBits::new(0x3f); + pub const OC1OE0: RegisterBits = RegisterBits::new(1<<0); + pub const OC1OE1: RegisterBits = RegisterBits::new(1<<1); + pub const OC1OE2: RegisterBits = RegisterBits::new(1<<2); + pub const OC1OE3: RegisterBits = RegisterBits::new(1<<3); + pub const OC1OE4: RegisterBits = RegisterBits::new(1<<4); + pub const OC1OE5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for TCCR1E { + type T = u8; + const ADDRESS: *mut u8 = 0x20 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT1; + +impl TCNT1 { +} + +impl Register for TCNT1 { + type T = u8; + const ADDRESS: *mut u8 = 0x4e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TC1H; + +impl TC1H { +} + +impl Register for TC1H { + type T = u8; + const ADDRESS: *mut u8 = 0x45 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x4d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x4c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1C; + +impl OCR1C { +} + +impl Register for OCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x4b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1D; + +impl OCR1D { +} + +impl Register for OCR1D { + type T = u8; + const ADDRESS: *mut u8 = 0x4a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE1D: RegisterBits = RegisterBits::new(0x80); + pub const OCIE1D0: RegisterBits = RegisterBits::new(1<<7); + + pub const OCIE1A: RegisterBits = RegisterBits::new(0x40); + pub const OCIE1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x20); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const TOIE1: RegisterBits = RegisterBits::new(0x4); + pub const TOIE10: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF1D: RegisterBits = RegisterBits::new(0x80); + pub const OCF1D0: RegisterBits = RegisterBits::new(1<<7); + + pub const OCF1A: RegisterBits = RegisterBits::new(0x40); + pub const OCF1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x20); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const TOV1: RegisterBits = RegisterBits::new(0x4); + pub const TOV10: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DT1; + +impl DT1 { + pub const DT1H: RegisterBits = RegisterBits::new(0xf0); + pub const DT1H0: RegisterBits = RegisterBits::new(1<<4); + pub const DT1H1: RegisterBits = RegisterBits::new(1<<5); + pub const DT1H2: RegisterBits = RegisterBits::new(1<<6); + pub const DT1H3: RegisterBits = RegisterBits::new(1<<7); + + pub const DT1L: RegisterBits = RegisterBits::new(0xf); + pub const DT1L0: RegisterBits = RegisterBits::new(1<<0); + pub const DT1L1: RegisterBits = RegisterBits::new(1<<1); + pub const DT1L2: RegisterBits = RegisterBits::new(1<<2); + pub const DT1L3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for DT1 { + type T = u8; + const ADDRESS: *mut u8 = 0x44 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPMCSR; + +impl SPMCSR { + pub const CTPB: RegisterBits = RegisterBits::new(0x10); + pub const CTPB0: RegisterBits = RegisterBits::new(1<<4); + + pub const RFLB: RegisterBits = RegisterBits::new(0x8); + pub const RFLB0: RegisterBits = RegisterBits::new(1<<3); + + pub const PGWRT: RegisterBits = RegisterBits::new(0x4); + pub const PGWRT0: RegisterBits = RegisterBits::new(1<<2); + + pub const PGERS: RegisterBits = RegisterBits::new(0x2); + pub const PGERS0: RegisterBits = RegisterBits::new(1<<1); + + pub const SPMEN: RegisterBits = RegisterBits::new(0x1); + pub const SPMEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SPMCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x57 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SREG; + +impl SREG { + pub const I: RegisterBits = RegisterBits::new(0x80); + pub const I0: RegisterBits = RegisterBits::new(1<<7); + + pub const T: RegisterBits = RegisterBits::new(0x40); + pub const T0: RegisterBits = RegisterBits::new(1<<6); + + pub const H: RegisterBits = RegisterBits::new(0x20); + pub const H0: RegisterBits = RegisterBits::new(1<<5); + + pub const S: RegisterBits = RegisterBits::new(0x10); + pub const S0: RegisterBits = RegisterBits::new(1<<4); + + pub const V: RegisterBits = RegisterBits::new(0x8); + pub const V0: RegisterBits = RegisterBits::new(1<<3); + + pub const N: RegisterBits = RegisterBits::new(0x4); + pub const N0: RegisterBits = RegisterBits::new(1<<2); + + pub const Z: RegisterBits = RegisterBits::new(0x2); + pub const Z0: RegisterBits = RegisterBits::new(1<<1); + + pub const C: RegisterBits = RegisterBits::new(0x1); + pub const C0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SREG { + type T = u8; + const ADDRESS: *mut u8 = 0x5f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x4); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<2); + + pub const PRUSI: RegisterBits = RegisterBits::new(0x2); + pub const PRUSI0: RegisterBits = RegisterBits::new(1<<1); + + pub const PRADC: RegisterBits = RegisterBits::new(0x1); + pub const PRADC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PRR { + type T = u8; + const ADDRESS: *mut u8 = 0x56 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SP; + +impl SP { +} + +impl Register for SP { + type T = u16; + const ADDRESS: *mut u16 = 0x5d as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const PUD: RegisterBits = RegisterBits::new(0x40); + pub const PUD0: RegisterBits = RegisterBits::new(1<<6); + + pub const SE: RegisterBits = RegisterBits::new(0x20); + pub const SE0: RegisterBits = RegisterBits::new(1<<5); + + pub const SM: RegisterBits = RegisterBits::new(0x18); + pub const SM0: RegisterBits = RegisterBits::new(1<<3); + pub const SM1: RegisterBits = RegisterBits::new(1<<4); + + pub const ISC0: RegisterBits = RegisterBits::new(0x3); + pub const ISC00: RegisterBits = RegisterBits::new(1<<0); + pub const ISC01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUSR; + +impl MCUSR { + pub const WDRF: RegisterBits = RegisterBits::new(0x8); + pub const WDRF0: RegisterBits = RegisterBits::new(1<<3); + + pub const BORF: RegisterBits = RegisterBits::new(0x4); + pub const BORF0: RegisterBits = RegisterBits::new(1<<2); + + pub const EXTRF: RegisterBits = RegisterBits::new(0x2); + pub const EXTRF0: RegisterBits = RegisterBits::new(1<<1); + + pub const PORF: RegisterBits = RegisterBits::new(0x1); + pub const PORF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUSR { + type T = u8; + const ADDRESS: *mut u8 = 0x54 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCCAL; + +impl OSCCAL { + pub const OSCCAL: RegisterBits = RegisterBits::new(0xff); + pub const OSCCAL0: RegisterBits = RegisterBits::new(1<<0); + pub const OSCCAL1: RegisterBits = RegisterBits::new(1<<1); + pub const OSCCAL2: RegisterBits = RegisterBits::new(1<<2); + pub const OSCCAL3: RegisterBits = RegisterBits::new(1<<3); + pub const OSCCAL4: RegisterBits = RegisterBits::new(1<<4); + pub const OSCCAL5: RegisterBits = RegisterBits::new(1<<5); + pub const OSCCAL6: RegisterBits = RegisterBits::new(1<<6); + pub const OSCCAL7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OSCCAL { + type T = u8; + const ADDRESS: *mut u8 = 0x51 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKPR; + +impl CLKPR { + pub const CLKPCE: RegisterBits = RegisterBits::new(0x80); + pub const CLKPCE0: RegisterBits = RegisterBits::new(1<<7); + + pub const CLKPS: RegisterBits = RegisterBits::new(0xf); + pub const CLKPS0: RegisterBits = RegisterBits::new(1<<0); + pub const CLKPS1: RegisterBits = RegisterBits::new(1<<1); + pub const CLKPS2: RegisterBits = RegisterBits::new(1<<2); + pub const CLKPS3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CLKPR { + type T = u8; + const ADDRESS: *mut u8 = 0x48 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PLLCSR; + +impl PLLCSR { + pub const LSM: RegisterBits = RegisterBits::new(0x80); + pub const LSM0: RegisterBits = RegisterBits::new(1<<7); + + pub const PCKE: RegisterBits = RegisterBits::new(0x4); + pub const PCKE0: RegisterBits = RegisterBits::new(1<<2); + + pub const PLLE: RegisterBits = RegisterBits::new(0x2); + pub const PLLE0: RegisterBits = RegisterBits::new(1<<1); + + pub const PLOCK: RegisterBits = RegisterBits::new(0x1); + pub const PLOCK0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PLLCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x49 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DWDR; + +impl DWDR { +} + +impl Register for DWDR { + type T = u8; + const ADDRESS: *mut u8 = 0x40 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR2; + +impl GPIOR2 { +} + +impl Register for GPIOR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x2c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR1; + +impl GPIOR1 { +} + +impl Register for GPIOR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x2b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR0; + +impl GPIOR0 { +} + +impl Register for GPIOR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x2a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const ISC01: RegisterBits = RegisterBits::new(0x2); + pub const ISC010: RegisterBits = RegisterBits::new(1<<1); + + pub const ISC00: RegisterBits = RegisterBits::new(0x1); + pub const ISC000: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIMSK; + +impl GIMSK { + pub const INT: RegisterBits = RegisterBits::new(0xc0); + pub const INT0: RegisterBits = RegisterBits::new(1<<6); + pub const INT1: RegisterBits = RegisterBits::new(1<<7); + + pub const PCIE: RegisterBits = RegisterBits::new(0x30); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<4); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x5b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIFR; + +impl GIFR { + pub const INTF: RegisterBits = RegisterBits::new(0xc0); + pub const INTF0: RegisterBits = RegisterBits::new(1<<6); + pub const INTF1: RegisterBits = RegisterBits::new(1<<7); + + pub const PCIF: RegisterBits = RegisterBits::new(0x20); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x5a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { +} + +impl Register for PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x42 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK0; + +impl PCMSK0 { +} + +impl Register for PCMSK0 { + type T = u8; + const ADDRESS: *mut u8 = 0x43 as *mut u8; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + + pub struct A0; + + impl Pin for A0 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA0 + const MASK: u8 = 1<<0; + } + + pub struct A1; + + impl Pin for A1 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA1 + const MASK: u8 = 1<<1; + } + + pub struct A2; + + impl Pin for A2 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA2 + const MASK: u8 = 1<<2; + } + + pub struct A3; + + impl Pin for A3 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA3 + const MASK: u8 = 1<<3; + } + + pub struct A4; + + impl Pin for A4 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA4 + const MASK: u8 = 1<<4; + } + + pub struct A5; + + impl Pin for A5 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA5 + const MASK: u8 = 1<<5; + } + + pub struct A6; + + impl Pin for A6 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA6 + const MASK: u8 = 1<<6; + } + + pub struct A7; + + impl Pin for A7 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA7 + const MASK: u8 = 1<<7; + } + + pub struct B0; + + impl Pin for B0 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB0 + const MASK: u8 = 1<<0; + } + + pub struct B1; + + impl Pin for B1 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB1 + const MASK: u8 = 1<<1; + } + + pub struct B2; + + impl Pin for B2 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB2 + const MASK: u8 = 1<<2; + } + + pub struct B3; + + impl Pin for B3 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB3 + const MASK: u8 = 1<<3; + } + + pub struct B4; + + impl Pin for B4 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB4 + const MASK: u8 = 1<<4; + } + + pub struct B5; + + impl Pin for B5 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB5 + const MASK: u8 = 1<<5; + } + + pub struct B6; + + impl Pin for B6 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB6 + const MASK: u8 = 1<<6; + } + + pub struct B7; + + impl Pin for B7 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB7 + const MASK: u8 = 1<<7; + } + +} + +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR0A; + type CompareB = OCR0B; + type Counter = TCNT0H; + type ControlA = TCCR0A; + type ControlB = TCCR0B; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE0A; +} +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR1A; + type CompareB = OCR1B; + type Counter = TCNT1; + type ControlA = TCCR1A; + type ControlB = TCCR1B; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE1A; +} + diff --git a/src/cores/attiny461a.rs b/src/cores/attiny461a.rs new file mode 100644 index 0000000..df928bd --- /dev/null +++ b/src/cores/attiny461a.rs @@ -0,0 +1,1269 @@ +//! Core for ATtiny461A. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + pub const SELFPRGEN: RegisterBits = RegisterBits::new(0x1); + pub const SELFPRGEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EXTENDED { + type T = u8; + const ADDRESS: *mut u8 = 0x2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct HIGH; + +impl HIGH { + pub const RSTDISBL: RegisterBits = RegisterBits::new(0x80); + pub const RSTDISBL0: RegisterBits = RegisterBits::new(1<<7); + + pub const DWEN: RegisterBits = RegisterBits::new(0x40); + pub const DWEN0: RegisterBits = RegisterBits::new(1<<6); + + pub const SPIEN: RegisterBits = RegisterBits::new(0x20); + pub const SPIEN0: RegisterBits = RegisterBits::new(1<<5); + + pub const WDTON: RegisterBits = RegisterBits::new(0x10); + pub const WDTON0: RegisterBits = RegisterBits::new(1<<4); + + pub const EESAVE: RegisterBits = RegisterBits::new(0x8); + pub const EESAVE0: RegisterBits = RegisterBits::new(1<<3); + + pub const BODLEVEL: RegisterBits = RegisterBits::new(0x7); + pub const BODLEVEL0: RegisterBits = RegisterBits::new(1<<0); + pub const BODLEVEL1: RegisterBits = RegisterBits::new(1<<1); + pub const BODLEVEL2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for HIGH { + type T = u8; + const ADDRESS: *mut u8 = 0x1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOW; + +impl LOW { + pub const CKDIV8: RegisterBits = RegisterBits::new(0x80); + pub const CKDIV80: RegisterBits = RegisterBits::new(1<<7); + + pub const CKOUT: RegisterBits = RegisterBits::new(0x40); + pub const CKOUT0: RegisterBits = RegisterBits::new(1<<6); + + pub const SUT_CKSEL: RegisterBits = RegisterBits::new(0x3f); + pub const SUT_CKSEL0: RegisterBits = RegisterBits::new(1<<0); + pub const SUT_CKSEL1: RegisterBits = RegisterBits::new(1<<1); + pub const SUT_CKSEL2: RegisterBits = RegisterBits::new(1<<2); + pub const SUT_CKSEL3: RegisterBits = RegisterBits::new(1<<3); + pub const SUT_CKSEL4: RegisterBits = RegisterBits::new(1<<4); + pub const SUT_CKSEL5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for LOW { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOCKBIT; + +impl LOCKBIT { + pub const LB: RegisterBits = RegisterBits::new(0x3); + pub const LB0: RegisterBits = RegisterBits::new(1<<0); + pub const LB1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for LOCKBIT { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTA; + +impl PORTA { +} + +impl Register for PORTA { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRA; + +impl DDRA { +} + +impl Register for DDRA { + type T = u8; + const ADDRESS: *mut u8 = 0x3a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINA; + +impl PINA { +} + +impl Register for PINA { + type T = u8; + const ADDRESS: *mut u8 = 0x39 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x38 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x36 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADMUX; + +impl ADMUX { + pub const REFS: RegisterBits = RegisterBits::new(0xc0); + pub const REFS0: RegisterBits = RegisterBits::new(1<<6); + pub const REFS1: RegisterBits = RegisterBits::new(1<<7); + + pub const ADLAR: RegisterBits = RegisterBits::new(0x20); + pub const ADLAR0: RegisterBits = RegisterBits::new(1<<5); + + pub const MUX: RegisterBits = RegisterBits::new(0x1f); + pub const MUX0: RegisterBits = RegisterBits::new(1<<0); + pub const MUX1: RegisterBits = RegisterBits::new(1<<1); + pub const MUX2: RegisterBits = RegisterBits::new(1<<2); + pub const MUX3: RegisterBits = RegisterBits::new(1<<3); + pub const MUX4: RegisterBits = RegisterBits::new(1<<4); + +} + +impl Register for ADMUX { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADCSRA; + +impl ADCSRA { + pub const ADEN: RegisterBits = RegisterBits::new(0x80); + pub const ADEN0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADSC: RegisterBits = RegisterBits::new(0x40); + pub const ADSC0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADATE: RegisterBits = RegisterBits::new(0x20); + pub const ADATE0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADIF: RegisterBits = RegisterBits::new(0x10); + pub const ADIF0: RegisterBits = RegisterBits::new(1<<4); + + pub const ADIE: RegisterBits = RegisterBits::new(0x8); + pub const ADIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADPS: RegisterBits = RegisterBits::new(0x7); + pub const ADPS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADPS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADPS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x26 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x24 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ADCSRB; + +impl ADCSRB { + pub const BIN: RegisterBits = RegisterBits::new(0x80); + pub const BIN0: RegisterBits = RegisterBits::new(1<<7); + + pub const GSEL: RegisterBits = RegisterBits::new(0x40); + pub const GSEL0: RegisterBits = RegisterBits::new(1<<6); + + pub const IPR: RegisterBits = RegisterBits::new(0x20); + pub const IPR0: RegisterBits = RegisterBits::new(1<<5); + + pub const REFS2: RegisterBits = RegisterBits::new(0x10); + pub const REFS20: RegisterBits = RegisterBits::new(1<<4); + + pub const MUX5: RegisterBits = RegisterBits::new(0x8); + pub const MUX50: RegisterBits = RegisterBits::new(1<<3); + + pub const ADTS: RegisterBits = RegisterBits::new(0x7); + pub const ADTS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADTS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADTS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x23 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + pub const ADC10D: RegisterBits = RegisterBits::new(0x80); + pub const ADC10D0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADC9D: RegisterBits = RegisterBits::new(0x40); + pub const ADC9D0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADC8D: RegisterBits = RegisterBits::new(0x20); + pub const ADC8D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC7D: RegisterBits = RegisterBits::new(0x10); + pub const ADC7D0: RegisterBits = RegisterBits::new(1<<4); + +} + +impl Register for DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x22 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + pub const ADC6D: RegisterBits = RegisterBits::new(0x80); + pub const ADC6D0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADC5D: RegisterBits = RegisterBits::new(0x40); + pub const ADC5D0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADC4D: RegisterBits = RegisterBits::new(0x20); + pub const ADC4D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC3D: RegisterBits = RegisterBits::new(0x10); + pub const ADC3D0: RegisterBits = RegisterBits::new(1<<4); + + pub const AREFD: RegisterBits = RegisterBits::new(0x8); + pub const AREFD0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADC2D: RegisterBits = RegisterBits::new(0x4); + pub const ADC2D0: RegisterBits = RegisterBits::new(1<<2); + + pub const ADC1D: RegisterBits = RegisterBits::new(0x2); + pub const ADC1D0: RegisterBits = RegisterBits::new(1<<1); + + pub const ADC0D: RegisterBits = RegisterBits::new(0x1); + pub const ADC0D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for DIDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x21 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSRB; + +impl ACSRB { + pub const HSEL: RegisterBits = RegisterBits::new(0x80); + pub const HSEL0: RegisterBits = RegisterBits::new(1<<7); + + pub const HLEV: RegisterBits = RegisterBits::new(0x40); + pub const HLEV0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACM: RegisterBits = RegisterBits::new(0x7); + pub const ACM0: RegisterBits = RegisterBits::new(1<<0); + pub const ACM1: RegisterBits = RegisterBits::new(1<<1); + pub const ACM2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ACSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x29 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSRA; + +impl ACSRA { + pub const ACD: RegisterBits = RegisterBits::new(0x80); + pub const ACD0: RegisterBits = RegisterBits::new(1<<7); + + pub const ACBG: RegisterBits = RegisterBits::new(0x40); + pub const ACBG0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACO: RegisterBits = RegisterBits::new(0x20); + pub const ACO0: RegisterBits = RegisterBits::new(1<<5); + + pub const ACI: RegisterBits = RegisterBits::new(0x10); + pub const ACI0: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIE: RegisterBits = RegisterBits::new(0x8); + pub const ACIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ACME: RegisterBits = RegisterBits::new(0x4); + pub const ACME0: RegisterBits = RegisterBits::new(1<<2); + + pub const ACIS: RegisterBits = RegisterBits::new(0x3); + pub const ACIS0: RegisterBits = RegisterBits::new(1<<0); + pub const ACIS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for ACSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x28 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIPP; + +impl USIPP { +} + +impl Register for USIPP { + type T = u8; + const ADDRESS: *mut u8 = 0x31 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIBR; + +impl USIBR { +} + +impl Register for USIBR { + type T = u8; + const ADDRESS: *mut u8 = 0x30 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIDR; + +impl USIDR { +} + +impl Register for USIDR { + type T = u8; + const ADDRESS: *mut u8 = 0x2f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USISR; + +impl USISR { + pub const USISIF: RegisterBits = RegisterBits::new(0x80); + pub const USISIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIF: RegisterBits = RegisterBits::new(0x40); + pub const USIOIF0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIPF: RegisterBits = RegisterBits::new(0x20); + pub const USIPF0: RegisterBits = RegisterBits::new(1<<5); + + pub const USIDC: RegisterBits = RegisterBits::new(0x10); + pub const USIDC0: RegisterBits = RegisterBits::new(1<<4); + + pub const USICNT: RegisterBits = RegisterBits::new(0xf); + pub const USICNT0: RegisterBits = RegisterBits::new(1<<0); + pub const USICNT1: RegisterBits = RegisterBits::new(1<<1); + pub const USICNT2: RegisterBits = RegisterBits::new(1<<2); + pub const USICNT3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for USISR { + type T = u8; + const ADDRESS: *mut u8 = 0x2e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USICR; + +impl USICR { + pub const USISIE: RegisterBits = RegisterBits::new(0x80); + pub const USISIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIE: RegisterBits = RegisterBits::new(0x40); + pub const USIOIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIWM: RegisterBits = RegisterBits::new(0x30); + pub const USIWM0: RegisterBits = RegisterBits::new(1<<4); + pub const USIWM1: RegisterBits = RegisterBits::new(1<<5); + + pub const USICS: RegisterBits = RegisterBits::new(0xc); + pub const USICS0: RegisterBits = RegisterBits::new(1<<2); + pub const USICS1: RegisterBits = RegisterBits::new(1<<3); + + pub const USICLK: RegisterBits = RegisterBits::new(0x2); + pub const USICLK0: RegisterBits = RegisterBits::new(1<<1); + + pub const USITC: RegisterBits = RegisterBits::new(0x1); + pub const USITC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for USICR { + type T = u8; + const ADDRESS: *mut u8 = 0x2d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEAR; + +impl EEAR { +} + +impl Register for EEAR { + type T = u16; + const ADDRESS: *mut u16 = 0x3e as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct EEDR; + +impl EEDR { +} + +impl Register for EEDR { + type T = u8; + const ADDRESS: *mut u8 = 0x3d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EECR; + +impl EECR { + pub const EEPM: RegisterBits = RegisterBits::new(0x30); + pub const EEPM0: RegisterBits = RegisterBits::new(1<<4); + pub const EEPM1: RegisterBits = RegisterBits::new(1<<5); + + pub const EERIE: RegisterBits = RegisterBits::new(0x8); + pub const EERIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const EEMPE: RegisterBits = RegisterBits::new(0x4); + pub const EEMPE0: RegisterBits = RegisterBits::new(1<<2); + + pub const EEPE: RegisterBits = RegisterBits::new(0x2); + pub const EEPE0: RegisterBits = RegisterBits::new(1<<1); + + pub const EERE: RegisterBits = RegisterBits::new(0x1); + pub const EERE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EECR { + type T = u8; + const ADDRESS: *mut u8 = 0x3c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct WDTCR; + +impl WDTCR { + pub const WDIF: RegisterBits = RegisterBits::new(0x80); + pub const WDIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WDIE: RegisterBits = RegisterBits::new(0x40); + pub const WDIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const WDP: RegisterBits = RegisterBits::new(0x27); + pub const WDP0: RegisterBits = RegisterBits::new(1<<0); + pub const WDP1: RegisterBits = RegisterBits::new(1<<1); + pub const WDP2: RegisterBits = RegisterBits::new(1<<2); + pub const WDP3: RegisterBits = RegisterBits::new(1<<5); + + pub const WDCE: RegisterBits = RegisterBits::new(0x10); + pub const WDCE0: RegisterBits = RegisterBits::new(1<<4); + + pub const WDE: RegisterBits = RegisterBits::new(0x8); + pub const WDE0: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for WDTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x41 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE0A: RegisterBits = RegisterBits::new(0x10); + pub const OCIE0A0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCIE0B: RegisterBits = RegisterBits::new(0x8); + pub const OCIE0B0: RegisterBits = RegisterBits::new(1<<3); + + pub const TOIE0: RegisterBits = RegisterBits::new(0x2); + pub const TOIE00: RegisterBits = RegisterBits::new(1<<1); + + pub const TICIE0: RegisterBits = RegisterBits::new(0x1); + pub const TICIE00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF0A: RegisterBits = RegisterBits::new(0x10); + pub const OCF0A0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCF0B: RegisterBits = RegisterBits::new(0x8); + pub const OCF0B0: RegisterBits = RegisterBits::new(1<<3); + + pub const TOV0: RegisterBits = RegisterBits::new(0x2); + pub const TOV00: RegisterBits = RegisterBits::new(1<<1); + + pub const ICF0: RegisterBits = RegisterBits::new(0x1); + pub const ICF00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0A; + +impl TCCR0A { + pub const TCW0: RegisterBits = RegisterBits::new(0x80); + pub const TCW00: RegisterBits = RegisterBits::new(1<<7); + + pub const ICEN0: RegisterBits = RegisterBits::new(0x40); + pub const ICEN00: RegisterBits = RegisterBits::new(1<<6); + + pub const ICNC0: RegisterBits = RegisterBits::new(0x20); + pub const ICNC00: RegisterBits = RegisterBits::new(1<<5); + + pub const ICES0: RegisterBits = RegisterBits::new(0x10); + pub const ICES00: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIC0: RegisterBits = RegisterBits::new(0x8); + pub const ACIC00: RegisterBits = RegisterBits::new(1<<3); + + pub const WGM00: RegisterBits = RegisterBits::new(0x1); + pub const WGM000: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x35 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0B; + +impl TCCR0B { + pub const TSM: RegisterBits = RegisterBits::new(0x10); + pub const TSM0: RegisterBits = RegisterBits::new(1<<4); + + pub const PSR0: RegisterBits = RegisterBits::new(0x8); + pub const PSR00: RegisterBits = RegisterBits::new(1<<3); + + pub const CS0: RegisterBits = RegisterBits::new(0x7); + pub const CS00: RegisterBits = RegisterBits::new(1<<0); + pub const CS01: RegisterBits = RegisterBits::new(1<<1); + pub const CS02: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x53 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0H; + +impl TCNT0H { +} + +impl Register for TCNT0H { + type T = u8; + const ADDRESS: *mut u8 = 0x34 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0L; + +impl TCNT0L { +} + +impl Register for TCNT0L { + type T = u8; + const ADDRESS: *mut u8 = 0x52 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x33 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0B; + +impl OCR0B { +} + +impl Register for OCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x32 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1A; + +impl TCCR1A { + pub const COM1A: RegisterBits = RegisterBits::new(0xc0); + pub const COM1A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM1A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM1B: RegisterBits = RegisterBits::new(0x30); + pub const COM1B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM1B1: RegisterBits = RegisterBits::new(1<<5); + + pub const FOC1A: RegisterBits = RegisterBits::new(0x8); + pub const FOC1A0: RegisterBits = RegisterBits::new(1<<3); + + pub const FOC1B: RegisterBits = RegisterBits::new(0x4); + pub const FOC1B0: RegisterBits = RegisterBits::new(1<<2); + + pub const PWM1A: RegisterBits = RegisterBits::new(0x2); + pub const PWM1A0: RegisterBits = RegisterBits::new(1<<1); + + pub const PWM1B: RegisterBits = RegisterBits::new(0x1); + pub const PWM1B0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1B; + +impl TCCR1B { + pub const PWM1X: RegisterBits = RegisterBits::new(0x80); + pub const PWM1X0: RegisterBits = RegisterBits::new(1<<7); + + pub const PSR1: RegisterBits = RegisterBits::new(0x40); + pub const PSR10: RegisterBits = RegisterBits::new(1<<6); + + pub const DTPS1: RegisterBits = RegisterBits::new(0x30); + pub const DTPS10: RegisterBits = RegisterBits::new(1<<4); + pub const DTPS11: RegisterBits = RegisterBits::new(1<<5); + + pub const CS1: RegisterBits = RegisterBits::new(0xf); + pub const CS10: RegisterBits = RegisterBits::new(1<<0); + pub const CS11: RegisterBits = RegisterBits::new(1<<1); + pub const CS12: RegisterBits = RegisterBits::new(1<<2); + pub const CS13: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for TCCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x4f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1C; + +impl TCCR1C { + pub const COM1A1S: RegisterBits = RegisterBits::new(0x80); + pub const COM1A1S0: RegisterBits = RegisterBits::new(1<<7); + + pub const COM1A0S: RegisterBits = RegisterBits::new(0x40); + pub const COM1A0S0: RegisterBits = RegisterBits::new(1<<6); + + pub const COM1B1S: RegisterBits = RegisterBits::new(0x20); + pub const COM1B1S0: RegisterBits = RegisterBits::new(1<<5); + + pub const COM1B0S: RegisterBits = RegisterBits::new(0x10); + pub const COM1B0S0: RegisterBits = RegisterBits::new(1<<4); + + pub const COM1D: RegisterBits = RegisterBits::new(0xc); + pub const COM1D0: RegisterBits = RegisterBits::new(1<<2); + pub const COM1D1: RegisterBits = RegisterBits::new(1<<3); + + pub const FOC1D: RegisterBits = RegisterBits::new(0x2); + pub const FOC1D0: RegisterBits = RegisterBits::new(1<<1); + + pub const PWM1D: RegisterBits = RegisterBits::new(0x1); + pub const PWM1D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x47 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1D; + +impl TCCR1D { + pub const FPIE1: RegisterBits = RegisterBits::new(0x80); + pub const FPIE10: RegisterBits = RegisterBits::new(1<<7); + + pub const FPEN1: RegisterBits = RegisterBits::new(0x40); + pub const FPEN10: RegisterBits = RegisterBits::new(1<<6); + + pub const FPNC1: RegisterBits = RegisterBits::new(0x20); + pub const FPNC10: RegisterBits = RegisterBits::new(1<<5); + + pub const FPES1: RegisterBits = RegisterBits::new(0x10); + pub const FPES10: RegisterBits = RegisterBits::new(1<<4); + + pub const FPAC1: RegisterBits = RegisterBits::new(0x8); + pub const FPAC10: RegisterBits = RegisterBits::new(1<<3); + + pub const FPF1: RegisterBits = RegisterBits::new(0x4); + pub const FPF10: RegisterBits = RegisterBits::new(1<<2); + + pub const WGM1: RegisterBits = RegisterBits::new(0x3); + pub const WGM10: RegisterBits = RegisterBits::new(1<<0); + pub const WGM11: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR1D { + type T = u8; + const ADDRESS: *mut u8 = 0x46 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1E; + +impl TCCR1E { + pub const OC1OE: RegisterBits = RegisterBits::new(0x3f); + pub const OC1OE0: RegisterBits = RegisterBits::new(1<<0); + pub const OC1OE1: RegisterBits = RegisterBits::new(1<<1); + pub const OC1OE2: RegisterBits = RegisterBits::new(1<<2); + pub const OC1OE3: RegisterBits = RegisterBits::new(1<<3); + pub const OC1OE4: RegisterBits = RegisterBits::new(1<<4); + pub const OC1OE5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for TCCR1E { + type T = u8; + const ADDRESS: *mut u8 = 0x20 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT1; + +impl TCNT1 { +} + +impl Register for TCNT1 { + type T = u8; + const ADDRESS: *mut u8 = 0x4e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TC1H; + +impl TC1H { +} + +impl Register for TC1H { + type T = u8; + const ADDRESS: *mut u8 = 0x45 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x4d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x4c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1C; + +impl OCR1C { +} + +impl Register for OCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x4b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1D; + +impl OCR1D { +} + +impl Register for OCR1D { + type T = u8; + const ADDRESS: *mut u8 = 0x4a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE1D: RegisterBits = RegisterBits::new(0x80); + pub const OCIE1D0: RegisterBits = RegisterBits::new(1<<7); + + pub const OCIE1A: RegisterBits = RegisterBits::new(0x40); + pub const OCIE1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x20); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const TOIE1: RegisterBits = RegisterBits::new(0x4); + pub const TOIE10: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF1D: RegisterBits = RegisterBits::new(0x80); + pub const OCF1D0: RegisterBits = RegisterBits::new(1<<7); + + pub const OCF1A: RegisterBits = RegisterBits::new(0x40); + pub const OCF1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x20); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const TOV1: RegisterBits = RegisterBits::new(0x4); + pub const TOV10: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DT1; + +impl DT1 { + pub const DT1H: RegisterBits = RegisterBits::new(0xf0); + pub const DT1H0: RegisterBits = RegisterBits::new(1<<4); + pub const DT1H1: RegisterBits = RegisterBits::new(1<<5); + pub const DT1H2: RegisterBits = RegisterBits::new(1<<6); + pub const DT1H3: RegisterBits = RegisterBits::new(1<<7); + + pub const DT1L: RegisterBits = RegisterBits::new(0xf); + pub const DT1L0: RegisterBits = RegisterBits::new(1<<0); + pub const DT1L1: RegisterBits = RegisterBits::new(1<<1); + pub const DT1L2: RegisterBits = RegisterBits::new(1<<2); + pub const DT1L3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for DT1 { + type T = u8; + const ADDRESS: *mut u8 = 0x44 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPMCSR; + +impl SPMCSR { + pub const CTPB: RegisterBits = RegisterBits::new(0x10); + pub const CTPB0: RegisterBits = RegisterBits::new(1<<4); + + pub const RFLB: RegisterBits = RegisterBits::new(0x8); + pub const RFLB0: RegisterBits = RegisterBits::new(1<<3); + + pub const PGWRT: RegisterBits = RegisterBits::new(0x4); + pub const PGWRT0: RegisterBits = RegisterBits::new(1<<2); + + pub const PGERS: RegisterBits = RegisterBits::new(0x2); + pub const PGERS0: RegisterBits = RegisterBits::new(1<<1); + + pub const SPMEN: RegisterBits = RegisterBits::new(0x1); + pub const SPMEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SPMCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x57 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SREG; + +impl SREG { + pub const I: RegisterBits = RegisterBits::new(0x80); + pub const I0: RegisterBits = RegisterBits::new(1<<7); + + pub const T: RegisterBits = RegisterBits::new(0x40); + pub const T0: RegisterBits = RegisterBits::new(1<<6); + + pub const H: RegisterBits = RegisterBits::new(0x20); + pub const H0: RegisterBits = RegisterBits::new(1<<5); + + pub const S: RegisterBits = RegisterBits::new(0x10); + pub const S0: RegisterBits = RegisterBits::new(1<<4); + + pub const V: RegisterBits = RegisterBits::new(0x8); + pub const V0: RegisterBits = RegisterBits::new(1<<3); + + pub const N: RegisterBits = RegisterBits::new(0x4); + pub const N0: RegisterBits = RegisterBits::new(1<<2); + + pub const Z: RegisterBits = RegisterBits::new(0x2); + pub const Z0: RegisterBits = RegisterBits::new(1<<1); + + pub const C: RegisterBits = RegisterBits::new(0x1); + pub const C0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SREG { + type T = u8; + const ADDRESS: *mut u8 = 0x5f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x4); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<2); + + pub const PRUSI: RegisterBits = RegisterBits::new(0x2); + pub const PRUSI0: RegisterBits = RegisterBits::new(1<<1); + + pub const PRADC: RegisterBits = RegisterBits::new(0x1); + pub const PRADC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PRR { + type T = u8; + const ADDRESS: *mut u8 = 0x56 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SP; + +impl SP { +} + +impl Register for SP { + type T = u16; + const ADDRESS: *mut u16 = 0x5d as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const BODS: RegisterBits = RegisterBits::new(0x80); + pub const BODS0: RegisterBits = RegisterBits::new(1<<7); + + pub const PUD: RegisterBits = RegisterBits::new(0x40); + pub const PUD0: RegisterBits = RegisterBits::new(1<<6); + + pub const SE: RegisterBits = RegisterBits::new(0x20); + pub const SE0: RegisterBits = RegisterBits::new(1<<5); + + pub const SM: RegisterBits = RegisterBits::new(0x18); + pub const SM0: RegisterBits = RegisterBits::new(1<<3); + pub const SM1: RegisterBits = RegisterBits::new(1<<4); + + pub const BODSE: RegisterBits = RegisterBits::new(0x4); + pub const BODSE0: RegisterBits = RegisterBits::new(1<<2); + + pub const ISC0: RegisterBits = RegisterBits::new(0x3); + pub const ISC00: RegisterBits = RegisterBits::new(1<<0); + pub const ISC01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUSR; + +impl MCUSR { + pub const WDRF: RegisterBits = RegisterBits::new(0x8); + pub const WDRF0: RegisterBits = RegisterBits::new(1<<3); + + pub const BORF: RegisterBits = RegisterBits::new(0x4); + pub const BORF0: RegisterBits = RegisterBits::new(1<<2); + + pub const EXTRF: RegisterBits = RegisterBits::new(0x2); + pub const EXTRF0: RegisterBits = RegisterBits::new(1<<1); + + pub const PORF: RegisterBits = RegisterBits::new(0x1); + pub const PORF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUSR { + type T = u8; + const ADDRESS: *mut u8 = 0x54 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCCAL; + +impl OSCCAL { + pub const OSCCAL: RegisterBits = RegisterBits::new(0xff); + pub const OSCCAL0: RegisterBits = RegisterBits::new(1<<0); + pub const OSCCAL1: RegisterBits = RegisterBits::new(1<<1); + pub const OSCCAL2: RegisterBits = RegisterBits::new(1<<2); + pub const OSCCAL3: RegisterBits = RegisterBits::new(1<<3); + pub const OSCCAL4: RegisterBits = RegisterBits::new(1<<4); + pub const OSCCAL5: RegisterBits = RegisterBits::new(1<<5); + pub const OSCCAL6: RegisterBits = RegisterBits::new(1<<6); + pub const OSCCAL7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OSCCAL { + type T = u8; + const ADDRESS: *mut u8 = 0x51 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKPR; + +impl CLKPR { + pub const CLKPCE: RegisterBits = RegisterBits::new(0x80); + pub const CLKPCE0: RegisterBits = RegisterBits::new(1<<7); + + pub const CLKPS: RegisterBits = RegisterBits::new(0xf); + pub const CLKPS0: RegisterBits = RegisterBits::new(1<<0); + pub const CLKPS1: RegisterBits = RegisterBits::new(1<<1); + pub const CLKPS2: RegisterBits = RegisterBits::new(1<<2); + pub const CLKPS3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CLKPR { + type T = u8; + const ADDRESS: *mut u8 = 0x48 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PLLCSR; + +impl PLLCSR { + pub const LSM: RegisterBits = RegisterBits::new(0x80); + pub const LSM0: RegisterBits = RegisterBits::new(1<<7); + + pub const PCKE: RegisterBits = RegisterBits::new(0x4); + pub const PCKE0: RegisterBits = RegisterBits::new(1<<2); + + pub const PLLE: RegisterBits = RegisterBits::new(0x2); + pub const PLLE0: RegisterBits = RegisterBits::new(1<<1); + + pub const PLOCK: RegisterBits = RegisterBits::new(0x1); + pub const PLOCK0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PLLCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x49 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DWDR; + +impl DWDR { +} + +impl Register for DWDR { + type T = u8; + const ADDRESS: *mut u8 = 0x40 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR2; + +impl GPIOR2 { +} + +impl Register for GPIOR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x2c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR1; + +impl GPIOR1 { +} + +impl Register for GPIOR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x2b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR0; + +impl GPIOR0 { +} + +impl Register for GPIOR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x2a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const ISC01: RegisterBits = RegisterBits::new(0x2); + pub const ISC010: RegisterBits = RegisterBits::new(1<<1); + + pub const ISC00: RegisterBits = RegisterBits::new(0x1); + pub const ISC000: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIMSK; + +impl GIMSK { + pub const INT: RegisterBits = RegisterBits::new(0xc0); + pub const INT0: RegisterBits = RegisterBits::new(1<<6); + pub const INT1: RegisterBits = RegisterBits::new(1<<7); + + pub const PCIE: RegisterBits = RegisterBits::new(0x30); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<4); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x5b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIFR; + +impl GIFR { + pub const INTF: RegisterBits = RegisterBits::new(0xc0); + pub const INTF0: RegisterBits = RegisterBits::new(1<<6); + pub const INTF1: RegisterBits = RegisterBits::new(1<<7); + + pub const PCIF: RegisterBits = RegisterBits::new(0x20); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x5a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { +} + +impl Register for PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x42 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK0; + +impl PCMSK0 { +} + +impl Register for PCMSK0 { + type T = u8; + const ADDRESS: *mut u8 = 0x43 as *mut u8; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + +} + +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR0A; + type CompareB = OCR0B; + type Counter = TCNT0H; + type ControlA = TCCR0A; + type ControlB = TCCR0B; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE0A; +} +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR1A; + type CompareB = OCR1B; + type Counter = TCNT1; + type ControlA = TCCR1A; + type ControlB = TCCR1B; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE1A; +} + diff --git a/src/cores/attiny85.rs b/src/cores/attiny85.rs new file mode 100644 index 0000000..3b20183 --- /dev/null +++ b/src/cores/attiny85.rs @@ -0,0 +1,1115 @@ +//! Core for ATtiny85. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + pub const SELFPRGEN: RegisterBits = RegisterBits::new(0x1); + pub const SELFPRGEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EXTENDED { + type T = u8; + const ADDRESS: *mut u8 = 0x2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct HIGH; + +impl HIGH { + pub const RSTDISBL: RegisterBits = RegisterBits::new(0x80); + pub const RSTDISBL0: RegisterBits = RegisterBits::new(1<<7); + + pub const DWEN: RegisterBits = RegisterBits::new(0x40); + pub const DWEN0: RegisterBits = RegisterBits::new(1<<6); + + pub const SPIEN: RegisterBits = RegisterBits::new(0x20); + pub const SPIEN0: RegisterBits = RegisterBits::new(1<<5); + + pub const WDTON: RegisterBits = RegisterBits::new(0x10); + pub const WDTON0: RegisterBits = RegisterBits::new(1<<4); + + pub const EESAVE: RegisterBits = RegisterBits::new(0x8); + pub const EESAVE0: RegisterBits = RegisterBits::new(1<<3); + + pub const BODLEVEL: RegisterBits = RegisterBits::new(0x7); + pub const BODLEVEL0: RegisterBits = RegisterBits::new(1<<0); + pub const BODLEVEL1: RegisterBits = RegisterBits::new(1<<1); + pub const BODLEVEL2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for HIGH { + type T = u8; + const ADDRESS: *mut u8 = 0x1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOW; + +impl LOW { + pub const CKDIV8: RegisterBits = RegisterBits::new(0x80); + pub const CKDIV80: RegisterBits = RegisterBits::new(1<<7); + + pub const CKOUT: RegisterBits = RegisterBits::new(0x40); + pub const CKOUT0: RegisterBits = RegisterBits::new(1<<6); + + pub const SUT_CKSEL: RegisterBits = RegisterBits::new(0x3f); + pub const SUT_CKSEL0: RegisterBits = RegisterBits::new(1<<0); + pub const SUT_CKSEL1: RegisterBits = RegisterBits::new(1<<1); + pub const SUT_CKSEL2: RegisterBits = RegisterBits::new(1<<2); + pub const SUT_CKSEL3: RegisterBits = RegisterBits::new(1<<3); + pub const SUT_CKSEL4: RegisterBits = RegisterBits::new(1<<4); + pub const SUT_CKSEL5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for LOW { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOCKBIT; + +impl LOCKBIT { + pub const LB: RegisterBits = RegisterBits::new(0x3); + pub const LB0: RegisterBits = RegisterBits::new(1<<0); + pub const LB1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for LOCKBIT { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x38 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x36 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADCSRB; + +impl ADCSRB { + pub const ACME: RegisterBits = RegisterBits::new(0x40); + pub const ACME0: RegisterBits = RegisterBits::new(1<<6); + +} + +impl Register for ADCSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x23 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSR; + +impl ACSR { + pub const ACD: RegisterBits = RegisterBits::new(0x80); + pub const ACD0: RegisterBits = RegisterBits::new(1<<7); + + pub const ACBG: RegisterBits = RegisterBits::new(0x40); + pub const ACBG0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACO: RegisterBits = RegisterBits::new(0x20); + pub const ACO0: RegisterBits = RegisterBits::new(1<<5); + + pub const ACI: RegisterBits = RegisterBits::new(0x10); + pub const ACI0: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIE: RegisterBits = RegisterBits::new(0x8); + pub const ACIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ACIS: RegisterBits = RegisterBits::new(0x3); + pub const ACIS0: RegisterBits = RegisterBits::new(1<<0); + pub const ACIS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for ACSR { + type T = u8; + const ADDRESS: *mut u8 = 0x28 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + pub const AIN1D: RegisterBits = RegisterBits::new(0x2); + pub const AIN1D0: RegisterBits = RegisterBits::new(1<<1); + + pub const AIN0D: RegisterBits = RegisterBits::new(0x1); + pub const AIN0D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for DIDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x34 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADMUX; + +impl ADMUX { + pub const REFS: RegisterBits = RegisterBits::new(0xc0); + pub const REFS0: RegisterBits = RegisterBits::new(1<<6); + pub const REFS1: RegisterBits = RegisterBits::new(1<<7); + + pub const ADLAR: RegisterBits = RegisterBits::new(0x20); + pub const ADLAR0: RegisterBits = RegisterBits::new(1<<5); + + pub const REFS2: RegisterBits = RegisterBits::new(0x10); + pub const REFS20: RegisterBits = RegisterBits::new(1<<4); + + pub const MUX: RegisterBits = RegisterBits::new(0xf); + pub const MUX0: RegisterBits = RegisterBits::new(1<<0); + pub const MUX1: RegisterBits = RegisterBits::new(1<<1); + pub const MUX2: RegisterBits = RegisterBits::new(1<<2); + pub const MUX3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for ADMUX { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADCSRA; + +impl ADCSRA { + pub const ADEN: RegisterBits = RegisterBits::new(0x80); + pub const ADEN0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADSC: RegisterBits = RegisterBits::new(0x40); + pub const ADSC0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADATE: RegisterBits = RegisterBits::new(0x20); + pub const ADATE0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADIF: RegisterBits = RegisterBits::new(0x10); + pub const ADIF0: RegisterBits = RegisterBits::new(1<<4); + + pub const ADIE: RegisterBits = RegisterBits::new(0x8); + pub const ADIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADPS: RegisterBits = RegisterBits::new(0x7); + pub const ADPS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADPS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADPS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x26 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x24 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ADCSRB; + +impl ADCSRB { + pub const BIN: RegisterBits = RegisterBits::new(0x80); + pub const BIN0: RegisterBits = RegisterBits::new(1<<7); + + pub const IPR: RegisterBits = RegisterBits::new(0x20); + pub const IPR0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADTS: RegisterBits = RegisterBits::new(0x7); + pub const ADTS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADTS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADTS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x23 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + pub const ADC0D: RegisterBits = RegisterBits::new(0x20); + pub const ADC0D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC2D: RegisterBits = RegisterBits::new(0x10); + pub const ADC2D0: RegisterBits = RegisterBits::new(1<<4); + + pub const ADC3D: RegisterBits = RegisterBits::new(0x8); + pub const ADC3D0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADC1D: RegisterBits = RegisterBits::new(0x4); + pub const ADC1D0: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for DIDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x34 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIBR; + +impl USIBR { +} + +impl Register for USIBR { + type T = u8; + const ADDRESS: *mut u8 = 0x30 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIDR; + +impl USIDR { +} + +impl Register for USIDR { + type T = u8; + const ADDRESS: *mut u8 = 0x2f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USISR; + +impl USISR { + pub const USISIF: RegisterBits = RegisterBits::new(0x80); + pub const USISIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIF: RegisterBits = RegisterBits::new(0x40); + pub const USIOIF0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIPF: RegisterBits = RegisterBits::new(0x20); + pub const USIPF0: RegisterBits = RegisterBits::new(1<<5); + + pub const USIDC: RegisterBits = RegisterBits::new(0x10); + pub const USIDC0: RegisterBits = RegisterBits::new(1<<4); + + pub const USICNT: RegisterBits = RegisterBits::new(0xf); + pub const USICNT0: RegisterBits = RegisterBits::new(1<<0); + pub const USICNT1: RegisterBits = RegisterBits::new(1<<1); + pub const USICNT2: RegisterBits = RegisterBits::new(1<<2); + pub const USICNT3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for USISR { + type T = u8; + const ADDRESS: *mut u8 = 0x2e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USICR; + +impl USICR { + pub const USISIE: RegisterBits = RegisterBits::new(0x80); + pub const USISIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIE: RegisterBits = RegisterBits::new(0x40); + pub const USIOIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIWM: RegisterBits = RegisterBits::new(0x30); + pub const USIWM0: RegisterBits = RegisterBits::new(1<<4); + pub const USIWM1: RegisterBits = RegisterBits::new(1<<5); + + pub const USICS: RegisterBits = RegisterBits::new(0xc); + pub const USICS0: RegisterBits = RegisterBits::new(1<<2); + pub const USICS1: RegisterBits = RegisterBits::new(1<<3); + + pub const USICLK: RegisterBits = RegisterBits::new(0x2); + pub const USICLK0: RegisterBits = RegisterBits::new(1<<1); + + pub const USITC: RegisterBits = RegisterBits::new(0x1); + pub const USITC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for USICR { + type T = u8; + const ADDRESS: *mut u8 = 0x2d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const ISC01: RegisterBits = RegisterBits::new(0x2); + pub const ISC010: RegisterBits = RegisterBits::new(1<<1); + + pub const ISC00: RegisterBits = RegisterBits::new(0x1); + pub const ISC000: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIMSK; + +impl GIMSK { + pub const INT0: RegisterBits = RegisterBits::new(0x40); + pub const INT00: RegisterBits = RegisterBits::new(1<<6); + + pub const PCIE: RegisterBits = RegisterBits::new(0x20); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x5b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIFR; + +impl GIFR { + pub const INTF0: RegisterBits = RegisterBits::new(0x40); + pub const INTF00: RegisterBits = RegisterBits::new(1<<6); + + pub const PCIF: RegisterBits = RegisterBits::new(0x20); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x5a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK; + +impl PCMSK { +} + +impl Register for PCMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x35 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEAR; + +impl EEAR { +} + +impl Register for EEAR { + type T = u16; + const ADDRESS: *mut u16 = 0x3e as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct EEDR; + +impl EEDR { +} + +impl Register for EEDR { + type T = u8; + const ADDRESS: *mut u8 = 0x3d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EECR; + +impl EECR { + pub const EEPM: RegisterBits = RegisterBits::new(0x30); + pub const EEPM0: RegisterBits = RegisterBits::new(1<<4); + pub const EEPM1: RegisterBits = RegisterBits::new(1<<5); + + pub const EERIE: RegisterBits = RegisterBits::new(0x8); + pub const EERIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const EEMPE: RegisterBits = RegisterBits::new(0x4); + pub const EEMPE0: RegisterBits = RegisterBits::new(1<<2); + + pub const EEPE: RegisterBits = RegisterBits::new(0x2); + pub const EEPE0: RegisterBits = RegisterBits::new(1<<1); + + pub const EERE: RegisterBits = RegisterBits::new(0x1); + pub const EERE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EECR { + type T = u8; + const ADDRESS: *mut u8 = 0x3c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct WDTCR; + +impl WDTCR { + pub const WDIF: RegisterBits = RegisterBits::new(0x80); + pub const WDIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WDIE: RegisterBits = RegisterBits::new(0x40); + pub const WDIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const WDP: RegisterBits = RegisterBits::new(0x27); + pub const WDP0: RegisterBits = RegisterBits::new(1<<0); + pub const WDP1: RegisterBits = RegisterBits::new(1<<1); + pub const WDP2: RegisterBits = RegisterBits::new(1<<2); + pub const WDP3: RegisterBits = RegisterBits::new(1<<5); + + pub const WDCE: RegisterBits = RegisterBits::new(0x10); + pub const WDCE0: RegisterBits = RegisterBits::new(1<<4); + + pub const WDE: RegisterBits = RegisterBits::new(0x8); + pub const WDE0: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for WDTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x41 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE0A: RegisterBits = RegisterBits::new(0x10); + pub const OCIE0A0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCIE0B: RegisterBits = RegisterBits::new(0x8); + pub const OCIE0B0: RegisterBits = RegisterBits::new(1<<3); + + pub const TOIE0: RegisterBits = RegisterBits::new(0x2); + pub const TOIE00: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF0A: RegisterBits = RegisterBits::new(0x10); + pub const OCF0A0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCF0B: RegisterBits = RegisterBits::new(0x8); + pub const OCF0B0: RegisterBits = RegisterBits::new(1<<3); + + pub const TOV0: RegisterBits = RegisterBits::new(0x2); + pub const TOV00: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0A; + +impl TCCR0A { + pub const COM0A: RegisterBits = RegisterBits::new(0xc0); + pub const COM0A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM0A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM0B: RegisterBits = RegisterBits::new(0x30); + pub const COM0B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM0B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM0: RegisterBits = RegisterBits::new(0x3); + pub const WGM00: RegisterBits = RegisterBits::new(1<<0); + pub const WGM01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x4a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0B; + +impl TCCR0B { + pub const FOC0A: RegisterBits = RegisterBits::new(0x80); + pub const FOC0A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC0B: RegisterBits = RegisterBits::new(0x40); + pub const FOC0B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM02: RegisterBits = RegisterBits::new(0x8); + pub const WGM020: RegisterBits = RegisterBits::new(1<<3); + + pub const CS0: RegisterBits = RegisterBits::new(0x7); + pub const CS00: RegisterBits = RegisterBits::new(1<<0); + pub const CS01: RegisterBits = RegisterBits::new(1<<1); + pub const CS02: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x53 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0; + +impl TCNT0 { +} + +impl Register for TCNT0 { + type T = u8; + const ADDRESS: *mut u8 = 0x52 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x49 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0B; + +impl OCR0B { +} + +impl Register for OCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x48 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1; + +impl TCCR1 { + pub const CTC1: RegisterBits = RegisterBits::new(0x80); + pub const CTC10: RegisterBits = RegisterBits::new(1<<7); + + pub const PWM1A: RegisterBits = RegisterBits::new(0x40); + pub const PWM1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const COM1A: RegisterBits = RegisterBits::new(0x30); + pub const COM1A0: RegisterBits = RegisterBits::new(1<<4); + pub const COM1A1: RegisterBits = RegisterBits::new(1<<5); + + pub const CS1: RegisterBits = RegisterBits::new(0xf); + pub const CS10: RegisterBits = RegisterBits::new(1<<0); + pub const CS11: RegisterBits = RegisterBits::new(1<<1); + pub const CS12: RegisterBits = RegisterBits::new(1<<2); + pub const CS13: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for TCCR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT1; + +impl TCNT1 { +} + +impl Register for TCNT1 { + type T = u8; + const ADDRESS: *mut u8 = 0x4f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x4e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x4b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1C; + +impl OCR1C { +} + +impl Register for OCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x4d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE1A: RegisterBits = RegisterBits::new(0x40); + pub const OCIE1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x20); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const TOIE1: RegisterBits = RegisterBits::new(0x4); + pub const TOIE10: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF1A: RegisterBits = RegisterBits::new(0x40); + pub const OCF1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x20); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const TOV1: RegisterBits = RegisterBits::new(0x4); + pub const TOV10: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DTPS; + +impl DTPS { + pub const DTPS: RegisterBits = RegisterBits::new(0x3); + pub const DTPS0: RegisterBits = RegisterBits::new(1<<0); + pub const DTPS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for DTPS { + type T = u8; + const ADDRESS: *mut u8 = 0x43 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DT1A; + +impl DT1A { + pub const DTVH: RegisterBits = RegisterBits::new(0xf0); + pub const DTVH0: RegisterBits = RegisterBits::new(1<<4); + pub const DTVH1: RegisterBits = RegisterBits::new(1<<5); + pub const DTVH2: RegisterBits = RegisterBits::new(1<<6); + pub const DTVH3: RegisterBits = RegisterBits::new(1<<7); + + pub const DTVL: RegisterBits = RegisterBits::new(0xf); + pub const DTVL0: RegisterBits = RegisterBits::new(1<<0); + pub const DTVL1: RegisterBits = RegisterBits::new(1<<1); + pub const DTVL2: RegisterBits = RegisterBits::new(1<<2); + pub const DTVL3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for DT1A { + type T = u8; + const ADDRESS: *mut u8 = 0x45 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DT1B; + +impl DT1B { + pub const DTVH: RegisterBits = RegisterBits::new(0xf0); + pub const DTVH0: RegisterBits = RegisterBits::new(1<<4); + pub const DTVH1: RegisterBits = RegisterBits::new(1<<5); + pub const DTVH2: RegisterBits = RegisterBits::new(1<<6); + pub const DTVH3: RegisterBits = RegisterBits::new(1<<7); + + pub const DTVL: RegisterBits = RegisterBits::new(0xf); + pub const DTVL0: RegisterBits = RegisterBits::new(1<<0); + pub const DTVL1: RegisterBits = RegisterBits::new(1<<1); + pub const DTVL2: RegisterBits = RegisterBits::new(1<<2); + pub const DTVL3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for DT1B { + type T = u8; + const ADDRESS: *mut u8 = 0x44 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPMCSR; + +impl SPMCSR { + pub const RSIG: RegisterBits = RegisterBits::new(0x20); + pub const RSIG0: RegisterBits = RegisterBits::new(1<<5); + + pub const CTPB: RegisterBits = RegisterBits::new(0x10); + pub const CTPB0: RegisterBits = RegisterBits::new(1<<4); + + pub const RFLB: RegisterBits = RegisterBits::new(0x8); + pub const RFLB0: RegisterBits = RegisterBits::new(1<<3); + + pub const PGWRT: RegisterBits = RegisterBits::new(0x4); + pub const PGWRT0: RegisterBits = RegisterBits::new(1<<2); + + pub const PGERS: RegisterBits = RegisterBits::new(0x2); + pub const PGERS0: RegisterBits = RegisterBits::new(1<<1); + + pub const SPMEN: RegisterBits = RegisterBits::new(0x1); + pub const SPMEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SPMCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x57 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SREG; + +impl SREG { + pub const I: RegisterBits = RegisterBits::new(0x80); + pub const I0: RegisterBits = RegisterBits::new(1<<7); + + pub const T: RegisterBits = RegisterBits::new(0x40); + pub const T0: RegisterBits = RegisterBits::new(1<<6); + + pub const H: RegisterBits = RegisterBits::new(0x20); + pub const H0: RegisterBits = RegisterBits::new(1<<5); + + pub const S: RegisterBits = RegisterBits::new(0x10); + pub const S0: RegisterBits = RegisterBits::new(1<<4); + + pub const V: RegisterBits = RegisterBits::new(0x8); + pub const V0: RegisterBits = RegisterBits::new(1<<3); + + pub const N: RegisterBits = RegisterBits::new(0x4); + pub const N0: RegisterBits = RegisterBits::new(1<<2); + + pub const Z: RegisterBits = RegisterBits::new(0x2); + pub const Z0: RegisterBits = RegisterBits::new(1<<1); + + pub const C: RegisterBits = RegisterBits::new(0x1); + pub const C0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SREG { + type T = u8; + const ADDRESS: *mut u8 = 0x5f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x4); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<2); + + pub const PRUSI: RegisterBits = RegisterBits::new(0x2); + pub const PRUSI0: RegisterBits = RegisterBits::new(1<<1); + + pub const PRADC: RegisterBits = RegisterBits::new(0x1); + pub const PRADC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PRR { + type T = u8; + const ADDRESS: *mut u8 = 0x40 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SP; + +impl SP { +} + +impl Register for SP { + type T = u16; + const ADDRESS: *mut u16 = 0x5d as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const PUD: RegisterBits = RegisterBits::new(0x40); + pub const PUD0: RegisterBits = RegisterBits::new(1<<6); + + pub const SE: RegisterBits = RegisterBits::new(0x20); + pub const SE0: RegisterBits = RegisterBits::new(1<<5); + + pub const SM: RegisterBits = RegisterBits::new(0x18); + pub const SM0: RegisterBits = RegisterBits::new(1<<3); + pub const SM1: RegisterBits = RegisterBits::new(1<<4); + + pub const ISC0: RegisterBits = RegisterBits::new(0x3); + pub const ISC00: RegisterBits = RegisterBits::new(1<<0); + pub const ISC01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUSR; + +impl MCUSR { + pub const WDRF: RegisterBits = RegisterBits::new(0x8); + pub const WDRF0: RegisterBits = RegisterBits::new(1<<3); + + pub const BORF: RegisterBits = RegisterBits::new(0x4); + pub const BORF0: RegisterBits = RegisterBits::new(1<<2); + + pub const EXTRF: RegisterBits = RegisterBits::new(0x2); + pub const EXTRF0: RegisterBits = RegisterBits::new(1<<1); + + pub const PORF: RegisterBits = RegisterBits::new(0x1); + pub const PORF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUSR { + type T = u8; + const ADDRESS: *mut u8 = 0x54 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCCAL; + +impl OSCCAL { + pub const OSCCAL: RegisterBits = RegisterBits::new(0xff); + pub const OSCCAL0: RegisterBits = RegisterBits::new(1<<0); + pub const OSCCAL1: RegisterBits = RegisterBits::new(1<<1); + pub const OSCCAL2: RegisterBits = RegisterBits::new(1<<2); + pub const OSCCAL3: RegisterBits = RegisterBits::new(1<<3); + pub const OSCCAL4: RegisterBits = RegisterBits::new(1<<4); + pub const OSCCAL5: RegisterBits = RegisterBits::new(1<<5); + pub const OSCCAL6: RegisterBits = RegisterBits::new(1<<6); + pub const OSCCAL7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OSCCAL { + type T = u8; + const ADDRESS: *mut u8 = 0x51 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKPR; + +impl CLKPR { + pub const CLKPCE: RegisterBits = RegisterBits::new(0x80); + pub const CLKPCE0: RegisterBits = RegisterBits::new(1<<7); + + pub const CLKPS: RegisterBits = RegisterBits::new(0xf); + pub const CLKPS0: RegisterBits = RegisterBits::new(1<<0); + pub const CLKPS1: RegisterBits = RegisterBits::new(1<<1); + pub const CLKPS2: RegisterBits = RegisterBits::new(1<<2); + pub const CLKPS3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CLKPR { + type T = u8; + const ADDRESS: *mut u8 = 0x46 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PLLCSR; + +impl PLLCSR { + pub const LSM: RegisterBits = RegisterBits::new(0x80); + pub const LSM0: RegisterBits = RegisterBits::new(1<<7); + + pub const PCKE: RegisterBits = RegisterBits::new(0x4); + pub const PCKE0: RegisterBits = RegisterBits::new(1<<2); + + pub const PLLE: RegisterBits = RegisterBits::new(0x2); + pub const PLLE0: RegisterBits = RegisterBits::new(1<<1); + + pub const PLOCK: RegisterBits = RegisterBits::new(0x1); + pub const PLOCK0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PLLCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x47 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DWDR; + +impl DWDR { +} + +impl Register for DWDR { + type T = u8; + const ADDRESS: *mut u8 = 0x42 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR2; + +impl GPIOR2 { +} + +impl Register for GPIOR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x33 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR1; + +impl GPIOR1 { +} + +impl Register for GPIOR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x32 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR0; + +impl GPIOR0 { +} + +impl Register for GPIOR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x31 as *mut u8; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + + pub struct B0; + + impl Pin for B0 { + /// Data Register, Port B. + type PORT = PORTB; + /// Data Direction Register, Port B. + type DDR = DDRB; + /// Input Pins, Port B. + type PIN = PINB; + /// PB0 + const MASK: u8 = 1<<0; + } + + pub struct B1; + + impl Pin for B1 { + /// Data Register, Port B. + type PORT = PORTB; + /// Data Direction Register, Port B. + type DDR = DDRB; + /// Input Pins, Port B. + type PIN = PINB; + /// PB1 + const MASK: u8 = 1<<1; + } + + pub struct B2; + + impl Pin for B2 { + /// Data Register, Port B. + type PORT = PORTB; + /// Data Direction Register, Port B. + type DDR = DDRB; + /// Input Pins, Port B. + type PIN = PINB; + /// PB2 + const MASK: u8 = 1<<2; + } + + pub struct B3; + + impl Pin for B3 { + /// Data Register, Port B. + type PORT = PORTB; + /// Data Direction Register, Port B. + type DDR = DDRB; + /// Input Pins, Port B. + type PIN = PINB; + /// PB3 + const MASK: u8 = 1<<3; + } + + pub struct B4; + + impl Pin for B4 { + /// Data Register, Port B. + type PORT = PORTB; + /// Data Direction Register, Port B. + type DDR = DDRB; + /// Input Pins, Port B. + type PIN = PINB; + /// PB4 + const MASK: u8 = 1<<4; + } + + pub struct B5; + + impl Pin for B5 { + /// Data Register, Port B. + type PORT = PORTB; + /// Data Direction Register, Port B. + type DDR = DDRB; + /// Input Pins, Port B. + type PIN = PINB; + /// PB5 + const MASK: u8 = 1<<5; + } + +} + +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR0A; + type CompareB = OCR0B; + type Counter = TCNT0; + type ControlA = TCCR0A; + type ControlB = TCCR0B; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE0A; +} + diff --git a/src/cores/attiny861.rs b/src/cores/attiny861.rs new file mode 100644 index 0000000..6c8350d --- /dev/null +++ b/src/cores/attiny861.rs @@ -0,0 +1,1470 @@ +//! Core for ATtiny861. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + pub const SELFPRGEN: RegisterBits = RegisterBits::new(0x1); + pub const SELFPRGEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EXTENDED { + type T = u8; + const ADDRESS: *mut u8 = 0x2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct HIGH; + +impl HIGH { + pub const RSTDISBL: RegisterBits = RegisterBits::new(0x80); + pub const RSTDISBL0: RegisterBits = RegisterBits::new(1<<7); + + pub const DWEN: RegisterBits = RegisterBits::new(0x40); + pub const DWEN0: RegisterBits = RegisterBits::new(1<<6); + + pub const SPIEN: RegisterBits = RegisterBits::new(0x20); + pub const SPIEN0: RegisterBits = RegisterBits::new(1<<5); + + pub const WDTON: RegisterBits = RegisterBits::new(0x10); + pub const WDTON0: RegisterBits = RegisterBits::new(1<<4); + + pub const EESAVE: RegisterBits = RegisterBits::new(0x8); + pub const EESAVE0: RegisterBits = RegisterBits::new(1<<3); + + pub const BODLEVEL: RegisterBits = RegisterBits::new(0x7); + pub const BODLEVEL0: RegisterBits = RegisterBits::new(1<<0); + pub const BODLEVEL1: RegisterBits = RegisterBits::new(1<<1); + pub const BODLEVEL2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for HIGH { + type T = u8; + const ADDRESS: *mut u8 = 0x1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOW; + +impl LOW { + pub const CKDIV8: RegisterBits = RegisterBits::new(0x80); + pub const CKDIV80: RegisterBits = RegisterBits::new(1<<7); + + pub const CKOUT: RegisterBits = RegisterBits::new(0x40); + pub const CKOUT0: RegisterBits = RegisterBits::new(1<<6); + + pub const SUT_CKSEL: RegisterBits = RegisterBits::new(0x3f); + pub const SUT_CKSEL0: RegisterBits = RegisterBits::new(1<<0); + pub const SUT_CKSEL1: RegisterBits = RegisterBits::new(1<<1); + pub const SUT_CKSEL2: RegisterBits = RegisterBits::new(1<<2); + pub const SUT_CKSEL3: RegisterBits = RegisterBits::new(1<<3); + pub const SUT_CKSEL4: RegisterBits = RegisterBits::new(1<<4); + pub const SUT_CKSEL5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for LOW { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOCKBIT; + +impl LOCKBIT { + pub const LB: RegisterBits = RegisterBits::new(0x3); + pub const LB0: RegisterBits = RegisterBits::new(1<<0); + pub const LB1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for LOCKBIT { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTA; + +impl PORTA { +} + +impl Register for PORTA { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRA; + +impl DDRA { +} + +impl Register for DDRA { + type T = u8; + const ADDRESS: *mut u8 = 0x3a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINA; + +impl PINA { +} + +impl Register for PINA { + type T = u8; + const ADDRESS: *mut u8 = 0x39 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x38 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x36 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADMUX; + +impl ADMUX { + pub const REFS: RegisterBits = RegisterBits::new(0xc0); + pub const REFS0: RegisterBits = RegisterBits::new(1<<6); + pub const REFS1: RegisterBits = RegisterBits::new(1<<7); + + pub const ADLAR: RegisterBits = RegisterBits::new(0x20); + pub const ADLAR0: RegisterBits = RegisterBits::new(1<<5); + + pub const MUX: RegisterBits = RegisterBits::new(0x1f); + pub const MUX0: RegisterBits = RegisterBits::new(1<<0); + pub const MUX1: RegisterBits = RegisterBits::new(1<<1); + pub const MUX2: RegisterBits = RegisterBits::new(1<<2); + pub const MUX3: RegisterBits = RegisterBits::new(1<<3); + pub const MUX4: RegisterBits = RegisterBits::new(1<<4); + +} + +impl Register for ADMUX { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADCSRA; + +impl ADCSRA { + pub const ADEN: RegisterBits = RegisterBits::new(0x80); + pub const ADEN0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADSC: RegisterBits = RegisterBits::new(0x40); + pub const ADSC0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADATE: RegisterBits = RegisterBits::new(0x20); + pub const ADATE0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADIF: RegisterBits = RegisterBits::new(0x10); + pub const ADIF0: RegisterBits = RegisterBits::new(1<<4); + + pub const ADIE: RegisterBits = RegisterBits::new(0x8); + pub const ADIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADPS: RegisterBits = RegisterBits::new(0x7); + pub const ADPS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADPS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADPS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x26 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x24 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ADCSRB; + +impl ADCSRB { + pub const BIN: RegisterBits = RegisterBits::new(0x80); + pub const BIN0: RegisterBits = RegisterBits::new(1<<7); + + pub const GSEL: RegisterBits = RegisterBits::new(0x40); + pub const GSEL0: RegisterBits = RegisterBits::new(1<<6); + + pub const IPR: RegisterBits = RegisterBits::new(0x20); + pub const IPR0: RegisterBits = RegisterBits::new(1<<5); + + pub const REFS2: RegisterBits = RegisterBits::new(0x10); + pub const REFS20: RegisterBits = RegisterBits::new(1<<4); + + pub const MUX5: RegisterBits = RegisterBits::new(0x8); + pub const MUX50: RegisterBits = RegisterBits::new(1<<3); + + pub const ADTS: RegisterBits = RegisterBits::new(0x7); + pub const ADTS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADTS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADTS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x23 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + pub const ADC10D: RegisterBits = RegisterBits::new(0x80); + pub const ADC10D0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADC9D: RegisterBits = RegisterBits::new(0x40); + pub const ADC9D0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADC8D: RegisterBits = RegisterBits::new(0x20); + pub const ADC8D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC7D: RegisterBits = RegisterBits::new(0x10); + pub const ADC7D0: RegisterBits = RegisterBits::new(1<<4); + +} + +impl Register for DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x22 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + pub const ADC6D: RegisterBits = RegisterBits::new(0x80); + pub const ADC6D0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADC5D: RegisterBits = RegisterBits::new(0x40); + pub const ADC5D0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADC4D: RegisterBits = RegisterBits::new(0x20); + pub const ADC4D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC3D: RegisterBits = RegisterBits::new(0x10); + pub const ADC3D0: RegisterBits = RegisterBits::new(1<<4); + + pub const AREFD: RegisterBits = RegisterBits::new(0x8); + pub const AREFD0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADC2D: RegisterBits = RegisterBits::new(0x4); + pub const ADC2D0: RegisterBits = RegisterBits::new(1<<2); + + pub const ADC1D: RegisterBits = RegisterBits::new(0x2); + pub const ADC1D0: RegisterBits = RegisterBits::new(1<<1); + + pub const ADC0D: RegisterBits = RegisterBits::new(0x1); + pub const ADC0D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for DIDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x21 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSRB; + +impl ACSRB { + pub const HSEL: RegisterBits = RegisterBits::new(0x80); + pub const HSEL0: RegisterBits = RegisterBits::new(1<<7); + + pub const HLEV: RegisterBits = RegisterBits::new(0x40); + pub const HLEV0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACM: RegisterBits = RegisterBits::new(0x7); + pub const ACM0: RegisterBits = RegisterBits::new(1<<0); + pub const ACM1: RegisterBits = RegisterBits::new(1<<1); + pub const ACM2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ACSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x29 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSRA; + +impl ACSRA { + pub const ACD: RegisterBits = RegisterBits::new(0x80); + pub const ACD0: RegisterBits = RegisterBits::new(1<<7); + + pub const ACBG: RegisterBits = RegisterBits::new(0x40); + pub const ACBG0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACO: RegisterBits = RegisterBits::new(0x20); + pub const ACO0: RegisterBits = RegisterBits::new(1<<5); + + pub const ACI: RegisterBits = RegisterBits::new(0x10); + pub const ACI0: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIE: RegisterBits = RegisterBits::new(0x8); + pub const ACIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ACME: RegisterBits = RegisterBits::new(0x4); + pub const ACME0: RegisterBits = RegisterBits::new(1<<2); + + pub const ACIS: RegisterBits = RegisterBits::new(0x3); + pub const ACIS0: RegisterBits = RegisterBits::new(1<<0); + pub const ACIS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for ACSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x28 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIPP; + +impl USIPP { +} + +impl Register for USIPP { + type T = u8; + const ADDRESS: *mut u8 = 0x31 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIBR; + +impl USIBR { +} + +impl Register for USIBR { + type T = u8; + const ADDRESS: *mut u8 = 0x30 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIDR; + +impl USIDR { +} + +impl Register for USIDR { + type T = u8; + const ADDRESS: *mut u8 = 0x2f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USISR; + +impl USISR { + pub const USISIF: RegisterBits = RegisterBits::new(0x80); + pub const USISIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIF: RegisterBits = RegisterBits::new(0x40); + pub const USIOIF0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIPF: RegisterBits = RegisterBits::new(0x20); + pub const USIPF0: RegisterBits = RegisterBits::new(1<<5); + + pub const USIDC: RegisterBits = RegisterBits::new(0x10); + pub const USIDC0: RegisterBits = RegisterBits::new(1<<4); + + pub const USICNT: RegisterBits = RegisterBits::new(0xf); + pub const USICNT0: RegisterBits = RegisterBits::new(1<<0); + pub const USICNT1: RegisterBits = RegisterBits::new(1<<1); + pub const USICNT2: RegisterBits = RegisterBits::new(1<<2); + pub const USICNT3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for USISR { + type T = u8; + const ADDRESS: *mut u8 = 0x2e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USICR; + +impl USICR { + pub const USISIE: RegisterBits = RegisterBits::new(0x80); + pub const USISIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIE: RegisterBits = RegisterBits::new(0x40); + pub const USIOIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIWM: RegisterBits = RegisterBits::new(0x30); + pub const USIWM0: RegisterBits = RegisterBits::new(1<<4); + pub const USIWM1: RegisterBits = RegisterBits::new(1<<5); + + pub const USICS: RegisterBits = RegisterBits::new(0xc); + pub const USICS0: RegisterBits = RegisterBits::new(1<<2); + pub const USICS1: RegisterBits = RegisterBits::new(1<<3); + + pub const USICLK: RegisterBits = RegisterBits::new(0x2); + pub const USICLK0: RegisterBits = RegisterBits::new(1<<1); + + pub const USITC: RegisterBits = RegisterBits::new(0x1); + pub const USITC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for USICR { + type T = u8; + const ADDRESS: *mut u8 = 0x2d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEAR; + +impl EEAR { +} + +impl Register for EEAR { + type T = u16; + const ADDRESS: *mut u16 = 0x3e as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct EEDR; + +impl EEDR { +} + +impl Register for EEDR { + type T = u8; + const ADDRESS: *mut u8 = 0x3d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EECR; + +impl EECR { + pub const EEPM: RegisterBits = RegisterBits::new(0x30); + pub const EEPM0: RegisterBits = RegisterBits::new(1<<4); + pub const EEPM1: RegisterBits = RegisterBits::new(1<<5); + + pub const EERIE: RegisterBits = RegisterBits::new(0x8); + pub const EERIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const EEMPE: RegisterBits = RegisterBits::new(0x4); + pub const EEMPE0: RegisterBits = RegisterBits::new(1<<2); + + pub const EEPE: RegisterBits = RegisterBits::new(0x2); + pub const EEPE0: RegisterBits = RegisterBits::new(1<<1); + + pub const EERE: RegisterBits = RegisterBits::new(0x1); + pub const EERE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EECR { + type T = u8; + const ADDRESS: *mut u8 = 0x3c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct WDTCR; + +impl WDTCR { + pub const WDIF: RegisterBits = RegisterBits::new(0x80); + pub const WDIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WDIE: RegisterBits = RegisterBits::new(0x40); + pub const WDIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const WDP: RegisterBits = RegisterBits::new(0x27); + pub const WDP0: RegisterBits = RegisterBits::new(1<<0); + pub const WDP1: RegisterBits = RegisterBits::new(1<<1); + pub const WDP2: RegisterBits = RegisterBits::new(1<<2); + pub const WDP3: RegisterBits = RegisterBits::new(1<<5); + + pub const WDCE: RegisterBits = RegisterBits::new(0x10); + pub const WDCE0: RegisterBits = RegisterBits::new(1<<4); + + pub const WDE: RegisterBits = RegisterBits::new(0x8); + pub const WDE0: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for WDTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x41 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE0A: RegisterBits = RegisterBits::new(0x10); + pub const OCIE0A0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCIE0B: RegisterBits = RegisterBits::new(0x8); + pub const OCIE0B0: RegisterBits = RegisterBits::new(1<<3); + + pub const TOIE0: RegisterBits = RegisterBits::new(0x2); + pub const TOIE00: RegisterBits = RegisterBits::new(1<<1); + + pub const TICIE0: RegisterBits = RegisterBits::new(0x1); + pub const TICIE00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF0A: RegisterBits = RegisterBits::new(0x10); + pub const OCF0A0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCF0B: RegisterBits = RegisterBits::new(0x8); + pub const OCF0B0: RegisterBits = RegisterBits::new(1<<3); + + pub const TOV0: RegisterBits = RegisterBits::new(0x2); + pub const TOV00: RegisterBits = RegisterBits::new(1<<1); + + pub const ICF0: RegisterBits = RegisterBits::new(0x1); + pub const ICF00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0A; + +impl TCCR0A { + pub const TCW0: RegisterBits = RegisterBits::new(0x80); + pub const TCW00: RegisterBits = RegisterBits::new(1<<7); + + pub const ICEN0: RegisterBits = RegisterBits::new(0x40); + pub const ICEN00: RegisterBits = RegisterBits::new(1<<6); + + pub const ICNC0: RegisterBits = RegisterBits::new(0x20); + pub const ICNC00: RegisterBits = RegisterBits::new(1<<5); + + pub const ICES0: RegisterBits = RegisterBits::new(0x10); + pub const ICES00: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIC0: RegisterBits = RegisterBits::new(0x8); + pub const ACIC00: RegisterBits = RegisterBits::new(1<<3); + + pub const WGM00: RegisterBits = RegisterBits::new(0x1); + pub const WGM000: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x35 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0B; + +impl TCCR0B { + pub const TSM: RegisterBits = RegisterBits::new(0x10); + pub const TSM0: RegisterBits = RegisterBits::new(1<<4); + + pub const PSR0: RegisterBits = RegisterBits::new(0x8); + pub const PSR00: RegisterBits = RegisterBits::new(1<<3); + + pub const CS0: RegisterBits = RegisterBits::new(0x7); + pub const CS00: RegisterBits = RegisterBits::new(1<<0); + pub const CS01: RegisterBits = RegisterBits::new(1<<1); + pub const CS02: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x53 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0H; + +impl TCNT0H { +} + +impl Register for TCNT0H { + type T = u8; + const ADDRESS: *mut u8 = 0x34 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0L; + +impl TCNT0L { +} + +impl Register for TCNT0L { + type T = u8; + const ADDRESS: *mut u8 = 0x52 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x33 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0B; + +impl OCR0B { +} + +impl Register for OCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x32 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1A; + +impl TCCR1A { + pub const COM1A: RegisterBits = RegisterBits::new(0xc0); + pub const COM1A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM1A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM1B: RegisterBits = RegisterBits::new(0x30); + pub const COM1B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM1B1: RegisterBits = RegisterBits::new(1<<5); + + pub const FOC1A: RegisterBits = RegisterBits::new(0x8); + pub const FOC1A0: RegisterBits = RegisterBits::new(1<<3); + + pub const FOC1B: RegisterBits = RegisterBits::new(0x4); + pub const FOC1B0: RegisterBits = RegisterBits::new(1<<2); + + pub const PWM1A: RegisterBits = RegisterBits::new(0x2); + pub const PWM1A0: RegisterBits = RegisterBits::new(1<<1); + + pub const PWM1B: RegisterBits = RegisterBits::new(0x1); + pub const PWM1B0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1B; + +impl TCCR1B { + pub const PSR1: RegisterBits = RegisterBits::new(0x40); + pub const PSR10: RegisterBits = RegisterBits::new(1<<6); + + pub const DTPS1: RegisterBits = RegisterBits::new(0x30); + pub const DTPS10: RegisterBits = RegisterBits::new(1<<4); + pub const DTPS11: RegisterBits = RegisterBits::new(1<<5); + + pub const CS1: RegisterBits = RegisterBits::new(0xf); + pub const CS10: RegisterBits = RegisterBits::new(1<<0); + pub const CS11: RegisterBits = RegisterBits::new(1<<1); + pub const CS12: RegisterBits = RegisterBits::new(1<<2); + pub const CS13: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for TCCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x4f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1C; + +impl TCCR1C { + pub const COM1A1S: RegisterBits = RegisterBits::new(0x80); + pub const COM1A1S0: RegisterBits = RegisterBits::new(1<<7); + + pub const COM1A0S: RegisterBits = RegisterBits::new(0x40); + pub const COM1A0S0: RegisterBits = RegisterBits::new(1<<6); + + pub const COM1B1S: RegisterBits = RegisterBits::new(0x20); + pub const COM1B1S0: RegisterBits = RegisterBits::new(1<<5); + + pub const COM1B0S: RegisterBits = RegisterBits::new(0x10); + pub const COM1B0S0: RegisterBits = RegisterBits::new(1<<4); + + pub const COM1D: RegisterBits = RegisterBits::new(0xc); + pub const COM1D0: RegisterBits = RegisterBits::new(1<<2); + pub const COM1D1: RegisterBits = RegisterBits::new(1<<3); + + pub const FOC1D: RegisterBits = RegisterBits::new(0x2); + pub const FOC1D0: RegisterBits = RegisterBits::new(1<<1); + + pub const PWM1D: RegisterBits = RegisterBits::new(0x1); + pub const PWM1D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x47 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1D; + +impl TCCR1D { + pub const FPIE1: RegisterBits = RegisterBits::new(0x80); + pub const FPIE10: RegisterBits = RegisterBits::new(1<<7); + + pub const FPEN1: RegisterBits = RegisterBits::new(0x40); + pub const FPEN10: RegisterBits = RegisterBits::new(1<<6); + + pub const FPNC1: RegisterBits = RegisterBits::new(0x20); + pub const FPNC10: RegisterBits = RegisterBits::new(1<<5); + + pub const FPES1: RegisterBits = RegisterBits::new(0x10); + pub const FPES10: RegisterBits = RegisterBits::new(1<<4); + + pub const FPAC1: RegisterBits = RegisterBits::new(0x8); + pub const FPAC10: RegisterBits = RegisterBits::new(1<<3); + + pub const FPF1: RegisterBits = RegisterBits::new(0x4); + pub const FPF10: RegisterBits = RegisterBits::new(1<<2); + + pub const WGM1: RegisterBits = RegisterBits::new(0x3); + pub const WGM10: RegisterBits = RegisterBits::new(1<<0); + pub const WGM11: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR1D { + type T = u8; + const ADDRESS: *mut u8 = 0x46 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1E; + +impl TCCR1E { + pub const OC1OE: RegisterBits = RegisterBits::new(0x3f); + pub const OC1OE0: RegisterBits = RegisterBits::new(1<<0); + pub const OC1OE1: RegisterBits = RegisterBits::new(1<<1); + pub const OC1OE2: RegisterBits = RegisterBits::new(1<<2); + pub const OC1OE3: RegisterBits = RegisterBits::new(1<<3); + pub const OC1OE4: RegisterBits = RegisterBits::new(1<<4); + pub const OC1OE5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for TCCR1E { + type T = u8; + const ADDRESS: *mut u8 = 0x20 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT1; + +impl TCNT1 { +} + +impl Register for TCNT1 { + type T = u8; + const ADDRESS: *mut u8 = 0x4e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TC1H; + +impl TC1H { +} + +impl Register for TC1H { + type T = u8; + const ADDRESS: *mut u8 = 0x45 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x4d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x4c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1C; + +impl OCR1C { +} + +impl Register for OCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x4b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1D; + +impl OCR1D { +} + +impl Register for OCR1D { + type T = u8; + const ADDRESS: *mut u8 = 0x4a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE1D: RegisterBits = RegisterBits::new(0x80); + pub const OCIE1D0: RegisterBits = RegisterBits::new(1<<7); + + pub const OCIE1A: RegisterBits = RegisterBits::new(0x40); + pub const OCIE1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x20); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const TOIE1: RegisterBits = RegisterBits::new(0x4); + pub const TOIE10: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF1D: RegisterBits = RegisterBits::new(0x80); + pub const OCF1D0: RegisterBits = RegisterBits::new(1<<7); + + pub const OCF1A: RegisterBits = RegisterBits::new(0x40); + pub const OCF1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x20); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const TOV1: RegisterBits = RegisterBits::new(0x4); + pub const TOV10: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DT1; + +impl DT1 { + pub const DT1H: RegisterBits = RegisterBits::new(0xf0); + pub const DT1H0: RegisterBits = RegisterBits::new(1<<4); + pub const DT1H1: RegisterBits = RegisterBits::new(1<<5); + pub const DT1H2: RegisterBits = RegisterBits::new(1<<6); + pub const DT1H3: RegisterBits = RegisterBits::new(1<<7); + + pub const DT1L: RegisterBits = RegisterBits::new(0xf); + pub const DT1L0: RegisterBits = RegisterBits::new(1<<0); + pub const DT1L1: RegisterBits = RegisterBits::new(1<<1); + pub const DT1L2: RegisterBits = RegisterBits::new(1<<2); + pub const DT1L3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for DT1 { + type T = u8; + const ADDRESS: *mut u8 = 0x44 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPMCSR; + +impl SPMCSR { + pub const CTPB: RegisterBits = RegisterBits::new(0x10); + pub const CTPB0: RegisterBits = RegisterBits::new(1<<4); + + pub const RFLB: RegisterBits = RegisterBits::new(0x8); + pub const RFLB0: RegisterBits = RegisterBits::new(1<<3); + + pub const PGWRT: RegisterBits = RegisterBits::new(0x4); + pub const PGWRT0: RegisterBits = RegisterBits::new(1<<2); + + pub const PGERS: RegisterBits = RegisterBits::new(0x2); + pub const PGERS0: RegisterBits = RegisterBits::new(1<<1); + + pub const SPMEN: RegisterBits = RegisterBits::new(0x1); + pub const SPMEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SPMCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x57 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const ISC01: RegisterBits = RegisterBits::new(0x2); + pub const ISC010: RegisterBits = RegisterBits::new(1<<1); + + pub const ISC00: RegisterBits = RegisterBits::new(0x1); + pub const ISC000: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIMSK; + +impl GIMSK { + pub const INT: RegisterBits = RegisterBits::new(0xc0); + pub const INT0: RegisterBits = RegisterBits::new(1<<6); + pub const INT1: RegisterBits = RegisterBits::new(1<<7); + + pub const PCIE: RegisterBits = RegisterBits::new(0x30); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<4); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x5b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIFR; + +impl GIFR { + pub const INTF: RegisterBits = RegisterBits::new(0xc0); + pub const INTF0: RegisterBits = RegisterBits::new(1<<6); + pub const INTF1: RegisterBits = RegisterBits::new(1<<7); + + pub const PCIF: RegisterBits = RegisterBits::new(0x20); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x5a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { +} + +impl Register for PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x42 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK0; + +impl PCMSK0 { +} + +impl Register for PCMSK0 { + type T = u8; + const ADDRESS: *mut u8 = 0x43 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SREG; + +impl SREG { + pub const I: RegisterBits = RegisterBits::new(0x80); + pub const I0: RegisterBits = RegisterBits::new(1<<7); + + pub const T: RegisterBits = RegisterBits::new(0x40); + pub const T0: RegisterBits = RegisterBits::new(1<<6); + + pub const H: RegisterBits = RegisterBits::new(0x20); + pub const H0: RegisterBits = RegisterBits::new(1<<5); + + pub const S: RegisterBits = RegisterBits::new(0x10); + pub const S0: RegisterBits = RegisterBits::new(1<<4); + + pub const V: RegisterBits = RegisterBits::new(0x8); + pub const V0: RegisterBits = RegisterBits::new(1<<3); + + pub const N: RegisterBits = RegisterBits::new(0x4); + pub const N0: RegisterBits = RegisterBits::new(1<<2); + + pub const Z: RegisterBits = RegisterBits::new(0x2); + pub const Z0: RegisterBits = RegisterBits::new(1<<1); + + pub const C: RegisterBits = RegisterBits::new(0x1); + pub const C0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SREG { + type T = u8; + const ADDRESS: *mut u8 = 0x5f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x4); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<2); + + pub const PRUSI: RegisterBits = RegisterBits::new(0x2); + pub const PRUSI0: RegisterBits = RegisterBits::new(1<<1); + + pub const PRADC: RegisterBits = RegisterBits::new(0x1); + pub const PRADC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PRR { + type T = u8; + const ADDRESS: *mut u8 = 0x56 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SP; + +impl SP { +} + +impl Register for SP { + type T = u16; + const ADDRESS: *mut u16 = 0x5d as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const PUD: RegisterBits = RegisterBits::new(0x40); + pub const PUD0: RegisterBits = RegisterBits::new(1<<6); + + pub const SE: RegisterBits = RegisterBits::new(0x20); + pub const SE0: RegisterBits = RegisterBits::new(1<<5); + + pub const SM: RegisterBits = RegisterBits::new(0x18); + pub const SM0: RegisterBits = RegisterBits::new(1<<3); + pub const SM1: RegisterBits = RegisterBits::new(1<<4); + + pub const ISC0: RegisterBits = RegisterBits::new(0x3); + pub const ISC00: RegisterBits = RegisterBits::new(1<<0); + pub const ISC01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUSR; + +impl MCUSR { + pub const WDRF: RegisterBits = RegisterBits::new(0x8); + pub const WDRF0: RegisterBits = RegisterBits::new(1<<3); + + pub const BORF: RegisterBits = RegisterBits::new(0x4); + pub const BORF0: RegisterBits = RegisterBits::new(1<<2); + + pub const EXTRF: RegisterBits = RegisterBits::new(0x2); + pub const EXTRF0: RegisterBits = RegisterBits::new(1<<1); + + pub const PORF: RegisterBits = RegisterBits::new(0x1); + pub const PORF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUSR { + type T = u8; + const ADDRESS: *mut u8 = 0x54 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCCAL; + +impl OSCCAL { + pub const OSCCAL: RegisterBits = RegisterBits::new(0xff); + pub const OSCCAL0: RegisterBits = RegisterBits::new(1<<0); + pub const OSCCAL1: RegisterBits = RegisterBits::new(1<<1); + pub const OSCCAL2: RegisterBits = RegisterBits::new(1<<2); + pub const OSCCAL3: RegisterBits = RegisterBits::new(1<<3); + pub const OSCCAL4: RegisterBits = RegisterBits::new(1<<4); + pub const OSCCAL5: RegisterBits = RegisterBits::new(1<<5); + pub const OSCCAL6: RegisterBits = RegisterBits::new(1<<6); + pub const OSCCAL7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OSCCAL { + type T = u8; + const ADDRESS: *mut u8 = 0x51 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKPR; + +impl CLKPR { + pub const CLKPCE: RegisterBits = RegisterBits::new(0x80); + pub const CLKPCE0: RegisterBits = RegisterBits::new(1<<7); + + pub const CLKPS: RegisterBits = RegisterBits::new(0xf); + pub const CLKPS0: RegisterBits = RegisterBits::new(1<<0); + pub const CLKPS1: RegisterBits = RegisterBits::new(1<<1); + pub const CLKPS2: RegisterBits = RegisterBits::new(1<<2); + pub const CLKPS3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CLKPR { + type T = u8; + const ADDRESS: *mut u8 = 0x48 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PLLCSR; + +impl PLLCSR { + pub const LSM: RegisterBits = RegisterBits::new(0x80); + pub const LSM0: RegisterBits = RegisterBits::new(1<<7); + + pub const PCKE: RegisterBits = RegisterBits::new(0x4); + pub const PCKE0: RegisterBits = RegisterBits::new(1<<2); + + pub const PLLE: RegisterBits = RegisterBits::new(0x2); + pub const PLLE0: RegisterBits = RegisterBits::new(1<<1); + + pub const PLOCK: RegisterBits = RegisterBits::new(0x1); + pub const PLOCK0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PLLCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x49 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DWDR; + +impl DWDR { +} + +impl Register for DWDR { + type T = u8; + const ADDRESS: *mut u8 = 0x40 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR2; + +impl GPIOR2 { +} + +impl Register for GPIOR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x2c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR1; + +impl GPIOR1 { +} + +impl Register for GPIOR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x2b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR0; + +impl GPIOR0 { +} + +impl Register for GPIOR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x2a as *mut u8; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + + pub struct A0; + + impl Pin for A0 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA0 + const MASK: u8 = 1<<0; + } + + pub struct A1; + + impl Pin for A1 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA1 + const MASK: u8 = 1<<1; + } + + pub struct A2; + + impl Pin for A2 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA2 + const MASK: u8 = 1<<2; + } + + pub struct A3; + + impl Pin for A3 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA3 + const MASK: u8 = 1<<3; + } + + pub struct A4; + + impl Pin for A4 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA4 + const MASK: u8 = 1<<4; + } + + pub struct A5; + + impl Pin for A5 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA5 + const MASK: u8 = 1<<5; + } + + pub struct A6; + + impl Pin for A6 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA6 + const MASK: u8 = 1<<6; + } + + pub struct A7; + + impl Pin for A7 { + /// Port A Data Register. + type PORT = PORTA; + /// Port A Data Direction Register. + type DDR = DDRA; + /// Port A Input Pins. + type PIN = PINA; + /// PA7 + const MASK: u8 = 1<<7; + } + + pub struct B0; + + impl Pin for B0 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB0 + const MASK: u8 = 1<<0; + } + + pub struct B1; + + impl Pin for B1 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB1 + const MASK: u8 = 1<<1; + } + + pub struct B2; + + impl Pin for B2 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB2 + const MASK: u8 = 1<<2; + } + + pub struct B3; + + impl Pin for B3 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB3 + const MASK: u8 = 1<<3; + } + + pub struct B4; + + impl Pin for B4 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB4 + const MASK: u8 = 1<<4; + } + + pub struct B5; + + impl Pin for B5 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB5 + const MASK: u8 = 1<<5; + } + + pub struct B6; + + impl Pin for B6 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB6 + const MASK: u8 = 1<<6; + } + + pub struct B7; + + impl Pin for B7 { + /// Port B Data Register. + type PORT = PORTB; + /// Port B Data Direction Register. + type DDR = DDRB; + /// Port B Input Pins. + type PIN = PINB; + /// PB7 + const MASK: u8 = 1<<7; + } + +} + +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR0A; + type CompareB = OCR0B; + type Counter = TCNT0H; + type ControlA = TCCR0A; + type ControlB = TCCR0B; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE0A; +} +/// 16-bit timer. +pub struct Timer16; + +impl modules::Timer16 for Timer16 { + type CompareA = OCR1A; + type CompareB = OCR1B; + type Counter = TCNT1; + type ControlA = TCCR1A; + type ControlB = TCCR1B; + type ControlC = TCCR1C; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS10; + const CS1: RegisterBits = Self::ControlB::CS11; + const CS2: RegisterBits = Self::ControlB::CS12; + const WGM0: RegisterBits = Self::ControlA::WGM10; + const WGM1: RegisterBits = Self::ControlA::WGM11; + const WGM2: RegisterBits = Self::ControlB::WGM10; + const WGM3: RegisterBits = Self::ControlB::WGM11; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE1A; +} + diff --git a/src/cores/attiny861a.rs b/src/cores/attiny861a.rs new file mode 100644 index 0000000..6025539 --- /dev/null +++ b/src/cores/attiny861a.rs @@ -0,0 +1,1271 @@ +//! Core for ATtiny861A. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + pub const SELFPRGEN: RegisterBits = RegisterBits::new(0x1); + pub const SELFPRGEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EXTENDED { + type T = u8; + const ADDRESS: *mut u8 = 0x2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct HIGH; + +impl HIGH { + pub const RSTDISBL: RegisterBits = RegisterBits::new(0x80); + pub const RSTDISBL0: RegisterBits = RegisterBits::new(1<<7); + + pub const DWEN: RegisterBits = RegisterBits::new(0x40); + pub const DWEN0: RegisterBits = RegisterBits::new(1<<6); + + pub const SPIEN: RegisterBits = RegisterBits::new(0x20); + pub const SPIEN0: RegisterBits = RegisterBits::new(1<<5); + + pub const WDTON: RegisterBits = RegisterBits::new(0x10); + pub const WDTON0: RegisterBits = RegisterBits::new(1<<4); + + pub const EESAVE: RegisterBits = RegisterBits::new(0x8); + pub const EESAVE0: RegisterBits = RegisterBits::new(1<<3); + + pub const BODLEVEL: RegisterBits = RegisterBits::new(0x7); + pub const BODLEVEL0: RegisterBits = RegisterBits::new(1<<0); + pub const BODLEVEL1: RegisterBits = RegisterBits::new(1<<1); + pub const BODLEVEL2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for HIGH { + type T = u8; + const ADDRESS: *mut u8 = 0x1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOW; + +impl LOW { + pub const CKDIV8: RegisterBits = RegisterBits::new(0x80); + pub const CKDIV80: RegisterBits = RegisterBits::new(1<<7); + + pub const CKOUT: RegisterBits = RegisterBits::new(0x40); + pub const CKOUT0: RegisterBits = RegisterBits::new(1<<6); + + pub const SUT_CKSEL: RegisterBits = RegisterBits::new(0x3f); + pub const SUT_CKSEL0: RegisterBits = RegisterBits::new(1<<0); + pub const SUT_CKSEL1: RegisterBits = RegisterBits::new(1<<1); + pub const SUT_CKSEL2: RegisterBits = RegisterBits::new(1<<2); + pub const SUT_CKSEL3: RegisterBits = RegisterBits::new(1<<3); + pub const SUT_CKSEL4: RegisterBits = RegisterBits::new(1<<4); + pub const SUT_CKSEL5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for LOW { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct LOCKBIT; + +impl LOCKBIT { + pub const LB: RegisterBits = RegisterBits::new(0x3); + pub const LB0: RegisterBits = RegisterBits::new(1<<0); + pub const LB1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for LOCKBIT { + type T = u8; + const ADDRESS: *mut u8 = 0x0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTA; + +impl PORTA { +} + +impl Register for PORTA { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRA; + +impl DDRA { +} + +impl Register for DDRA { + type T = u8; + const ADDRESS: *mut u8 = 0x3a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINA; + +impl PINA { +} + +impl Register for PINA { + type T = u8; + const ADDRESS: *mut u8 = 0x39 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x38 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x36 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADMUX; + +impl ADMUX { + pub const REFS: RegisterBits = RegisterBits::new(0xc0); + pub const REFS0: RegisterBits = RegisterBits::new(1<<6); + pub const REFS1: RegisterBits = RegisterBits::new(1<<7); + + pub const ADLAR: RegisterBits = RegisterBits::new(0x20); + pub const ADLAR0: RegisterBits = RegisterBits::new(1<<5); + + pub const MUX: RegisterBits = RegisterBits::new(0x1f); + pub const MUX0: RegisterBits = RegisterBits::new(1<<0); + pub const MUX1: RegisterBits = RegisterBits::new(1<<1); + pub const MUX2: RegisterBits = RegisterBits::new(1<<2); + pub const MUX3: RegisterBits = RegisterBits::new(1<<3); + pub const MUX4: RegisterBits = RegisterBits::new(1<<4); + +} + +impl Register for ADMUX { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADCSRA; + +impl ADCSRA { + pub const ADEN: RegisterBits = RegisterBits::new(0x80); + pub const ADEN0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADSC: RegisterBits = RegisterBits::new(0x40); + pub const ADSC0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADATE: RegisterBits = RegisterBits::new(0x20); + pub const ADATE0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADIF: RegisterBits = RegisterBits::new(0x10); + pub const ADIF0: RegisterBits = RegisterBits::new(1<<4); + + pub const ADIE: RegisterBits = RegisterBits::new(0x8); + pub const ADIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADPS: RegisterBits = RegisterBits::new(0x7); + pub const ADPS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADPS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADPS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x26 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x24 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ADCSRB; + +impl ADCSRB { + pub const BIN: RegisterBits = RegisterBits::new(0x80); + pub const BIN0: RegisterBits = RegisterBits::new(1<<7); + + pub const GSEL: RegisterBits = RegisterBits::new(0x40); + pub const GSEL0: RegisterBits = RegisterBits::new(1<<6); + + pub const IPR: RegisterBits = RegisterBits::new(0x20); + pub const IPR0: RegisterBits = RegisterBits::new(1<<5); + + pub const REFS2: RegisterBits = RegisterBits::new(0x10); + pub const REFS20: RegisterBits = RegisterBits::new(1<<4); + + pub const MUX5: RegisterBits = RegisterBits::new(0x8); + pub const MUX50: RegisterBits = RegisterBits::new(1<<3); + + pub const ADTS: RegisterBits = RegisterBits::new(0x7); + pub const ADTS0: RegisterBits = RegisterBits::new(1<<0); + pub const ADTS1: RegisterBits = RegisterBits::new(1<<1); + pub const ADTS2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ADCSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x23 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + pub const ADC10D: RegisterBits = RegisterBits::new(0x80); + pub const ADC10D0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADC9D: RegisterBits = RegisterBits::new(0x40); + pub const ADC9D0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADC8D: RegisterBits = RegisterBits::new(0x20); + pub const ADC8D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC7D: RegisterBits = RegisterBits::new(0x10); + pub const ADC7D0: RegisterBits = RegisterBits::new(1<<4); + +} + +impl Register for DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x22 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + pub const ADC6D: RegisterBits = RegisterBits::new(0x80); + pub const ADC6D0: RegisterBits = RegisterBits::new(1<<7); + + pub const ADC5D: RegisterBits = RegisterBits::new(0x40); + pub const ADC5D0: RegisterBits = RegisterBits::new(1<<6); + + pub const ADC4D: RegisterBits = RegisterBits::new(0x20); + pub const ADC4D0: RegisterBits = RegisterBits::new(1<<5); + + pub const ADC3D: RegisterBits = RegisterBits::new(0x10); + pub const ADC3D0: RegisterBits = RegisterBits::new(1<<4); + + pub const AREFD: RegisterBits = RegisterBits::new(0x8); + pub const AREFD0: RegisterBits = RegisterBits::new(1<<3); + + pub const ADC2D: RegisterBits = RegisterBits::new(0x4); + pub const ADC2D0: RegisterBits = RegisterBits::new(1<<2); + + pub const ADC1D: RegisterBits = RegisterBits::new(0x2); + pub const ADC1D0: RegisterBits = RegisterBits::new(1<<1); + + pub const ADC0D: RegisterBits = RegisterBits::new(0x1); + pub const ADC0D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for DIDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x21 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSRB; + +impl ACSRB { + pub const HSEL: RegisterBits = RegisterBits::new(0x80); + pub const HSEL0: RegisterBits = RegisterBits::new(1<<7); + + pub const HLEV: RegisterBits = RegisterBits::new(0x40); + pub const HLEV0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACM: RegisterBits = RegisterBits::new(0x7); + pub const ACM0: RegisterBits = RegisterBits::new(1<<0); + pub const ACM1: RegisterBits = RegisterBits::new(1<<1); + pub const ACM2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for ACSRB { + type T = u8; + const ADDRESS: *mut u8 = 0x29 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ACSRA; + +impl ACSRA { + pub const ACD: RegisterBits = RegisterBits::new(0x80); + pub const ACD0: RegisterBits = RegisterBits::new(1<<7); + + pub const ACBG: RegisterBits = RegisterBits::new(0x40); + pub const ACBG0: RegisterBits = RegisterBits::new(1<<6); + + pub const ACO: RegisterBits = RegisterBits::new(0x20); + pub const ACO0: RegisterBits = RegisterBits::new(1<<5); + + pub const ACI: RegisterBits = RegisterBits::new(0x10); + pub const ACI0: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIE: RegisterBits = RegisterBits::new(0x8); + pub const ACIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const ACME: RegisterBits = RegisterBits::new(0x4); + pub const ACME0: RegisterBits = RegisterBits::new(1<<2); + + pub const ACIS: RegisterBits = RegisterBits::new(0x3); + pub const ACIS0: RegisterBits = RegisterBits::new(1<<0); + pub const ACIS1: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for ACSRA { + type T = u8; + const ADDRESS: *mut u8 = 0x28 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIPP; + +impl USIPP { +} + +impl Register for USIPP { + type T = u8; + const ADDRESS: *mut u8 = 0x31 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIBR; + +impl USIBR { +} + +impl Register for USIBR { + type T = u8; + const ADDRESS: *mut u8 = 0x30 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USIDR; + +impl USIDR { +} + +impl Register for USIDR { + type T = u8; + const ADDRESS: *mut u8 = 0x2f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USISR; + +impl USISR { + pub const USISIF: RegisterBits = RegisterBits::new(0x80); + pub const USISIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIF: RegisterBits = RegisterBits::new(0x40); + pub const USIOIF0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIPF: RegisterBits = RegisterBits::new(0x20); + pub const USIPF0: RegisterBits = RegisterBits::new(1<<5); + + pub const USIDC: RegisterBits = RegisterBits::new(0x10); + pub const USIDC0: RegisterBits = RegisterBits::new(1<<4); + + pub const USICNT: RegisterBits = RegisterBits::new(0xf); + pub const USICNT0: RegisterBits = RegisterBits::new(1<<0); + pub const USICNT1: RegisterBits = RegisterBits::new(1<<1); + pub const USICNT2: RegisterBits = RegisterBits::new(1<<2); + pub const USICNT3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for USISR { + type T = u8; + const ADDRESS: *mut u8 = 0x2e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct USICR; + +impl USICR { + pub const USISIE: RegisterBits = RegisterBits::new(0x80); + pub const USISIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const USIOIE: RegisterBits = RegisterBits::new(0x40); + pub const USIOIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const USIWM: RegisterBits = RegisterBits::new(0x30); + pub const USIWM0: RegisterBits = RegisterBits::new(1<<4); + pub const USIWM1: RegisterBits = RegisterBits::new(1<<5); + + pub const USICS: RegisterBits = RegisterBits::new(0xc); + pub const USICS0: RegisterBits = RegisterBits::new(1<<2); + pub const USICS1: RegisterBits = RegisterBits::new(1<<3); + + pub const USICLK: RegisterBits = RegisterBits::new(0x2); + pub const USICLK0: RegisterBits = RegisterBits::new(1<<1); + + pub const USITC: RegisterBits = RegisterBits::new(0x1); + pub const USITC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for USICR { + type T = u8; + const ADDRESS: *mut u8 = 0x2d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEAR; + +impl EEAR { +} + +impl Register for EEAR { + type T = u16; + const ADDRESS: *mut u16 = 0x3e as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct EEDR; + +impl EEDR { +} + +impl Register for EEDR { + type T = u8; + const ADDRESS: *mut u8 = 0x3d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EECR; + +impl EECR { + pub const EEPM: RegisterBits = RegisterBits::new(0x30); + pub const EEPM0: RegisterBits = RegisterBits::new(1<<4); + pub const EEPM1: RegisterBits = RegisterBits::new(1<<5); + + pub const EERIE: RegisterBits = RegisterBits::new(0x8); + pub const EERIE0: RegisterBits = RegisterBits::new(1<<3); + + pub const EEMPE: RegisterBits = RegisterBits::new(0x4); + pub const EEMPE0: RegisterBits = RegisterBits::new(1<<2); + + pub const EEPE: RegisterBits = RegisterBits::new(0x2); + pub const EEPE0: RegisterBits = RegisterBits::new(1<<1); + + pub const EERE: RegisterBits = RegisterBits::new(0x1); + pub const EERE0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for EECR { + type T = u8; + const ADDRESS: *mut u8 = 0x3c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct WDTCR; + +impl WDTCR { + pub const WDIF: RegisterBits = RegisterBits::new(0x80); + pub const WDIF0: RegisterBits = RegisterBits::new(1<<7); + + pub const WDIE: RegisterBits = RegisterBits::new(0x40); + pub const WDIE0: RegisterBits = RegisterBits::new(1<<6); + + pub const WDP: RegisterBits = RegisterBits::new(0x27); + pub const WDP0: RegisterBits = RegisterBits::new(1<<0); + pub const WDP1: RegisterBits = RegisterBits::new(1<<1); + pub const WDP2: RegisterBits = RegisterBits::new(1<<2); + pub const WDP3: RegisterBits = RegisterBits::new(1<<5); + + pub const WDCE: RegisterBits = RegisterBits::new(0x10); + pub const WDCE0: RegisterBits = RegisterBits::new(1<<4); + + pub const WDE: RegisterBits = RegisterBits::new(0x8); + pub const WDE0: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for WDTCR { + type T = u8; + const ADDRESS: *mut u8 = 0x41 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE0A: RegisterBits = RegisterBits::new(0x10); + pub const OCIE0A0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCIE0B: RegisterBits = RegisterBits::new(0x8); + pub const OCIE0B0: RegisterBits = RegisterBits::new(1<<3); + + pub const TOIE0: RegisterBits = RegisterBits::new(0x2); + pub const TOIE00: RegisterBits = RegisterBits::new(1<<1); + + pub const TICIE0: RegisterBits = RegisterBits::new(0x1); + pub const TICIE00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF0A: RegisterBits = RegisterBits::new(0x10); + pub const OCF0A0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCF0B: RegisterBits = RegisterBits::new(0x8); + pub const OCF0B0: RegisterBits = RegisterBits::new(1<<3); + + pub const TOV0: RegisterBits = RegisterBits::new(0x2); + pub const TOV00: RegisterBits = RegisterBits::new(1<<1); + + pub const ICF0: RegisterBits = RegisterBits::new(0x1); + pub const ICF00: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0A; + +impl TCCR0A { + pub const TCW0: RegisterBits = RegisterBits::new(0x80); + pub const TCW00: RegisterBits = RegisterBits::new(1<<7); + + pub const ICEN0: RegisterBits = RegisterBits::new(0x40); + pub const ICEN00: RegisterBits = RegisterBits::new(1<<6); + + pub const ICNC0: RegisterBits = RegisterBits::new(0x20); + pub const ICNC00: RegisterBits = RegisterBits::new(1<<5); + + pub const ICES0: RegisterBits = RegisterBits::new(0x10); + pub const ICES00: RegisterBits = RegisterBits::new(1<<4); + + pub const ACIC0: RegisterBits = RegisterBits::new(0x8); + pub const ACIC00: RegisterBits = RegisterBits::new(1<<3); + + pub const WGM00: RegisterBits = RegisterBits::new(0x1); + pub const WGM000: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x35 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR0B; + +impl TCCR0B { + pub const TSM: RegisterBits = RegisterBits::new(0x10); + pub const TSM0: RegisterBits = RegisterBits::new(1<<4); + + pub const PSR0: RegisterBits = RegisterBits::new(0x8); + pub const PSR00: RegisterBits = RegisterBits::new(1<<3); + + pub const CS0: RegisterBits = RegisterBits::new(0x7); + pub const CS00: RegisterBits = RegisterBits::new(1<<0); + pub const CS01: RegisterBits = RegisterBits::new(1<<1); + pub const CS02: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x53 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0H; + +impl TCNT0H { +} + +impl Register for TCNT0H { + type T = u8; + const ADDRESS: *mut u8 = 0x34 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT0L; + +impl TCNT0L { +} + +impl Register for TCNT0L { + type T = u8; + const ADDRESS: *mut u8 = 0x52 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x33 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR0B; + +impl OCR0B { +} + +impl Register for OCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x32 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1A; + +impl TCCR1A { + pub const COM1A: RegisterBits = RegisterBits::new(0xc0); + pub const COM1A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM1A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM1B: RegisterBits = RegisterBits::new(0x30); + pub const COM1B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM1B1: RegisterBits = RegisterBits::new(1<<5); + + pub const FOC1A: RegisterBits = RegisterBits::new(0x8); + pub const FOC1A0: RegisterBits = RegisterBits::new(1<<3); + + pub const FOC1B: RegisterBits = RegisterBits::new(0x4); + pub const FOC1B0: RegisterBits = RegisterBits::new(1<<2); + + pub const PWM1A: RegisterBits = RegisterBits::new(0x2); + pub const PWM1A0: RegisterBits = RegisterBits::new(1<<1); + + pub const PWM1B: RegisterBits = RegisterBits::new(0x1); + pub const PWM1B0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1B; + +impl TCCR1B { + pub const PWM1X: RegisterBits = RegisterBits::new(0x80); + pub const PWM1X0: RegisterBits = RegisterBits::new(1<<7); + + pub const PSR1: RegisterBits = RegisterBits::new(0x40); + pub const PSR10: RegisterBits = RegisterBits::new(1<<6); + + pub const DTPS1: RegisterBits = RegisterBits::new(0x30); + pub const DTPS10: RegisterBits = RegisterBits::new(1<<4); + pub const DTPS11: RegisterBits = RegisterBits::new(1<<5); + + pub const CS1: RegisterBits = RegisterBits::new(0xf); + pub const CS10: RegisterBits = RegisterBits::new(1<<0); + pub const CS11: RegisterBits = RegisterBits::new(1<<1); + pub const CS12: RegisterBits = RegisterBits::new(1<<2); + pub const CS13: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for TCCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x4f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1C; + +impl TCCR1C { + pub const COM1A1S: RegisterBits = RegisterBits::new(0x80); + pub const COM1A1S0: RegisterBits = RegisterBits::new(1<<7); + + pub const COM1A0S: RegisterBits = RegisterBits::new(0x40); + pub const COM1A0S0: RegisterBits = RegisterBits::new(1<<6); + + pub const COM1B1S: RegisterBits = RegisterBits::new(0x20); + pub const COM1B1S0: RegisterBits = RegisterBits::new(1<<5); + + pub const COM1B0S: RegisterBits = RegisterBits::new(0x10); + pub const COM1B0S0: RegisterBits = RegisterBits::new(1<<4); + + pub const COM1D: RegisterBits = RegisterBits::new(0xc); + pub const COM1D0: RegisterBits = RegisterBits::new(1<<2); + pub const COM1D1: RegisterBits = RegisterBits::new(1<<3); + + pub const FOC1D: RegisterBits = RegisterBits::new(0x2); + pub const FOC1D0: RegisterBits = RegisterBits::new(1<<1); + + pub const PWM1D: RegisterBits = RegisterBits::new(0x1); + pub const PWM1D0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TCCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x47 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1D; + +impl TCCR1D { + pub const FPIE1: RegisterBits = RegisterBits::new(0x80); + pub const FPIE10: RegisterBits = RegisterBits::new(1<<7); + + pub const FPEN1: RegisterBits = RegisterBits::new(0x40); + pub const FPEN10: RegisterBits = RegisterBits::new(1<<6); + + pub const FPNC1: RegisterBits = RegisterBits::new(0x20); + pub const FPNC10: RegisterBits = RegisterBits::new(1<<5); + + pub const FPES1: RegisterBits = RegisterBits::new(0x10); + pub const FPES10: RegisterBits = RegisterBits::new(1<<4); + + pub const FPAC1: RegisterBits = RegisterBits::new(0x8); + pub const FPAC10: RegisterBits = RegisterBits::new(1<<3); + + pub const FPF1: RegisterBits = RegisterBits::new(0x4); + pub const FPF10: RegisterBits = RegisterBits::new(1<<2); + + pub const WGM1: RegisterBits = RegisterBits::new(0x3); + pub const WGM10: RegisterBits = RegisterBits::new(1<<0); + pub const WGM11: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR1D { + type T = u8; + const ADDRESS: *mut u8 = 0x46 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR1E; + +impl TCCR1E { + pub const OC1OE: RegisterBits = RegisterBits::new(0x3f); + pub const OC1OE0: RegisterBits = RegisterBits::new(1<<0); + pub const OC1OE1: RegisterBits = RegisterBits::new(1<<1); + pub const OC1OE2: RegisterBits = RegisterBits::new(1<<2); + pub const OC1OE3: RegisterBits = RegisterBits::new(1<<3); + pub const OC1OE4: RegisterBits = RegisterBits::new(1<<4); + pub const OC1OE5: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for TCCR1E { + type T = u8; + const ADDRESS: *mut u8 = 0x20 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT1; + +impl TCNT1 { +} + +impl Register for TCNT1 { + type T = u8; + const ADDRESS: *mut u8 = 0x4e as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TC1H; + +impl TC1H { +} + +impl Register for TC1H { + type T = u8; + const ADDRESS: *mut u8 = 0x45 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u8; + const ADDRESS: *mut u8 = 0x4d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u8; + const ADDRESS: *mut u8 = 0x4c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1C; + +impl OCR1C { +} + +impl Register for OCR1C { + type T = u8; + const ADDRESS: *mut u8 = 0x4b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR1D; + +impl OCR1D { +} + +impl Register for OCR1D { + type T = u8; + const ADDRESS: *mut u8 = 0x4a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIMSK; + +impl TIMSK { + pub const OCIE1D: RegisterBits = RegisterBits::new(0x80); + pub const OCIE1D0: RegisterBits = RegisterBits::new(1<<7); + + pub const OCIE1A: RegisterBits = RegisterBits::new(0x40); + pub const OCIE1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x20); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const TOIE1: RegisterBits = RegisterBits::new(0x4); + pub const TOIE10: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x59 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR; + +impl TIFR { + pub const OCF1D: RegisterBits = RegisterBits::new(0x80); + pub const OCF1D0: RegisterBits = RegisterBits::new(1<<7); + + pub const OCF1A: RegisterBits = RegisterBits::new(0x40); + pub const OCF1A0: RegisterBits = RegisterBits::new(1<<6); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x20); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<5); + + pub const TOV1: RegisterBits = RegisterBits::new(0x4); + pub const TOV10: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x58 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DT1; + +impl DT1 { + pub const DT1H: RegisterBits = RegisterBits::new(0xf0); + pub const DT1H0: RegisterBits = RegisterBits::new(1<<4); + pub const DT1H1: RegisterBits = RegisterBits::new(1<<5); + pub const DT1H2: RegisterBits = RegisterBits::new(1<<6); + pub const DT1H3: RegisterBits = RegisterBits::new(1<<7); + + pub const DT1L: RegisterBits = RegisterBits::new(0xf); + pub const DT1L0: RegisterBits = RegisterBits::new(1<<0); + pub const DT1L1: RegisterBits = RegisterBits::new(1<<1); + pub const DT1L2: RegisterBits = RegisterBits::new(1<<2); + pub const DT1L3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for DT1 { + type T = u8; + const ADDRESS: *mut u8 = 0x44 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPMCSR; + +impl SPMCSR { + pub const CTPB: RegisterBits = RegisterBits::new(0x10); + pub const CTPB0: RegisterBits = RegisterBits::new(1<<4); + + pub const RFLB: RegisterBits = RegisterBits::new(0x8); + pub const RFLB0: RegisterBits = RegisterBits::new(1<<3); + + pub const PGWRT: RegisterBits = RegisterBits::new(0x4); + pub const PGWRT0: RegisterBits = RegisterBits::new(1<<2); + + pub const PGERS: RegisterBits = RegisterBits::new(0x2); + pub const PGERS0: RegisterBits = RegisterBits::new(1<<1); + + pub const SPMEN: RegisterBits = RegisterBits::new(0x1); + pub const SPMEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SPMCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x57 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const ISC01: RegisterBits = RegisterBits::new(0x2); + pub const ISC010: RegisterBits = RegisterBits::new(1<<1); + + pub const ISC00: RegisterBits = RegisterBits::new(0x1); + pub const ISC000: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIMSK; + +impl GIMSK { + pub const INT: RegisterBits = RegisterBits::new(0xc0); + pub const INT0: RegisterBits = RegisterBits::new(1<<6); + pub const INT1: RegisterBits = RegisterBits::new(1<<7); + + pub const PCIE: RegisterBits = RegisterBits::new(0x30); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<4); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIMSK { + type T = u8; + const ADDRESS: *mut u8 = 0x5b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GIFR; + +impl GIFR { + pub const INTF: RegisterBits = RegisterBits::new(0xc0); + pub const INTF0: RegisterBits = RegisterBits::new(1<<6); + pub const INTF1: RegisterBits = RegisterBits::new(1<<7); + + pub const PCIF: RegisterBits = RegisterBits::new(0x20); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<5); + +} + +impl Register for GIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x5a as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { +} + +impl Register for PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x42 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK0; + +impl PCMSK0 { +} + +impl Register for PCMSK0 { + type T = u8; + const ADDRESS: *mut u8 = 0x43 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SREG; + +impl SREG { + pub const I: RegisterBits = RegisterBits::new(0x80); + pub const I0: RegisterBits = RegisterBits::new(1<<7); + + pub const T: RegisterBits = RegisterBits::new(0x40); + pub const T0: RegisterBits = RegisterBits::new(1<<6); + + pub const H: RegisterBits = RegisterBits::new(0x20); + pub const H0: RegisterBits = RegisterBits::new(1<<5); + + pub const S: RegisterBits = RegisterBits::new(0x10); + pub const S0: RegisterBits = RegisterBits::new(1<<4); + + pub const V: RegisterBits = RegisterBits::new(0x8); + pub const V0: RegisterBits = RegisterBits::new(1<<3); + + pub const N: RegisterBits = RegisterBits::new(0x4); + pub const N0: RegisterBits = RegisterBits::new(1<<2); + + pub const Z: RegisterBits = RegisterBits::new(0x2); + pub const Z0: RegisterBits = RegisterBits::new(1<<1); + + pub const C: RegisterBits = RegisterBits::new(0x1); + pub const C0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SREG { + type T = u8; + const ADDRESS: *mut u8 = 0x5f as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x4); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<2); + + pub const PRUSI: RegisterBits = RegisterBits::new(0x2); + pub const PRUSI0: RegisterBits = RegisterBits::new(1<<1); + + pub const PRADC: RegisterBits = RegisterBits::new(0x1); + pub const PRADC0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PRR { + type T = u8; + const ADDRESS: *mut u8 = 0x56 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SP; + +impl SP { +} + +impl Register for SP { + type T = u16; + const ADDRESS: *mut u16 = 0x5d as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct MCUCR; + +impl MCUCR { + pub const BODS: RegisterBits = RegisterBits::new(0x80); + pub const BODS0: RegisterBits = RegisterBits::new(1<<7); + + pub const PUD: RegisterBits = RegisterBits::new(0x40); + pub const PUD0: RegisterBits = RegisterBits::new(1<<6); + + pub const SE: RegisterBits = RegisterBits::new(0x20); + pub const SE0: RegisterBits = RegisterBits::new(1<<5); + + pub const SM: RegisterBits = RegisterBits::new(0x18); + pub const SM0: RegisterBits = RegisterBits::new(1<<3); + pub const SM1: RegisterBits = RegisterBits::new(1<<4); + + pub const BODSE: RegisterBits = RegisterBits::new(0x4); + pub const BODSE0: RegisterBits = RegisterBits::new(1<<2); + + pub const ISC0: RegisterBits = RegisterBits::new(0x3); + pub const ISC00: RegisterBits = RegisterBits::new(1<<0); + pub const ISC01: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for MCUCR { + type T = u8; + const ADDRESS: *mut u8 = 0x55 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct MCUSR; + +impl MCUSR { + pub const WDRF: RegisterBits = RegisterBits::new(0x8); + pub const WDRF0: RegisterBits = RegisterBits::new(1<<3); + + pub const BORF: RegisterBits = RegisterBits::new(0x4); + pub const BORF0: RegisterBits = RegisterBits::new(1<<2); + + pub const EXTRF: RegisterBits = RegisterBits::new(0x2); + pub const EXTRF0: RegisterBits = RegisterBits::new(1<<1); + + pub const PORF: RegisterBits = RegisterBits::new(0x1); + pub const PORF0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for MCUSR { + type T = u8; + const ADDRESS: *mut u8 = 0x54 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OSCCAL; + +impl OSCCAL { + pub const OSCCAL: RegisterBits = RegisterBits::new(0xff); + pub const OSCCAL0: RegisterBits = RegisterBits::new(1<<0); + pub const OSCCAL1: RegisterBits = RegisterBits::new(1<<1); + pub const OSCCAL2: RegisterBits = RegisterBits::new(1<<2); + pub const OSCCAL3: RegisterBits = RegisterBits::new(1<<3); + pub const OSCCAL4: RegisterBits = RegisterBits::new(1<<4); + pub const OSCCAL5: RegisterBits = RegisterBits::new(1<<5); + pub const OSCCAL6: RegisterBits = RegisterBits::new(1<<6); + pub const OSCCAL7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OSCCAL { + type T = u8; + const ADDRESS: *mut u8 = 0x51 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct CLKPR; + +impl CLKPR { + pub const CLKPCE: RegisterBits = RegisterBits::new(0x80); + pub const CLKPCE0: RegisterBits = RegisterBits::new(1<<7); + + pub const CLKPS: RegisterBits = RegisterBits::new(0xf); + pub const CLKPS0: RegisterBits = RegisterBits::new(1<<0); + pub const CLKPS1: RegisterBits = RegisterBits::new(1<<1); + pub const CLKPS2: RegisterBits = RegisterBits::new(1<<2); + pub const CLKPS3: RegisterBits = RegisterBits::new(1<<3); + +} + +impl Register for CLKPR { + type T = u8; + const ADDRESS: *mut u8 = 0x48 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PLLCSR; + +impl PLLCSR { + pub const LSM: RegisterBits = RegisterBits::new(0x80); + pub const LSM0: RegisterBits = RegisterBits::new(1<<7); + + pub const PCKE: RegisterBits = RegisterBits::new(0x4); + pub const PCKE0: RegisterBits = RegisterBits::new(1<<2); + + pub const PLLE: RegisterBits = RegisterBits::new(0x2); + pub const PLLE0: RegisterBits = RegisterBits::new(1<<1); + + pub const PLOCK: RegisterBits = RegisterBits::new(0x1); + pub const PLOCK0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for PLLCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x49 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DWDR; + +impl DWDR { +} + +impl Register for DWDR { + type T = u8; + const ADDRESS: *mut u8 = 0x40 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR2; + +impl GPIOR2 { +} + +impl Register for GPIOR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x2c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR1; + +impl GPIOR1 { +} + +impl Register for GPIOR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x2b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct GPIOR0; + +impl GPIOR0 { +} + +impl Register for GPIOR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x2a as *mut u8; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + +} + +/// 8-bit timer. +pub struct Timer8; + +impl modules::Timer8 for Timer8 { + type CompareA = OCR0A; + type CompareB = OCR0B; + type Counter = TCNT0H; + type ControlA = TCCR0A; + type ControlB = TCCR0B; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS00; + const CS1: RegisterBits = Self::ControlB::CS01; + const CS2: RegisterBits = Self::ControlB::CS02; + const WGM0: RegisterBits = Self::ControlA::WGM00; + const WGM1: RegisterBits = Self::ControlA::WGM01; + const WGM2: RegisterBits = Self::ControlB::WGM020; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE0A; +} +/// 16-bit timer. +pub struct Timer16; + +impl modules::Timer16 for Timer16 { + type CompareA = OCR1A; + type CompareB = OCR1B; + type Counter = TCNT1; + type ControlA = TCCR1A; + type ControlB = TCCR1B; + type ControlC = TCCR1C; + type InterruptMask = TIMSK; + type InterruptFlag = TIFR; + const CS0: RegisterBits = Self::ControlB::CS10; + const CS1: RegisterBits = Self::ControlB::CS11; + const CS2: RegisterBits = Self::ControlB::CS12; + const WGM0: RegisterBits = Self::ControlA::WGM10; + const WGM1: RegisterBits = Self::ControlA::WGM11; + const WGM2: RegisterBits = Self::ControlB::WGM10; + const WGM3: RegisterBits = Self::ControlB::WGM11; + const OCIEA: RegisterBits = Self::InterruptMask::OCIE1A; +} + diff --git a/src/cores/mod.rs b/src/cores/mod.rs index 699b8cb..6ed0eff 100644 --- a/src/cores/mod.rs +++ b/src/cores/mod.rs @@ -20,6 +20,10 @@ #[cfg(any(avr_mcu_atmega168a, feature = "all-mcus"))] pub mod atmega168a; #[cfg(avr_mcu_atmega168a)] pub use self::atmega168a as current; +/// The AT90PWM161. +#[cfg(any(avr_mcu_at90pwm161, feature = "all-mcus"))] pub mod at90pwm161; +#[cfg(avr_mcu_at90pwm161)] pub use self::at90pwm161 as current; + /// The ATmega48. #[cfg(any(avr_mcu_atmega48, feature = "all-mcus"))] pub mod atmega48; #[cfg(avr_mcu_atmega48)] pub use self::atmega48 as current; @@ -28,6 +32,10 @@ #[cfg(any(avr_mcu_atmega48a, feature = "all-mcus"))] pub mod atmega48a; #[cfg(avr_mcu_atmega48a)] pub use self::atmega48a as current; +/// The ATmega406. +#[cfg(any(avr_mcu_atmega406, feature = "all-mcus"))] pub mod atmega406; +#[cfg(avr_mcu_atmega406)] pub use self::atmega406 as current; + /// The ATmega88PA. #[cfg(any(avr_mcu_atmega88pa, feature = "all-mcus"))] pub mod atmega88pa; #[cfg(avr_mcu_atmega88pa)] pub use self::atmega88pa as current; @@ -66,4 +74,68 @@ #[cfg(any(avr_mcu_atmega168, feature = "all-mcus"))] pub mod atmega168; #[cfg(avr_mcu_atmega168)] pub use self::atmega168 as current; +/// The ATtiny261. +#[cfg(any(avr_mcu_attiny261, feature = "all-mcus"))] pub mod attiny261; +#[cfg(avr_mcu_attiny261)] pub use self::attiny261 as current; + +/// The ATtiny861A. +#[cfg(any(avr_mcu_attiny861a, feature = "all-mcus"))] pub mod attiny861a; +#[cfg(avr_mcu_attiny861a)] pub use self::attiny861a as current; + +/// The ATtiny461. +#[cfg(any(avr_mcu_attiny461, feature = "all-mcus"))] pub mod attiny461; +#[cfg(avr_mcu_attiny461)] pub use self::attiny461 as current; + +/// The ATtiny861. +#[cfg(any(avr_mcu_attiny861, feature = "all-mcus"))] pub mod attiny861; +#[cfg(avr_mcu_attiny861)] pub use self::attiny861 as current; + +/// The ATtiny26. +#[cfg(any(avr_mcu_attiny26, feature = "all-mcus"))] pub mod attiny26; +#[cfg(avr_mcu_attiny26)] pub use self::attiny26 as current; + +/// The ATtiny261A. +#[cfg(any(avr_mcu_attiny261a, feature = "all-mcus"))] pub mod attiny261a; +#[cfg(avr_mcu_attiny261a)] pub use self::attiny261a as current; + +/// The ATtiny2313. +#[cfg(any(avr_mcu_attiny2313, feature = "all-mcus"))] pub mod attiny2313; +#[cfg(avr_mcu_attiny2313)] pub use self::attiny2313 as current; + +/// The ATtiny11. +#[cfg(any(avr_mcu_attiny11, feature = "all-mcus"))] pub mod attiny11; +#[cfg(avr_mcu_attiny11)] pub use self::attiny11 as current; + +/// The ATtiny40. +#[cfg(any(avr_mcu_attiny40, feature = "all-mcus"))] pub mod attiny40; +#[cfg(avr_mcu_attiny40)] pub use self::attiny40 as current; + +/// The ATtiny12. +#[cfg(any(avr_mcu_attiny12, feature = "all-mcus"))] pub mod attiny12; +#[cfg(avr_mcu_attiny12)] pub use self::attiny12 as current; + +/// The ATtiny461A. +#[cfg(any(avr_mcu_attiny461a, feature = "all-mcus"))] pub mod attiny461a; +#[cfg(avr_mcu_attiny461a)] pub use self::attiny461a as current; + +/// The ATtiny2313A. +#[cfg(any(avr_mcu_attiny2313a, feature = "all-mcus"))] pub mod attiny2313a; +#[cfg(avr_mcu_attiny2313a)] pub use self::attiny2313a as current; + +/// The ATtiny20. +#[cfg(any(avr_mcu_attiny20, feature = "all-mcus"))] pub mod attiny20; +#[cfg(avr_mcu_attiny20)] pub use self::attiny20 as current; + +/// The ATtiny1634. +#[cfg(any(avr_mcu_attiny1634, feature = "all-mcus"))] pub mod attiny1634; +#[cfg(avr_mcu_attiny1634)] pub use self::attiny1634 as current; + +/// The ATtiny85. +#[cfg(any(avr_mcu_attiny85, feature = "all-mcus"))] pub mod attiny85; +#[cfg(avr_mcu_attiny85)] pub use self::attiny85 as current; + +/// The ATtiny4313. +#[cfg(any(avr_mcu_attiny4313, feature = "all-mcus"))] pub mod attiny4313; +#[cfg(avr_mcu_attiny4313)] pub use self::attiny4313 as current; +