arch/arm/src/nrf52/nrf52_i2c.c: protect the I2C transfer with a semaphore
This commit is contained in:
parent
4f130d4274
commit
fef7abb598
@ -223,6 +223,12 @@ static int nrf52_i2c_transfer(FAR struct i2c_master_s *dev,
|
||||
uint32_t regval = 0;
|
||||
int ret = OK;
|
||||
|
||||
ret = nxsem_wait(&priv->sem_excl);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Reset ptr and dcnt */
|
||||
|
||||
priv->dcnt = 0;
|
||||
@ -397,7 +403,8 @@ static int nrf52_i2c_transfer(FAR struct i2c_master_s *dev,
|
||||
#endif
|
||||
|
||||
errout:
|
||||
return ret;
|
||||
nxsem_post(&priv->sem_excl);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user