File tree Expand file tree Collapse file tree 2 files changed +21
-9
lines changed
examples/nordic/nrf5x/src
port/nordic/nrf5x/src/hal Expand file tree Collapse file tree 2 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const nrf = microzig.hal;
55const time = nrf .time ;
66
77const rtc_overflow_interrupt = nrf .time .rtc_overflow_interrupt ;
8+ const uart = nrf .uart .num (0 );
89
910pub const microzig_options = microzig.Options {
1011 .log_level = .debug ,
@@ -15,20 +16,26 @@ pub const microzig_options = microzig.Options{
1516pub fn main () ! void {
1617 board .init ();
1718
19+ uart .apply (.{
20+ .tx_pin = board .uart_tx ,
21+ .rx_pin = board .uart_rx ,
22+ });
23+
24+ nrf .uart .init_logger (uart );
25+
1826 while (true ) {
1927 board .led1 .toggle ();
20- // std.log.info("Now: {}", .{time.get_time_since_boot()});
21- std .log .info ("Counter: {}" , .{microzig .chip .peripherals .RTC0 .COUNTER });
22- // time.sleep_ms(500);
28+ std .log .info ("Now: {}" , .{time .get_time_since_boot ()});
29+ time .sleep_ms (500 );
2330
2431 board .led1 .toggle ();
2532 board .led2 .toggle ();
26- // std.log.info("Now: {}", .{time.get_time_since_boot()});
27- // time.sleep_ms(500);
33+ std .log .info ("Now: {}" , .{time .get_time_since_boot ()});
34+ time .sleep_ms (500 );
2835
2936 board .led2 .toggle ();
3037 board .led3 .toggle ();
31- // std.log.info("Now: {}", .{time.get_time_since_boot()});
32- // time.sleep_ms(500);
38+ std .log .info ("Now: {}" , .{time .get_time_since_boot ()});
39+ time .sleep_ms (500 );
3340 }
3441}
Original file line number Diff line number Diff line change @@ -36,14 +36,19 @@ pub fn init() void {
3636 // 'period' on two different events:
3737 // First, when it hits the halfway point, and again on overflow.
3838
39+ // TODO: Put this in clocks hal
40+ // Set clock source
41+ microzig .chip .peripherals .CLOCK .LFCLKSRC .modify (.{ .SRC = .RC });
42+ // Start LFCLK
43+ microzig .chip .peripherals .CLOCK .TASKS_LFCLKSTART .write_raw (1 );
44+
3945 // Enable interrupt firing on compare AND on overflow
4046 rtc .INTENSET .modify (.{
4147 .COMPARE3 = .Enabled ,
4248 .OVRFLW = .Enabled ,
4349 });
4450 // Set the comparator to trigger on overflow of bottom 23 bits
45- rtc .CC [COMPARE_INDEX ].write (.{ .COMPARE = 0x8000 });
46- // rtc.CC[COMPARE_INDEX].write(.{ .COMPARE = 0x800000 });
51+ rtc .CC [COMPARE_INDEX ].write (.{ .COMPARE = 0x800000 });
4752
4853 // Clear counter, then start timer
4954 switch (version ) {
You can’t perform that action at this time.
0 commit comments