\doxysection{test.\+ino}
\hypertarget{test_8ino_source}{}\label{test_8ino_source}\index{examples/test/test.ino@{examples/test/test.ino}}
\mbox{\hyperlink{test_8ino}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00001}00001\ /**}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00002}00002\ \ *\ @file\ test.ino}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00003}00003\ \ *\ @brief\ Accelerometer\ DLPF\ validation\ sketch\ for\ the\ 7Semi\ ICM-\/20948.}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00004}00004\ \ *\ @details\ Runs\ an\ I2C\ accelerometer\ sweep\ across\ DLPF\ settings,\ prints\ sample}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00005}00005\ \ *\ data\ to\ Serial,\ and\ is\ intended\ for\ bench\ validation\ with\ the\ sensor\ flat\ and}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00006}00006\ \ *\ stationary.}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00007}00007\ \ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00008}00008\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00009}00009\ \#include\ <Wire.h>}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00010}00010\ \#include\ <DevLab\_ICM20948.h>}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00011}00011\ //\ -\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00012}00012\ //\ PINES\ I2C\ —\ ESP32C6\ NANO\ Unit\ Electronics}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00013}00013\ //\ -\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00014}00014\ /**\ @brief\ I2C\ SDA\ pin\ used\ by\ the\ example\ board.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00015}00015\ \#define\ SDA\_PIN\ \ \ \ \ \ \ \ \ 6}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00016}00016\ /**\ @brief\ I2C\ SCL\ pin\ used\ by\ the\ example\ board.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00017}00017\ \#define\ SCL\_PIN\ \ \ \ \ \ \ \ \ 7}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00018}00018\ /**\ @brief\ I2C\ bus\ speed\ in\ hertz.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00019}00019\ \#define\ I2C\_FREQ\ \ \ \ \ \ \ \ 400000UL\ \ \ //\ Fast\ Mode\ 400\ kHz}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00020}00020\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00021}00021\ //\ -\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00022}00022\ //\ DIRECCIONES\ I2C}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00023}00023\ //\ -\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00024}00024\ /**\ @brief\ ICM-\/20948\ I2C\ address\ selected\ by\ the\ AD0\ pin.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00025}00025\ \#define\ ICM\_ADDR\ \ \ \ \ \ \ \ 0x69\ \ \ \ \ \ \ //\ AD0\ =\ LOW\ (GND)}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00026}00026\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00027}00027\ /**\ @brief\ Accelerometer\ DLPF\ divider\ and\ timing\ configuration.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00028}00028\ struct\ configDLPF\ \{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00029}00029\ \ \ /**\ @brief\ Index\ into\ the\ accelDLPF\ lookup\ table.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00030}00030\ \ \ uint8\_t\ \ \ \ \ dlpf\_idx;}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00031}00031\ \ \ /**\ @brief\ Sample-\/rate\ divider\ written\ to\ the\ IMU\ register.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00032}00032\ \ \ uint16\_t\ \ \ \ div;\ \ \ \ \ \ \ //\ el\ valor\ REAL\ del\ registro,\ 0-\/4095,\ sin\ ambigüedad}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00033}00033\ \ \ /**\ @brief\ Noise\ bandwidth\ in\ hertz\ for\ reporting.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00034}00034\ \ \ float\ \ \ \ \ \ \ nbw\_hz;}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00035}00035\ \ \ /**\ @brief\ Output\ data\ rate\ in\ hertz\ for\ timing\ calculations.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00036}00036\ \ \ float\ \ \ \ \ \ \ odr\_hz;\ \ \ //\ =\ 1125.0f\ /\ (1\ +\ div),\ para\ calcular\ tiempos}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00037}00037\ \ \ /**\ @brief\ Text\ label\ printed\ with\ each\ captured\ sample.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00038}00038\ \ \ const\ char*\ nombre;}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00039}00039\ \};}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00040}00040\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00041}00041\ /**\ @brief\ Accelerometer\ DLPF\ configurations\ exercised\ by\ this\ validation.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00042}00042\ const\ configDLPF\ configsDLPF[]\ =\ \{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00043}00043\ \ \ //\ idx\ \ div\ \ \ NBW(Hz)\ \ \ ODR(Hz)\ \ \ \ nombre}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00044}00044\ \ \ \{\ \ 0,\ \ \ 0,\ \ \ 265.0f,\ \ 1125.0f,\ \ "{}DLPF0\_246\ |\ NBW=265Hz\ |\ ODR=1125Hz\ (4.2x)"{}\ \},}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00045}00045\ \ \ \{\ \ 1,\ \ \ 0,\ \ \ 265.0f,\ \ 1125.0f,\ \ "{}DLPF\_246\ \ |\ NBW=265Hz\ |\ ODR=1125Hz\ (4.2x)"{}\ \},}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00046}00046\ \ \ \{\ \ 2,\ \ \ 1,\ \ \ 136.0f,\ \ \ 562.5f,\ \ "{}DLPF\_111\ \ |\ NBW=136Hz\ |\ ODR=\ 562Hz\ (4.1x)"{}\ \},}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00047}00047\ \ \ \{\ \ 3,\ \ \ 3,\ \ \ \ 68.8f,\ \ \ 281.3f,\ \ "{}DLPF\_50\ \ \ |\ NBW=\ 69Hz\ |\ ODR=\ 281Hz\ (4.1x)"{}\ \},}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00048}00048\ \ \ \{\ \ 4,\ \ \ 7,\ \ \ \ 34.4f,\ \ \ 140.6f,\ \ "{}DLPF\_24\ \ \ |\ NBW=\ 34Hz\ |\ ODR=\ 141Hz\ (4.1x)"{}\ \},}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00049}00049\ \ \ \{\ \ 5,\ \ 15,\ \ \ \ 17.0f,\ \ \ \ 70.3f,\ \ "{}DLPF\_12\ \ \ |\ NBW=\ 17Hz\ |\ ODR=\ \ 70Hz\ (4.1x)"{}\ \},}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00050}00050\ \ \ \{\ \ 6,\ \ 31,\ \ \ \ \ 8.3f,\ \ \ \ 35.2f,\ \ "{}DLPF\_6\ \ \ \ |\ NBW=\ \ 8Hz\ |\ ODR=\ \ 35Hz\ (4.2x)"{}\ \},}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00051}00051\ \ \ \{\ \ 7,\ \ \ 0,\ \ \ 499.0f,\ \ 1125.0f,\ \ "{}DLPF\_473\ \ |\ NBW=499Hz\ |\ ODR=1125Hz\ (2.3x)"{}\ \},}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00052}00052\ \};}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00053}00053\ //-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00054}00054\ //\ \ ARRAYS\ DE\ CONFIGURACIÓN\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00055}00055\ //\ -\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00056}00056\ /**\ @brief\ Number\ of\ accelerometer\ DLPF\ configurations.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00057}00057\ const\ uint8\_t\ N\_DLPF\ =\ sizeof(configsDLPF)\ /\ sizeof(configsDLPF[0]);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00058}00058\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00059}00059\ /**\ @brief\ Accelerometer\ full-\/scale\ ranges\ available\ for\ validation.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00060}00060\ const\ ICM20948\_Accel\_FullScale\ accelCfg[]\ =\ \{\ ICM20948\_Accel\_FullScale::G\_2,\ ICM20948\_Accel\_FullScale::G\_4,\ ICM20948\_Accel\_FullScale::G\_8,\ ICM20948\_Accel\_FullScale::G\_16\};}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00061}00061\ /**\ @brief\ Text\ labels\ matching\ accelCfg.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00062}00062\ const\ char*\ etiquetasAccelCfg[]\ =\ \{"{}+-\/2G"{},"{}+-\/4G"{},\ "{}+-\/8G"{},\ "{}+-\/16G"{}\};}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00063}00063\ /**\ @brief\ Number\ of\ accelerometer\ full-\/scale\ ranges.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00064}00064\ const\ uint8\_t\ N\_FS\ =\ 4;}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00065}00065\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00066}00066\ /**\ @brief\ Accelerometer\ DLPF\ enum\ values\ matching\ configsDLPF.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00067}00067\ const\ ICM20948\_Accel\_DLPFCFG\ accelDLPF[]\ =\ \{\ ICM20948\_Accel\_DLPFCFG::DLPF0\_246HZ,\ ICM20948\_Accel\_DLPFCFG::DLPF\_246HZ,\ ICM20948\_Accel\_DLPFCFG::DLPF\_111HZ,\ ICM20948\_Accel\_DLPFCFG::DLPF\_50HZ,\ ICM20948\_Accel\_DLPFCFG::DLPF\_24HZ,\ ICM20948\_Accel\_DLPFCFG::DLPF\_12HZ,\ ICM20948\_Accel\_DLPFCFG::DLPF\_6HZ,ICM20948\_Accel\_DLPFCFG::DLPF\_473HZ\ \};}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00068}00068\ /**\ @brief\ Text\ labels\ describing\ accelDLPF\ bandwidth\ pairs.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00069}00069\ const\ char*\ etiquetasAccelDLPFCFG[]\ =\ \{\ "{}246/265"{},\ "{}246/265"{},\ "{}111/136"{},\ "{}50.4/68.8"{},"{}23.9/34.4"{},\ "{}11.5/17.0"{},\ "{}5.7/8.3"{},"{}473/499"{}\};}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00070}00070\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00071}00071\ /**\ @brief\ Accelerometer\ averaging\ settings\ available\ for\ validation.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00072}00072\ const\ ICM20948\_Accel\_Average\ accelAVG[]\ =\ \{ICM20948\_Accel\_Average::AVG\_1\_OR\_4\ ,ICM20948\_Accel\_Average::AVG\_8,\ ICM20948\_Accel\_Average::AVG\_16,\ ICM20948\_Accel\_Average::AVG\_32\};}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00073}00073\ /**\ @brief\ Text\ labels\ matching\ accelAVG.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00074}00074\ const\ char*\ etiquetasAccelAVG[]\ =\ \{"{}1\ OR\ 4"{},"{}8"{},"{}16"{},"{}32"{}\};}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00075}00075\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00076}00076\ /**\ @brief\ Raw\ accelerometer\ sample-\/rate\ divider\ values\ for\ experiments.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00077}00077\ const\ uint16\_t\ accelSR[]\ =\ \{0,\ 1,\ 3,\ 5,\ 7\ ,\ 10,\ 15,\ 22,\ 31,\ 63,\ 127,\ 255,\ 513,\ 1022,\ 2044,\ 4095\};}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00078}00078\ /**\ @brief\ Text\ labels\ matching\ accelSR\ output\ data\ rates.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00079}00079\ const\ char*\ etiquetasSR[]\ =\ \{\ "{}1125.0"{},"{}562.5"{},\ "{}281.3"{},\ "{}187.5"{},"{}140.6"{},\ "{}102.3"{},\ "{}70.3"{},\ "{}48.9"{},\ "{}35.2"{},\ "{}17.6"{},\ "{}8.8"{},\ "{}4.4"{},\ "{}2.2"{},\ "{}1.1"{},\ "{}0.55"{},\ "{}0.27"{}\};}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00080}00080\ //\ -\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00081}00081\ //\ \ INSTANCIA\ DEL\ SENSOR}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00082}00082\ //\ -\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00083}00083\ /**\ @brief\ Global\ ICM-\/20948\ driver\ instance.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00084}00084\ DevLab\_ICM20948\ imu;}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00085}00085\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00086}00086\ /**\ @brief\ Count\ of\ validation\ passes\ reserved\ for\ future\ checks.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00087}00087\ uint8\_t\ total\_pass\ =\ 0;}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00088}00088\ /**\ @brief\ Count\ of\ validation\ failures\ reserved\ for\ future\ checks.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00089}00089\ uint8\_t\ total\_fail\ =\ 0;}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00090}00090\ /**\ @brief\ Count\ of\ validation\ warnings\ reserved\ for\ future\ checks.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00091}00091\ uint8\_t\ total\_warn\ =\ 0;}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00092}00092\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00093}00093\ //\ ============================================================}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00094}00094\ //\ \ UTILIDADES\ DE\ IMPRESIÓN}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00095}00095\ //\ ============================================================}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00096}00096\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00097}00097\ /**\ @brief\ Print\ a\ separator\ line\ to\ Serial.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00098}00098\ void\ printLinea()\ \{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00099}00099\ \ \ Serial.println(F("{}-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/"{}));}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00100}00100\ \}}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00101}00101\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00102}00102\ /**\ @brief\ Print\ a\ double\ separator\ line\ to\ Serial.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00103}00103\ void\ printDobleLinea()\ \{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00104}00104\ \ \ Serial.println(F("{}============================================================"{}));}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00105}00105\ \}}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00106}00106\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00107}00107\ /**}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00108}00108\ \ *\ @brief\ Apply\ one\ accelerometer\ full-\/scale\ and\ DLPF\ configuration.}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00109}00109\ \ *}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00110}00110\ \ *\ @param\ fs\_idx\ Index\ into\ accelCfg.}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00111}00111\ \ *\ @param\ cfg\ DLPF\ timing\ and\ divider\ configuration.}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00112}00112\ \ *\ @return\ true\ if\ all\ configuration\ writes\ succeeded,\ otherwise\ false.}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00113}00113\ \ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00114}00114\ bool\ applySettings(uint8\_t\ fs\_idx,const\ configDLPF\ \&cfg)\{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00115}00115\ \ \ uint8\_t\ dlpf\_val\ =\ (uint8\_t)accelDLPF[cfg.dlpf\_idx];}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00116}00116\ \ \ bool\ ok\ =\ true;}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00117}00117\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00118}00118\ \ \ ok\ \&=\ imu.setAccelScale(accelCfg[fs\_idx]);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00119}00119\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00120}00120\ \ \ ok\ \&=\ imu.setAccelDLPF(dlpf\_val,false);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00121}00121\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00122}00122\ \ \ ok\ \&=\ imu.setAccelDivRate(cfg.div);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00123}00123\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00124}00124\ \ \ return\ ok;}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00125}00125\ \}}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00126}00126\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00127}00127\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00128}00128\ /**}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00129}00129\ \ *\ @brief\ Verify\ the\ IMU\ identity\ register.}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00130}00130\ \ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00131}00131\ void\ firstStage()\{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00132}00132\ \ \ uint8\_t\ who;}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00133}00133\ \ \ if\ (!imu.readWhoAmI(who)\ ||\ who\ !=\ 0xEA)\ \{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00134}00134\ \ \ \ \ Serial.println(F("{}ERROR:\ WHO\_AM\_I\ mismatch"{}));}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00135}00135\ \ \ \ \ while\ (1)\ delay(200);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00136}00136\ \ \ \}}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00137}00137\ \ \ Serial.print(F("{}WHO\_AM\_I\ =\ 0x"{}));}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00138}00138\ \ \ Serial.println(who,\ HEX);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00139}00139\ \}}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00140}00140\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00141}00141\ /**}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00142}00142\ \ *\ @brief\ Run\ the\ accelerometer\ DLPF\ validation\ sweep\ and\ print\ samples.}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00143}00143\ \ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00144}00144\ void\ runSweep()\{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00145}00145\ \ \ printDobleLinea();}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00146}00146\ \ \ Serial.println("{}Acelerometro\ ICM-\/200948\ |\ UNIT\ Electronics"{});}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00147}00147\ \ \ Serial.printf("{}\%d\ DLPFS\ x\ \%d\ FS\ =\ \%d\ combinaciones\(\backslash\)n"{},N\_DLPF,N\_FS,N\_DLPF\ *\ N\_FS);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00148}00148\ \ \ Serial.println(F("{}Coloque\ el\ sensor\ plano\ y\ quieto\ mirando\ hacia\ arriba"{}));}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00149}00149\ \ \ printDobleLinea();}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00150}00150\ \ \ for(uint8\_t\ d\ =\ 0;\ d\ <\ N\_DLPF;\ d++)\{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00151}00151\ \ \ \ \ Serial.printf("{}\ BLOQUE\ \%d/\%d:\ \%s\(\backslash\)n"{},\ d+1,\ N\_DLPF,configsDLPF[d].nombre);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00152}00152\ \ \ \ \ Serial.printf("{}\ ODR\ =\ \%.1fHz\ |\ Delay\ =\ \%lums\ |\ Periodo=\ \%.1fms\(\backslash\)n"{},configsDLPF[d].odr\_hz,max((uint32\_t)(10000.0f/configsDLPF[d].odr\_hz),(uint32\_t)50),}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00153}00153\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 1000.0f/configsDLPF[d].odr\_hz);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00154}00154\ \ \ printDobleLinea();}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00155}00155\ \ \ bool\ cfg\_ok\ =\ applySettings(configsDLPF[d].dlpf\_idx,\ configsDLPF[d]);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00156}00156\ \ \ if\ (!cfg\_ok)\ \{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00157}00157\ \ \ \ \ Serial.println(F("{}\ \ ERROR:\ applySettings()\ fallo"{}));}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00158}00158\ \ \ \ \ continue;}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00159}00159\ \ \ \}}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00160}00160\ \ \ //\ Esperar\ que\ el\ filtro\ estabilice\ (10\ periodos\ del\ ODR,\ min\ 50ms)}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00161}00161\ \ \ \ \ uint32\_t\ settle\_ms\ =\ max((uint32\_t)(10000.0f\ /\ configsDLPF[d].odr\_hz),}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00162}00162\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (uint32\_t)50);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00163}00163\ \ \ \ \ delay(settle\_ms);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00164}00164\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00165}00165\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00166}00166\ \ \ \ \ //\ Tomar\ 3\ lecturas\ espaciadas\ por\ el\ periodo\ del\ ODR}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00167}00167\ \ \ \ \ uint32\_t\ periodo\_ms\ =\ max((uint32\_t)(1000.0f\ /\ configsDLPF[d].odr\_hz),}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00168}00168\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (uint32\_t)1);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00169}00169\ \ \ \ \ float\ ax,\ ay,\ az;}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00170}00170\ \ \ \ \ for\ (uint8\_t\ r\ =\ 0;\ r\ <\ 3;\ r++)\ \{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00171}00171\ \ \ \ \ \ \ delay(periodo\_ms);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00172}00172\ \ \ \ \ \ \ if\ (imu.readAccel(ax,\ ay,\ az))\ \{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00173}00173\ \ \ \ \ \ \ \ \ Serial.printf("{}\ \ [\%d]\ Ax=\%+.3f\ \ Ay=\%+.3f\ \ Az=\%+.3f\ g\(\backslash\)n"{},}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00174}00174\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ r+1,\ ax,\ ay,\ az);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00175}00175\ \ \ \ \ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00176}00176\ \ \ \ \ \ \ \ \ Serial.println(F("{}\ \ [?]\ readAccel()\ fallo"{}));}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00177}00177\ \ \ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00178}00178\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00179}00179\ \ \ printLinea();}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00180}00180\ \ \ \}}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00181}00181\ \}}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00182}00182\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00183}00183\ /**}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00184}00184\ \ *\ @brief\ Initialize\ I2C,\ reset/wake\ the\ IMU,\ enable\ sensors,\ and\ start\ sweep.}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00185}00185\ \ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00186}00186\ void\ setup()\ \{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00187}00187\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00188}00188\ \ \ Serial.begin(115200);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00189}00189\ \ \ delay(200);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00190}00190\ \ \ Serial.println(F("{}ICM-\/20948\ —\ I2C\ Basic"{}));}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00191}00191\ \ \ printDobleLinea();}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00192}00192\ \ \ Serial.println(F("{}\ \ ICM-\/20948\ VALIDACION\ ACELEROMETRO"{}));}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00193}00193\ \ \ printDobleLinea();}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00194}00194\ \ \ //\ I2C\ init\ (UNO/ESP32\ defaults).\ For\ ESP32\ custom\ pins:\ Wire.begin(SDA,SCL);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00195}00195\ \ \ Wire.begin(SDA\_PIN,SCL\_PIN);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00196}00196\ \ \ //\ Attach\ IMU}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00197}00197\ \ \ if\ (!imu.beginI2C(ICM\_ADDR,Wire,I2C\_FREQ))\ \{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00198}00198\ \ \ \ \ Serial.println(F("{}ERROR:\ begin(I2C)\ failed"{}));}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00199}00199\ \ \ \ \ while\ (1)\ delay(200);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00200}00200\ \ \ \}}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00201}00201\ \ \ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00202}00202\ \ \ firstStage();}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00203}00203\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00204}00204\ \ \ imu.softReset();}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00205}00205\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00206}00206\ \ \ imu.sleep(false);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00207}00207\ \ \ delay(50);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00208}00208\ \ \ /*\ Enable\ all\ sensors.\ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00209}00209\ \ \ if\ (!imu.setSensors(true,\ true,\ true))\ \{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00210}00210\ \ \ \ \ Serial.println(F("{}ERROR:\ setSensors\ failed"{}));}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00211}00211\ \ \ \}}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00212}00212\ \ \ Serial.println(F("{}\ \ Sensor\ listo.\(\backslash\)n"{}));}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00213}00213\ \ \ Serial.println(F("{}\ \ Sensor\ PLANO\ y\ QUIETO\ sobre\ la\ mesa."{}));}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00214}00214\ \ \ Serial.println(F("{}\ \ Iniciando\ en\ 5\ segundos..."{}));}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00215}00215\ \ \ for\ (int\ i\ =\ 5;\ i\ >\ 0;\ i-\/-\/)\ \{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00216}00216\ \ \ \ \ Serial.printf("{}\ \ \%d...\(\backslash\)n"{},\ i);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00217}00217\ \ \ \ \ delay(1000);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00218}00218\ \ \ \}}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00219}00219\ \ \ runSweep();\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00220}00220\ \}}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00221}00221\ }
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00222}00222\ /**}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00223}00223\ \ *\ @brief\ Optional\ post-\/sweep\ loop\ for\ manual\ accelerometer\ reads.}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00224}00224\ \ */}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00225}00225\ void\ loop()\ \{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00226}00226\ \ \ /*float\ ax,\ ay,\ az;}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00227}00227\ \ \ if\ (imu.readAccel(ax,\ ay,\ az))\ \{}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00228}00228\ \ \ \ \ Serial.printf("{}X:\%.3f\ \ Y:\%.3f\ \ Z:\%.3f\(\backslash\)n"{},\ ax,\ ay,\ az);}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00229}00229\ \ \ \}}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00230}00230\ \ \ delay(200);*/}
\DoxyCodeLine{\Hypertarget{test_8ino_source_l00231}00231\ \}}

\end{DoxyCode}
