Skip to content

Commit cd78bc8

Browse files
authored
nRF52: Add clock device (#564)
1 parent b4adc72 commit cd78bc8

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

port/nordic/nrf5x/src/hal/drivers.zig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,25 @@ pub const I2C_Device = struct {
109109
};
110110
}
111111
};
112+
113+
///
114+
/// Implementation of a time device
115+
///
116+
pub const ClockDevice = struct {
117+
pub fn clock_device(td: *ClockDevice) Clock_Device {
118+
_ = td;
119+
return Clock_Device{
120+
.ptr = undefined,
121+
.vtable = &vtable,
122+
};
123+
}
124+
const vtable = Clock_Device.VTable{
125+
.get_time_since_boot = get_time_since_boot_fn,
126+
};
127+
128+
fn get_time_since_boot_fn(td: *anyopaque) time.Absolute {
129+
_ = td;
130+
const t = hal.time.get_time_since_boot().to_us();
131+
return @enumFromInt(t);
132+
}
133+
};

port/nordic/nrf5x/src/hal/uart.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub const UART = enum(u1) {
148148
.nrf52840 => regs.PSEL.TXD.write(.{
149149
.PIN = pin.index(),
150150
.PORT = pin.port(),
151-
.CONNECT = @enumFromInt(0), // 0 means connected lol
151+
.CONNECT = .Connected,
152152
}),
153153
}
154154
}
@@ -160,7 +160,7 @@ pub const UART = enum(u1) {
160160
.nrf52840 => regs.PSEL.RXD.write(.{
161161
.PIN = pin.index(),
162162
.PORT = pin.port(),
163-
.CONNECT = @enumFromInt(0), // 0 means connected lol
163+
.CONNECT = .Connected,
164164
}),
165165
}
166166
}

0 commit comments

Comments
 (0)