disable servo stuff, run I2C reader
haldean
4 years ago
30 | 30 | |
31 | 31 | static const int addr = 0x63; |
32 | 32 | |
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 | ||
49 | 33 | int t_lo = 800; |
50 | 34 | int t_hi = 2600; |
51 | 35 | int p_lo = 800; |
62 | 46 | |
63 | 47 | if (rc_initialize()) |
64 | 48 | { |
65 | fprintf(stderr,"ERROR: failed to initialize rc_initialize(), are you root?\n"); | |
49 | fprintf(stderr, "ERROR: rc_initialize failed, needs root\n"); | |
66 | 50 | return -1; |
67 | 51 | } |
68 | 52 | |
71 | 55 | rc_enable_servo_power_rail(); |
72 | 56 | rc_set_state(RUNNING); |
73 | 57 | |
58 | if (!rc_i2c_init(1, addr)) | |
59 | { | |
60 | fprintf(stderr, "ERROR: failed to initialize I2C\n"); | |
61 | return -1; | |
62 | } | |
63 | ||
74 | 64 | while (rc_get_state() != EXITING) |
75 | 65 | { |
66 | /* | |
76 | 67 | int iters = 1; |
77 | 68 | phi += (inc ? 1 : -1) * 5; |
78 | 69 | if (phi > p_hi || phi < p_lo) |
93 | 84 | rc_send_servo_pulse_us(2, phi); |
94 | 85 | usleep(period); |
95 | 86 | } |
87 | */ | |
88 | ||
89 | uint8_t status = 0xFF; | |
90 | rc_i2c_read_byte(1, STATUS, &status); | |
91 | printf("status: %02x\n"); | |
96 | 92 | |
97 | 93 | if (rc_get_state() == RUNNING) |
98 | 94 | { |