diff --git a/examples/gpio_status.rs b/examples/gpio_status.rs index 9bd8ccc..e0766e2 100644 --- a/examples/gpio_status.rs +++ b/examples/gpio_status.rs @@ -142,19 +142,6 @@ fn main() -> Result<(), Box> { print_header(&header_rev1[..MAX_PINS_SHORT]) } Model::RaspberryPiA | Model::RaspberryPiBRev2 => print_header(&HEADER[..MAX_PINS_SHORT]), - Model::RaspberryPiAPlus - | Model::RaspberryPiBPlus - | Model::RaspberryPi2B - | Model::RaspberryPi3APlus - | Model::RaspberryPi3B - | Model::RaspberryPi3BPlus - | Model::RaspberryPi4B - | Model::RaspberryPi5 - | Model::RaspberryPiZero - | Model::RaspberryPiZeroW => print_header(&HEADER[..MAX_PINS_LONG]), - model => { - eprintln!("Error: No GPIO header information available for {}", model); - process::exit(1); - } + _ => print_header(&HEADER[..MAX_PINS_LONG]), } } diff --git a/src/i2c.rs b/src/i2c.rs index 9906696..e5c93a6 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -233,7 +233,14 @@ impl I2c { match DeviceInfo::new()?.model() { // Pi B Rev 1 uses I2C0 Model::RaspberryPiBRev1 => I2c::with_bus(0), - Model::RaspberryPi4B | Model::RaspberryPi400 | Model::RaspberryPi5 => { + Model::RaspberryPi4B + | Model::RaspberryPi400 + | Model::RaspberryPiComputeModule4 + | Model::RaspberryPiComputeModule4S + | Model::RaspberryPi5 + | Model::RaspberryPi500 + | Model::RaspberryPiComputeModule5 + | Model::RaspberryPiComputeModule5Lite => { // Pi 4B/400 could have I2C3 enabled on pins 3 and 5 I2c::with_bus(1).or_else(|_| I2c::with_bus(3)) } diff --git a/src/system.rs b/src/system.rs index b9176ea..1220ca8 100644 --- a/src/system.rs +++ b/src/system.rs @@ -87,6 +87,7 @@ pub enum Model { RaspberryPiComputeModule4, RaspberryPiComputeModule4S, RaspberryPiComputeModule5, + RaspberryPiComputeModule5Lite, RaspberryPiZero, RaspberryPiZeroW, RaspberryPiZero2W, @@ -114,6 +115,7 @@ impl fmt::Display for Model { Model::RaspberryPiComputeModule4 => write!(f, "Raspberry Pi Compute Module 4"), Model::RaspberryPiComputeModule4S => write!(f, "Raspberry Pi Compute Module 4S"), Model::RaspberryPiComputeModule5 => write!(f, "Raspberry Pi Compute Module 5"), + Model::RaspberryPiComputeModule5Lite => write!(f, "Raspberry Pi Compute Module 5 Lite"), Model::RaspberryPiZero => write!(f, "Raspberry Pi Zero"), Model::RaspberryPiZeroW => write!(f, "Raspberry Pi Zero W"), Model::RaspberryPiZero2W => write!(f, "Raspberry Pi Zero 2 W"), @@ -212,7 +214,9 @@ fn parse_proc_cpuinfo() -> Result { 0x14 => Model::RaspberryPiComputeModule4, 0x15 => Model::RaspberryPiComputeModule4S, 0x17 => Model::RaspberryPi5, + 0x18 => Model::RaspberryPiComputeModule5, 0x19 => Model::RaspberryPi500, + 0x1a => Model::RaspberryPiComputeModule5Lite, _ => return Err(Error::UnknownModel), } } else { @@ -320,6 +324,7 @@ fn parse_base_model() -> Result { "Raspberry Pi Compute Module 4S" => Model::RaspberryPiComputeModule4S, "Raspberry Pi 5 Model B" => Model::RaspberryPi5, "Raspberry Pi Compute Module 5" => Model::RaspberryPiComputeModule5, + "Raspberry Pi Compute Module 5 Lite" => Model::RaspberryPiComputeModule5Lite, "Raspberry Pi 500" => Model::RaspberryPi500, _ => return Err(Error::UnknownModel), }; @@ -423,18 +428,19 @@ impl DeviceInfo { pwm_chip: 0, pwm_channels: [0, 1], }), - Model::RaspberryPi5 | Model::RaspberryPi500 | Model::RaspberryPiComputeModule5 => { - Ok(DeviceInfo { - model, - soc: SoC::Bcm2712, - peripheral_base: PERIPHERAL_BASE_RP1, - gpio_offset: GPIO_OFFSET_RP1, - gpio_lines: GPIO_LINES_RP1, - gpio_interface: GpioInterface::Rp1, - pwm_chip: 2, - pwm_channels: [2, 3], - }) - } + Model::RaspberryPi5 + | Model::RaspberryPi500 + | Model::RaspberryPiComputeModule5 + | Model::RaspberryPiComputeModule5Lite => Ok(DeviceInfo { + model, + soc: SoC::Bcm2712, + peripheral_base: PERIPHERAL_BASE_RP1, + gpio_offset: GPIO_OFFSET_RP1, + gpio_lines: GPIO_LINES_RP1, + gpio_interface: GpioInterface::Rp1, + pwm_chip: 2, + pwm_channels: [2, 3], + }), } } diff --git a/src/uart.rs b/src/uart.rs index e943894..0f7048f 100644 --- a/src/uart.rs +++ b/src/uart.rs @@ -145,7 +145,7 @@ use libc::{c_int, O_NOCTTY, O_NONBLOCK}; use libc::{TIOCM_CAR, TIOCM_CTS, TIOCM_DSR, TIOCM_DTR, TIOCM_RNG, TIOCM_RTS}; use crate::gpio::{self, Gpio, IoPin, Mode}; -use crate::system::{self, DeviceInfo, Model}; +use crate::system::{self, DeviceInfo, Model, SoC}; #[cfg(any( feature = "embedded-hal-0", @@ -422,8 +422,8 @@ impl Uart { // On the Raspberry Pi 5, by default /dev/serial0 will point to the UART on the debug header, // which is /dev/ttyAMA10. Check if /dev/ttyAMA0 exists first, which would mean the user // enabled UART on GPIO14/15 and likely wants to use that one instead. - let path = match DeviceInfo::new()?.model() { - Model::RaspberryPi5 | Model::RaspberryPiComputeModule5 => { + let path = match DeviceInfo::new()?.soc() { + SoC::Bcm2712 => { if Path::new("/dev/ttyAMA0").exists() { "/dev/ttyAMA0" } else {