\documentclass[a4paper,10pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{kpfonts}
\usepackage[american]{babel}
\usepackage[pdftex]{color,graphicx} % formats accéptés: .jpg,.mps,.pdf,.png
\graphicspath{{figures/}} % chemin vers le repertoire contenant les figures
\usepackage{pdfpages} % Include pdf file
\usepackage[colorlinks=true,menucolor=blue,linkcolor=blue,pdfstartview=FitH]{hyperref} % Enable typesetting of hyperlinks
\usepackage[tablegrid]{vhistory}

% Utile uniquement pour les tableaux
%\usepackage{multirow}% fusioner les lignes d'un tableau
%\usepackage{colortbl}% colorier le fond d'une cellule d'un tableau

%% Pour lier la position des éléments flottants aux limites de sections %%
%\usepackage{placeins}
%% Insertion de figure dans le texte %%
%\usepackage{floatflt} 
%% Place les flottants apres le point d'insertion %%
%\usepackage{flafter} 

% Divers
\usepackage{xspace}% pour ajouter une espace inteligente
\usepackage{verbatim}% pour insérer du texte sans traitement (utile pour ajouter un bout de code par exemple)
\usepackage{cite}% pour numéroter les référrences bibliographique dans l'ordre de citation


%--- macros simples ----------------------------------------------------
\newcommand{\cad}{c'est-\'a-dire\xspace}
\newcommand{\etal}{\mbox{$et$ $al$}\xspace}
\newcommand{\ie}{\mbox{i.e.}\xspace}
\newcommand{\degree}{\mbox{$^{\circ}$}}% pour afficher le signe 'degré'
\newcommand{\warningsymbol}{{\fontencoding{U}\fontfamily{futs}\selectfont\char 66\relax}}

\usepackage{color} % requie pour la définition de 'red' et 'green'
\newcommand{\rcolor}{\cellcolor{red}}% utile pour colorier une cellule de tableau
\newcommand{\gcolor}{\cellcolor{green}}% utile pour colorier une cellule de tableau 
\newcommand{\ccolor}{\cellcolor[gray]{0.85}}% utile pour colorier une cellule de tableau


%--- JPH style --------------------------------------------------------
%% Modification de l'environnement enumerate %%
%% premier niveau de liste numerotee en chiffres arabes %%
\renewcommand{\theenumi}{\arabic{enumi}}
%% presentation du prenier niveau de liste numerotee %%
\renewcommand{\labelenumi}{\textbf{\theenumi .}}
%% second niveau de liste numerotee en chiffres arabes %%
\renewcommand{\theenumii}{\arabic{enumii}}
%% presentation du second niveau de liste numerotee %%
\renewcommand{\labelenumii}{\theenumi .\theenumii .}
%% troisieme niveau de liste numerotee en chiffres arabes %%
\renewcommand{\theenumiii}{\arabic{enumiii}}
%% presentation du troisieme niveau de liste numerotee %%
\renewcommand{\labelenumiii}{\theenumi .\theenumii .\theenumiii .}

%% Personalisation des en-tetes et des pieds de page %%
%% Pages ordinaires %%
\usepackage{fancyhdr}
\renewcommand{\headheight}{13pt} %% warning 12pt toot small
\lhead{\scriptsize{\soustitre}}
\chead{}
%\rhead{\tiny \textit{\the\month~\the\year}}
\rhead{\tiny \textit{\today}}
\lfoot{\scriptsize{BD}}
\cfoot{---~\thepage~---}
\rfoot{\scriptsize{FEMTO-Engineering}}
%% Page de tete de chapitre %%
\fancypagestyle{chapitre}{%
  \fancyhead{}
  \fancyfoot{}
  \lhead{\textbf{\textsc{FIP}}~ --~\textsl{ANALOGIQUE}~--}
  \chead{}
  \rhead{\tiny \textit{\today}}
  %\rhead{\tiny \textit{\the\month~\the\year}}
  \lfoot{\scriptsize{BD}}
  \cfoot{---~\thepage~---}
  \rfoot{\scriptsize{STM32 motherboard starting guide}}
}
%% Page de redefinition du style plain par defaut %%
\fancypagestyle{plain}{%
  \fancyhead{}
  \fancyfoot{}
  \lhead{\textbf{\textsc{\titre}}}%~ --~\textsl{\soustitre}~--}
  \chead{}
  \rhead{\tiny \textit{\today}}
  %\rhead{\tiny \textit{\the\month~\number\year}}
  \lfoot{\scriptsize{BD}}
  \cfoot{---~\thepage~---}
  \rfoot{\scriptsize{STM32 motherboard starting guide}}
}
\pagestyle{fancy}

%% Page de titre %%
\title{
   \includegraphics[width=4cm,keepaspectratio=true]{femto_engineering_logo.png}
   \\
   \bigskip
   \vfill
   {\Huge \textbf{\titre}}
   %\\
   %\textit{\soustitre}
   \\
   \textsl{\sousoustitre}
   \vfill
   \bigskip
   \includegraphics[width=4cm,keepaspectratio=true]{femto_engineering_logo.png}
}
\vfill
\bigskip
\author{
  \textcopyright\ Benoit~\textsc{Dubois}
  \thanks{benoit.dubois@femto-engineering.fr}
  %\thanks{benoit.dubois\at{}femto-engineering.fr}
}
\date{
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %%%%%%%%%%%%%%\mois~\number\year
  %%%%%%%%%%%%\thanks{Compiled with \LaTeXe{} the \today.}
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \vfill
  \includegraphics[width=8cm,keepaspectratio=false]{stm32_on_motherboard_v0-2-0.jpg}
  \vfill
}

%% Titre %%
\newcommand{\titre}{STM32 motherboard}

%% Sous-titre %%
\newcommand{\soustitre}{Starting guide}

%% Sous-sous-titre %%
\newcommand{\sousoustitre}{\textsc{Starting guide 2}}
%-----------------------------------------------------------------------

\begin{document}

\maketitle
\pagenumbering{roman}

\begin{versionhistory}
  \vhEntry{1.0}{2021, january 10}{BD}{First release}
\end{versionhistory}

\tableofcontents
\pagebreak

\pagenumbering{arabic}


\chapter{Hardware}
\section{Overview}
\begin{figure}[htp]
 \centering
 \includegraphics[width=0.5\linewidth]{motherboard_v0-2-0.jpg} 
 \caption{Motherboard for STM32F407G}
 \label{fig:stm32motherboard}
\end{figure}
\begin{figure}[htp]
 \centering
 \includegraphics[width=0.5\linewidth]{stm32f407.jpg} 
 \caption{STM32F407G board}
 \label{fig:stm32disc}
\end{figure}
This report cover use of STM32 motherboard v0.2.0.
In the document, the term ``STM32Disc'' refer to the STM32 Discovery board (Fig.\ref{fig:stm32disc}) and the term ``STM32Mother'' refer to the STM32 motherboard (Fig.\ref{fig:stm32motherboard}).

\begin{itemize}
 \item Motherboard for STM32Disc (reference STM32F407G-DISCxx)
 \item Euroboard standard format: rack plugable
 \item Powered from standard 5V/15V Euroboard standard or from external 5V/15V power supply (section~\ref{sec:power})
\end{itemize}

\section{I/O}

\subsection{SPI PMOD}
\begin{figure}[htp]
 \centering
 \includegraphics[width=0.5\linewidth]{motherboard_v0-2-0_spi.jpg} 
 \caption{SPI PMOD interface}
 \label{fig:spi_intf}
\end{figure}
Three SPI bus are availlables from board.
Find pin name in use for each bus in table~\ref{tab:spipinname}.
\begin{table}[htbp]
  \begin{center}
    \begin{tabular}{|c|c|c|c|c|c|c|}
      \hline
      Bus & SCK & MISO & MOSI & CS1 & CS2 & CS3 \\
      \hline
      SPI1 & PB3 & PB4 & PB5 & PE0 & PE1 & PD7 \\
      SPI2 & PB13 & PB14 & PB15 & PD8 & PD9 & PD10 \\
      SPI3 & PC10 & PC11 & PC12 & PD0 & PA14 & PA15 \\
      \hline
    \end{tabular}
    \caption{OTA transistor sizes before and after DfR 
    \label{tab:spipinname}}
  \end{center}
\end{table}

\subsection{I2C PMOD}
\begin{figure}[htp]
 \centering
 \includegraphics[width=0.5\linewidth]{motherboard_v0-2-0_i2c.jpg} 
 \caption{I2C PMOD interface}
 \label{fig:i2c_intf}
\end{figure}

\subsection{Integrated ADC and DAC}
\begin{figure}[htp]
 \centering
 \includegraphics[width=0.5\linewidth]{motherboard_v0-2-0_adc_dac.jpg} 
 \caption{ADC and DAC interface}
 \label{fig:adc_dac_intf}
\end{figure}

\subsection{VNH5019}
The board integrate an interface to a VNH5019 shield (Fig.\ref{fig:vnh5019_intf}).
The VNH5019 is a H-bridge motor driver handled by PWM.\\
\begin{figure}[htp]
 \centering
 \includegraphics[width=0.5\linewidth]{motherboard_v0-2-0_vnh5019.jpg} 
 \caption{VNH5019 interface}
 \label{fig:vnh5019_intf}
\end{figure}

\warningsymbol You need to select timer 4 and channel 1 or 2 only (see Fig.\ref{fig:timer4}) in your software development if you want to use the VNH5019 interface.
\begin{figure}[htp]
 \centering
 \includegraphics[width=0.5\linewidth]{timer4.png} 
 \caption{VNH5019 interface}
 \label{fig:timer4}
\end{figure}

\subsection{GPIO}
\begin{figure}[htp]
 \centering
 \includegraphics[width=0.5\linewidth]{motherboard_v0-2-0_gpio.jpg} 
 \caption{GPIO interface}
 \label{fig:gpio_intf}
\end{figure}

\subsection{U(S)ART}
\begin{figure}[htp]
 \centering
 \includegraphics[width=0.5\linewidth]{motherboard_v0-2-0_usart.jpg} 
 \caption{U(S)ART interface}
 \label{fig:usart_intf}
\end{figure}
USART2 RX: A3
USART2 TX: A2

UART4 RX: A1
UART4 TX: A0
NOTE: A0 also connects to the user switch.
To use UART4 you should set MICROPY\_HW\_HAS\_SWITCH to 0 (if you build micropython), and also remove SB20 (on the back of the STM32 board near the USER switch).

\subsection{NRST}
NRST pin is connected to Reset button of the STM32Disc.
This pin can be used to deport a reset button on the front panel of the STM32Mother for example.

\section{Power}\label{sec:power}
\begin{figure}[htp]
 \centering
 \includegraphics[width=0.5\linewidth]{motherboard_v0-2-0_powersupply.jpg} 
 \caption{Power supply}
 \label{fig:power_intf}
\end{figure}
\subsection{Supply from DIN 5V}
Set the jumper of connector P11 (surrounded in red on fig.~\ref{fig:power_intf})

\subsection{Supply from DIN 15V}
Set the jumper of connector P11 (surrounded in red on fig.~\ref{fig:power_intf})
To use a power supply of 15~V, you need to 


\subsection{Supply from external 5V}
\subsection{Supply from external 15V}


\newpage
\addcontentsline{toc}{chapter}{Annexes}

\begin{appendix}
\chapter{Schematic}
\includepdf[pages=-]{stm32discovery_mboard_schematic_v0_2.pdf}

\chapter{Layout}
\includepdf[pages=-]{figures/pcb_top_v0_2.pdf}
\includepdf[pages=-]{figures/pcb_bottom_v0_2.pdf}
\end{appendix}


\end{document}          
