AvrIO  1.4.5
Bibliothèque C modulaire pour ATMEL AVR
tnc.h
1 
20 #ifndef _AVRIO_TNC_H_
21 #define _AVRIO_TNC_H_
22 
23 #include <avrio/defs.h>
24 
25 __BEGIN_C_DECLS
26 /* ========================================================================== */
27 #include <stdio.h>
28 
49 /* constants ================================================================ */
50 #define TNC_SOH 1
51 #define TNC_STX 2
52 #define TNC_ETX 3
53 #define TNC_EOT 4
54 #define TNC_TXT 5
55 #define TNC_CRC 6
56 
60 typedef enum {
61 
62  TNC_SUCCESS = 0,
63  TNC_CRC_ERROR = -1,
64  TNC_NOT_ENOUGH_MEMORY = -2,
65  TNC_OBJECT_NOT_FOUND = -3,
66  TNC_ILLEGAL_MSG = -4,
67  TNC_FILE_NOT_FOUND = -5,
68  TNC_IO_ERROR = -6
69 
70 } eTncError;
71 
72 //##############################################################################
73 //# #
74 //# xTnc Class #
75 //# #
76 //##############################################################################
77 
78 struct xTnc;
79 
86 void vTncInit (struct xTnc *p, FILE *fin, FILE *fout);
87 
91 void vTncClear (struct xTnc *p);
92 
105 int iTncPoll(struct xTnc *tnc);
106 
114 ssize_t iTncWrite (struct xTnc *tnc, const void *buf, size_t count);
115 
119 int iTncError (struct xTnc *tnc);
120 
121 #if defined(__DOXYGEN__)
122 /*
123  * __DOXYGEN__ defined
124  * Partie documentation ne devant pas être compilée.
125  * =============================================================================
126  */
131 #else
132 /*
133  * __DOXYGEN__ not defined
134  * Partie ne devant pas être documentée.
135  * =============================================================================
136  */
137 #include "avrio-config.h"
138 
139 #ifdef AVRIO_TNC_ENABLE
140 #include "avrio-board-tnc.h"
144 typedef struct xTnc {
145 
146  FILE * fin;
147  FILE * fout;
148  uint8_t rxbuf[TNC_RXBUFSIZE];
149  size_t len;
150  uint16_t crc_rx;
151  uint16_t crc_tx;
152  int state;
153  uint8_t cnt;
154  uint8_t msb;
155 } xTnc;
156 
157 #endif /* AVRIO_TNC_ENABLE defined */
158 
159 #endif /* __DOXYGEN__ not defined */
160 
161 /* ========================================================================== */
162 __END_C_DECLS
163 #endif /* _AVRIO_TNC_H_ */
int iTncError(struct xTnc *tnc)
eTncError
Definition: tnc.h:60
ssize_t iTncWrite(struct xTnc *tnc, const void *buf, size_t count)
void vTncClear(struct xTnc *p)
int iTncPoll(struct xTnc *tnc)
void vTncInit(struct xTnc *p, FILE *fin, FILE *fout)