stm32l1/i2c.c: adapt for new i2c periph driver interface#4096
stm32l1/i2c.c: adapt for new i2c periph driver interface#4096thomaseichinger merged 1 commit intoRIOT-OS:masterfrom
Conversation
|
@ReneHerthel Great, would you mind also taking care of |
|
@thomaseichinger This board should work with the same driver, or am I wrong? Or did you just mean I should test it with a |
|
@ReneHerthel I'm sorry I was not clear, I meant to also adopt |
|
@thomaseichinger Ah, okey :-). Only for I2C? I see there are only definitions for I2C_0 but not for I2C_1. I think I can adapt that, but I need a |
|
That would be really great if you could add |
|
@thomaseichinger Think you can test it now. |
|
Ok great, one proposal: What do you think about changing the current approach to something like the UART configuration for the samr21-xpro board. Defining something comparable to |
|
@thomaseichinger Sounds really interesting! I'll look at it later :-) think it could be a good idea |
|
@thomaseichinger Adapt, think this change makes sense :-) |
|
|
|
@thomaseichinger may I assign you? |
There was a problem hiding this comment.
Could you add a small comment that says which pin is which?
fbf24c9 to
4d18bea
Compare
|
Rebase. |
|
@thomaseichinger I don't know how to add a mutex to the constant i2c_cfg array, any ideas? I adapt the other things. |
cpu/stm32l1/include/periph_cpu.h
Outdated
There was a problem hiding this comment.
@ReneHerthel you could add:
mutex_t mtx; /**< i2c config mutex */here, and change the initialization of the config array [1] by appending the static mutex initializer MUTEX_INIT, e.g.:
{I2C2, GPIO_PIN(PORT_B, 10), GPIO_PIN(PORT_B, 11), 4,
I2C2_EV_IRQn, I2C2_ER_IRQn, RCC_APB1ENR_I2C2EN, MUTEX_INIT},(though this is untested, so don't know if this works)
There was a problem hiding this comment.
@BytesGalore Yes I already tried this, but I got an error like: the i2c_cfg is constant and the Mutex is not.
There was a problem hiding this comment.
@ReneHerthel The following is untested but semantically it should be what we want:
typedef struct {
const I2C_TypeDef *dev; /**< pointer to the used I2C device */
const gpio_t scl_pin; /**< pin used for SCL */
...
mutex_t mutex;
} i2c_conf_t;and
static i2c_conf_t i2c_cfg[] = {
{I2C2, GPIO_PIN(PORT_B, 10), GPIO_PIN(PORT_B, 11), 4,
I2C2_EV_IRQn, I2C2_ER_IRQn, RCC_APB1ENR_I2C2EN, MUTEX_INIT},
...
}There was a problem hiding this comment.
@thomaseichinger hmm okey. I'll Change that :)
|
@thomaseichinger can you please have a look at this? It would be really comfortable to merge this asap so we can test #3495 and #3263 |
|
@PeterKietzmann I will have a look on the code, but I can't test for the next one and a half weeks as I don't have access to l1 board. Are #3495 and #3263 urgent? |
|
Well, once your're happy with the code, we can test it here. The mentioned PRs are not urgent but I don't want Rene to lose his motivation ;-) |
|
@thomaseichinger Hmm I can compile that, don't know why, but okey! :-), think I did something wrong.. Thanks, it should work now. BTW: I had to include mutex.h in periph_cpu.h, dont know if that is okey. |
|
@ReneHerthel It did compile because you where not using the mutex in |
|
@thomaseichinger Check. |
|
@katezilla you need this PR for testing #3495 and #3263. Will you voluntary also take over this one :-D ? Thomas already did a code review. It's more about testing |
|
yes, i can test it also |
|
@katezilla any news? :-) I thought you can test the limifrog drivers only with this here? |
|
@ReneHerthel as we discussed yesterday: please squash! AFAIK you and @katezilla successfully tested your PR |
59f7522 to
cf0c49f
Compare
|
rebase. |
cf0c49f to
f4c7cbe
Compare
|
@PeterKietzmann @katezilla It is squashed now. |
eaae573 to
a7a0922
Compare
a7a0922 to
e9215a6
Compare
|
We needed to put this again to the periph_conf, to satisfy travis: @thomaseichinger ( @haukepetersen ) are you fine this way?! |
|
BTW: Travis is green. So if you agree, we can merge this instantly |
|
ACK & Go |
stm32l1/i2c.c: adapt for new i2c periph driver interface
|
I wonder if this PR works? Seems broken: The pins are defined as i2c_cfg[] = {... GPIO_PIN(PORT_B, 8)}now the _pin_config(dev, GPIOB, i2c_cfg[dev].scl_pin, i2c_cfg[dev].sda_pin);So |
|
@ReneHerthel, @katezilla you told me your tests were successful, didn't you? Anyway, what you say seems logic, I will check... |
|
Yes we tested it with the nucleo-l1 and a ultrasound Sensor, it worked fine. |
Adaptation of the stm32l1/I2C driver for the optimized Interface