PSoC-FDC1004Q
PSoC FDC1004Q Library
Enumerations | Functions
I2C_Interface.h File Reference

Hardware specific I2C interface. More...

#include "cytypes.h"

Go to the source code of this file.

Enumerations

enum  I2C_ErrorCode { I2C_NO_ERROR, I2C_ERROR }
 Error codes returned by the I2C Functions. More...
 
enum  I2C_Connection { I2C_DEV_CONNECTED, I2C_DEV_UNCONNECTED }
 Values returned to determine if device connected or not. More...
 

Functions

I2C_ErrorCode I2C_Peripheral_Start (void)
 Start the I2C peripheral. More...
 
I2C_ErrorCode I2C_Peripheral_Stop (void)
 Stop the I2C peripheral. More...
 
I2C_ErrorCode I2C_Peripheral_ReadRegister (uint8_t device_address, uint8_t register_address, uint8_t *data)
 Read one byte over I2C. More...
 
I2C_ErrorCode I2C_Peripheral_ReadRegisterMulti (uint8_t device_address, uint8_t register_address, uint8_t register_count, uint8_t *data)
 Read multiple bytes over I2C. More...
 
I2C_ErrorCode I2C_Peripheral_WriteRegister (uint8_t device_address, uint8_t register_address, uint8_t data)
 Write a byte over I2C. More...
 
I2C_ErrorCode I2C_Peripheral_WriteRegisterMulti (uint8_t device_address, uint8_t register_address, uint8_t register_count, uint8_t *data)
 Write multiple bytes over I2C. More...
 
I2C_ErrorCode I2C_Peripheral_WriteRegisterNoData (uint8_t device_address, uint8_t register_address)
 Write single byte over I2C. More...
 
I2C_ErrorCode I2C_Peripheral_IsDeviceConnected (uint8_t device_address, I2C_Connection *connection)
 Check if device is connected over I2C. More...
 

Detailed Description

Hardware specific I2C interface.

This is an interface to the I2C peripheral. If you need to port this C-code to another platform, you could simply replace this interface and still use the code.

Author
Davide Marzorati
Date
September 12, 2019

Definition in file I2C_Interface.h.

Enumeration Type Documentation

Values returned to determine if device connected or not.

Enumerator
I2C_DEV_CONNECTED 

Device is connected

I2C_DEV_UNCONNECTED 

Device is not connected on the bus

Definition at line 33 of file I2C_Interface.h.

Error codes returned by the I2C Functions.

Enumerator
I2C_NO_ERROR 

No error occurred during I2C communication

I2C_ERROR 

An error occurred during I2C communication

Definition at line 22 of file I2C_Interface.h.

Function Documentation

I2C_ErrorCode I2C_Peripheral_IsDeviceConnected ( uint8_t  device_address,
I2C_Connection connection 
)

Check if device is connected over I2C.

This function checks if a device is connected over the I2C lines.

Parameters
device_addressI2C address of the device to be checked.
connectionpointer where the connection status will be stored
Returns
I2C_ErrorCode error code value

Definition at line 204 of file I2C_Interface.c.

I2C_ErrorCode I2C_Peripheral_ReadRegister ( uint8_t  device_address,
uint8_t  register_address,
uint8_t *  data 
)

Read one byte over I2C.

This function performs a complete reading operation over I2C from a single register.

Parameters
device_addressI2C address of the device to talk to.
register_addressAddress of the register to be read.
dataPointer to a variable where the byte will be saved.
Returns
I2C_ErrorCode error code value

Definition at line 41 of file I2C_Interface.c.

I2C_ErrorCode I2C_Peripheral_ReadRegisterMulti ( uint8_t  device_address,
uint8_t  register_address,
uint8_t  register_count,
uint8_t *  data 
)

Read multiple bytes over I2C.

This function performs a complete reading operation over I2C from multiple registers.

Parameters
device_addressI2C address of the device to talk to.
register_addressAddress of the first register to be read.
register_countNumber of registers we want to read.
dataPointer to an array where data will be saved.
Returns
I2C_ErrorCode error code value

Definition at line 71 of file I2C_Interface.c.

I2C_ErrorCode I2C_Peripheral_Start ( void  )

Start the I2C peripheral.

This function starts the I2C peripheral so that it is ready to work.

Returns
I2C_ErrorCode error code value

Definition at line 23 of file I2C_Interface.c.

I2C_ErrorCode I2C_Peripheral_Stop ( void  )

Stop the I2C peripheral.

This function stops the I2C peripheral from working.

Returns
I2C_ErrorCode error code value

Definition at line 33 of file I2C_Interface.c.

I2C_ErrorCode I2C_Peripheral_WriteRegister ( uint8_t  device_address,
uint8_t  register_address,
uint8_t  data 
)

Write a byte over I2C.

This function performs a complete writing operation over I2C to a single register.

Parameters
device_addressI2C address of the device to talk to.
register_addressAddress of the register to be written.
dataData to be written
Returns
I2C_ErrorCode error code value

Definition at line 112 of file I2C_Interface.c.

I2C_ErrorCode I2C_Peripheral_WriteRegisterMulti ( uint8_t  device_address,
uint8_t  register_address,
uint8_t  register_count,
uint8_t *  data 
)

Write multiple bytes over I2C.

This function performs a complete writing operation over I2C to multiple registers

Parameters
device_addressI2C address of the device to talk to.
register_addressAddress of the first register to be written.
register_countNumber of registers that need to be written.
dataArray of data to be written
Returns
I2C_ErrorCode error code value

Definition at line 165 of file I2C_Interface.c.

I2C_ErrorCode I2C_Peripheral_WriteRegisterNoData ( uint8_t  device_address,
uint8_t  register_address 
)

Write single byte over I2C.

This function performs a complete writing operation over I2C to multiple registers

Parameters
device_addressI2C address of the device to talk to.
register_addressAddress of the first register to be written.
Returns
I2C_ErrorCode error code value

Definition at line 141 of file I2C_Interface.c.