FastArduino  v1.8
C++ library to build fast but small Arduino/AVR projects
i2c_debug.cpp
1 // Copyright 2016-2021 Jean-Francois Poilpret
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "i2c_debug.h"
16 
17 namespace i2c::debug
18 {
20  // Add utility ostream manipulator for FutureStatus
21  static const flash::FlashStorage* convert(i2c::DebugStatus s)
22  {
23  switch (s)
24  {
26  return F("ST ");
27 
29  return F("RS ");
30 
32  return F("AW ");
33 
35  return F("AR ");
36 
38  return F("S ");
39 
41  return F("R ");
42 
44  return F("RL ");
45 
47  return F("SP ");
48 
49  case i2c::DebugStatus::SEND_OK:
50  return F("So ");
51 
52  case i2c::DebugStatus::SEND_ERROR:
53  return F("Se ");
54 
55  case i2c::DebugStatus::RECV_OK:
56  return F("Ro ");
57 
59  return F("Re ");
60  }
61  }
62 
64  {
65  return out << convert(s);
66  }
67 
69  {
70  return DEBUG(uint8_t(a) | uint8_t(b));
71  }
73 }
streams::ostream
Output stream wrapper to provide formatted output API, a la C++.
Definition: streams.h:61
i2c::DebugStatus::SLAW
@ SLAW
A slave address has just been sent for writing.
i2c::debug::DEBUG
DEBUG
Indicate what in I2C protocol shall be debugged.
Definition: i2c_debug.h:55
i2c::DebugStatus
DebugStatus
List of debug states that are reported by the I2C Manager in debug mode.
Definition: i2c_handler_common.h:44
i2c::DebugStatus::STOP
@ STOP
A stop condition has just been sent.
i2c::DebugStatus::REPEAT_START
@ REPEAT_START
A repeat start condition has just been sent.
i2c::DebugStatus::START
@ START
A start condition has just been sent.
timer::operator|
constexpr TimerInterrupt operator|(TimerInterrupt i1, TimerInterrupt i2)
Combine 2 timer interrupts for use with Timer.set_interrupts().
Definition: timer.h:254
i2c::DebugStatus::SLAR
@ SLAR
A slave address has just been sent for reading.
i2c::DebugStatus::RECV
@ RECV
A byte is being received from the slave.
i2c::DebugStatus::RECV_LAST
@ RECV_LAST
The last byte is being received from the slave.
i2c_debug.h
I2C debugging utilities (useful when implementing support for new devices).
i2c::debug
Defines API to ease I2C devices debugging.
Definition: i2c_debug.cpp:18
F
#define F(ptr)
Force string constant to be stored as flash storage.
Definition: flash.h:118
i2c::DebugStatus::SEND
@ SEND
A byte has just be sent to the slave.