@@ -30,77 +30,77 @@ SOFTWARE.
3030
3131#define AP3_WIRE_RX_BUFFER_LEN 256
3232#define AP3_WIRE_TX_BUFFER_LEN 256
33- #define AP3_WIRE_LINEAR_BUFFER_LEN (AP3_WIRE_RX_BUFFER_LEN+ AP3_WIRE_TX_BUFFER_LEN)
33+ #define AP3_WIRE_LINEAR_BUFFER_LEN (AP3_WIRE_RX_BUFFER_LEN + AP3_WIRE_TX_BUFFER_LEN)
3434
35- // WIRE_HAS_END means Wire has end()
35+ // WIRE_HAS_END means Wire has end()
3636#define WIRE_HAS_END 1
3737
38- class TwoWire : public Stream , public IOMaster {
39- public:
40- TwoWire ( uint8_t iom_instance);
41- void begin ( );
42- void begin (uint8_t , bool enableGeneralCall = false );
43- void end ( );
44- void setClock ( uint32_t );
45-
46- void beginTransmission ( uint8_t address);
47- uint8_t endTransmission ( bool stopBit = true );
48-
49- uint8_t requestFrom ( uint8_t address, size_t quantity, bool stopBit = true );
50-
51- size_t write ( uint8_t data);
52- size_t write (const uint8_t * data, size_t quantity );
53-
54- virtual int available ( void );
55- virtual int read (void );
56- virtual int peek (void );
57- virtual void flush (void );
58- void onReceive (void (*)( int ) );
59- void onRequest (void (*)(void ));
60-
61- inline size_t write ( unsigned long n) { return write (( uint8_t )n); }
62- inline size_t write (long n) { return write ((uint8_t )n); }
63- inline size_t write (unsigned int n) { return write ((uint8_t )n); }
64- inline size_t write (int n) { return write ((uint8_t )n); }
65- using Print:: write;
66-
67- void onService ( void );
68-
69- private:
70- ap3_gpio_pin_t _padSDA;
71- ap3_gpio_pin_t _padSCL ;
72-
73- bool _transmissionBegun;
74- uint8_t _transmissionAddress ;
75-
76-
77- RingBufferN<AP3_WIRE_RX_BUFFER_LEN> _rxBuffer;// RX Buffer
78- RingBufferN<AP3_WIRE_TX_BUFFER_LEN> _txBuffer;// TX buffer
79- uint8_t _linearBugger[AP3_WIRE_LINEAR_BUFFER_LEN]; // ToDo: choose a more efficient way to handle this
80- uint8_t txAddress;
81-
82- // Callback user functions
83- void (*_onRequestCallback)(void );
84- void (*_onReceiveCallback)(int );
38+ class TwoWire : public Stream , public IOMaster
39+ {
40+ public:
41+ TwoWire ( uint8_t iom_instance );
42+ void begin ();
43+ void begin ( uint8_t , bool enableGeneralCall = false );
44+ void end ( );
45+ void setClock ( uint32_t );
46+
47+ void beginTransmission ( uint8_t address );
48+ uint8_t endTransmission ( bool stopBit = true );
49+
50+ uint8_t requestFrom ( uint8_t address, size_t quantity, bool stopBit = true );
51+
52+ size_t write (uint8_t data);
53+ size_t write ( const uint8_t *data, size_t quantity);
54+
55+ virtual int available (void );
56+ virtual int read (void );
57+ virtual int peek (void );
58+ virtual void flush (void );
59+ void onReceive (void (*)(int ));
60+ void onRequest ( void (*)( void ));
61+
62+ inline size_t write (unsigned long n) { return write ((uint8_t )n); }
63+ inline size_t write (long n) { return write ((uint8_t )n); }
64+ inline size_t write (unsigned int n) { return write ((uint8_t )n); }
65+ inline size_t write ( int n) { return write (( uint8_t )n); }
66+ using Print::write;
67+
68+ void onService ( void );
69+
70+ private:
71+ ap3_gpio_pin_t _padSDA ;
72+ ap3_gpio_pin_t _padSCL;
73+
74+ bool _transmissionBegun ;
75+ uint8_t _transmissionAddress;
76+
77+ RingBufferN<AP3_WIRE_RX_BUFFER_LEN> _rxBuffer; // RX Buffer
78+ RingBufferN<AP3_WIRE_TX_BUFFER_LEN> _txBuffer; // TX buffer
79+ uint8_t _linearBugger[AP3_WIRE_LINEAR_BUFFER_LEN]; // ToDo: choose a more efficient way to handle this
80+ uint8_t txAddress;
81+
82+ // Callback user functions
83+ void (*_onRequestCallback)(void );
84+ void (*_onReceiveCallback)(int );
8585};
8686
8787#if WIRE_INTERFACES_COUNT > 0
88- extern TwoWire Wire;
88+ extern TwoWire Wire;
8989#endif
9090#if WIRE_INTERFACES_COUNT > 1
91- extern TwoWire Wire1;
91+ extern TwoWire Wire1;
9292#endif
9393#if WIRE_INTERFACES_COUNT > 2
94- extern TwoWire Wire2;
94+ extern TwoWire Wire2;
9595#endif
9696#if WIRE_INTERFACES_COUNT > 3
97- extern TwoWire Wire3;
97+ extern TwoWire Wire3;
9898#endif
9999#if WIRE_INTERFACES_COUNT > 4
100- extern TwoWire Wire4;
100+ extern TwoWire Wire4;
101101#endif
102102#if WIRE_INTERFACES_COUNT > 5
103- extern TwoWire Wire5;
103+ extern TwoWire Wire5;
104104#endif
105105
106106#endif // _AP3_WIRE_H_
0 commit comments