\hypertarget{_wheelchair_control_main_8c}{\section{C\-:/\-Users/\-Ondra/\-Desktop/\-Wheelchair Control M\-C\-U/\-Wheelchair\-Control\-Main.c File Reference}
\label{_wheelchair_control_main_8c}\index{C\-:/\-Users/\-Ondra/\-Desktop/\-Wheelchair Control M\-C\-U/\-Wheelchair\-Control\-Main.\-c@{C\-:/\-Users/\-Ondra/\-Desktop/\-Wheelchair Control M\-C\-U/\-Wheelchair\-Control\-Main.\-c}}
}
{\ttfamily \#include \char`\"{}Wheelchair\-Control\-Main.\-h\char`\"{}}\\*
\begin{DoxyCompactItemize}
\item 
\hyperlink{structt___config_struct}{t\-\_\-\-Config\-Struct} \hyperlink{_wheelchair_control_main_8c_a04dc688b0b35746587b9ea10b8ceec38}{Config\-Struct\-R\-A\-M}
\item 
\hyperlink{structt___config_struct}{t\-\_\-\-Config\-Struct} E\-E\-M\-E\-M \hyperlink{_wheelchair_control_main_8c_a3da2c38e18cfc9112bb73ca24805fc72}{Config\-Struct\-E\-E\-P\-R\-O\-M}
\item 
\hyperlink{structt___i_s_rs_shared_struct}{t\-\_\-\-I\-S\-Rs\-Shared\-Struct} \hyperlink{_wheelchair_control_main_8c_ae6c537dfd6efae197f82e541bc7fd270}{I\-S\-Rs\-Shared\-Struct}
\item 
int16\-\_\-t \hyperlink{_wheelchair_control_main_8c_aec570f4ab450e8224be63b7dcfa62b35}{main} (void)
\item 
void \hyperlink{_wheelchair_control_main_8c_af63c950b40c4295feee7560ee2f8c9f4}{Initialize\-M\-C\-U} (void)
\item 
void \hyperlink{_wheelchair_control_main_8c_abf031d2177c1b64989aa2c0c7dfe9962}{Calculate\-Odometry} (void)
\item 
void \hyperlink{_wheelchair_control_main_8c_a17e97b8ac548755495d5079244921b42}{Run\-Regulators} (void)
\item 
void \hyperlink{_wheelchair_control_main_8c_a064d0fdfe3c2f3ba843a1c7533d1f37e}{E\-E\-P\-R\-O\-M\-\_\-\-Load\-Variables} (void)
\item 
void \hyperlink{_wheelchair_control_main_8c_abfd2e77848beb40580522f0a8f7a22d0}{E\-E\-P\-R\-O\-M\-\_\-\-Write\-Variable} (uint8\-\_\-t $\ast$address, uint8\-\_\-t data)
\item 
void \hyperlink{_wheelchair_control_main_8c_af0b8a5a618096e8da8d41059ac05c237}{E\-E\-P\-R\-O\-M\-\_\-\-Write\-Word} (uint16\-\_\-t $\ast$address, uint16\-\_\-t data)
\item 
\hyperlink{_wheelchair_control_main_8c_a68f52df99eb21e6ef4cf3dbcf0527f97}{I\-S\-R} (U\-S\-A\-R\-T\-\_\-\-R\-X\-C\-\_\-vect)
\item 
\hyperlink{_wheelchair_control_main_8c_add2d7cdddfb682dcc0391e60cf42c7d6}{I\-S\-R} (T\-I\-M\-E\-R0\-\_\-\-O\-V\-F\-\_\-vect)
\item 
\hyperlink{_wheelchair_control_main_8c_a7cfcbe42bd266750aeb6e5d71e5ea479}{I\-S\-R} (T\-I\-M\-E\-R2\-\_\-\-O\-V\-F\-\_\-vect)
\item 
\hyperlink{_wheelchair_control_main_8c_afea150fcd685610cb9f7672fce361e53}{I\-S\-R} (I\-N\-T0\-\_\-vect)
\item 
\hyperlink{_wheelchair_control_main_8c_a22acfb428840c6d9aa212764589cf6c6}{I\-S\-R} (I\-N\-T1\-\_\-vect)
\item 
\hyperlink{_wheelchair_control_main_8c_a30a0ad88a89a84c0161cf09eace108e8}{I\-S\-R} (I\-N\-T2\-\_\-vect)
\end{DoxyCompactItemize}


\subsection{Detailed Description}
This is main program file. 

Definition in file \hyperlink{_wheelchair_control_main_8c_source}{Wheelchair\-Control\-Main.\-c}.



\subsection{Function Documentation}
\hypertarget{_wheelchair_control_main_8c_abf031d2177c1b64989aa2c0c7dfe9962}{\index{Wheelchair\-Control\-Main.\-c@{Wheelchair\-Control\-Main.\-c}!Calculate\-Odometry@{Calculate\-Odometry}}
\index{Calculate\-Odometry@{Calculate\-Odometry}!WheelchairControlMain.c@{Wheelchair\-Control\-Main.\-c}}
\subsubsection[{Calculate\-Odometry}]{\setlength{\rightskip}{0pt plus 5cm}void Calculate\-Odometry (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}}\label{_wheelchair_control_main_8c_abf031d2177c1b64989aa2c0c7dfe9962}
Odometry is calculated here. 

Definition at line 109 of file Wheelchair\-Control\-Main.\-c.

\hypertarget{_wheelchair_control_main_8c_a064d0fdfe3c2f3ba843a1c7533d1f37e}{\index{Wheelchair\-Control\-Main.\-c@{Wheelchair\-Control\-Main.\-c}!E\-E\-P\-R\-O\-M\-\_\-\-Load\-Variables@{E\-E\-P\-R\-O\-M\-\_\-\-Load\-Variables}}
\index{E\-E\-P\-R\-O\-M\-\_\-\-Load\-Variables@{E\-E\-P\-R\-O\-M\-\_\-\-Load\-Variables}!WheelchairControlMain.c@{Wheelchair\-Control\-Main.\-c}}
\subsubsection[{E\-E\-P\-R\-O\-M\-\_\-\-Load\-Variables}]{\setlength{\rightskip}{0pt plus 5cm}void E\-E\-P\-R\-O\-M\-\_\-\-Load\-Variables (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}}\label{_wheelchair_control_main_8c_a064d0fdfe3c2f3ba843a1c7533d1f37e}
Loads variables stored in E\-E\-P\-R\-O\-M to R\-A\-M. 

Definition at line 367 of file Wheelchair\-Control\-Main.\-c.

\hypertarget{_wheelchair_control_main_8c_abfd2e77848beb40580522f0a8f7a22d0}{\index{Wheelchair\-Control\-Main.\-c@{Wheelchair\-Control\-Main.\-c}!E\-E\-P\-R\-O\-M\-\_\-\-Write\-Variable@{E\-E\-P\-R\-O\-M\-\_\-\-Write\-Variable}}
\index{E\-E\-P\-R\-O\-M\-\_\-\-Write\-Variable@{E\-E\-P\-R\-O\-M\-\_\-\-Write\-Variable}!WheelchairControlMain.c@{Wheelchair\-Control\-Main.\-c}}
\subsubsection[{E\-E\-P\-R\-O\-M\-\_\-\-Write\-Variable}]{\setlength{\rightskip}{0pt plus 5cm}void E\-E\-P\-R\-O\-M\-\_\-\-Write\-Variable (
\begin{DoxyParamCaption}
\item[{uint8\-\_\-t $\ast$}]{address, }
\item[{uint8\-\_\-t}]{data}
\end{DoxyParamCaption}
)}}\label{_wheelchair_control_main_8c_abfd2e77848beb40580522f0a8f7a22d0}
Writes byte to E\-E\-P\-R\-O\-M. 
\begin{DoxyParams}{Parameters}
{\em address} & Address in E\-E\-P\-R\-O\-M to write to. \\
\hline
{\em data} & 1 byte of data to be written. \\
\hline
\end{DoxyParams}


Definition at line 409 of file Wheelchair\-Control\-Main.\-c.

\hypertarget{_wheelchair_control_main_8c_af0b8a5a618096e8da8d41059ac05c237}{\index{Wheelchair\-Control\-Main.\-c@{Wheelchair\-Control\-Main.\-c}!E\-E\-P\-R\-O\-M\-\_\-\-Write\-Word@{E\-E\-P\-R\-O\-M\-\_\-\-Write\-Word}}
\index{E\-E\-P\-R\-O\-M\-\_\-\-Write\-Word@{E\-E\-P\-R\-O\-M\-\_\-\-Write\-Word}!WheelchairControlMain.c@{Wheelchair\-Control\-Main.\-c}}
\subsubsection[{E\-E\-P\-R\-O\-M\-\_\-\-Write\-Word}]{\setlength{\rightskip}{0pt plus 5cm}void E\-E\-P\-R\-O\-M\-\_\-\-Write\-Word (
\begin{DoxyParamCaption}
\item[{uint16\-\_\-t $\ast$}]{address, }
\item[{uint16\-\_\-t}]{data}
\end{DoxyParamCaption}
)}}\label{_wheelchair_control_main_8c_af0b8a5a618096e8da8d41059ac05c237}
Writes word to E\-E\-P\-R\-O\-M. 
\begin{DoxyParams}{Parameters}
{\em address} & Address in E\-E\-P\-R\-O\-M to write to. \\
\hline
{\em data} & 2 bytes of data to be written. \\
\hline
\end{DoxyParams}


Definition at line 416 of file Wheelchair\-Control\-Main.\-c.

\hypertarget{_wheelchair_control_main_8c_af63c950b40c4295feee7560ee2f8c9f4}{\index{Wheelchair\-Control\-Main.\-c@{Wheelchair\-Control\-Main.\-c}!Initialize\-M\-C\-U@{Initialize\-M\-C\-U}}
\index{Initialize\-M\-C\-U@{Initialize\-M\-C\-U}!WheelchairControlMain.c@{Wheelchair\-Control\-Main.\-c}}
\subsubsection[{Initialize\-M\-C\-U}]{\setlength{\rightskip}{0pt plus 5cm}void Initialize\-M\-C\-U (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}}\label{_wheelchair_control_main_8c_af63c950b40c4295feee7560ee2f8c9f4}
Initializes interrupts and peripherals. 

Definition at line 62 of file Wheelchair\-Control\-Main.\-c.

\hypertarget{_wheelchair_control_main_8c_a68f52df99eb21e6ef4cf3dbcf0527f97}{\index{Wheelchair\-Control\-Main.\-c@{Wheelchair\-Control\-Main.\-c}!I\-S\-R@{I\-S\-R}}
\index{I\-S\-R@{I\-S\-R}!WheelchairControlMain.c@{Wheelchair\-Control\-Main.\-c}}
\subsubsection[{I\-S\-R}]{\setlength{\rightskip}{0pt plus 5cm}I\-S\-R (
\begin{DoxyParamCaption}
\item[{U\-S\-A\-R\-T\-\_\-\-R\-X\-C\-\_\-vect}]{}
\end{DoxyParamCaption}
)}}\label{_wheelchair_control_main_8c_a68f52df99eb21e6ef4cf3dbcf0527f97}
U\-A\-R\-T Rx complete interrupt service routine. 

Definition at line 432 of file Wheelchair\-Control\-Main.\-c.

\hypertarget{_wheelchair_control_main_8c_add2d7cdddfb682dcc0391e60cf42c7d6}{\index{Wheelchair\-Control\-Main.\-c@{Wheelchair\-Control\-Main.\-c}!I\-S\-R@{I\-S\-R}}
\index{I\-S\-R@{I\-S\-R}!WheelchairControlMain.c@{Wheelchair\-Control\-Main.\-c}}
\subsubsection[{I\-S\-R}]{\setlength{\rightskip}{0pt plus 5cm}I\-S\-R (
\begin{DoxyParamCaption}
\item[{T\-I\-M\-E\-R0\-\_\-\-O\-V\-F\-\_\-vect}]{}
\end{DoxyParamCaption}
)}}\label{_wheelchair_control_main_8c_add2d7cdddfb682dcc0391e60cf42c7d6}
T\-I\-M\-E\-R0 interrupt service routine (period = 1 ms). Rx index reset. 

Definition at line 995 of file Wheelchair\-Control\-Main.\-c.

\hypertarget{_wheelchair_control_main_8c_a7cfcbe42bd266750aeb6e5d71e5ea479}{\index{Wheelchair\-Control\-Main.\-c@{Wheelchair\-Control\-Main.\-c}!I\-S\-R@{I\-S\-R}}
\index{I\-S\-R@{I\-S\-R}!WheelchairControlMain.c@{Wheelchair\-Control\-Main.\-c}}
\subsubsection[{I\-S\-R}]{\setlength{\rightskip}{0pt plus 5cm}I\-S\-R (
\begin{DoxyParamCaption}
\item[{T\-I\-M\-E\-R2\-\_\-\-O\-V\-F\-\_\-vect}]{}
\end{DoxyParamCaption}
)}}\label{_wheelchair_control_main_8c_a7cfcbe42bd266750aeb6e5d71e5ea479}
T\-I\-M\-E\-R2 interrupt service routine (period = 2 ms). Measures the range every 50 ms, processes acquired data, P\-S\-D motors' regulators are run here. 

Definition at line 1008 of file Wheelchair\-Control\-Main.\-c.

\hypertarget{_wheelchair_control_main_8c_afea150fcd685610cb9f7672fce361e53}{\index{Wheelchair\-Control\-Main.\-c@{Wheelchair\-Control\-Main.\-c}!I\-S\-R@{I\-S\-R}}
\index{I\-S\-R@{I\-S\-R}!WheelchairControlMain.c@{Wheelchair\-Control\-Main.\-c}}
\subsubsection[{I\-S\-R}]{\setlength{\rightskip}{0pt plus 5cm}I\-S\-R (
\begin{DoxyParamCaption}
\item[{I\-N\-T0\-\_\-vect}]{}
\end{DoxyParamCaption}
)}}\label{_wheelchair_control_main_8c_afea150fcd685610cb9f7672fce361e53}
External interrupt 0 (left wheel encoder signal) service routine. 

Definition at line 1278 of file Wheelchair\-Control\-Main.\-c.

\hypertarget{_wheelchair_control_main_8c_a22acfb428840c6d9aa212764589cf6c6}{\index{Wheelchair\-Control\-Main.\-c@{Wheelchair\-Control\-Main.\-c}!I\-S\-R@{I\-S\-R}}
\index{I\-S\-R@{I\-S\-R}!WheelchairControlMain.c@{Wheelchair\-Control\-Main.\-c}}
\subsubsection[{I\-S\-R}]{\setlength{\rightskip}{0pt plus 5cm}I\-S\-R (
\begin{DoxyParamCaption}
\item[{I\-N\-T1\-\_\-vect}]{}
\end{DoxyParamCaption}
)}}\label{_wheelchair_control_main_8c_a22acfb428840c6d9aa212764589cf6c6}
External interrupt 1 (right wheel encoder signal) service routine. 

Definition at line 1320 of file Wheelchair\-Control\-Main.\-c.

\hypertarget{_wheelchair_control_main_8c_a30a0ad88a89a84c0161cf09eace108e8}{\index{Wheelchair\-Control\-Main.\-c@{Wheelchair\-Control\-Main.\-c}!I\-S\-R@{I\-S\-R}}
\index{I\-S\-R@{I\-S\-R}!WheelchairControlMain.c@{Wheelchair\-Control\-Main.\-c}}
\subsubsection[{I\-S\-R}]{\setlength{\rightskip}{0pt plus 5cm}I\-S\-R (
\begin{DoxyParamCaption}
\item[{I\-N\-T2\-\_\-vect}]{}
\end{DoxyParamCaption}
)}}\label{_wheelchair_control_main_8c_a30a0ad88a89a84c0161cf09eace108e8}
External interrupt 2 (emergency stop button) service routine.

\begin{DoxyWarning}{Warning}
This I\-S\-R runs in infinite loop until M\-C\-U reset to prevent P\-C app from controlling the wheelchair in case of emergency! 
\end{DoxyWarning}


Definition at line 1364 of file Wheelchair\-Control\-Main.\-c.

\hypertarget{_wheelchair_control_main_8c_aec570f4ab450e8224be63b7dcfa62b35}{\index{Wheelchair\-Control\-Main.\-c@{Wheelchair\-Control\-Main.\-c}!main@{main}}
\index{main@{main}!WheelchairControlMain.c@{Wheelchair\-Control\-Main.\-c}}
\subsubsection[{main}]{\setlength{\rightskip}{0pt plus 5cm}int16\-\_\-t main (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}}\label{_wheelchair_control_main_8c_aec570f4ab450e8224be63b7dcfa62b35}
Main -\/ program entry point. Superloop (odometry and regulators) is run here. 

Definition at line 40 of file Wheelchair\-Control\-Main.\-c.

\hypertarget{_wheelchair_control_main_8c_a17e97b8ac548755495d5079244921b42}{\index{Wheelchair\-Control\-Main.\-c@{Wheelchair\-Control\-Main.\-c}!Run\-Regulators@{Run\-Regulators}}
\index{Run\-Regulators@{Run\-Regulators}!WheelchairControlMain.c@{Wheelchair\-Control\-Main.\-c}}
\subsubsection[{Run\-Regulators}]{\setlength{\rightskip}{0pt plus 5cm}void Run\-Regulators (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}}\label{_wheelchair_control_main_8c_a17e97b8ac548755495d5079244921b42}
Position regulators are run here (wall following and position regulator). 

Definition at line 144 of file Wheelchair\-Control\-Main.\-c.



\subsection{Variable Documentation}
\hypertarget{_wheelchair_control_main_8c_a3da2c38e18cfc9112bb73ca24805fc72}{\index{Wheelchair\-Control\-Main.\-c@{Wheelchair\-Control\-Main.\-c}!Config\-Struct\-E\-E\-P\-R\-O\-M@{Config\-Struct\-E\-E\-P\-R\-O\-M}}
\index{Config\-Struct\-E\-E\-P\-R\-O\-M@{Config\-Struct\-E\-E\-P\-R\-O\-M}!WheelchairControlMain.c@{Wheelchair\-Control\-Main.\-c}}
\subsubsection[{Config\-Struct\-E\-E\-P\-R\-O\-M}]{\setlength{\rightskip}{0pt plus 5cm}{\bf t\-\_\-\-Config\-Struct} E\-E\-M\-E\-M Config\-Struct\-E\-E\-P\-R\-O\-M}}\label{_wheelchair_control_main_8c_a3da2c38e18cfc9112bb73ca24805fc72}
Configuration variables (stored in eeprom). 

Definition at line 29 of file Wheelchair\-Control\-Main.\-c.

\hypertarget{_wheelchair_control_main_8c_a04dc688b0b35746587b9ea10b8ceec38}{\index{Wheelchair\-Control\-Main.\-c@{Wheelchair\-Control\-Main.\-c}!Config\-Struct\-R\-A\-M@{Config\-Struct\-R\-A\-M}}
\index{Config\-Struct\-R\-A\-M@{Config\-Struct\-R\-A\-M}!WheelchairControlMain.c@{Wheelchair\-Control\-Main.\-c}}
\subsubsection[{Config\-Struct\-R\-A\-M}]{\setlength{\rightskip}{0pt plus 5cm}{\bf t\-\_\-\-Config\-Struct} Config\-Struct\-R\-A\-M}}\label{_wheelchair_control_main_8c_a04dc688b0b35746587b9ea10b8ceec38}
Configuration variables. 

Definition at line 28 of file Wheelchair\-Control\-Main.\-c.

\hypertarget{_wheelchair_control_main_8c_ae6c537dfd6efae197f82e541bc7fd270}{\index{Wheelchair\-Control\-Main.\-c@{Wheelchair\-Control\-Main.\-c}!I\-S\-Rs\-Shared\-Struct@{I\-S\-Rs\-Shared\-Struct}}
\index{I\-S\-Rs\-Shared\-Struct@{I\-S\-Rs\-Shared\-Struct}!WheelchairControlMain.c@{Wheelchair\-Control\-Main.\-c}}
\subsubsection[{I\-S\-Rs\-Shared\-Struct}]{\setlength{\rightskip}{0pt plus 5cm}{\bf t\-\_\-\-I\-S\-Rs\-Shared\-Struct} I\-S\-Rs\-Shared\-Struct}}\label{_wheelchair_control_main_8c_ae6c537dfd6efae197f82e541bc7fd270}
Structure inter-\/\-I\-S\-Rs shared variables. 

Definition at line 30 of file Wheelchair\-Control\-Main.\-c.

