CDEV_LPT Working (for Epson)
Channels based on CDEV_LPT now working for my Epson printer.
This commit is contained in:
parent
6bd9908531
commit
f8d62a2f66
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -13,6 +13,8 @@
|
|||
|
||||
#if MODEL == MODEL_FOENIX_A2560K
|
||||
|
||||
#define MAX_LPT_JIFFIES 600
|
||||
|
||||
/**
|
||||
* Wait a little bit...
|
||||
*/
|
||||
|
@ -60,26 +62,45 @@ short lpt_close(t_channel * chan) {
|
|||
*/
|
||||
short lpt_write_b(p_channel chan, unsigned char b) {
|
||||
/* This write routine is polled I/O. */
|
||||
long target_jiffies = 0;
|
||||
|
||||
/* 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();
|
||||
if (target_jiffies < sys_time_jiffies()) {
|
||||
return DEV_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
/* Send the byte */
|
||||
*LPT_DATA_PORT = b;
|
||||
|
||||
/* 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_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) {
|
||||
// // Online, there's paper, not busy, and not in error
|
||||
// return ERR_GENERAL;
|
||||
// } else {
|
||||
// return 0;
|
||||
// }
|
||||
/* Wait until the printer is not busy */
|
||||
target_jiffies = sys_time_jiffies() + MAX_LPT_JIFFIES;
|
||||
while ((*LPT_STAT_PORT & LPT_STAT_nBUSY) != LPT_STAT_nBUSY) {
|
||||
lpt_delay();
|
||||
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;
|
||||
}
|
||||
|
@ -111,12 +132,12 @@ short lpt_status(p_channel chan) {
|
|||
unsigned char stat = *LPT_STAT_PORT;
|
||||
|
||||
// Conver the status bits to be consistent with channels
|
||||
if ((stat & LPT_STAT_nERROR) == 0) result |= LPT_STAT_nERROR;
|
||||
if (stat & LPT_STAT_PO) result |= LPT_STAT_PAPER;
|
||||
if (stat & LPT_STAT_SELECT) result |= LPT_STAT_ONLINE;
|
||||
if ((stat & LPT_STAT_nERROR) == 0) result |= LPT_STATUS_ERROR;
|
||||
if (stat & LPT_STAT_PO) result |= LPT_STATUS_PAPER;
|
||||
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) {
|
||||
// Online, there's paper, not busy, and not in error
|
||||
result |= LPT_STAT_WRITABLE;
|
||||
result |= LPT_STATUS_WRITABLE;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
|
||||
#include "dev/channel.h"
|
||||
|
||||
#define LPT_STAT_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_STAT_PAPER 0x10 /** The printer is out of paper */
|
||||
#define LPT_STAT_ONLINE 0x20 /** The printer is selected/online */
|
||||
#define LPT_STATUS_ERROR 0x02 /** The printer has encountered some error */
|
||||
#define LPT_STATUS_WRITABLE 0x08 /** The printer can accept data (online, no error, has paper, not busy) */
|
||||
#define LPT_STATUS_PAPER 0x10 /** The printer is out of paper */
|
||||
#define LPT_STATUS_ONLINE 0x20 /** The printer is selected/online */
|
||||
|
||||
/*
|
||||
* Install the LPT driver
|
||||
|
|
Binary file not shown.
11698
src/mapfile
11698
src/mapfile
File diff suppressed because it is too large
Load diff
|
@ -7,6 +7,6 @@
|
|||
|
||||
#define VER_MAJOR 0
|
||||
#define VER_MINOR 52
|
||||
#define VER_BUILD 2
|
||||
#define VER_BUILD 3
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue