hc
2024-03-22 a0752693d998599af469473b8dc239ef973a012f
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/** @file
 
Intel I2C library implementation built upon I/O library
 
 
Copyright (c) 2013-2015 Intel Corporation.
 
SPDX-License-Identifier: BSD-2-Clause-Patent
 
**/
 
#ifndef _I2C_LIB_H_
#define _I2C_LIB_H_
 
#include "I2cRegs.h"
 
/**
 
  The I2cWriteByte() function is a wrapper function for the WriteByte() function.
  Provides a standard way to execute a standard single byte write to an IC2 device
  (without accessing sub-addresses), as defined in the I2C Specification.
 
  @param SlaveAddress The I2C slave address of the device
                      with which to communicate.
 
  @param AddrMode     I2C Addressing Mode: 7-bit or 10-bit address.
 
  @param Buffer       Contains the value of byte data to execute to the
                      I2C slave device.
 
 
  @retval EFI_SUCCESS           Transfer success.
  @retval EFI_INVALID_PARAMETER  This or Buffer pointers are invalid.
  @retval EFI_TIMEOUT           Timeout while waiting xfer.
  @retval EFI_ABORTED           Controller aborted xfer.
  @retval EFI_DEVICE_ERROR      Device error detected by controller.
 
**/
EFI_STATUS
EFIAPI
I2cWriteByte (
  IN        EFI_I2C_DEVICE_ADDRESS  SlaveAddress,
  IN        EFI_I2C_ADDR_MODE       AddrMode,
  IN OUT VOID                       *Buffer
  );
 
/**
 
  The I2cReadByte() function is a wrapper function for the ReadByte() function.
  Provides a standard way to execute a standard single byte read to an I2C device
  (without accessing sub-addresses), as defined in the I2C Specification.
 
  @param SlaveAddress The I2C slave address of the device
                      with which to communicate.
 
  @param AddrMode     I2C Addressing Mode: 7-bit or 10-bit address.
 
  @param Buffer       Contains the value of byte data read from the
                      I2C slave device.
 
 
  @retval EFI_SUCCESS           Transfer success.
  @retval EFI_INVALID_PARAMETER This or Buffer pointers are invalid.
  @retval EFI_TIMEOUT           Timeout while waiting xfer.
  @retval EFI_ABORTED           Controller aborted xfer.
  @retval EFI_DEVICE_ERROR      Device error detected by controller.
 
**/
EFI_STATUS
EFIAPI
I2cReadByte (
  IN        EFI_I2C_DEVICE_ADDRESS  SlaveAddress,
  IN        EFI_I2C_ADDR_MODE       AddrMode,
  IN OUT VOID                       *Buffer
  );
 
/**
 
  The I2cWriteMultipleByte() function is a wrapper function for the WriteMultipleByte()
  function. Provides a standard way to execute multiple byte writes to an I2C device (e.g. when
  accessing sub-addresses or writing block of data), as defined in the I2C Specification.
 
  @param SlaveAddress The I2C slave address of the device
                      with which to communicate.
 
  @param AddrMode     I2C Addressing Mode: 7-bit or 10-bit address.
 
  @param Length       No. of bytes to be written.
 
  @param Buffer       Contains the value of byte to be written to the
                      I2C slave device.
 
  @retval EFI_SUCCESS            Transfer success.
  @retval EFI_INVALID_PARAMETER  This, Length or Buffer pointers are invalid.
  @retval EFI_UNSUPPORTED        Unsupported input param.
  @retval EFI_TIMEOUT            Timeout while waiting xfer.
  @retval EFI_ABORTED            Controller aborted xfer.
  @retval EFI_DEVICE_ERROR       Device error detected by controller.
 
**/
EFI_STATUS
EFIAPI
I2cWriteMultipleByte (
  IN        EFI_I2C_DEVICE_ADDRESS  SlaveAddress,
  IN        EFI_I2C_ADDR_MODE       AddrMode,
  IN UINTN                          *Length,
  IN OUT VOID                       *Buffer
  );
 
/**
 
  The I2cReadMultipleByte() function is a wrapper function for the ReadMultipleByte
  function. Provides a standard way to execute multiple byte writes to an IC2 device
  (e.g. when accessing sub-addresses or when reading block of data), as defined
  in the I2C Specification (I2C combined write/read protocol).
 
  @param SlaveAddress The I2C slave address of the device
                      with which to communicate.
 
  @param AddrMode     I2C Addressing Mode: 7-bit or 10-bit address.
 
  @param WriteLength  No. of bytes to be written. In this case data
                      written typically contains sub-address or sub-addresses
                      in Hi-Lo format, that need to be read (I2C combined
                      write/read protocol).
 
  @param ReadLength   No. of bytes to be read from I2C slave device.
                      need to be read.
 
  @param Buffer       Contains the value of byte data read from the
                      I2C slave device.
 
  @retval EFI_SUCCESS            Transfer success.
  @retval EFI_INVALID_PARAMETER  This, WriteLength, ReadLength or Buffer
                                 pointers are invalid.
  @retval EFI_UNSUPPORTED        Unsupported input param.
  @retval EFI_TIMEOUT            Timeout while waiting xfer.
  @retval EFI_ABORTED            Controller aborted xfer.
  @retval EFI_DEVICE_ERROR       Device error detected by controller.
 
**/
EFI_STATUS
EFIAPI
I2cReadMultipleByte (
  IN        EFI_I2C_DEVICE_ADDRESS  SlaveAddress,
  IN        EFI_I2C_ADDR_MODE       AddrMode,
  IN UINTN                          *WriteLength,
  IN UINTN                          *ReadLength,
  IN OUT VOID                       *Buffer
  );
 
#endif