Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of minimal_i2c_mother by
master.cpp
- Committer:
- rrbeauch
- Date:
- 2014-12-02
- Revision:
- 1:92677fbab5f1
- Parent:
- 0:d3bdf717512e
- Child:
- 2:4709985cf716
File content as of revision 1:92677fbab5f1:
#include "mbed.h"
#define ROWSIZE (3)
#define SELECTSIZE (0x04)
//BusOut toCells(p5,p6,p7,p8,p9,p10,p11,p12);
//BusOut select(p13,p14,p15);
I2C Bus(p28, p27);
//I2CSlave Self(p9, p10);
int slaveAddressRow1;
int slaveAddressRow2;
Serial Usb(USBTX, USBRX);
char buffer[16] = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x00};
int ack;
char slaveBuffer[16];
DigitalOut sent(LED1);
DigitalOut received(LED2);
void resetBus()
{
Bus.stop();
Bus.start();
return;
}
int main()
{
slaveAddressRow1 = 0x02;
//slaveAddressRow2 = 0x04;
//Self.address(slaveAddressRow2);
resetBus();
while (1)
{
//for(int i = 0; i < sizeof buffer; buffer[i++]=0x00);
//Usb.scanf("%s", buffer);
//Usb.printf("%s \n\r", buffer);
wait(1);
int ack1 = Bus.write(slaveAddressRow1 & 0xFE, buffer, 16);
if(ack1 == 0)
Usb.printf("Row one sent\n\r");
else
Usb.printf("No Ack");
//ack2 = Bus.write(slaveAddressRow2 & 0xFE, buffer, 16);
//if(ack2 == 0)
// Usb.printf("Row two sent\n\r");
/*int i = Bus.receive();
switch (i)
{
case I2CSlave::ReadAddressed:
Bus.write(slaveBuffer, 16);
PC.printf("wrote: %s \n\r", buffer);
break;
case I2CSlave::WriteGeneral:
Bus.read(slaveBuffer, 16);
PC.printf("received broadcast: %s \n\r", buffer);
break;
case I2CSlave::WriteAddressed:
Bus.read(slaveBuffer, 16);
PC.printf("received message: %s \n\r", buffer);
break;
}
char cell = SELECTSIZE;
for(j = 0; j < ROWSIZE; j++)
{
toCells = buffer[j];
select = cell;
cell >>= 1;
wait(0.1);
select = 0x00;
}
*/
}
}
