@@ -45,18 +45,43 @@ int main(void)
45
45
int res ;
46
46
int64_t req_start_uptime ;
47
47
int64_t req_stop_uptime ;
48
+ struct nrf_clock_spec res_spec ;
49
+ const struct nrf_clock_spec req_spec = {
50
+ .frequency = CONFIG_SAMPLE_CLOCK_FREQUENCY_HZ ,
51
+ .accuracy = CONFIG_SAMPLE_CLOCK_ACCURACY_PPM ,
52
+ .precision = CONFIG_SAMPLE_CLOCK_PRECISION ,
53
+ };
54
+ uint32_t startup_time_us ;
48
55
49
56
printk ("\n" );
50
57
printk ("clock name: %s\n" , SAMPLE_CLOCK_NAME );
51
58
printk ("minimum frequency request: %uHz\n" , CONFIG_SAMPLE_CLOCK_FREQUENCY_HZ );
52
59
printk ("minimum accuracy request: %uPPM\n" , CONFIG_SAMPLE_CLOCK_ACCURACY_PPM );
53
60
printk ("minimum precision request: %u\n" , CONFIG_SAMPLE_CLOCK_PRECISION );
54
61
55
- const struct nrf_clock_spec spec = {
56
- .frequency = CONFIG_SAMPLE_CLOCK_FREQUENCY_HZ ,
57
- .accuracy = CONFIG_SAMPLE_CLOCK_ACCURACY_PPM ,
58
- .precision = CONFIG_SAMPLE_CLOCK_PRECISION ,
59
- };
62
+ printk ("\n" );
63
+ ret = nrf_clock_control_resolve (sample_clock_dev , & req_spec , & res_spec );
64
+ if (ret == 0 ) {
65
+ printk ("resolved frequency request: %uHz\n" , res_spec .frequency );
66
+ printk ("resolved accuracy request: %uPPM\n" , res_spec .accuracy );
67
+ printk ("resolved precision request: %u\n" , res_spec .precision );
68
+ } else if (ret == - ENOSYS ) {
69
+ printk ("resolve not supported\n" );
70
+ } else {
71
+ printk ("minimum clock specs could not be resolved\n" );
72
+ return 0 ;
73
+ }
74
+
75
+ printk ("\n" );
76
+ ret = nrf_clock_control_get_startup_time (sample_clock_dev , & req_spec , & startup_time_us );
77
+ if (ret == 0 ) {
78
+ printk ("startup time for requested spec: %uus\n" , startup_time_us );
79
+ } else if (ret == - ENOSYS ) {
80
+ printk ("get startup time not supported\n" );
81
+ } else {
82
+ printk ("failed to get startup time\n" );
83
+ return 0 ;
84
+ }
60
85
61
86
sys_notify_init_callback (& cli .notify , sample_notify_cb );
62
87
@@ -65,7 +90,7 @@ int main(void)
65
90
printk ("\n" );
66
91
printk ("requesting minimum clock specs\n" );
67
92
req_start_uptime = k_uptime_get ();
68
- ret = nrf_clock_control_request (sample_clock_dev , & spec , & cli );
93
+ ret = nrf_clock_control_request (sample_clock_dev , & req_spec , & cli );
69
94
if (ret < 0 ) {
70
95
printk ("minimum clock specs could not be met\n" );
71
96
return 0 ;
@@ -95,7 +120,7 @@ int main(void)
95
120
96
121
printk ("\n" );
97
122
printk ("releasing requested clock specs\n" );
98
- ret = nrf_clock_control_release (sample_clock_dev , & spec );
123
+ ret = nrf_clock_control_release (sample_clock_dev , & req_spec );
99
124
if (ret < 0 ) {
100
125
printk ("failed to release requested clock specs\n" );
101
126
return 0 ;
0 commit comments