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
main.cpp
- Committer:
- rrbeauch
- Date:
- 2014-11-19
- Revision:
- 0:942156b7d5e8
- Child:
- 1:d03710f41041
File content as of revision 0:942156b7d5e8:
#include "mbed.h" //------------------------------------------------------- //Title: main.cpp //Author: Richard Beauchemin //Date: 11/17/2014 //Description: Motherboard I2C communication test. //------------------------------------------------------- //------------------------------------------------------- //Global Variables I2C mI2C(p28,p27); DigitalOut sendLED(LED1); DigitalOut receiveLED(LED2); int dCardAddress = 0x02; //char msg[6] = {'(','T','E','S','T',')'}; char msg[2]; //------------------------------------------------------- //------------------------------------------------------- //Function Declarations int writeCell(int,char*); int writeRow(int,char[],int); //------------------------------------------------------- int writeCell(int address, char* data) { return mI2C.write((address),data,1,0); } int writeRow(int address, char data[], int length) { int ACK = 1; while(length) { ACK &= writeCell(address,&data[length - 1]); length--; } return ACK; } int main() { sendLED = 0; receiveLED = 0; //mI2C.frequency(100000); int data = 0x0001; while(1) { mI2C.write(data); sendLED = 1; mI2C.read((dCardAddress),msg,2,0); if(msg[0] || msg[1]) { receiveLED = 1; msg[0] = 0; msg[1] = 0; } wait(0.5); sendLED = 0; receiveLED = 0; } /*receiveLED = writeRow(dCardAddress, msg, 6); while(1) { sendLED = 1; wait(0.2); sendLED = 0; }*/ }