git.haldean.org d / f3abca2
disable servo stuff, run I2C reader haldean 4 years ago
1 changed file(s) with 13 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
3030
3131 static const int addr = 0x63;
3232
33 static bool
34 register_write(int i2c, uint8_t *cmd, size_t len)
35 {
36 struct timespec ts;
37
38 if (write(i2c, cmd, len) != len)
39 {
40 fprintf(stderr, "failed to send write to %02X register\n",
41 cmd[0]);
42 return false;
43 }
44
45 // clock_nanosleep(
46 return true;
47 }
48
4933 int t_lo = 800;
5034 int t_hi = 2600;
5135 int p_lo = 800;
6246
6347 if (rc_initialize())
6448 {
65 fprintf(stderr,"ERROR: failed to initialize rc_initialize(), are you root?\n");
49 fprintf(stderr, "ERROR: rc_initialize failed, needs root\n");
6650 return -1;
6751 }
6852
7155 rc_enable_servo_power_rail();
7256 rc_set_state(RUNNING);
7357
58 if (!rc_i2c_init(1, addr))
59 {
60 fprintf(stderr, "ERROR: failed to initialize I2C\n");
61 return -1;
62 }
63
7464 while (rc_get_state() != EXITING)
7565 {
66 /*
7667 int iters = 1;
7768 phi += (inc ? 1 : -1) * 5;
7869 if (phi > p_hi || phi < p_lo)
9384 rc_send_servo_pulse_us(2, phi);
9485 usleep(period);
9586 }
87 */
88
89 uint8_t status = 0xFF;
90 rc_i2c_read_byte(1, STATUS, &status);
91 printf("status: %02x\n");
9692
9793 if (rc_get_state() == RUNNING)
9894 {