forked from agalakhov/captdriver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
capt-status.h
76 lines (69 loc) · 2.2 KB
/
capt-status.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Copyright (C) 2013 Alexey Galakhov <agalakhov@gmail.com>
*
* Licensed under the GNU General Public License Version 3
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "std.h"
struct capt_status_s {
uint16_t status[7];
uint16_t page_decoding;
uint16_t page_printing;
uint16_t page_out;
uint16_t page_completed;
uint16_t page_received;
};
#define _FL(s, b) ((s << 16) | (1 << b))
enum capt_flags
{
/* status[0] */
CAPT_FL_READY1 = _FL(0, 15), /* ? */
CAPT_FL_READY2 = _FL(0, 12), /* ? */
CAPT_FL_JOBSTAT_CHNG = _FL(0, 9),
CAPT_FL_XSTATUS_CHNG = _FL(0, 8),
CAPT_FL_BUSY = _FL(0, 7),
CAPT_FL_UNINIT1 = _FL(0, 5),
CAPT_FL_UNINIT2 = _FL(0, 4),
CAPT_FL_BUFFERFULL = _FL(0, 2),
CAPT_FL_NOPAPER1 = _FL(0, 1),
CAPT_FL_PROCESSING = _FL(0, 0),
/* status[1] */
CAPT_FL_NOPAPER2 = _FL(1, 14),
CAPT_FL_PROCESSING1 = _FL(1, 7),
CAPT_FL_BUTTON = _FL(1, 5),
CAPT_FL_PRINTING = _FL(1, 2),
CAPT_FL_POWERUP = _FL(1, 0),
/* status[2] */
CAPT_FL_nERROR = _FL(2, 7),
CAPT_FL_BUTTON1 = _FL(2, 8),
/* status[3] */
CAPT_FL_POWERUP1 = _FL(3, 12),
/* status[4] */
/* status[5] */
/* status[6] */
};
#undef _FL
static inline bool FLAG(const struct capt_status_s *status, enum capt_flags flag)
{
return !! (status->status[flag >> 16] & (flag & 0xFFFF));
}
void capt_init_status(void);
const struct capt_status_s *capt_get_status(void);
const struct capt_status_s *capt_get_xstatus_only(void);
const struct capt_status_s *capt_get_xstatus(void);
void capt_wait_ready(void);
void capt_wait_xready(void);
void capt_wait_xready_only(void);