AvrIO  1.4.5
Bibliothèque C modulaire pour ATMEL AVR
serial.h
1 
20 #ifndef _AVRIO_SERIAL_H_
21 #define _AVRIO_SERIAL_H_
22 
23 #include <avrio/defs.h>
24 #include <avrio/serialios.h>
25 #include <avr/interrupt.h>
41  /* constants ============================================================== */
42 #define SERIAL_NOECHO 0x0000
43 #define SERIAL_ECHO 0x0001
44 #define SERIAL_5BIT 0x0000
45 #define SERIAL_6BIT 0x0002
46 #define SERIAL_7BIT 0x0004
47 #define SERIAL_8BIT 0x0006
48 #define SERIAL_9BIT 0x8006
49 #define SERIAL_2STP 0x0008
50 #define SERIAL_1STP 0x0000
51 #define SERIAL_NONE 0x0000
52 #define SERIAL_EVEN 0x0020
53 #define SERIAL_ODD 0x0030
54 #define SERIAL_WR 0x0040
55 #define SERIAL_RD 0x0080
56 #define SERIAL_RW 0x00C0
57 #define SERIAL_NOBLOCK 0x0100
58 #define SERIAL_RTSCTS 0x0200
59 #define SERIAL_XONXOFF 0x0400
64 #define EBADBAUD (-2)
65 
70 #define SERIAL_DEFAULT \
71  (SERIAL_8BIT + SERIAL_1STP + SERIAL_NONE + SERIAL_NOECHO)
72 
73  /* macros ================================================================= */
74 
82 #define SERIAL_BAUD_X1(usBaud) (AVRIO_CPU_FREQ / (1600UL * usBaud) - 1)
83 
91 #define SERIAL_BAUD_X2(usBaud) (AVRIO_CPU_FREQ / (800UL * usBaud) - 1)
92 
93 #ifndef __ASSEMBLER__
94 /* ========================================================================== */
95 __BEGIN_C_DECLS
96 
97 #include <stdio.h>
98 
99 /* constants ================================================================ */
100 
105 typedef enum {
110 } eSerialError;
111 
112 /* internal public functions ================================================ */
118 void vSerialInit (uint16_t usBaud, uint16_t usFlags);
119 
123 uint16_t usIosToFlags (const xSerialIos * ios);
124 
128 void vSerialFlush(void);
129 
133 void vSerialSetFlags (uint16_t usFlags);
134 
138 uint16_t usSerialGetFlags (void);
139 
143 bool xSerialReady (void);
144 
148 void vSerialEnable (uint16_t usFlags);
149 
155 int iSerialPutChar (char c);
156 
166 void vSerialPutString (const char *pcString);
167 
172 int iSerialGetChar (void);
173 
177 uint16_t usSerialHit (void);
178 
179 /* public variables ========================================================= */
201 extern FILE xSerialPort;
202 
208 extern int iSerialError;
209 
210 /* ========================================================================== */
211 __END_C_DECLS
212 #endif /* __ASSEMBLER__ not defined */
213 
218 /* *INDENT-ON* */
219 #endif /* _AVRIO_SERIAL_H_ */
uint16_t usIosToFlags(const xSerialIos *ios)
uint16_t usSerialHit(void)
Renvoie le nombre de caractères reçus.
int iSerialPutChar(char c)
Envoie un caractère sur la liaison série.
void vSerialInit(uint16_t usBaud, uint16_t usFlags)
Initialise l&#39;SERIAL.
void vSerialEnable(uint16_t usFlags)
Modifie l&#39;accès en lecture et/ou écriture.
void vSerialSetFlags(uint16_t usFlags)
Modifie les drapeaux de configuration de l&#39;uart.
eSerialError
Codes d&#39;erreur.
Definition: serial.h:105
void vSerialPutString(const char *pcString)
Envoie une chaîne caractères sur la liaison série.
FILE xSerialPort
Descripteur de fichier de l&#39;uart permettant son utilisation avec les fonctions de la libc...
uint16_t usSerialGetFlags(void)
Renvoie les drapeaux de configuration de l&#39;uart.
void vSerialFlush(void)
Vide les tampons de transmission et de réception.
bool xSerialReady(void)
int iSerialGetChar(void)
Reçoit un caractère sur la liaison série.
int iSerialError
Numéro de la dernière erreur.