From fbe88581b882f2e3857038ed7dfc3688362e29fb Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Tue, 12 May 2020 21:47:22 +0200 Subject: [PATCH] Allow interrupts in cambus read/write_bytes functions. * Those are used exclusively by the FIR sensors and not by the main image sensor, so it's safe (and much faster) to leave interrupts enabled. --- src/omv/cambus.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/omv/cambus.c b/src/omv/cambus.c index a29085c31..b876db480 100644 --- a/src/omv/cambus.c +++ b/src/omv/cambus.c @@ -177,48 +177,36 @@ int cambus_writew2(I2C_HandleTypeDef *i2c, uint8_t slv_addr, uint16_t reg_addr, int cambus_read_bytes(I2C_HandleTypeDef *i2c, uint8_t slv_addr, uint8_t reg_addr, uint8_t *buf, int len) { - int ret=0; - __disable_irq(); if (HAL_I2C_Mem_Read(i2c, slv_addr, reg_addr, I2C_MEMADD_SIZE_8BIT, buf, len, I2C_TIMEOUT) != HAL_OK) { - ret = -1; + return -1; } - __enable_irq(); - return ret; + return 0; } int cambus_write_bytes(I2C_HandleTypeDef *i2c, uint8_t slv_addr, uint8_t reg_addr, uint8_t *buf, int len) { - int ret=0; - __disable_irq(); if (HAL_I2C_Mem_Write(i2c, slv_addr, reg_addr, I2C_MEMADD_SIZE_8BIT, buf, len, I2C_TIMEOUT) != HAL_OK) { - ret = -1; + return -1; } - __enable_irq(); - return ret; + return 0; } int cambus_readw_bytes(I2C_HandleTypeDef *i2c, uint8_t slv_addr, uint16_t reg_addr, uint8_t *buf, int len) { - int ret=0; - __disable_irq(); if (HAL_I2C_Mem_Read(i2c, slv_addr, reg_addr, I2C_MEMADD_SIZE_16BIT, buf, len, I2C_TIMEOUT) != HAL_OK) { - ret = -1; + return -1; } - __enable_irq(); - return ret; + return 0; } int cambus_writew_bytes(I2C_HandleTypeDef *i2c, uint8_t slv_addr, uint16_t reg_addr, uint8_t *buf, int len) { - int ret=0; - __disable_irq(); if (HAL_I2C_Mem_Write(i2c, slv_addr, reg_addr, I2C_MEMADD_SIZE_16BIT, buf, len, I2C_TIMEOUT) != HAL_OK) { - ret = -1; + return -1; } - __enable_irq(); - return ret; + return 0; }