-
Notifications
You must be signed in to change notification settings - Fork 3k
RFC HAL I2C: Reference implementations for K64F and STM32F0 #8682
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
Closed
Closed
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
70d329d
docs(hal-i2c): Add initial design document for the I2C HAL API overhaul
1f70325
docs(hal-i2c): Add modifications for timeout and multimaster support
6453cbc
docs(hal-i2c): Update the RFC to reflect removing the DMAUsage parameter
6d2162c
docs(hal-i2c): Add missing stop and last parameters to i2c_read/write
846658a
docs(hal-i2c): Move address parameter into a seperate i2c_slave function
52ca16c
docs(hal-i2c): Add additional defined function behaviours
28e4f05
docs(hal-i2c): Make additional amendments to I2C API specification
d2ed736
docs(hal-i2c): Add additional notes to synchronous read/write
b2db175
docs(hal-i2c): Add clock stretching field to target capabilities
4a88ec4
docs(hal-i2c): Add context pointer to async transfer function
76e954c
docs(hal-i2c): Fix return type of i2c_frequency function
0f3cba4
docs(hal-i2c): Move design document to the updated folder
280ffce
docs(hal-i2c): Update design document to match recent API alterations
459097e
feat(hal-i2c): Disable I2C on all targets in preparation
6a51a72
feat(hal-i2c): Update the HAL I2C header file to new API
c681eeb
feat(hal-i2c): Update I2C driver API to new specification
2118993
feat(hal-i2c): Add synchronous HAL I2C implementation for K64F
8322216
feat(hal-i2c): Add synchronous HAL I2C implementation for STM32
9b54bc0
feat(hal-i2c): Remove unused DMAUsage member from I2C class
79185d3
feat(hal-i2c): Add asynchronous HAL I2C implementation for STM32
b8fce70
fix(hal-i2c): Fix issue with master byte read/write failing on K64F
5722179
fix(hal-i2c): Add missing i2c_free function to API
0272127
fix(hal-i2c): Fix incorrect minimum frequency in STM I2C implementation
a7ce674
fix(hal-i2c): Fix STM implementation calling event handler too early
e837039
refactor(hal-i2c): Rename HAL slave status enum to match Driver API
2d0d952
fix(hal-i2c): Return the correct number of transferred bytes in STM32
1510f5a
fix(hal-i2c): Fix incorrect byte counts during aborted R/W transfers
42cd01c
refactor(hal-i2c): Change STOP function to return success or failure
e82a475
fix(hal-i2c): Add missing semicolon to STM32 I2C attribute 'tx_count'
16b41dd
fix(hal-i2c): STM: Return the num of bytes sent for incomplete transfers
75909df
refactor(hal-i2c): Remove return status from I2C start/stop functions
837cf18
fix(hal-i2c): STM: Fix frequency function checking the wrong variable
9c6f7fd
style(hal-i2c): STM: Remove empty comment block from code
1c26c91
fix(hal-i2c): STM: Add missing return statement when re-initing as slave
3887f85
refactor(hal-i2c): Add an API function to configure clock stretching
216b1f3
refactor(hal-i2c): Remove i2c_timeout function from the API
77e0cba
style(hal-i2c): Fix astyle code formatting failures
4bda684
fix(hal-i2c): K64F: Ignore calls to set slave address in master mode
c2390bb
fix(hal-i2c): Disable `I2CSLAVE` feature flag on K64F devices
19ae834
fix(hal-i2c): Return the num bytes transferred in STM slave read/write
51fc969
fix(hal-i2c): Disable slave mode and 10-bit from I2C capabilities on K64
c57fb11
fix(hal-i2c): Disable 10-bit addressing I2C capabilities on STM32
d150905
fix(hal-i2c): Fix compiler warning from unused variable on STM32
c1ba83f
fix(hal-i2c): Fix return value for transfers that timeout in STM
7d9de66
rebase fixes
maciejbocianski 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
|
@@ -22,9 +22,8 @@ namespace mbed { | |
|
||
I2CSlave::I2CSlave(PinName sda, PinName scl) : _i2c() | ||
{ | ||
i2c_init(&_i2c, sda, scl); | ||
i2c_init(&_i2c, sda, scl, true); | ||
i2c_frequency(&_i2c, 100000); | ||
i2c_slave_mode(&_i2c, 1); | ||
} | ||
|
||
void I2CSlave::frequency(int hz) | ||
|
@@ -35,39 +34,43 @@ void I2CSlave::frequency(int hz) | |
void I2CSlave::address(int address) | ||
{ | ||
int addr = (address & 0xFF) | 1; | ||
i2c_slave_address(&_i2c, 0, addr, 0); | ||
|
||
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. The line: |
||
i2c_slave_address(&_i2c, addr); | ||
} | ||
|
||
int I2CSlave::receive(void) | ||
{ | ||
return i2c_slave_receive(&_i2c); | ||
return i2c_slave_status(&_i2c); | ||
} | ||
|
||
int I2CSlave::read(char *data, int length) | ||
{ | ||
return i2c_slave_read(&_i2c, data, length) != length; | ||
return i2c_read(&_i2c, 0, data, length, false) != length; | ||
} | ||
|
||
int I2CSlave::read(void) | ||
{ | ||
return i2c_byte_read(&_i2c, 0); | ||
int ret; | ||
i2c_read(&_i2c, 0, &ret, 1, false); | ||
|
||
return ret; | ||
} | ||
|
||
int I2CSlave::write(const char *data, int length) | ||
{ | ||
return i2c_slave_write(&_i2c, data, length) != length; | ||
return i2c_write(&_i2c, 0, data, length, false) != length; | ||
} | ||
|
||
int I2CSlave::write(int data) | ||
{ | ||
return i2c_byte_write(&_i2c, data); | ||
return i2c_write(&_i2c, 0, (void *)&data, 1, false); | ||
} | ||
|
||
void I2CSlave::stop(void) | ||
{ | ||
i2c_stop(&_i2c); | ||
} | ||
|
||
} | ||
} // namespace mbed | ||
|
||
#endif | ||
#endif // DEVICE_I2CSLAVE |
This file contains hidden or 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
Oops, something went wrong.
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.
I think that shouldn't be empty!