Skip to main content

consortium_hal/
lib.rs

1#![no_std]
2// Copyright 2026 Ethan Wu
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//     http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16// SPDX-License-Identifier: Apache-2.0
17
18//! Shared HAL traits for Consortium chip support crates.
19
20pub mod nvic;
21
22/// Marker for a concrete peripheral instance.
23pub trait Peripheral {
24    /// Human-readable peripheral name used by generated chip metadata.
25    const NAME: &'static str;
26}
27
28/// Minimal clock/reset hooks for chip-specific peripheral drivers.
29pub trait ClockControl {
30    /// Enable the peripheral clock.
31    fn enable(&self);
32
33    /// Reset the peripheral when the chip supports a local reset.
34    fn reset(&self);
35}
36
37/// Interrupt source that can be bound by board startup code.
38pub trait InterruptSource {
39    /// Human-readable interrupt name.
40    const INTERRUPT: &'static str;
41}
42
43/// Minimal monotonic timer abstraction shared by chip HAL time drivers.
44pub trait MonotonicTimer {
45    /// Return monotonically increasing ticks.
46    fn now(&self) -> u64;
47
48    /// Program the next hardware alarm.
49    fn set_alarm(&self, at: u64) -> bool;
50}