CDEV_LPT Working (for Epson)

Channels based on CDEV_LPT now working for my Epson printer.
This commit is contained in:
Peter Weingartner 2022-04-19 16:55:05 -04:00
parent 6bd9908531
commit f8d62a2f66
8 changed files with 5894 additions and 5861 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -13,6 +13,8 @@
#if MODEL == MODEL_FOENIX_A2560K #if MODEL == MODEL_FOENIX_A2560K
#define MAX_LPT_JIFFIES 600
/** /**
* Wait a little bit... * Wait a little bit...
*/ */
@ -60,26 +62,45 @@ short lpt_close(t_channel * chan) {
*/ */
short lpt_write_b(p_channel chan, unsigned char b) { short lpt_write_b(p_channel chan, unsigned char b) {
/* This write routine is polled I/O. */ /* This write routine is polled I/O. */
long target_jiffies = 0;
/* Wait until the printer is not busy */ /* Wait until the printer is not busy */
while ((*LPT_STAT_PORT & LPT_STAT_nBUSY) == LPT_STAT_nBUSY) { target_jiffies = sys_time_jiffies() + MAX_LPT_JIFFIES;
while ((*LPT_STAT_PORT & LPT_STAT_nBUSY) != LPT_STAT_nBUSY) {
lpt_delay(); lpt_delay();
if (target_jiffies < sys_time_jiffies()) {
return DEV_TIMEOUT;
}
} }
/* Send the byte */ /* Send the byte */
*LPT_DATA_PORT = b; *LPT_DATA_PORT = b;
/* Strobe the interface */ /* Strobe the interface */
*LPT_CTRL_PORT = LPT_CTRL_mINIT | LPT_CTRL_SELECT | LPT_CTRL_STROBE;
lpt_delay();
*LPT_CTRL_PORT = LPT_CTRL_mINIT | LPT_CTRL_SELECT; *LPT_CTRL_PORT = LPT_CTRL_mINIT | LPT_CTRL_SELECT;
lpt_delay();
*LPT_CTRL_PORT = LPT_CTRL_mINIT | LPT_CTRL_SELECT | LPT_CTRL_STROBE;
// if ((*LPT_STAT_PORT & (LPT_STAT_nERROR | LPT_STAT_PO | LPT_STAT_nBUSY | LPT_STAT_SELECT)) != LPT_STAT_nERROR | LPT_STAT_nBUSY | LPT_STAT_SELECT) { /* Wait until the printer is not busy */
// // Online, there's paper, not busy, and not in error target_jiffies = sys_time_jiffies() + MAX_LPT_JIFFIES;
// return ERR_GENERAL; while ((*LPT_STAT_PORT & LPT_STAT_nBUSY) != LPT_STAT_nBUSY) {
// } else { lpt_delay();
// return 0; if (target_jiffies < sys_time_jiffies()) {
// } return DEV_TIMEOUT;
}
}
unsigned char status = *LPT_STAT_PORT;
if ((status & (LPT_STAT_nERROR | LPT_STAT_PO)) != LPT_STAT_nERROR ) {
// Online, there's paper, not busy, and not in error
if (status & LPT_STAT_PO) {
return DEV_NOMEDIA;
} else {
return ERR_GENERAL;
}
} else {
return 0;
}
return 0; return 0;
} }
@ -111,12 +132,12 @@ short lpt_status(p_channel chan) {
unsigned char stat = *LPT_STAT_PORT; unsigned char stat = *LPT_STAT_PORT;
// Conver the status bits to be consistent with channels // Conver the status bits to be consistent with channels
if ((stat & LPT_STAT_nERROR) == 0) result |= LPT_STAT_nERROR; if ((stat & LPT_STAT_nERROR) == 0) result |= LPT_STATUS_ERROR;
if (stat & LPT_STAT_PO) result |= LPT_STAT_PAPER; if (stat & LPT_STAT_PO) result |= LPT_STATUS_PAPER;
if (stat & LPT_STAT_SELECT) result |= LPT_STAT_ONLINE; if (stat & LPT_STAT_SELECT) result |= LPT_STATUS_ONLINE;
if ((stat & (LPT_STAT_nERROR | LPT_STAT_PO | LPT_STAT_nBUSY | LPT_STAT_SELECT)) == LPT_STAT_nERROR | LPT_STAT_nBUSY | LPT_STAT_SELECT) { if ((stat & (LPT_STAT_nERROR | LPT_STAT_PO | LPT_STAT_nBUSY | LPT_STAT_SELECT)) == LPT_STAT_nERROR | LPT_STAT_nBUSY | LPT_STAT_SELECT) {
// Online, there's paper, not busy, and not in error // Online, there's paper, not busy, and not in error
result |= LPT_STAT_WRITABLE; result |= LPT_STATUS_WRITABLE;
} }
return result; return result;

View file

@ -7,10 +7,10 @@
#include "dev/channel.h" #include "dev/channel.h"
#define LPT_STAT_ERROR 0x02 /** The printer has encountered some error */ #define LPT_STATUS_ERROR 0x02 /** The printer has encountered some error */
#define LPT_STAT_WRITABLE 0x08 /** The printer can accept data (online, no error, has paper, not busy) */ #define LPT_STATUS_WRITABLE 0x08 /** The printer can accept data (online, no error, has paper, not busy) */
#define LPT_STAT_PAPER 0x10 /** The printer is out of paper */ #define LPT_STATUS_PAPER 0x10 /** The printer is out of paper */
#define LPT_STAT_ONLINE 0x20 /** The printer is selected/online */ #define LPT_STATUS_ONLINE 0x20 /** The printer is selected/online */
/* /*
* Install the LPT driver * Install the LPT driver

Binary file not shown.

11698
src/mapfile

File diff suppressed because it is too large Load diff

View file

@ -7,6 +7,6 @@
#define VER_MAJOR 0 #define VER_MAJOR 0
#define VER_MINOR 52 #define VER_MINOR 52
#define VER_BUILD 2 #define VER_BUILD 3
#endif #endif