001package com.pi4j.io.i2c; 002 003/*- 004 * #%L 005 * ********************************************************************** 006 * ORGANIZATION : Pi4J 007 * PROJECT : Pi4J :: Java Library (Core) 008 * FILENAME : I2CConstants.java 009 * 010 * This file is part of the Pi4J project. More information about 011 * this project can be found here: https://www.pi4j.com/ 012 * ********************************************************************** 013 * %% 014 * Copyright (C) 2012 - 2019 Pi4J 015 * %% 016 * This program is free software: you can redistribute it and/or modify 017 * it under the terms of the GNU Lesser General Public License as 018 * published by the Free Software Foundation, either version 3 of the 019 * License, or (at your option) any later version. 020 * 021 * This program is distributed in the hope that it will be useful, 022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 024 * GNU General Lesser Public License for more details. 025 * 026 * You should have received a copy of the GNU General Lesser Public 027 * License along with this program. If not, see 028 * <http://www.gnu.org/licenses/lgpl-3.0.html>. 029 * #L% 030 */ 031 032/** 033 * These are constants scraped directly from linux kernel (i2c-dev.h i2c.h). They are to 034 * be used with advanced I2C ioctl. 035 */ 036public class I2CConstants { 037 /* Flags for i2c_msg.flags */ 038 039 public static int I2C_M_RD = 0x0001; /* read data, from slave to master 040 I2C_M_RD is guaranteed to be = 0x0001! */ 041 public static int I2C_M_TEN = 0x0010; /* this is a ten bit chip address */ 042 public static int I2C_M_RECV_LEN = 0x0400; /* length will be first received byte */ 043 public static int I2C_M_NO_RD_ACK = 0x0800; /* if I2C_FUNC_PROTOCOL_MANGLING */ 044 public static int I2C_M_IGNORE_NAK = 0x1000; /* if I2C_FUNC_PROTOCOL_MANGLING */ 045 public static int I2C_M_REV_DIR_ADDR = 0x2000; /* if I2C_FUNC_PROTOCOL_MANGLING */ 046 public static int I2C_M_NOSTART = 0x4000; /* if I2C_FUNC_NOSTART */ 047 public static int I2C_M_STOP = 0x8000; /* if I2C_FUNC_PROTOCOL_MANGLING */ 048 049 /* To determine what functionality is present */ 050 051 public static int I2C_FUNC_I2C = 0x00000001; 052 public static int I2C_FUNC_10BIT_ADDR = 0x00000002; 053 public static int I2C_FUNC_PROTOCOL_MANGLING = 0x00000004; /* I2C_M_IGNORE_NAK etc. */ 054 public static int I2C_FUNC_SMBUS_PEC = 0x00000008; 055 public static int I2C_FUNC_NOSTART = 0x00000010; /* I2C_M_NOSTART */ 056 public static int I2C_FUNC_SLAVE = 0x00000020; 057 public static int I2C_FUNC_SMBUS_BLOCK_PROC_CALL = 0x00008000; /* SMBus 2.0 */ 058 public static int I2C_FUNC_SMBUS_QUICK = 0x00010000; 059 public static int I2C_FUNC_SMBUS_READ_BYTE = 0x00020000; 060 public static int I2C_FUNC_SMBUS_WRITE_BYTE = 0x00040000; 061 public static int I2C_FUNC_SMBUS_READ_BYTE_DATA = 0x00080000; 062 public static int I2C_FUNC_SMBUS_WRITE_BYTE_DATA = 0x00100000; 063 public static int I2C_FUNC_SMBUS_READ_WORD_DATA = 0x00200000; 064 public static int I2C_FUNC_SMBUS_WRITE_WORD_DATA = 0x00400000; 065 public static int I2C_FUNC_SMBUS_PROC_CALL = 0x00800000; 066 public static int I2C_FUNC_SMBUS_READ_BLOCK_DATA = 0x01000000; 067 public static int I2C_FUNC_SMBUS_WRITE_BLOCK_DATA = 0x02000000; 068 public static int I2C_FUNC_SMBUS_READ_I2C_BLOCK = 0x04000000; /* I2C-like block xfer */ 069 public static int I2C_FUNC_SMBUS_WRITE_I2C_BLOCK = 0x08000000; /* w/ 1-byte reg. addr. */ 070 public static int I2C_FUNC_SMBUS_HOST_NOTIFY = 0x10000000; 071 072 public static int I2C_FUNC_SMBUS_BYTE = (I2C_FUNC_SMBUS_READ_BYTE | 073 I2C_FUNC_SMBUS_WRITE_BYTE); 074 public static int I2C_FUNC_SMBUS_BYTE_DATA = (I2C_FUNC_SMBUS_READ_BYTE_DATA | 075 I2C_FUNC_SMBUS_WRITE_BYTE_DATA); 076 public static int I2C_FUNC_SMBUS_WORD_DATA = (I2C_FUNC_SMBUS_READ_WORD_DATA | 077 I2C_FUNC_SMBUS_WRITE_WORD_DATA); 078 public static int I2C_FUNC_SMBUS_BLOCK_DATA = (I2C_FUNC_SMBUS_READ_BLOCK_DATA | 079 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA); 080 public static int I2C_FUNC_SMBUS_I2C_BLOCK = (I2C_FUNC_SMBUS_READ_I2C_BLOCK | 081 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK); 082 083 public static int I2C_FUNC_SMBUS_EMUL = (I2C_FUNC_SMBUS_QUICK | 084 I2C_FUNC_SMBUS_BYTE | 085 I2C_FUNC_SMBUS_BYTE_DATA | 086 I2C_FUNC_SMBUS_WORD_DATA | 087 I2C_FUNC_SMBUS_PROC_CALL | 088 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | 089 I2C_FUNC_SMBUS_I2C_BLOCK | 090 I2C_FUNC_SMBUS_PEC); 091 092 /* 093 * Data for SMBus Messages 094 */ 095 public static int I2C_SMBUS_BLOCK_MAX = 32; /* As specified in SMBus standard */ 096 097 /* i2c_smbus_xfer read or write markers */ 098 public static int I2C_SMBUS_READ = 1; 099 public static int I2C_SMBUS_WRITE = 0; 100 101 /* SMBus transaction types (size parameter in the above functions) 102 Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */ 103 public static int I2C_SMBUS_QUICK = 0; 104 public static int I2C_SMBUS_BYTE = 1; 105 public static int I2C_SMBUS_BYTE_DATA = 2; 106 public static int I2C_SMBUS_WORD_DATA = 3; 107 public static int I2C_SMBUS_PROC_CALL = 4; 108 public static int I2C_SMBUS_BLOCK_DATA = 5; 109 public static int I2C_SMBUS_I2C_BLOCK_BROKEN= 6; 110 public static int I2C_SMBUS_BLOCK_PROC_CALL = 7; /* SMBus 2.0 */ 111 public static int I2C_SMBUS_I2C_BLOCK_DATA = 8; 112 113 public static int I2C_RETRIES = 0x0701; /* number of times a device address should 114 be polled when not acknowledging */ 115 public static int I2C_TIMEOUT = 0x0702; /* set timeout in units of 10 ms */ 116 117 /* NOTE: Slave address is 7 or 10 bits, but 10-bit addresses 118 * are NOT supported! (due to code brokenness) 119 */ 120 public static int I2C_SLAVE = 0x0703; /* Use this slave address */ 121 public static int I2C_SLAVE_FORCE = 0x0706; /* Use this slave address, even if it 122 is already in use by a driver! */ 123 public static int I2C_TENBIT = 0x0704; /* 0 for 7 bit addrs, != 0 for 10 bit */ 124 125 public static int I2C_FUNCS = 0x0705; /* Get the adapter functionality mask */ 126 127 public static int I2C_RDWR = 0x0707; /* Combined R/W transfer (one STOP only) */ 128 129 public static int I2C_PEC = 0x0708; /* != 0 to use PEC with SMBus */ 130 public static int I2C_SMBUS = 0x0720; /* SMBus transfer */ 131}