File tree Expand file tree Collapse file tree 6 files changed +39
-6
lines changed
Expand file tree Collapse file tree 6 files changed +39
-6
lines changed Original file line number Diff line number Diff line change 33
44#include < cstdint>
55
6- #include < targets/core/nxp/lpc175x /watchdog.hpp>
6+ #include < targets/core/nxp/lpc17xx /watchdog.hpp>
77
88namespace klib ::lpc1752::io::periph {
99 struct wdt0 {
Original file line number Diff line number Diff line change 33
44#include < cstdint>
55
6- #include < targets/core/nxp/lpc175x /watchdog.hpp>
6+ #include < targets/core/nxp/lpc17xx /watchdog.hpp>
77
88namespace klib ::lpc1754::io::periph {
99 struct wdt0 {
Original file line number Diff line number Diff line change 33
44#include < cstdint>
55
6- #include < targets/core/nxp/lpc175x /watchdog.hpp>
6+ #include < targets/core/nxp/lpc17xx /watchdog.hpp>
77
88namespace klib ::lpc1756::io::periph {
99 struct wdt0 {
Original file line number Diff line number Diff line change 33
44#include < cstdint>
55
6- #include < targets/core/nxp/lpc175x /watchdog.hpp>
6+ #include < targets/core/nxp/lpc17xx /watchdog.hpp>
77
88namespace klib ::lpc1759::io::periph {
99 struct wdt0 {
Original file line number Diff line number Diff line change 1+ #ifndef KLIB_LPC1788_WATCHDOG_HPP
2+ #define KLIB_LPC1788_WATCHDOG_HPP
3+
4+ #include < cstdint>
5+
6+ #include < targets/core/nxp/lpc17xx/watchdog.hpp>
7+
8+ namespace klib ::lpc1788::io::periph {
9+ struct wdt0 {
10+ // peripheral id (e.g wdt0, wdt1)
11+ constexpr static uint32_t id = 0 ;
12+
13+ // peripheral interrupt position
14+ constexpr static uint32_t interrupt_id = 16 ;
15+
16+ // port to the wdt hardware
17+ static inline WWDT_Type *const port = WWDT;
18+ };
19+ }
20+
21+ namespace klib ::lpc1788::io {
22+ template <typename Wdt>
23+ using watchdog = core::lpc175x::io::watchdog<Wdt>;
24+ }
25+
26+ #endif
Original file line number Diff line number Diff line change @@ -51,8 +51,15 @@ namespace klib::core::lpc175x::io {
5151 // Set the period
5252 Wdt::port->TC = ResetPeriod;
5353
54- // set the clocksource
55- Wdt::port->CLKSEL = ClkSource & 0x3 ;
54+ // check if we have a clock selection (lpc1788 does not have this)
55+ constexpr bool has_clocksel = requires () {
56+ (void )Wdt::port->CLKSEL ;
57+ };
58+
59+ if constexpr (has_clocksel) {
60+ // set the clocksource
61+ Wdt::port->CLKSEL = ClkSource & 0x3 ;
62+ }
5663
5764 // enable the watchdog timer
5865 Wdt::port->MOD = (Reset << 1 ) | 0x1 ;
You can’t perform that action at this time.
0 commit comments