\doxysection{gyr\+\_\+test.\+ino}
\hypertarget{gyr__test_8ino_source}{}\label{gyr__test_8ino_source}\index{examples/gyr\_test/gyr\_test.ino@{examples/gyr\_test/gyr\_test.ino}}
\mbox{\hyperlink{gyr__test_8ino}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00001}00001\ /**}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00002}00002\ \ *\ @file\ gyr\_test.ino}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00003}00003\ \ *\ @brief\ Gyroscope\ DLPF\ and\ full-\/scale\ sweep\ for\ the\ 7Semi\ ICM-\/20948.}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00004}00004\ \ *\ @details\ Applies\ each\ gyroscope\ filter/full-\/scale\ configuration\ over\ I2C\ and}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00005}00005\ \ *\ prints\ repeated\ samples\ for\ validation\ and\ noise\ comparison.}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00006}00006\ \ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00007}00007\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00008}00008\ \#include\ <Wire.h>}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00009}00009\ \#include\ <DevLab\_ICM20948.h>}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00010}00010\ //\ -\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00011}00011\ //\ PINES\ I2C\ —\ ESP32C6\ NANO\ Unit\ Electronics}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00012}00012\ //\ -\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00013}00013\ /**\ @brief\ I2C\ SDA\ pin\ used\ by\ the\ example\ board.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00014}00014\ \#define\ SDA\_PIN\ \ \ 6}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00015}00015\ /**\ @brief\ I2C\ SCL\ pin\ used\ by\ the\ example\ board.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00016}00016\ \#define\ SCL\_PIN\ \ \ 7}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00017}00017\ /**\ @brief\ I2C\ bus\ speed\ in\ hertz.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00018}00018\ \#define\ I2C\_FREQ\ \ 400000UL}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00019}00019\ /**\ @brief\ ICM-\/20948\ I2C\ address\ selected\ by\ the\ AD0\ pin.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00020}00020\ \#define\ ICM\_ADDR\ \ 0x69}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00021}00021\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00022}00022\ //\ -\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00023}00023\ //\ STRUCT}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00024}00024\ //\ -\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00025}00025\ /**\ @brief\ Gyroscope\ DLPF\ divider\ and\ timing\ configuration.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00026}00026\ struct\ configDLPF\ \{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00027}00027\ \ \ /**\ @brief\ Index\ into\ the\ gyroDLPF\ lookup\ table.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00028}00028\ \ \ uint8\_t\ \ \ \ \ dlpf\_idx;}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00029}00029\ \ \ /**\ @brief\ Sample-\/rate\ divider\ written\ to\ the\ IMU\ register.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00030}00030\ \ \ uint16\_t\ \ \ \ div;}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00031}00031\ \ \ /**\ @brief\ Noise\ bandwidth\ in\ hertz\ for\ reporting.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00032}00032\ \ \ float\ \ \ \ \ \ \ nbw\_hz;}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00033}00033\ \ \ /**\ @brief\ Output\ data\ rate\ in\ hertz\ for\ timing\ calculations.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00034}00034\ \ \ float\ \ \ \ \ \ \ odr\_hz;}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00035}00035\ \ \ /**\ @brief\ Text\ label\ printed\ with\ each\ captured\ sample.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00036}00036\ \ \ const\ char*\ nombre;}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00037}00037\ \};}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00038}00038\ //id,div,nbw\_hz,odr\_hz,nombre\ :\ \{DLPF,\ NBW\ ,\ ODR\}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00039}00039\ /*}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00040}00040\ /**\ @brief\ Gyroscope\ DLPF\ configurations\ exercised\ by\ the\ sweep.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00041}00041\ const\ configDLPF\ configsDLPF[]\ =\ \{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00042}00042\ \ \ \{\ \ 0,\ \ \ 0,\ \ 229.8f,\ 1125.0f,\ "{}196,6\ ;\ 229,8\ ;\ 1125.0\ "{}\ \},}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00043}00043\ \ \ \{\ \ 1,\ \ \ 0,\ \ 187.6f,\ 1125.0f,\ "{}151,8\ ;\ 187.6\ ;\ 1125.0\ "{}\ \},}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00044}00044\ \ \ \{\ \ 2,\ \ \ 0,\ \ 154.3f,\ \ 1125.0f,\ "{}119,5\ ;\ 154,3\ ;\ 1125.0\ "{}\ \},}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00045}00045\ \ \ \{\ \ 3,\ \ \ 2,\ \ \ 73.3f,\ \ 375.0f,\ "{}51,2\ ;\ 73,3\ ;\ 375\ "{}\ \},}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00046}00046\ \ \ \{\ \ 4,\ \ \ 5,\ \ \ 35.9f,\ \ 187.5f,\ "{}23,9\ ;\ 35,9\ ;\ 187.5\ "{}\ \},}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00047}00047\ \ \ \{\ \ 5,\ \ 14,\ \ \ 17.8f,\ \ \ 75.0f,\ "{}11,6\ ;\ 17,8\ ;\ \ 75.0\ "{}\ \},}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00048}00048\ \ \ \{\ \ 6,\ \ 29,\ \ \ \ 8.9f,\ \ \ 37.5f,\ "{}5,7\ ;\ 8,9\ ;\ \ 37.5\ "{}\ \},}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00049}00049\ \ \ \{\ \ 7,\ \ \ 0,\ \ 376.5f,\ 1125.0f,\ "{}361,4\ ;\ 376,5\ ;\ 1125\ "{}\ \},}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00050}00050\ \};*/}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00051}00051\ const\ configDLPF\ configsDLPF[]\ =\ \{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00052}00052\ \ \ \{\ \ 0,\ \ \ 0,\ \ 229.8f,\ 1125.0f,\ "{}196,6\ ;\ 229,8\ ;\ 1125.0\ "{}\ \},}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00053}00053\ \ \ \{\ \ 1,\ \ \ 0,\ \ 187.6f,\ 1125.0f,\ "{}151,8\ ;\ 187.6\ ;\ 1125.0\ "{}\ \},}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00054}00054\ \ \ \{\ \ 2,\ \ \ 0,\ \ 154.3f,\ \ 1125.0f,\ "{}119,5\ ;\ 154,3\ ;\ 1125.0\ "{}\ \},}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00055}00055\ \ \ \{\ \ 3,\ \ \ 2,\ \ \ 73.3f,\ \ 375.0f,\ "{}51,2\ ;\ 73,3\ ;\ 375\ "{}\ \},}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00056}00056\ \ \ \{\ \ 4,\ \ \ 5,\ \ \ 35.9f,\ \ 187.5f,\ "{}23,9\ ;\ 35,9\ ;\ 187.5\ "{}\ \},}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00057}00057\ \ \ \{\ \ 5,\ \ 14,\ \ \ 17.8f,\ \ \ 75.0f,\ "{}11,6\ ;\ 17,8\ ;\ \ 75.0\ "{}\ \},}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00058}00058\ \ \ \{\ \ 6,\ \ 29,\ \ \ \ 8.9f,\ \ \ 37.5f,\ "{}5,7\ ;\ 8,9\ ;\ \ 37.5\ "{}\ \},}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00059}00059\ \ \ \{\ \ 7,\ \ \ 0,\ \ 376.5f,\ 1125.0f,\ "{}361,4\ ;\ 376,5\ ;\ 1125\ "{}\ \},}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00060}00060\ \};}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00061}00061\ /**\ @brief\ Number\ of\ gyroscope\ DLPF\ configurations.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00062}00062\ const\ uint8\_t\ N\_DLPF\ =\ sizeof(configsDLPF)\ /\ sizeof(configsDLPF[0]);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00063}00063\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00064}00064\ /**\ @brief\ Gyroscope\ full-\/scale\ ranges\ exercised\ by\ the\ sweep.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00065}00065\ const\ ICM20948\_Gyro\_FullScale\ gyroFSCfg[]\ =\ \{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00066}00066\ \ \ ICM20948\_Gyro\_FullScale::DPS\_250,}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00067}00067\ \ \ ICM20948\_Gyro\_FullScale::DPS\_500,}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00068}00068\ \ \ ICM20948\_Gyro\_FullScale::DPS\_1000,}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00069}00069\ \ \ ICM20948\_Gyro\_FullScale::DPS\_2000}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00070}00070\ \};}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00071}00071\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00072}00072\ /**\ @brief\ Text\ labels\ matching\ gyroFSCfg.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00073}00073\ const\ char*\ etiquetasGyroFSCfg[]\ =\ \{"{}250"{},\ "{}500"{},\ "{}1000"{},\ "{}2000"{}\};}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00074}00074\ /**\ @brief\ Number\ of\ gyroscope\ full-\/scale\ ranges.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00075}00075\ const\ uint8\_t\ N\_FS\ =\ 4;}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00076}00076\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00077}00077\ /**\ @brief\ Gyroscope\ DLPF\ enum\ values\ matching\ configsDLPF.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00078}00078\ const\ ICM20948\_Gyro\_DLPF\ gyroDLPF[]\ =\ \{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00079}00079\ \ \ ICM20948\_Gyro\_DLPF::DLPF\_196HZ,}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00080}00080\ \ \ ICM20948\_Gyro\_DLPF::DLPF\_151HZ,}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00081}00081\ \ \ ICM20948\_Gyro\_DLPF::DLPF\_119HZ,}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00082}00082\ \ \ ICM20948\_Gyro\_DLPF::DLPF\_51HZ,}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00083}00083\ \ \ ICM20948\_Gyro\_DLPF::DLPF\_23HZ,}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00084}00084\ \ \ ICM20948\_Gyro\_DLPF::DLPF\_11HZ,}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00085}00085\ \ \ ICM20948\_Gyro\_DLPF::DLPF\_5HZ,}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00086}00086\ \ \ ICM20948\_Gyro\_DLPF::DLPF\_361HZ}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00087}00087\ \};}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00088}00088\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00089}00089\ /**\ @brief\ Gyroscope\ averaging\ settings\ available\ for\ experiments.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00090}00090\ const\ ICM20948\_Gyro\_Average\ gyroAVGCfg[]=\ \{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00091}00091\ \ \ ICM20948\_Gyro\_Average::AVG\_1,}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00092}00092\ \ \ ICM20948\_Gyro\_Average::AVG\_2,}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00093}00093\ \ \ ICM20948\_Gyro\_Average::AVG\_4,}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00094}00094\ \ \ ICM20948\_Gyro\_Average::AVG\_8,}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00095}00095\ \ \ ICM20948\_Gyro\_Average::AVG\_16,}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00096}00096\ \ \ ICM20948\_Gyro\_Average::AVG\_32,}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00097}00097\ \ \ ICM20948\_Gyro\_Average::AVG\_64,}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00098}00098\ \ \ ICM20948\_Gyro\_Average::AVG\_128}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00099}00099\ \};\ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00100}00100\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00101}00101\ /**\ @brief\ Text\ labels\ matching\ gyroAVGCfg.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00102}00102\ const\ char*\ etiquetasGyroAVGCfg[]\ =\ \{"{}1"{},"{}2"{},"{}4"{},"{}8"{},"{}16"{},"{}32"{},"{}64"{},"{}128"{}\};}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00103}00103\ /**\ @brief\ Number\ of\ gyroscope\ averaging\ settings.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00104}00104\ const\ uint8\_t\ N\_AVG\ =\ 8;}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00105}00105\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00106}00106\ /**\ @brief\ Global\ ICM-\/20948\ driver\ instance.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00107}00107\ DevLab\_ICM20948\ imu;}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00108}00108\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00109}00109\ /**\ @brief\ Print\ a\ separator\ line\ to\ Serial.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00110}00110\ void\ printLinea()\ \ \ \ \ \ \{\ Serial.println(F("{}-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/"{}));\ \}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00111}00111\ /**\ @brief\ Print\ a\ double\ separator\ line\ to\ Serial.\ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00112}00112\ void\ printDobleLinea()\ \{\ Serial.println(F("{}============================================================"{}));\ \}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00113}00113\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00114}00114\ /**}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00115}00115\ \ *\ @brief\ Verify\ the\ IMU\ identity\ register.}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00116}00116\ \ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00117}00117\ void\ firstStage()\ \{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00118}00118\ \ \ uint8\_t\ who;}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00119}00119\ \ \ if\ (!imu.readWhoAmI(who)\ ||\ who\ !=\ 0xEA)\ \{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00120}00120\ \ \ \ \ Serial.println(F("{}ERROR:\ WHO\_AM\_I\ mismatch"{}));}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00121}00121\ \ \ \ \ while\ (1)\ delay(200);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00122}00122\ \ \ \}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00123}00123\ \ \ Serial.printf("{}WHO\_AM\_I\ =\ 0x\%02X\ \ OK\(\backslash\)n"{},\ who);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00124}00124\ \}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00125}00125\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00126}00126\ /**}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00127}00127\ \ *\ @brief\ Apply\ one\ gyroscope\ full-\/scale\ and\ DLPF\ configuration.}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00128}00128\ \ *}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00129}00129\ \ *\ @param\ fs\_idx\ Index\ into\ gyroFSCfg.}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00130}00130\ \ *\ @param\ cfg\ DLPF\ timing\ and\ divider\ configuration.}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00131}00131\ \ *\ @return\ true\ if\ all\ configuration\ writes\ succeeded,\ otherwise\ false.}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00132}00132\ \ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00133}00133\ bool\ applySettings(uint8\_t\ fs\_idx,\ const\ configDLPF\ \&cfg)\ \{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00134}00134\ \ \ ICM20948\_Gyro\_DLPF\ dlpf\_val\ =\ gyroDLPF[cfg.dlpf\_idx];}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00135}00135\ \ \ bool\ ok\ =\ true;}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00136}00136\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00137}00137\ \ \ ok\ \&=\ imu.setGyroScale(gyroFSCfg[fs\_idx]);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00138}00138\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00139}00139\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00140}00140\ \ \ //\ Paso\ 1:\ escribe\ DLPFCFG\ en\ bits\ [5:3]}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00141}00141\ \ \ //\ SetDLPF\ false\ -\/>\ Activa\ DLPF\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00142}00142\ \ \ //\ SetDLPF\ true\ -\/>\ Desactiva\ DLPF}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00143}00143\ \ \ ok\ \&=\ imu.setDLPF(dlpf\_val,\ false);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00144}00144\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00145}00145\ \ \ //ok\ \&=\ imu.setGyroAveraging(gyroAVGCfg[avg]);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00146}00146\ \ \ //\ Paso\ 2:\ activa\ FCHOICE=1\ (DLPF\ activo)\ sin\ tocar\ DLPFCFG}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00147}00147\ \ \ //ok\ \&=\ imu.setAccelDLPF(0,\ true);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00148}00148\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00149}00149\ \ \ //\ DIV\ directo\ al\ registro,\ sin\ conversion\ interna}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00150}00150\ \ \ ok\ \&=\ imu.setGyroDivRate(cfg.div);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00151}00151\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00152}00152\ \ \ return\ ok;}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00153}00153\ \}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00154}00154\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00155}00155\ /**}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00156}00156\ \ *\ @brief\ Run\ the\ gyroscope\ validation\ sweep\ and\ print\ each\ captured\ sample.}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00157}00157\ \ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00158}00158\ void\ runSweep()\{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00159}00159\ \ \ uint16\_t\ n\ =\ 0;}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00160}00160\ \ \ printDobleLinea();}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00161}00161\ \ \ Serial.println(F("{}\ \ ICM-\/20948\ |\ UNIT\ Electronics"{}));}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00162}00162\ \ \ Serial.println(F("{}\ \ MODO\ VERIFICACION\ —\ FS=+-\/2g\ fijo,\ 3\ lecturas\ por\ config"{}));}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00163}00163\ \ \ Serial.println(F("{}\ \ Sensor\ PLANO\ y\ QUIETO\ |\ Az\ esperado:\ \string~+1.000g"{}));}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00164}00164\ \ \ printDobleLinea();}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00165}00165\ \ \ for\ (uint8\_t\ i\ =\ 0;\ i\ <\ N\_FS\ ;\ i++)\{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00166}00166\ \ \ \ \ \ \ for(uint8\_t\ d\ =\ 0;\ d\ <\ N\_DLPF;\ d++)\{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00167}00167\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00168}00168\ \ \ \ \ \ \ \ \ bool\ cfg\_ok\ =\ applySettings(i,configsDLPF[d]);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00169}00169\ \ \ \ \ \ \ \ \ if(!cfg\_ok)\{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00170}00170\ \ \ \ \ \ \ \ \ \ \ Serial.println(F("{}ERROR:\ applySettings\ fallo"{}));}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00171}00171\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00172}00172\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00173}00173\ \ \ \ \ \ \ \ \ //\ Esperar\ que\ el\ filtro\ estabilice\ (10\ periodos\ del\ ODR,\ min\ 50ms)}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00174}00174\ \ \ \ \ \ \ \ \ uint32\_t\ settle\_ms\ =\ max((uint32\_t)(10000.0f\ /\ configsDLPF[d].odr\_hz),}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00175}00175\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (uint32\_t)50);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00176}00176\ \ \ \ \ \ \ \ \ delay(settle\_ms);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00177}00177\ \ \ \ \ \ \ \ \ //\ Tomar\ 3\ lecturas\ espaciadas\ por\ el\ periodo\ del\ ODR}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00178}00178\ \ \ \ \ \ \ \ \ uint32\_t\ periodo\_ms\ =\ max((uint32\_t)(1000.0f\ /\ configsDLPF[d].odr\_hz),}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00179}00179\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (uint32\_t)1);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00180}00180\ \ \ \ \ \ \ \ \ float\ gx,\ gy,\ gz;}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00181}00181\ \ \ \ \ \ \ \ \ for\ (uint8\_t\ r\ =\ 0;\ r\ <\ 100;\ r++)\ \{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00182}00182\ \ \ \ \ \ \ \ \ \ \ n++;}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00183}00183\ \ \ \ \ \ \ \ \ \ \ delay(periodo\_ms);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00184}00184\ \ \ \ \ \ \ \ \ \ \ if\ (imu.readGyro(gx,\ gy,\ gz))\ \{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00185}00185\ \ \ \ \ \ \ \ \ \ \ \ \ Serial.printf("{}\%d\ ;\ \%s\ ;\ \%s\ ;\ \%+.4f\ ;\ \%+.4f\ ;\ \%+.4f\(\backslash\)n"{},}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00186}00186\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ n,}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00187}00187\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ configsDLPF[d].nombre,\ \ \ //\ "{}246\ ;\ 265\ ;\ 1125"{}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00188}00188\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ etiquetasGyroFSCfg[i],\ \ \ \ \ //\ "{}+-\/2G"{}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00189}00189\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ //etiquetasGyroAVGCfg[j],\ \ \ \ \ //\ "{}8"{}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00190}00190\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ gx,\ gy,\ gz);\ \ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00191}00191\ \ \ \ \ \ \ \ \ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00192}00192\ \ \ \ \ \ \ \ \ \ \ \ \ Serial.println(F("{}\ \ [?]\ readGyr()\ fallo"{}));}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00193}00193\ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00194}00194\ \ \ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00195}00195\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00196}00196\ \ \ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00197}00197\ \ \ \}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00198}00198\ \}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00199}00199\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00200}00200\ /**}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00201}00201\ \ *\ @brief\ Initialize\ I2C,\ reset/wake\ the\ IMU,\ enable\ gyro,\ and\ start\ the\ sweep.}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00202}00202\ \ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00203}00203\ void\ setup()\ \{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00204}00204\ \ \ //\ put\ your\ setup\ code\ here,\ to\ run\ once:}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00205}00205\ \ \ Serial.begin(115200);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00206}00206\ \ \ delay(200);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00207}00207\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00208}00208\ \ \ \ \ printDobleLinea();}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00209}00209\ \ \ Serial.println(F("{}\ \ ICM-\/20948\ VALIDACION\ ACELEROMETRO"{}));}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00210}00210\ \ \ printDobleLinea();}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00211}00211\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00212}00212\ \ \ Wire.begin(SDA\_PIN,\ SCL\_PIN);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00213}00213\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00214}00214\ \ \ if\ (!imu.beginI2C(ICM\_ADDR,\ Wire,\ I2C\_FREQ))\ \{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00215}00215\ \ \ \ \ Serial.println(F("{}ERROR:\ beginI2C()\ fallo"{}));}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00216}00216\ \ \ \ \ while\ (1)\ delay(200);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00217}00217\ \ \ \}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00218}00218\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00219}00219\ \ \ firstStage();}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00220}00220\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00221}00221\ \ \ //\ softReset\ pone\ el\ chip\ a\ dormir}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00222}00222\ \ \ //\ Despues\ del\ reset\ hay\ que\ despertar\ el\ dispositivo}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00223}00223\ \ \ imu.softReset();}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00224}00224\ \ \ delay(100);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00225}00225\ \ \ imu.sleep(false);\ \ \ //\ limpia\ SLEEP\ bit,\ CLKSEL=1}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00226}00226\ \ \ delay(50);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00227}00227\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00228}00228\ \ \ if\ (!imu.setSensors(false,\ true,\ false))\ \{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00229}00229\ \ \ \ \ Serial.println(F("{}ERROR:\ setSensors()\ fallo"{}));}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00230}00230\ \ \ \}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00231}00231\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00232}00232\ \ \ Serial.println(F("{}\ \ Sensor\ listo.\(\backslash\)n"{}));}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00233}00233\ \ \ Serial.println(F("{}\ \ Sensor\ PLANO\ y\ QUIETO\ sobre\ la\ mesa."{}));}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00234}00234\ \ \ Serial.println(F("{}\ \ Iniciando\ en\ 5\ segundos..."{}));}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00235}00235\ \ \ for\ (int\ i\ =\ 5;\ i\ >\ 0;\ i-\/-\/)\ \{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00236}00236\ \ \ \ \ Serial.printf("{}\ \ \%d...\(\backslash\)n"{},\ i);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00237}00237\ \ \ \ \ delay(1000);}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00238}00238\ \ \ \}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00239}00239\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00240}00240\ \ \ //for\ (int\ runs\ =\ 0;\ runs\ <\ 20\ ;\ runs++)\{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00241}00241\ \ \ \ \ runSweep();}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00242}00242\ \ \ //\}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00243}00243\ \}}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00244}00244\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00245}00245\ /**}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00246}00246\ \ *\ @brief\ Empty\ loop;\ this\ sketch\ runs\ the\ gyroscope\ sweep\ once\ in\ setup().}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00247}00247\ \ */}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00248}00248\ void\ loop()\ \{}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00249}00249\ \ \ //\ put\ your\ main\ code\ here,\ to\ run\ repeatedly:}
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00250}00250\ }
\DoxyCodeLine{\Hypertarget{gyr__test_8ino_source_l00251}00251\ \}}

\end{DoxyCode}
