1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include "spi_config.h"
spi_config_t::spi_config_t(const spi_hwd_settings_t hwd_settings, const spi_device_settings_t device_settings) :
full_settings({
_convert_to_adi_settings(hwd_settings.chip_select_index, device_settings),
hwd_settings })
{
}
spiSettings_t spi_config_t::_convert_to_adi_settings(const uint8_t chip_select_index, const spi_device_settings_t device_settings)
{
return {
chip_select_index,
device_settings.writeBitPolarity,
device_settings.longInstructionWord,
device_settings.MSBFirst,
device_settings.CPHA,
device_settings.CPOL,
device_settings.enSpiStreaming,
device_settings.autoIncAddrUp,
device_settings.fourWireMode,
device_settings.spiClkFreq_Hz,
};
}
const spiSettings_t* spi_config_t::get_spi_settings() const
{
return &(full_settings.adi_settings);
}
const spi_full_settings_t* spi_config_t::recover_full_spi_settings(const spiSettings_t* settings)
{
// TODO: make this better
return reinterpret_cast<const spi_full_settings_t*>(settings);
}
|