ports: add initSpiCs helper that does not mak pin used
This commit is contained in:
parent
f9389aae39
commit
84ac47c4af
|
@ -273,12 +273,18 @@ void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso,
|
||||||
PAL_MODE_ALTERNATE(misoAf) | misoMode | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_PULLUP);
|
PAL_MODE_ALTERNATE(misoAf) | misoMode | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_PULLUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin) {
|
void initSpiCsNoOccupy(SPIConfig *spiConfig, brain_pin_e csPin) {
|
||||||
spiConfig->end_cb = nullptr;
|
|
||||||
ioportid_t port = getHwPort("spi", csPin);
|
ioportid_t port = getHwPort("spi", csPin);
|
||||||
ioportmask_t pin = getHwPin("spi", csPin);
|
ioportmask_t pin = getHwPin("spi", csPin);
|
||||||
spiConfig->ssport = port;
|
spiConfig->ssport = port;
|
||||||
spiConfig->sspad = pin;
|
spiConfig->sspad = pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin) {
|
||||||
|
/* TODO: why this is here? */
|
||||||
|
spiConfig->end_cb = nullptr;
|
||||||
|
|
||||||
|
initSpiCsNoOccupy(spiConfig, csPin);
|
||||||
efiSetPadMode("chip select", csPin, PAL_STM32_MODE_OUTPUT);
|
efiSetPadMode("chip select", csPin, PAL_STM32_MODE_OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,12 +186,17 @@ void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso,
|
||||||
efiSetPadMode("SPI master in ", miso, PAL_MODE_ALTERNATE(getSpiAf(driver)) /*| misoMode | PAL_STM32_OSPEED_HIGHEST*/);
|
efiSetPadMode("SPI master in ", miso, PAL_MODE_ALTERNATE(getSpiAf(driver)) /*| misoMode | PAL_STM32_OSPEED_HIGHEST*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin) {
|
void initSpiCsNoOccupy(SPIConfig *spiConfig, brain_pin_e csPin) {
|
||||||
spiConfig->end_cb = NULL;
|
|
||||||
ioportid_t port = getHwPort("spi", csPin);
|
ioportid_t port = getHwPort("spi", csPin);
|
||||||
ioportmask_t pin = getHwPin("spi", csPin);
|
ioportmask_t pin = getHwPin("spi", csPin);
|
||||||
spiConfig->ssport = port;
|
spiConfig->ssport = port;
|
||||||
spiConfig->sspad = pin;
|
spiConfig->sspad = pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin) {
|
||||||
|
/* TODO: why this is here? */
|
||||||
|
spiConfig->end_cb = nullptr;
|
||||||
|
initSpiCsNoOccupy(spiConfig, csPin);
|
||||||
// CS is controlled inside 'hal_spi_lld' driver using both software and hardware methods.
|
// CS is controlled inside 'hal_spi_lld' driver using both software and hardware methods.
|
||||||
//efiSetPadMode("chip select", csPin, PAL_MODE_OUTPUT_OPENDRAIN);
|
//efiSetPadMode("chip select", csPin, PAL_MODE_OUTPUT_OPENDRAIN);
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,12 +179,18 @@ void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso,
|
||||||
efiSetPadMode("SPI master in ", miso, PAL_MODE_ALTERNATE(getSpiAf(driver)) | misoMode | PAL_STM32_OSPEED_HIGHEST);
|
efiSetPadMode("SPI master in ", miso, PAL_MODE_ALTERNATE(getSpiAf(driver)) | misoMode | PAL_STM32_OSPEED_HIGHEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin) {
|
void initSpiCsNoOccupy(SPIConfig *spiConfig, brain_pin_e csPin) {
|
||||||
spiConfig->end_cb = NULL;
|
|
||||||
ioportid_t port = getHwPort("spi", csPin);
|
ioportid_t port = getHwPort("spi", csPin);
|
||||||
ioportmask_t pin = getHwPin("spi", csPin);
|
ioportmask_t pin = getHwPin("spi", csPin);
|
||||||
spiConfig->ssport = port;
|
spiConfig->ssport = port;
|
||||||
spiConfig->sspad = pin;
|
spiConfig->sspad = pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin) {
|
||||||
|
/* TODO: why this is here? */
|
||||||
|
spiConfig->end_cb = nullptr;
|
||||||
|
|
||||||
|
initSpiCsNoOccupy(spiConfig, csPin);
|
||||||
// CS is controlled inside 'hal_spi_lld' driver using both software and hardware methods.
|
// CS is controlled inside 'hal_spi_lld' driver using both software and hardware methods.
|
||||||
//efiSetPadMode("chip select", csPin, PAL_MODE_OUTPUT_OPENDRAIN);
|
//efiSetPadMode("chip select", csPin, PAL_MODE_OUTPUT_OPENDRAIN);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso,
|
||||||
int mosiMode,
|
int mosiMode,
|
||||||
int misoMode);
|
int misoMode);
|
||||||
|
|
||||||
|
void initSpiCsNoOccupy(SPIConfig *spiConfig, brain_pin_e csPin);
|
||||||
void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin);
|
void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin);
|
||||||
void turnOnSpi(spi_device_e device);
|
void turnOnSpi(spi_device_e device);
|
||||||
#endif // HAL_USE_SPI
|
#endif // HAL_USE_SPI
|
||||||
|
|
|
@ -152,12 +152,18 @@ void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso,
|
||||||
efiSetPadMode("SPI master in ", miso, PAL_MODE_ALTERNATE(getSpiAf(driver)) | misoMode | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_PULLUP);
|
efiSetPadMode("SPI master in ", miso, PAL_MODE_ALTERNATE(getSpiAf(driver)) | misoMode | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_PULLUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin) {
|
void initSpiCsNoOccupy(SPIConfig *spiConfig, brain_pin_e csPin) {
|
||||||
spiConfig->end_cb = nullptr;
|
|
||||||
ioportid_t port = getHwPort("spi", csPin);
|
ioportid_t port = getHwPort("spi", csPin);
|
||||||
ioportmask_t pin = getHwPin("spi", csPin);
|
ioportmask_t pin = getHwPin("spi", csPin);
|
||||||
spiConfig->ssport = port;
|
spiConfig->ssport = port;
|
||||||
spiConfig->sspad = pin;
|
spiConfig->sspad = pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin) {
|
||||||
|
/* TODO: why this is here? */
|
||||||
|
spiConfig->end_cb = nullptr;
|
||||||
|
|
||||||
|
initSpiCsNoOccupy(spiConfig, csPin);
|
||||||
efiSetPadMode("chip select", csPin, PAL_STM32_MODE_OUTPUT);
|
efiSetPadMode("chip select", csPin, PAL_STM32_MODE_OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue