\section{Module IO (E/S) et manipulation des broches}

Montre les fonctions pour pouvoir travailler avec les broches du PIC.

\verb! #include <pinio.h> !

\subsection[{output\_high\_slow}]{\label{ID_OUTPUTHIGHSLOW}output\_high\_slow}

Établit une broche de sortie (PIN) à l'état haut, tension proche de VCC, vérifie l'état de \textbf{tris}
\begin{verbatim}
void output_high_slow( BYTE puerto, 
                BYTE pin);
        ejemplo:
                output_high_slow(PIN_B0);
\end{verbatim}
\subsection[{output\_high\_fast}]{\label{ID_OUTPUTHIGHFAST}output\_high\_fast}

Établit une broche de sortie (PIN) à l'état haut, tension proche de VCC, ne vérifie pas l'état de \textbf{tris}
\begin{verbatim}
void output_high_fast( BYTE puerto, 
                BYTE pin);
        ejemplo:
                output_high_fast(PIN_B0);
\end{verbatim}

\subsection[{output\_high}]{\label{ID_OUTPUTHIGH}output\_high}

Établit une broche de sortie (PIN) à l'état haut, tension proche de VCC.
La vérification de l'état de tris dépend de l'état de la macro SLOW\_IO come vrai TRUE ou faux FALSE

Par défaut, si on n'écrit pas \#define SLOW\_IO TRUE ,  SLOW\_IO a la valeur TRUE

\begin{verbatim}
#define SLOW_IO TRUE

void output_high_fast( BYTE puerto, 
                BYTE pin);
        ejemplo:
                output_high_fast(PIN_B0);
\end{verbatim}

\subsection[{output\_low\_slow}]{\label{ID_OUTPUTLOWSLOW}output\_low\_slow}

Établit une broche de sortie (PIN) a l'état bas, tension proche de la masse, vérifie l'état de \textbf{tris} 
\begin{verbatim}
void output_low_slow( BYTE puerto, 
			BYTE pin);
exemple:
	 output_low_slow(PIN_B0);
\end{verbatim}

\subsection[{output\_low\_fast}]{\label{ID_OUTPUTLOWFAST}output\_low\_fast}

Établit une broche de sortie (PIN) a l'état bas, tension proche de la masse, ne vérifie pas l'état de \textbf{tris} 
\begin{verbatim}
void output_low_fast( BYTE puerto, 
			BYTE pin);
exemple:
	 output_low_fast(PIN_B0);
\end{verbatim}

\subsection[{output\_low}]{\label{ID_OUTPUTLOW}output\_low}
Établit une broche de sortie (PIN) a l'état bas, tension proche de la masse, 
La vérification de l'état de tris dépend de l'état de la macro SLOW\_IO come vrai TRUE ou faux FALSE

Par défaut, si on n'écrit pas \#define SLOW\_IO TRUE ,  SLOW\_IO a la valeur TRUE

\begin{verbatim}
void output_low( BYTE puerto, 
			BYTE pin);
exemple:
	 output_low(PIN_B0);
\end{verbatim}

\subsection[{input\_slow}]{\label{ID_INPUTSLOW}input\_slow}

Retourne l'état d'une broche d'entrée (pin). peut être 1 ou 0, vérifie l'état de \textbf{tris} 
\begin{verbatim}
BYTE input_slow( BYTE puerto, 
		BYTE pin);
exemple:
	input_slow(PIN_B1);
\end{verbatim}

\subsection[{input\_fast}]{\label{ID_INPUTFAST}input\_fast}

Retourne l'état d'une broche d'entrée (pin) peut être 1 ou 0, ne vérifie pas l'état de \textbf{tris} 
\begin{verbatim}
BYTE input_fast( BYTE puerto, 
		BYTE pin);
exemple:
	input_fast(PIN_B1);
\end{verbatim}i2c\_start

\subsection[{input}]{\label{ID_INPUT}input}

Retourne l'état d'une broche d'entrée (pin). peut être 1 ou 0
La vérification de l'état de tris dépend de l'état de la macro SLOW\_IO come vrai TRUE ou faux FALSE

Par défaut, si on n'écrit pas \#define SLOW\_IO TRUE ,  SLOW\_IO a la valeur TRUE

\begin{verbatim}
BYTE input( BYTE puerto, 
		BYTE pin);
exemple:
	input(PIN_B1);
\end{verbatim}

\subsection[{set\_pin\_to\_slow}]{  \label{ID_SETPINTOSLOW}set\_pin\_to\_slow}

Établit l'état d'une broche de sortie (pin) à 1 ou 0
\begin{verbatim}
 void set_pin_to_slow(volatile BYTE puerto, 
			BYTE pin,
			BYTE X);
	exemple :
	set_pin_to_slow(PIN_C1,1);//la broche C1 est maintenant à l'état haut
	set_pin_to_slow(PIN_C1,0);//la broche C1 est maintenant à l'état bas
\end{verbatim}

\subsection[{set\_pin\_to\_fast}]{  \label{ID_SETPINTOFAST}set\_pin\_to\_fast}

Établit l'état d'une broche de sortie (pin) à 1 ou 0
\begin{verbatim}
 void set_pin_to_fast(volatile BYTE puerto, 
			BYTE pin,
			BYTE X);
	exemple :
	set_pin_to_fast(PIN_C1,1);//la broche C1 est maintenant à l'état haut
	set_pin_to_fast(PIN_C1,0);//la broche C1 est maintenant à l'état bas
\end{verbatim}
\subsection[{set\_pin\_to}]{  \label{ID_SETPINTO}set\_pin\_to}

Établit l'état d'une broche de sortie (pin) à 1 ou 0
\begin{verbatim}
 void set_pin_to(volatile BYTE puerto, 
			BYTE pin,
			BYTE X);
	exemple :
	set_pin_to(PIN_C1,1);//la broche C1 est maintenant à l'état haut
	set_pin_to(PIN_C1,0);//la broche C1 est maintenant à l'état bas
\end{verbatim}

\subsection[{set\_pin\_tris\_to}]{\label{ID_SETPINTRISTO}set\_pin\_tris\_to}

TRIS data direction register: registre de direction des données.

Établit le TRIS d'une ~broche à 1 ou 0 
\begin{itemize}
\item si TRIS est à 1, la broche est en entrée
\item si TRIS est à 0, la broche est en sortie
\end{itemize}

\begin{verbatim}
 	void set_pin_tris_to(volatile BYTE *tris,
		volatile BYTE *puerto, 
		BYTE pin,
		BYTE X);
exemple:
	set_pin_tris_to(PIN_C1,1);//el TRIS C1 à 1, C1 en entrée
	set_pin_tris_to(PIN_C1,0);//el TRIS C1 à 0, C1 en sortie
\end{verbatim}

\subsection[{set\_porta\_as\_digital}]{\label{ID_SETPORTAASDIGITAL}set\_porta\_as\_digital}

Établit le port A comme DIGITAL
\begin{verbatim}
  #define set_porta_as_digital() ADCON1=0x06
	exemple:
	set_porta_as_digital();
\end{verbatim}

\subsection[{set\_pullup\_portb}]{  \label{ID_SETPULLUPPORTB}set\_pullup\_portb}

autorise ou inhibe les résistances de tirage vers le haut (pull-{}up) du port B

\begin{itemize}
 \item pour autoriser les résistances de tirage vers le haut (pull-{}up) X= 1 o TRUE
 \item pour inhiber ~les résistances de tirage vers le haut (pull-{}up) ~X= 0 o FALSE
\end{itemize}

void set\_pullup\_portb(BYTE X);

\subsection[{Exemple de PinIO}]{  \label{ID_EJEMPLOPINIO}Exemple de PinIO}

pour compiler vous avez besoin des commandes suivantes :
\begin{verbatim}
Exemple de compilation : ~./compila.sh ej\_pinio 16f877a
\end{verbatim}

ej\_pinio.c
\verbatiminput{source/ej_pinio.c}
