FastArduino  v1.8
C++ library to build fast but small Arduino/AVR projects
i2c.h
Go to the documentation of this file.
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 
16 
21 #ifndef I2C_HH
22 #define I2C_HH
23 
24 #include <stdint.h>
25 #include "streams.h"
26 
27 //NOTE only Master operation is supported for the moment
49 namespace i2c
50 {
65  enum class Status : uint8_t
66  {
68  OK = 0x00,
70  START_TRANSMITTED = 0x08,
72  REPEAT_START_TRANSMITTED = 0x10,
74  SLA_W_TRANSMITTED_ACK = 0x18,
76  SLA_W_TRANSMITTED_NACK = 0x20,
78  DATA_TRANSMITTED_ACK = 0x28,
80  DATA_TRANSMITTED_NACK = 0x30,
85  ARBITRATION_LOST = 0x38,
87  SLA_R_TRANSMITTED_ACK = 0x40,
89  SLA_R_TRANSMITTED_NACK = 0x48,
91  DATA_RECEIVED_ACK = 0x50,
93  DATA_RECEIVED_NACK = 0x58,
94  };
95 
97  streams::ostream& operator<<(streams::ostream& out, Status s);
99 
107  enum class I2CMode : uint8_t
108  {
110  STANDARD,
112  FAST
113  };
114 };
115 
116 #endif /* I2C_HH */
117 
streams::ostream
Output stream wrapper to provide formatted output API, a la C++.
Definition: streams.h:61
streams.h
C++-like std::iostream facilities.
i2c::I2CMode
I2CMode
I2C available transmission modes.
Definition: i2c.h:108
i2c::Status::OK
@ OK
Code indicating the last called method executed as expected without any issue.
i2c::Status
Status
Transmission status codes.
Definition: i2c.h:66
i2c
Define API to define and manage I2C devices.
Definition: i2c.cpp:18
i2c::I2CMode::STANDARD
@ STANDARD
I2C Standard mode, less than 100KHz.