Compare commits

...

4 Commits

Author SHA1 Message Date
Markus Koch 323fa68222 printer:avr: Fix startup behavior if in correction mode
Also introduce startup wait until 0xFF is received.
2020-05-10 20:43:53 +02:00
Markus Koch 0ec64e6a39 ioc:kernel-driver: Fix startup delay for normal mode 2020-05-10 20:41:10 +02:00
Markus Koch 3ae19dc20a display:fpga: Fix project file 2020-05-10 20:40:08 +02:00
Markus Koch eebd6e5517 doc: Add HW architecture diagram 2020-05-10 20:36:53 +02:00
5 changed files with 42 additions and 11 deletions

View File

@ -2,7 +2,7 @@
<BaliProject version="3.2" title="lmg6202" device="LCMXO2-1200HC-5SG32C" default_implementation="impl1">
<Options/>
<Implementation title="impl1" dir="impl1" description="impl1" synthesis="synplify" default_strategy="Strategy1">
<Options def_top="design.top" top="design.top"/>
<Options def_top="design.top" lib="design" top="design.top"/>
<Source name="../ip/gram0/gram0.ipx" type="IPX_Module" type_short="IPX">
<Options/>
</Source>
@ -18,6 +18,12 @@
<Source name="../design/spi_if.vhd" type="VHDL" type_short="VHDL">
<Options lib="design"/>
</Source>
<Source name="../ip/pll0/pll0.vhd" type="VHDL" type_short="VHDL">
<Options lib="ip"/>
</Source>
<Source name="../generics/synchronizer.vhd" type="VHDL" type_short="VHDL">
<Options lib="generics"/>
</Source>
<Source name="impl1/impl1.xcf" type="Programming Project File" type_short="Programming">
<Options/>
</Source>

View File

@ -190,7 +190,7 @@
<Property name="PROP_SYN_ResolvedMixedDrivers" value="False" time="0"/>
<Property name="PROP_SYN_UpdateCompilePtTimData" value="False" time="0"/>
<Property name="PROP_SYN_UseLPF" value="True" time="0"/>
<Property name="PROP_SYN_VHDL2008" value="False" time="0"/>
<Property name="PROP_SYN_VHDL2008" value="True" time="0"/>
<Property name="PROP_THERMAL_DefaultFreq" value="0" time="0"/>
<Property name="PROP_TIM_MaxDelSimDes" value="" time="0"/>
<Property name="PROP_TIM_MinSpeedGrade" value="False" time="0"/>

BIN
doc/architecture.dia Normal file

Binary file not shown.

View File

@ -292,8 +292,9 @@ static int lw35ioc_chardev_open(struct inode *inodep, struct file *filep) {
break;
case PASSIVE:
lw35ioc_reset_ioc_hw(serdev);
usleep_range(1000000, 1010000);
usleep_range(2100000, 2210000);
dev_info(&serdev->dev, "Put ioc into active mode.\n");
serdev_device_write(serdev, "\xFF", 1, 0);
priv->state = ACTIVE;
break;
case ACTIVE:

View File

@ -112,7 +112,7 @@ void hardfault() {
#define PRINTER_CONTROL_CHAR 56
#define PRINTER_NO_CHAR 128
#define ASCII_TRANSLATION_TABLE_SIZE 128 + 12
#define ASCII_TRANSLATION_TABLE_SIZE (128 + 12)
const uint8_t ascii_translation_table[ASCII_TRANSLATION_TABLE_SIZE] PROGMEM = {
PRINTER_CONTROL_CHAR,
PRINTER_CONTROL_CHAR,
@ -277,6 +277,9 @@ const uint8_t ascii_translation_table[ASCII_TRANSLATION_TABLE_SIZE] PROGMEM = {
#define PIN_CORRECTION (1 << 1)
#define PIN_ARMHAMMER (1 << 0)
/* Misc I/O */
#define MISCIO(t) t##D
#define PIN_BACKLIGHT (1 << 2)
/* Stepper drive */
@ -671,11 +674,22 @@ void move_carriage_to_far_left(uint8_t reset)
if (LIMITSWITCH) {
debug_write("[car] Clearing switch area...\r\n");
while (LIMITSWITCH) {
cnt = 32;
while (LIMITSWITCH && (cnt> 0)) {
if (block_for(TIM_CARRIAGE, STEPPER_CFG_CARRIAGE.delay)) {
STEPPER_NEXT(CARRIAGE, 1);
cnt--;
}
}
if (LIMITSWITCH && !cnt) { // We're probably in correction mode
DCMOTOR_EN;
arm_correction();
_delay_ms(1000);
DCMOTOR_STOP;
}
if (LIMITSWITCH) { // If the switch is still not released, there's some problem we can't fix from SW
hardfault();
}
for (cnt = 0; cnt < 16; cnt++) {
STEPPER_NEXT(CARRIAGE, 1);
}
@ -911,7 +925,7 @@ void printer_process()
switch (state) {
case IDLE:
if (print_buffer_rd != print_buffer_wr) { // maybe add "|| current_is_linebreak"
if (print_buffer_rd != print_buffer_wr) { // TODO: maybe add "|| current_is_linebreak"
if (!DCMOTOR_ISACTIVE) {
DCMOTOR_EN;
_delay_ms(100); /* Let the motor get up to speed */
@ -1019,7 +1033,8 @@ void printer_process()
// stepper_status_WHEEL.target_pos += 10;
// // -----------
if (stepper_status_CARRIAGE.target_pos > PRINTER_STOP_RIGHT) { // Right margin safety
if (stepper_status_CARRIAGE.target_pos > PRINTER_STOP_RIGHT ||
stepper_status_CARRIAGE.target_pos < 0) { // Margin safety
hardfault();
}
stepper_perform_movement(&stepper_status_LINEFEED, &STEPPER_CFG_LINEFEED);
@ -1211,10 +1226,10 @@ static void system_test_auto()
if (POSITION_REACHED(WHEEL) && POSITION_REACHED(CARRIAGE) && POSITION_REACHED(LINEFEED) && print_stat) {
print_stat = 0;
debug_printf("[pos] %uL %uC%c %uW\r\n",
stepper_status_LINEFEED.pos,
stepper_status_CARRIAGE.pos,
(LIMITSWITCH ? '*' : '+'),
stepper_status_WHEEL.pos);
stepper_status_LINEFEED.pos,
stepper_status_CARRIAGE.pos,
(LIMITSWITCH ? '*' : '+'),
stepper_status_WHEEL.pos);
}
if (do_it) {
@ -1274,6 +1289,10 @@ int main()
STEPPER_SET_IO(WHEEL);
STEPPER_SET_IO(LINEFEED);
/* Set up miscellaneous I/O */
MISCIO(DDR) |= PIN_BACKLIGHT;
MISCIO(PORT) |= PIN_BACKLIGHT; /* Permanently enable backlight */
/* Set up SysTick Timer */
TCCR1B = (1 << WGM12) | (1 << CS11); // f_tim = 8 MHz / 8
OCR1A = 2000 / TIMESCALE;
@ -1283,6 +1302,11 @@ int main()
sync_uart();
update_status(0);
debug_write("\n\n\r[sys] STARTING IO CONTROLLER...\r\n");
#ifndef DEBUG_BUILD
while (!((UCSRA & (1 << RXC)) && (UDR == 0xFF))); /* Wait for init command from driver */
update_status(0);
_delay_ms(250);
#endif
debug_write("[sys] Enabling interrupts.\r\n");
sei();