diff --git a/src/.gitignore b/src/.gitignore index 5c921d9..e69de29 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,2 +0,0 @@ -# Generated automatically. -config.rs diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..ef737df --- /dev/null +++ b/src/config.rs @@ -0,0 +1,2 @@ +/// The clock frequency of device being targeted in Hertz. +pub const CPU_FREQUENCY_HZ: u32 = 16000000; diff --git a/src/cores/.gitignore b/src/cores/.gitignore index 6f5f3d1..e69de29 100644 --- a/src/cores/.gitignore +++ b/src/cores/.gitignore @@ -1 +0,0 @@ -*.rs diff --git a/src/cores/atmega328.rs b/src/cores/atmega328.rs new file mode 100644 index 0000000..61ff648 --- /dev/null +++ b/src/cores/atmega328.rs @@ -0,0 +1,2019 @@ +//! Core for ATmega328. + +use crate::{modules, RegisterBits, Register}; + +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; +} +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; +} +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; +} +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; +} +pub struct UDR0; + +impl UDR0 { + pub const UDR0: RegisterBits = RegisterBits::new(0xff); + pub const UDR00: RegisterBits = RegisterBits::new(1<<0); + pub const UDR01: RegisterBits = RegisterBits::new(1<<1); + pub const UDR02: RegisterBits = RegisterBits::new(1<<2); + pub const UDR03: RegisterBits = RegisterBits::new(1<<3); + pub const UDR04: RegisterBits = RegisterBits::new(1<<4); + pub const UDR05: RegisterBits = RegisterBits::new(1<<5); + pub const UDR06: RegisterBits = RegisterBits::new(1<<6); + pub const UDR07: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for UDR0 { + type T = u8; + const ADDRESS: *mut u8 = 0xc6 as *mut u8; +} +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; +} +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; +} +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; +} +pub struct UBRR0; + +impl UBRR0 { + pub const UBRR0: RegisterBits = RegisterBits::new(0xfff); + pub const UBRR00: RegisterBits = RegisterBits::new(1<<0); + pub const UBRR01: RegisterBits = RegisterBits::new(1<<1); + pub const UBRR02: RegisterBits = RegisterBits::new(1<<2); + pub const UBRR03: RegisterBits = RegisterBits::new(1<<3); + pub const UBRR04: RegisterBits = RegisterBits::new(1<<4); + pub const UBRR05: RegisterBits = RegisterBits::new(1<<5); + pub const UBRR06: RegisterBits = RegisterBits::new(1<<6); + pub const UBRR07: RegisterBits = RegisterBits::new(1<<7); + pub const UBRR08: RegisterBits = RegisterBits::new(1<<8); + pub const UBRR09: RegisterBits = RegisterBits::new(1<<9); + pub const UBRR010: RegisterBits = RegisterBits::new(1<<10); + pub const UBRR011: RegisterBits = RegisterBits::new(1<<11); + +} + +impl Register for UBRR0 { + type T = u16; + const ADDRESS: *mut u16 = 0xc4 as *mut u16; +} +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; +} +pub struct TWBR; + +impl TWBR { + pub const TWBR: RegisterBits = RegisterBits::new(0xff); + pub const TWBR0: RegisterBits = RegisterBits::new(1<<0); + pub const TWBR1: RegisterBits = RegisterBits::new(1<<1); + pub const TWBR2: RegisterBits = RegisterBits::new(1<<2); + pub const TWBR3: RegisterBits = RegisterBits::new(1<<3); + pub const TWBR4: RegisterBits = RegisterBits::new(1<<4); + pub const TWBR5: RegisterBits = RegisterBits::new(1<<5); + pub const TWBR6: RegisterBits = RegisterBits::new(1<<6); + pub const TWBR7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for TWBR { + type T = u8; + const ADDRESS: *mut u8 = 0xb8 as *mut u8; +} +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; +} +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; +} +pub struct TWDR; + +impl TWDR { + pub const TWDR: RegisterBits = RegisterBits::new(0xff); + pub const TWDR0: RegisterBits = RegisterBits::new(1<<0); + pub const TWDR1: RegisterBits = RegisterBits::new(1<<1); + pub const TWDR2: RegisterBits = RegisterBits::new(1<<2); + pub const TWDR3: RegisterBits = RegisterBits::new(1<<3); + pub const TWDR4: RegisterBits = RegisterBits::new(1<<4); + pub const TWDR5: RegisterBits = RegisterBits::new(1<<5); + pub const TWDR6: RegisterBits = RegisterBits::new(1<<6); + pub const TWDR7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for TWDR { + type T = u8; + const ADDRESS: *mut u8 = 0xbb as *mut u8; +} +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; +} +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; +} +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; +} +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; +} +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; +} +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; +} +pub struct TCNT1; + +impl TCNT1 { + pub const TCNT1: RegisterBits = RegisterBits::new(0xffff); + pub const TCNT10: RegisterBits = RegisterBits::new(1<<0); + pub const TCNT11: RegisterBits = RegisterBits::new(1<<1); + pub const TCNT12: RegisterBits = RegisterBits::new(1<<2); + pub const TCNT13: RegisterBits = RegisterBits::new(1<<3); + pub const TCNT14: RegisterBits = RegisterBits::new(1<<4); + pub const TCNT15: RegisterBits = RegisterBits::new(1<<5); + pub const TCNT16: RegisterBits = RegisterBits::new(1<<6); + pub const TCNT17: RegisterBits = RegisterBits::new(1<<7); + pub const TCNT18: RegisterBits = RegisterBits::new(1<<8); + pub const TCNT19: RegisterBits = RegisterBits::new(1<<9); + pub const TCNT110: RegisterBits = RegisterBits::new(1<<10); + pub const TCNT111: RegisterBits = RegisterBits::new(1<<11); + pub const TCNT112: RegisterBits = RegisterBits::new(1<<12); + pub const TCNT113: RegisterBits = RegisterBits::new(1<<13); + pub const TCNT114: RegisterBits = RegisterBits::new(1<<14); + +} + +impl Register for TCNT1 { + type T = u16; + const ADDRESS: *mut u16 = 0x84 as *mut u16; +} +pub struct OCR1A; + +impl OCR1A { + pub const OCR1A: RegisterBits = RegisterBits::new(0xffff); + pub const OCR1A0: RegisterBits = RegisterBits::new(1<<0); + pub const OCR1A1: RegisterBits = RegisterBits::new(1<<1); + pub const OCR1A2: RegisterBits = RegisterBits::new(1<<2); + pub const OCR1A3: RegisterBits = RegisterBits::new(1<<3); + pub const OCR1A4: RegisterBits = RegisterBits::new(1<<4); + pub const OCR1A5: RegisterBits = RegisterBits::new(1<<5); + pub const OCR1A6: RegisterBits = RegisterBits::new(1<<6); + pub const OCR1A7: RegisterBits = RegisterBits::new(1<<7); + pub const OCR1A8: RegisterBits = RegisterBits::new(1<<8); + pub const OCR1A9: RegisterBits = RegisterBits::new(1<<9); + pub const OCR1A10: RegisterBits = RegisterBits::new(1<<10); + pub const OCR1A11: RegisterBits = RegisterBits::new(1<<11); + pub const OCR1A12: RegisterBits = RegisterBits::new(1<<12); + pub const OCR1A13: RegisterBits = RegisterBits::new(1<<13); + pub const OCR1A14: RegisterBits = RegisterBits::new(1<<14); + +} + +impl Register for OCR1A { + type T = u16; + const ADDRESS: *mut u16 = 0x88 as *mut u16; +} +pub struct OCR1B; + +impl OCR1B { + pub const OCR1B: RegisterBits = RegisterBits::new(0xffff); + pub const OCR1B0: RegisterBits = RegisterBits::new(1<<0); + pub const OCR1B1: RegisterBits = RegisterBits::new(1<<1); + pub const OCR1B2: RegisterBits = RegisterBits::new(1<<2); + pub const OCR1B3: RegisterBits = RegisterBits::new(1<<3); + pub const OCR1B4: RegisterBits = RegisterBits::new(1<<4); + pub const OCR1B5: RegisterBits = RegisterBits::new(1<<5); + pub const OCR1B6: RegisterBits = RegisterBits::new(1<<6); + pub const OCR1B7: RegisterBits = RegisterBits::new(1<<7); + pub const OCR1B8: RegisterBits = RegisterBits::new(1<<8); + pub const OCR1B9: RegisterBits = RegisterBits::new(1<<9); + pub const OCR1B10: RegisterBits = RegisterBits::new(1<<10); + pub const OCR1B11: RegisterBits = RegisterBits::new(1<<11); + pub const OCR1B12: RegisterBits = RegisterBits::new(1<<12); + pub const OCR1B13: RegisterBits = RegisterBits::new(1<<13); + pub const OCR1B14: RegisterBits = RegisterBits::new(1<<14); + +} + +impl Register for OCR1B { + type T = u16; + const ADDRESS: *mut u16 = 0x8a as *mut u16; +} +pub struct ICR1; + +impl ICR1 { + pub const ICR1: RegisterBits = RegisterBits::new(0xffff); + pub const ICR10: RegisterBits = RegisterBits::new(1<<0); + pub const ICR11: RegisterBits = RegisterBits::new(1<<1); + pub const ICR12: RegisterBits = RegisterBits::new(1<<2); + pub const ICR13: RegisterBits = RegisterBits::new(1<<3); + pub const ICR14: RegisterBits = RegisterBits::new(1<<4); + pub const ICR15: RegisterBits = RegisterBits::new(1<<5); + pub const ICR16: RegisterBits = RegisterBits::new(1<<6); + pub const ICR17: RegisterBits = RegisterBits::new(1<<7); + pub const ICR18: RegisterBits = RegisterBits::new(1<<8); + pub const ICR19: RegisterBits = RegisterBits::new(1<<9); + pub const ICR110: RegisterBits = RegisterBits::new(1<<10); + pub const ICR111: RegisterBits = RegisterBits::new(1<<11); + pub const ICR112: RegisterBits = RegisterBits::new(1<<12); + pub const ICR113: RegisterBits = RegisterBits::new(1<<13); + pub const ICR114: RegisterBits = RegisterBits::new(1<<14); + +} + +impl Register for ICR1 { + type T = u16; + const ADDRESS: *mut u16 = 0x86 as *mut u16; +} +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; +} +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; +} +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; +} +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; +} +pub struct TCNT2; + +impl TCNT2 { + pub const TCNT2: RegisterBits = RegisterBits::new(0xff); + pub const TCNT20: RegisterBits = RegisterBits::new(1<<0); + pub const TCNT21: RegisterBits = RegisterBits::new(1<<1); + pub const TCNT22: RegisterBits = RegisterBits::new(1<<2); + pub const TCNT23: RegisterBits = RegisterBits::new(1<<3); + pub const TCNT24: RegisterBits = RegisterBits::new(1<<4); + pub const TCNT25: RegisterBits = RegisterBits::new(1<<5); + pub const TCNT26: RegisterBits = RegisterBits::new(1<<6); + pub const TCNT27: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for TCNT2 { + type T = u8; + const ADDRESS: *mut u8 = 0xb2 as *mut u8; +} +pub struct OCR2B; + +impl OCR2B { + pub const OCR2B: RegisterBits = RegisterBits::new(0xff); + pub const OCR2B0: RegisterBits = RegisterBits::new(1<<0); + pub const OCR2B1: RegisterBits = RegisterBits::new(1<<1); + pub const OCR2B2: RegisterBits = RegisterBits::new(1<<2); + pub const OCR2B3: RegisterBits = RegisterBits::new(1<<3); + pub const OCR2B4: RegisterBits = RegisterBits::new(1<<4); + pub const OCR2B5: RegisterBits = RegisterBits::new(1<<5); + pub const OCR2B6: RegisterBits = RegisterBits::new(1<<6); + pub const OCR2B7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OCR2B { + type T = u8; + const ADDRESS: *mut u8 = 0xb4 as *mut u8; +} +pub struct OCR2A; + +impl OCR2A { + pub const OCR2A: RegisterBits = RegisterBits::new(0xff); + pub const OCR2A0: RegisterBits = RegisterBits::new(1<<0); + pub const OCR2A1: RegisterBits = RegisterBits::new(1<<1); + pub const OCR2A2: RegisterBits = RegisterBits::new(1<<2); + pub const OCR2A3: RegisterBits = RegisterBits::new(1<<3); + pub const OCR2A4: RegisterBits = RegisterBits::new(1<<4); + pub const OCR2A5: RegisterBits = RegisterBits::new(1<<5); + pub const OCR2A6: RegisterBits = RegisterBits::new(1<<6); + pub const OCR2A7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OCR2A { + type T = u8; + const ADDRESS: *mut u8 = 0xb3 as *mut u8; +} +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; +} +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; +} +pub struct ADC; + +impl ADC { + pub const ADC: RegisterBits = RegisterBits::new(0x3ff); + pub const ADC0: RegisterBits = RegisterBits::new(1<<0); + pub const ADC1: RegisterBits = RegisterBits::new(1<<1); + pub const ADC2: RegisterBits = RegisterBits::new(1<<2); + pub const ADC3: RegisterBits = RegisterBits::new(1<<3); + pub const ADC4: RegisterBits = RegisterBits::new(1<<4); + pub const ADC5: RegisterBits = RegisterBits::new(1<<5); + pub const ADC6: RegisterBits = RegisterBits::new(1<<6); + pub const ADC7: RegisterBits = RegisterBits::new(1<<7); + pub const ADC8: RegisterBits = RegisterBits::new(1<<8); + pub const ADC9: RegisterBits = RegisterBits::new(1<<9); + +} + +impl Register for ADC { + type T = u16; + const ADDRESS: *mut u16 = 0x78 as *mut u16; +} +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; +} +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; +} +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; +} +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; +} +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; +} +pub struct PORTB; + +impl PORTB { +} + +impl Register for PORTB { + type T = u8; + const ADDRESS: *mut u8 = 0x25 as *mut u8; +} +pub struct DDRB; + +impl DDRB { +} + +impl Register for DDRB { + type T = u8; + const ADDRESS: *mut u8 = 0x24 as *mut u8; +} +pub struct PINB; + +impl PINB { +} + +impl Register for PINB { + type T = u8; + const ADDRESS: *mut u8 = 0x23 as *mut u8; +} +pub struct PORTC; + +impl PORTC { +} + +impl Register for PORTC { + type T = u8; + const ADDRESS: *mut u8 = 0x28 as *mut u8; +} +pub struct DDRC; + +impl DDRC { +} + +impl Register for DDRC { + type T = u8; + const ADDRESS: *mut u8 = 0x27 as *mut u8; +} +pub struct PINC; + +impl PINC { +} + +impl Register for PINC { + type T = u8; + const ADDRESS: *mut u8 = 0x26 as *mut u8; +} +pub struct PORTD; + +impl PORTD { +} + +impl Register for PORTD { + type T = u8; + const ADDRESS: *mut u8 = 0x2b as *mut u8; +} +pub struct DDRD; + +impl DDRD { +} + +impl Register for DDRD { + type T = u8; + const ADDRESS: *mut u8 = 0x2a as *mut u8; +} +pub struct PIND; + +impl PIND { +} + +impl Register for PIND { + type T = u8; + const ADDRESS: *mut u8 = 0x29 as *mut u8; +} +pub struct OCR0B; + +impl OCR0B { + pub const OCR0B: RegisterBits = RegisterBits::new(0xff); + pub const OCR0B0: RegisterBits = RegisterBits::new(1<<0); + pub const OCR0B1: RegisterBits = RegisterBits::new(1<<1); + pub const OCR0B2: RegisterBits = RegisterBits::new(1<<2); + pub const OCR0B3: RegisterBits = RegisterBits::new(1<<3); + pub const OCR0B4: RegisterBits = RegisterBits::new(1<<4); + pub const OCR0B5: RegisterBits = RegisterBits::new(1<<5); + pub const OCR0B6: RegisterBits = RegisterBits::new(1<<6); + pub const OCR0B7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OCR0B { + type T = u8; + const ADDRESS: *mut u8 = 0x48 as *mut u8; +} +pub struct OCR0A; + +impl OCR0A { + pub const OCR0A: RegisterBits = RegisterBits::new(0xff); + pub const OCR0A0: RegisterBits = RegisterBits::new(1<<0); + pub const OCR0A1: RegisterBits = RegisterBits::new(1<<1); + pub const OCR0A2: RegisterBits = RegisterBits::new(1<<2); + pub const OCR0A3: RegisterBits = RegisterBits::new(1<<3); + pub const OCR0A4: RegisterBits = RegisterBits::new(1<<4); + pub const OCR0A5: RegisterBits = RegisterBits::new(1<<5); + pub const OCR0A6: RegisterBits = RegisterBits::new(1<<6); + pub const OCR0A7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for OCR0A { + type T = u8; + const ADDRESS: *mut u8 = 0x47 as *mut u8; +} +pub struct TCNT0; + +impl TCNT0 { + pub const TCNT0: RegisterBits = RegisterBits::new(0xff); + pub const TCNT00: RegisterBits = RegisterBits::new(1<<0); + pub const TCNT01: RegisterBits = RegisterBits::new(1<<1); + pub const TCNT02: RegisterBits = RegisterBits::new(1<<2); + pub const TCNT03: RegisterBits = RegisterBits::new(1<<3); + pub const TCNT04: RegisterBits = RegisterBits::new(1<<4); + pub const TCNT05: RegisterBits = RegisterBits::new(1<<5); + pub const TCNT06: RegisterBits = RegisterBits::new(1<<6); + pub const TCNT07: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for TCNT0 { + type T = u8; + const ADDRESS: *mut u8 = 0x46 as *mut u8; +} +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; +} +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; +} +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; +} +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; +} +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; +} +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; +} +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; +} +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; +} +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; +} +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; +} +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; +} +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; +} +pub struct SPDR; + +impl SPDR { + pub const SPDR: RegisterBits = RegisterBits::new(0xff); + pub const SPDR0: RegisterBits = RegisterBits::new(1<<0); + pub const SPDR1: RegisterBits = RegisterBits::new(1<<1); + pub const SPDR2: RegisterBits = RegisterBits::new(1<<2); + pub const SPDR3: RegisterBits = RegisterBits::new(1<<3); + pub const SPDR4: RegisterBits = RegisterBits::new(1<<4); + pub const SPDR5: RegisterBits = RegisterBits::new(1<<5); + pub const SPDR6: RegisterBits = RegisterBits::new(1<<6); + pub const SPDR7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for SPDR { + type T = u8; + const ADDRESS: *mut u8 = 0x4e as *mut u8; +} +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; +} +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; +} +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; +} +pub struct EEAR; + +impl EEAR { + pub const EEAR: RegisterBits = RegisterBits::new(0x3ff); + pub const EEAR0: RegisterBits = RegisterBits::new(1<<0); + pub const EEAR1: RegisterBits = RegisterBits::new(1<<1); + pub const EEAR2: RegisterBits = RegisterBits::new(1<<2); + pub const EEAR3: RegisterBits = RegisterBits::new(1<<3); + pub const EEAR4: RegisterBits = RegisterBits::new(1<<4); + pub const EEAR5: RegisterBits = RegisterBits::new(1<<5); + pub const EEAR6: RegisterBits = RegisterBits::new(1<<6); + pub const EEAR7: RegisterBits = RegisterBits::new(1<<7); + pub const EEAR8: RegisterBits = RegisterBits::new(1<<8); + pub const EEAR9: RegisterBits = RegisterBits::new(1<<9); + +} + +impl Register for EEAR { + type T = u16; + const ADDRESS: *mut u16 = 0x41 as *mut u16; +} +pub struct EEDR; + +impl EEDR { + pub const EEDR: RegisterBits = RegisterBits::new(0xff); + pub const EEDR0: RegisterBits = RegisterBits::new(1<<0); + pub const EEDR1: RegisterBits = RegisterBits::new(1<<1); + pub const EEDR2: RegisterBits = RegisterBits::new(1<<2); + pub const EEDR3: RegisterBits = RegisterBits::new(1<<3); + pub const EEDR4: RegisterBits = RegisterBits::new(1<<4); + pub const EEDR5: RegisterBits = RegisterBits::new(1<<5); + pub const EEDR6: RegisterBits = RegisterBits::new(1<<6); + pub const EEDR7: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for EEDR { + type T = u8; + const ADDRESS: *mut u8 = 0x40 as *mut u8; +} +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 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; +} +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; +} +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; +} +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; +} +pub struct SP; + +impl SP { +} + +impl Register for SP { + type T = u16; + const ADDRESS: *mut u16 = 0x5d as *mut u16; +} +pub struct SPMCSR; + +impl SPMCSR { + pub const SPMIE: RegisterBits = RegisterBits::new(0x80); + pub const SPMIE0: RegisterBits = RegisterBits::new(1<<7); + + pub const RWWSB: RegisterBits = RegisterBits::new(0x40); + pub const RWWSB0: RegisterBits = RegisterBits::new(1<<6); + + pub const SIGRD: RegisterBits = RegisterBits::new(0x20); + pub const SIGRD0: RegisterBits = RegisterBits::new(1<<5); + + pub const RWWSRE: RegisterBits = RegisterBits::new(0x10); + pub const RWWSRE0: RegisterBits = RegisterBits::new(1<<4); + + pub const BLBSET: RegisterBits = RegisterBits::new(0x8); + pub const BLBSET0: RegisterBits = RegisterBits::new(1<<3); + + pub const PGWRT: RegisterBits = RegisterBits::new(0x4); + pub const PGWRT0: RegisterBits = RegisterBits::new(1<<2); + + pub const PGERS: RegisterBits = RegisterBits::new(0x2); + pub const PGERS0: RegisterBits = RegisterBits::new(1<<1); + + pub const SPMEN: RegisterBits = RegisterBits::new(0x1); + pub const SPMEN0: RegisterBits = RegisterBits::new(1<<0); + +} + +impl Register for SPMCSR { + type T = u8; + const ADDRESS: *mut u8 = 0x57 as *mut u8; +} +pub 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; +} +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; +} +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; +} +pub struct GPIOR2; + +impl GPIOR2 { + pub const GPIOR2: RegisterBits = RegisterBits::new(0xff); + pub const GPIOR20: RegisterBits = RegisterBits::new(1<<0); + pub const GPIOR21: RegisterBits = RegisterBits::new(1<<1); + pub const GPIOR22: RegisterBits = RegisterBits::new(1<<2); + pub const GPIOR23: RegisterBits = RegisterBits::new(1<<3); + pub const GPIOR24: RegisterBits = RegisterBits::new(1<<4); + pub const GPIOR25: RegisterBits = RegisterBits::new(1<<5); + pub const GPIOR26: RegisterBits = RegisterBits::new(1<<6); + pub const GPIOR27: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for GPIOR2 { + type T = u8; + const ADDRESS: *mut u8 = 0x4b as *mut u8; +} +pub struct GPIOR1; + +impl GPIOR1 { + pub const GPIOR1: RegisterBits = RegisterBits::new(0xff); + pub const GPIOR10: RegisterBits = RegisterBits::new(1<<0); + pub const GPIOR11: RegisterBits = RegisterBits::new(1<<1); + pub const GPIOR12: RegisterBits = RegisterBits::new(1<<2); + pub const GPIOR13: RegisterBits = RegisterBits::new(1<<3); + pub const GPIOR14: RegisterBits = RegisterBits::new(1<<4); + pub const GPIOR15: RegisterBits = RegisterBits::new(1<<5); + pub const GPIOR16: RegisterBits = RegisterBits::new(1<<6); + pub const GPIOR17: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for GPIOR1 { + type T = u8; + const ADDRESS: *mut u8 = 0x4a as *mut u8; +} +pub struct GPIOR0; + +impl GPIOR0 { + pub const GPIOR0: RegisterBits = RegisterBits::new(0xff); + pub const GPIOR00: RegisterBits = RegisterBits::new(1<<0); + pub const GPIOR01: RegisterBits = RegisterBits::new(1<<1); + pub const GPIOR02: RegisterBits = RegisterBits::new(1<<2); + pub const GPIOR03: RegisterBits = RegisterBits::new(1<<3); + pub const GPIOR04: RegisterBits = RegisterBits::new(1<<4); + pub const GPIOR05: RegisterBits = RegisterBits::new(1<<5); + pub const GPIOR06: RegisterBits = RegisterBits::new(1<<6); + pub const GPIOR07: RegisterBits = RegisterBits::new(1<<7); + +} + +impl Register for GPIOR0 { + type T = u8; + const ADDRESS: *mut u8 = 0x3e as *mut u8; +} +pub mod port { + 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 new file mode 100644 index 0000000..2bd1f10 --- /dev/null +++ b/src/cores/mod.rs @@ -0,0 +1,6 @@ + +/// The ATmega328. +pub mod atmega328; +#[cfg(avr_mcu_atmega328)] +pub use self::atmega328 as current; +