i2ccmds: Validate the i2c address

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-11-28 20:26:49 -05:00
parent db4f0c24cd
commit 3a47d972db
1 changed files with 4 additions and 1 deletions

View File

@ -16,9 +16,12 @@ struct i2cdev_s {
void
command_config_i2c(uint32_t *args)
{
uint8_t addr = args[3];
if (addr & 1)
shutdown("Invalid I2C address");
struct i2cdev_s *i2c = oid_alloc(args[0], command_config_i2c
, sizeof(*i2c));
i2c->i2c_config = i2c_setup(args[1], args[2], args[3]);
i2c->i2c_config = i2c_setup(args[1], args[2], addr);
}
DECL_COMMAND(command_config_i2c,
"config_i2c oid=%c bus=%u rate=%u addr=%u");