24
24
* THE SOFTWARE.
25
25
*/
26
26
27
- #include <stdio.h>
28
27
#include <string.h>
29
28
30
29
#include "modmachine.h"
@@ -163,24 +162,26 @@ void machine_deinit(void) {
163
162
// machine.info([dump_alloc_table])
164
163
// Print out lots of information about the board.
165
164
STATIC mp_obj_t machine_info (size_t n_args , const mp_obj_t * args ) {
165
+ const mp_print_t * print = & mp_plat_print ;
166
+
166
167
// get and print unique id; 96 bits
167
168
{
168
169
byte * id = (byte * )MP_HAL_UNIQUE_ID_ADDRESS ;
169
- printf ( "ID=%02x%02x%02x%02x:%02x%02x%02x%02x:%02x%02x%02x%02x\n" , id [0 ], id [1 ], id [2 ], id [3 ], id [4 ], id [5 ], id [6 ], id [7 ], id [8 ], id [9 ], id [10 ], id [11 ]);
170
+ mp_printf ( print , "ID=%02x%02x%02x%02x:%02x%02x%02x%02x:%02x%02x%02x%02x\n" , id [0 ], id [1 ], id [2 ], id [3 ], id [4 ], id [5 ], id [6 ], id [7 ], id [8 ], id [9 ], id [10 ], id [11 ]);
170
171
}
171
172
172
- printf ( "DEVID=0x%04x\nREVID=0x%04x\n" , (unsigned int )HAL_GetDEVID (), (unsigned int )HAL_GetREVID ());
173
+ mp_printf ( print , "DEVID=0x%04x\nREVID=0x%04x\n" , (unsigned int )HAL_GetDEVID (), (unsigned int )HAL_GetREVID ());
173
174
174
175
// get and print clock speeds
175
176
// SYSCLK=168MHz, HCLK=168MHz, PCLK1=42MHz, PCLK2=84MHz
176
177
{
177
178
#if defined(STM32F0 ) || defined(STM32G0 )
178
- printf ( "S=%u\nH=%u\nP1=%u\n" ,
179
+ mp_printf ( print , "S=%u\nH=%u\nP1=%u\n" ,
179
180
(unsigned int )HAL_RCC_GetSysClockFreq (),
180
181
(unsigned int )HAL_RCC_GetHCLKFreq (),
181
182
(unsigned int )HAL_RCC_GetPCLK1Freq ());
182
183
#else
183
- printf ( "S=%u\nH=%u\nP1=%u\nP2=%u\n" ,
184
+ mp_printf ( print , "S=%u\nH=%u\nP1=%u\nP2=%u\n" ,
184
185
(unsigned int )HAL_RCC_GetSysClockFreq (),
185
186
(unsigned int )HAL_RCC_GetHCLKFreq (),
186
187
(unsigned int )HAL_RCC_GetPCLK1Freq (),
@@ -190,35 +191,35 @@ STATIC mp_obj_t machine_info(size_t n_args, const mp_obj_t *args) {
190
191
191
192
// to print info about memory
192
193
{
193
- printf ( "_etext=%p\n" , & _etext );
194
- printf ( "_sidata=%p\n" , & _sidata );
195
- printf ( "_sdata=%p\n" , & _sdata );
196
- printf ( "_edata=%p\n" , & _edata );
197
- printf ( "_sbss=%p\n" , & _sbss );
198
- printf ( "_ebss=%p\n" , & _ebss );
199
- printf ( "_sstack=%p\n" , & _sstack );
200
- printf ( "_estack=%p\n" , & _estack );
201
- printf ( "_ram_start=%p\n" , & _ram_start );
202
- printf ( "_heap_start=%p\n" , & _heap_start );
203
- printf ( "_heap_end=%p\n" , & _heap_end );
204
- printf ( "_ram_end=%p\n" , & _ram_end );
194
+ mp_printf ( print , "_etext=%p\n" , & _etext );
195
+ mp_printf ( print , "_sidata=%p\n" , & _sidata );
196
+ mp_printf ( print , "_sdata=%p\n" , & _sdata );
197
+ mp_printf ( print , "_edata=%p\n" , & _edata );
198
+ mp_printf ( print , "_sbss=%p\n" , & _sbss );
199
+ mp_printf ( print , "_ebss=%p\n" , & _ebss );
200
+ mp_printf ( print , "_sstack=%p\n" , & _sstack );
201
+ mp_printf ( print , "_estack=%p\n" , & _estack );
202
+ mp_printf ( print , "_ram_start=%p\n" , & _ram_start );
203
+ mp_printf ( print , "_heap_start=%p\n" , & _heap_start );
204
+ mp_printf ( print , "_heap_end=%p\n" , & _heap_end );
205
+ mp_printf ( print , "_ram_end=%p\n" , & _ram_end );
205
206
}
206
207
207
208
// qstr info
208
209
{
209
210
size_t n_pool , n_qstr , n_str_data_bytes , n_total_bytes ;
210
211
qstr_pool_info (& n_pool , & n_qstr , & n_str_data_bytes , & n_total_bytes );
211
- printf ( "qstr:\n n_pool=%u\n n_qstr=%u\n n_str_data_bytes=%u\n n_total_bytes=%u\n" , n_pool , n_qstr , n_str_data_bytes , n_total_bytes );
212
+ mp_printf ( print , "qstr:\n n_pool=%u\n n_qstr=%u\n n_str_data_bytes=%u\n n_total_bytes=%u\n" , n_pool , n_qstr , n_str_data_bytes , n_total_bytes );
212
213
}
213
214
214
215
// GC info
215
216
{
216
217
gc_info_t info ;
217
218
gc_info (& info );
218
- printf ( "GC:\n" );
219
- printf ( " %u total\n" , info .total );
220
- printf ( " %u : %u\n" , info .used , info .free );
221
- printf ( " 1=%u 2=%u m=%u\n" , info .num_1block , info .num_2block , info .max_block );
219
+ mp_printf ( print , "GC:\n" );
220
+ mp_printf ( print , " %u total\n" , info .total );
221
+ mp_printf ( print , " %u : %u\n" , info .used , info .free );
222
+ mp_printf ( print , " 1=%u 2=%u m=%u\n" , info .num_1block , info .num_2block , info .max_block );
222
223
}
223
224
224
225
// free space on flash
@@ -230,7 +231,7 @@ STATIC mp_obj_t machine_info(size_t n_args, const mp_obj_t *args) {
230
231
fs_user_mount_t * vfs_fat = MP_OBJ_TO_PTR (vfs -> obj );
231
232
DWORD nclst ;
232
233
f_getfree (& vfs_fat -> fatfs , & nclst );
233
- printf ( "LFS free: %u bytes\n" , (uint )(nclst * vfs_fat -> fatfs .csize * 512 ));
234
+ mp_printf ( print , "LFS free: %u bytes\n" , (uint )(nclst * vfs_fat -> fatfs .csize * 512 ));
234
235
break ;
235
236
}
236
237
}
0 commit comments