Bavo Van Achte
/
MLX90418_I2C_master
Fork
Diff: main.cpp
- Revision:
- 2:9bdcd2c966de
- Parent:
- 1:47cc6952e346
- Child:
- 3:557d5725b1bb
diff -r 47cc6952e346 -r 9bdcd2c966de main.cpp --- a/main.cpp Mon Dec 07 12:21:14 2020 +0000 +++ b/main.cpp Tue Dec 08 13:53:10 2020 +0000 @@ -21,7 +21,7 @@ } void i2c_init(){ - i2c_master.frequency(350000); + i2c_master.frequency(35000); } void main_init(){ @@ -45,6 +45,10 @@ char i2cWriteTest[4] = {0x13, 0x8a, 0xac, 0x35}; char i2cReadTest[4] = {0x13, 0x8a, 0x00, 0x00}; + char i2cStartMotor[4] = {0x13, 0xa4, 0xca, 0xfe}; //Start motor to skip the 1s + char i2cPositionPulseSetup[4] = {0x13, 0x82, 0xc6, 0x00}; //Start motor to skip the 1s + char i2cStartUpRead[4] = {0x13, 0x84, 0x00, 0x00}; //Start motor to skip the 1s + int ack; main_init(); @@ -53,16 +57,18 @@ char c = pc.getc(); if(c=='s'){ fpga_rstb = 0; //reset FPGA - wait_ms(10); + wait_ms(100); fpga_rstb = 1; //enable FPGA wait_ms(10); //i2c_keyEntry(i2c_master); - ack+=i2c_word_write(i2c_master,i2cWriteTest); + ack+=i2c_word_write(i2c_master,i2cPositionPulseSetup); + wait_ms(10); + ack+=i2c_word_write(i2c_master,i2cStartMotor); wait_ms(10); - ack+=i2c_word_read(i2c_master,i2cReadTest); + //ack+=i2c_word_read(i2c_master,i2cStartUpRead); led1 = ack; - pc.printf("d[0]=%2d\n",i2cReadTest[3]); - pc.printf("d[1]=%2d\n",i2cReadTest[2]); + //pc.printf("d[0]=%2d\n",i2cStartUpRead[3]); + //pc.printf("d[1]=%2d\n",i2cStartUpRead[2]); } if(c=='t'){ fpga_rstb = 0; //disable FPGA