program for I2C master device

Dependencies:   mbed

Fork of I2C_HelloWorld_Mbed by mbed official

Committer:
marcus255
Date:
Tue Dec 15 22:44:03 2015 +0000
Revision:
7:b07706b16279
Parent:
5:8dc6d7d81250
Child:
8:3e6945d5d9a1
memore read/write works fine

Who changed what in which revision?

UserRevisionLine numberNew contents of line
marcus255 4:1ec553356dcc 1 #ifndef MAIN_H
marcus255 4:1ec553356dcc 2 #define MAIN_H
marcus255 4:1ec553356dcc 3
marcus255 4:1ec553356dcc 4 #include "mbed.h"
marcus255 4:1ec553356dcc 5 #define SLAVE_ADDR 0xA0
marcus255 7:b07706b16279 6 #define DATA_SIZE 16
marcus255 4:1ec553356dcc 7
marcus255 4:1ec553356dcc 8 I2C i2c(PTE0, PTE1);
marcus255 4:1ec553356dcc 9 Serial pc(USBTX, USBRX);
marcus255 4:1ec553356dcc 10 DigitalOut led(LED_GREEN);
marcus255 4:1ec553356dcc 11 Ticker i2c_ticker;
marcus255 5:8dc6d7d81250 12 void write_data(void);
marcus255 7:b07706b16279 13 void read_data(char*);
marcus255 5:8dc6d7d81250 14 void write_and_read(void);
marcus255 4:1ec553356dcc 15 void init(void);
marcus255 4:1ec553356dcc 16 char data[DATA_SIZE];
marcus255 4:1ec553356dcc 17
marcus255 4:1ec553356dcc 18
marcus255 4:1ec553356dcc 19 #endif