Home | History | Annotate | Download | only in Library
      1 /** @file
      2 
      3 Intel I2C library implementation built upon I/O library
      4 
      5 
      6 Copyright (c) 2013-2015 Intel Corporation.
      7 
      8 This program and the accompanying materials
      9 are licensed and made available under the terms and conditions of the BSD License
     10 which accompanies this distribution.  The full text of the license may be found at
     11 http://opensource.org/licenses/bsd-license.php
     12 
     13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     15 
     16 **/
     17 
     18 #ifndef _I2C_LIB_H_
     19 #define _I2C_LIB_H_
     20 
     21 #include "I2cRegs.h"
     22 
     23 /**
     24 
     25   The I2cWriteByte() function is a wrapper function for the WriteByte() function.
     26   Provides a standard way to execute a standard single byte write to an IC2 device
     27   (without accessing sub-addresses), as defined in the I2C Specification.
     28 
     29   @param SlaveAddress The I2C slave address of the device
     30                       with which to communicate.
     31 
     32   @param AddrMode     I2C Addressing Mode: 7-bit or 10-bit address.
     33 
     34   @param Buffer       Contains the value of byte data to execute to the
     35                       I2C slave device.
     36 
     37 
     38   @retval EFI_SUCCESS           Transfer success.
     39   @retval EFI_INVALID_PARAMETER  This or Buffer pointers are invalid.
     40   @retval EFI_TIMEOUT           Timeout while waiting xfer.
     41   @retval EFI_ABORTED           Controller aborted xfer.
     42   @retval EFI_DEVICE_ERROR      Device error detected by controller.
     43 
     44 **/
     45 EFI_STATUS
     46 EFIAPI
     47 I2cWriteByte (
     48   IN        EFI_I2C_DEVICE_ADDRESS  SlaveAddress,
     49   IN        EFI_I2C_ADDR_MODE       AddrMode,
     50   IN OUT VOID                       *Buffer
     51   );
     52 
     53 /**
     54 
     55   The I2cReadByte() function is a wrapper function for the ReadByte() function.
     56   Provides a standard way to execute a standard single byte read to an I2C device
     57   (without accessing sub-addresses), as defined in the I2C Specification.
     58 
     59   @param SlaveAddress The I2C slave address of the device
     60                       with which to communicate.
     61 
     62   @param AddrMode     I2C Addressing Mode: 7-bit or 10-bit address.
     63 
     64   @param Buffer       Contains the value of byte data read from the
     65                       I2C slave device.
     66 
     67 
     68   @retval EFI_SUCCESS           Transfer success.
     69   @retval EFI_INVALID_PARAMETER This or Buffer pointers are invalid.
     70   @retval EFI_TIMEOUT           Timeout while waiting xfer.
     71   @retval EFI_ABORTED           Controller aborted xfer.
     72   @retval EFI_DEVICE_ERROR      Device error detected by controller.
     73 
     74 **/
     75 EFI_STATUS
     76 EFIAPI
     77 I2cReadByte (
     78   IN        EFI_I2C_DEVICE_ADDRESS  SlaveAddress,
     79   IN        EFI_I2C_ADDR_MODE       AddrMode,
     80   IN OUT VOID                       *Buffer
     81   );
     82 
     83 /**
     84 
     85   The I2cWriteMultipleByte() function is a wrapper function for the WriteMultipleByte()
     86   function. Provides a standard way to execute multiple byte writes to an I2C device (e.g. when
     87   accessing sub-addresses or writing block of data), as defined in the I2C Specification.
     88 
     89   @param SlaveAddress The I2C slave address of the device
     90                       with which to communicate.
     91 
     92   @param AddrMode     I2C Addressing Mode: 7-bit or 10-bit address.
     93 
     94   @param Length       No. of bytes to be written.
     95 
     96   @param Buffer       Contains the value of byte to be written to the
     97                       I2C slave device.
     98 
     99   @retval EFI_SUCCESS            Transfer success.
    100   @retval EFI_INVALID_PARAMETER  This, Length or Buffer pointers are invalid.
    101   @retval EFI_UNSUPPORTED        Unsupported input param.
    102   @retval EFI_TIMEOUT            Timeout while waiting xfer.
    103   @retval EFI_ABORTED            Controller aborted xfer.
    104   @retval EFI_DEVICE_ERROR       Device error detected by controller.
    105 
    106 **/
    107 EFI_STATUS
    108 EFIAPI
    109 I2cWriteMultipleByte (
    110   IN        EFI_I2C_DEVICE_ADDRESS  SlaveAddress,
    111   IN        EFI_I2C_ADDR_MODE       AddrMode,
    112   IN UINTN                          *Length,
    113   IN OUT VOID                       *Buffer
    114   );
    115 
    116 /**
    117 
    118   The I2cReadMultipleByte() function is a wrapper function for the ReadMultipleByte
    119   function. Provides a standard way to execute multiple byte writes to an IC2 device
    120   (e.g. when accessing sub-addresses or when reading block of data), as defined
    121   in the I2C Specification (I2C combined write/read protocol).
    122 
    123   @param SlaveAddress The I2C slave address of the device
    124                       with which to communicate.
    125 
    126   @param AddrMode     I2C Addressing Mode: 7-bit or 10-bit address.
    127 
    128   @param WriteLength  No. of bytes to be written. In this case data
    129                       written typically contains sub-address or sub-addresses
    130                       in Hi-Lo format, that need to be read (I2C combined
    131                       write/read protocol).
    132 
    133   @param ReadLength   No. of bytes to be read from I2C slave device.
    134                       need to be read.
    135 
    136   @param Buffer       Contains the value of byte data read from the
    137                       I2C slave device.
    138 
    139   @retval EFI_SUCCESS            Transfer success.
    140   @retval EFI_INVALID_PARAMETER  This, WriteLength, ReadLength or Buffer
    141                                  pointers are invalid.
    142   @retval EFI_UNSUPPORTED        Unsupported input param.
    143   @retval EFI_TIMEOUT            Timeout while waiting xfer.
    144   @retval EFI_ABORTED            Controller aborted xfer.
    145   @retval EFI_DEVICE_ERROR       Device error detected by controller.
    146 
    147 **/
    148 EFI_STATUS
    149 EFIAPI
    150 I2cReadMultipleByte (
    151   IN        EFI_I2C_DEVICE_ADDRESS  SlaveAddress,
    152   IN        EFI_I2C_ADDR_MODE       AddrMode,
    153   IN UINTN                          *WriteLength,
    154   IN UINTN                          *ReadLength,
    155   IN OUT VOID                       *Buffer
    156   );
    157 
    158 #endif
    159