-
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
driver - periph: Extend SPI low-level driver interface #1770
Conversation
port->MODER &= ~(3 << (pin[i] * 2)); | ||
port->MODER |= (2 << (pin[i] * 2)); | ||
int hl = (pin[i] < 8) ? 0 : 1; | ||
port->AFR[hl] &= (0xf << ((pin[i] - (hl * 8)) * 4)); |
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.
To reset the right pins the value should be negated. I corrected this in my pin configuration function.
Probably @haukepetersen should be the right assignee? Also interesting for @PeterKietzmann and @thomaseichinger! |
Okay, I'll add an implementation for the sam3x8e of #1584 as well. |
@@ -97,6 +68,7 @@ int spi_init_master(spi_t dev, spi_conf_t conf, spi_speed_t speed) | |||
break; | |||
case SPI_SPEED_100KHZ: | |||
br_div = 0x07; /* actual speed: 280kHz on APB2, 140KHz on APB1 */ | |||
break; |
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.
Was this break just missing or was SPI_SPEED_100KHZ not supposed to be supported?
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.
The manual says 0x7
is the greatest divider which leads to the smallest baudrate (f_PCLK/256) so I think it it supposed to be supported.
Tested with stm32f4discovery and stm32f0discovery boards and it worked. |
Thanks for testing! Hauke asked Thomas to test it for the stm32f1 with the IoT-Lab board. He also said that you can ACK it when the tests are positive. I also discussed adapting the sam3x8e spi driver with Hauke and we came to the conclusion, that it is better to do it after #1584 is merged. |
Because #1584 was merged already, I adapted the sam3x8e spi implementation as well. Could you look into it @PeterKietzmann? @haukepetersen, you know someone who could test it for the stm32f1? Concerning #1771, I think we should not mix up these two PRs. I'll look into it, after this PR is merged. |
Yes, me :-) I will try to test soon! |
Tested with arduino-due. Works as expected! |
Works for |
Perfect, tested for all adapted MCU's. Just needs your final ACK + GO. |
ACK and go. |
driver - periph: Extend SPI low-level driver interface
This PR adds a new function to the low-level SPI driver interface and adapts the existing implementations accordingly. The new function is used to configure the SPI pins (CLK,MISO,MOSI) independently from the SPI initialization function.
The possibility to independently reconfigure the pins is especially useful if a pin shares SPI and GPIO functionality (e.g. MISO/GDO1 in CC110X) and switching between them is needed.