Conversation
|
@ant9000 I tested your PR on my saml21-xpro and an accelerometer (ADXL345) |
|
Can't confirm at present, but on my YARM board I use the PLL (logic was taken from samr21-xpro): https://github.com/ant9000/RIOT/blob/master/boards/yarm/include/periph_conf.h#L32 Maybe the same stuff should apply to saml21-xpro? Antonio |
|
I tried using the same PLL config. Now i2c frequency seems to be around 33kHz. |
|
GCLK->GENCTRL[0] is set to 16Mhz in cpu/saml21/cpu.c (div factor = 0) and this is the clock source of SERCOM2 (used by your I2C) Someone can confirm ? |
|
@dylad took a scope and tested the frequency on my YARM board - with a divisor of 1 it is indeed correct, even if a little bit jittery. I wrongly assumed that the code was correct since the peripheral I've tested it with was working - thanks a lot for pointing this matter out. And I also noticed that PLL defines weren't used at all in SAM L21 initialization... sorry, my fault, again! |
64fc21a to
ed73e98
Compare
cpu/sam0_common/periph/i2c.c
Outdated
|
|
||
| #define SAMD21_I2C_TIMEOUT (65535) | ||
|
|
||
| #define CPU_MODEL_SAML21 (CPU_MODEL_SAML21E18A || CPU_MODEL_SAML21G18A || \ |
There was a problem hiding this comment.
I think you don't need this define, you can use the predefined macro CPU_FAM_SAML21 instead.
|
This PR needs rebase. |
|
@ant9000 Are you still working on it ? |
|
ping @ant9000 |
|
@dylad sorry for not responding for so long. I am currently too busy elsewhere, and unable to keep focus on RIOT development. Can't say when I'll be able to dedicate a non trivial amount of time again - hopefully not too long in the future. Antonio |
|
@ant9000 thanks a lot for informing us :) |
|
The PR stayed there staling for more than a month - probably I was the only one looking for I2C support on this CPU. Unluckily, I'm not anymore in the position to check if my code complies to your other PRs. The patch in itself is really small, if you find it useful you can just copy/paste the code wherever you please and close the PR. Sorry for the time lost, Antonio |
|
I2C on SAML21 should work the same than on SAMR21, is there any difference? Otherwise use i2c from SAMR21 |
|
@biboc There are some differences about clock management between SAMD21 family and SAML21 family. We just need to handle these small differences. We could easily get a shared driver for both family. |
ed73e98 to
ab62e3e
Compare
ab62e3e to
7913d19
Compare
|
@dylad, I allowed myself to directly update this PR with the comments applied. Not sure if it still works. Can you test again (I might have missed something) ? |
|
Thanks @aabadie ! |
|
@aabadie I tested I2C driver with my ADXL345 module, it works perfectly ! |
No description provided.