\doxysection{7Semi\+\_\+\+I2\+C\+\_\+\+Interface.\+h}
\hypertarget{7Semi__I2C__Interface_8h_source}{}\label{7Semi__I2C__Interface_8h_source}\index{src/7Semi\_I2C\_Interface.h@{src/7Semi\_I2C\_Interface.h}}
\mbox{\hyperlink{7Semi__I2C__Interface_8h}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00001}00001\ \textcolor{preprocessor}{\#pragma\ once}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00002}00002\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{7Semi__Interface_8h}{7Semi\_Interface.h}}"{}}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00003}00003\ \textcolor{preprocessor}{\#include\ <Wire.h>}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00004}00004\ }
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00005}\mbox{\hyperlink{classI2C__Interface}{00005}}\ \textcolor{keyword}{class\ }\mbox{\hyperlink{classI2C__Interface}{I2C\_Interface}}\ :\ \textcolor{keyword}{public}\ \mbox{\hyperlink{classInterface__7Semi}{Interface\_7Semi}}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00006}00006\ \{}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00007}00007\ \textcolor{keyword}{public}:}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00008}\mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{00008}}\ \ \ \ \ TwoWire\ *\mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}}\ =\ \textcolor{keyword}{nullptr};}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00009}\mbox{\hyperlink{classI2C__Interface_a82b99f14771cafc58b37708e3cb9bf6e}{00009}}\ \ \ \ \ uint8\_t\ \mbox{\hyperlink{classI2C__Interface_a82b99f14771cafc58b37708e3cb9bf6e}{address}}\ =\ 0;}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00010}00010\ }
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00011}\mbox{\hyperlink{classI2C__Interface_ae8147c4d6e54fe2622825d7e17493152}{00011}}\ \ \ \ \ \textcolor{keywordtype}{bool}\ \mbox{\hyperlink{classI2C__Interface_ae8147c4d6e54fe2622825d7e17493152}{beginI2C}}(uint8\_t\ addr,\ TwoWire\ \&wire,\ uint32\_t\ speed,}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00012}00012\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uint8\_t\ sda\ =\ 255,\ uint8\_t\ scl\ =\ 255)}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00013}00013\ \ \ \ \ \{}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00014}00014\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{classI2C__Interface_a82b99f14771cafc58b37708e3cb9bf6e}{address}}\ =\ addr;}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00015}00015\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}}\ =\ \&wire;}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00016}00016\ }
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00017}00017\ \textcolor{preprocessor}{\#if\ defined(ESP32)}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00018}00018\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (sda\ !=\ 255\ \&\&\ scl\ !=\ 255)}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00019}00019\ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}}-\/>begin(sda,\ scl);}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00020}00020\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00021}00021\ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}}-\/>begin();}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00022}00022\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00023}00023\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}}-\/>begin();}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00024}00024\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00025}00025\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ i2c-\/>setClock(speed);}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00026}00026\ }
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00027}00027\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ Probe\ device}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00028}00028\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}}-\/>beginTransmission(\mbox{\hyperlink{classI2C__Interface_a82b99f14771cafc58b37708e3cb9bf6e}{address}});}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00029}00029\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ (\mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}}-\/>endTransmission()\ ==\ 0);}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00030}00030\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00031}00031\ }
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00032}\mbox{\hyperlink{classI2C__Interface_ae28f61d8a681f69a81d383f4b9d98fc9}{00032}}\ \ \ \ \ int8\_t\ \mbox{\hyperlink{classI2C__Interface_ae28f61d8a681f69a81d383f4b9d98fc9}{read}}(uint8\_t\ reg,\ uint8\_t\ *data,\ uint32\_t\ len)\textcolor{keyword}{\ override}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00033}00033\ \textcolor{keyword}{\ \ \ \ }\{}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00034}00034\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!\mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}})}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00035}00035\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00036}00036\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}}-\/>beginTransmission(\mbox{\hyperlink{classI2C__Interface_a82b99f14771cafc58b37708e3cb9bf6e}{address}});}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00037}00037\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}}-\/>write(reg\ );}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00038}00038\ }
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00039}00039\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (\mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}}-\/>endTransmission(\textcolor{keyword}{false})\ !=\ 0)}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00040}00040\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00041}00041\ }
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00042}00042\ \ \ \ \ \ \ \ \ delay(1);}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00043}00043\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00044}00044\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (len\ >\ 255)}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00045}00045\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/3;}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00046}00046\ \ \ \ \ \ \ \ \ uint8\_t\ received\ =\ \mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}}-\/>requestFrom(\mbox{\hyperlink{classI2C__Interface_a82b99f14771cafc58b37708e3cb9bf6e}{address}},\ (uint8\_t)len);}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00047}00047\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (received\ !=\ len)}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00048}00048\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/2;}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00049}00049\ }
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00050}00050\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (uint32\_t\ i\ =\ 0;\ i\ <\ len;\ i++)}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00051}00051\ \ \ \ \ \ \ \ \ \{}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00052}00052\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!\mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}}-\/>available())}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00053}00053\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/4;}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00054}00054\ \ \ \ \ \ \ \ \ \ \ \ \ data[i]\ =\ \mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}}-\/>read();}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00055}00055\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00056}00056\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ Serial.print("{}R-\/Reg:\ "{});}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00057}00057\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ Serial.print(reg,\ HEX);}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00058}00058\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ Serial.print("{}\ |Data:\ "{});}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00059}00059\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ for\ (int\ i\ =\ 0;\ i\ <\ len;\ i++)}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00060}00060\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ \{}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00061}00061\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ Serial.print("{}\ "{});}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00062}00062\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ Serial.print(data[i],\ HEX);}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00063}00063\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ \}}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00064}00064\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ Serial.println();}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00065}00065\ }
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00066}00066\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00067}00067\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00068}00068\ }
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00069}\mbox{\hyperlink{classI2C__Interface_ac8ffcc85b81a8e7e43f1cae80e17e06e}{00069}}\ \ \ \ \ \textcolor{keywordtype}{bool}\ \mbox{\hyperlink{classI2C__Interface_ac8ffcc85b81a8e7e43f1cae80e17e06e}{beginSPI}}(uint8\_t,\ SPIClass\ \&,\ uint32\_t,}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00070}00070\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uint8\_t,\ uint8\_t,\ uint8\_t)\textcolor{keyword}{\ override}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00071}00071\ \textcolor{keyword}{\ \ \ \ }\{}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00072}00072\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{false};}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00073}00073\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00074}00074\ }
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00075}\mbox{\hyperlink{classI2C__Interface_aa3191e7336ca8b3167f60aeee058a523}{00075}}\ \ \ \ \ int8\_t\ \mbox{\hyperlink{classI2C__Interface_aa3191e7336ca8b3167f60aeee058a523}{write}}(uint8\_t\ reg,\ \textcolor{keyword}{const}\ uint8\_t\ *data,\ uint32\_t\ len)\textcolor{keyword}{\ override}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00076}00076\ \textcolor{keyword}{\ \ \ \ }\{}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00077}00077\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!\mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}})}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00078}00078\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00079}00079\ }
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00080}00080\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}}-\/>beginTransmission(\mbox{\hyperlink{classI2C__Interface_a82b99f14771cafc58b37708e3cb9bf6e}{address}});}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00081}00081\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}}-\/>write(reg);}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00082}00082\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (uint32\_t\ i\ =\ 0;\ i\ <\ len;\ i++)}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00083}00083\ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}}-\/>write(data[i]);}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00084}00084\ }
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00085}00085\ \ \ \ \ \ \ \ \ uint8\_t\ status\ =\ \mbox{\hyperlink{classI2C__Interface_aef1b0cf102ef2b57d5e47279848ea575}{i2c}}-\/>endTransmission();}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00086}00086\ \ \ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00087}00087\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ Serial.print("{}W-\/Reg:\ "{});}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00088}00088\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ Serial.print(reg,\ HEX);}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00089}00089\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ Serial.print("{}\ |Data:\ "{});}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00090}00090\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ for\ (int\ i\ =\ 0;\ i\ <\ len;\ i++)}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00091}00091\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ \{}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00092}00092\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ Serial.print("{}\ "{});}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00093}00093\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ Serial.print(data[i],\ HEX);}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00094}00094\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ \}}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00095}00095\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ Serial.println();}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00096}00096\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ (status\ ==\ 0)\ ?\ 0\ :\ -\/status;}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00097}00097\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{7Semi__I2C__Interface_8h_source_l00098}00098\ \};}

\end{DoxyCode}
