WPILibC++  2018.4.1-20180729040223-1137-g011f0ff
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
I2C.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <stdint.h>
11 
12 #include "hal/Types.h"
13 
14 // clang-format off
15 HAL_ENUM(HAL_I2CPort) { HAL_I2C_kOnboard = 0, HAL_I2C_kMXP };
16 // clang-format on
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
30 void HAL_InitializeI2C(HAL_I2CPort port, int32_t* status);
31 
45 int32_t HAL_TransactionI2C(HAL_I2CPort port, int32_t deviceAddress,
46  const uint8_t* dataToSend, int32_t sendSize,
47  uint8_t* dataReceived, int32_t receiveSize);
48 
61 int32_t HAL_WriteI2C(HAL_I2CPort port, int32_t deviceAddress,
62  const uint8_t* dataToSend, int32_t sendSize);
63 
78 int32_t HAL_ReadI2C(HAL_I2CPort port, int32_t deviceAddress, uint8_t* buffer,
79  int32_t count);
80 
86 void HAL_CloseI2C(HAL_I2CPort port);
87 #ifdef __cplusplus
88 } // extern "C"
89 #endif