1.1 --- a/pkg/landfall-examples/hw_info/hw_info.c Sat May 04 01:30:06 2024 +0200
1.2 +++ b/pkg/landfall-examples/hw_info/hw_info.c Sat May 04 01:31:54 2024 +0200
1.3 @@ -356,7 +356,7 @@
1.4 const char *source_id = clock_id(cpm_get_source_clock(cpm, clocks[i].clock));
1.5 int num_parameters = cpm_get_parameters(cpm, clocks[i].clock, parameters);
1.6
1.7 - for (int p = 0, pos = 0; p < num_parameters; p++)
1.8 + for (int p = 0, pos = 0; (p < num_parameters) && (p < 4); p++)
1.9 {
1.10 int result = sprintf(parameter_str + pos, "%-7d ", parameters[p]);
1.11 if (result < 0)
1.12 @@ -1326,6 +1326,13 @@
1.13
1.14 /* RTC operations. */
1.15
1.16 +static void rtc_clock_frequency(void *rtc, void *cpm)
1.17 +{
1.18 + enum Clock_identifiers clock = rtc_get_clock(rtc);
1.19 +
1.20 + printf("RTC frequency: %lld\n", cpm_get_frequency(cpm, clock));
1.21 +}
1.22 +
1.23 static void rtc_reset(void *rtc, void *cpm)
1.24 {
1.25 unsigned int seconds;
1.26 @@ -1333,10 +1340,9 @@
1.27 if (!read_number("Seconds", &seconds))
1.28 return;
1.29
1.30 - /* NOTE: Assuming EXCLK/512 as RTC source. */
1.31 -
1.32 + enum Clock_identifiers clock = rtc_get_clock(rtc);
1.33 uint32_t rtc_seconds = rtc_get_seconds(rtc);
1.34 - uint32_t value = seconds * cpm_get_frequency(cpm, Clock_external) / 512;
1.35 + uint32_t value = seconds * cpm_get_frequency(cpm, clock);
1.36
1.37 rtc_alarm_disable(rtc);
1.38 rtc_set_alarm_seconds(rtc, rtc_seconds + value);
1.39 @@ -1871,7 +1877,9 @@
1.40
1.41 if ((token = read_token(NULL)) != NULL)
1.42 {
1.43 - if (!strcmp(token, "d") || !strcmp(token, "disable"))
1.44 + if (!strcmp(token, "c") || !strcmp(token, "clock-frequency"))
1.45 + rtc_clock_frequency(rtc, cpm);
1.46 + else if (!strcmp(token, "d") || !strcmp(token, "disable"))
1.47 rtc_disable(rtc);
1.48 else if (!strcmp(token, "e") || !strcmp(token, "enable"))
1.49 rtc_enable(rtc);
1.50 @@ -1888,10 +1896,10 @@
1.51 else if (!strcmp(token, "sa") || !strcmp(token, "set-alarm"))
1.52 _rtc_set_seconds(rtc, 1);
1.53 else
1.54 - printf("rtc disable | enable | get | get-alarm | power-down | reset | set | set-alarm\n");
1.55 + printf("rtc clock-frequency | disable | enable | get | get-alarm | power-down | reset | set | set-alarm\n");
1.56 }
1.57 else
1.58 - printf("rtc disable | enable | get | get-alarm | power-down | reset | set | set-alarm\n");
1.59 + printf("rtc clock-frequency | disable | enable | get | get-alarm | power-down | reset | set | set-alarm\n");
1.60 }
1.61
1.62 static void handle_spi(void *spi, void *gpio[])