diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-12-28 19:00:29 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2019-01-07 19:33:26 -0500 |
commit | 4683036f98b319d1c36853c1a200d63c36b470ff (patch) | |
tree | 340620d721c54de9de57bbb3b514e3fcff8b1599 /src/sam3/main.c | |
parent | b4baabe4081a3c1473e970b776a5d760bf6689e3 (diff) | |
download | kutter-4683036f98b319d1c36853c1a200d63c36b470ff.tar.gz kutter-4683036f98b319d1c36853c1a200d63c36b470ff.tar.xz kutter-4683036f98b319d1c36853c1a200d63c36b470ff.zip |
sam3: Add enable_pclock() helper function
Add a helper function to enable peripheral clocks.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/sam3/main.c')
-rw-r--r-- | src/sam3/main.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/sam3/main.c b/src/sam3/main.c index 3908fddb..68949ce7 100644 --- a/src/sam3/main.c +++ b/src/sam3/main.c @@ -35,6 +35,26 @@ DECL_INIT(watchdog_init); * misc functions ****************************************************************/ +// Check if a peripheral clock has been enabled +int +is_enabled_pclock(uint32_t id) +{ + if (id < 32) + return !!(PMC->PMC_PCSR0 & (1 << id)); + else + return !!(PMC->PMC_PCSR1 & (1 << (id - 32))); +} + +// Enable a peripheral clock +void +enable_pclock(uint32_t id) +{ + if (id < 32) + PMC->PMC_PCER0 = 1 << id; + else + PMC->PMC_PCER1 = 1 << (id - 32); +} + void command_reset(uint32_t *args) { |