File: uirt2_common.h

package info (click to toggle)
lirc 0.10.1-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 8,364 kB
  • sloc: ansic: 26,717; cpp: 9,066; sh: 5,521; python: 4,362; makefile: 1,034; xml: 63
file content (122 lines) | stat: -rw-r--r-- 3,759 bytes parent folder | download | duplicates (3)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122

/****************************************************************************
 ** hw_uirt2_common.h *******************************************************
 ****************************************************************************
 *
 * Routines for UIRT2 receiver/transmitter
 *
 * Copyright (C) 2003 Mikael Magnusson <mikma@users.sourceforge.net>
 *
 *  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 2 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 Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 */

#ifndef HW_UIRT2_H
#define HW_UIRT2_H

#define UIRT2_UNIT 50		/* 50 us */

/* UIRT2 Commands */
#define UIRT2_SETMODEUIR   0x20
#define UIRT2_SETMODERAW   0x21
#define UIRT2_SETMODESTRUC 0x22
#define UIRT2_GETVERSION   0x23
#define UIRT2_GETGPIOCAPS  0x30
#define UIRT2_GETGPIOCFG   0x31
#define UIRT2_SETGPIOCFG   0x32
#define UIRT2_GETGPIO      0x33
#define UIRT2_SETGPIO      0x34
#define UIRT2_REFRESHGPIO  0x35
#define UIRT2_DOTXRAW      0x36
#define UIRT2_DOTXSTRUCT   0x37

/* UIRT2 Responses */
#define UIRT2_TRANSMITTING 0x20
#define UIRT2_CMDOK        0x21
#define UIRT2_CSERROR      0x80
#define UIRT2_TOERROR      0x81
#define UIRT2_CMDERROR     0x82

/* UIRT2 Actions */
#define UIRT2_ACTION_PULSE  0x00
#define UIRT2_ACTION_SET    0x40
#define UIRT2_ACTION_CLEAR  0x80
#define UIRT2_ACTION_TOGGLE 0xC0

/* UIRT2 Ports */
#define UIRT2_PORT_A 0x00
#define UIRT2_PORT_B 0x08
#define UIRT2_PORT_C 0x10
#define UIRT2_PORT_D 0x18

/* UIRT2 Frequences */
#define UIRT2_FREQ_40 0x00
#define UIRT2_FREQ_38 0x40
#define UIRT2_FREQ_36 0xC0

/* uirt2_setmode */
#define UIRT2_MODE_UIR   0x00
#define UIRT2_MODE_RAW   0x01
#define UIRT2_MODE_STRUC 0x02
#define UIRT2_MODE_MASK  0x03

#define UIRT2_CODE_SIZE 6

/* Remstruct1 */
#define UIRT2_MAX_BITS (16 * 8)

typedef unsigned char byte_t;

typedef struct {
	byte_t bISDlyHi, bISDlyLo;
	byte_t bBits, bHdr1, bHdr0;
	byte_t bOff0, bOff1, bOn0, bOn1;
	byte_t bDatBits[UIRT2_MAX_BITS / 8];
	byte_t bCheck;
} __attribute__ ((packed)) remstruct1_data_t;

typedef struct {
	byte_t bCmd;
	remstruct1_data_t data;
} __attribute__ ((packed)) remstruct1_t;

typedef struct {
	byte_t bFrequency;
	byte_t bRepeatCount;
	remstruct1_data_t data;
} __attribute__ ((packed)) remstruct1_ext_t;

typedef struct tag_uirt2_t uirt2_t;

typedef byte_t uirt2_code_t[UIRT2_CODE_SIZE];

uirt2_t *uirt2_init(int fd);
int uirt2_uninit(uirt2_t * dev);
int uirt2_getfd(uirt2_t * dev);
int uirt2_setmode(uirt2_t * dev, int mode);
int uirt2_setmodeuir(uirt2_t * dev);
int uirt2_setmoderaw(uirt2_t * dev);
int uirt2_setmodestruc(uirt2_t * dev);
int uirt2_getversion(uirt2_t * dev, int *version);
int uirt2_getgpiocaps(uirt2_t * dev, int *slots, byte_t masks[4]);
int uirt2_getgpiocfg(uirt2_t * dev, int slot, uirt2_code_t code, int *action, int *duration);
int uirt2_setgpio(uirt2_t * dev, int action, int duration);
int uirt2_read_uir(uirt2_t * dev, byte_t * buf, int length);
lirc_t uirt2_read_raw(uirt2_t * dev, lirc_t timeout);
int uirt2_send_raw(uirt2_t * dev, byte_t * buf, int length);
int uirt2_send_struct1(uirt2_t * dev, int freq, int bRepeatCount, remstruct1_data_t * buf);
int uirt2_calc_freq(int freq);

#endif /* HW_UIRT2_H */