printer: avr: Extend test mode

master
Markus Koch 2019-11-10 20:12:20 +01:00
parent d3997d6049
commit 9a896c3314
1 changed files with 39 additions and 9 deletions

View File

@ -13,6 +13,7 @@ inline void spi_process_data();
enum TIMERS{TIM_CARRIAGE,
TIM_WHEEL,
TIM_LINEFEED,
TIM_SYSTEM,
TIMS};
#define TIMESCALE 4
@ -753,15 +754,18 @@ void initialize_paperfeed()
// }
//}
//void systick_test()
//{
// debug_write("[tmr] System timer test\r\n");
// while (1) {
// if (block_for(0, 1000 * TIMESCALE)) {
// debug_write("hello\n");
// }
// }
//}
void systick_test()
{
debug_write("[tmr] System timer test\r\n");
while (1) {
if (block_for(TIM_SYSTEM, 1000 * TIMESCALE)) {
debug_write("tick.\r\n");
}
if (UCSRA & (1 << RXC)) {
break;
}
}
}
void hardfault() {
@ -769,6 +773,12 @@ void hardfault() {
STEPPER_STOP(WHEEL);
STEPPER_STOP(CARRIAGE);
STEPPER_STOP(LINEFEED);
DDRB = 0;
DDRC = 0;
DDRD = 0;
PORTB = 0;
PORTC = 0;
PORTD = 0;
while(1);
}
@ -1156,6 +1166,26 @@ int system_test_auto()
default:
break;
}
/* System control */
switch (c) {
case 'i':
sei();
debug_write("Interrupts enabled.\r\n");
break;
case 'I':
cli();
debug_write("Interrupts disabled.\r\n");
break;
case 't':
systick_test();
break;
case 'f':
hardfault();
break;
default:
break;
}
}
}