forked from djmuhlestein/fx2lib
-
Notifications
You must be signed in to change notification settings - Fork 6
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
RacingTornado
wants to merge
1
commit into
mithro:linux-descriptors
Choose a base branch
from
RacingTornado:merge_i2c_api
base: linux-descriptors
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
* | ||
**/ | ||
enum i2c_speed { | ||
HIGH_SPEED = -2, | ||
FULL_SPEED = -1, | ||
SPEED_INVALID = 0, | ||
SPEED_FASTEST = 1, | ||
SPEED_FX2 = 2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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...