Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created a I2C API definition in i2c/api.h to allow the example code to access I2C using a standard interface #19

Open
wants to merge 1 commit into
base: linux-descriptors
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions include/i2c/api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/** \file include/i2c/api.h
* This file is for defining a common API for accessing I2C.
**/

#ifndef I2C_API_H
#define I2C_API_H

#include "fx2types.h"
#include "stdarg.h"

/**
* \brief Initalizes I2C.
* Returns TRUE if initialization is successful.
**/
BOOL i2cX_init(enum i2c_speed speed, ...);

/**
* enum Standard available i2c speeds.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments from the uart enum apply here...

*
**/
enum i2c_speed {
HIGH_SPEED = -2,
FULL_SPEED = -1,
SPEED_INVALID = 0,
SPEED_FASTEST = 1,
SPEED_FX2 = 2
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is SPEED_FX2?

};

/**
* \brief Sets the i2c_speed to one of the allowed parameters.
* Possible I2C speeds:
* \li HIGH_SPEED (not supported)
* \li FULL_SPEED (not supported)
* \li SPEED_INVALID
* \li SPEED_FASTEST
* \li SPEED_FX2 (currently supported)
* Returns TRUE if successful.
**/
BOOL i2cX_set_speed(enum i2c_speed speed);

/**
* \brief Returns the i2c_speed currently being used.
**/
enum i2c_speed i2cX_get_speed();

/**
* \brief Transmits data through I2C.
* \param c The character to be sent out.
**/

void i2cX_tx(char c);

/**
* \brief Returns if the transmit is blocking or not.
* FALSE - Non Blocking
* TRUE - Blocking
**/

BOOL i2cX_tx_will_block();

/**
* \brief Returns how many more bytes can be loaded into the buffer.
**/
BYTE i2cX_tx_queue_len();

/**
* \brief Receives data through I2C.
* Returns one byte at a time from the queue.
*
**/
char i2cX_rx();

/**
* \brief Returns if the receive is blocking or not.
* FALSE - Non Blocking
* TRUE - Blocking
**/
BOOL i2cX_rx_will_block();

/**
* \brief Returns count number of bytes present in the buffer.
*
**/
BYTE i2cX_rx_queue_len();

#endif