X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fao_dbg.c;h=493715600b169e2fcbbeab74d5f5fecaac6f64b6;hp=2fc266e3f38c462083e746d1a38db9c4449cf2ee;hb=f3e68341f6f5daaf26dd162e4f9a06c29988986a;hpb=f93c9bf3695862db31f2c3b3bc5a7bb24ef3766c diff --git a/src/ao_dbg.c b/src/ao_dbg.c index 2fc266e3..49371560 100644 --- a/src/ao_dbg.c +++ b/src/ao_dbg.c @@ -164,6 +164,12 @@ ao_dbg_read_byte(void) static void ao_dbg_set_pins(void) { + /* Make the DBG pins GPIOs. On TeleMetrum, this will + * disable the SPI link, so don't expect SPI to work after + * using the debugger. + */ + DBG_PORT_SEL &= ~(DBG_CLOCK|DBG_DATA|DBG_RESET_N); + /* make DBG_DATA tri-state */ DBG_PORT_INP |= DBG_DATA; @@ -184,11 +190,8 @@ ao_dbg_long_delay(void) _asm nop _endasm; } -static void -ao_dbg_reset_delay(void) -{ - ao_delay(AO_MS_TO_TICKS(20)); -} +#define AO_RESET_LOW_DELAY AO_MS_TO_TICKS(100) +#define AO_RESET_HIGH_DELAY AO_MS_TO_TICKS(100) void ao_dbg_debug_mode(void) @@ -198,7 +201,7 @@ ao_dbg_debug_mode(void) ao_dbg_send_bits(DBG_CLOCK|DBG_DATA|DBG_RESET_N, DBG_CLOCK|DBG_DATA|DBG_RESET_N); ao_dbg_long_delay(); ao_dbg_send_bits(DBG_CLOCK|DBG_DATA|DBG_RESET_N, 0 |DBG_DATA| 0 ); - ao_dbg_reset_delay(); + ao_delay(AO_RESET_LOW_DELAY); ao_dbg_send_bits(DBG_CLOCK|DBG_DATA|DBG_RESET_N, DBG_CLOCK|DBG_DATA| 0 ); ao_dbg_long_delay(); ao_dbg_send_bits(DBG_CLOCK|DBG_DATA|DBG_RESET_N, 0 |DBG_DATA| 0 ); @@ -206,7 +209,7 @@ ao_dbg_debug_mode(void) ao_dbg_send_bits(DBG_CLOCK|DBG_DATA|DBG_RESET_N, DBG_CLOCK|DBG_DATA| 0 ); ao_dbg_long_delay(); ao_dbg_send_bits(DBG_CLOCK|DBG_DATA|DBG_RESET_N, 0 |DBG_DATA|DBG_RESET_N); - ao_dbg_reset_delay(); + ao_delay(AO_RESET_HIGH_DELAY); } void @@ -217,7 +220,7 @@ ao_dbg_reset(void) ao_dbg_send_bits(DBG_CLOCK|DBG_DATA|DBG_RESET_N, DBG_CLOCK|DBG_DATA|DBG_RESET_N); ao_dbg_long_delay(); ao_dbg_send_bits(DBG_CLOCK|DBG_DATA|DBG_RESET_N, DBG_CLOCK|DBG_DATA| 0 ); - ao_dbg_reset_delay(); + ao_delay(AO_RESET_LOW_DELAY); ao_dbg_send_bits(DBG_CLOCK|DBG_DATA|DBG_RESET_N, DBG_CLOCK|DBG_DATA| 0 ); ao_dbg_long_delay(); ao_dbg_send_bits(DBG_CLOCK|DBG_DATA|DBG_RESET_N, DBG_CLOCK|DBG_DATA| 0 ); @@ -225,7 +228,7 @@ ao_dbg_reset(void) ao_dbg_send_bits(DBG_CLOCK|DBG_DATA|DBG_RESET_N, DBG_CLOCK|DBG_DATA| 0 ); ao_dbg_long_delay(); ao_dbg_send_bits(DBG_CLOCK|DBG_DATA|DBG_RESET_N, DBG_CLOCK|DBG_DATA|DBG_RESET_N); - ao_dbg_reset_delay(); + ao_delay(AO_RESET_HIGH_DELAY); } static void @@ -345,13 +348,13 @@ debug_output(void) } __code struct ao_cmds ao_dbg_cmds[7] = { - { 'D', debug_enable, "D Enable debug mode" }, - { 'G', debug_get, "G Get data from debug port" }, - { 'I', debug_input, "I Input bytes to target at " }, - { 'O', debug_output, "O Output bytes to target at " }, - { 'P', debug_put, "P ... Put data to debug port" }, - { 'R', debug_reset, "R Reset target" }, - { 0, debug_reset, 0 }, + { debug_enable, "D\0Enable debug mode" }, + { debug_get, "G \0Get data from debug port" }, + { debug_input, "I \0Input bytes to target at " }, + { debug_output, "O \0Output bytes to target at " }, + { debug_put, "P ...\0Put data to debug port" }, + { debug_reset, "R\0Reset target" }, + { 0, NULL }, }; void