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