/* Setup a SPI device. 
The returned device descriptor structure must be passed to the driver whenever that device should be used as current slave device. */
void spi_master_setup_device(volatile void *spi, struct spi_device *device, spi_flags_t flags, uint32_t baud_rate, board_spi_select_id_t sel_id)
/* Setup a SPI device. 
The returned device descriptor structure must be passed to the driver whenever that device should be used as current slave device. */
void spi_master_setup_device(volatile void *spi, struct spi_device *device, spi_flags_t flags, uint32_t baud_rate, board_spi_select_id_t sel_id)
{
	if (spi_set_baud_div(spi, baud_rate, sysclk_get_cpu_hz()) < 0) {
		Assert(false);
		return;
	}
	SPCR = (SPCR & ~SPI_MODE_gm) |
			((flags << SPI_MODE_gp) & SPI_MODE_gm);
}