Merge pull request #4386 from kamtom480/spi_and_i2c

spresense: minor i2c and spi fixes
This commit is contained in:
Scott Shawcroft 2021-03-11 10:43:27 -08:00 committed by GitHub
commit a32359b0a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -103,7 +103,7 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t address, cons
msg.flags = (stop ? 0 : I2C_M_NOSTOP);
msg.buffer = (uint8_t *) data;
msg.length = len;
return I2C_TRANSFER(self->i2c_dev, &msg, 1);
return -I2C_TRANSFER(self->i2c_dev, &msg, 1);
}
uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t address, uint8_t *data, size_t len) {
@ -114,7 +114,7 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t address, uint8
msg.flags = I2C_M_READ;
msg.buffer = data;
msg.length = len;
return I2C_TRANSFER(self->i2c_dev, &msg, 1);
return -I2C_TRANSFER(self->i2c_dev, &msg, 1);
}
void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) {

View File

@ -35,9 +35,13 @@ 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) {
int port = -1;
if (clock->number == PIN_SPI4_SCK && mosi->number == PIN_SPI4_MOSI && miso->number == PIN_SPI4_MISO) {
if (clock->number == PIN_SPI4_SCK &&
(mosi == NULL || mosi->number == PIN_SPI4_MOSI) &&
(miso == NULL || miso->number == PIN_SPI4_MISO)) {
port = 4;
} else if (clock->number == PIN_EMMC_CLK && mosi->number == PIN_EMMC_DATA0 && miso->number == PIN_EMMC_DATA1) {
} else if (clock->number == PIN_EMMC_CLK &&
(mosi == NULL || mosi->number == PIN_EMMC_DATA0) &&
(miso == NULL || miso->number == PIN_EMMC_DATA1)) {
port = 5;
}