[][src]Trait e310x_hal::pmu::PMUExt

pub trait PMUExt {
    fn load_default_programs(&self);
fn sleep(self, sleep_time: u32);
fn wakeup_cause(&self) -> Result<WakeupCause, CauseError>;
unsafe fn store_backup<UD>(&self, user_data: &UD) -> Result<(), BackupError>;
unsafe fn restore_backup<UD>(
        &self,
        user_data: &mut UD
    ) -> Result<(), BackupError>;
fn clear_backup(&self); }

Required methods

fn load_default_programs(&self)

Resets SLEEP and WAKE programs on the PMU to defaults

fn sleep(self, sleep_time: u32)

Puts device to sleep for N seconds, allowing wake-up button to wake it up as well

Arguments

sleep_time - the amount of time to sleep for in seconds

Notes

  • enables RTC to be always on
  • sets RTC scale to 1/s

fn wakeup_cause(&self) -> Result<WakeupCause, CauseError>

Returns an enumified version of the Wakeup and Reset causes from the pmucause register

Returns

  • Result<WakeupCause, CauseError> - the cause enum is returned on success

Errors

  • CauseError::InvalidCause - returned if an unknown wakeup or reset cause is encountered

unsafe fn store_backup<UD>(&self, user_data: &UD) -> Result<(), BackupError>

Stores user data UD to backup registers.

WARNING

user_data value must not contain un-serializable types such as pointers or references.

user_data size must be divisible by 4 bytes.

The data is only guaranteed to be consistent when program is compiled with the same version of the compiler on store/restore.

#[repr(align(4))] can be used to enforce a minimum alignment of 4 bytes for user_data

Arguments

  • user_data - reference to the user data to store. user_data size must by divisible by 4 bytes

Returns

  • Result<(), BackupError> - () is returned on success

Errors

  • BackupError::DataTooLarge - returned if user_data cannot fit into backup registers
  • BackupError::DataSizeInvalid - returned if user_data size is not divisible by 4 bytes

unsafe fn restore_backup<UD>(
    &self,
    user_data: &mut UD
) -> Result<(), BackupError>

Restores user data UD from backup registers.

WARNING

user_data value must not contain un-serializable types such as pointers or references.

user_data size must be divisible by 4 bytes.

The data is only guaranteed to be consistent when program is compiled with the same version of the compiler on store/restore.

#[repr(align(4))] can be used to enforce a minimum alignment of 4 bytes for user_data

Arguments

  • user_data - the user data to restore to. user_data size must by divisible by 4 bytes

Returns

  • Result<(), BackupError> - () is returned on success

Errors

  • BackupError::DataTooLarge - returned if user_data cannot fit into backup registers
  • BackupError::DataSizeInvalid - returned if user_data size is not divisible by 4 bytes ///

fn clear_backup(&self)

Clears all backup registers by setting each to zero

Loading content...

Implementations on Foreign Types

impl PMUExt for PMU[src]

Loading content...

Implementors

Loading content...