i2c slave class to RaspberryPi with interrupt
Fork of i2cslave by
i2cslave.h@3:5d19d3a231b3, 2018-07-15 (annotated)
- Committer:
- sgrsn
- Date:
- Sun Jul 15 14:20:26 2018 +0000
- Revision:
- 3:5d19d3a231b3
- Parent:
- 2:0dff052266ca
i2c slave class to RaspberryPi with interrupt
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sgrsn | 0:69b088a9899b | 1 | #ifndef MBED_I2CSLAVE_H |
sgrsn | 0:69b088a9899b | 2 | #define MBED_I2CSLAVE_H |
sgrsn | 0:69b088a9899b | 3 | |
sgrsn | 0:69b088a9899b | 4 | #include "mbed.h" |
sgrsn | 0:69b088a9899b | 5 | |
sgrsn | 3:5d19d3a231b3 | 6 | #define ReadRequired 1 |
sgrsn | 3:5d19d3a231b3 | 7 | #define WriteRequired 2 |
sgrsn | 3:5d19d3a231b3 | 8 | |
sgrsn | 0:69b088a9899b | 9 | namespace mbed { |
sgrsn | 0:69b088a9899b | 10 | |
sgrsn | 0:69b088a9899b | 11 | class i2cslave : public I2CSlave |
sgrsn | 0:69b088a9899b | 12 | { |
sgrsn | 0:69b088a9899b | 13 | public: |
sgrsn | 3:5d19d3a231b3 | 14 | int8_t *Registar; |
sgrsn | 3:5d19d3a231b3 | 15 | int log[10]; |
sgrsn | 3:5d19d3a231b3 | 16 | i2cslave(PinName sda, PinName scl, int8_t *Registar); |
sgrsn | 0:69b088a9899b | 17 | |
sgrsn | 0:69b088a9899b | 18 | void getdata(); |
sgrsn | 0:69b088a9899b | 19 | |
sgrsn | 0:69b088a9899b | 20 | void attach(void (*fptr)(void)); |
sgrsn | 0:69b088a9899b | 21 | |
sgrsn | 0:69b088a9899b | 22 | template<typename T> |
sgrsn | 0:69b088a9899b | 23 | void attach(T* tptr, void (T::*mptr)(void)) { |
sgrsn | 0:69b088a9899b | 24 | fp.attach(tptr, mptr); |
sgrsn | 0:69b088a9899b | 25 | enable_attach(); |
sgrsn | 0:69b088a9899b | 26 | } |
sgrsn | 0:69b088a9899b | 27 | |
sgrsn | 0:69b088a9899b | 28 | void enable_attach(); |
sgrsn | 0:69b088a9899b | 29 | |
sgrsn | 0:69b088a9899b | 30 | void disable_attach(); |
sgrsn | 0:69b088a9899b | 31 | |
sgrsn | 0:69b088a9899b | 32 | static void func_call(uint32_t id, uint8_t addr, uint8_t state); |
sgrsn | 0:69b088a9899b | 33 | |
sgrsn | 0:69b088a9899b | 34 | protected: |
sgrsn | 0:69b088a9899b | 35 | FunctionPointer fp; |
sgrsn | 0:69b088a9899b | 36 | |
sgrsn | 0:69b088a9899b | 37 | }; |
sgrsn | 0:69b088a9899b | 38 | |
sgrsn | 0:69b088a9899b | 39 | } |
sgrsn | 0:69b088a9899b | 40 | |
sgrsn | 0:69b088a9899b | 41 | #endif |