summaryrefslogtreecommitdiff
path: root/apps/debug_menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/debug_menu.c')
-rw-r--r--apps/debug_menu.c43
1 files changed, 10 insertions, 33 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 1c633200c2..5f1b5af241 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1268,32 +1268,19 @@ static bool view_runtime(void)
1268} 1268}
1269 1269
1270#ifdef HAVE_MMC 1270#ifdef HAVE_MMC
1271/* value is 10 * real value */
1272static unsigned char prep_value_unit(unsigned long *value,
1273 const unsigned char *units)
1274{
1275 int unit_no = 0;
1276
1277 while (*value >= 10000)
1278 {
1279 *value /= 1000;
1280 unit_no++;
1281 }
1282 return units[unit_no];
1283}
1284
1285bool dbg_mmc_info(void) 1271bool dbg_mmc_info(void)
1286{ 1272{
1287 bool done = false; 1273 bool done = false;
1288 int currval = 0; 1274 int currval = 0;
1289 unsigned long value; 1275 unsigned long value;
1290 tCardInfo *card; 1276 tCardInfo *card;
1291 unsigned char pbuf[32]; 1277 unsigned char pbuf[32], pbuf2[32];
1292 unsigned char card_name[7]; 1278 unsigned char card_name[7];
1293 unsigned char unit; 1279
1294
1295 static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 }; 1280 static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1296 static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 }; 1281 static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1282 static const unsigned char *kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" };
1283 static const unsigned char *nsec_units[] = { "ns", "µs", "ms" };
1297 1284
1298 card_name[6] = '\0'; 1285 card_name[6] = '\0';
1299 1286
@@ -1337,24 +1324,14 @@ bool dbg_mmc_info(void)
1337 } 1324 }
1338 else /* Technical details */ 1325 else /* Technical details */
1339 { 1326 {
1340 value = card->speed / 100; 1327 output_dyn_value(pbuf2, sizeof pbuf2, card->speed / 1000,
1341 unit = prep_value_unit(&value, "kMG"); 1328 kbit_units, false);
1342 if (value < 100) 1329 snprintf(pbuf, sizeof pbuf, "Speed: %s", pbuf2);
1343 snprintf(pbuf, sizeof(pbuf), "Speed: %d.%01d %cBit/s",
1344 (int)(value / 10), (int)(value % 10), unit);
1345 else
1346 snprintf(pbuf, sizeof(pbuf), "Speed: %d %cBit/s",
1347 (int)(value / 10), unit);
1348 lcd_puts(0, 1, pbuf); 1330 lcd_puts(0, 1, pbuf);
1349 1331
1350 value = card->tsac; 1332 output_dyn_value(pbuf2, sizeof pbuf2, card->tsac,
1351 unit = prep_value_unit(&value, "nµm"); 1333 nsec_units, false);
1352 if (value < 100) 1334 snprintf(pbuf, sizeof pbuf, "Tsac: %s", pbuf2);
1353 snprintf(pbuf, sizeof(pbuf), "Tsac: %d.%01d %cs",
1354 (int)(value / 10), (int)(value % 10), unit);
1355 else
1356 snprintf(pbuf, sizeof(pbuf), "Tsac: %d %cs",
1357 (int)(value / 10), unit);
1358 lcd_puts(0, 2, pbuf); 1335 lcd_puts(0, 2, pbuf);
1359 1336
1360 snprintf(pbuf, sizeof(pbuf), "Nsac: %d clk", card->nsac); 1337 snprintf(pbuf, sizeof(pbuf), "Nsac: %d clk", card->nsac);