X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/blobdiff_plain/f4d5b4febbffab80cb06bd18564d4c326756fad7..64045ba0916623ab9e7c2f1eed837a2aae081e63:/stm32/z180-stamp-stm32.c diff --git a/stm32/z180-stamp-stm32.c b/stm32/z180-stamp-stm32.c index 284fc8f..96d724c 100644 --- a/stm32/z180-stamp-stm32.c +++ b/stm32/z180-stamp-stm32.c @@ -1,7 +1,6 @@ /* */ -#include #include #include @@ -11,6 +10,8 @@ #include #include +#include + #define ODR 0x0c #define IDR 0x08 @@ -319,10 +320,10 @@ static void key_timerproc() { void sys_tick_handler(void) { - static int tick_10ms = 0; - static int count_ms = 0; + static int_fast8_t tick_10ms = 0; + static int_fast16_t count_ms = 0; - int i; + int_fast8_t i; ++tick_10ms; if (tick_10ms == 10) @@ -389,12 +390,12 @@ void tim3_set(int mode) /*--------------------------------------------------------------------------*/ -static uint32_t z80_sram_cmp(uint32_t addr, int length, uint8_t wval, int inc) +static uint32_t z80_sram_cmp(uint32_t addr, uint32_t length, uint8_t wval, int inc) { uint8_t rval; - int errors = 0; + int_fast8_t errors = 0; - DBG_P(1, "SRAM: Check %#.5x byte... ", length); + DBG_P(1, "SRAM: Check 0x%.5lX byte... ", length); while (length--) { if ((rval = z80_read(addr)) != wval) { if (errors == 0) { @@ -462,6 +463,8 @@ const char * const qbcat = "Zhe quick brown fox jumps over the lazy cat!"; #endif +/*--------------------------------------------------------------------------*/ + uint8_t z80_get_byte(uint32_t adr) { uint8_t data; @@ -508,14 +511,16 @@ struct msg_item { void (*func)(uint8_t, int, uint8_t *); }; +static uint32_t msg_to_addr(uint8_t *msg) { - uint32_t addr = msg[0] + (msg[1] << 8) + (msg[2] << 16); + uint32_t addr = msg[0] | (msg[1] << 8) | ((uint32_t)msg[2] << 16); return addr; } +static void do_msg_ini_msgfifo(uint8_t subf, int len, uint8_t * msg) { (void)subf; (void)len; @@ -524,6 +529,7 @@ void do_msg_ini_msgfifo(uint8_t subf, int len, uint8_t * msg) } +static void do_msg_ini_memfifo(uint8_t subf, int len, uint8_t * msg) { (void)len; @@ -532,6 +538,7 @@ void do_msg_ini_memfifo(uint8_t subf, int len, uint8_t * msg) } +static void do_msg_char_out(uint8_t subf, int len, uint8_t * msg) { (void)subf; @@ -541,10 +548,11 @@ void do_msg_char_out(uint8_t subf, int len, uint8_t * msg) } +static const struct msg_item z80_messages[] = { - { 0, - 0, 0, + { 0, /* fct nr. */ + 0, 0, /* sub fct nr. from, to */ &do_msg_ini_msgfifo}, { 0, 1, 2, @@ -561,10 +569,11 @@ const struct msg_item z80_messages[] = +static void do_message(int len, uint8_t *msg) { uint8_t fct, sub_fct; - int i = 0; + int_fast8_t i = 0; if (len >= 2) { fct = *msg++; @@ -605,10 +614,11 @@ void do_message(int len, uint8_t *msg) #define CTRBUF_LEN 256 +static void check_msg_fifo(void) { int ch; - static int state; + static int_fast8_t state; static int msglen,idx; static uint8_t buffer[CTRBUF_LEN]; @@ -645,12 +655,11 @@ void check_msg_fifo(void) void z80_load_mem(void) { - -DBG_P(1, "Loading z80 memory... \n"); - unsigned sec = 0; uint32_t sec_base = hdrom_start; + DBG_P(1, "Loading z80 memory... \n"); + while (sec < hdrom_sections) { DBG_P(2, " From: 0x%.5lX to: 0x%.5lX (%5li bytes)\n", hdrom_address[sec], @@ -668,11 +677,7 @@ DBG_P(1, "Loading z80 memory... \n"); int main(void) { - //uint32_t led_state = LED_BLUE_PIN; - //uint32_t rc; - //uint8_t startval = 0; - //int count; - int state = 0; + int_fast8_t state = 0; int ch; clock_setup(); @@ -704,7 +709,7 @@ int main(void) z80_memset(0, 0x76, 0x80000); //z80_sram_fill(0, 512 * 1024, 0x76, 0); - z80_sram_cmp(0, 512 * 1024, 0x76, 0); + z80_sram_cmp(0, (uint32_t)512 * 1024, 0x76, 0); z80_load_mem(); z80_reset(LOW);