Files
RP2040-Decoder/latex/shared_8h_source.tex
T
2024-01-02 17:30:32 +00:00

74 lines
6.3 KiB
TeX

\doxysection{shared.\+h}
\hypertarget{shared_8h_source}{}\label{shared_8h_source}\mbox{\hyperlink{shared_8h}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ }
\DoxyCodeLine{00008\ \textcolor{preprocessor}{\#pragma\ once}}
\DoxyCodeLine{00009\ \textcolor{preprocessor}{\#include\ "{}string.h"{}}}
\DoxyCodeLine{00010\ \textcolor{preprocessor}{\#include\ "{}pico/float.h"{}}}
\DoxyCodeLine{00011\ \textcolor{preprocessor}{\#include\ "{}pico/stdlib.h"{}}}
\DoxyCodeLine{00012\ \textcolor{preprocessor}{\#include\ "{}pico/multicore.h"{}}}
\DoxyCodeLine{00013\ \textcolor{preprocessor}{\#include\ "{}pico/printf.h"{}}}
\DoxyCodeLine{00014\ \textcolor{preprocessor}{\#include\ "{}hardware/pwm.h"{}}}
\DoxyCodeLine{00015\ \textcolor{preprocessor}{\#include\ "{}hardware/adc.h"{}}}
\DoxyCodeLine{00016\ \textcolor{preprocessor}{\#include\ "{}hardware/flash.h"{}}}
\DoxyCodeLine{00017\ }
\DoxyCodeLine{00018\ }
\DoxyCodeLine{00019\ \textcolor{comment}{//\ here\ you\ can\ enable\ printf\ debugging\ (needs\ extra\ soldering\ and\ you\ have\ to\ enable\ uart\ in\ the\ cmake\ configuration)}}
\DoxyCodeLine{00020\ \textcolor{comment}{//\ please\ note}}
\DoxyCodeLine{00021\ \textcolor{comment}{//\ -\/\ if\ it's\ disabled\ it\ will\ be\ compiled\ completely\ out}}
\DoxyCodeLine{00022\ \textcolor{comment}{//\ -\/\ be\ careful\ that\ printf\ debugging\ can\ change\ your\ timing\ behavior,\ for\ example\ in\ the\ pid\ controller\ limit\ the\ outputs}}
\DoxyCodeLine{00023\ \textcolor{comment}{//\ \ \ like\ already\ done\ (only\ print\ every\ 100th\ iteration\ for\ example!)}}
\DoxyCodeLine{00024\ \textcolor{comment}{//\ -\/\ also\ note\ that\ with\ logging\ enabled\ GPIO0/1\ are\ DISABLED\ from\ decoder\ functions\ because\ they\ are\ used\ for\ uart\ to\ the}}
\DoxyCodeLine{00025\ \textcolor{comment}{//\ \ \ outside\ world\ (this\ is\ configure\ automatically\ for\ you\ below!)}}
\DoxyCodeLine{00026\ \textcolor{comment}{//\ -\/\ IMPORTANT:\ you\ have\ to\ enable\ uart\ in\ the\ cmakelists.txt\ to\ enable\ logging!}}
\DoxyCodeLine{00027\ \textcolor{preprocessor}{\#define\ LOGLEVEL\ 0}}
\DoxyCodeLine{00028\ \textcolor{preprocessor}{\#define\ LOG(level,\ ...)\ \{\ if(level\ <=\ LOGLEVEL)\ \{printf(\_\_VA\_ARGS\_\_);\}\}}}
\DoxyCodeLine{00029\ }
\DoxyCodeLine{00030\ \textcolor{comment}{//\ Constant\ Value\ of\ 125\ x\ 10⁶}}
\DoxyCodeLine{00031\ \textcolor{preprocessor}{\#define\ \_125M\ 125000000}}
\DoxyCodeLine{00032\ }
\DoxyCodeLine{00033\ \textcolor{comment}{//\ GPIO\ used\ for\ DCC-\/Signal,\ Motor\ PWM\ or\ ADC}}
\DoxyCodeLine{00034\ \textcolor{preprocessor}{\#define\ DCC\_INPUT\_PIN\ 21u}}
\DoxyCodeLine{00035\ \textcolor{preprocessor}{\#define\ MOTOR\_FWD\_PIN\ 23u}}
\DoxyCodeLine{00036\ \textcolor{preprocessor}{\#define\ MOTOR\_REV\_PIN\ 22u}}
\DoxyCodeLine{00037\ \textcolor{preprocessor}{\#define\ FWD\_V\_EMF\_ADC\_PIN\ 28u}}
\DoxyCodeLine{00038\ \textcolor{preprocessor}{\#define\ REV\_V\_EMF\_ADC\_PIN\ 29u}}
\DoxyCodeLine{00039\ }
\DoxyCodeLine{00040\ \textcolor{comment}{//\ if\ logging\ is\ enabled\ do\ NOT\ use\ gpio0/1\ for\ functions\ in\ the\ decoder}}
\DoxyCodeLine{00041\ \textcolor{preprocessor}{\#if\ LOGLEVEL\ !=\ 0}}
\DoxyCodeLine{00042\ \ \ \ \textcolor{comment}{//\ GPIO\ used\ directly\ (GPIO\ 2-\/5\ incl.)\ as\ outputs\ or\ to\ switch\ auxiliary\ output\ transistors\ (GPIO\ 24-\/27\ incl.)}}
\DoxyCodeLine{00043\ \textcolor{preprocessor}{\ \ \ \#define\ GPIO\_OUTPUT\_PIN\_MASK\ (1u<<24)\ |\ (1u<<25)\ |\ (1u<<26)\ |\ (1u<<27)\ |\ (1u<<5)\ |\ (1u<<4)\ |\ (1u<<3)\ |\ (1u<<2)}}
\DoxyCodeLine{00044\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00045\ \ \ \ \textcolor{comment}{//\ GPIO\ used\ directly\ (GPIO\ 0-\/5\ incl.)\ as\ outputs\ or\ to\ switch\ auxiliary\ output\ transistors\ (GPIO\ 24-\/27\ incl.)}}
\DoxyCodeLine{00046\ \textcolor{preprocessor}{\ \ \ \#define\ GPIO\_OUTPUT\_PIN\_MASK\ (1u<<24)\ |\ (1u<<25)\ |\ (1u<<26)\ |\ (1u<<27)\ |\ (1u<<5)\ |\ (1u<<4)\ |\ (1u<<3)\ |\ (1u<<2)\ |\ (1u<<1)\ |\ (1u<<0)}}
\DoxyCodeLine{00047\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00048\ }
\DoxyCodeLine{00049\ \textcolor{comment}{//\ GPIO\ pin\ mask\ to\ prevent\ setting\ illegal\ GPIOs\ (ADC,\ Motor,\ DCC\ Input\ Pin)}}
\DoxyCodeLine{00050\ \textcolor{preprocessor}{\#define\ GPIO\_ILLEGAL\_MASK\ (1u<<DCC\_INPUT\_PIN)\ |\ (1u<<MOTOR\_FWD\_PIN)\ |\ (1u<<MOTOR\_REV\_PIN)\ |\ (1u<<FWD\_V\_EMF\_ADC\_PIN)\ |\ (1u<<REV\_V\_EMF\_ADC\_PIN)}}
\DoxyCodeLine{00051\ }
\DoxyCodeLine{00052\ \textcolor{comment}{//\ GPIO\ pin\ mask\ with\ allowed\ outputs\ (AUX\ \&\ GPIO\ (configured\ as\ outputs))}}
\DoxyCodeLine{00053\ \textcolor{preprocessor}{\#define\ GPIO\_ALLOWED\_OUTPUTS\ (GPIO\_OUTPUT\_PIN\_MASK)\ \&\ \string~(GPIO\_ILLEGAL\_MASK)}}
\DoxyCodeLine{00054\ }
\DoxyCodeLine{00055\ \textcolor{comment}{//\ Offset\ from\ base\ address\ used\ for\ saving\ CV\_ARRAY\_FLASH}}
\DoxyCodeLine{00056\ \textcolor{preprocessor}{\#define\ FLASH\_TARGET\_OFFSET\ (PICO\_FLASH\_SIZE\_BYTES-\/FLASH\_SECTOR\_SIZE)}}
\DoxyCodeLine{00057\ }
\DoxyCodeLine{00058\ \textcolor{keyword}{extern}\ repeating\_timer\_t\ pid\_control\_timer;}
\DoxyCodeLine{00059\ \textcolor{keyword}{extern}\ repeating\_timer\_t\ speed\_helper\_timer;}
\DoxyCodeLine{00060\ \textcolor{keyword}{extern}\ \textcolor{keyword}{const}\ uint8\_t\ *CV\_ARRAY\_FLASH;}
\DoxyCodeLine{00061\ \textcolor{keyword}{extern}\ uint8\_t\ speed\_step\_target;}
\DoxyCodeLine{00062\ \textcolor{keyword}{extern}\ uint8\_t\ speed\_step\_target\_prev;}
\DoxyCodeLine{00063\ }
\DoxyCodeLine{00064\ }
\DoxyCodeLine{00065\ \textcolor{keywordtype}{void}\ core1\_entry();}
\DoxyCodeLine{00066\ \textcolor{keywordtype}{void}\ write\_cv\_handler(uint16\_t\ cv\_index,\ uint8\_t\ cv\_data);}
\DoxyCodeLine{00067\ \textcolor{keywordtype}{float}\ measure(uint8\_t\ total\_iterations,}
\DoxyCodeLine{00068\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uint8\_t\ measurement\_delay\_us,}
\DoxyCodeLine{00069\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uint8\_t\ l\_side\_arr\_cutoff,}
\DoxyCodeLine{00070\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uint8\_t\ r\_side\_arr\_cutoff,}
\DoxyCodeLine{00071\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{bool}\ direction);}
\DoxyCodeLine{00072\ uint32\_t\ get\_32bit\_CV\ (uint16\_t\ CV\_start\_index);}
\DoxyCodeLine{00073\ uint16\_t\ get\_16bit\_CV\ (uint16\_t\ CV\_start\_index);}
\DoxyCodeLine{00105\ \textcolor{keywordtype}{bool}\ \mbox{\hyperlink{shared_8h_aed72641466dd9da550e446ad104607d0}{get\_direction\_of\_speed\_step}}(uint8\_t\ speed\_step);}
\end{DoxyCode}