/* Select the given device on the SPI bus. 
Set device specific setting and call board chip select. */
void spi_select_device(Spi *p_spi, struct spi_device *device)
/* Select the given device on the SPI bus. 
Set device specific setting and call board chip select. */
void spi_select_device(Spi *p_spi, struct spi_device *device)
{
	if (spi_get_peripheral_select_decode_setting(p_spi)) {
		if (device->id < MAX_NUM_WITH_DECODER) {
			spi_set_peripheral_chip_select_value(p_spi, device->id);
		}
	} else {
		if (device->id < MAX_NUM_WITHOUT_DECODER) {
			spi_set_peripheral_chip_select_value(p_spi, (~(1 << device->id)));
		}
	}
}