lazaro camargo
/
islp_master_2
teste
Revision 0:87bc55898a84, committed 2018-05-09
- Comitter:
- lazarocamargo
- Date:
- Wed May 09 17:41:54 2018 +0000
- Commit message:
- teste
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed May 09 17:41:54 2018 +0000 @@ -0,0 +1,97 @@ +#include "mbed.h" + +//#define slave_add ((uint8_t) 0x3C) + +Serial pc(PA_9, PA_10); //tx, rx +I2C i2c(PB_7,PB_8); //sda, scl + +i2c.frequency(100000); +pc.baud(115200); + +void islp(int endereco_I2C, int num_blocos, int indice_bloco) + + endereco_I2c = endereco_I2C << 1; // 8bit I2C address, 0x90 + + + char cmd[12]; + char data[100]; + + + pc.printf("\ni2cmaster\n"); +// while(1){ + cmd[0] = 0xf0; + + while(data[0]!=0xfA){ + i2c.write(addr8bit,cmd,1); + i2c.read(addr8bit,data,1); + pc.printf("rx=%x\n",data[0]); + } + + + cmd[0] = 0xf1; + cmd[1] = 0x01; + cmd[2] = 0x08; + cmd[3] = 0x10; + cmd[4] = 0x00; + cmd[5] = 0x01; + cmd[6] = 0x01; + + i2c.write(addr8bit,cmd,7); + + wait(1); + + cmd[0] = 0xf0; + + i2c.write(addr8bit,cmd,1); + i2c.read(addr8bit,data,1); + pc.printf("rx=%x\n",data[0]); + + wait(60*5); + wait(15); + + cmd[0] = 0xf0; + + i2c.write(addr8bit,cmd,1); + i2c.read(addr8bit,data,1); + pc.printf("rx=%x\n",data[0]); + + wait(1); + + cmd[0] = 0xf2; + cmd[1] = 0x05; + + i2c.write(addr8bit,cmd,2); + i2c.read(addr8bit,data,1); + pc.printf("rx=%x\n",data[0]); + + wait(1); + + cmd[0] = 0xf3; + cmd[1] = 0x00; + cmd[2] = 0x00; + + i2c.write(addr8bit,cmd,3); + i2c.read(addr8bit,data,1); + pc.printf("rx=%x\n",data[0]); + + wait(1); + + cmd[0] = 0xf4; + // cmd[1] = 0x00; + // cmd[2] = 0x00; + + i2c.write(addr8bit,cmd,1); + i2c.read(addr8bit,data,100); + pc.printf("rx=%x\n",data[0]); + pc.printf("rx=%x\n",data[1]); + + + + + + +// } +} + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed May 09 17:41:54 2018 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/64910690c574 \ No newline at end of file