mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
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.
This commit is contained in:
parent
2ecf2b5a1d
commit
fbe88581b8
@ -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 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,
|
if (HAL_I2C_Mem_Read(i2c, slv_addr, reg_addr,
|
||||||
I2C_MEMADD_SIZE_8BIT, buf, len, I2C_TIMEOUT) != HAL_OK) {
|
I2C_MEMADD_SIZE_8BIT, buf, len, I2C_TIMEOUT) != HAL_OK) {
|
||||||
ret = -1;
|
return -1;
|
||||||
}
|
}
|
||||||
__enable_irq();
|
return 0;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int cambus_write_bytes(I2C_HandleTypeDef *i2c, uint8_t slv_addr, uint8_t reg_addr, uint8_t *buf, int len)
|
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,
|
if (HAL_I2C_Mem_Write(i2c, slv_addr, reg_addr,
|
||||||
I2C_MEMADD_SIZE_8BIT, buf, len, I2C_TIMEOUT) != HAL_OK) {
|
I2C_MEMADD_SIZE_8BIT, buf, len, I2C_TIMEOUT) != HAL_OK) {
|
||||||
ret = -1;
|
return -1;
|
||||||
}
|
}
|
||||||
__enable_irq();
|
return 0;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int cambus_readw_bytes(I2C_HandleTypeDef *i2c, uint8_t slv_addr, uint16_t reg_addr, uint8_t *buf, int len)
|
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,
|
if (HAL_I2C_Mem_Read(i2c, slv_addr, reg_addr,
|
||||||
I2C_MEMADD_SIZE_16BIT, buf, len, I2C_TIMEOUT) != HAL_OK) {
|
I2C_MEMADD_SIZE_16BIT, buf, len, I2C_TIMEOUT) != HAL_OK) {
|
||||||
ret = -1;
|
return -1;
|
||||||
}
|
}
|
||||||
__enable_irq();
|
return 0;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int cambus_writew_bytes(I2C_HandleTypeDef *i2c, uint8_t slv_addr, uint16_t reg_addr, uint8_t *buf, int len)
|
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,
|
if (HAL_I2C_Mem_Write(i2c, slv_addr, reg_addr,
|
||||||
I2C_MEMADD_SIZE_16BIT, buf, len, I2C_TIMEOUT) != HAL_OK) {
|
I2C_MEMADD_SIZE_16BIT, buf, len, I2C_TIMEOUT) != HAL_OK) {
|
||||||
ret = -1;
|
return -1;
|
||||||
}
|
}
|
||||||
__enable_irq();
|
return 0;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user