-
Notifications
You must be signed in to change notification settings - Fork 2k
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
cpu/cc2538: add periph/i2c driver #3765
Conversation
@hexluthor, good to see that you're still interested in RIOT and keep contributing. As you may have seen on the mailing list we're currently in feature freeze, so we will probably not be able to merge this within the next two weeks, but getting all the cc2538 stuff you have proposed is definitely a top priority right after the release. |
Thanks @OlegHahm. No rush. I saw the |
0e8d3af
to
878fb87
Compare
@hexluthor I am sorry I didn't respond to this PR recently. I currently can't flash the OpenMote, but I am in contact with the OpenMote people to fix this again. I will test this as soon as I can. |
Hi @hexluthor, I got a CC2838DK here and going to perform HW tests on that platform. For now I'm trying to get used to the components.
Both |
@A-Paul, you're using a SmartRF06 baseboard with CC2538EM daughter board attached, correct? Make sure these jumpers are populated:
Confirm that the power switch in the on position and the USB power source is selected. Try both UARTs:
If you send me a photo of your board, I may be able to identify an issue. Good luck! |
hello! I was wondering if I can ACK this PR using a ReMote http://zolertia.io/product/hardware/re-mote ? |
@PeterKietzmann Yes I have the instruments, I'll try to test it in the following hours |
Nice! While you're at it how about #3842 :-) ? |
Yeah sure, I already asked the people on that PR :-) |
I wrote a small example to test the functionality. The configuration is: The cc2538dk example : #include <stdio.h>
#include <string.h>
#include "periph/i2c.h"
int main(void)
{
char *i2c_message = "This is the i2c working";
uint8_t charLength = strlen(i2c_message);
puts("Hello World!");
printf("You are running RIOT on a(n) %s board.\n", RIOT_BOARD);
printf("This board features a(n) %s MCU.\n", RIOT_MCU);
if (i2c_init_master(I2C_0, I2C_SPEED_NORMAL) == 0) {
printf("Trying to send message \"%s\" with length %d\n", i2c_message, charLength);
if (i2c_write_bytes(I2C_0, 8, i2c_message, charLength) == charLength) {
printf("I2C message successfully sent!\n");
} else {
printf("I2C message not sent!\n");
}
} else {
printf("Error while initializing I2C interface\n");
}
return 0;
} The arduino sketch: #include <Wire.h>
void setup() {
Wire.begin(8); // join i2c bus with address #8
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600); // start serial for output
Serial.println("Starting I2C tests sketch!");
}
void loop() {
delay(100);
}
// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany) {
while (Wire.available()) { // loop through all available bytes
char c = Wire.read(); // receive byte as a character
Serial.print(c); // print the character
}
} This is working if I plug the SmartRF06 board for the first time, then if I push the reset button to resend the message it is not sent showing the error Any thoughts? |
Could you put a logic analyser in parallel to the bus to see the check the signals? I don't know how the Arduino slave implementation behaves. Maybe something with the ACK/NACK synchronization goes wrong after resetting the cc2538 board? E.g. some default configurations of the hardware pins lead to signal toggles on the SCK or SDA pins which the slave device tries to interpret as I2C command? |
One question: Is |
Hi all. Here's a bunch of new commits that make the I2C driver more robust. I cherry-picked them so hopefully nothing got lost. It now depends on the xtimer module, but I don't know how to express this in the Makefile rules. For now, I just add |
Ok I'll try to analyze with the oscilloscope. As I receive the message correctly on the Arduino side, I think it should behave as expected.
I'll try to get a simpler slave i2c device too. |
hi @hexluthor thanks for your commits, I'll test with and give feedback. |
@kYc0o any progress? |
I'm waiting for an i2c hardware for more tests. I'll put the analyser output but everything seems to be ok... |
@hexluthor have you tested this using tests/periph_i2c on some i2c device? I'm currently testing on cc2538dk but it freezes when I initialize the i2c |
If necessary I can do a final check tomorrow, I can test at least in a cc2538dk, but possibly on the other two boards |
I just checked with a cc2538dk and an mpu9150 with a great success! we need to test it in another board? edit: of course, it needs #4878 merged before |
can you change this commit name: Fix i2c_write_regs() ? Just to make travis happy :) |
As #4878 was merged, @hexluthor can you rebase and change the commit message so we can merge this asap? Thanks! |
Rebased and squashed. Thanks! |
|
||
assert_scl(); | ||
|
||
#ifdef MODULE_XTIMER |
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.
Is this still necessary?
@A-Paul, it depends if we want With a perfect I2C bus |
@hexluthor, at first, sorry for the "last minute" intervention. |
AFAIK timer is working ok, I just merged xtimers several days ago, so we can say that xtimer is no more an obstacle. However, if @hexluthor wants a perfect bus, we should avoid it's use. IMO this is a very good and useful implementation, but as @A-Paul said, the ifdef for xtimer it's not needed anymore. So, if you guys agree, we can try to merge this without those ifdefs and try to improve this in the future without any xtimers? |
@kYc0o, @hexluthor I just wanted to prevent a temporary workaround being forgotten. From my side, ACK for this PR in the current state. @kYc0o, do you join? |
I agree, although I'd prefer to remove the |
The I2C driver will work without the xtimer module. With the xtimer module, it becomes more robust and fault-tolerant. The |
OK great, then ACK and merge! |
cpu/cc2538: add periph/i2c driver
Merged without CI? |
CI was green when merged, since several days ago... |
ah sorry |
Tested on
cc2538dk
.