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.
main.cpp
- Committer:
- franni
- Date:
- 2018-10-12
- Revision:
- 0:b16fccf97adb
File content as of revision 0:b16fccf97adb:
#include "mbed.h"
DigitalOut led(LED1);
Serial pc(USBTX, USBRX); // tx, rx
I2CSlave slave(PTC9,PTC8); // SDA, SCL
const int SLAVE_ADDRESS = 0x0A;
const int I2C_FREQUENCY = 100000;
// const int I2C_BUFFER_SIZE = 6;
int main() {
pc.baud(9600);
// Configure I2C
slave.frequency(I2C_FREQUENCY);
pc.printf("Frecuencia I2C Slave @ %dHz\r\n", I2C_FREQUENCY);
slave.address(SLAVE_ADDRESS);
pc.printf("Direccion Slave @ SLAVE_ADDRESS = 0x%x\r\n", SLAVE_ADDRESS);
// I2C buffer
// char buffer[I2C_BUFFER_SIZE];
while (1) {
int rec = slave.receive();
pc.printf("Dato recibido %d\r\n", rec);
}
}