Hortau / Mbed 2 deprecated Tensiometer_Simulator_waterbench

Dependencies:   mbed

Committer:
Blanglois
Date:
Tue Oct 30 15:52:54 2018 +0000
Revision:
0:265fff2cfb0a
Child:
1:85afd4bd4651
I2C Communication with ST

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Blanglois 0:265fff2cfb0a 1 #ifndef __I2C_SLAVE_COMM__
Blanglois 0:265fff2cfb0a 2 #define __I2C_SLAVE_COMM__
Blanglois 0:265fff2cfb0a 3
Blanglois 0:265fff2cfb0a 4 #define MAX_WRITE_SIZE 8
Blanglois 0:265fff2cfb0a 5 #include "mbed.h"
Blanglois 0:265fff2cfb0a 6
Blanglois 0:265fff2cfb0a 7
Blanglois 0:265fff2cfb0a 8 class I2CSlaveCustom : public I2CSlave
Blanglois 0:265fff2cfb0a 9 {
Blanglois 0:265fff2cfb0a 10 public:
Blanglois 0:265fff2cfb0a 11
Blanglois 0:265fff2cfb0a 12 I2CSlaveCustom(PinName sda, PinName scl) : I2CSlave(sda, scl)
Blanglois 0:265fff2cfb0a 13 {
Blanglois 0:265fff2cfb0a 14
Blanglois 0:265fff2cfb0a 15 }
Blanglois 0:265fff2cfb0a 16
Blanglois 0:265fff2cfb0a 17 int getCount()
Blanglois 0:265fff2cfb0a 18 {
Blanglois 0:265fff2cfb0a 19 int result = MAX_WRITE_SIZE - _i2c.i2c.handle.XferSize;
Blanglois 0:265fff2cfb0a 20 if (result > 8 || result < 0)
Blanglois 0:265fff2cfb0a 21 return 0;
Blanglois 0:265fff2cfb0a 22 return result;
Blanglois 0:265fff2cfb0a 23 }
Blanglois 0:265fff2cfb0a 24
Blanglois 0:265fff2cfb0a 25
Blanglois 0:265fff2cfb0a 26 };
Blanglois 0:265fff2cfb0a 27
Blanglois 0:265fff2cfb0a 28
Blanglois 0:265fff2cfb0a 29 void InitI2CSlaveComm();
Blanglois 0:265fff2cfb0a 30 void I2CSlaveProcess();
Blanglois 0:265fff2cfb0a 31 void setADC(unsigned short value);
Blanglois 0:265fff2cfb0a 32
Blanglois 0:265fff2cfb0a 33 #endif