Skip to content

Commit 90fa492

Browse files
committed
lpc17xx Moved watchdog timer and added support for lpc1788
1 parent 6925edf commit 90fa492

File tree

6 files changed

+39
-6
lines changed

6 files changed

+39
-6
lines changed

targets/chip/lpc1752/io/watchdog.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <cstdint>
55

6-
#include <targets/core/nxp/lpc175x/watchdog.hpp>
6+
#include <targets/core/nxp/lpc17xx/watchdog.hpp>
77

88
namespace klib::lpc1752::io::periph {
99
struct wdt0 {

targets/chip/lpc1754/io/watchdog.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <cstdint>
55

6-
#include <targets/core/nxp/lpc175x/watchdog.hpp>
6+
#include <targets/core/nxp/lpc17xx/watchdog.hpp>
77

88
namespace klib::lpc1754::io::periph {
99
struct wdt0 {

targets/chip/lpc1756/io/watchdog.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <cstdint>
55

6-
#include <targets/core/nxp/lpc175x/watchdog.hpp>
6+
#include <targets/core/nxp/lpc17xx/watchdog.hpp>
77

88
namespace klib::lpc1756::io::periph {
99
struct wdt0 {

targets/chip/lpc1759/io/watchdog.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <cstdint>
55

6-
#include <targets/core/nxp/lpc175x/watchdog.hpp>
6+
#include <targets/core/nxp/lpc17xx/watchdog.hpp>
77

88
namespace klib::lpc1759::io::periph {
99
struct wdt0 {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)