[−][src]Struct lpc8xx_hal::Peripherals
Provides access to all peripherals
This is the entry point to the HAL API. Before you can do anything else, you
need to get an instance of this struct via Peripherals::take
or
Peripherals::steal
.
The HAL API tracks the state of peripherals at compile-time, to prevent potential bugs before the program can even run. Many parts of this documentation call this "type state". The peripherals available in this struct are set to their initial state (i.e. their state after a system reset). See user manual, section 5.6.14.
Safe Use of the API
Since it should be impossible (outside of unsafe code) to access the peripherals before this struct is initialized, you can rely on the peripheral states being correct, as long as there's no bug in the API, and you're not using unsafe code to do anything that the HAL API can't account for.
If you directly use unsafe code to access peripherals or manipulate this API, this will be really obvious from the code. But please note that if you're using other APIs to access the hardware, such conflicting hardware access might not be obvious, as the other API might use unsafe code under the hood to access the hardware (just like this API does).
If you do access the peripherals in any way not intended by this API, please make sure you know what you're doing. In specific terms, this means you should be fully aware of what your code does, and whether that is a valid use of the hardware.
Fields
GPIO: GPIO<Disabled>
General-purpose I/O (GPIO)
PMU: PMU
Power Management Unit
SWM: SWM
Switch matrix
SYSCON: SYSCON
System configuration
WKT: WKT<Disabled>
Self-wake-up timer (WKT)
ACOMP: ACOMP
Analog comparator
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
ADC0: ADC0
Analog-to-Digital Converter (ADC)
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
CAPT: CAPT
Capacitive Touch (CAPT)
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
CRC: CRC
CRC engine
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
CTIMER0: CTIMER0
Standard counter/timer (CTIMER)
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
DAC0: DAC0
Digital-to-Analog Converter 0 (DAC0)
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
DAC1: DAC1
Digital-to-Analog Converter 1 (DAC1)
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
DMA0: DMA0
DMA controller
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
FLASH_CTRL: FLASH_CTRL
Flash controller
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
I2C0: I2C0
I2C0-bus interface
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
I2C1: I2C1
I2C1-bus interface
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
I2C2: I2C2
I2C2-bus interface
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
I2C3: I2C3
I2C3-bus interface
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
INPUTMUX: INPUTMUX
Input multiplexing
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
IOCON: IOCON
I/O configuration
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
MRT0: MRT0
Multi-Rate Timer (MRT)
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
PINT: PINT
Pin interrupt and pattern match engine
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
SCT0: SCT0
State Configurable Timer (SCT)
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
SPI0: SPI0
SPI0
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
SPI1: SPI1
SPI1
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
USART0: USART0
USART0
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
USART1: USART1
USART1
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
USART2: USART2
USART2
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
USART3: USART3
USART3
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
USART4: USART4
USART4
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
WWDT: WWDT
Windowed Watchdog Timer (WWDT)
A HAL API for this peripheral has not been implemented yet. In the meantime, this field provides you with the raw register mappings, which allow you full, unprotected access to the peripheral.
CPUID: CPUID
CPUID
This is a core peripherals that's available on all ARM Cortex-M0+ cores.
DCB: DCB
Debug Control Block (DCB)
This is a core peripherals that's available on all ARM Cortex-M0+ cores.
DWT: DWT
Data Watchpoint and Trace unit (DWT)
This is a core peripherals that's available on all ARM Cortex-M0+ cores.
MPU: MPU
Memory Protection Unit (MPU)
This is a core peripherals that's available on all ARM Cortex-M0+ cores.
NVIC: NVIC
Nested Vector Interrupt Controller (NVIC)
This is a core peripherals that's available on all ARM Cortex-M0+ cores.
SCB: SCB
System Control Block (SCB)
This is a core peripherals that's available on all ARM Cortex-M0+ cores.
SYST: SYST
SysTick: System Timer
This is a core peripherals that's available on all ARM Cortex-M0+ cores.
Methods
impl Peripherals
[src]
pub fn take() -> Option<Self>
[src]
Take the peripherals safely
This method can only be called one time to access the peripherals. It
will return Some(Peripherals)
when called for the first time, then
None
on any subsequent calls.
Applications should call this method once, at the beginning of their main method, to get access to the full API. Any other parts of the program should just expect to be passed whatever parts of the HAL API they need.
Calling this method from a library is considered an anti-pattern. Libraries should just require whatever they need to be passed as arguments and leave the initialization to the application that calls them.
For an alternative way to gain access to the hardware, please take a
look at Peripherals::steal
.
Example
use lpc82x_hal::Peripherals; // This code should be at the beginning of your program. As long as this // is the only place that calls `take`, the following should never // panic. let p = Peripherals::take().unwrap();
pub unsafe fn steal() -> Self
[src]
Steal the peripherals
This function returns an instance of Peripherals
, whether or not such
an instance exists somewhere else. This is highly unsafe, as it can lead
to conflicting access of the hardware, mismatch between actual hardware
state and peripheral state as tracked by this API at compile-time, and
in general a full nullification of all safety guarantees that this API
would normally make.
If at all possible, you should always prefer Peripherals::take
to this
method. The only legitimate use of this API is code that can't access
Peripherals
the usual way, like a panic handler, or maybe temporary
debug code in an interrupt handler.
Safety
This method returns an instance of Peripherals
that might conflict
with either other instances of Peripherals
that exist in the program,
or other means of accessing the hardware. This is only sure, if you make
sure of the following:
- No other code can access the hardware at the same time.
- You don't change the hardware state in any way that could invalidate
the type state of other
Peripherals
instances. - The type state in your
Peripherals
instance matches the actual state of the hardware.
Items 1. and 2. are really tricky, so it is recommended to avoid any situations where they apply, and restrict the use of this method to situations where the program has effectively ended and the hardware will be reset right after (like a panic handler).
Item 3. applies to all uses of this method, and is generally very tricky to get right. The best way to achieve that is probably to force the API into a type state that allows you to execute operations that are known to put the hardware in a safe state. Like forcing the type state for a peripheral API to the "disabled" state, then enabling it, to make sure it is enabled, regardless of wheter it was enabled before.
Since there are no means within this API to forcibly change type state,
you will need to resort to something like core::mem::transmute
.
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
type Output = T
Should always be Self