File tree Expand file tree Collapse file tree 1 file changed +24
-3
lines changed
Expand file tree Collapse file tree 1 file changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -126,10 +126,31 @@ STATIC mp_obj_t machine_soft_reset(void) {
126126}
127127MP_DEFINE_CONST_FUN_OBJ_0 (machine_soft_reset_obj , machine_soft_reset );
128128
129+ /*
130+ * @param clkid - range 0~127 (e.g 0:SYSCLK 1:HCLK 2:PCLK1 etc)
131+ *
132+ * @return 0 - ok, -1 - no such clock
133+ */
134+ RT_WEAK int mp_port_get_freq (int clkid , int * freq )
135+ {
136+ return -1 ;
137+ }
138+
129139STATIC mp_obj_t machine_freq (void ) {
130- //TODO
131- MP_RTT_NOT_IMPL_PRINT ;
132- return MP_OBJ_SMALL_INT_VALUE (0 );
140+ int i ;
141+ mp_obj_list_t * ret_list = m_new (mp_obj_list_t , 1 );
142+ mp_obj_list_init (ret_list , 0 );
143+ int freq ;
144+
145+ for (i = 0 ; i < 128 ; i ++ )
146+ {
147+ if (mp_port_get_freq (i , & freq ) != 0 )
148+ break ;
149+
150+ mp_obj_list_append (ret_list , mp_obj_new_int (freq ));
151+ }
152+
153+ return MP_OBJ_FROM_PTR (ret_list );
133154}
134155MP_DEFINE_CONST_FUN_OBJ_0 (machine_freq_obj , machine_freq );
135156
You can’t perform that action at this time.
0 commit comments