-
Notifications
You must be signed in to change notification settings - Fork 3k
Added I2CSlave support for lpc812 #881
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
Conversation
Added support for I2C Slave block read, block write and byte read and write. The slave address can be set and the general call address is automatically enabled. Note that the lpc812, lpc824 and lpc1549 have the same I2C engine. This new engine is very different from the lpc1768 and other NXP mbeds. The newer engine has separate controls for Master and Slave functions and they can be enable at the same time. Note that currently the lib does not support multi-master (arbitration lost is not handled).
Added i2c_slave_byte_read() and i2c_slave_byte_write() for devices such as the lpc812, lpc824 and lpc1549 that have separate I2C engines for Master and Slave functions.
The dedicated I2C Slave byte read and byte write functions need to be called from 'common' mbed I2CSlave API for devices that have separate Master and Slave engines such as the lpc812 and lpc1549.
This proves that there should be slave read/write. I suggest creating new functions in HAL, as you did, but for all targets. So the i2c slave class invokes them and there's not specific target keywords there. You can edit this PR - leave implementation for lpc812 slave (file libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/i2c_api.c, the other 2 files - revert changes), send a new pull request with modifications to introduce slave read/write, and enable slave for this target. What do u think? |
Hi Martin, I agree that we should have the new slave functions for all targets and get int i2c_slave_byte_read(i2c_t *obj, int last); int i2c_slave_byte_write(i2c_t *obj, int data); It should not be too difficult to do as it can be a wrapper around the I also think that transition should best be done after some However, perhaps I misunderstand your proposal, so I am OK with any better Regards, Wim From: Martin Kojtal [mailto:[email protected]] This proves that there should be slave read/write. I suggest creating new You can edit this PR - leave implementation for lpc812 slave (file What do u think? Reply to this email directly or view it |
Fixed SystemCoreClock calculation for LPC810 (same as for LPC812). Added MainClock variable for serial_api. Added comments for PLL calculation. Note that SystemCoreClock for LPC810 is still 24MHz rather than rated 30MHz.
My proposal is to keep changes in HAL, the slave implementation, device i2c slave macro set to 0 to disable it, remove macros from I2C slave class. |
Added comments regarding the need for dedicated i2c_slave_byte_write() and i2c_slave_byte_read() functions.
Disabled DEVICE_I2CSLAVE option for LPC812 until the dedicated i2c_slave_byte_read() and i2c_slave_byte_write() functions have been added for all platforms.
Martin, I have removed the lpc812 specific macro in the I2C slave class again, I I have currently disabled the i2c slave in device.h for the lpc812, but in Regards, Wim From: Martin Kojtal [mailto:[email protected]] My proposal is to keep changes in HAL, the slave implementation, device i2c Reply to this email directly or view it |
Ok great, one more thing, to remove those comments from libraries/mbed/common/I2CSlave.cpp file. The code should stay clean, the place for this type of reminders is our issue tracker I created a new issue with the code snippet #896 |
Removed comments again regarding need for dedicated i2c_slave_byte_read() and i2c_slave_byte_read(). This issue is captured in "I2c - slave should have own write/read functions (ARMmbed#896)"
Removed comments in I2CSlave. |
Thanks for cooperating, going to merge it |
The I2C engine on newer devices such as the lpc812, lpc824 and lpc1549 is very different from other mbed NXP devices such as the lpc1768. The newer devices have separate Master and Slave engines. This also means that dedicated I2C Slave byte read and byte write functions need to be called from the 'common' mbed I2CSlave.cpp.