Compare commits

..

4 Commits

Author SHA1 Message Date
Paul Bender 57ecefccc3 Generate error when century bit is set in month method. 2025-10-10 18:33:41 -07:00
Paul Bender 459dfa9200 Improve date/datetime too_big tests. 2025-10-10 18:12:55 -07:00
Paul Bender 66fee80b62 Generate error when century bit is set in functions already reading the century bit 2025-10-10 13:17:53 -07:00
Paul Bender 6874151dec Limit setting year to 20th century. 2025-10-10 12:57:58 -07:00
6 changed files with 19 additions and 31 deletions

View File

@ -8,16 +8,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
<!-- next-header -->
## [Unreleased] - ReleaseDate
## [0.7.0] - 2025-10-11
### Added
- Added `defmt` support behind a feature flag.
### Changed
- Updated `rtcc` to version 0.4.0, which has `defmt` support.
## [0.6.0] - 2025-01-02
### Changed
@ -101,8 +91,7 @@ this CHANGELOG.
[`rtcc`]: https://crates.io/crates/rtcc
<!-- next-url -->
[Unreleased]: https://github.com/eldruin/ds323x-rs/compare/v0.7.0...HEAD
[0.7.0]: https://github.com/eldruin/ds323x-rs/compare/v0.6.0...v0.7.0
[Unreleased]: https://github.com/eldruin/ds323x-rs/compare/v0.6.0...HEAD
[0.6.0]: https://github.com/eldruin/ds323x-rs/compare/v0.5.1...v0.6.0
[0.5.1]: https://github.com/eldruin/ds323x-rs/compare/v0.5.0...v0.5.1
[0.5.0]: https://github.com/eldruin/ds323x-rs/compare/v0.4.0...v0.5.0
@ -110,4 +99,4 @@ this CHANGELOG.
[0.3.2]: https://github.com/eldruin/ds323x-rs/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/eldruin/ds323x-rs/compare/v0.3.0...v0.3.1
[0.3.0]: https://github.com/eldruin/ds323x-rs/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/eldruin/ds323x-rs/compare/v0.1.0...v0.2.0
[0.2.0]: https://github.com/eldruin/ds323x-rs/compare/v0.1.0...v0.2.0

View File

@ -1,6 +1,6 @@
[package]
name = "ds323x"
version = "0.7.0"
version = "0.6.0"
authors = ["Diego Barrios Romero <eldruin@gmail.com>"]
repository = "https://github.com/eldruin/ds323x-rs"
license = "MIT OR Apache-2.0"
@ -20,13 +20,9 @@ include = [
]
edition = "2018"
[features]
defmt = ["dep:defmt", "rtcc/defmt"]
[dependencies]
embedded-hal = "1.0.0"
rtcc = "0.4"
defmt = { version = "1.0.1", optional = true }
rtcc = "0.3"
[dev-dependencies]
embedded-hal-mock = { version = "0.11.1", features = ["eh1"] }

View File

@ -15,7 +15,6 @@ use crate::{
/// - Second, minute and hour: 0
/// - Day: 1
#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct DayAlarm1 {
/// Day of the month [1-31]
pub day: u8,
@ -35,7 +34,6 @@ pub struct DayAlarm1 {
/// - Second, minute and hour: 0
/// - Weekday: 1
#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct WeekdayAlarm1 {
/// Weekday [1-7]
pub weekday: u8,
@ -49,7 +47,6 @@ pub struct WeekdayAlarm1 {
/// Alarm1 trigger rate
#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Alarm1Matching {
/// Alarm once per second.
OncePerSecond,
@ -71,7 +68,6 @@ pub enum Alarm1Matching {
/// - Minute and hour: 0
/// - Day: 1
#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct DayAlarm2 {
/// Day of month [1-31]
pub day: u8,
@ -89,7 +85,6 @@ pub struct DayAlarm2 {
/// - Minute and hour: 0
/// - Weekday: 1
#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct WeekdayAlarm2 {
/// Weekday [1-7]
pub weekday: u8,
@ -101,7 +96,6 @@ pub struct WeekdayAlarm2 {
/// Alarm2 trigger rate
#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Alarm2Matching {
/// Alarm once per minute. (00 seconds of every minute)
OncePerMinute,

View File

@ -5,14 +5,12 @@ use embedded_hal::{i2c, spi};
/// I2C interface
#[derive(Debug, Default)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct I2cInterface<I2C> {
pub(crate) i2c: I2C,
}
/// SPI interface
#[derive(Debug, Default)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct SpiInterface<SPI> {
pub(crate) spi: SPI,
}

View File

@ -377,7 +377,6 @@ pub const SPI_MODE_3: Mode = MODE_3;
/// All possible errors in this crate
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Error<E> {
/// I²C/SPI bus error
Comm(E),
@ -397,7 +396,6 @@ pub enum Error<E> {
/// Square-wave output frequency
#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum SqWFreq {
/// 1 Hz (default)
_1Hz,
@ -413,7 +411,6 @@ pub enum SqWFreq {
///
/// This is only available on the DS3232 and DS3234 devices.
#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum TempConvRate {
/// Once every 64 seconds (default)
_64s,
@ -486,7 +483,6 @@ pub mod ic {
/// DS3231, DS3232 and DS3234 RTC driver
#[derive(Debug, Default)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct Ds323x<DI, IC> {
iface: DI,
control: u8,

View File

@ -57,6 +57,21 @@ impl BitFlags {
pub const WEEKDAY: u8 = 0b0100_0000;
}
pub struct DummyOutputPin;
impl embedded_hal::digital::OutputPin for DummyOutputPin {
fn set_low(&mut self) -> Result<(), Self::Error> {
Ok(())
}
fn set_high(&mut self) -> Result<(), Self::Error> {
Ok(())
}
}
impl embedded_hal::digital::ErrorType for DummyOutputPin {
type Error = embedded_hal::digital::ErrorKind;
}
pub fn new_ds3231(
transactions: &[I2cTrans],
) -> Ds323x<interface::I2cInterface<I2cMock>, ic::DS3231> {