Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HAL: Add PMC, EFC configuration APIs #16

Closed
wants to merge 45 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
4addd5d
manifest: increase internal feature flag granularity
tmplt Apr 22, 2022
c552e47
add pmc, efc modules from @jamesmunns's work
jamesmunns Apr 22, 2022
1c8fcd2
move feature checking to a build.rs instead
tmplt Apr 25, 2022
d7e0f57
efc: find FWS via TryFrom impls
tmplt Apr 25, 2022
7c5d8b6
hal: apply fmt
tmplt Apr 25, 2022
ecb51b5
features: separate device-selected master feature from MCU info
tmplt Apr 25, 2022
d77f43e
Add Voltage Level Checks To build.rs
martinmortsell Apr 26, 2022
83de611
Fix Return Types
martinmortsell Apr 26, 2022
3f1f25f
Add get_ Methods For All The Clocks (Except SLCK)
martinmortsell Apr 26, 2022
762e919
efc: set VDDIO level via ctor instead of feature
tmplt Apr 27, 2022
be19501
build: ensure a chip feature is enabled
tmplt Apr 27, 2022
e42837e
pmc: Add Methods For Configuring Plla And Mck
martinmortsell Apr 27, 2022
5d2dd11
Merge branch 'feat/pmc' of https://github.com/GrepitAB/atsams70-rust …
martinmortsell Apr 27, 2022
d8edfe1
pmc: Add Non-functional External Oscillator Support
martinmortsell Apr 27, 2022
daa8a2c
pmc: Fix Main Clock Selection
martinmortsell May 3, 2022
9faca53
pmc: Add PCK Configuration
martinmortsell May 5, 2022
14660e7
Update Documentation
martinmortsell May 6, 2022
4ce66d6
pmc: Change Clock Source From Enum To Trait
martinmortsell May 9, 2022
745c86a
Add get_slck() Method
martinmortsell May 13, 2022
3d8af21
pmc: apply formatting
tmplt May 24, 2022
41c83aa
boards/atsame70_xpro: init example skeleton
tmplt May 24, 2022
6a614a8
boards/atsame70_xpro: doc how to erase fauly firmware
tmplt May 24, 2022
465f7d7
pmc: improve get_mainck
tmplt May 24, 2022
c08d50f
hal/pmc: refer to PMC as pmc, instead of periph
tmplt May 24, 2022
672c168
hal/pmc: add main crystal osc in normal mode back
tmplt May 25, 2022
d213282
hal/pmc: get_pllack: deconstruct PllaConfig
tmplt May 25, 2022
fef7e49
hal/pmc: refactor get_hclk
tmplt May 25, 2022
0b5694b
hal/pmc: record clock freq for MAINCK, PLLACK, and HCLK
tmplt May 25, 2022
c47096b
hal/pmc: get_hclk: set EFC wait states before switching clocks
tmplt May 25, 2022
451e3c1
hal/pmc: correctly configure UPLLCK and record its freq
tmplt May 25, 2022
22c9964
hal/pmc: implement get_upllckdiv
tmplt May 30, 2022
e035fae
hal/pmc: use Hertz instead of Megahertz when logical
tmplt May 30, 2022
2d4389c
hal/pmc: record SLCK freq
tmplt May 30, 2022
5adcf9f
hal/pmc: remove unnecessary Results
tmplt May 30, 2022
dbe39b1
hal/pmc: handle unused_variables/dead_code warnings
tmplt May 30, 2022
b88ffd6
atsame70_xpro: apply example clock hierarchy configuration
tmplt May 30, 2022
27f5bc0
hal/pmc: improve struct/enum docs
tmplt May 30, 2022
0e6a9c5
hal/pmc: remove unused enum
tmplt May 30, 2022
dd1a9dc
hal/pmc: get_slck: remove impl details from docs
tmplt May 30, 2022
009d478
hal/pmc: improve top-level docs
tmplt May 30, 2022
f74507d
atsame70_xpro: expose UPLLCKDIV on PCK2, @ 2.4MHz
tmplt May 30, 2022
82a87de
hal/pmc: globalize magic values
tmplt May 31, 2022
828299f
hal/pmc: apply formatting
tmplt May 31, 2022
b89177d
hal/pmc: refactor SCLK configuration to match MAINCK
tmplt May 31, 2022
d249979
hal/pmc: remove outdated comment
tmplt May 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pmc: Add PCK Configuration
  • Loading branch information
martinmortsell committed May 5, 2022
commit 9faca53d061b51c5f4b3067b4830e997c53b7444
39 changes: 39 additions & 0 deletions hal/src/pmc.rs
Original file line number Diff line number Diff line change
@@ -102,6 +102,33 @@ pub enum MasterClockSource {
PllaClock,
}


pub struct Pck {
id: PckId,

}


#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum PckId {
Pck0,
Pck1,
Pck2,
Pck3,
Pck4,
Pck5,
Pck6,
Pck7,
}

pub enum PckSource {
Sclk,
Mainck,
Pllack,
UpllCk,
Mck,
}

pub struct ClockSettings {
// "Main Clock" is abbreviated "MAINCK"
/// Main Clock Oscillator Source
@@ -374,6 +401,18 @@ impl Pmc {

}

pub fn get_pck(&mut self, source: PckSource, pres: u8, id: PckId) -> Result<Pck,PmcError> {

self.periph.pmc_pck[id as usize].write(|w| unsafe {
w.pres().bits(pres);
w.css().bits(source as u8)
});
self.periph.pmc_scer.write( |w|unsafe{ w.bits(1<<(id as u8+8))});
while (self.periph.pmc_scsr.read().bits() & (1<< (id as u8+8))) == 0 {}
Ok(Pck {id})

}



pub fn settings(&self) -> Option<&ClockSettings> {