Skip to content
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

Merged
merged 2 commits into from
Oct 17, 2014

Conversation

fnack
Copy link
Member

@fnack fnack commented Oct 7, 2014

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.

@LudwigKnuepfer LudwigKnuepfer added the Type: new feature The issue requests / The PR implemements a new feature for RIOT label Oct 7, 2014
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));
Copy link
Member Author

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.

@fnack
Copy link
Member Author

fnack commented Oct 7, 2014

Probably @haukepetersen should be the right assignee? Also interesting for @PeterKietzmann and @thomaseichinger!

@PeterKietzmann
Copy link
Member

Will test this later for stm32f4 and stm32f0. You should check the return values defined by the SPI API (I just did so in #1771). How about implementing this for #1584 ;-) ?

@fnack
Copy link
Member Author

fnack commented Oct 7, 2014

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;
Copy link
Member Author

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?

Copy link
Member

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.

@PeterKietzmann
Copy link
Member

Tested with stm32f4discovery and stm32f0discovery boards and it worked.

@fnack
Copy link
Member Author

fnack commented Oct 7, 2014

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.

@PeterKietzmann
Copy link
Member

Jepp, maybe it's easier to wait until #1584. Furthermore could you take care of #1771? For the rest ACK

@fnack
Copy link
Member Author

fnack commented Oct 16, 2014

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.

@haukepetersen
Copy link
Contributor

Yes, me :-) I will try to test soon!

@PeterKietzmann
Copy link
Member

Tested with arduino-due. Works as expected!

@haukepetersen
Copy link
Contributor

Works for iot-lab_M3 and stm32f0discovery.

@fnack
Copy link
Member Author

fnack commented Oct 17, 2014

Perfect, tested for all adapted MCU's. Just needs your final ACK + GO.

@haukepetersen
Copy link
Contributor

ACK and go.

haukepetersen added a commit that referenced this pull request Oct 17, 2014
driver - periph: Extend SPI low-level driver interface
@haukepetersen haukepetersen merged commit 8c3a207 into RIOT-OS:master Oct 17, 2014
@fnack fnack deleted the spi_extension branch March 13, 2015 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants