WPILibC++  2019.1.1-beta-4-15-g8ac4b11
 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/I2CTypes.h"
13 #include "hal/Types.h"
14 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
33 void HAL_InitializeI2C(HAL_I2CPort port, int32_t* status);
34 
48 int32_t HAL_TransactionI2C(HAL_I2CPort port, int32_t deviceAddress,
49  const uint8_t* dataToSend, int32_t sendSize,
50  uint8_t* dataReceived, int32_t receiveSize);
51 
64 int32_t HAL_WriteI2C(HAL_I2CPort port, int32_t deviceAddress,
65  const uint8_t* dataToSend, int32_t sendSize);
66 
81 int32_t HAL_ReadI2C(HAL_I2CPort port, int32_t deviceAddress, uint8_t* buffer,
82  int32_t count);
83 
89 void HAL_CloseI2C(HAL_I2CPort port);
90 #ifdef __cplusplus
91 } // extern "C"
92 #endif
93 
int32_t HAL_TransactionI2C(HAL_I2CPort port, int32_t deviceAddress, const uint8_t *dataToSend, int32_t sendSize, uint8_t *dataReceived, int32_t receiveSize)
Generic I2C read/write transaction.
void HAL_CloseI2C(HAL_I2CPort port)
Closes an I2C port.
int32_t HAL_WriteI2C(HAL_I2CPort port, int32_t deviceAddress, const uint8_t *dataToSend, int32_t sendSize)
Executes a write transaction with the device.
void HAL_InitializeI2C(HAL_I2CPort port, int32_t *status)
Initializes the I2C port.
int32_t HAL_ReadI2C(HAL_I2CPort port, int32_t deviceAddress, uint8_t *buffer, int32_t count)
Executes a read transaction with the device.