Skip to content

Commit

Permalink
lpc1756 added posibility to override the init detection
Browse files Browse the repository at this point in the history
  • Loading branch information
itzandroidtab committed Aug 31, 2024
1 parent 9eb0b7c commit cf48f41
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions targets/core/nxp/lpc175x/rtc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ namespace klib::core::lpc175x::io {
* @param cal_value
* @param cal_direction
*/
template <bool Override = false>
static void init(const uint32_t cal_value = 0, const bool cal_direction = 1) {
// enable the power for the rtc
target::io::power_control::enable<Rtc>();

// check if the rtc is already on (and not in reset)
if (Rtc::port->CCR & 0x1 && !(Rtc::port->CCR & (0x1 << 1))) {
// rtc already on. No need for more configuration
return;
// check if we should always override any configuration
if constexpr (!Override) {
// check if the rtc is already on (and not in reset)
if (Rtc::port->CCR & 0x1 && !(Rtc::port->CCR & (0x1 << 1))) {
// rtc already on. No need for more configuration
return;
}
}

// disable the oscillator fail detect interrupt
Expand Down

0 comments on commit cf48f41

Please sign in to comment.