1 /* $Id: hw_uirt2_common.h,v 5.3 2006/11/22 21:28:39 lirc Exp $ */ 2 3 /**************************************************************************** 4 ** hw_uirt2_common.h ******************************************************* 5 **************************************************************************** 6 * 7 * Routines for UIRT2 receiver/transmitter 8 * 9 * Copyright (C) 2003 Mikael Magnusson <mikma@users.sourceforge.net> 10 * 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. 15 * 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. 20 * 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. 24 * 25 */ 26 27 #ifndef HW_UIRT2_H 28 #define HW_UIRT2_H 29 30 #define UIRT2_UNIT 50 /* 50 us */ 31 32 /* UIRT2 Commands */ 33 #define UIRT2_SETMODEUIR 0x20 34 #define UIRT2_SETMODERAW 0x21 35 #define UIRT2_SETMODESTRUC 0x22 36 #define UIRT2_GETVERSION 0x23 37 #define UIRT2_GETGPIOCAPS 0x30 38 #define UIRT2_GETGPIOCFG 0x31 39 #define UIRT2_SETGPIOCFG 0x32 40 #define UIRT2_GETGPIO 0x33 41 #define UIRT2_SETGPIO 0x34 42 #define UIRT2_REFRESHGPIO 0x35 43 #define UIRT2_DOTXRAW 0x36 44 #define UIRT2_DOTXSTRUCT 0x37 45 46 /* UIRT2 Responses */ 47 #define UIRT2_TRANSMITTING 0x20 48 #define UIRT2_CMDOK 0x21 49 #define UIRT2_CSERROR 0x80 50 #define UIRT2_TOERROR 0x81 51 #define UIRT2_CMDERROR 0x82 52 53 /* UIRT2 Actions */ 54 #define UIRT2_ACTION_PULSE 0x00 55 #define UIRT2_ACTION_SET 0x40 56 #define UIRT2_ACTION_CLEAR 0x80 57 #define UIRT2_ACTION_TOGGLE 0xC0 58 59 /* UIRT2 Ports */ 60 #define UIRT2_PORT_A 0x00 61 #define UIRT2_PORT_B 0x08 62 #define UIRT2_PORT_C 0x10 63 #define UIRT2_PORT_D 0x18 64 65 /* UIRT2 Frequences */ 66 #define UIRT2_FREQ_40 0x00 67 #define UIRT2_FREQ_38 0x40 68 #define UIRT2_FREQ_36 0xC0 69 70 /* uirt2_setmode */ 71 #define UIRT2_MODE_UIR 0x00 72 #define UIRT2_MODE_RAW 0x01 73 #define UIRT2_MODE_STRUC 0x02 74 #define UIRT2_MODE_MASK 0x03 75 76 #define UIRT2_CODE_SIZE 6 77 78 /* Remstruct1 */ 79 #define UIRT2_MAX_BITS (16 * 8) 80 81 typedef unsigned char byte_t; 82 83 typedef struct { 84 byte_t bISDlyHi, bISDlyLo; 85 byte_t bBits, bHdr1, bHdr0; 86 byte_t bOff0, bOff1, bOn0, bOn1; 87 byte_t bDatBits[UIRT2_MAX_BITS / 8]; 88 byte_t bCheck; 89 } __attribute__ ((packed)) remstruct1_data_t; 90 91 typedef struct { 92 byte_t bCmd; 93 remstruct1_data_t data; 94 } __attribute__ ((packed)) remstruct1_t; 95 96 typedef struct { 97 byte_t bFrequency; 98 byte_t bRepeatCount; 99 remstruct1_data_t data; 100 } __attribute__ ((packed)) remstruct1_ext_t; 101 102 typedef struct tag_uirt2_t uirt2_t; 103 104 typedef byte_t uirt2_code_t[UIRT2_CODE_SIZE]; 105 106 uirt2_t *uirt2_init(int fd); 107 int uirt2_uninit(uirt2_t * dev); 108 int uirt2_getfd(uirt2_t * dev); 109 int uirt2_setmode(uirt2_t * dev, int mode); 110 int uirt2_setmodeuir(uirt2_t * dev); 111 int uirt2_setmoderaw(uirt2_t * dev); 112 int uirt2_setmodestruc(uirt2_t * dev); 113 int uirt2_getversion(uirt2_t * dev, int *version); 114 int uirt2_getgpiocaps(uirt2_t * dev, int *slots, byte_t masks[4]); 115 int uirt2_getgpiocfg(uirt2_t * dev, int slot, uirt2_code_t code, int *action, int *duration); 116 int uirt2_setgpio(uirt2_t * dev, int action, int duration); 117 int uirt2_read_uir(uirt2_t * dev, byte_t * buf, int length); 118 lirc_t uirt2_read_raw(uirt2_t * dev, lirc_t timeout); 119 int uirt2_send_raw(uirt2_t * dev, byte_t * buf, int length); 120 int uirt2_send_struct1(uirt2_t * dev, int freq, int bRepeatCount, remstruct1_data_t * buf); 121 int uirt2_calc_freq(int freq); 122 123 #endif /* HW_UIRT2_H */ 124