Plese use this class with my "i2cmaster" class.
Dependents: 2016_slave_rorikon_2 2016_slave_cylinder 2016_slave_MD 2016_slave_MD_rorikon ... more
i2cslave.h@3:6e9ecf7b83e3, 2019-12-17 (annotated)
- Committer:
- sgrsn
- Date:
- Tue Dec 17 07:16:20 2019 +0000
- Revision:
- 3:6e9ecf7b83e3
- Parent:
- 2:0dff052266ca
Fix anything
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 | 0:69b088a9899b | 6 | namespace mbed { |
sgrsn | 0:69b088a9899b | 7 | |
sgrsn | 0:69b088a9899b | 8 | class i2cslave : public I2CSlave |
sgrsn | 0:69b088a9899b | 9 | { |
sgrsn | 0:69b088a9899b | 10 | public: |
sgrsn | 2:0dff052266ca | 11 | int32_t *Registar; |
sgrsn | 2:0dff052266ca | 12 | i2cslave(PinName sda, PinName scl, int32_t *Registar); |
sgrsn | 0:69b088a9899b | 13 | |
sgrsn | 0:69b088a9899b | 14 | void getdata(); |
sgrsn | 0:69b088a9899b | 15 | |
sgrsn | 0:69b088a9899b | 16 | void attach(void (*fptr)(void)); |
sgrsn | 0:69b088a9899b | 17 | |
sgrsn | 0:69b088a9899b | 18 | template<typename T> |
sgrsn | 0:69b088a9899b | 19 | void attach(T* tptr, void (T::*mptr)(void)) { |
sgrsn | 0:69b088a9899b | 20 | fp.attach(tptr, mptr); |
sgrsn | 0:69b088a9899b | 21 | enable_attach(); |
sgrsn | 0:69b088a9899b | 22 | } |
sgrsn | 0:69b088a9899b | 23 | |
sgrsn | 0:69b088a9899b | 24 | void enable_attach(); |
sgrsn | 0:69b088a9899b | 25 | |
sgrsn | 0:69b088a9899b | 26 | void disable_attach(); |
sgrsn | 0:69b088a9899b | 27 | |
sgrsn | 0:69b088a9899b | 28 | static void func_call(uint32_t id, uint8_t addr, uint8_t state); |
sgrsn | 0:69b088a9899b | 29 | |
sgrsn | 0:69b088a9899b | 30 | protected: |
sgrsn | 0:69b088a9899b | 31 | FunctionPointer fp; |
sgrsn | 0:69b088a9899b | 32 | |
sgrsn | 0:69b088a9899b | 33 | }; |
sgrsn | 0:69b088a9899b | 34 | |
sgrsn | 0:69b088a9899b | 35 | } |
sgrsn | 0:69b088a9899b | 36 | |
sgrsn | 0:69b088a9899b | 37 | #endif |