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

Use hardware SPI? #424

Open
Peque opened this issue Oct 24, 2019 · 0 comments
Open

Use hardware SPI? #424

Peque opened this issue Oct 24, 2019 · 0 comments

Comments

@Peque
Copy link
Member

Peque commented Oct 24, 2019

See: libopencm3/libopencm3#876 (comment)

The MPU PCB is supposed to already have the 10 k pull-up, so this should be possible?

Maybe something like:

static void
spi_setup(void) {
	rcc_periph_clock_enable(RCC_SPI1);
	gpio_set_mode(
		GPIOA,
		GPIO_MODE_OUTPUT_50_MHZ,
		GPIO_CNF_OUTPUT_ALTFN_PUSHPULL,
		GPIO4|GPIO5|GPIO7 // NSS=PA4,SCK=PA5,MOSI=PA7
	);
	gpio_set_mode(
		GPIOA,
		GPIO_MODE_INPUT,
		GPIO_CNF_INPUT_FLOAT,
		GPIO6 // MISO=PA6
	);
	spi_reset(SPI1);
	spi_init_master(
		SPI1,
		SPI_CR1_BAUDRATE_FPCLK_DIV_256,
		SPI_CR1_CPOL_CLK_TO_0_WHEN_IDLE,
		SPI_CR1_CPHA_CLK_TRANSITION_1,
		SPI_CR1_DFF_8BIT,
		SPI_CR1_MSBFIRST
	);
	spi_disable_software_slave_management(SPI1);
	spi_enable_ss_output(SPI1);
}

See Warren Gay's "Beginning STM32" book.

@Peque Peque added this to the OSHWDem 2019 milestone Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant