\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<