1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! Hardware abstraction layer for the `GD32E23x` series (Cortex-M23), built on top
//! of the [`gd32e2`](https://crates.io/crates/gd32e2) peripheral access crate.
//! Only the GD32E230 is implemented so far; the crate is named for the family it
//! is meant to grow into.
//!
//! The API leans on the type system: a method that makes no sense for the
//! hardware fails to compile.
//!
//! # Chip variants
//!
//! One feature names the part being built for, and exactly one must be enabled.
//!
//! A feature is the part number with an `x` in each field the code cannot see, so
//! `gd32e230g8xx` is every G8 part: the letter is the bonded pin count (F 20, E 24,
//! G 28, K 32, C 48), the digit the flash code (4 = 16K flash and 4K SRAM, 6 = 32K
//! and 6K, 8 = 64K and 8K), and the last `x` the temperature grade. Only the 32-pin
//! parts spell their package out — a QFN32 (`gd32e230k8ux`) carries VSS on its
//! thermal pad and gives the two freed pins to `PB2` and `PB8`, an LQFP32
//! (`gd32e230k8tx`) does not.
//!
//! # Getting started
//!
//! Clocks come first: freezing the tree is what produces the [`Rcu`](rcu::Rcu)
//! every other module takes, and it enables each peripheral's clock as that
//! peripheral is constructed.
//!
//! ```ignore
//! let dp = pac::Peripherals::take().unwrap();
//! let mut fmc = dp.fmc.constrain();
//! let config = ClockConfig::default().sysclk(SysClk::Pll(PllFreq::Mhz48));
//! let mut rcu = dp.rcu.constrain().freeze(&mut fmc, config);
//! let parts = dp.gpioa.split(&mut rcu);
//! let mut led = parts.pa5.into_output();
//! led.set_high().unwrap();
//! ```
// --- Warnings ---
// --- Cargo warnings ---
// --- Pedantic warnings ---
// --- Unsafe warnings ---
// Both halves of the choice are checked in build.rs, which counts the enabled
// features and knows their names. This guards the source against being compiled
// with no build script at all — the flags below are what every gate reads.
compile_error!;
/// Re-export of the peripheral access crate this HAL is built on. Referring to
/// it as `pac` keeps the door open to other parts of the family behind a single
/// alias, instead of naming a specific chip module throughout.
pub use gd32e230 as pac;