Mostly minor fixes up until version 0.8.10.
[irreco.git] / lirc-0.8.4a / daemons / hw_uirt2_common.h
blobecefabbb1bc4c9398525e16a3911f0ed4e7d1821
1 /* $Id: hw_uirt2_common.h,v 5.3 2006/11/22 21:28:39 lirc Exp $ */
3 /****************************************************************************
4 ** hw_uirt2_common.h *******************************************************
5 ****************************************************************************
7 * Routines for UIRT2 receiver/transmitter
8 *
9 * Copyright (C) 2003 Mikael Magnusson <mikma@users.sourceforge.net>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 #ifndef HW_UIRT2_H
28 #define HW_UIRT2_H
30 #define UIRT2_UNIT 50 /* 50 us */
33 /* UIRT2 Commands */
34 #define UIRT2_SETMODEUIR 0x20
35 #define UIRT2_SETMODERAW 0x21
36 #define UIRT2_SETMODESTRUC 0x22
37 #define UIRT2_GETVERSION 0x23
38 #define UIRT2_GETGPIOCAPS 0x30
39 #define UIRT2_GETGPIOCFG 0x31
40 #define UIRT2_SETGPIOCFG 0x32
41 #define UIRT2_GETGPIO 0x33
42 #define UIRT2_SETGPIO 0x34
43 #define UIRT2_REFRESHGPIO 0x35
44 #define UIRT2_DOTXRAW 0x36
45 #define UIRT2_DOTXSTRUCT 0x37
47 /* UIRT2 Responses */
48 #define UIRT2_TRANSMITTING 0x20
49 #define UIRT2_CMDOK 0x21
50 #define UIRT2_CSERROR 0x80
51 #define UIRT2_TOERROR 0x81
52 #define UIRT2_CMDERROR 0x82
54 /* UIRT2 Actions */
55 #define UIRT2_ACTION_PULSE 0x00
56 #define UIRT2_ACTION_SET 0x40
57 #define UIRT2_ACTION_CLEAR 0x80
58 #define UIRT2_ACTION_TOGGLE 0xC0
60 /* UIRT2 Ports */
61 #define UIRT2_PORT_A 0x00
62 #define UIRT2_PORT_B 0x08
63 #define UIRT2_PORT_C 0x10
64 #define UIRT2_PORT_D 0x18
66 /* UIRT2 Frequences */
67 #define UIRT2_FREQ_40 0x00
68 #define UIRT2_FREQ_38 0x40
69 #define UIRT2_FREQ_36 0xC0
71 /* uirt2_setmode */
72 #define UIRT2_MODE_UIR 0x00
73 #define UIRT2_MODE_RAW 0x01
74 #define UIRT2_MODE_STRUC 0x02
75 #define UIRT2_MODE_MASK 0x03
78 #define UIRT2_CODE_SIZE 6
80 /* Remstruct1 */
81 #define UIRT2_MAX_BITS (16 * 8)
83 typedef unsigned char byte_t;
85 typedef struct {
86 byte_t bISDlyHi,bISDlyLo;
87 byte_t bBits,bHdr1,bHdr0;
88 byte_t bOff0,bOff1,bOn0,bOn1;
89 byte_t bDatBits [UIRT2_MAX_BITS / 8];
90 byte_t bCheck;
91 } __attribute__ ((packed)) remstruct1_data_t;
93 typedef struct {
94 byte_t bCmd;
95 remstruct1_data_t data;
96 } __attribute__ ((packed)) remstruct1_t;
98 typedef struct {
99 byte_t bFrequency;
100 byte_t bRepeatCount;
101 remstruct1_data_t data;
102 } __attribute__ ((packed)) remstruct1_ext_t;
104 typedef struct tag_uirt2_t uirt2_t;
106 typedef byte_t uirt2_code_t[UIRT2_CODE_SIZE];
108 uirt2_t *uirt2_init(int fd);
109 int uirt2_uninit(uirt2_t *dev);
110 int uirt2_getfd(uirt2_t *dev);
111 int uirt2_setmode(uirt2_t *dev, int mode);
112 int uirt2_setmodeuir(uirt2_t *dev);
113 int uirt2_setmoderaw(uirt2_t *dev);
114 int uirt2_setmodestruc(uirt2_t *dev);
115 int uirt2_getversion(uirt2_t *dev, int *version);
116 int uirt2_getgpiocaps(uirt2_t *dev, int *slots, byte_t masks[4]);
117 int uirt2_getgpiocfg(uirt2_t *dev, int slot, uirt2_code_t code,
118 int *action, int *duration);
119 int uirt2_setgpio(uirt2_t *dev, int action, int duration);
120 int uirt2_read_uir(uirt2_t *dev, byte_t *buf, int length);
121 lirc_t uirt2_read_raw(uirt2_t *dev, lirc_t timeout);
122 int uirt2_send_raw(uirt2_t *dev, byte_t *buf, int length);
123 int uirt2_send_struct1(uirt2_t *dev, int freq, int bRepeatCount,
124 remstruct1_data_t *buf);
125 int uirt2_calc_freq(int freq);
127 #endif /* HW_UIRT2_H */