Skip to content

Commit

Permalink
enable misra-c2012-2.7 (#1813)
Browse files Browse the repository at this point in the history
* cpp-check suppress

* enable misra-c2012-2.7
  • Loading branch information
0x41head authored Jan 17, 2024
1 parent 7e8b829 commit c118c28
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
18 changes: 9 additions & 9 deletions board/stm32h7/lli2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,29 +119,29 @@ bool i2c_read_reg(I2C_TypeDef *I2C, uint8_t addr, uint8_t reg, uint8_t *value) {
return ret;
}

bool i2c_set_reg_bits(I2C_TypeDef *I2C, uint8_t addr, uint8_t reg, uint8_t bits) {
bool i2c_set_reg_bits(I2C_TypeDef *I2C, uint8_t address, uint8_t regis, uint8_t bits) {
uint8_t value;
bool ret = i2c_read_reg(I2C, addr, reg, &value);
bool ret = i2c_read_reg(I2C, address, regis, &value);
if(ret) {
ret = i2c_write_reg(I2C, addr, reg, value | bits);
ret = i2c_write_reg(I2C, address, regis, value | bits);
}
return ret;
}

bool i2c_clear_reg_bits(I2C_TypeDef *I2C, uint8_t addr, uint8_t reg, uint8_t bits) {
bool i2c_clear_reg_bits(I2C_TypeDef *I2C, uint8_t address, uint8_t regis, uint8_t bits) {
uint8_t value;
bool ret = i2c_read_reg(I2C, addr, reg, &value);
bool ret = i2c_read_reg(I2C, address, regis, &value);
if(ret) {
ret = i2c_write_reg(I2C, addr, reg, value & (uint8_t) (~bits));
ret = i2c_write_reg(I2C, address, regis, value & (uint8_t) (~bits));
}
return ret;
}

bool i2c_set_reg_mask(I2C_TypeDef *I2C, uint8_t addr, uint8_t reg, uint8_t value, uint8_t mask) {
bool i2c_set_reg_mask(I2C_TypeDef *I2C, uint8_t address, uint8_t regis, uint8_t value, uint8_t mask) {
uint8_t old_value;
bool ret = i2c_read_reg(I2C, addr, reg, &old_value);
bool ret = i2c_read_reg(I2C, address, regis, &old_value);
if(ret) {
ret = i2c_write_reg(I2C, addr, reg, (old_value & (uint8_t) (~mask)) | (value & mask));
ret = i2c_write_reg(I2C, address, regis, (old_value & (uint8_t) (~mask)) | (value & mask));
}
return ret;
}
Expand Down
1 change: 0 additions & 1 deletion tests/misra/suppressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ knownConditionTrueFalse
misra-config
misra-c2012-1.2 # this is from the extensions (e.g. __typeof__) used in the MIN, MAX, ABS, and CLAMP macros
misra-c2012-2.5
misra-c2012-2.7
misra-c2012-8.7
misra-c2012-8.2
misra-c2012-8.4
Expand Down

0 comments on commit c118c28

Please sign in to comment.