#include "z80-if.h"
#include "con-utils.h"
-//#include "env.h"
+#include "env.h"
#include "eval_arg.h"
#include "timer.h"
#include "getopt-min.h"
-//#include "debug.h"
+#include "debug.h"
/* hack to get Z180 loadfile into flash memory */
#define const const FLASH
uint32_t x_cnt = x_freq;
x_freq *= cycles;
- x_freq = ((uint64_t) x_freq * F_CPU + (ref_cnt / 2))/ ref_cnt;
+ x_freq = ((uint64_t) x_freq * getenv_ulong(PSTR(ENV_FMON), 10, F_CPU) + (ref_cnt / 2))/ ref_cnt;
debug("ref_start: %6u, ref_stop: %6u, ref_ovfl: %4u, ref_cnt: %9lu\n"
" TCNT3: %6u, x_cnt: %6lu, cycles: %3u, xfreq: %9lu\n",
uint32_t pulsewidth = 10; /* ms */
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("t:"))) != -1) {
switch (opt) {
char ch;
#if 0
- /* reset getopt() */
- optind = 0;
int opt;
while ((opt = getopt(argc, argv, PSTR("t:"))) != -1) {
switch (opt) {
}
static const FLASH uint8_t loop_code[] = {
- /* 0000 */ 0x01,0x36,0x00, /* ld bc,00*256+RCR */
+ /* 0000 */ 0x01,0x36,0x00, /* ld bc,00*256+RCR ; no refresh cycles */
/* 0003 */ 0xAF, /* xor a */
/* 0004 */ 0xED,0x79, /* out (c),a */
- /* 0006 */ 0xD3,0x40, /* out (040H),a */
+ /* 0006 */ 0xD3,0x40, /* out (040H),a ; ready */
+ /* */ /* */
/* */ /* ;Z80 Z180(0W) Z180(MaxW) */
/* 0008 */ /* loop: ;-------------------------- */
- /* 0008 */ 0xDB,0x50 /* in a,(050h) ;11 10 +3*3 19 */
+ /* 0008 */ 0xDB,0x50, /* in a,(050h) ;11 10 +3*3 19 */
/* 000A */ 0xC3,0x08,0x00 /* jp loop ;10 9 +3*3 18 */
/* ;-------------------------- */
/* ;21 19 37 */
-}
+};
command_ret_t do_cpu_freq(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc, char * const argv[])
{
uint8_t mem_save[ARRAY_SIZE(loop_code)];
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("swnuc:t:"))) != -1) {
switch (opt) {
int32_t cpu_freq;
if (!err)
- cpu_freq = z80_measure_phi(lcycles, false, timeout);
+ cpu_freq = z80_measure_phi(lcycles, timeout);
z80_bus_cmd(Reset);
if (options & O_UNLOAD_LOOP) {