%
% $LastChangedRevision: 4180 $
% $LastChangedDate:: 2026-04-07 18:02:35 +0200#$
%
% This file is part of X2C. http://x2c.lcm.at/
%
% Copyright (c) 2018, Linz Center of Mechatronics GmbH (LCM) http://www.lcm.at/
% All rights reserved.
%
%
% This file is licensed according to the BSD 3-clause license as follows:
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are met:
%     * Redistributions of source code must retain the above copyright
%       notice, this list of conditions and the following disclaimer.
%     * Redistributions in binary form must reproduce the above copyright
%       notice, this list of conditions and the following disclaimer in the
%       documentation and/or other materials provided with the distribution.
%     * Neither the name of the "Linz Center of Mechatronics GmbH" and "LCM" nor
%       the names of its contributors may be used to endorse or promote products
%       derived from this software without specific prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
% ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
% IN NO EVENT SHALL "Linz Center of Mechatronics GmbH" BE LIABLE FOR ANY
% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
% (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
% LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
% ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
% (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%

% this style file is called by generalDoc.sty and contains special
% X2C commands and formatting

\usepackage{tabularray}
\usepackage{etoolbox}

\newcommand{\XtoC}{\textit{X2C }}
\newcommand{\XtoCReg}{\textit{X2C\textsuperscript{\textregistered} }}
\newcommand{\CCS}{\textit{Code Composer Studio }}
\newcommand{\MPL}{\textit{MPLAB X }}
\newcommand{\MPLReg}{\textit{MPLAB\textsuperscript{\textregistered} X }}
\newcommand{\CubeIDE}{\textit{STM32CubeIDE }}
\newcommand{\DAVE}{\textit{DAVE IDE }}
\newcommand{\UVISION}{\textit{{\textmu}Vision }}
\newcommand{\UVISIONReg}{\textit{{\textmu}Vision\textsuperscript{\textregistered} }}
\newcommand{\SCL}{\textit{Scilab }}
\newcommand{\Xcos}{\textit{Xcos }}

% ------------ X2C LIBRARY -----------------
\newcommand{\XtoCLibrary}[1]{
\section*{#1}
\addcontentsline{toc}{section}{#1}
}
% ------------------------------------------

% ------------ X2C BLOCK -------------------
\newcommand{\XtoCBlock}[1]{
\vspace{3ex}%
\section*{Block:  #1}
\vspace{-1ex}
\hrule
\vspace{1em}
\addcontentsline{toc}{subsection}{#1}
}
% ------------------------------------------

% ------------ X2C IMPLEMENTATION ---------
\newcommand{\XtoCImplementation}[1]{
\vspace{3ex}%
\subsection*{Implementation: #1}
\vspace{-1ex}
\hrule
\vspace{1ex}
%\addcontentsline{toc}{subsubsection}{Implementation #1}
}
% ------------------------------------------

% ------------ X2C TABULAR -----------------
\ifdefined\useRegularTable
  \newenvironment{XtoCtabular}[1]{
  \vspace{1em}
  \begin{tabular}{|>{\raggedright\arraybackslash}p{0.3\textwidth-2\tabcolsep}|>{\raggedright\arraybackslash}p{0.7\textwidth-2\tabcolsep-3\arrayrulewidth}|}
  \hline 
  \multicolumn{2}{|l|}{\cellcolor[gray]{0.8}\textbf{#1}} \\
  \hline }
  {\end{tabular}\\
  \vspace{1ex}}
\else
  \newenvironment{XtoCtabular}[1]{
  \vspace{1em}
  \begin{tblr}{|X[0.3,l]|X[l]|}
  \hline 
  \SetRow{lightgray} \SetCell[c=2]{l} \textbf{#1} \\
  \hline }
  {\end{tblr}\\
  \vspace{1ex}}
\fi

% ------------------------------------------

% ---------- X2C MASK PARAMETERS -----------
\ifdefined\useRegularTable
  \newenvironment{XtoCMaskParamTabular}[1]{
  \vspace{1em}
  \begin{tabular}{|>{\raggedright\arraybackslash}p{0.3\textwidth-2\tabcolsep}|>{\raggedright\arraybackslash}p{0.1\textwidth-2\tabcolsep-2\arrayrulewidth}|>{\raggedright\arraybackslash}p{0.6\textwidth-2\tabcolsep-2\arrayrulewidth}|}
  \hline 
  \multicolumn{3}{|l|}{\cellcolor[gray]{0.8}\textbf{#1}} \\
  \hline 
  \rowcolor[gray]{0.8}\textbf{Name} & \textbf{ID} & \textbf{Description}\\
  \hline }
  {\end{tabular}\\
  \vspace{1ex}}
\else
  \newenvironment{XtoCMaskParamTabular}[1]{
  \vspace{1em}
  \begin{tblr}{|X[0.3,l]|X[0.1,l]|X[l]|}
  \hline
  \SetRow{lightgray} \SetCell[c=3]{l} \textbf{#1} \\
  \hline
  \SetRow{lightgray}\textbf{Name} & \textbf{ID} & \textbf{Description}\\
  \hline }
  {\end{tblr}\\
  \vspace{1ex}}
\fi

% ------------------------------------------

% ------------ X2C DATASTRUCT --------------
\newcommand{\XtoCDataStruct}[1]{
\vspace{1em}
\textbf{#1}
\vspace{1ex}
\clisting}
% ------------------------------------------

% ------------ X2C VARIABLE ----------------
\newcommand{\XtoCvar}[1]{
\moparam{#1}
}
% ------------------------------------------

% ------------ X2C VERIFICATION ------------
\newcommand{\XtoCVerification}[1]{
\vspace{3ex}%
\newpage
\subsection*{Verification: #1}
\vspace{-1ex}
\hrule
%\addcontentsline{toc}{subsubsection}{Verification #1}
}
% ------------------------------------------

% ------------ X2C TESTCASE --------------
\newcommand{\XtoCTestCase}[2]{
\subsubsection*{Test case: #1 
\hfill
\ifnum #2=1
  \textcolor{green}{OK}
\else
  \textcolor{red}{FAILED}
\fi
}
}
%------------------------------------------

% ---------- HELPER COMMANDS --------------
% command to generate subscripts in text environment
\newcommand{\textsub} [1]{\raisebox{-0.5ex}{\scriptsize{#1}}}
%------------------------------------------

% ---------- X2C DEMO BOARD  --------------
\ifdefined\Blinky
\else
 \def\Blinky{0}
\fi
\ifcase\Blinky 
	\newcommand{\DemoPath}{<X2C\_ROOT>{\textbackslash\allowbreak}DemoApplication{\textbackslash\allowbreak}Blinky\_TI\_TMS320F28069\_controlSTICK}
	\newcommand{\DemoName}{TI F28069 Piccolo controlSTICK}
	\newcommand{\DemoImage}{DemoApplication_Piccolo}
\or 
	\newcommand{\DemoPath}{<X2C\_ROOT>{\textbackslash\allowbreak}DemoApplication{\textbackslash\allowbreak}Blinky\_TI\_TM4C123GH6\_LaunchPad}
	\newcommand{\DemoName}{TI Tiva TM4C123G LaunchPad}
	\newcommand{\DemoImage}{DemoApplication_Tiva}
\or 
	\newcommand{\DemoPath}{<X2C\_ROOT>{\textbackslash\allowbreak}DemoApplication{\textbackslash\allowbreak}Blinky\_Microchip\_dsPIC33Fxxxx\_MicrostickPlus}
	\newcommand{\DemoName}{Microchip dsPIC33F MicrostickPlus}
	\newcommand{\DemoImage}{DemoApplication_MicrostickPlus}
\or 
	\newcommand{\DemoPath}{<X2C\_ROOT>{\textbackslash\allowbreak}DemoApplication{\textbackslash\allowbreak}Blinky\_ST\_STM32G474RE\_Nucleo}
	\newcommand{\DemoName}{ST STM32FG474RE Nucleo}
	\newcommand{\DemoImage}{DemoApplication_Nucleo}
\or 
	\newcommand{\DemoPath}{<X2C\_ROOT>{\textbackslash\allowbreak}DemoApplication{\textbackslash\allowbreak}Blinky\_ST\_STM32F072RB\_Nucleo}
	\newcommand{\DemoName}{ST STM32F072RB Nucleo}
	\newcommand{\DemoImage}{DemoApplication_Nucleo}
\or
	\newcommand{\DemoPath}{<X2C\_ROOT>{\textbackslash\allowbreak}DemoApplication{\textbackslash\allowbreak}Blinky\_Infineon\_XMC4700\_RelaxKit}
	\newcommand{\DemoName}{Infineon XMC4700 Relax Kit}
	\newcommand{\DemoImage}{DemoApplication_XMC4700}
 \else
       % default demo application
	\newcommand{\DemoPath}{<X2C\_ROOT>{\textbackslash\allowbreak}DemoApplication{\textbackslash\allowbreak}Blinky\_TI\_TMS320F28069\_controlSTICK}
	\newcommand{\DemoName}{TI F28069 Piccolo controlSTICK}
	\newcommand{\DemoImage}{DemoApplication_Piccolo}
\fi
%------------------------------------------
