diff options
Diffstat (limited to 'driver/accel_kxcj9.c')
-rw-r--r-- | driver/accel_kxcj9.c | 223 |
1 files changed, 0 insertions, 223 deletions
diff --git a/driver/accel_kxcj9.c b/driver/accel_kxcj9.c index 76aee6f1b5..ff65e50b94 100644 --- a/driver/accel_kxcj9.c +++ b/driver/accel_kxcj9.c @@ -514,226 +514,3 @@ int accel_init(const enum accel_id id) return ret; } - - - -/*****************************************************************************/ -/* Console commands */ -#ifdef CONFIG_CMD_ACCELS -static int command_read_accelerometer(int argc, char **argv) -{ - char *e; - int addr, reg, data; - - if (argc != 3) - return EC_ERROR_PARAM_COUNT; - - /* First argument is address. */ - addr = strtoi(argv[1], &e, 0); - if (*e) - return EC_ERROR_PARAM1; - - /* Second argument is register offset. */ - reg = strtoi(argv[2], &e, 0); - if (*e) - return EC_ERROR_PARAM2; - - raw_read8(addr, reg, &data); - - ccprintf("0x%02x\n", data); - - return EC_SUCCESS; -} -DECLARE_CONSOLE_COMMAND(accelread, command_read_accelerometer, - "addr reg", - "Read from accelerometer at slave address addr", NULL); - -static int command_write_accelerometer(int argc, char **argv) -{ - char *e; - int addr, reg, data; - - if (argc != 4) - return EC_ERROR_PARAM_COUNT; - - /* First argument is address. */ - addr = strtoi(argv[1], &e, 0); - if (*e) - return EC_ERROR_PARAM1; - - /* Second argument is register offset. */ - reg = strtoi(argv[2], &e, 0); - if (*e) - return EC_ERROR_PARAM2; - - /* Third argument is data. */ - data = strtoi(argv[3], &e, 0); - if (*e) - return EC_ERROR_PARAM3; - - raw_write8(addr, reg, data); - - return EC_SUCCESS; -} -DECLARE_CONSOLE_COMMAND(accelwrite, command_write_accelerometer, - "addr reg data", - "Write to accelerometer at slave address addr", NULL); - -static int command_accelrange(int argc, char **argv) -{ - char *e; - int id, data, round = 1; - - if (argc < 2 || argc > 4) - return EC_ERROR_PARAM_COUNT; - - /* First argument is sensor id. */ - id = strtoi(argv[1], &e, 0); - if (*e || id < 0 || id > ACCEL_COUNT) - return EC_ERROR_PARAM1; - - if (argc >= 3) { - /* Second argument is data to write. */ - data = strtoi(argv[2], &e, 0); - if (*e) - return EC_ERROR_PARAM2; - - if (argc == 4) { - /* Third argument is rounding flag. */ - round = strtoi(argv[3], &e, 0); - if (*e) - return EC_ERROR_PARAM3; - } - - /* - * Write new range, if it returns invalid arg, then return - * a parameter error. - */ - if (accel_set_range(id, data, round) == EC_ERROR_INVAL) - return EC_ERROR_PARAM2; - } else { - accel_get_range(id, &data); - ccprintf("Range for sensor %d: %d\n", id, data); - } - - return EC_SUCCESS; -} -DECLARE_CONSOLE_COMMAND(accelrange, command_accelrange, - "id [data [roundup]]", - "Read or write accelerometer range", NULL); - -static int command_accelresolution(int argc, char **argv) -{ - char *e; - int id, data, round = 1; - - if (argc < 2 || argc > 4) - return EC_ERROR_PARAM_COUNT; - - /* First argument is sensor id. */ - id = strtoi(argv[1], &e, 0); - if (*e || id < 0 || id > ACCEL_COUNT) - return EC_ERROR_PARAM1; - - if (argc >= 3) { - /* Second argument is data to write. */ - data = strtoi(argv[2], &e, 0); - if (*e) - return EC_ERROR_PARAM2; - - if (argc == 4) { - /* Third argument is rounding flag. */ - round = strtoi(argv[3], &e, 0); - if (*e) - return EC_ERROR_PARAM3; - } - - /* - * Write new resolution, if it returns invalid arg, then - * return a parameter error. - */ - if (accel_set_resolution(id, data, round) == EC_ERROR_INVAL) - return EC_ERROR_PARAM2; - } else { - accel_get_resolution(id, &data); - ccprintf("Resolution for sensor %d: %d\n", id, data); - } - - return EC_SUCCESS; -} -DECLARE_CONSOLE_COMMAND(accelres, command_accelresolution, - "id [data [roundup]]", - "Read or write accelerometer resolution", NULL); - -static int command_acceldatarate(int argc, char **argv) -{ - char *e; - int id, data, round = 1; - - if (argc < 2 || argc > 4) - return EC_ERROR_PARAM_COUNT; - - /* First argument is sensor id. */ - id = strtoi(argv[1], &e, 0); - if (*e || id < 0 || id > ACCEL_COUNT) - return EC_ERROR_PARAM1; - - if (argc >= 3) { - /* Second argument is data to write. */ - data = strtoi(argv[2], &e, 0); - if (*e) - return EC_ERROR_PARAM2; - - if (argc == 4) { - /* Third argument is rounding flag. */ - round = strtoi(argv[3], &e, 0); - if (*e) - return EC_ERROR_PARAM3; - } - - /* - * Write new data rate, if it returns invalid arg, then - * return a parameter error. - */ - if (accel_set_datarate(id, data, round) == EC_ERROR_INVAL) - return EC_ERROR_PARAM2; - } else { - accel_get_datarate(id, &data); - ccprintf("Data rate for sensor %d: %d\n", id, data); - } - - return EC_SUCCESS; -} -DECLARE_CONSOLE_COMMAND(accelrate, command_acceldatarate, - "id [data [roundup]]", - "Read or write accelerometer range", NULL); - -#ifdef CONFIG_ACCEL_INTERRUPTS -static int command_accelerometer_interrupt(int argc, char **argv) -{ - char *e; - int id, thresh; - - if (argc != 3) - return EC_ERROR_PARAM_COUNT; - - /* First argument is id. */ - id = strtoi(argv[1], &e, 0); - if (*e || id < 0 || id >= ACCEL_COUNT) - return EC_ERROR_PARAM1; - - /* Second argument is interrupt threshold. */ - thresh = strtoi(argv[2], &e, 0); - if (*e) - return EC_ERROR_PARAM2; - - accel_set_interrupt(id, thresh); - - return EC_SUCCESS; -} -DECLARE_CONSOLE_COMMAND(accelint, command_accelerometer_interrupt, - "id threshold", - "Write interrupt threshold", NULL); -#endif /* CONFIG_ACCEL_INTERRUPTS */ - -#endif /* CONFIG_CMD_ACCELS */ |