Skip to content

Commit bb27b40

Browse files
authored
Use more explicit names for i2c_id and spi_id
1 parent 183a517 commit bb27b40

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

ports/analog/common-hal/busio/I2C.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
4646
const mcu_pin_obj_t *scl,
4747
const mcu_pin_obj_t *sda,
4848
uint32_t frequency, uint32_t timeout) {
49-
50-
int temp = 0;
51-
5249
// Check for NULL Pointers && valid I2C settings
5350
assert(self);
5451

@@ -58,12 +55,12 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
5855
*/
5956

6057
// Assign I2C ID based on pins
61-
temp = pinsToI2c(sda, scl);
62-
if (temp == -1) {
58+
int i2c_id = pinsToI2c(sda, scl);
59+
if (i2c_id == -1) {
6360
return;
6461
} else {
65-
self->i2c_id = temp;
66-
self->i2c_regs = MXC_I2C_GET_I2C(temp);
62+
self->i2c_id = i2c_id;
63+
self->i2c_regs = MXC_I2C_GET_I2C(i2c_id);
6764
}
6865

6966
// Check for valid I2C controller

ports/analog/common-hal/busio/SPI.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,18 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
5656
const mcu_pin_obj_t *mosi,
5757
const mcu_pin_obj_t *miso,
5858
bool half_duplex) {
59-
int temp, err = 0;
59+
int err = 0;
6060

6161
// Check for NULL Pointer
6262
assert(self);
6363

6464
// Assign SPI ID based on pins
65-
temp = pinsToSpi(mosi, miso, sck);
66-
if (temp == -1) {
65+
int spi_id = pinsToSpi(mosi, miso, sck);
66+
if (spi_id == -1) {
6767
return;
6868
} else {
69-
self->spi_id = temp;
70-
self->spi_regs = MXC_SPI_GET_SPI(temp);
69+
self->spi_id = spi_id;
70+
self->spi_regs = MXC_SPI_GET_SPI(spi_id);
7171
}
7272

7373
// Other pins default to true

0 commit comments

Comments
 (0)