void spi_send_lsb_first(uint32_t spi) { SPI_CR1(spi) |= SPI_CR1_LSBFIRST; }
void spi_set_dff_16bit(uint32_t spi) { SPI_CR1(spi) |= SPI_CR1_DFF; }
void spi_set_nss_low(uint32_t spi) { SPI_CR1(spi) &= ~SPI_CR1_SSI; }
void spi_set_clock_phase_0(uint32_t spi) { SPI_CR1(spi) &= ~SPI_CR1_CPHA; }
void spi_set_bidirectional_mode(uint32_t spi) { SPI_CR1(spi) |= SPI_CR1_BIDIMODE; }
void spi_set_slave_mode(uint32_t spi) { SPI_CR1(spi) &= ~SPI_CR1_MSTR; }
void spi_set_clock_polarity_0(uint32_t spi) { SPI_CR1(spi) &= ~SPI_CR1_CPOL; }
void spi_set_next_tx_from_buffer(uint32_t spi) { SPI_CR1(spi) &= ~SPI_CR1_CRCNEXT; }
void spi_set_next_tx_from_crc(uint32_t spi) { SPI_CR1(spi) |= SPI_CR1_CRCNEXT; }
void spi_enable_crc(uint32_t spi) { SPI_CR1(spi) |= SPI_CR1_CRCEN; }
void spi_disable_crc(uint32_t spi) { SPI_CR1(spi) &= ~SPI_CR1_CRCEN; }
void spi_set_bidirectional_transmit_only_mode(uint32_t spi) { SPI_CR1(spi) |= SPI_CR1_BIDIMODE; SPI_CR1(spi) |= SPI_CR1_BIDIOE; }
void spi_set_bidirectional_receive_only_mode(uint32_t spi) { SPI_CR1(spi) |= SPI_CR1_BIDIMODE; SPI_CR1(spi) &= ~SPI_CR1_BIDIOE; }
void spi_enable_software_slave_management(uint32_t spi) { SPI_CR1(spi) |= SPI_CR1_SSM; }
void spi_send_msb_first(uint32_t spi) { SPI_CR1(spi) &= ~SPI_CR1_LSBFIRST; }
void spi_set_full_duplex_mode(uint32_t spi) { SPI_CR1(spi) &= ~SPI_CR1_RXONLY; }
void spi_set_master_mode(uint32_t spi) { SPI_CR1(spi) |= SPI_CR1_MSTR; }
void spi_set_receive_only_mode(uint32_t spi) { SPI_CR1(spi) |= SPI_CR1_RXONLY; }
void spi_set_clock_polarity_1(uint32_t spi) { SPI_CR1(spi) |= SPI_CR1_CPOL; }
void spi_disable_software_slave_management(uint32_t spi) { SPI_CR1(spi) &= ~SPI_CR1_SSM; }
void spi_set_clock_phase_1(uint32_t spi) { SPI_CR1(spi) |= SPI_CR1_CPHA; }
void spi_enable_software_slave_management(uint32_t spi) { SPI_CR1(spi) |= SPI_CR1_SSM; /* allow slave select to be an input */ SPI_CR2(spi) &= ~SPI_CR2_SSOE; }
void spi_enable(uint32_t spi) { SPI_CR1(spi) |= SPI_CR1_SPE; /* Enable SPI. */ }
void spi_set_nss_high(uint32_t spi) { SPI_CR1(spi) |= SPI_CR1_SSI; }
void spi_set_unidirectional_mode(uint32_t spi) { SPI_CR1(spi) &= ~SPI_CR1_BIDIMODE; }
void spi_set_dff_8bit(uint32_t spi) { SPI_CR1(spi) &= ~SPI_CR1_DFF; }