From b0abe893ed36425cfd63bbe5a9d0881bcee053cb Mon Sep 17 00:00:00 2001 From: Andrew Dona-Couch Date: Fri, 31 Jul 2020 23:22:25 -0400 Subject: [PATCH] Add support for ATtiny88 --- Cargo.toml | 1 + Makefile | 2 +- README.md | 1 + patch/attiny88.yaml | 127 ++++ patch/timer/attiny88.yaml | 14 + patch/timer/dev/8bit-tiny88.yaml | 11 + src/devices/mod.rs | 19 + src/lib.rs | 5 + vendor/attiny88.atdf | 1015 ++++++++++++++++++++++++++++++ 9 files changed, 1194 insertions(+), 1 deletion(-) create mode 100644 patch/attiny88.yaml create mode 100644 patch/timer/attiny88.yaml create mode 100644 patch/timer/dev/8bit-tiny88.yaml create mode 100644 vendor/attiny88.atdf diff --git a/Cargo.toml b/Cargo.toml index 3292940..b459362 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,7 @@ atmega328p = [] atmega32u4 = [] atmega64 = [] attiny85 = [] +attiny88 = [] rt = ["avr-device-macros"] [dependencies] diff --git a/Makefile b/Makefile index 5cbec8c..1e46308 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all: deps chips -CHIPS := atmega1280 atmega2560 atmega8 atmega328p atmega32u4 atmega64 attiny85 +CHIPS := atmega1280 atmega2560 atmega8 atmega328p atmega32u4 atmega64 attiny85 attiny88 RUSTUP_TOOLCHAIN ?= nightly diff --git a/README.md b/README.md index 8b5f0e3..d525aea 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Via the feature you can select which chip you want the register specifications f * `atmega32u4` * `atmega64` * `attiny85` +* `attiny88` ## Build Instructions The version on `crates.io` is pre-built. The following is only necessary when trying to build this crate from source. diff --git a/patch/attiny88.yaml b/patch/attiny88.yaml new file mode 100644 index 0000000..e1f3166 --- /dev/null +++ b/patch/attiny88.yaml @@ -0,0 +1,127 @@ +_include: + - "common/ac.yaml" + - "common/spi.yaml" + - "common/wdt.yaml" + + - "timer/attiny88.yaml" + +ADC: + ADMUX: + _modify: + MUX: + description: "Analog Channel Selection Bits" + MUX: + _replace_enum: + ADC0: [0, "ADC Single Ended Input pin 0"] + ADC1: [1, "ADC Single Ended Input pin 1"] + ADC2: [2, "ADC Single Ended Input pin 2"] + ADC3: [3, "ADC Single Ended Input pin 3"] + ADC4: [4, "ADC Single Ended Input pin 4"] + ADC5: [5, "ADC Single Ended Input pin 5"] + ADC6: [6, "ADC Single Ended Input pin 6"] + ADC7: [7, "ADC Single Ended Input pin 7"] + TEMPSENS: [8, "Temperature sensor"] + ADC_VBG: [14, "Internal Reference (VBG)"] + ADC_GND: [15, "0V (GND)"] + REFS0: + _replace_enum: + INTERNAL: [0, "Internal 1.1V Voltage Reference"] + AVCC: [1, "AVcc Reference"] + ADCSRA: + ADPS: + _replace_enum: + PRESCALER_2: [1, "Prescaler Value 2"] + PRESCALER_4: [2, "Prescaler Value 4"] + PRESCALER_8: [3, "Prescaler Value 8"] + PRESCALER_16: [4, "Prescaler Value 16"] + PRESCALER_32: [5, "Prescaler Value 32"] + PRESCALER_64: [6, "Prescaler Value 64"] + PRESCALER_128: [7, "Prescaler Value 128"] + ADCSRB: + ADTS: + _replace_enum: + FREE: [0, "Free Running mode"] + AC: [1, "Analog Comparator"] + INT0: [2, "External Interrupt Request 0"] + TC0_CMA: [3, "Timer/Counter0 Compare Match A"] + TC0_OVF: [4, "Timer/Counter0 Overflow"] + TC1_CMB: [5, "Timer/Counter1 Compare Match B"] + TC1_OVF: [6, "Timer/Counter1 Overflow"] + TC1_CE: [7, "Timer/Counter1 Capture Event"] +CPU: + _modify: + CLKPR: + access: read-write + OSCCAL: + access: read-write + PORTCR: + access: read-write + PRR: + access: read-write + CLKPR: + CLKPS: + _replace_enum: + PRESCALER_1: [0, "Prescaler Value 1"] + PRESCALER_2: [1, "Prescaler Value 2"] + PRESCALER_4: [2, "Prescaler Value 4"] + PRESCALER_8: [3, "Prescaler Value 8"] + PRESCALER_16: [4, "Prescaler Value 16"] + PRESCALER_32: [5, "Prescaler Value 32"] + PRESCALER_64: [6, "Prescaler Value 64"] + PRESCALER_128: [7, "Prescaler Value 128"] + PRESCALER_256: [8, "Prescaler Value 256"] + SMCR: + SM: + _replace_enum: + IDLE: [0, "Idle"] + ADC: [1, "ADC Noise Reduction"] + PDOWN: [2, "Power-down"] +EEPROM: + EECR: + EEPM: + _replace_enum: + ATOMIC: [0, "Atomic (erase and write in one operation)"] + ERASE: [1, "Erase only"] + WRITE: [2, "Write only"] +EXINT: + EICRA: + ISC0: + _replace_enum: + LOW: [0, "The low level of INT0 generates an interrupt request"] + TOGGLE: [1, "Any logical change on INT0 generates an interrupt request"] + FALLING: [2, "The falling edge of INT0 generates an interrupt request"] + RISING: [3, "The rising edge of INT0 generates an interrupt request"] + ISC1: + _replace_enum: + LOW: [0, "The low level of INT1 generates an interrupt request"] + TOGGLE: [1, "Any logical change on INT1 generates an interrupt request"] + FALLING: [2, "The falling edge of INT1 generates an interrupt request"] + RISING: [3, "The rising edge of INT1 generates an interrupt request"] + _modify: + PCICR: + description: "Pin Change Interrupt Control Register" +PORTA: + _modify: + PORTA: + access: read-write + DDRA: + access: read-write +TWI: + TWCR: + _modify: + TWWC: + access: read-only + TWAMR: + _modify: + TWAM: + description: "TWI (Slave) Address Mask Bits" + TWSR: + _modify: + TWS: + access: read-only + TWPS: + _replace_enum: + PRESCALER_1: [0, "Prescaler Value 1"] + PRESCALER_4: [1, "Prescaler Value 4"] + PRESCALER_16: [2, "Prescaler Value 16"] + PRESCALER_64: [3, "Prescaler Value 64"] diff --git a/patch/timer/attiny88.yaml b/patch/timer/attiny88.yaml new file mode 100644 index 0000000..4ee715e --- /dev/null +++ b/patch/timer/attiny88.yaml @@ -0,0 +1,14 @@ +# This intermediate file is needed because peripheral-level includes are not +# supported in top-level files. + +_modify: + TC1: + description: "Timer/Counter1, 16-bit, PWM" + +TC0: + _include: + - "dev/8bit-tiny88.yaml" + +TC1: + _include: + - "dev/16bit.yaml" diff --git a/patch/timer/dev/8bit-tiny88.yaml b/patch/timer/dev/8bit-tiny88.yaml new file mode 100644 index 0000000..449038d --- /dev/null +++ b/patch/timer/dev/8bit-tiny88.yaml @@ -0,0 +1,11 @@ +TCCR?A: + CS?: + _replace_enum: + NO_CLOCK: [0, "No clock source (Timer/Counter stopped)"] + DIRECT: [1, "Running, No Prescaling"] + PRESCALE_8: [2, "Running, CLK/8"] + PRESCALE_64: [3, "Running, CLK/64"] + PRESCALE_256: [4, "Running, CLK/256"] + PRESCALE_1024: [5, "Running, CLK/1024"] + EXT_FALLING: [6, "Running, ExtClk Tx Falling Edge"] + EXT_RISING: [7, "Running, ExtClk Tx Rising Edge"] diff --git a/src/devices/mod.rs b/src/devices/mod.rs index 41dd429..4408629 100644 --- a/src/devices/mod.rs +++ b/src/devices/mod.rs @@ -135,3 +135,22 @@ impl attiny85::Peripherals { }) } } + +/// [ATtiny88](https://www.microchip.com/wwwproducts/en/ATtiny88) +#[cfg(feature = "attiny88")] +pub mod attiny88; + +#[cfg(feature = "attiny88")] +impl attiny88::Peripherals { + /// Returns all the peripherals *once* + #[inline] + pub fn take() -> Option { + crate::interrupt::free(|_| { + if unsafe { DEVICE_PERIPHERALS } { + None + } else { + Some(unsafe { attiny88::Peripherals::steal() }) + } + }) + } +} diff --git a/src/lib.rs b/src/lib.rs index c95ac64..3ebf359 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,6 +6,7 @@ #![cfg_attr(feature = "atmega32u4", doc = "**atmega32u4**,")] #![cfg_attr(feature = "atmega64", doc = "**atmega64**,")] #![cfg_attr(feature = "attiny85", doc = "**attiny85**,")] +#![cfg_attr(feature = "attiny88", doc = "**attiny88**,")] //! and a few things which apply to AVR microcontrollers generally. //! //! Which chips the crate is built for depends on the feature flag used. @@ -17,6 +18,7 @@ //! * `atmega32u4` //! * `atmega64` //! * `attiny85` +//! * `attiny88` #![no_std] #![feature(llvm_asm)] @@ -78,6 +80,8 @@ pub use crate::devices::atmega8; pub use crate::devices::atmega64; #[cfg(feature = "attiny85")] pub use crate::devices::attiny85; +#[cfg(feature = "attiny88")] +pub use crate::devices::attiny88; #[cfg(not(any( feature = "atmega1280", @@ -87,5 +91,6 @@ pub use crate::devices::attiny85; feature = "atmega32u4", feature = "atmega64", feature = "attiny85", + feature = "attiny88", )))] compile_error!("You need to select at least one chip as a feature!"); diff --git a/vendor/attiny88.atdf b/vendor/attiny88.atdf new file mode 100644 index 0000000..2c51109 --- /dev/null +++ b/vendor/attiny88.atdf @@ -0,0 +1,1015 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- 2.48.1