Skip to content

Commit

Permalink
rename mcu module to platform
Browse files Browse the repository at this point in the history
  • Loading branch information
Univa committed Mar 30, 2024
1 parent e9e09fb commit 10b0c03
Show file tree
Hide file tree
Showing 36 changed files with 200 additions and 200 deletions.
2 changes: 1 addition & 1 deletion docs/src/content/docs/features/feature-backlight.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ For example, with `is31fl3731`, you must implement `IS31FL3731DriverSettings` an
```rust ins={3-30}
// later in your file...

use rumcake::hw::mcu::setup_i2c;
use rumcake::hw::platform::setup_i2c;
use rumcake::drivers::is31fl3731::{
get_led_from_matrix_coordinates, IS31FL3731BacklightDriver
};
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/features/feature-bluetooth-host.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use rumcake::keyboard;
)]
struct MyKeyboard;

use rumcake::hw::mcu::BluetoothDevice;
use rumcake::hw::platform::BluetoothDevice;
impl BluetoothDevice for WingpairLeft {
// This addresses can be whatever you want, as long as it is a valid "Random Static" bluetooth addresses.
// See "Random Static Address" in this link: https://novelbits.io/bluetooth-address-privacy-ble/
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/features/feature-display.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ For example, with `ssd1306`, you must implement `Ssd1306I2cDriverSettings` and `
```rust ins={3-23}
// later in your file...

use rumcake::hw::mcu::setup_i2c_blocking;
use rumcake::hw::platform::setup_i2c_blocking;
use rumcake::drivers::ssd1306::driver::size::DisplaySize128x32;
use rumcake::drivers::ssd1306::display::Ssd1306I2cDisplayDriver;
// Note: The Ssd1306I2cDriverSettings trait does NOT come from the `rumcake` library. It is generated by the `keyboard` macro.
Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/features/feature-split.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl KeyboardLayout for MyKeyboard {
// later in your file ...

// Bluetooth device setup
use rumcake::hw::mcu::BluetoothDevice;
use rumcake::hw::platform::BluetoothDevice;
impl BluetoothDevice for MyKeyboardLeftHalf {
// This addresses can be whatever you want, as long as it is a valid "Random Static" bluetooth addresses.
// See "Random Static Address" in this link: https://novelbits.io/bluetooth-address-privacy-ble/
Expand Down Expand Up @@ -137,7 +137,7 @@ use rumcake::keyboard;
struct MyKeyboardRightHalf;

// Bluetooth device setup
use rumcake::hw::mcu::BluetoothDevice;
use rumcake::hw::platform::BluetoothDevice;
impl BluetoothDevice for WingpairLeft {
// Must be valid "Random Static" bluetooth address.
const BLUETOOTH_ADDRESS: [u8; 6] = [0x92, 0x32, 0x98, 0xC7, 0xF6, 0xF8]; // TODO: Change this to something else
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/features/feature-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ use rumcake::storage::StorageDevice;
impl StorageDevice for MyKeyboard {}

// Required for RP2040, omit if you are not using an RP2040
use rumcake::hw::mcu::setup_dma_channel;
use rumcake::hw::platform::setup_dma_channel;
impl RP2040FlashSettings for MyKeyboard {
setup_dma_channel! { DMA_CH0 }
}
Expand Down
2 changes: 1 addition & 1 deletion rumcake-macros/src/drivers/is31fl3731.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub fn driver_trait() -> TokenStream {

/// Setup the I2C peripheral to communicate with the IS31FL3731 chip.
///
/// It is recommended to use [`rumcake::hw::mcu::setup_i2c`] to implement this function.
/// It is recommended to use [`rumcake::hw::platform::setup_i2c`] to implement this function.
fn setup_i2c() -> impl ::rumcake::embedded_hal_async::i2c::I2c<Error = impl core::fmt::Debug>;
}
}
Expand Down
2 changes: 1 addition & 1 deletion rumcake-macros/src/drivers/ssd1306.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn driver_trait() -> TokenStream {

/// Setup the I2C peripheral to communicate with the SSD1306 display.
///
/// It is recommended to use [`rumcake::hw::mcu::setup_i2c`] to implement this function.
/// It is recommended to use [`rumcake::hw::platform::setup_i2c`] to implement this function.
fn setup_i2c() -> impl ::rumcake::embedded_hal::blocking::i2c::Write<Error = impl core::fmt::Debug>;
}
}
Expand Down
2 changes: 1 addition & 1 deletion rumcake-macros/src/drivers/ws2812.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub mod bitbang {
pub fn pin(input: Ident) -> TokenStream {
quote! {
fn ws2812_pin() -> impl ::rumcake::embedded_hal::digital::v2::OutputPin {
::rumcake::hw::mcu::output_pin!(#input)
::rumcake::hw::platform::output_pin!(#input)
}
}
}
Expand Down
84 changes: 42 additions & 42 deletions rumcake-macros/src/hw/nrf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ pub const HAL_CRATE: &'static str = "embassy_nrf";
pub fn input_pin(ident: Ident) -> TokenStream {
quote! {
unsafe {
::rumcake::hw::mcu::embassy_nrf::gpio::Input::new(
::rumcake::hw::mcu::embassy_nrf::gpio::Pin::degrade(
::rumcake::hw::mcu::embassy_nrf::peripherals::#ident::steal(),
::rumcake::hw::platform::embassy_nrf::gpio::Input::new(
::rumcake::hw::platform::embassy_nrf::gpio::Pin::degrade(
::rumcake::hw::platform::embassy_nrf::peripherals::#ident::steal(),
),
::rumcake::hw::mcu::embassy_nrf::gpio::Pull::Up,
::rumcake::hw::platform::embassy_nrf::gpio::Pull::Up,
)
}
}
Expand All @@ -25,12 +25,12 @@ pub fn input_pin(ident: Ident) -> TokenStream {
pub fn output_pin(ident: Ident) -> TokenStream {
quote! {
unsafe {
::rumcake::hw::mcu::embassy_nrf::gpio::Output::new(
::rumcake::hw::mcu::embassy_nrf::gpio::Pin::degrade(
::rumcake::hw::mcu::embassy_nrf::peripherals::#ident::steal(),
::rumcake::hw::platform::embassy_nrf::gpio::Output::new(
::rumcake::hw::platform::embassy_nrf::gpio::Pin::degrade(
::rumcake::hw::platform::embassy_nrf::peripherals::#ident::steal(),
),
::rumcake::hw::mcu::embassy_nrf::gpio::Level::High,
::rumcake::hw::mcu::embassy_nrf::gpio::OutputDrive::Standard,
::rumcake::hw::platform::embassy_nrf::gpio::Level::High,
::rumcake::hw::platform::embassy_nrf::gpio::OutputDrive::Standard,
)
}
}
Expand All @@ -55,18 +55,18 @@ fn setup_i2c_inner(args: Punctuated<Ident, Token![,]>) -> TokenStream {
}

quote! {
use ::rumcake::hw::mcu::embassy_nrf::interrupt::InterruptExt;
use ::rumcake::hw::platform::embassy_nrf::interrupt::InterruptExt;
unsafe {
::rumcake::hw::mcu::embassy_nrf::bind_interrupts! {
::rumcake::hw::platform::embassy_nrf::bind_interrupts! {
struct Irqs {
#interrupt => ::rumcake::hw::mcu::embassy_nrf::twim::InterruptHandler<::rumcake::hw::mcu::embassy_nrf::peripherals::#i2c>;
#interrupt => ::rumcake::hw::platform::embassy_nrf::twim::InterruptHandler<::rumcake::hw::platform::embassy_nrf::peripherals::#i2c>;
}
};
::rumcake::hw::mcu::embassy_nrf::interrupt::#interrupt.set_priority(::rumcake::hw::mcu::embassy_nrf::interrupt::Priority::P2);
let i2c = ::rumcake::hw::mcu::embassy_nrf::peripherals::#i2c::steal();
let sda = ::rumcake::hw::mcu::embassy_nrf::peripherals::#sda::steal();
let scl = ::rumcake::hw::mcu::embassy_nrf::peripherals::#scl::steal();
::rumcake::hw::mcu::embassy_nrf::twim::Twim::new(i2c, Irqs, sda, scl, Default::default())
::rumcake::hw::platform::embassy_nrf::interrupt::#interrupt.set_priority(::rumcake::hw::platform::embassy_nrf::interrupt::Priority::P2);
let i2c = ::rumcake::hw::platform::embassy_nrf::peripherals::#i2c::steal();
let sda = ::rumcake::hw::platform::embassy_nrf::peripherals::#sda::steal();
let scl = ::rumcake::hw::platform::embassy_nrf::peripherals::#scl::steal();
::rumcake::hw::platform::embassy_nrf::twim::Twim::new(i2c, Irqs, sda, scl, Default::default())
}
}
}
Expand Down Expand Up @@ -116,19 +116,19 @@ fn setup_buffered_uarte_inner(args: Punctuated<Ident, Token![,]>) -> TokenStream
unsafe {
static mut RBUF: [u8; 4096] = [0; 4096];
static mut TBUF: [u8; 4096] = [0; 4096];
::rumcake::hw::mcu::embassy_nrf::bind_interrupts! {
::rumcake::hw::platform::embassy_nrf::bind_interrupts! {
struct Irqs {
#interrupt => ::rumcake::hw::mcu::embassy_nrf::buffered_uarte::InterruptHandler<::rumcake::hw::mcu::embassy_nrf::peripherals::#uarte>;
#interrupt => ::rumcake::hw::platform::embassy_nrf::buffered_uarte::InterruptHandler<::rumcake::hw::platform::embassy_nrf::peripherals::#uarte>;
}
};
let uarte = ::rumcake::hw::mcu::embassy_nrf::peripherals::#uarte::steal();
let timer = ::rumcake::hw::mcu::embassy_nrf::peripherals::#timer::steal();
let ppi_ch1 = ::rumcake::hw::mcu::embassy_nrf::peripherals::#ppi_ch1::steal();
let ppi_ch2 = ::rumcake::hw::mcu::embassy_nrf::peripherals::#ppi_ch2::steal();
let ppi_group = ::rumcake::hw::mcu::embassy_nrf::peripherals::#ppi_group::steal();
let rx_pin = ::rumcake::hw::mcu::embassy_nrf::peripherals::#rx_pin::steal();
let tx_pin = ::rumcake::hw::mcu::embassy_nrf::peripherals::#tx_pin::steal();
::rumcake::hw::mcu::embassy_nrf::buffered_uarte::BufferedUarte::new(
let uarte = ::rumcake::hw::platform::embassy_nrf::peripherals::#uarte::steal();
let timer = ::rumcake::hw::platform::embassy_nrf::peripherals::#timer::steal();
let ppi_ch1 = ::rumcake::hw::platform::embassy_nrf::peripherals::#ppi_ch1::steal();
let ppi_ch2 = ::rumcake::hw::platform::embassy_nrf::peripherals::#ppi_ch2::steal();
let ppi_group = ::rumcake::hw::platform::embassy_nrf::peripherals::#ppi_group::steal();
let rx_pin = ::rumcake::hw::platform::embassy_nrf::peripherals::#rx_pin::steal();
let tx_pin = ::rumcake::hw::platform::embassy_nrf::peripherals::#tx_pin::steal();
::rumcake::hw::platform::embassy_nrf::buffered_uarte::BufferedUarte::new(
uarte,
timer,
ppi_ch1,
Expand Down Expand Up @@ -208,13 +208,13 @@ pub fn setup_adc_sampler(
let select_pins = select_pins.iter().map(|select_pin| match select_pin {
crate::keyboard::OptionalItem::None => quote! { None },
crate::keyboard::OptionalItem::Some(pin_ident) => {
quote! { Some(::rumcake::hw::mcu::output_pin!(#pin_ident)) }
quote! { Some(::rumcake::hw::platform::output_pin!(#pin_ident)) }
}
});

(
quote! {
::rumcake::hw::mcu::AnalogPinType::Multiplexed(
::rumcake::hw::platform::AnalogPinType::Multiplexed(
[0; #buf_size],
::rumcake::hw::Multiplexer::new(
[ #(#select_pins),* ],
Expand All @@ -223,31 +223,31 @@ pub fn setup_adc_sampler(
)
},
quote! {
::rumcake::hw::mcu::embassy_nrf::saadc::ChannelConfig::single_ended(
unsafe { ::rumcake::hw::mcu::embassy_nrf::peripherals::#pin::steal() }
::rumcake::hw::platform::embassy_nrf::saadc::ChannelConfig::single_ended(
unsafe { ::rumcake::hw::platform::embassy_nrf::peripherals::#pin::steal() }
)
},
)
}
AnalogPinType::Direct(DirectPinDefinition { pin, .. }) => (
quote! {
::rumcake::hw::mcu::AnalogPinType::Direct([0])
::rumcake::hw::platform::AnalogPinType::Direct([0])
},
quote! {
::rumcake::hw::mcu::embassy_nrf::saadc::ChannelConfig::single_ended(
unsafe { ::rumcake::hw::mcu::embassy_nrf::peripherals::#pin::steal() }
::rumcake::hw::platform::embassy_nrf::saadc::ChannelConfig::single_ended(
unsafe { ::rumcake::hw::platform::embassy_nrf::peripherals::#pin::steal() }
)
},
),
})
.unzip();

quote! {
type AdcSamplerType = ::rumcake::hw::mcu::AdcSampler<
type AdcSamplerType = ::rumcake::hw::platform::AdcSampler<
'static,
::rumcake::hw::mcu::embassy_nrf::peripherals::#timer,
::rumcake::hw::mcu::embassy_nrf::peripherals::#ppi_ch0,
::rumcake::hw::mcu::embassy_nrf::peripherals::#ppi_ch1,
::rumcake::hw::platform::embassy_nrf::peripherals::#timer,
::rumcake::hw::platform::embassy_nrf::peripherals::#ppi_ch0,
::rumcake::hw::platform::embassy_nrf::peripherals::#ppi_ch1,
#select_pin_count,
#channel_count,
>;
Expand All @@ -256,12 +256,12 @@ pub fn setup_adc_sampler(
static SAMPLER: ::rumcake::once_cell::sync::OnceCell<AdcSamplerType> = ::rumcake::once_cell::sync::OnceCell::new();

SAMPLER.get_or_init(|| unsafe {
::rumcake::hw::mcu::AdcSampler::new(
::rumcake::hw::platform::AdcSampler::new(
[ #(#pins),* ],
[ #(#channels),* ],
::rumcake::hw::mcu::embassy_nrf::peripherals::#timer::steal(),
::rumcake::hw::mcu::embassy_nrf::peripherals::#ppi_ch0::steal(),
::rumcake::hw::mcu::embassy_nrf::peripherals::#ppi_ch1::steal(),
::rumcake::hw::platform::embassy_nrf::peripherals::#timer::steal(),
::rumcake::hw::platform::embassy_nrf::peripherals::#ppi_ch0::steal(),
::rumcake::hw::platform::embassy_nrf::peripherals::#ppi_ch1::steal(),
)
})
}
Expand Down
Loading

0 comments on commit 10b0c03

Please sign in to comment.