From 9fbcff1f4554565c87222af7ea75ec9240092b29 Mon Sep 17 00:00:00 2001 From: Dylan McKay Date: Thu, 28 Jan 2021 06:06:10 +1300 Subject: [PATCH] Regenerate the core files, committing them to VCS for the first time --- src/cores/.gitignore | 0 src/cores/atmega168.rs | 1854 +++++++++++++++++++++++++++++++++++++ src/cores/atmega168a.rs | 1857 +++++++++++++++++++++++++++++++++++++ src/cores/atmega168p.rs | 1863 +++++++++++++++++++++++++++++++++++++ src/cores/atmega168pa.rs | 1863 +++++++++++++++++++++++++++++++++++++ src/cores/atmega328.rs | 84 ++ src/cores/atmega328p.rs | 1863 +++++++++++++++++++++++++++++++++++++ src/cores/atmega48.rs | 1836 +++++++++++++++++++++++++++++++++++++ src/cores/atmega48a.rs | 1861 +++++++++++++++++++++++++++++++++++++ src/cores/atmega48p.rs | 1842 +++++++++++++++++++++++++++++++++++++ src/cores/atmega48pa.rs | 1867 ++++++++++++++++++++++++++++++++++++++ src/cores/atmega88.rs | 1854 +++++++++++++++++++++++++++++++++++++ src/cores/atmega88a.rs | 1857 +++++++++++++++++++++++++++++++++++++ src/cores/atmega88p.rs | 1860 +++++++++++++++++++++++++++++++++++++ src/cores/atmega88pa.rs | 1863 +++++++++++++++++++++++++++++++++++++ src/cores/mod.rs | 57 +- 16 files changed, 24279 insertions(+), 2 deletions(-) delete mode 100644 src/cores/.gitignore create mode 100644 src/cores/atmega168.rs create mode 100644 src/cores/atmega168a.rs create mode 100644 src/cores/atmega168p.rs create mode 100644 src/cores/atmega168pa.rs create mode 100644 src/cores/atmega328p.rs create mode 100644 src/cores/atmega48.rs create mode 100644 src/cores/atmega48a.rs create mode 100644 src/cores/atmega48p.rs create mode 100644 src/cores/atmega48pa.rs create mode 100644 src/cores/atmega88.rs create mode 100644 src/cores/atmega88a.rs create mode 100644 src/cores/atmega88p.rs create mode 100644 src/cores/atmega88pa.rs diff --git a/src/cores/.gitignore b/src/cores/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/src/cores/atmega168.rs b/src/cores/atmega168.rs new file mode 100644 index 0000000..2339016 --- /dev/null +++ b/src/cores/atmega168.rs @@ -0,0 +1,1854 @@ +//! Core for ATmega168. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + 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 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); + + 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 UDR0; + +impl UDR0 { +} + +impl Register for UDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0xc6 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 = 0xc0 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 = 0xc1 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 = 0xc2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRR0; + +impl UBRR0 { +} + +impl Register for UBRR0 { + type T = u16; + const ADDRESS: *mut u16 = 0xc4 as *mut u16; +} +#[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 TIMSK1; + +impl TIMSK1 { + pub const ICIE1: RegisterBits = RegisterBits::new(0x20); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 ICF1: RegisterBits = RegisterBits::new(0x20); + pub const ICF10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x4); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 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 = 0x80 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 = 0x81 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 = 0x82 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 OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x88 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x8a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x86 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct TIMSK2; + +impl TIMSK2 { + pub const OCIE2B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCIE2A: RegisterBits = RegisterBits::new(0x2); + pub const OCIE2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOIE2: RegisterBits = RegisterBits::new(0x1); + pub const TOIE20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x70 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR2; + +impl TIFR2 { + pub const OCF2B: RegisterBits = RegisterBits::new(0x4); + pub const OCF2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCF2A: RegisterBits = RegisterBits::new(0x2); + pub const OCF2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOV2: RegisterBits = RegisterBits::new(0x1); + pub const TOV20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2A; + +impl TCCR2A { + pub const COM2A: RegisterBits = RegisterBits::new(0xc0); + pub const COM2A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM2A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM2B: RegisterBits = RegisterBits::new(0x30); + pub const COM2B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM2B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM2: RegisterBits = RegisterBits::new(0x3); + pub const WGM20: RegisterBits = RegisterBits::new(1<<0); + pub const WGM21: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2B; + +impl TCCR2B { + pub const FOC2A: RegisterBits = RegisterBits::new(0x80); + pub const FOC2A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC2B: RegisterBits = RegisterBits::new(0x40); + pub const FOC2B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM22: RegisterBits = RegisterBits::new(0x8); + pub const WGM220: RegisterBits = RegisterBits::new(1<<3); + + pub const CS2: RegisterBits = RegisterBits::new(0x7); + pub const CS20: RegisterBits = RegisterBits::new(1<<0); + pub const CS21: RegisterBits = RegisterBits::new(1<<1); + pub const CS22: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT2; + +impl TCNT2 { +} + +impl Register for TCNT2 { + type T = u8; + const ADDRESS: *mut u8 = 0xb2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2B; + +impl OCR2B { +} + +impl Register for OCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb4 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2A; + +impl OCR2A { +} + +impl Register for OCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb3 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ASSR; + +impl ASSR { + pub const EXCLK: RegisterBits = RegisterBits::new(0x40); + pub const EXCLK0: RegisterBits = RegisterBits::new(1<<6); + + pub const AS2: RegisterBits = RegisterBits::new(0x20); + pub const AS20: RegisterBits = RegisterBits::new(1<<5); + + pub const TCN2UB: RegisterBits = RegisterBits::new(0x10); + pub const TCN2UB0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCR2AUB: RegisterBits = RegisterBits::new(0x8); + pub const OCR2AUB0: RegisterBits = RegisterBits::new(1<<3); + + pub const OCR2BUB: RegisterBits = RegisterBits::new(0x4); + pub const OCR2BUB0: RegisterBits = RegisterBits::new(1<<2); + + pub const TCR2AUB: RegisterBits = RegisterBits::new(0x2); + pub const TCR2AUB0: RegisterBits = RegisterBits::new(1<<1); + + pub const TCR2BUB: RegisterBits = RegisterBits::new(0x1); + pub const TCR2BUB0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for ASSR { + type T = u8; + const ADDRESS: *mut u8 = 0xb6 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 = 0x7c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x78 as *mut u16; +} +#[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 = 0x7a 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); + + 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 = 0x7b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + 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 = 0x7e 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 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + 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 DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x7f 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 DDRC; + +impl DDRC { +} + +impl Register for DDRC { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINC; + +impl PINC { +} + +impl Register for PINC { + type T = u8; + const ADDRESS: *mut u8 = 0x26 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 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 OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x47 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 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 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 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 EICRA; + +impl EICRA { + 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(0x3); + pub const INT0: RegisterBits = RegisterBits::new(1<<0); + pub const INT1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x3); + pub const INTF0: RegisterBits = RegisterBits::new(1<<0); + pub const INTF1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x7); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIE2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCICR { + type T = u8; + const ADDRESS: *mut u8 = 0x68 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK2; + +impl PCMSK2 { + 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 PCMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x6d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { + 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 PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x6c 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 = 0x6b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCIFR; + +impl PCIFR { + pub const PCIF: RegisterBits = RegisterBits::new(0x7); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIF2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPDR; + +impl SPDR { +} + +impl Register for SPDR { + type T = u8; + const ADDRESS: *mut u8 = 0x4e 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 = 0x4d 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 = 0x4c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTWI: RegisterBits = RegisterBits::new(0x80); + pub const PRTWI0: RegisterBits = RegisterBits::new(1<<7); + + pub const PRTIM2: RegisterBits = RegisterBits::new(0x40); + pub const PRTIM20: RegisterBits = RegisterBits::new(1<<6); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x20); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<5); + + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRSPI: RegisterBits = RegisterBits::new(0x4); + pub const PRSPI0: 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 = 0x64 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 = 0x66 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 = 0x61 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 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 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 SELFPRGEN: RegisterBits = RegisterBits::new(0x1); + pub const SELFPRGEN0: 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(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 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 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 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 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; + + 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; + } + + pub struct C0; + + impl Pin for C0 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC0 + const MASK: u8 = 1<<0; + } + + pub struct C1; + + impl Pin for C1 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC1 + const MASK: u8 = 1<<1; + } + + pub struct C2; + + impl Pin for C2 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC2 + const MASK: u8 = 1<<2; + } + + pub struct C3; + + impl Pin for C3 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC3 + const MASK: u8 = 1<<3; + } + + pub struct C4; + + impl Pin for C4 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC4 + const MASK: u8 = 1<<4; + } + + pub struct C5; + + impl Pin for C5 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC5 + const MASK: u8 = 1<<5; + } + + pub struct C6; + + impl Pin for C6 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC6 + const MASK: u8 = 1<<6; + } + + pub struct D0; + + impl Pin for D0 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD0 + const MASK: u8 = 1<<0; + } + + pub struct D1; + + impl Pin for D1 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD1 + const MASK: u8 = 1<<1; + } + + pub struct D2; + + impl Pin for D2 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD2 + const MASK: u8 = 1<<2; + } + + pub struct D3; + + impl Pin for D3 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD3 + const MASK: u8 = 1<<3; + } + + pub struct D4; + + impl Pin for D4 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD4 + const MASK: u8 = 1<<4; + } + + pub struct D5; + + impl Pin for D5 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD5 + const MASK: u8 = 1<<5; + } + + pub struct D6; + + impl Pin for D6 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD6 + const MASK: u8 = 1<<6; + } + + pub struct D7; + + impl Pin for D7 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD7 + const MASK: u8 = 1<<7; + } + +} + +pub struct Spi; + +impl modules::HardwareSpi for Spi { + type SlaveSelect = port::B2; + type MasterOutSlaveIn = port::B3; + type MasterInSlaveOut = port::B4; + type Clock = port::B5; + type DataRegister = SPDR; + type StatusRegister = SPSR; + type ControlRegister = SPCR; +} + +/// The USART0 module. +pub struct USART0; + +impl modules::HardwareUsart for USART0 { + type DataRegister = UDR0; + type ControlRegisterA = UCSR0A; + type ControlRegisterB = UCSR0B; + type ControlRegisterC = UCSR0C; + type BaudRateRegister = UBRR0; +} + +/// 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; +} +/// 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/atmega168a.rs b/src/cores/atmega168a.rs new file mode 100644 index 0000000..58e5f6d --- /dev/null +++ b/src/cores/atmega168a.rs @@ -0,0 +1,1857 @@ +//! Core for ATmega168A. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + 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 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); + + 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 UDR0; + +impl UDR0 { +} + +impl Register for UDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0xc6 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 = 0xc0 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 = 0xc1 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 = 0xc2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRR0; + +impl UBRR0 { +} + +impl Register for UBRR0 { + type T = u16; + const ADDRESS: *mut u16 = 0xc4 as *mut u16; +} +#[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 TIMSK1; + +impl TIMSK1 { + pub const ICIE1: RegisterBits = RegisterBits::new(0x20); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 ICF1: RegisterBits = RegisterBits::new(0x20); + pub const ICF10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x4); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 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 = 0x80 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 = 0x81 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 = 0x82 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 OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x88 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x8a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x86 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct TIMSK2; + +impl TIMSK2 { + pub const OCIE2B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCIE2A: RegisterBits = RegisterBits::new(0x2); + pub const OCIE2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOIE2: RegisterBits = RegisterBits::new(0x1); + pub const TOIE20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x70 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR2; + +impl TIFR2 { + pub const OCF2B: RegisterBits = RegisterBits::new(0x4); + pub const OCF2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCF2A: RegisterBits = RegisterBits::new(0x2); + pub const OCF2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOV2: RegisterBits = RegisterBits::new(0x1); + pub const TOV20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2A; + +impl TCCR2A { + pub const COM2A: RegisterBits = RegisterBits::new(0xc0); + pub const COM2A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM2A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM2B: RegisterBits = RegisterBits::new(0x30); + pub const COM2B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM2B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM2: RegisterBits = RegisterBits::new(0x3); + pub const WGM20: RegisterBits = RegisterBits::new(1<<0); + pub const WGM21: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2B; + +impl TCCR2B { + pub const FOC2A: RegisterBits = RegisterBits::new(0x80); + pub const FOC2A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC2B: RegisterBits = RegisterBits::new(0x40); + pub const FOC2B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM22: RegisterBits = RegisterBits::new(0x8); + pub const WGM220: RegisterBits = RegisterBits::new(1<<3); + + pub const CS2: RegisterBits = RegisterBits::new(0x7); + pub const CS20: RegisterBits = RegisterBits::new(1<<0); + pub const CS21: RegisterBits = RegisterBits::new(1<<1); + pub const CS22: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT2; + +impl TCNT2 { +} + +impl Register for TCNT2 { + type T = u8; + const ADDRESS: *mut u8 = 0xb2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2B; + +impl OCR2B { +} + +impl Register for OCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb4 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2A; + +impl OCR2A { +} + +impl Register for OCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb3 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ASSR; + +impl ASSR { + pub const EXCLK: RegisterBits = RegisterBits::new(0x40); + pub const EXCLK0: RegisterBits = RegisterBits::new(1<<6); + + pub const AS2: RegisterBits = RegisterBits::new(0x20); + pub const AS20: RegisterBits = RegisterBits::new(1<<5); + + pub const TCN2UB: RegisterBits = RegisterBits::new(0x10); + pub const TCN2UB0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCR2AUB: RegisterBits = RegisterBits::new(0x8); + pub const OCR2AUB0: RegisterBits = RegisterBits::new(1<<3); + + pub const OCR2BUB: RegisterBits = RegisterBits::new(0x4); + pub const OCR2BUB0: RegisterBits = RegisterBits::new(1<<2); + + pub const TCR2AUB: RegisterBits = RegisterBits::new(0x2); + pub const TCR2AUB0: RegisterBits = RegisterBits::new(1<<1); + + pub const TCR2BUB: RegisterBits = RegisterBits::new(0x1); + pub const TCR2BUB0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for ASSR { + type T = u8; + const ADDRESS: *mut u8 = 0xb6 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 = 0x7c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x78 as *mut u16; +} +#[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 = 0x7a 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); + + 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 = 0x7b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + 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 = 0x7e 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 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + 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 DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x7f 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 DDRC; + +impl DDRC { +} + +impl Register for DDRC { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINC; + +impl PINC { +} + +impl Register for PINC { + type T = u8; + const ADDRESS: *mut u8 = 0x26 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 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 OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x47 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 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 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 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 EICRA; + +impl EICRA { + 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(0x3); + pub const INT0: RegisterBits = RegisterBits::new(1<<0); + pub const INT1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x3); + pub const INTF0: RegisterBits = RegisterBits::new(1<<0); + pub const INTF1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x7); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIE2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCICR { + type T = u8; + const ADDRESS: *mut u8 = 0x68 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK2; + +impl PCMSK2 { + 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 PCMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x6d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { + 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 PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x6c 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 = 0x6b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCIFR; + +impl PCIFR { + pub const PCIF: RegisterBits = RegisterBits::new(0x7); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIF2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPDR; + +impl SPDR { +} + +impl Register for SPDR { + type T = u8; + const ADDRESS: *mut u8 = 0x4e 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 = 0x4d 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 = 0x4c 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 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; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTWI: RegisterBits = RegisterBits::new(0x80); + pub const PRTWI0: RegisterBits = RegisterBits::new(1<<7); + + pub const PRTIM2: RegisterBits = RegisterBits::new(0x40); + pub const PRTIM20: RegisterBits = RegisterBits::new(1<<6); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x20); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<5); + + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRSPI: RegisterBits = RegisterBits::new(0x4); + pub const PRSPI0: 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 = 0x64 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 = 0x66 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 = 0x61 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 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 MCUCR; + +impl MCUCR { + 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 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 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; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + + 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; + } + + pub struct C0; + + impl Pin for C0 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC0 + const MASK: u8 = 1<<0; + } + + pub struct C1; + + impl Pin for C1 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC1 + const MASK: u8 = 1<<1; + } + + pub struct C2; + + impl Pin for C2 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC2 + const MASK: u8 = 1<<2; + } + + pub struct C3; + + impl Pin for C3 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC3 + const MASK: u8 = 1<<3; + } + + pub struct C4; + + impl Pin for C4 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC4 + const MASK: u8 = 1<<4; + } + + pub struct C5; + + impl Pin for C5 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC5 + const MASK: u8 = 1<<5; + } + + pub struct C6; + + impl Pin for C6 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC6 + const MASK: u8 = 1<<6; + } + + pub struct D0; + + impl Pin for D0 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD0 + const MASK: u8 = 1<<0; + } + + pub struct D1; + + impl Pin for D1 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD1 + const MASK: u8 = 1<<1; + } + + pub struct D2; + + impl Pin for D2 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD2 + const MASK: u8 = 1<<2; + } + + pub struct D3; + + impl Pin for D3 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD3 + const MASK: u8 = 1<<3; + } + + pub struct D4; + + impl Pin for D4 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD4 + const MASK: u8 = 1<<4; + } + + pub struct D5; + + impl Pin for D5 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD5 + const MASK: u8 = 1<<5; + } + + pub struct D6; + + impl Pin for D6 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD6 + const MASK: u8 = 1<<6; + } + + pub struct D7; + + impl Pin for D7 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD7 + const MASK: u8 = 1<<7; + } + +} + +pub struct Spi; + +impl modules::HardwareSpi for Spi { + type SlaveSelect = port::B2; + type MasterOutSlaveIn = port::B3; + type MasterInSlaveOut = port::B4; + type Clock = port::B5; + type DataRegister = SPDR; + type StatusRegister = SPSR; + type ControlRegister = SPCR; +} + +/// The USART0 module. +pub struct USART0; + +impl modules::HardwareUsart for USART0 { + type DataRegister = UDR0; + type ControlRegisterA = UCSR0A; + type ControlRegisterB = UCSR0B; + type ControlRegisterC = UCSR0C; + type BaudRateRegister = UBRR0; +} + +/// 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; +} +/// 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/atmega168p.rs b/src/cores/atmega168p.rs new file mode 100644 index 0000000..948f58a --- /dev/null +++ b/src/cores/atmega168p.rs @@ -0,0 +1,1863 @@ +//! Core for ATmega168P. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + 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 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); + + 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 UDR0; + +impl UDR0 { +} + +impl Register for UDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0xc6 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 = 0xc0 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 = 0xc1 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 = 0xc2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRR0; + +impl UBRR0 { +} + +impl Register for UBRR0 { + type T = u16; + const ADDRESS: *mut u16 = 0xc4 as *mut u16; +} +#[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 TIMSK1; + +impl TIMSK1 { + pub const ICIE1: RegisterBits = RegisterBits::new(0x20); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 ICF1: RegisterBits = RegisterBits::new(0x20); + pub const ICF10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x4); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 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 = 0x80 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 = 0x81 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 = 0x82 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 OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x88 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x8a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x86 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct TIMSK2; + +impl TIMSK2 { + pub const OCIE2B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCIE2A: RegisterBits = RegisterBits::new(0x2); + pub const OCIE2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOIE2: RegisterBits = RegisterBits::new(0x1); + pub const TOIE20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x70 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR2; + +impl TIFR2 { + pub const OCF2B: RegisterBits = RegisterBits::new(0x4); + pub const OCF2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCF2A: RegisterBits = RegisterBits::new(0x2); + pub const OCF2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOV2: RegisterBits = RegisterBits::new(0x1); + pub const TOV20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2A; + +impl TCCR2A { + pub const COM2A: RegisterBits = RegisterBits::new(0xc0); + pub const COM2A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM2A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM2B: RegisterBits = RegisterBits::new(0x30); + pub const COM2B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM2B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM2: RegisterBits = RegisterBits::new(0x3); + pub const WGM20: RegisterBits = RegisterBits::new(1<<0); + pub const WGM21: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2B; + +impl TCCR2B { + pub const FOC2A: RegisterBits = RegisterBits::new(0x80); + pub const FOC2A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC2B: RegisterBits = RegisterBits::new(0x40); + pub const FOC2B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM22: RegisterBits = RegisterBits::new(0x8); + pub const WGM220: RegisterBits = RegisterBits::new(1<<3); + + pub const CS2: RegisterBits = RegisterBits::new(0x7); + pub const CS20: RegisterBits = RegisterBits::new(1<<0); + pub const CS21: RegisterBits = RegisterBits::new(1<<1); + pub const CS22: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT2; + +impl TCNT2 { +} + +impl Register for TCNT2 { + type T = u8; + const ADDRESS: *mut u8 = 0xb2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2B; + +impl OCR2B { +} + +impl Register for OCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb4 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2A; + +impl OCR2A { +} + +impl Register for OCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb3 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ASSR; + +impl ASSR { + pub const EXCLK: RegisterBits = RegisterBits::new(0x40); + pub const EXCLK0: RegisterBits = RegisterBits::new(1<<6); + + pub const AS2: RegisterBits = RegisterBits::new(0x20); + pub const AS20: RegisterBits = RegisterBits::new(1<<5); + + pub const TCN2UB: RegisterBits = RegisterBits::new(0x10); + pub const TCN2UB0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCR2AUB: RegisterBits = RegisterBits::new(0x8); + pub const OCR2AUB0: RegisterBits = RegisterBits::new(1<<3); + + pub const OCR2BUB: RegisterBits = RegisterBits::new(0x4); + pub const OCR2BUB0: RegisterBits = RegisterBits::new(1<<2); + + pub const TCR2AUB: RegisterBits = RegisterBits::new(0x2); + pub const TCR2AUB0: RegisterBits = RegisterBits::new(1<<1); + + pub const TCR2BUB: RegisterBits = RegisterBits::new(0x1); + pub const TCR2BUB0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for ASSR { + type T = u8; + const ADDRESS: *mut u8 = 0xb6 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 = 0x7c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x78 as *mut u16; +} +#[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 = 0x7a 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); + + 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 = 0x7b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + 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 = 0x7e 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 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + 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 DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x7f 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 DDRC; + +impl DDRC { +} + +impl Register for DDRC { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINC; + +impl PINC { +} + +impl Register for PINC { + type T = u8; + const ADDRESS: *mut u8 = 0x26 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 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 OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x47 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 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 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 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 EICRA; + +impl EICRA { + 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(0x3); + pub const INT0: RegisterBits = RegisterBits::new(1<<0); + pub const INT1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x3); + pub const INTF0: RegisterBits = RegisterBits::new(1<<0); + pub const INTF1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x7); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIE2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCICR { + type T = u8; + const ADDRESS: *mut u8 = 0x68 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK2; + +impl PCMSK2 { + 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 PCMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x6d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { + 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 PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x6c 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 = 0x6b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCIFR; + +impl PCIFR { + pub const PCIF: RegisterBits = RegisterBits::new(0x7); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIF2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPDR; + +impl SPDR { +} + +impl Register for SPDR { + type T = u8; + const ADDRESS: *mut u8 = 0x4e 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 = 0x4d 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 = 0x4c 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 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; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTWI: RegisterBits = RegisterBits::new(0x80); + pub const PRTWI0: RegisterBits = RegisterBits::new(1<<7); + + pub const PRTIM2: RegisterBits = RegisterBits::new(0x40); + pub const PRTIM20: RegisterBits = RegisterBits::new(1<<6); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x20); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<5); + + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRSPI: RegisterBits = RegisterBits::new(0x4); + pub const PRSPI0: 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 = 0x64 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 = 0x66 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 = 0x61 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 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 SELFPRGEN: RegisterBits = RegisterBits::new(0x1); + pub const SELFPRGEN0: 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 BODS: RegisterBits = RegisterBits::new(0x40); + pub const BODS0: RegisterBits = RegisterBits::new(1<<6); + + pub const BODSE: RegisterBits = RegisterBits::new(0x20); + pub const BODSE0: RegisterBits = RegisterBits::new(1<<5); + + 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 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 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; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + + 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; + } + + pub struct C0; + + impl Pin for C0 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC0 + const MASK: u8 = 1<<0; + } + + pub struct C1; + + impl Pin for C1 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC1 + const MASK: u8 = 1<<1; + } + + pub struct C2; + + impl Pin for C2 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC2 + const MASK: u8 = 1<<2; + } + + pub struct C3; + + impl Pin for C3 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC3 + const MASK: u8 = 1<<3; + } + + pub struct C4; + + impl Pin for C4 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC4 + const MASK: u8 = 1<<4; + } + + pub struct C5; + + impl Pin for C5 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC5 + const MASK: u8 = 1<<5; + } + + pub struct C6; + + impl Pin for C6 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC6 + const MASK: u8 = 1<<6; + } + + pub struct D0; + + impl Pin for D0 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD0 + const MASK: u8 = 1<<0; + } + + pub struct D1; + + impl Pin for D1 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD1 + const MASK: u8 = 1<<1; + } + + pub struct D2; + + impl Pin for D2 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD2 + const MASK: u8 = 1<<2; + } + + pub struct D3; + + impl Pin for D3 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD3 + const MASK: u8 = 1<<3; + } + + pub struct D4; + + impl Pin for D4 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD4 + const MASK: u8 = 1<<4; + } + + pub struct D5; + + impl Pin for D5 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD5 + const MASK: u8 = 1<<5; + } + + pub struct D6; + + impl Pin for D6 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD6 + const MASK: u8 = 1<<6; + } + + pub struct D7; + + impl Pin for D7 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD7 + const MASK: u8 = 1<<7; + } + +} + +pub struct Spi; + +impl modules::HardwareSpi for Spi { + type SlaveSelect = port::B2; + type MasterOutSlaveIn = port::B3; + type MasterInSlaveOut = port::B4; + type Clock = port::B5; + type DataRegister = SPDR; + type StatusRegister = SPSR; + type ControlRegister = SPCR; +} + +/// The USART0 module. +pub struct USART0; + +impl modules::HardwareUsart for USART0 { + type DataRegister = UDR0; + type ControlRegisterA = UCSR0A; + type ControlRegisterB = UCSR0B; + type ControlRegisterC = UCSR0C; + type BaudRateRegister = UBRR0; +} + +/// 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; +} +/// 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/atmega168pa.rs b/src/cores/atmega168pa.rs new file mode 100644 index 0000000..409699f --- /dev/null +++ b/src/cores/atmega168pa.rs @@ -0,0 +1,1863 @@ +//! Core for ATmega168PA. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + 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 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); + + 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 UDR0; + +impl UDR0 { +} + +impl Register for UDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0xc6 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 = 0xc0 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 = 0xc1 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 = 0xc2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRR0; + +impl UBRR0 { +} + +impl Register for UBRR0 { + type T = u16; + const ADDRESS: *mut u16 = 0xc4 as *mut u16; +} +#[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 TIMSK1; + +impl TIMSK1 { + pub const ICIE1: RegisterBits = RegisterBits::new(0x20); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 ICF1: RegisterBits = RegisterBits::new(0x20); + pub const ICF10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x4); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 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 = 0x80 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 = 0x81 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 = 0x82 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 OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x88 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x8a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x86 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct TIMSK2; + +impl TIMSK2 { + pub const OCIE2B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCIE2A: RegisterBits = RegisterBits::new(0x2); + pub const OCIE2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOIE2: RegisterBits = RegisterBits::new(0x1); + pub const TOIE20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x70 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR2; + +impl TIFR2 { + pub const OCF2B: RegisterBits = RegisterBits::new(0x4); + pub const OCF2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCF2A: RegisterBits = RegisterBits::new(0x2); + pub const OCF2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOV2: RegisterBits = RegisterBits::new(0x1); + pub const TOV20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2A; + +impl TCCR2A { + pub const COM2A: RegisterBits = RegisterBits::new(0xc0); + pub const COM2A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM2A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM2B: RegisterBits = RegisterBits::new(0x30); + pub const COM2B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM2B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM2: RegisterBits = RegisterBits::new(0x3); + pub const WGM20: RegisterBits = RegisterBits::new(1<<0); + pub const WGM21: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2B; + +impl TCCR2B { + pub const FOC2A: RegisterBits = RegisterBits::new(0x80); + pub const FOC2A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC2B: RegisterBits = RegisterBits::new(0x40); + pub const FOC2B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM22: RegisterBits = RegisterBits::new(0x8); + pub const WGM220: RegisterBits = RegisterBits::new(1<<3); + + pub const CS2: RegisterBits = RegisterBits::new(0x7); + pub const CS20: RegisterBits = RegisterBits::new(1<<0); + pub const CS21: RegisterBits = RegisterBits::new(1<<1); + pub const CS22: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT2; + +impl TCNT2 { +} + +impl Register for TCNT2 { + type T = u8; + const ADDRESS: *mut u8 = 0xb2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2B; + +impl OCR2B { +} + +impl Register for OCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb4 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2A; + +impl OCR2A { +} + +impl Register for OCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb3 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ASSR; + +impl ASSR { + pub const EXCLK: RegisterBits = RegisterBits::new(0x40); + pub const EXCLK0: RegisterBits = RegisterBits::new(1<<6); + + pub const AS2: RegisterBits = RegisterBits::new(0x20); + pub const AS20: RegisterBits = RegisterBits::new(1<<5); + + pub const TCN2UB: RegisterBits = RegisterBits::new(0x10); + pub const TCN2UB0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCR2AUB: RegisterBits = RegisterBits::new(0x8); + pub const OCR2AUB0: RegisterBits = RegisterBits::new(1<<3); + + pub const OCR2BUB: RegisterBits = RegisterBits::new(0x4); + pub const OCR2BUB0: RegisterBits = RegisterBits::new(1<<2); + + pub const TCR2AUB: RegisterBits = RegisterBits::new(0x2); + pub const TCR2AUB0: RegisterBits = RegisterBits::new(1<<1); + + pub const TCR2BUB: RegisterBits = RegisterBits::new(0x1); + pub const TCR2BUB0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for ASSR { + type T = u8; + const ADDRESS: *mut u8 = 0xb6 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 = 0x7c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x78 as *mut u16; +} +#[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 = 0x7a 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); + + 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 = 0x7b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + 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 = 0x7e 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 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + 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 DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x7f 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 DDRC; + +impl DDRC { +} + +impl Register for DDRC { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINC; + +impl PINC { +} + +impl Register for PINC { + type T = u8; + const ADDRESS: *mut u8 = 0x26 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 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 OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x47 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 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 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 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 EICRA; + +impl EICRA { + 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(0x3); + pub const INT0: RegisterBits = RegisterBits::new(1<<0); + pub const INT1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x3); + pub const INTF0: RegisterBits = RegisterBits::new(1<<0); + pub const INTF1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x7); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIE2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCICR { + type T = u8; + const ADDRESS: *mut u8 = 0x68 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK2; + +impl PCMSK2 { + 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 PCMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x6d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { + 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 PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x6c 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 = 0x6b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCIFR; + +impl PCIFR { + pub const PCIF: RegisterBits = RegisterBits::new(0x7); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIF2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPDR; + +impl SPDR { +} + +impl Register for SPDR { + type T = u8; + const ADDRESS: *mut u8 = 0x4e 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 = 0x4d 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 = 0x4c 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 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; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTWI: RegisterBits = RegisterBits::new(0x80); + pub const PRTWI0: RegisterBits = RegisterBits::new(1<<7); + + pub const PRTIM2: RegisterBits = RegisterBits::new(0x40); + pub const PRTIM20: RegisterBits = RegisterBits::new(1<<6); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x20); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<5); + + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRSPI: RegisterBits = RegisterBits::new(0x4); + pub const PRSPI0: 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 = 0x64 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 = 0x66 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 = 0x61 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 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 MCUCR; + +impl MCUCR { + pub const BODS: RegisterBits = RegisterBits::new(0x40); + pub const BODS0: RegisterBits = RegisterBits::new(1<<6); + + pub const BODSE: RegisterBits = RegisterBits::new(0x20); + pub const BODSE0: RegisterBits = RegisterBits::new(1<<5); + + 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 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 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; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + + 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; + } + + pub struct C0; + + impl Pin for C0 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC0 + const MASK: u8 = 1<<0; + } + + pub struct C1; + + impl Pin for C1 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC1 + const MASK: u8 = 1<<1; + } + + pub struct C2; + + impl Pin for C2 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC2 + const MASK: u8 = 1<<2; + } + + pub struct C3; + + impl Pin for C3 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC3 + const MASK: u8 = 1<<3; + } + + pub struct C4; + + impl Pin for C4 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC4 + const MASK: u8 = 1<<4; + } + + pub struct C5; + + impl Pin for C5 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC5 + const MASK: u8 = 1<<5; + } + + pub struct C6; + + impl Pin for C6 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC6 + const MASK: u8 = 1<<6; + } + + pub struct D0; + + impl Pin for D0 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD0 + const MASK: u8 = 1<<0; + } + + pub struct D1; + + impl Pin for D1 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD1 + const MASK: u8 = 1<<1; + } + + pub struct D2; + + impl Pin for D2 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD2 + const MASK: u8 = 1<<2; + } + + pub struct D3; + + impl Pin for D3 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD3 + const MASK: u8 = 1<<3; + } + + pub struct D4; + + impl Pin for D4 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD4 + const MASK: u8 = 1<<4; + } + + pub struct D5; + + impl Pin for D5 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD5 + const MASK: u8 = 1<<5; + } + + pub struct D6; + + impl Pin for D6 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD6 + const MASK: u8 = 1<<6; + } + + pub struct D7; + + impl Pin for D7 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD7 + const MASK: u8 = 1<<7; + } + +} + +pub struct Spi; + +impl modules::HardwareSpi for Spi { + type SlaveSelect = port::B2; + type MasterOutSlaveIn = port::B3; + type MasterInSlaveOut = port::B4; + type Clock = port::B5; + type DataRegister = SPDR; + type StatusRegister = SPSR; + type ControlRegister = SPCR; +} + +/// The USART0 module. +pub struct USART0; + +impl modules::HardwareUsart for USART0 { + type DataRegister = UDR0; + type ControlRegisterA = UCSR0A; + type ControlRegisterB = UCSR0B; + type ControlRegisterC = UCSR0C; + type BaudRateRegister = UBRR0; +} + +/// 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; +} +/// 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 61ff648..c2dd69e 100644 --- a/src/cores/atmega328.rs +++ b/src/cores/atmega328.rs @@ -2,6 +2,7 @@ use crate::{modules, RegisterBits, Register}; +#[allow(non_camel_case_types)] pub struct EXTENDED; impl EXTENDED { @@ -16,6 +17,7 @@ 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 { @@ -47,6 +49,7 @@ 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 { @@ -70,6 +73,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 { @@ -91,6 +95,7 @@ impl Register for LOCKBIT { type T = u8; const ADDRESS: *mut u8 = 0x0 as *mut u8; } +#[allow(non_camel_case_types)] pub struct UDR0; impl UDR0 { @@ -110,6 +115,7 @@ impl Register for UDR0 { type T = u8; const ADDRESS: *mut u8 = 0xc6 as *mut u8; } +#[allow(non_camel_case_types)] pub struct UCSR0A; impl UCSR0A { @@ -143,6 +149,7 @@ impl Register for UCSR0A { type T = u8; const ADDRESS: *mut u8 = 0xc0 as *mut u8; } +#[allow(non_camel_case_types)] pub struct UCSR0B; impl UCSR0B { @@ -176,6 +183,7 @@ impl Register for UCSR0B { type T = u8; const ADDRESS: *mut u8 = 0xc1 as *mut u8; } +#[allow(non_camel_case_types)] pub struct UCSR0C; impl UCSR0C { @@ -203,6 +211,7 @@ impl Register for UCSR0C { type T = u8; const ADDRESS: *mut u8 = 0xc2 as *mut u8; } +#[allow(non_camel_case_types)] pub struct UBRR0; impl UBRR0 { @@ -226,6 +235,7 @@ impl Register for UBRR0 { type T = u16; const ADDRESS: *mut u16 = 0xc4 as *mut u16; } +#[allow(non_camel_case_types)] pub struct TWAMR; impl TWAMR { @@ -244,6 +254,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 { @@ -263,6 +274,7 @@ 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 { @@ -293,6 +305,7 @@ 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 { @@ -313,6 +326,7 @@ 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 { @@ -332,6 +346,7 @@ 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 { @@ -353,6 +368,7 @@ impl Register for TWAR { type T = u8; const ADDRESS: *mut u8 = 0xba as *mut u8; } +#[allow(non_camel_case_types)] pub struct TIMSK1; impl TIMSK1 { @@ -374,6 +390,7 @@ 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 { @@ -395,6 +412,7 @@ impl Register for TIFR1 { type T = u8; const ADDRESS: *mut u8 = 0x36 as *mut u8; } +#[allow(non_camel_case_types)] pub struct TCCR1A; impl TCCR1A { @@ -416,6 +434,7 @@ impl Register for TCCR1A { type T = u8; const ADDRESS: *mut u8 = 0x80 as *mut u8; } +#[allow(non_camel_case_types)] pub struct TCCR1B; impl TCCR1B { @@ -440,6 +459,7 @@ impl Register for TCCR1B { type T = u8; const ADDRESS: *mut u8 = 0x81 as *mut u8; } +#[allow(non_camel_case_types)] pub struct TCCR1C; impl TCCR1C { @@ -455,6 +475,7 @@ impl Register for TCCR1C { type T = u8; const ADDRESS: *mut u8 = 0x82 as *mut u8; } +#[allow(non_camel_case_types)] pub struct TCNT1; impl TCNT1 { @@ -481,6 +502,7 @@ impl Register for TCNT1 { type T = u16; const ADDRESS: *mut u16 = 0x84 as *mut u16; } +#[allow(non_camel_case_types)] pub struct OCR1A; impl OCR1A { @@ -507,6 +529,7 @@ impl Register for OCR1A { type T = u16; const ADDRESS: *mut u16 = 0x88 as *mut u16; } +#[allow(non_camel_case_types)] pub struct OCR1B; impl OCR1B { @@ -533,6 +556,7 @@ impl Register for OCR1B { type T = u16; const ADDRESS: *mut u16 = 0x8a as *mut u16; } +#[allow(non_camel_case_types)] pub struct ICR1; impl ICR1 { @@ -559,6 +583,7 @@ impl Register for ICR1 { type T = u16; const ADDRESS: *mut u16 = 0x86 as *mut u16; } +#[allow(non_camel_case_types)] pub struct TIMSK2; impl TIMSK2 { @@ -577,6 +602,7 @@ impl Register for TIMSK2 { type T = u8; const ADDRESS: *mut u8 = 0x70 as *mut u8; } +#[allow(non_camel_case_types)] pub struct TIFR2; impl TIFR2 { @@ -595,6 +621,7 @@ impl Register for TIFR2 { type T = u8; const ADDRESS: *mut u8 = 0x37 as *mut u8; } +#[allow(non_camel_case_types)] pub struct TCCR2A; impl TCCR2A { @@ -616,6 +643,7 @@ impl Register for TCCR2A { type T = u8; const ADDRESS: *mut u8 = 0xb0 as *mut u8; } +#[allow(non_camel_case_types)] pub struct TCCR2B; impl TCCR2B { @@ -639,6 +667,7 @@ impl Register for TCCR2B { type T = u8; const ADDRESS: *mut u8 = 0xb1 as *mut u8; } +#[allow(non_camel_case_types)] pub struct TCNT2; impl TCNT2 { @@ -658,6 +687,7 @@ impl Register for TCNT2 { type T = u8; const ADDRESS: *mut u8 = 0xb2 as *mut u8; } +#[allow(non_camel_case_types)] pub struct OCR2B; impl OCR2B { @@ -677,6 +707,7 @@ impl Register for OCR2B { type T = u8; const ADDRESS: *mut u8 = 0xb4 as *mut u8; } +#[allow(non_camel_case_types)] pub struct OCR2A; impl OCR2A { @@ -696,6 +727,7 @@ impl Register for OCR2A { type T = u8; const ADDRESS: *mut u8 = 0xb3 as *mut u8; } +#[allow(non_camel_case_types)] pub struct ASSR; impl ASSR { @@ -726,6 +758,7 @@ impl Register for ASSR { type T = u8; const ADDRESS: *mut u8 = 0xb6 as *mut u8; } +#[allow(non_camel_case_types)] pub struct ADMUX; impl ADMUX { @@ -748,6 +781,7 @@ impl Register for ADMUX { type T = u8; const ADDRESS: *mut u8 = 0x7c as *mut u8; } +#[allow(non_camel_case_types)] pub struct ADC; impl ADC { @@ -769,6 +803,7 @@ impl Register for ADC { type T = u16; const ADDRESS: *mut u16 = 0x78 as *mut u16; } +#[allow(non_camel_case_types)] pub struct ADCSRA; impl ADCSRA { @@ -798,6 +833,7 @@ impl Register for ADCSRA { type T = u8; const ADDRESS: *mut u8 = 0x7a as *mut u8; } +#[allow(non_camel_case_types)] pub struct ADCSRB; impl ADCSRB { @@ -815,6 +851,7 @@ impl Register for ADCSRB { type T = u8; const ADDRESS: *mut u8 = 0x7b as *mut u8; } +#[allow(non_camel_case_types)] pub struct DIDR0; impl DIDR0 { @@ -842,6 +879,7 @@ impl Register for DIDR0 { type T = u8; const ADDRESS: *mut u8 = 0x7e as *mut u8; } +#[allow(non_camel_case_types)] pub struct ACSR; impl ACSR { @@ -873,6 +911,7 @@ impl Register for ACSR { type T = u8; const ADDRESS: *mut u8 = 0x50 as *mut u8; } +#[allow(non_camel_case_types)] pub struct DIDR1; impl DIDR1 { @@ -888,6 +927,7 @@ impl Register for DIDR1 { type T = u8; const ADDRESS: *mut u8 = 0x7f as *mut u8; } +#[allow(non_camel_case_types)] pub struct PORTB; impl PORTB { @@ -897,6 +937,7 @@ 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 { @@ -906,6 +947,7 @@ 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 { @@ -915,6 +957,7 @@ 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 { @@ -924,6 +967,7 @@ impl Register for PORTC { type T = u8; const ADDRESS: *mut u8 = 0x28 as *mut u8; } +#[allow(non_camel_case_types)] pub struct DDRC; impl DDRC { @@ -933,6 +977,7 @@ impl Register for DDRC { type T = u8; const ADDRESS: *mut u8 = 0x27 as *mut u8; } +#[allow(non_camel_case_types)] pub struct PINC; impl PINC { @@ -942,6 +987,7 @@ impl Register for PINC { type T = u8; const ADDRESS: *mut u8 = 0x26 as *mut u8; } +#[allow(non_camel_case_types)] pub struct PORTD; impl PORTD { @@ -951,6 +997,7 @@ 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 { @@ -960,6 +1007,7 @@ 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 { @@ -969,6 +1017,7 @@ impl Register for PIND { type T = u8; const ADDRESS: *mut u8 = 0x29 as *mut u8; } +#[allow(non_camel_case_types)] pub struct OCR0B; impl OCR0B { @@ -988,6 +1037,7 @@ impl Register for OCR0B { type T = u8; const ADDRESS: *mut u8 = 0x48 as *mut u8; } +#[allow(non_camel_case_types)] pub struct OCR0A; impl OCR0A { @@ -1007,6 +1057,7 @@ impl Register for OCR0A { type T = u8; const ADDRESS: *mut u8 = 0x47 as *mut u8; } +#[allow(non_camel_case_types)] pub struct TCNT0; impl TCNT0 { @@ -1026,6 +1077,7 @@ impl Register for TCNT0 { type T = u8; const ADDRESS: *mut u8 = 0x46 as *mut u8; } +#[allow(non_camel_case_types)] pub struct TCCR0B; impl TCCR0B { @@ -1049,6 +1101,7 @@ impl Register for TCCR0B { type T = u8; const ADDRESS: *mut u8 = 0x45 as *mut u8; } +#[allow(non_camel_case_types)] pub struct TCCR0A; impl TCCR0A { @@ -1070,6 +1123,7 @@ impl Register for TCCR0A { type T = u8; const ADDRESS: *mut u8 = 0x44 as *mut u8; } +#[allow(non_camel_case_types)] pub struct TIMSK0; impl TIMSK0 { @@ -1088,6 +1142,7 @@ 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 { @@ -1106,6 +1161,7 @@ impl Register for TIFR0 { type T = u8; const ADDRESS: *mut u8 = 0x35 as *mut u8; } +#[allow(non_camel_case_types)] pub struct EICRA; impl EICRA { @@ -1123,6 +1179,7 @@ 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 { @@ -1136,6 +1193,7 @@ 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 { @@ -1149,6 +1207,7 @@ 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 { @@ -1163,6 +1222,7 @@ impl Register for PCICR { type T = u8; const ADDRESS: *mut u8 = 0x68 as *mut u8; } +#[allow(non_camel_case_types)] pub struct PCMSK2; impl PCMSK2 { @@ -1182,6 +1242,7 @@ impl Register for PCMSK2 { type T = u8; const ADDRESS: *mut u8 = 0x6d as *mut u8; } +#[allow(non_camel_case_types)] pub struct PCMSK1; impl PCMSK1 { @@ -1200,6 +1261,7 @@ 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 { @@ -1219,6 +1281,7 @@ impl Register for PCMSK0 { type T = u8; const ADDRESS: *mut u8 = 0x6b as *mut u8; } +#[allow(non_camel_case_types)] pub struct PCIFR; impl PCIFR { @@ -1233,6 +1296,7 @@ impl Register for PCIFR { type T = u8; const ADDRESS: *mut u8 = 0x3b as *mut u8; } +#[allow(non_camel_case_types)] pub struct SPDR; impl SPDR { @@ -1252,6 +1316,7 @@ impl Register for SPDR { type T = u8; const ADDRESS: *mut u8 = 0x4e as *mut u8; } +#[allow(non_camel_case_types)] pub struct SPSR; impl SPSR { @@ -1270,6 +1335,7 @@ impl Register for SPSR { type T = u8; const ADDRESS: *mut u8 = 0x4d as *mut u8; } +#[allow(non_camel_case_types)] pub struct SPCR; impl SPCR { @@ -1301,6 +1367,7 @@ impl Register for SPCR { type T = u8; const ADDRESS: *mut u8 = 0x4c as *mut u8; } +#[allow(non_camel_case_types)] pub struct WDTCSR; impl WDTCSR { @@ -1328,6 +1395,7 @@ impl Register for WDTCSR { type T = u8; const ADDRESS: *mut u8 = 0x60 as *mut u8; } +#[allow(non_camel_case_types)] pub struct EEAR; impl EEAR { @@ -1349,6 +1417,7 @@ 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 { @@ -1368,6 +1437,7 @@ 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 { @@ -1393,6 +1463,7 @@ impl Register for EECR { type T = u8; const ADDRESS: *mut u8 = 0x3f as *mut u8; } +#[allow(non_camel_case_types)] pub struct PRR; impl PRR { @@ -1423,6 +1494,7 @@ impl Register for PRR { type T = u8; const ADDRESS: *mut u8 = 0x64 as *mut u8; } +#[allow(non_camel_case_types)] pub struct OSCCAL; impl OSCCAL { @@ -1442,6 +1514,7 @@ impl Register for OSCCAL { type T = u8; const ADDRESS: *mut u8 = 0x66 as *mut u8; } +#[allow(non_camel_case_types)] pub struct CLKPR; impl CLKPR { @@ -1460,6 +1533,7 @@ impl Register for CLKPR { type T = u8; const ADDRESS: *mut u8 = 0x61 as *mut u8; } +#[allow(non_camel_case_types)] pub struct SREG; impl SREG { @@ -1493,6 +1567,7 @@ 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 { @@ -1502,6 +1577,7 @@ 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 { @@ -1535,6 +1611,7 @@ 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 { @@ -1553,6 +1630,7 @@ 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 { @@ -1574,6 +1652,7 @@ impl Register for MCUSR { type T = u8; const ADDRESS: *mut u8 = 0x54 as *mut u8; } +#[allow(non_camel_case_types)] pub struct SMCR; impl SMCR { @@ -1591,6 +1670,7 @@ 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 { @@ -1610,6 +1690,7 @@ 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 { @@ -1629,6 +1710,7 @@ 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 { @@ -1649,6 +1731,8 @@ impl Register for GPIOR0 { const ADDRESS: *mut u8 = 0x3e as *mut u8; } pub mod port { + #![allow(unused_imports)] + use super::*; use crate::Pin; diff --git a/src/cores/atmega328p.rs b/src/cores/atmega328p.rs new file mode 100644 index 0000000..bbf440a --- /dev/null +++ b/src/cores/atmega328p.rs @@ -0,0 +1,1863 @@ +//! Core for ATmega328P. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + 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 UDR0; + +impl UDR0 { +} + +impl Register for UDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0xc6 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 = 0xc0 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 = 0xc1 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 = 0xc2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRR0; + +impl UBRR0 { +} + +impl Register for UBRR0 { + type T = u16; + const ADDRESS: *mut u16 = 0xc4 as *mut u16; +} +#[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 TIMSK1; + +impl TIMSK1 { + pub const ICIE1: RegisterBits = RegisterBits::new(0x20); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 ICF1: RegisterBits = RegisterBits::new(0x20); + pub const ICF10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x4); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 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 = 0x80 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 = 0x81 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 = 0x82 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 OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x88 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x8a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x86 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct TIMSK2; + +impl TIMSK2 { + pub const OCIE2B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCIE2A: RegisterBits = RegisterBits::new(0x2); + pub const OCIE2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOIE2: RegisterBits = RegisterBits::new(0x1); + pub const TOIE20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x70 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR2; + +impl TIFR2 { + pub const OCF2B: RegisterBits = RegisterBits::new(0x4); + pub const OCF2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCF2A: RegisterBits = RegisterBits::new(0x2); + pub const OCF2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOV2: RegisterBits = RegisterBits::new(0x1); + pub const TOV20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2A; + +impl TCCR2A { + pub const COM2A: RegisterBits = RegisterBits::new(0xc0); + pub const COM2A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM2A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM2B: RegisterBits = RegisterBits::new(0x30); + pub const COM2B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM2B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM2: RegisterBits = RegisterBits::new(0x3); + pub const WGM20: RegisterBits = RegisterBits::new(1<<0); + pub const WGM21: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2B; + +impl TCCR2B { + pub const FOC2A: RegisterBits = RegisterBits::new(0x80); + pub const FOC2A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC2B: RegisterBits = RegisterBits::new(0x40); + pub const FOC2B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM22: RegisterBits = RegisterBits::new(0x8); + pub const WGM220: RegisterBits = RegisterBits::new(1<<3); + + pub const CS2: RegisterBits = RegisterBits::new(0x7); + pub const CS20: RegisterBits = RegisterBits::new(1<<0); + pub const CS21: RegisterBits = RegisterBits::new(1<<1); + pub const CS22: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT2; + +impl TCNT2 { +} + +impl Register for TCNT2 { + type T = u8; + const ADDRESS: *mut u8 = 0xb2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2B; + +impl OCR2B { +} + +impl Register for OCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb4 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2A; + +impl OCR2A { +} + +impl Register for OCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb3 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ASSR; + +impl ASSR { + pub const EXCLK: RegisterBits = RegisterBits::new(0x40); + pub const EXCLK0: RegisterBits = RegisterBits::new(1<<6); + + pub const AS2: RegisterBits = RegisterBits::new(0x20); + pub const AS20: RegisterBits = RegisterBits::new(1<<5); + + pub const TCN2UB: RegisterBits = RegisterBits::new(0x10); + pub const TCN2UB0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCR2AUB: RegisterBits = RegisterBits::new(0x8); + pub const OCR2AUB0: RegisterBits = RegisterBits::new(1<<3); + + pub const OCR2BUB: RegisterBits = RegisterBits::new(0x4); + pub const OCR2BUB0: RegisterBits = RegisterBits::new(1<<2); + + pub const TCR2AUB: RegisterBits = RegisterBits::new(0x2); + pub const TCR2AUB0: RegisterBits = RegisterBits::new(1<<1); + + pub const TCR2BUB: RegisterBits = RegisterBits::new(0x1); + pub const TCR2BUB0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for ASSR { + type T = u8; + const ADDRESS: *mut u8 = 0xb6 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 = 0x7c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x78 as *mut u16; +} +#[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 = 0x7a 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); + + 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 = 0x7b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + 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 = 0x7e 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 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + 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 DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x7f 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 DDRC; + +impl DDRC { +} + +impl Register for DDRC { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINC; + +impl PINC { +} + +impl Register for PINC { + type T = u8; + const ADDRESS: *mut u8 = 0x26 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 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 OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x47 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 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 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 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 EICRA; + +impl EICRA { + 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(0x3); + pub const INT0: RegisterBits = RegisterBits::new(1<<0); + pub const INT1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x3); + pub const INTF0: RegisterBits = RegisterBits::new(1<<0); + pub const INTF1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x7); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIE2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCICR { + type T = u8; + const ADDRESS: *mut u8 = 0x68 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK2; + +impl PCMSK2 { + 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 PCMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x6d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { + 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 PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x6c 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 = 0x6b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCIFR; + +impl PCIFR { + pub const PCIF: RegisterBits = RegisterBits::new(0x7); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIF2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPDR; + +impl SPDR { +} + +impl Register for SPDR { + type T = u8; + const ADDRESS: *mut u8 = 0x4e 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 = 0x4d 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 = 0x4c 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 PRR; + +impl PRR { + pub const PRTWI: RegisterBits = RegisterBits::new(0x80); + pub const PRTWI0: RegisterBits = RegisterBits::new(1<<7); + + pub const PRTIM2: RegisterBits = RegisterBits::new(0x40); + pub const PRTIM20: RegisterBits = RegisterBits::new(1<<6); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x20); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<5); + + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRSPI: RegisterBits = RegisterBits::new(0x4); + pub const PRSPI0: 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 = 0x64 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 = 0x66 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 = 0x61 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 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 MCUCR; + +impl MCUCR { + pub const BODS: RegisterBits = RegisterBits::new(0x40); + pub const BODS0: RegisterBits = RegisterBits::new(1<<6); + + pub const BODSE: RegisterBits = RegisterBits::new(0x20); + pub const BODSE0: RegisterBits = RegisterBits::new(1<<5); + + 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 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 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 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; + + 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; + } + + pub struct C0; + + impl Pin for C0 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC0 + const MASK: u8 = 1<<0; + } + + pub struct C1; + + impl Pin for C1 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC1 + const MASK: u8 = 1<<1; + } + + pub struct C2; + + impl Pin for C2 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC2 + const MASK: u8 = 1<<2; + } + + pub struct C3; + + impl Pin for C3 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC3 + const MASK: u8 = 1<<3; + } + + pub struct C4; + + impl Pin for C4 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC4 + const MASK: u8 = 1<<4; + } + + pub struct C5; + + impl Pin for C5 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC5 + const MASK: u8 = 1<<5; + } + + pub struct C6; + + impl Pin for C6 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC6 + const MASK: u8 = 1<<6; + } + + pub struct D0; + + impl Pin for D0 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD0 + const MASK: u8 = 1<<0; + } + + pub struct D1; + + impl Pin for D1 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD1 + const MASK: u8 = 1<<1; + } + + pub struct D2; + + impl Pin for D2 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD2 + const MASK: u8 = 1<<2; + } + + pub struct D3; + + impl Pin for D3 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD3 + const MASK: u8 = 1<<3; + } + + pub struct D4; + + impl Pin for D4 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD4 + const MASK: u8 = 1<<4; + } + + pub struct D5; + + impl Pin for D5 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD5 + const MASK: u8 = 1<<5; + } + + pub struct D6; + + impl Pin for D6 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD6 + const MASK: u8 = 1<<6; + } + + pub struct D7; + + impl Pin for D7 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD7 + const MASK: u8 = 1<<7; + } + +} + +pub struct Spi; + +impl modules::HardwareSpi for Spi { + type SlaveSelect = port::B2; + type MasterOutSlaveIn = port::B3; + type MasterInSlaveOut = port::B4; + type Clock = port::B5; + type DataRegister = SPDR; + type StatusRegister = SPSR; + type ControlRegister = SPCR; +} + +/// The USART0 module. +pub struct USART0; + +impl modules::HardwareUsart for USART0 { + type DataRegister = UDR0; + type ControlRegisterA = UCSR0A; + type ControlRegisterB = UCSR0B; + type ControlRegisterC = UCSR0C; + type BaudRateRegister = UBRR0; +} + +/// 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; +} +/// 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/atmega48.rs b/src/cores/atmega48.rs new file mode 100644 index 0000000..7c75020 --- /dev/null +++ b/src/cores/atmega48.rs @@ -0,0 +1,1836 @@ +//! Core for ATmega48. + +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 UDR0; + +impl UDR0 { +} + +impl Register for UDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0xc6 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 = 0xc0 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 = 0xc1 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 = 0xc2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRR0; + +impl UBRR0 { +} + +impl Register for UBRR0 { + type T = u16; + const ADDRESS: *mut u16 = 0xc4 as *mut u16; +} +#[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 TIMSK1; + +impl TIMSK1 { + pub const ICIE1: RegisterBits = RegisterBits::new(0x20); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 ICF1: RegisterBits = RegisterBits::new(0x20); + pub const ICF10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x4); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 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 = 0x80 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 = 0x81 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 = 0x82 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 OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x88 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x8a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x86 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct TIMSK2; + +impl TIMSK2 { + pub const OCIE2B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCIE2A: RegisterBits = RegisterBits::new(0x2); + pub const OCIE2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOIE2: RegisterBits = RegisterBits::new(0x1); + pub const TOIE20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x70 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR2; + +impl TIFR2 { + pub const OCF2B: RegisterBits = RegisterBits::new(0x4); + pub const OCF2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCF2A: RegisterBits = RegisterBits::new(0x2); + pub const OCF2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOV2: RegisterBits = RegisterBits::new(0x1); + pub const TOV20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2A; + +impl TCCR2A { + pub const COM2A: RegisterBits = RegisterBits::new(0xc0); + pub const COM2A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM2A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM2B: RegisterBits = RegisterBits::new(0x30); + pub const COM2B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM2B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM2: RegisterBits = RegisterBits::new(0x3); + pub const WGM20: RegisterBits = RegisterBits::new(1<<0); + pub const WGM21: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2B; + +impl TCCR2B { + pub const FOC2A: RegisterBits = RegisterBits::new(0x80); + pub const FOC2A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC2B: RegisterBits = RegisterBits::new(0x40); + pub const FOC2B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM22: RegisterBits = RegisterBits::new(0x8); + pub const WGM220: RegisterBits = RegisterBits::new(1<<3); + + pub const CS2: RegisterBits = RegisterBits::new(0x7); + pub const CS20: RegisterBits = RegisterBits::new(1<<0); + pub const CS21: RegisterBits = RegisterBits::new(1<<1); + pub const CS22: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT2; + +impl TCNT2 { +} + +impl Register for TCNT2 { + type T = u8; + const ADDRESS: *mut u8 = 0xb2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2B; + +impl OCR2B { +} + +impl Register for OCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb4 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2A; + +impl OCR2A { +} + +impl Register for OCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb3 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ASSR; + +impl ASSR { + pub const EXCLK: RegisterBits = RegisterBits::new(0x40); + pub const EXCLK0: RegisterBits = RegisterBits::new(1<<6); + + pub const AS2: RegisterBits = RegisterBits::new(0x20); + pub const AS20: RegisterBits = RegisterBits::new(1<<5); + + pub const TCN2UB: RegisterBits = RegisterBits::new(0x10); + pub const TCN2UB0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCR2AUB: RegisterBits = RegisterBits::new(0x8); + pub const OCR2AUB0: RegisterBits = RegisterBits::new(1<<3); + + pub const OCR2BUB: RegisterBits = RegisterBits::new(0x4); + pub const OCR2BUB0: RegisterBits = RegisterBits::new(1<<2); + + pub const TCR2AUB: RegisterBits = RegisterBits::new(0x2); + pub const TCR2AUB0: RegisterBits = RegisterBits::new(1<<1); + + pub const TCR2BUB: RegisterBits = RegisterBits::new(0x1); + pub const TCR2BUB0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for ASSR { + type T = u8; + const ADDRESS: *mut u8 = 0xb6 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 = 0x7c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x78 as *mut u16; +} +#[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 = 0x7a 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); + + 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 = 0x7b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + 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 = 0x7e 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 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + 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 DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x7f 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 DDRC; + +impl DDRC { +} + +impl Register for DDRC { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINC; + +impl PINC { +} + +impl Register for PINC { + type T = u8; + const ADDRESS: *mut u8 = 0x26 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 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 OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x47 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 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 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 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 EICRA; + +impl EICRA { + 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(0x3); + pub const INT0: RegisterBits = RegisterBits::new(1<<0); + pub const INT1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x3); + pub const INTF0: RegisterBits = RegisterBits::new(1<<0); + pub const INTF1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x7); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIE2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCICR { + type T = u8; + const ADDRESS: *mut u8 = 0x68 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK2; + +impl PCMSK2 { + 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 PCMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x6d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { + 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 PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x6c 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 = 0x6b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCIFR; + +impl PCIFR { + pub const PCIF: RegisterBits = RegisterBits::new(0x7); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIF2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPDR; + +impl SPDR { +} + +impl Register for SPDR { + type T = u8; + const ADDRESS: *mut u8 = 0x4e 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 = 0x4d 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 = 0x4c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTWI: RegisterBits = RegisterBits::new(0x80); + pub const PRTWI0: RegisterBits = RegisterBits::new(1<<7); + + pub const PRTIM2: RegisterBits = RegisterBits::new(0x40); + pub const PRTIM20: RegisterBits = RegisterBits::new(1<<6); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x20); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<5); + + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRSPI: RegisterBits = RegisterBits::new(0x4); + pub const PRSPI0: 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 = 0x64 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 = 0x66 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 = 0x61 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 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 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 SELFPRGEN: RegisterBits = RegisterBits::new(0x1); + pub const SELFPRGEN0: 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(0x10); + pub const PUD0: RegisterBits = RegisterBits::new(1<<4); + +} + +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 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 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 EEARL; + +impl EEARL { +} + +impl Register for EEARL { + type T = u8; + const ADDRESS: *mut u8 = 0x41 as *mut u8; +} +#[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; + + 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; + } + + pub struct C0; + + impl Pin for C0 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC0 + const MASK: u8 = 1<<0; + } + + pub struct C1; + + impl Pin for C1 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC1 + const MASK: u8 = 1<<1; + } + + pub struct C2; + + impl Pin for C2 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC2 + const MASK: u8 = 1<<2; + } + + pub struct C3; + + impl Pin for C3 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC3 + const MASK: u8 = 1<<3; + } + + pub struct C4; + + impl Pin for C4 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC4 + const MASK: u8 = 1<<4; + } + + pub struct C5; + + impl Pin for C5 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC5 + const MASK: u8 = 1<<5; + } + + pub struct C6; + + impl Pin for C6 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC6 + const MASK: u8 = 1<<6; + } + + pub struct D0; + + impl Pin for D0 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD0 + const MASK: u8 = 1<<0; + } + + pub struct D1; + + impl Pin for D1 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD1 + const MASK: u8 = 1<<1; + } + + pub struct D2; + + impl Pin for D2 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD2 + const MASK: u8 = 1<<2; + } + + pub struct D3; + + impl Pin for D3 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD3 + const MASK: u8 = 1<<3; + } + + pub struct D4; + + impl Pin for D4 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD4 + const MASK: u8 = 1<<4; + } + + pub struct D5; + + impl Pin for D5 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD5 + const MASK: u8 = 1<<5; + } + + pub struct D6; + + impl Pin for D6 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD6 + const MASK: u8 = 1<<6; + } + + pub struct D7; + + impl Pin for D7 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD7 + const MASK: u8 = 1<<7; + } + +} + +pub struct Spi; + +impl modules::HardwareSpi for Spi { + type SlaveSelect = port::B2; + type MasterOutSlaveIn = port::B3; + type MasterInSlaveOut = port::B4; + type Clock = port::B5; + type DataRegister = SPDR; + type StatusRegister = SPSR; + type ControlRegister = SPCR; +} + +/// The USART0 module. +pub struct USART0; + +impl modules::HardwareUsart for USART0 { + type DataRegister = UDR0; + type ControlRegisterA = UCSR0A; + type ControlRegisterB = UCSR0B; + type ControlRegisterC = UCSR0C; + type BaudRateRegister = UBRR0; +} + +/// 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; +} +/// 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/atmega48a.rs b/src/cores/atmega48a.rs new file mode 100644 index 0000000..5a54179 --- /dev/null +++ b/src/cores/atmega48a.rs @@ -0,0 +1,1861 @@ +//! Core for ATmega48A. + +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 UDR0; + +impl UDR0 { +} + +impl Register for UDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0xc6 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 = 0xc0 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 = 0xc1 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 = 0xc2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRR0; + +impl UBRR0 { +} + +impl Register for UBRR0 { + type T = u16; + const ADDRESS: *mut u16 = 0xc4 as *mut u16; +} +#[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 TIMSK1; + +impl TIMSK1 { + pub const ICIE1: RegisterBits = RegisterBits::new(0x20); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 ICF1: RegisterBits = RegisterBits::new(0x20); + pub const ICF10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x4); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 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 = 0x80 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 = 0x81 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 = 0x82 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 OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x88 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x8a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x86 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct TIMSK2; + +impl TIMSK2 { + pub const OCIE2B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCIE2A: RegisterBits = RegisterBits::new(0x2); + pub const OCIE2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOIE2: RegisterBits = RegisterBits::new(0x1); + pub const TOIE20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x70 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR2; + +impl TIFR2 { + pub const OCF2B: RegisterBits = RegisterBits::new(0x4); + pub const OCF2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCF2A: RegisterBits = RegisterBits::new(0x2); + pub const OCF2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOV2: RegisterBits = RegisterBits::new(0x1); + pub const TOV20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2A; + +impl TCCR2A { + pub const COM2A: RegisterBits = RegisterBits::new(0xc0); + pub const COM2A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM2A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM2B: RegisterBits = RegisterBits::new(0x30); + pub const COM2B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM2B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM2: RegisterBits = RegisterBits::new(0x3); + pub const WGM20: RegisterBits = RegisterBits::new(1<<0); + pub const WGM21: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2B; + +impl TCCR2B { + pub const FOC2A: RegisterBits = RegisterBits::new(0x80); + pub const FOC2A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC2B: RegisterBits = RegisterBits::new(0x40); + pub const FOC2B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM22: RegisterBits = RegisterBits::new(0x8); + pub const WGM220: RegisterBits = RegisterBits::new(1<<3); + + pub const CS2: RegisterBits = RegisterBits::new(0x7); + pub const CS20: RegisterBits = RegisterBits::new(1<<0); + pub const CS21: RegisterBits = RegisterBits::new(1<<1); + pub const CS22: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT2; + +impl TCNT2 { +} + +impl Register for TCNT2 { + type T = u8; + const ADDRESS: *mut u8 = 0xb2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2B; + +impl OCR2B { +} + +impl Register for OCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb4 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2A; + +impl OCR2A { +} + +impl Register for OCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb3 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ASSR; + +impl ASSR { + pub const EXCLK: RegisterBits = RegisterBits::new(0x40); + pub const EXCLK0: RegisterBits = RegisterBits::new(1<<6); + + pub const AS2: RegisterBits = RegisterBits::new(0x20); + pub const AS20: RegisterBits = RegisterBits::new(1<<5); + + pub const TCN2UB: RegisterBits = RegisterBits::new(0x10); + pub const TCN2UB0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCR2AUB: RegisterBits = RegisterBits::new(0x8); + pub const OCR2AUB0: RegisterBits = RegisterBits::new(1<<3); + + pub const OCR2BUB: RegisterBits = RegisterBits::new(0x4); + pub const OCR2BUB0: RegisterBits = RegisterBits::new(1<<2); + + pub const TCR2AUB: RegisterBits = RegisterBits::new(0x2); + pub const TCR2AUB0: RegisterBits = RegisterBits::new(1<<1); + + pub const TCR2BUB: RegisterBits = RegisterBits::new(0x1); + pub const TCR2BUB0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for ASSR { + type T = u8; + const ADDRESS: *mut u8 = 0xb6 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 = 0x7c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x78 as *mut u16; +} +#[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 = 0x7a 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); + + 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 = 0x7b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + 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 = 0x7e 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 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + 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 DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x7f 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 DDRC; + +impl DDRC { +} + +impl Register for DDRC { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINC; + +impl PINC { +} + +impl Register for PINC { + type T = u8; + const ADDRESS: *mut u8 = 0x26 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 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 OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x47 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 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 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 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 EICRA; + +impl EICRA { + 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(0x3); + pub const INT0: RegisterBits = RegisterBits::new(1<<0); + pub const INT1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x3); + pub const INTF0: RegisterBits = RegisterBits::new(1<<0); + pub const INTF1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x7); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIE2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCICR { + type T = u8; + const ADDRESS: *mut u8 = 0x68 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK2; + +impl PCMSK2 { + 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 PCMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x6d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { + 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 PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x6c 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 = 0x6b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCIFR; + +impl PCIFR { + pub const PCIF: RegisterBits = RegisterBits::new(0x7); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIF2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPDR; + +impl SPDR { +} + +impl Register for SPDR { + type T = u8; + const ADDRESS: *mut u8 = 0x4e 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 = 0x4d 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 = 0x4c 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 EEARH; + +impl EEARH { + pub const EEAR8: RegisterBits = RegisterBits::new(0x1); + pub const EEAR80: RegisterBits = RegisterBits::new(1<<0); + + pub const EEAR9: RegisterBits = RegisterBits::new(0x2); + pub const EEAR90: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for EEARH { + type T = u8; + const ADDRESS: *mut u8 = 0x42 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEARL; + +impl EEARL { +} + +impl Register for EEARL { + type T = u8; + const ADDRESS: *mut u8 = 0x41 as *mut u8; +} +#[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; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTWI: RegisterBits = RegisterBits::new(0x80); + pub const PRTWI0: RegisterBits = RegisterBits::new(1<<7); + + pub const PRTIM2: RegisterBits = RegisterBits::new(0x40); + pub const PRTIM20: RegisterBits = RegisterBits::new(1<<6); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x20); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<5); + + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRSPI: RegisterBits = RegisterBits::new(0x4); + pub const PRSPI0: 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 = 0x64 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 = 0x66 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 = 0x61 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 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 MCUCR; + +impl MCUCR { + 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 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 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; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + + 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; + } + + pub struct C0; + + impl Pin for C0 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC0 + const MASK: u8 = 1<<0; + } + + pub struct C1; + + impl Pin for C1 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC1 + const MASK: u8 = 1<<1; + } + + pub struct C2; + + impl Pin for C2 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC2 + const MASK: u8 = 1<<2; + } + + pub struct C3; + + impl Pin for C3 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC3 + const MASK: u8 = 1<<3; + } + + pub struct C4; + + impl Pin for C4 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC4 + const MASK: u8 = 1<<4; + } + + pub struct C5; + + impl Pin for C5 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC5 + const MASK: u8 = 1<<5; + } + + pub struct C6; + + impl Pin for C6 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC6 + const MASK: u8 = 1<<6; + } + + pub struct D0; + + impl Pin for D0 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD0 + const MASK: u8 = 1<<0; + } + + pub struct D1; + + impl Pin for D1 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD1 + const MASK: u8 = 1<<1; + } + + pub struct D2; + + impl Pin for D2 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD2 + const MASK: u8 = 1<<2; + } + + pub struct D3; + + impl Pin for D3 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD3 + const MASK: u8 = 1<<3; + } + + pub struct D4; + + impl Pin for D4 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD4 + const MASK: u8 = 1<<4; + } + + pub struct D5; + + impl Pin for D5 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD5 + const MASK: u8 = 1<<5; + } + + pub struct D6; + + impl Pin for D6 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD6 + const MASK: u8 = 1<<6; + } + + pub struct D7; + + impl Pin for D7 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD7 + const MASK: u8 = 1<<7; + } + +} + +pub struct Spi; + +impl modules::HardwareSpi for Spi { + type SlaveSelect = port::B2; + type MasterOutSlaveIn = port::B3; + type MasterInSlaveOut = port::B4; + type Clock = port::B5; + type DataRegister = SPDR; + type StatusRegister = SPSR; + type ControlRegister = SPCR; +} + +/// The USART0 module. +pub struct USART0; + +impl modules::HardwareUsart for USART0 { + type DataRegister = UDR0; + type ControlRegisterA = UCSR0A; + type ControlRegisterB = UCSR0B; + type ControlRegisterC = UCSR0C; + type BaudRateRegister = UBRR0; +} + +/// 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; +} +/// 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/atmega48p.rs b/src/cores/atmega48p.rs new file mode 100644 index 0000000..47285d3 --- /dev/null +++ b/src/cores/atmega48p.rs @@ -0,0 +1,1842 @@ +//! Core for ATmega48P. + +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 UDR0; + +impl UDR0 { +} + +impl Register for UDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0xc6 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 = 0xc0 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 = 0xc1 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 = 0xc2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRR0; + +impl UBRR0 { +} + +impl Register for UBRR0 { + type T = u16; + const ADDRESS: *mut u16 = 0xc4 as *mut u16; +} +#[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 TIMSK1; + +impl TIMSK1 { + pub const ICIE1: RegisterBits = RegisterBits::new(0x20); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 ICF1: RegisterBits = RegisterBits::new(0x20); + pub const ICF10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x4); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 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 = 0x80 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 = 0x81 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 = 0x82 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 OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x88 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x8a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x86 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct TIMSK2; + +impl TIMSK2 { + pub const OCIE2B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCIE2A: RegisterBits = RegisterBits::new(0x2); + pub const OCIE2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOIE2: RegisterBits = RegisterBits::new(0x1); + pub const TOIE20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x70 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR2; + +impl TIFR2 { + pub const OCF2B: RegisterBits = RegisterBits::new(0x4); + pub const OCF2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCF2A: RegisterBits = RegisterBits::new(0x2); + pub const OCF2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOV2: RegisterBits = RegisterBits::new(0x1); + pub const TOV20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2A; + +impl TCCR2A { + pub const COM2A: RegisterBits = RegisterBits::new(0xc0); + pub const COM2A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM2A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM2B: RegisterBits = RegisterBits::new(0x30); + pub const COM2B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM2B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM2: RegisterBits = RegisterBits::new(0x3); + pub const WGM20: RegisterBits = RegisterBits::new(1<<0); + pub const WGM21: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2B; + +impl TCCR2B { + pub const FOC2A: RegisterBits = RegisterBits::new(0x80); + pub const FOC2A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC2B: RegisterBits = RegisterBits::new(0x40); + pub const FOC2B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM22: RegisterBits = RegisterBits::new(0x8); + pub const WGM220: RegisterBits = RegisterBits::new(1<<3); + + pub const CS2: RegisterBits = RegisterBits::new(0x7); + pub const CS20: RegisterBits = RegisterBits::new(1<<0); + pub const CS21: RegisterBits = RegisterBits::new(1<<1); + pub const CS22: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT2; + +impl TCNT2 { +} + +impl Register for TCNT2 { + type T = u8; + const ADDRESS: *mut u8 = 0xb2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2B; + +impl OCR2B { +} + +impl Register for OCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb4 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2A; + +impl OCR2A { +} + +impl Register for OCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb3 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ASSR; + +impl ASSR { + pub const EXCLK: RegisterBits = RegisterBits::new(0x40); + pub const EXCLK0: RegisterBits = RegisterBits::new(1<<6); + + pub const AS2: RegisterBits = RegisterBits::new(0x20); + pub const AS20: RegisterBits = RegisterBits::new(1<<5); + + pub const TCN2UB: RegisterBits = RegisterBits::new(0x10); + pub const TCN2UB0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCR2AUB: RegisterBits = RegisterBits::new(0x8); + pub const OCR2AUB0: RegisterBits = RegisterBits::new(1<<3); + + pub const OCR2BUB: RegisterBits = RegisterBits::new(0x4); + pub const OCR2BUB0: RegisterBits = RegisterBits::new(1<<2); + + pub const TCR2AUB: RegisterBits = RegisterBits::new(0x2); + pub const TCR2AUB0: RegisterBits = RegisterBits::new(1<<1); + + pub const TCR2BUB: RegisterBits = RegisterBits::new(0x1); + pub const TCR2BUB0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for ASSR { + type T = u8; + const ADDRESS: *mut u8 = 0xb6 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 = 0x7c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x78 as *mut u16; +} +#[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 = 0x7a 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); + + 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 = 0x7b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + 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 = 0x7e 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 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + 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 DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x7f 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 DDRC; + +impl DDRC { +} + +impl Register for DDRC { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINC; + +impl PINC { +} + +impl Register for PINC { + type T = u8; + const ADDRESS: *mut u8 = 0x26 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 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 OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x47 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 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 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 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 EICRA; + +impl EICRA { + 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(0x3); + pub const INT0: RegisterBits = RegisterBits::new(1<<0); + pub const INT1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x3); + pub const INTF0: RegisterBits = RegisterBits::new(1<<0); + pub const INTF1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x7); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIE2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCICR { + type T = u8; + const ADDRESS: *mut u8 = 0x68 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK2; + +impl PCMSK2 { + 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 PCMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x6d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { + 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 PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x6c 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 = 0x6b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCIFR; + +impl PCIFR { + pub const PCIF: RegisterBits = RegisterBits::new(0x7); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIF2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPDR; + +impl SPDR { +} + +impl Register for SPDR { + type T = u8; + const ADDRESS: *mut u8 = 0x4e 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 = 0x4d 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 = 0x4c 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 EEARL; + +impl EEARL { +} + +impl Register for EEARL { + type T = u8; + const ADDRESS: *mut u8 = 0x41 as *mut u8; +} +#[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; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTWI: RegisterBits = RegisterBits::new(0x80); + pub const PRTWI0: RegisterBits = RegisterBits::new(1<<7); + + pub const PRTIM2: RegisterBits = RegisterBits::new(0x40); + pub const PRTIM20: RegisterBits = RegisterBits::new(1<<6); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x20); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<5); + + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRSPI: RegisterBits = RegisterBits::new(0x4); + pub const PRSPI0: 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 = 0x64 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 = 0x66 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 = 0x61 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 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 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 SELFPRGEN: RegisterBits = RegisterBits::new(0x1); + pub const SELFPRGEN0: 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 BODS: RegisterBits = RegisterBits::new(0x40); + pub const BODS0: RegisterBits = RegisterBits::new(1<<6); + + pub const BODSE: RegisterBits = RegisterBits::new(0x20); + pub const BODSE0: RegisterBits = RegisterBits::new(1<<5); + + pub const PUD: RegisterBits = RegisterBits::new(0x10); + pub const PUD0: RegisterBits = RegisterBits::new(1<<4); + +} + +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 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; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + + 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; + } + + pub struct C0; + + impl Pin for C0 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC0 + const MASK: u8 = 1<<0; + } + + pub struct C1; + + impl Pin for C1 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC1 + const MASK: u8 = 1<<1; + } + + pub struct C2; + + impl Pin for C2 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC2 + const MASK: u8 = 1<<2; + } + + pub struct C3; + + impl Pin for C3 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC3 + const MASK: u8 = 1<<3; + } + + pub struct C4; + + impl Pin for C4 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC4 + const MASK: u8 = 1<<4; + } + + pub struct C5; + + impl Pin for C5 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC5 + const MASK: u8 = 1<<5; + } + + pub struct C6; + + impl Pin for C6 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC6 + const MASK: u8 = 1<<6; + } + + pub struct D0; + + impl Pin for D0 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD0 + const MASK: u8 = 1<<0; + } + + pub struct D1; + + impl Pin for D1 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD1 + const MASK: u8 = 1<<1; + } + + pub struct D2; + + impl Pin for D2 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD2 + const MASK: u8 = 1<<2; + } + + pub struct D3; + + impl Pin for D3 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD3 + const MASK: u8 = 1<<3; + } + + pub struct D4; + + impl Pin for D4 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD4 + const MASK: u8 = 1<<4; + } + + pub struct D5; + + impl Pin for D5 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD5 + const MASK: u8 = 1<<5; + } + + pub struct D6; + + impl Pin for D6 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD6 + const MASK: u8 = 1<<6; + } + + pub struct D7; + + impl Pin for D7 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD7 + const MASK: u8 = 1<<7; + } + +} + +pub struct Spi; + +impl modules::HardwareSpi for Spi { + type SlaveSelect = port::B2; + type MasterOutSlaveIn = port::B3; + type MasterInSlaveOut = port::B4; + type Clock = port::B5; + type DataRegister = SPDR; + type StatusRegister = SPSR; + type ControlRegister = SPCR; +} + +/// The USART0 module. +pub struct USART0; + +impl modules::HardwareUsart for USART0 { + type DataRegister = UDR0; + type ControlRegisterA = UCSR0A; + type ControlRegisterB = UCSR0B; + type ControlRegisterC = UCSR0C; + type BaudRateRegister = UBRR0; +} + +/// 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; +} +/// 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/atmega48pa.rs b/src/cores/atmega48pa.rs new file mode 100644 index 0000000..33ec2f0 --- /dev/null +++ b/src/cores/atmega48pa.rs @@ -0,0 +1,1867 @@ +//! Core for ATmega48PA. + +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 UDR0; + +impl UDR0 { +} + +impl Register for UDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0xc6 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 = 0xc0 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 = 0xc1 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 = 0xc2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRR0; + +impl UBRR0 { +} + +impl Register for UBRR0 { + type T = u16; + const ADDRESS: *mut u16 = 0xc4 as *mut u16; +} +#[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 TIMSK1; + +impl TIMSK1 { + pub const ICIE1: RegisterBits = RegisterBits::new(0x20); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 ICF1: RegisterBits = RegisterBits::new(0x20); + pub const ICF10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x4); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 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 = 0x80 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 = 0x81 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 = 0x82 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 OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x88 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x8a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x86 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct TIMSK2; + +impl TIMSK2 { + pub const OCIE2B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCIE2A: RegisterBits = RegisterBits::new(0x2); + pub const OCIE2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOIE2: RegisterBits = RegisterBits::new(0x1); + pub const TOIE20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x70 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR2; + +impl TIFR2 { + pub const OCF2B: RegisterBits = RegisterBits::new(0x4); + pub const OCF2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCF2A: RegisterBits = RegisterBits::new(0x2); + pub const OCF2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOV2: RegisterBits = RegisterBits::new(0x1); + pub const TOV20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2A; + +impl TCCR2A { + pub const COM2A: RegisterBits = RegisterBits::new(0xc0); + pub const COM2A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM2A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM2B: RegisterBits = RegisterBits::new(0x30); + pub const COM2B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM2B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM2: RegisterBits = RegisterBits::new(0x3); + pub const WGM20: RegisterBits = RegisterBits::new(1<<0); + pub const WGM21: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2B; + +impl TCCR2B { + pub const FOC2A: RegisterBits = RegisterBits::new(0x80); + pub const FOC2A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC2B: RegisterBits = RegisterBits::new(0x40); + pub const FOC2B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM22: RegisterBits = RegisterBits::new(0x8); + pub const WGM220: RegisterBits = RegisterBits::new(1<<3); + + pub const CS2: RegisterBits = RegisterBits::new(0x7); + pub const CS20: RegisterBits = RegisterBits::new(1<<0); + pub const CS21: RegisterBits = RegisterBits::new(1<<1); + pub const CS22: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT2; + +impl TCNT2 { +} + +impl Register for TCNT2 { + type T = u8; + const ADDRESS: *mut u8 = 0xb2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2B; + +impl OCR2B { +} + +impl Register for OCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb4 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2A; + +impl OCR2A { +} + +impl Register for OCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb3 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ASSR; + +impl ASSR { + pub const EXCLK: RegisterBits = RegisterBits::new(0x40); + pub const EXCLK0: RegisterBits = RegisterBits::new(1<<6); + + pub const AS2: RegisterBits = RegisterBits::new(0x20); + pub const AS20: RegisterBits = RegisterBits::new(1<<5); + + pub const TCN2UB: RegisterBits = RegisterBits::new(0x10); + pub const TCN2UB0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCR2AUB: RegisterBits = RegisterBits::new(0x8); + pub const OCR2AUB0: RegisterBits = RegisterBits::new(1<<3); + + pub const OCR2BUB: RegisterBits = RegisterBits::new(0x4); + pub const OCR2BUB0: RegisterBits = RegisterBits::new(1<<2); + + pub const TCR2AUB: RegisterBits = RegisterBits::new(0x2); + pub const TCR2AUB0: RegisterBits = RegisterBits::new(1<<1); + + pub const TCR2BUB: RegisterBits = RegisterBits::new(0x1); + pub const TCR2BUB0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for ASSR { + type T = u8; + const ADDRESS: *mut u8 = 0xb6 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 = 0x7c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x78 as *mut u16; +} +#[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 = 0x7a 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); + + 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 = 0x7b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + 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 = 0x7e 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 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + 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 DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x7f 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 DDRC; + +impl DDRC { +} + +impl Register for DDRC { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINC; + +impl PINC { +} + +impl Register for PINC { + type T = u8; + const ADDRESS: *mut u8 = 0x26 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 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 OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x47 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 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 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 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 EICRA; + +impl EICRA { + 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(0x3); + pub const INT0: RegisterBits = RegisterBits::new(1<<0); + pub const INT1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x3); + pub const INTF0: RegisterBits = RegisterBits::new(1<<0); + pub const INTF1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x7); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIE2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCICR { + type T = u8; + const ADDRESS: *mut u8 = 0x68 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK2; + +impl PCMSK2 { + 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 PCMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x6d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { + 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 PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x6c 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 = 0x6b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCIFR; + +impl PCIFR { + pub const PCIF: RegisterBits = RegisterBits::new(0x7); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIF2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPDR; + +impl SPDR { +} + +impl Register for SPDR { + type T = u8; + const ADDRESS: *mut u8 = 0x4e 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 = 0x4d 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 = 0x4c 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 EEARH; + +impl EEARH { + pub const EEAR8: RegisterBits = RegisterBits::new(0x1); + pub const EEAR80: RegisterBits = RegisterBits::new(1<<0); + + pub const EEAR9: RegisterBits = RegisterBits::new(0x2); + pub const EEAR90: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for EEARH { + type T = u8; + const ADDRESS: *mut u8 = 0x42 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct EEARL; + +impl EEARL { +} + +impl Register for EEARL { + type T = u8; + const ADDRESS: *mut u8 = 0x41 as *mut u8; +} +#[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; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTWI: RegisterBits = RegisterBits::new(0x80); + pub const PRTWI0: RegisterBits = RegisterBits::new(1<<7); + + pub const PRTIM2: RegisterBits = RegisterBits::new(0x40); + pub const PRTIM20: RegisterBits = RegisterBits::new(1<<6); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x20); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<5); + + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRSPI: RegisterBits = RegisterBits::new(0x4); + pub const PRSPI0: 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 = 0x64 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 = 0x66 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 = 0x61 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 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 MCUCR; + +impl MCUCR { + pub const BODS: RegisterBits = RegisterBits::new(0x40); + pub const BODS0: RegisterBits = RegisterBits::new(1<<6); + + pub const BODSE: RegisterBits = RegisterBits::new(0x20); + pub const BODSE0: RegisterBits = RegisterBits::new(1<<5); + + 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 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 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; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + + 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; + } + + pub struct C0; + + impl Pin for C0 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC0 + const MASK: u8 = 1<<0; + } + + pub struct C1; + + impl Pin for C1 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC1 + const MASK: u8 = 1<<1; + } + + pub struct C2; + + impl Pin for C2 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC2 + const MASK: u8 = 1<<2; + } + + pub struct C3; + + impl Pin for C3 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC3 + const MASK: u8 = 1<<3; + } + + pub struct C4; + + impl Pin for C4 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC4 + const MASK: u8 = 1<<4; + } + + pub struct C5; + + impl Pin for C5 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC5 + const MASK: u8 = 1<<5; + } + + pub struct C6; + + impl Pin for C6 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC6 + const MASK: u8 = 1<<6; + } + + pub struct D0; + + impl Pin for D0 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD0 + const MASK: u8 = 1<<0; + } + + pub struct D1; + + impl Pin for D1 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD1 + const MASK: u8 = 1<<1; + } + + pub struct D2; + + impl Pin for D2 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD2 + const MASK: u8 = 1<<2; + } + + pub struct D3; + + impl Pin for D3 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD3 + const MASK: u8 = 1<<3; + } + + pub struct D4; + + impl Pin for D4 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD4 + const MASK: u8 = 1<<4; + } + + pub struct D5; + + impl Pin for D5 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD5 + const MASK: u8 = 1<<5; + } + + pub struct D6; + + impl Pin for D6 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD6 + const MASK: u8 = 1<<6; + } + + pub struct D7; + + impl Pin for D7 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD7 + const MASK: u8 = 1<<7; + } + +} + +pub struct Spi; + +impl modules::HardwareSpi for Spi { + type SlaveSelect = port::B2; + type MasterOutSlaveIn = port::B3; + type MasterInSlaveOut = port::B4; + type Clock = port::B5; + type DataRegister = SPDR; + type StatusRegister = SPSR; + type ControlRegister = SPCR; +} + +/// The USART0 module. +pub struct USART0; + +impl modules::HardwareUsart for USART0 { + type DataRegister = UDR0; + type ControlRegisterA = UCSR0A; + type ControlRegisterB = UCSR0B; + type ControlRegisterC = UCSR0C; + type BaudRateRegister = UBRR0; +} + +/// 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; +} +/// 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/atmega88.rs b/src/cores/atmega88.rs new file mode 100644 index 0000000..e743a07 --- /dev/null +++ b/src/cores/atmega88.rs @@ -0,0 +1,1854 @@ +//! Core for ATmega88. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + 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 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); + + 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 UDR0; + +impl UDR0 { +} + +impl Register for UDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0xc6 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 = 0xc0 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 = 0xc1 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 = 0xc2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRR0; + +impl UBRR0 { +} + +impl Register for UBRR0 { + type T = u16; + const ADDRESS: *mut u16 = 0xc4 as *mut u16; +} +#[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 TIMSK1; + +impl TIMSK1 { + pub const ICIE1: RegisterBits = RegisterBits::new(0x20); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 ICF1: RegisterBits = RegisterBits::new(0x20); + pub const ICF10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x4); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 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 = 0x80 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 = 0x81 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 = 0x82 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 OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x88 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x8a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x86 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct TIMSK2; + +impl TIMSK2 { + pub const OCIE2B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCIE2A: RegisterBits = RegisterBits::new(0x2); + pub const OCIE2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOIE2: RegisterBits = RegisterBits::new(0x1); + pub const TOIE20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x70 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR2; + +impl TIFR2 { + pub const OCF2B: RegisterBits = RegisterBits::new(0x4); + pub const OCF2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCF2A: RegisterBits = RegisterBits::new(0x2); + pub const OCF2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOV2: RegisterBits = RegisterBits::new(0x1); + pub const TOV20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2A; + +impl TCCR2A { + pub const COM2A: RegisterBits = RegisterBits::new(0xc0); + pub const COM2A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM2A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM2B: RegisterBits = RegisterBits::new(0x30); + pub const COM2B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM2B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM2: RegisterBits = RegisterBits::new(0x3); + pub const WGM20: RegisterBits = RegisterBits::new(1<<0); + pub const WGM21: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2B; + +impl TCCR2B { + pub const FOC2A: RegisterBits = RegisterBits::new(0x80); + pub const FOC2A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC2B: RegisterBits = RegisterBits::new(0x40); + pub const FOC2B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM22: RegisterBits = RegisterBits::new(0x8); + pub const WGM220: RegisterBits = RegisterBits::new(1<<3); + + pub const CS2: RegisterBits = RegisterBits::new(0x7); + pub const CS20: RegisterBits = RegisterBits::new(1<<0); + pub const CS21: RegisterBits = RegisterBits::new(1<<1); + pub const CS22: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT2; + +impl TCNT2 { +} + +impl Register for TCNT2 { + type T = u8; + const ADDRESS: *mut u8 = 0xb2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2B; + +impl OCR2B { +} + +impl Register for OCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb4 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2A; + +impl OCR2A { +} + +impl Register for OCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb3 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ASSR; + +impl ASSR { + pub const EXCLK: RegisterBits = RegisterBits::new(0x40); + pub const EXCLK0: RegisterBits = RegisterBits::new(1<<6); + + pub const AS2: RegisterBits = RegisterBits::new(0x20); + pub const AS20: RegisterBits = RegisterBits::new(1<<5); + + pub const TCN2UB: RegisterBits = RegisterBits::new(0x10); + pub const TCN2UB0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCR2AUB: RegisterBits = RegisterBits::new(0x8); + pub const OCR2AUB0: RegisterBits = RegisterBits::new(1<<3); + + pub const OCR2BUB: RegisterBits = RegisterBits::new(0x4); + pub const OCR2BUB0: RegisterBits = RegisterBits::new(1<<2); + + pub const TCR2AUB: RegisterBits = RegisterBits::new(0x2); + pub const TCR2AUB0: RegisterBits = RegisterBits::new(1<<1); + + pub const TCR2BUB: RegisterBits = RegisterBits::new(0x1); + pub const TCR2BUB0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for ASSR { + type T = u8; + const ADDRESS: *mut u8 = 0xb6 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 = 0x7c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x78 as *mut u16; +} +#[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 = 0x7a 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); + + 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 = 0x7b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + 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 = 0x7e 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 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + 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 DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x7f 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 DDRC; + +impl DDRC { +} + +impl Register for DDRC { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINC; + +impl PINC { +} + +impl Register for PINC { + type T = u8; + const ADDRESS: *mut u8 = 0x26 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 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 OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x47 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 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 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 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 EICRA; + +impl EICRA { + 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(0x3); + pub const INT0: RegisterBits = RegisterBits::new(1<<0); + pub const INT1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x3); + pub const INTF0: RegisterBits = RegisterBits::new(1<<0); + pub const INTF1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x7); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIE2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCICR { + type T = u8; + const ADDRESS: *mut u8 = 0x68 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK2; + +impl PCMSK2 { + 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 PCMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x6d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { + 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 PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x6c 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 = 0x6b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCIFR; + +impl PCIFR { + pub const PCIF: RegisterBits = RegisterBits::new(0x7); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIF2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPDR; + +impl SPDR { +} + +impl Register for SPDR { + type T = u8; + const ADDRESS: *mut u8 = 0x4e 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 = 0x4d 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 = 0x4c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTWI: RegisterBits = RegisterBits::new(0x80); + pub const PRTWI0: RegisterBits = RegisterBits::new(1<<7); + + pub const PRTIM2: RegisterBits = RegisterBits::new(0x40); + pub const PRTIM20: RegisterBits = RegisterBits::new(1<<6); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x20); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<5); + + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRSPI: RegisterBits = RegisterBits::new(0x4); + pub const PRSPI0: 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 = 0x64 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 = 0x66 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 = 0x61 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 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 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 SELFPRGEN: RegisterBits = RegisterBits::new(0x1); + pub const SELFPRGEN0: 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(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 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 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 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 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; + + 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; + } + + pub struct C0; + + impl Pin for C0 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC0 + const MASK: u8 = 1<<0; + } + + pub struct C1; + + impl Pin for C1 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC1 + const MASK: u8 = 1<<1; + } + + pub struct C2; + + impl Pin for C2 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC2 + const MASK: u8 = 1<<2; + } + + pub struct C3; + + impl Pin for C3 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC3 + const MASK: u8 = 1<<3; + } + + pub struct C4; + + impl Pin for C4 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC4 + const MASK: u8 = 1<<4; + } + + pub struct C5; + + impl Pin for C5 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC5 + const MASK: u8 = 1<<5; + } + + pub struct C6; + + impl Pin for C6 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC6 + const MASK: u8 = 1<<6; + } + + pub struct D0; + + impl Pin for D0 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD0 + const MASK: u8 = 1<<0; + } + + pub struct D1; + + impl Pin for D1 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD1 + const MASK: u8 = 1<<1; + } + + pub struct D2; + + impl Pin for D2 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD2 + const MASK: u8 = 1<<2; + } + + pub struct D3; + + impl Pin for D3 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD3 + const MASK: u8 = 1<<3; + } + + pub struct D4; + + impl Pin for D4 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD4 + const MASK: u8 = 1<<4; + } + + pub struct D5; + + impl Pin for D5 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD5 + const MASK: u8 = 1<<5; + } + + pub struct D6; + + impl Pin for D6 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD6 + const MASK: u8 = 1<<6; + } + + pub struct D7; + + impl Pin for D7 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD7 + const MASK: u8 = 1<<7; + } + +} + +pub struct Spi; + +impl modules::HardwareSpi for Spi { + type SlaveSelect = port::B2; + type MasterOutSlaveIn = port::B3; + type MasterInSlaveOut = port::B4; + type Clock = port::B5; + type DataRegister = SPDR; + type StatusRegister = SPSR; + type ControlRegister = SPCR; +} + +/// The USART0 module. +pub struct USART0; + +impl modules::HardwareUsart for USART0 { + type DataRegister = UDR0; + type ControlRegisterA = UCSR0A; + type ControlRegisterB = UCSR0B; + type ControlRegisterC = UCSR0C; + type BaudRateRegister = UBRR0; +} + +/// 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; +} +/// 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/atmega88a.rs b/src/cores/atmega88a.rs new file mode 100644 index 0000000..4815a7f --- /dev/null +++ b/src/cores/atmega88a.rs @@ -0,0 +1,1857 @@ +//! Core for ATmega88A. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + 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 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); + + 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 UDR0; + +impl UDR0 { +} + +impl Register for UDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0xc6 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 = 0xc0 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 = 0xc1 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 = 0xc2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRR0; + +impl UBRR0 { +} + +impl Register for UBRR0 { + type T = u16; + const ADDRESS: *mut u16 = 0xc4 as *mut u16; +} +#[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 TIMSK1; + +impl TIMSK1 { + pub const ICIE1: RegisterBits = RegisterBits::new(0x20); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 ICF1: RegisterBits = RegisterBits::new(0x20); + pub const ICF10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x4); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 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 = 0x80 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 = 0x81 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 = 0x82 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 OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x88 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x8a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x86 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct TIMSK2; + +impl TIMSK2 { + pub const OCIE2B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCIE2A: RegisterBits = RegisterBits::new(0x2); + pub const OCIE2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOIE2: RegisterBits = RegisterBits::new(0x1); + pub const TOIE20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x70 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR2; + +impl TIFR2 { + pub const OCF2B: RegisterBits = RegisterBits::new(0x4); + pub const OCF2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCF2A: RegisterBits = RegisterBits::new(0x2); + pub const OCF2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOV2: RegisterBits = RegisterBits::new(0x1); + pub const TOV20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2A; + +impl TCCR2A { + pub const COM2A: RegisterBits = RegisterBits::new(0xc0); + pub const COM2A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM2A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM2B: RegisterBits = RegisterBits::new(0x30); + pub const COM2B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM2B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM2: RegisterBits = RegisterBits::new(0x3); + pub const WGM20: RegisterBits = RegisterBits::new(1<<0); + pub const WGM21: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2B; + +impl TCCR2B { + pub const FOC2A: RegisterBits = RegisterBits::new(0x80); + pub const FOC2A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC2B: RegisterBits = RegisterBits::new(0x40); + pub const FOC2B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM22: RegisterBits = RegisterBits::new(0x8); + pub const WGM220: RegisterBits = RegisterBits::new(1<<3); + + pub const CS2: RegisterBits = RegisterBits::new(0x7); + pub const CS20: RegisterBits = RegisterBits::new(1<<0); + pub const CS21: RegisterBits = RegisterBits::new(1<<1); + pub const CS22: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT2; + +impl TCNT2 { +} + +impl Register for TCNT2 { + type T = u8; + const ADDRESS: *mut u8 = 0xb2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2B; + +impl OCR2B { +} + +impl Register for OCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb4 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2A; + +impl OCR2A { +} + +impl Register for OCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb3 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ASSR; + +impl ASSR { + pub const EXCLK: RegisterBits = RegisterBits::new(0x40); + pub const EXCLK0: RegisterBits = RegisterBits::new(1<<6); + + pub const AS2: RegisterBits = RegisterBits::new(0x20); + pub const AS20: RegisterBits = RegisterBits::new(1<<5); + + pub const TCN2UB: RegisterBits = RegisterBits::new(0x10); + pub const TCN2UB0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCR2AUB: RegisterBits = RegisterBits::new(0x8); + pub const OCR2AUB0: RegisterBits = RegisterBits::new(1<<3); + + pub const OCR2BUB: RegisterBits = RegisterBits::new(0x4); + pub const OCR2BUB0: RegisterBits = RegisterBits::new(1<<2); + + pub const TCR2AUB: RegisterBits = RegisterBits::new(0x2); + pub const TCR2AUB0: RegisterBits = RegisterBits::new(1<<1); + + pub const TCR2BUB: RegisterBits = RegisterBits::new(0x1); + pub const TCR2BUB0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for ASSR { + type T = u8; + const ADDRESS: *mut u8 = 0xb6 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 = 0x7c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x78 as *mut u16; +} +#[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 = 0x7a 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); + + 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 = 0x7b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + 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 = 0x7e 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 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + 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 DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x7f 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 DDRC; + +impl DDRC { +} + +impl Register for DDRC { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINC; + +impl PINC { +} + +impl Register for PINC { + type T = u8; + const ADDRESS: *mut u8 = 0x26 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 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 OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x47 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 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 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 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 EICRA; + +impl EICRA { + 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(0x3); + pub const INT0: RegisterBits = RegisterBits::new(1<<0); + pub const INT1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x3); + pub const INTF0: RegisterBits = RegisterBits::new(1<<0); + pub const INTF1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x7); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIE2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCICR { + type T = u8; + const ADDRESS: *mut u8 = 0x68 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK2; + +impl PCMSK2 { + 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 PCMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x6d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { + 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 PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x6c 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 = 0x6b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCIFR; + +impl PCIFR { + pub const PCIF: RegisterBits = RegisterBits::new(0x7); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIF2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPDR; + +impl SPDR { +} + +impl Register for SPDR { + type T = u8; + const ADDRESS: *mut u8 = 0x4e 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 = 0x4d 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 = 0x4c 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 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; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTWI: RegisterBits = RegisterBits::new(0x80); + pub const PRTWI0: RegisterBits = RegisterBits::new(1<<7); + + pub const PRTIM2: RegisterBits = RegisterBits::new(0x40); + pub const PRTIM20: RegisterBits = RegisterBits::new(1<<6); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x20); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<5); + + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRSPI: RegisterBits = RegisterBits::new(0x4); + pub const PRSPI0: 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 = 0x64 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 = 0x66 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 = 0x61 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 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 MCUCR; + +impl MCUCR { + 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 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 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; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + + 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; + } + + pub struct C0; + + impl Pin for C0 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC0 + const MASK: u8 = 1<<0; + } + + pub struct C1; + + impl Pin for C1 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC1 + const MASK: u8 = 1<<1; + } + + pub struct C2; + + impl Pin for C2 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC2 + const MASK: u8 = 1<<2; + } + + pub struct C3; + + impl Pin for C3 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC3 + const MASK: u8 = 1<<3; + } + + pub struct C4; + + impl Pin for C4 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC4 + const MASK: u8 = 1<<4; + } + + pub struct C5; + + impl Pin for C5 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC5 + const MASK: u8 = 1<<5; + } + + pub struct C6; + + impl Pin for C6 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC6 + const MASK: u8 = 1<<6; + } + + pub struct D0; + + impl Pin for D0 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD0 + const MASK: u8 = 1<<0; + } + + pub struct D1; + + impl Pin for D1 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD1 + const MASK: u8 = 1<<1; + } + + pub struct D2; + + impl Pin for D2 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD2 + const MASK: u8 = 1<<2; + } + + pub struct D3; + + impl Pin for D3 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD3 + const MASK: u8 = 1<<3; + } + + pub struct D4; + + impl Pin for D4 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD4 + const MASK: u8 = 1<<4; + } + + pub struct D5; + + impl Pin for D5 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD5 + const MASK: u8 = 1<<5; + } + + pub struct D6; + + impl Pin for D6 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD6 + const MASK: u8 = 1<<6; + } + + pub struct D7; + + impl Pin for D7 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD7 + const MASK: u8 = 1<<7; + } + +} + +pub struct Spi; + +impl modules::HardwareSpi for Spi { + type SlaveSelect = port::B2; + type MasterOutSlaveIn = port::B3; + type MasterInSlaveOut = port::B4; + type Clock = port::B5; + type DataRegister = SPDR; + type StatusRegister = SPSR; + type ControlRegister = SPCR; +} + +/// The USART0 module. +pub struct USART0; + +impl modules::HardwareUsart for USART0 { + type DataRegister = UDR0; + type ControlRegisterA = UCSR0A; + type ControlRegisterB = UCSR0B; + type ControlRegisterC = UCSR0C; + type BaudRateRegister = UBRR0; +} + +/// 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; +} +/// 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/atmega88p.rs b/src/cores/atmega88p.rs new file mode 100644 index 0000000..89b1690 --- /dev/null +++ b/src/cores/atmega88p.rs @@ -0,0 +1,1860 @@ +//! Core for ATmega88P. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + 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 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); + + 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 UDR0; + +impl UDR0 { +} + +impl Register for UDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0xc6 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 = 0xc0 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 = 0xc1 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 = 0xc2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRR0; + +impl UBRR0 { +} + +impl Register for UBRR0 { + type T = u16; + const ADDRESS: *mut u16 = 0xc4 as *mut u16; +} +#[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 TIMSK1; + +impl TIMSK1 { + pub const ICIE1: RegisterBits = RegisterBits::new(0x20); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 ICF1: RegisterBits = RegisterBits::new(0x20); + pub const ICF10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x4); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 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 = 0x80 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 = 0x81 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 = 0x82 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 OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x88 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x8a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x86 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct TIMSK2; + +impl TIMSK2 { + pub const OCIE2B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCIE2A: RegisterBits = RegisterBits::new(0x2); + pub const OCIE2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOIE2: RegisterBits = RegisterBits::new(0x1); + pub const TOIE20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x70 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR2; + +impl TIFR2 { + pub const OCF2B: RegisterBits = RegisterBits::new(0x4); + pub const OCF2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCF2A: RegisterBits = RegisterBits::new(0x2); + pub const OCF2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOV2: RegisterBits = RegisterBits::new(0x1); + pub const TOV20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2A; + +impl TCCR2A { + pub const COM2A: RegisterBits = RegisterBits::new(0xc0); + pub const COM2A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM2A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM2B: RegisterBits = RegisterBits::new(0x30); + pub const COM2B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM2B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM2: RegisterBits = RegisterBits::new(0x3); + pub const WGM20: RegisterBits = RegisterBits::new(1<<0); + pub const WGM21: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2B; + +impl TCCR2B { + pub const FOC2A: RegisterBits = RegisterBits::new(0x80); + pub const FOC2A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC2B: RegisterBits = RegisterBits::new(0x40); + pub const FOC2B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM22: RegisterBits = RegisterBits::new(0x8); + pub const WGM220: RegisterBits = RegisterBits::new(1<<3); + + pub const CS2: RegisterBits = RegisterBits::new(0x7); + pub const CS20: RegisterBits = RegisterBits::new(1<<0); + pub const CS21: RegisterBits = RegisterBits::new(1<<1); + pub const CS22: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT2; + +impl TCNT2 { +} + +impl Register for TCNT2 { + type T = u8; + const ADDRESS: *mut u8 = 0xb2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2B; + +impl OCR2B { +} + +impl Register for OCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb4 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2A; + +impl OCR2A { +} + +impl Register for OCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb3 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ASSR; + +impl ASSR { + pub const EXCLK: RegisterBits = RegisterBits::new(0x40); + pub const EXCLK0: RegisterBits = RegisterBits::new(1<<6); + + pub const AS2: RegisterBits = RegisterBits::new(0x20); + pub const AS20: RegisterBits = RegisterBits::new(1<<5); + + pub const TCN2UB: RegisterBits = RegisterBits::new(0x10); + pub const TCN2UB0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCR2AUB: RegisterBits = RegisterBits::new(0x8); + pub const OCR2AUB0: RegisterBits = RegisterBits::new(1<<3); + + pub const OCR2BUB: RegisterBits = RegisterBits::new(0x4); + pub const OCR2BUB0: RegisterBits = RegisterBits::new(1<<2); + + pub const TCR2AUB: RegisterBits = RegisterBits::new(0x2); + pub const TCR2AUB0: RegisterBits = RegisterBits::new(1<<1); + + pub const TCR2BUB: RegisterBits = RegisterBits::new(0x1); + pub const TCR2BUB0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for ASSR { + type T = u8; + const ADDRESS: *mut u8 = 0xb6 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 = 0x7c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x78 as *mut u16; +} +#[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 = 0x7a 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); + + 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 = 0x7b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + 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 = 0x7e 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 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + 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 DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x7f 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 DDRC; + +impl DDRC { +} + +impl Register for DDRC { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINC; + +impl PINC { +} + +impl Register for PINC { + type T = u8; + const ADDRESS: *mut u8 = 0x26 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 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 OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x47 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 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 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 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 EICRA; + +impl EICRA { + 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(0x3); + pub const INT0: RegisterBits = RegisterBits::new(1<<0); + pub const INT1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x3); + pub const INTF0: RegisterBits = RegisterBits::new(1<<0); + pub const INTF1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x7); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIE2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCICR { + type T = u8; + const ADDRESS: *mut u8 = 0x68 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK2; + +impl PCMSK2 { + 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 PCMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x6d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { + 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 PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x6c 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 = 0x6b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCIFR; + +impl PCIFR { + pub const PCIF: RegisterBits = RegisterBits::new(0x7); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIF2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPDR; + +impl SPDR { +} + +impl Register for SPDR { + type T = u8; + const ADDRESS: *mut u8 = 0x4e 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 = 0x4d 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 = 0x4c 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 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; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTWI: RegisterBits = RegisterBits::new(0x80); + pub const PRTWI0: RegisterBits = RegisterBits::new(1<<7); + + pub const PRTIM2: RegisterBits = RegisterBits::new(0x40); + pub const PRTIM20: RegisterBits = RegisterBits::new(1<<6); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x20); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<5); + + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRSPI: RegisterBits = RegisterBits::new(0x4); + pub const PRSPI0: 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 = 0x64 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 = 0x66 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 = 0x61 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 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 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 SELFPRGEN: RegisterBits = RegisterBits::new(0x1); + pub const SELFPRGEN0: 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 BODS: RegisterBits = RegisterBits::new(0x40); + pub const BODS0: RegisterBits = RegisterBits::new(1<<6); + + pub const BODSE: RegisterBits = RegisterBits::new(0x20); + pub const BODSE0: RegisterBits = RegisterBits::new(1<<5); + + 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 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 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; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + + 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; + } + + pub struct C0; + + impl Pin for C0 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC0 + const MASK: u8 = 1<<0; + } + + pub struct C1; + + impl Pin for C1 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC1 + const MASK: u8 = 1<<1; + } + + pub struct C2; + + impl Pin for C2 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC2 + const MASK: u8 = 1<<2; + } + + pub struct C3; + + impl Pin for C3 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC3 + const MASK: u8 = 1<<3; + } + + pub struct C4; + + impl Pin for C4 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC4 + const MASK: u8 = 1<<4; + } + + pub struct C5; + + impl Pin for C5 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC5 + const MASK: u8 = 1<<5; + } + + pub struct C6; + + impl Pin for C6 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC6 + const MASK: u8 = 1<<6; + } + + pub struct D0; + + impl Pin for D0 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD0 + const MASK: u8 = 1<<0; + } + + pub struct D1; + + impl Pin for D1 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD1 + const MASK: u8 = 1<<1; + } + + pub struct D2; + + impl Pin for D2 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD2 + const MASK: u8 = 1<<2; + } + + pub struct D3; + + impl Pin for D3 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD3 + const MASK: u8 = 1<<3; + } + + pub struct D4; + + impl Pin for D4 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD4 + const MASK: u8 = 1<<4; + } + + pub struct D5; + + impl Pin for D5 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD5 + const MASK: u8 = 1<<5; + } + + pub struct D6; + + impl Pin for D6 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD6 + const MASK: u8 = 1<<6; + } + + pub struct D7; + + impl Pin for D7 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD7 + const MASK: u8 = 1<<7; + } + +} + +pub struct Spi; + +impl modules::HardwareSpi for Spi { + type SlaveSelect = port::B2; + type MasterOutSlaveIn = port::B3; + type MasterInSlaveOut = port::B4; + type Clock = port::B5; + type DataRegister = SPDR; + type StatusRegister = SPSR; + type ControlRegister = SPCR; +} + +/// The USART0 module. +pub struct USART0; + +impl modules::HardwareUsart for USART0 { + type DataRegister = UDR0; + type ControlRegisterA = UCSR0A; + type ControlRegisterB = UCSR0B; + type ControlRegisterC = UCSR0C; + type BaudRateRegister = UBRR0; +} + +/// 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; +} +/// 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/atmega88pa.rs b/src/cores/atmega88pa.rs new file mode 100644 index 0000000..d22303e --- /dev/null +++ b/src/cores/atmega88pa.rs @@ -0,0 +1,1863 @@ +//! Core for ATmega88PA. + +use crate::{modules, RegisterBits, Register}; + +#[allow(non_camel_case_types)] +pub struct EXTENDED; + +impl EXTENDED { + 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 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); + + 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 UDR0; + +impl UDR0 { +} + +impl Register for UDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0xc6 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 = 0xc0 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 = 0xc1 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 = 0xc2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct UBRR0; + +impl UBRR0 { +} + +impl Register for UBRR0 { + type T = u16; + const ADDRESS: *mut u16 = 0xc4 as *mut u16; +} +#[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 TIMSK1; + +impl TIMSK1 { + pub const ICIE1: RegisterBits = RegisterBits::new(0x20); + pub const ICIE10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCIE1B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 ICF1: RegisterBits = RegisterBits::new(0x20); + pub const ICF10: RegisterBits = RegisterBits::new(1<<5); + + pub const OCF1B: RegisterBits = RegisterBits::new(0x4); + pub const OCF1B0: RegisterBits = RegisterBits::new(1<<2); + + 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 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 = 0x80 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 = 0x81 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 = 0x82 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 OCR1A; + +impl OCR1A { +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x88 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct OCR1B; + +impl OCR1B { +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x8a as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct ICR1; + +impl ICR1 { +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x86 as *mut u16; +} +#[allow(non_camel_case_types)] +pub struct TIMSK2; + +impl TIMSK2 { + pub const OCIE2B: RegisterBits = RegisterBits::new(0x4); + pub const OCIE2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCIE2A: RegisterBits = RegisterBits::new(0x2); + pub const OCIE2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOIE2: RegisterBits = RegisterBits::new(0x1); + pub const TOIE20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x70 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TIFR2; + +impl TIFR2 { + pub const OCF2B: RegisterBits = RegisterBits::new(0x4); + pub const OCF2B0: RegisterBits = RegisterBits::new(1<<2); + + pub const OCF2A: RegisterBits = RegisterBits::new(0x2); + pub const OCF2A0: RegisterBits = RegisterBits::new(1<<1); + + pub const TOV2: RegisterBits = RegisterBits::new(0x1); + pub const TOV20: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for TIFR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x37 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2A; + +impl TCCR2A { + pub const COM2A: RegisterBits = RegisterBits::new(0xc0); + pub const COM2A0: RegisterBits = RegisterBits::new(1<<6); + pub const COM2A1: RegisterBits = RegisterBits::new(1<<7); + + pub const COM2B: RegisterBits = RegisterBits::new(0x30); + pub const COM2B0: RegisterBits = RegisterBits::new(1<<4); + pub const COM2B1: RegisterBits = RegisterBits::new(1<<5); + + pub const WGM2: RegisterBits = RegisterBits::new(0x3); + pub const WGM20: RegisterBits = RegisterBits::new(1<<0); + pub const WGM21: RegisterBits = RegisterBits::new(1<<1); + +} + +impl Register for TCCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb0 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCCR2B; + +impl TCCR2B { + pub const FOC2A: RegisterBits = RegisterBits::new(0x80); + pub const FOC2A0: RegisterBits = RegisterBits::new(1<<7); + + pub const FOC2B: RegisterBits = RegisterBits::new(0x40); + pub const FOC2B0: RegisterBits = RegisterBits::new(1<<6); + + pub const WGM22: RegisterBits = RegisterBits::new(0x8); + pub const WGM220: RegisterBits = RegisterBits::new(1<<3); + + pub const CS2: RegisterBits = RegisterBits::new(0x7); + pub const CS20: RegisterBits = RegisterBits::new(1<<0); + pub const CS21: RegisterBits = RegisterBits::new(1<<1); + pub const CS22: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for TCCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb1 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct TCNT2; + +impl TCNT2 { +} + +impl Register for TCNT2 { + type T = u8; + const ADDRESS: *mut u8 = 0xb2 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2B; + +impl OCR2B { +} + +impl Register for OCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb4 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct OCR2A; + +impl OCR2A { +} + +impl Register for OCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb3 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ASSR; + +impl ASSR { + pub const EXCLK: RegisterBits = RegisterBits::new(0x40); + pub const EXCLK0: RegisterBits = RegisterBits::new(1<<6); + + pub const AS2: RegisterBits = RegisterBits::new(0x20); + pub const AS20: RegisterBits = RegisterBits::new(1<<5); + + pub const TCN2UB: RegisterBits = RegisterBits::new(0x10); + pub const TCN2UB0: RegisterBits = RegisterBits::new(1<<4); + + pub const OCR2AUB: RegisterBits = RegisterBits::new(0x8); + pub const OCR2AUB0: RegisterBits = RegisterBits::new(1<<3); + + pub const OCR2BUB: RegisterBits = RegisterBits::new(0x4); + pub const OCR2BUB0: RegisterBits = RegisterBits::new(1<<2); + + pub const TCR2AUB: RegisterBits = RegisterBits::new(0x2); + pub const TCR2AUB0: RegisterBits = RegisterBits::new(1<<1); + + pub const TCR2BUB: RegisterBits = RegisterBits::new(0x1); + pub const TCR2BUB0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for ASSR { + type T = u8; + const ADDRESS: *mut u8 = 0xb6 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 = 0x7c as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct ADC; + +impl ADC { +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x78 as *mut u16; +} +#[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 = 0x7a 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); + + 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 = 0x7b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR0; + +impl DIDR0 { + 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 = 0x7e 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 = 0x50 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct DIDR1; + +impl DIDR1 { + 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 DIDR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x7f 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 DDRC; + +impl DDRC { +} + +impl Register for DDRC { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PINC; + +impl PINC { +} + +impl Register for PINC { + type T = u8; + const ADDRESS: *mut u8 = 0x26 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 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 OCR0A; + +impl OCR0A { +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x47 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 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 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 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 EICRA; + +impl EICRA { + 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(0x3); + pub const INT0: RegisterBits = RegisterBits::new(1<<0); + pub const INT1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x3); + pub const INTF0: RegisterBits = RegisterBits::new(1<<0); + pub const INTF1: RegisterBits = RegisterBits::new(1<<1); + +} + +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(0x7); + pub const PCIE0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIE1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIE2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCICR { + type T = u8; + const ADDRESS: *mut u8 = 0x68 as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK2; + +impl PCMSK2 { + 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 PCMSK2 { + type T = u8; + const ADDRESS: *mut u8 = 0x6d as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCMSK1; + +impl PCMSK1 { + 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 PCMSK1 { + type T = u8; + const ADDRESS: *mut u8 = 0x6c 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 = 0x6b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct PCIFR; + +impl PCIFR { + pub const PCIF: RegisterBits = RegisterBits::new(0x7); + pub const PCIF0: RegisterBits = RegisterBits::new(1<<0); + pub const PCIF1: RegisterBits = RegisterBits::new(1<<1); + pub const PCIF2: RegisterBits = RegisterBits::new(1<<2); + +} + +impl Register for PCIFR { + type T = u8; + const ADDRESS: *mut u8 = 0x3b as *mut u8; +} +#[allow(non_camel_case_types)] +pub struct SPDR; + +impl SPDR { +} + +impl Register for SPDR { + type T = u8; + const ADDRESS: *mut u8 = 0x4e 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 = 0x4d 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 = 0x4c 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 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; +} +#[allow(non_camel_case_types)] +pub struct PRR; + +impl PRR { + pub const PRTWI: RegisterBits = RegisterBits::new(0x80); + pub const PRTWI0: RegisterBits = RegisterBits::new(1<<7); + + pub const PRTIM2: RegisterBits = RegisterBits::new(0x40); + pub const PRTIM20: RegisterBits = RegisterBits::new(1<<6); + + pub const PRTIM0: RegisterBits = RegisterBits::new(0x20); + pub const PRTIM00: RegisterBits = RegisterBits::new(1<<5); + + pub const PRTIM1: RegisterBits = RegisterBits::new(0x8); + pub const PRTIM10: RegisterBits = RegisterBits::new(1<<3); + + pub const PRSPI: RegisterBits = RegisterBits::new(0x4); + pub const PRSPI0: 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 = 0x64 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 = 0x66 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 = 0x61 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 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 MCUCR; + +impl MCUCR { + pub const BODS: RegisterBits = RegisterBits::new(0x40); + pub const BODS0: RegisterBits = RegisterBits::new(1<<6); + + pub const BODSE: RegisterBits = RegisterBits::new(0x20); + pub const BODSE0: RegisterBits = RegisterBits::new(1<<5); + + 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 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 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; +} +pub mod port { + #![allow(unused_imports)] + + use super::*; + use crate::Pin; + + 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; + } + + pub struct C0; + + impl Pin for C0 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC0 + const MASK: u8 = 1<<0; + } + + pub struct C1; + + impl Pin for C1 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC1 + const MASK: u8 = 1<<1; + } + + pub struct C2; + + impl Pin for C2 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC2 + const MASK: u8 = 1<<2; + } + + pub struct C3; + + impl Pin for C3 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC3 + const MASK: u8 = 1<<3; + } + + pub struct C4; + + impl Pin for C4 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC4 + const MASK: u8 = 1<<4; + } + + pub struct C5; + + impl Pin for C5 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC5 + const MASK: u8 = 1<<5; + } + + pub struct C6; + + impl Pin for C6 { + /// Port C Data Register. + type PORT = PORTC; + /// Port C Data Direction Register. + type DDR = DDRC; + /// Port C Input Pins. + type PIN = PINC; + /// PC6 + const MASK: u8 = 1<<6; + } + + pub struct D0; + + impl Pin for D0 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD0 + const MASK: u8 = 1<<0; + } + + pub struct D1; + + impl Pin for D1 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD1 + const MASK: u8 = 1<<1; + } + + pub struct D2; + + impl Pin for D2 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD2 + const MASK: u8 = 1<<2; + } + + pub struct D3; + + impl Pin for D3 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD3 + const MASK: u8 = 1<<3; + } + + pub struct D4; + + impl Pin for D4 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD4 + const MASK: u8 = 1<<4; + } + + pub struct D5; + + impl Pin for D5 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD5 + const MASK: u8 = 1<<5; + } + + pub struct D6; + + impl Pin for D6 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD6 + const MASK: u8 = 1<<6; + } + + pub struct D7; + + impl Pin for D7 { + /// Port D Data Register. + type PORT = PORTD; + /// Port D Data Direction Register. + type DDR = DDRD; + /// Port D Input Pins. + type PIN = PIND; + /// PD7 + const MASK: u8 = 1<<7; + } + +} + +pub struct Spi; + +impl modules::HardwareSpi for Spi { + type SlaveSelect = port::B2; + type MasterOutSlaveIn = port::B3; + type MasterInSlaveOut = port::B4; + type Clock = port::B5; + type DataRegister = SPDR; + type StatusRegister = SPSR; + type ControlRegister = SPCR; +} + +/// The USART0 module. +pub struct USART0; + +impl modules::HardwareUsart for USART0 { + type DataRegister = UDR0; + type ControlRegisterA = UCSR0A; + type ControlRegisterB = UCSR0B; + type ControlRegisterC = UCSR0C; + type BaudRateRegister = UBRR0; +} + +/// 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; +} +/// 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/mod.rs b/src/cores/mod.rs index 2bd1f10..bf8774d 100644 --- a/src/cores/mod.rs +++ b/src/cores/mod.rs @@ -1,6 +1,59 @@ +//! The primary module containing microcontroller-specific core definitions + +/// The ATmega88. +pub mod atmega88; +#[cfg(avr_mcu_atmega88)] pub use self::atmega88 as current; + +/// The ATmega48A. +pub mod atmega48a; +#[cfg(avr_mcu_atmega48a)] pub use self::atmega48a as current; + +/// The ATmega168A. +pub mod atmega168a; +#[cfg(avr_mcu_atmega168a)] pub use self::atmega168a as current; + +/// The ATmega88P. +pub mod atmega88p; +#[cfg(avr_mcu_atmega88p)] pub use self::atmega88p as current; + +/// The ATmega168P. +pub mod atmega168p; +#[cfg(avr_mcu_atmega168p)] pub use self::atmega168p as current; + +/// The ATmega88PA. +pub mod atmega88pa; +#[cfg(avr_mcu_atmega88pa)] pub use self::atmega88pa as current; + +/// The ATmega168. +pub mod atmega168; +#[cfg(avr_mcu_atmega168)] pub use self::atmega168 as current; + +/// The ATmega328P. +pub mod atmega328p; +#[cfg(avr_mcu_atmega328p)] pub use self::atmega328p as current; + +/// The ATmega48PA. +pub mod atmega48pa; +#[cfg(avr_mcu_atmega48pa)] pub use self::atmega48pa as current; + +/// The ATmega168PA. +pub mod atmega168pa; +#[cfg(avr_mcu_atmega168pa)] pub use self::atmega168pa as current; + +/// The ATmega48P. +pub mod atmega48p; +#[cfg(avr_mcu_atmega48p)] pub use self::atmega48p as current; /// The ATmega328. pub mod atmega328; -#[cfg(avr_mcu_atmega328)] -pub use self::atmega328 as current; +#[cfg(avr_mcu_atmega328)] pub use self::atmega328 as current; + +/// The ATmega88A. +pub mod atmega88a; +#[cfg(avr_mcu_atmega88a)] pub use self::atmega88a as current; + +/// The ATmega48. +pub mod atmega48; +#[cfg(avr_mcu_atmega48)] pub use self::atmega48 as current; +