Canonical C style for half_duplex = true/false
This commit is contained in:
parent
309f4fb2b9
commit
a8d8651873
@ -57,7 +57,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
uint8_t miso_pad = 0;
|
||||
uint8_t dopo = 255;
|
||||
|
||||
if (half_duplex == true) {
|
||||
if (half_duplex) {
|
||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
BP_Function_Enum mosi_alt = 0;
|
||||
BP_Function_Enum miso_alt = 0;
|
||||
|
||||
if (half_duplex == true) {
|
||||
if (half_duplex) {
|
||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *
|
||||
const mcu_pin_obj_t *mosi, const mcu_pin_obj_t *miso, bool half_duplex) {
|
||||
int port = -1;
|
||||
|
||||
if (half_duplex == true) {
|
||||
if (half_duplex) {
|
||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
.quadhd_io_num = -1,
|
||||
};
|
||||
|
||||
if (half_duplex == true) {
|
||||
if (half_duplex) {
|
||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
const uint32_t mosi_count = MP_ARRAY_SIZE(mcu_spi_mosi_list);
|
||||
bool spi_taken = false;
|
||||
|
||||
if (half_duplex == true) {
|
||||
if (half_duplex) {
|
||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ static nrf_spim_frequency_t baudrate_to_spim_frequency(const uint32_t baudrate)
|
||||
|
||||
void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi, const mcu_pin_obj_t *miso, bool half_duplex) {
|
||||
|
||||
if (half_duplex == true) {
|
||||
if (half_duplex) {
|
||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
const mcu_pin_obj_t *miso, bool half_duplex) {
|
||||
size_t instance_index = NO_INSTANCE;
|
||||
|
||||
if (half_duplex == true) {
|
||||
if (half_duplex) {
|
||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
self->handle.Instance = SPIx;
|
||||
self->handle.Init.Mode = SPI_MODE_MASTER;
|
||||
// Direction change only required for RX-only, see RefMan RM0090:884
|
||||
if (half_duplex == true) {
|
||||
if (half_duplex) {
|
||||
self->handle.Init.Direction = SPI_DIRECTION_1LINE;
|
||||
} else {
|
||||
self->handle.Init.Direction = (self->mosi == NULL) ? SPI_DIRECTION_2LINES_RXONLY : SPI_DIRECTION_2LINES;
|
||||
@ -345,13 +345,13 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self,
|
||||
|
||||
bool common_hal_busio_spi_read(busio_spi_obj_t *self,
|
||||
uint8_t *data, size_t len, uint8_t write_value) {
|
||||
if (self->miso == NULL && self->half_duplex == false) {
|
||||
if (self->miso == NULL && !self->half_duplex) {
|
||||
mp_raise_ValueError(translate("No MISO Pin"));
|
||||
} else if (self->half_duplex == true && self->mosi == NULL) {
|
||||
} else if (self->half_duplex && self->mosi == NULL) {
|
||||
mp_raise_ValueError(translate("No MOSI Pin"));
|
||||
}
|
||||
HAL_StatusTypeDef result = HAL_OK;
|
||||
if ((self->half_duplex == false && self->mosi == NULL) || (self->half_duplex == true && self->mosi != NULL && self->miso == NULL)) {
|
||||
if ((!self->half_duplex && self->mosi == NULL) || (self->half_duplex && self->mosi != NULL && self->miso == NULL)) {
|
||||
result = HAL_SPI_Receive(&self->handle, data, (uint16_t)len, HAL_MAX_DELAY);
|
||||
} else {
|
||||
memset(data, write_value, len);
|
||||
|
Loading…
Reference in New Issue
Block a user