Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

atmega-hal: atmega168 #145

Merged
merged 2 commits into from
Feb 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
mcu:
- name: atmega1280
crate: atmega-hal
- name: atmega168
crate: atmega-hal
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down
1 change: 1 addition & 0 deletions mcu/atmega-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2018"
[features]
rt = ["avr-device/rt"]
device-selected = []
atmega168 = ["avr-device/atmega168", "device-selected"]
atmega328p = ["avr-device/atmega328p", "device-selected"]
atmega328pb = ["avr-device/atmega328pb", "device-selected"]
atmega32u4 = ["avr-device/atmega32u4", "device-selected"]
Expand Down
20 changes: 17 additions & 3 deletions mcu/atmega-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ compile_error!(

Please select one of the following

* atmega168
* atmega328p
* atmega32u4
* atmega1280
Expand All @@ -19,6 +20,9 @@ compile_error!(
/// Reexport of `atmega1280` from `avr-device`
#[cfg(feature = "atmega1280")]
pub use avr_device::atmega1280 as pac;
/// Reexport of `atmega168` from `avr-device`
#[cfg(feature = "atmega168")]
pub use avr_device::atmega168 as pac;
/// Reexport of `atmega2560` from `avr-device`
#[cfg(feature = "atmega2560")]
pub use avr_device::atmega2560 as pac;
Expand Down Expand Up @@ -52,7 +56,12 @@ pub struct RawPeripheral<P>(pub(crate) P);
#[cfg(feature = "device-selected")]
pub struct Peripherals {
pub pins: Pins,
#[cfg(any(feature = "atmega328p", feature = "atmega1280", feature = "atmega2560"))]
#[cfg(any(
feature = "atmega168",
feature = "atmega328p",
feature = "atmega1280",
feature = "atmega2560"
))]
pub USART0: RawPeripheral<pac::USART0>,
#[cfg(any(feature = "atmega32u4", feature = "atmega1280", feature = "atmega2560"))]
pub USART1: RawPeripheral<pac::USART1>,
Expand All @@ -66,7 +75,7 @@ pub struct Peripherals {
impl Peripherals {
fn new(dp: pac::Peripherals) -> Self {
Self {
#[cfg(feature = "atmega328p")]
#[cfg(any(feature = "atmega168", feature = "atmega328p"))]
pins: Pins::new(dp.PORTB, dp.PORTC, dp.PORTD),
#[cfg(feature = "atmega32u4")]
pins: Pins::new(dp.PORTB, dp.PORTC, dp.PORTD, dp.PORTE, dp.PORTF),
Expand All @@ -76,7 +85,12 @@ impl Peripherals {
dp.PORTJ, dp.PORTK, dp.PORTL,
),

#[cfg(any(feature = "atmega328p", feature = "atmega1280", feature = "atmega2560"))]
#[cfg(any(
feature = "atmega168",
feature = "atmega328p",
feature = "atmega1280",
feature = "atmega2560"
))]
USART0: RawPeripheral(dp.USART0),
#[cfg(any(feature = "atmega32u4", feature = "atmega1280", feature = "atmega2560"))]
USART1: RawPeripheral(dp.USART1),
Expand Down
2 changes: 1 addition & 1 deletion mcu/atmega-hal/src/port.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(feature = "atmega328p")]
#[cfg(any(feature = "atmega168", feature = "atmega328p"))]
avr_hal_generic::impl_port_traditional! {
enum Ports {
PORTB: (crate::pac::PORTB, portb, pinb, ddrb),
Expand Down
4 changes: 2 additions & 2 deletions mcu/atmega-hal/src/usart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
use crate::port;
pub use avr_hal_generic::usart::*;

#[cfg(feature = "atmega328p")]
#[cfg(any(feature = "atmega168", feature = "atmega328p"))]
pub type Usart0<CLOCK, IMODE> = Usart<
crate::RawPeripheral<crate::pac::USART0>,
port::Pin<port::mode::Input<IMODE>, port::PD0>,
port::Pin<port::mode::Output, port::PD1>,
CLOCK,
>;
#[cfg(feature = "atmega328p")]
#[cfg(any(feature = "atmega168", feature = "atmega328p"))]
avr_hal_generic::impl_usart_traditional! {
peripheral: crate::RawPeripheral<crate::pac::USART0>,
register_suffix: 0,
Expand Down