| 29 | void exit_signal_handler(int signo); |
| 30 | |
| 31 | int main(){ |
| 32 | signal(SIGINT, exit_signal_handler); // register the exit function for Ctrl+C |
| 33 | |
| 34 | GPG.detect(); // Make sure that the GoPiGo3 is communicating and that the firmware is compatible with the drivers. |
| 35 | |
| 36 | GPG.set_grove_type(GROVE_1, GROVE_TYPE_I2C); |
| 37 | i2c_struct_t I2C1; |
| 38 | I2C1.address = 0x24; |
| 39 | I2C1.length_read = 3; |
| 40 | I2C1.length_write = 1; |
| 41 | uint8_t s = 0; |
| 42 | while(true){ |
| 43 | I2C1.buffer_write[0] = s; |
| 44 | int error = GPG.grove_i2c_transfer(GROVE_1, &I2C1); |
| 45 | printf("Error: %d bytes: %d %d %d\n", error, I2C1.buffer_read[0], I2C1.buffer_read[1], I2C1.buffer_read[2]); |
| 46 | if(s == 0){ |
| 47 | s = 1; |
| 48 | }else{ |
| 49 | s = 0; |
| 50 | } |
| 51 | usleep(50000); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | // Signal handler that will be called when Ctrl+C is pressed to stop the program |
| 56 | void exit_signal_handler(int signo){ |
nothing calls this directly
no test coverage detected