summaryrefslogtreecommitdiffhomepage
path: root/doc/tex/30pin.tex
blob: 11830fbf6b4633722feaa7ff07613ede841d3f05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

\documentclass{article}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{geometry}
\usepackage{titlesec}
\usepackage{fancyhdr}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{graphicx}
\usepackage{enumitem}
\geometry{margin=1in}

\titleformat{\section}{\large\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}{\normalsize\bfseries}{\thesubsection}{1em}{}

\title{\texttt{30Pin} Technical Specification}
\author{Amlal El Mahrouss}
\date{\today}

\lstset{
    basicstyle=\ttfamily\footnotesize,
    keywordstyle=\color{blue},
    commentstyle=\color{gray},
    stringstyle=\color{red},
    showstringspaces=false,
    breaklines=true
}

\begin{document}

\maketitle

\section*{File Description}
\textbf{File:} \texttt{30pin.h} \\
\textbf{Description:} This header defines the 30pin recovery protocol structures, constants, and packet kinds.

\section{Constants}
\begin{itemize}[leftmargin=2em]
    \item \texttt{NB\_30PIN\_MAG} - Magic number identifier for a 30pin packet. Defined as \texttt{"TP"}.
    \item \texttt{NB\_30PIN\_MAG\_LEN} - Length of the magic number (\texttt{2} bytes).
    \item \texttt{NB\_30PIN\_BUFFER\_LEN} - Length of the data buffer in the packet (\texttt{498} bytes).
    \item \texttt{NB\_30PIN\_EOP\_LEN} - Length of the end-of-packet data (\texttt{11} bytes).
\end{itemize}

\section{Data Structures}
\subsection{\texttt{nb\_tpin\_recovery\_packet}}
\begin{lstlisting}[language=C]
struct _nb_tpin_recovery_packet
{
    uint8_t mag[NB_30PIN_MAG_LEN];     // Magic number
    uint8_t kind;                      // Packet kind identifier
    uint8_t buffer[NB_30PIN_BUFFER_LEN]; // Packet data buffer
    uint8_t eop[NB_30PIN_EOP_LEN];     // End-of-packet data
};
\end{lstlisting}

\textbf{Typedef:} \texttt{nb\_tpin\_recovery\_packet\_t}

\section{Enumerations}
\subsection{Packet Kinds}
Defines the kinds of packets used in the 30pin recovery protocol:

\begin{itemize}[leftmargin=2em]
    \item \texttt{TPIN\_RECOVERY\_PACKET\_KIND\_UNKNOWN = 0}
    \item \texttt{TPIN\_RECOVERY\_PACKET\_KIND\_BOOT = 1}
    \item \texttt{TPIN\_RECOVERY\_PACKET\_KIND\_DATA = 2}
    \item \texttt{TPIN\_RECOVERY\_PACKET\_KIND\_EOP = 3}
    \item \texttt{TPIN\_RECOVERY\_PACKET\_KIND\_EOP\_ACK = 4}
    \item \texttt{TPIN\_RECOVERY\_PACKET\_KIND\_EOP\_NACK = 5}
    \item \texttt{TPIN\_RECOVERY\_PACKET\_KIND\_EOP\_RESET = 6}
\end{itemize}

\section{30PIN Extensions}

\subsection{Validation Extension 1 (VE-1)}

A valid 30pin recovery packet must have the magic number set to \texttt{"TP"}.
Moreover, the packet should be validated based on the CRC32 algorithm.

\begin{lstlisting}[language=C]
void validate_entry(nb_tpin_crc_t crc, nb_tpin_recovery_packet_t* packet);
\end{lstlisting} The `nb\_tpin\_crc\_t' type shall be of size 4 bytes to hold the CRC32 checksum.

\begin{lstlisting}[language=C]
typedef uint8_t nb_tpin_crc_t[sizeof(uint32_t)];
\end{lstlisting} This ensures that the byte are indexable and compatible with CRC32 calculations. Such CRC32 shall be stored in big-endian order. As per networking protocols standard. 

\end{document}