Netcruzer Library API  V2.03
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
nz_serDataPorts.h
Go to the documentation of this file.
1 
51 #ifndef NZ_SERDATAPORTS_H
52 #define NZ_SERDATAPORTS_H
53 
55 // "Serial Data Ports" - documentation module
57 
99 //"Serial Data Ports" contain circular buffers, this include is required
100 #include "nz_circularBuffer.h"
101 
102 
106 #define SERPORT_ID_DEBUG 0
107 
108 #define SERPORT_ID_UART1 1
109 #define SERPORT_ID_UART2 2
110 #define SERPORT_ID_UART3 3
111 #define SERPORT_ID_UART4 4
112 #define SERPORT_ID_SPI1 5
113 #define SERPORT_ID_SPI3 6
114 #define SERPORT_ID_I2C1 7
115 #define SERPORT_ID_I2C2 8
116 
117 #define SERPORT_ID_I2C3 9
118 #define SERPORT_ID_UDP1 10
119 #define SERPORT_ID_UDP2 11
120 #define SERPORT_ID_UDP3 12
121 #define SERPORT_ID_TCP1 13
122 #define SERPORT_ID_TCP2 14
123 #define SERPORT_ID_TCP3 15
124 #define SERPORT_ID_USB1 16
125 
126 #define SERPORT_ID_USER1 17
127 #define SERPORT_ID_USER2 18
128 #define SERPORT_ID_USER3 19
129 #define SERPORT_ID_USER4 20
130 #define SERPORT_ID_USER5 21
131 #define SERPORT_ID_USER6 22
132 #define SERPORT_ID_USER7 23
133 #define SERPORT_ID_USER8 24
134 
135 #define SERPORT_ID_MAX SERPORT_ID_USER8
136 
141 //#define BUF_COUNT (SERPORT_ID_MAX)
142 
143 
158 //1 I2C, 3 UDP, 3 TCP and one USB buffer
159 #define SERPORT_TXBUFID_UART1 (SERPORT_ID_UART1*2)
160 #define SERPORT_RXBUFID_UART1 ((SERPORT_ID_UART1*2)+1)
161 #define SERPORT_TXBUFID_UART2 (SERPORT_ID_UART2*2)
162 #define SERPORT_RXBUFID_UART2 ((SERPORT_ID_UART2*2)+1)
163 #define SERPORT_TXBUFID_UART3 (SERPORT_ID_UART3*2)
164 #define SERPORT_RXBUFID_UART3 ((SERPORT_ID_UART3*2)+1)
165 #define SERPORT_TXBUFID_UART4 (SERPORT_ID_UART4*2)
166 #define SERPORT_RXBUFID_UART4 ((SERPORT_ID_UART4*2)+1)
167 #define SERPORT_TXBUFID_SPI1 (SERPORT_ID_SPI1*2)
168 #define SERPORT_RXBUFID_SPI1 ((SERPORT_ID_SPI1*2)+1)
169 #define SERPORT_TXBUFID_SPI3 (SERPORT_ID_SPI3*2)
170 #define SERPORT_RXBUFID_SPI3 ((SERPORT_ID_SPI3*2)+1)
171 #define SERPORT_TXBUFID_I2C1 (SERPORT_ID_I2C1*2)
172 #define SERPORT_RXBUFID_I2C1 ((SERPORT_ID_I2C1*2)+1)
173 #define SERPORT_TXBUFID_I2C2 (SERPORT_ID_I2C2*2)
174 #define SERPORT_RXBUFID_I2C2 ((SERPORT_ID_I2C2*2)+1)
175 //1 I2C, 3 UDP, 3 TCP and one USB buffer
176 #define SERPORT_TXBUFID_I2C3 (SERPORT_ID_I2C3*2)
177 #define SERPORT_RXBUFID_I2C3 ((SERPORT_ID_I2C3*2)+1)
178 #define SERPORT_TXBUFID_UDP1 (SERPORT_ID_UDP1*2)
179 #define SERPORT_RXBUFID_UDP1 ((SERPORT_ID_UDP1*2)+1)
180 #define SERPORT_TXBUFID_UDP2 (SERPORT_ID_UDP2*2)
181 #define SERPORT_RXBUFID_UDP2 ((SERPORT_ID_UDP2*2)+1)
182 #define SERPORT_TXBUFID_UDP3 (SERPORT_ID_UDP3*2)
183 #define SERPORT_RXBUFID_UDP3 ((SERPORT_ID_UDP3*2)+1)
184 #define SERPORT_TXBUFID_TCP1 (SERPORT_ID_TCP1*2)
185 #define SERPORT_RXBUFID_TCP1 ((SERPORT_ID_TCP1*2)+1)
186 #define SERPORT_TXBUFID_TCP2 (SERPORT_ID_TCP2*2)
187 #define SERPORT_RXBUFID_TCP2 ((SERPORT_ID_TCP2*2)+1)
188 #define SERPORT_TXBUFID_TCP3 (SERPORT_ID_TCP3*2)
189 #define SERPORT_RXBUFID_TCP3 ((SERPORT_ID_TCP3*2)+1)
190 #define SERPORT_TXBUFID_USB1 (SERPORT_ID_USB1*2)
191 #define SERPORT_RXBUFID_USB1 ((SERPORT_ID_USB1*2)+1)
192 //8 User buffers
193 #define SERPORT_TXBUFID_USER1 (SERPORT_ID_USER1*2)
194 #define SERPORT_RXBUFID_USER1 ((SERPORT_ID_USER1*2)+1)
195 #define SERPORT_TXBUFID_USER2 (SERPORT_ID_USER2*2)
196 #define SERPORT_RXBUFID_USER2 ((SERPORT_ID_USER2*2)+1)
197 #define SERPORT_TXBUFID_USER3 (SERPORT_ID_USER3*2)
198 #define SERPORT_RXBUFID_USER3 ((SERPORT_ID_USER3*2)+1)
199 #define SERPORT_TXBUFID_USER4 (SERPORT_ID_USER4*2)
200 #define SERPORT_RXBUFID_USER4 ((SERPORT_ID_USER4*2)+1)
201 #define SERPORT_TXBUFID_USER5 (SERPORT_ID_USER5*2)
202 #define SERPORT_RXBUFID_USER5 ((SERPORT_ID_USER5*2)+1)
203 #define SERPORT_TXBUFID_USER6 (SERPORT_ID_USER6*2)
204 #define SERPORT_RXBUFID_USER6 ((SERPORT_ID_USER6*2)+1)
205 #define SERPORT_TXBUFID_USER7 (SERPORT_ID_USER7*2)
206 #define SERPORT_RXBUFID_USER7 ((SERPORT_ID_USER7*2)+1)
207 #define SERPORT_TXBUFID_USER8 (SERPORT_ID_USER8*2)
208 #define SERPORT_RXBUFID_USER8 ((SERPORT_ID_USER8*2)+1)
209 
210 
213  SERPORT_TYPE_UNDEFINED=0,
214  SERPORT_TYPE_SOFTWARE,
216  SERPORT_TYPE_USART,
217  SERPORT_TYPE_SPI,
218  SERPORT_TYPE_I2C,
219  SERPORT_TYPE_USBHID,
220  SERPORT_TYPE_UDP,
221  SERPORT_TYPE_TCP,
222  SERPORT_TYPE_CAN,
223  SERPORT_TYPE_MIWI,
224  SERPORT_TYPE_ZIGBEE,
225  SERPORT_TYPE_BLUETOOTH,
226  SERPORT_TYPE_MAX
227 };
228 
229 //#if (SERPORT_TYPE_MAX >= sizeof(SERPORT.flagBits.type))
230 #if (SERPORT_TYPE_MAX >= 32)
231 #error "Size of SERPORT.flagBits.type too small for all SERPORT_TYPES!"
232 #endif
233 
235 #define SERPORT_STAT_ENABLED 0x8000
236 
237 //SERPORT is defined in nz_netcruzer.h
239 // * "Serial Data Port" structure, TX and RX "Circular Buffers" (CIRBUF structures).
240 // */
241 typedef struct __attribute__((__packed__)) _SERPORT
242 {
243  union {
244  struct
245  {
246  unsigned int type : 5;
247  unsigned int fill5_7 : 3;
248  unsigned int typeInfo : 3;
249  unsigned int fill11_14 : 4;
250  unsigned int bEnabled : 1;
251  } flagBits;
252  struct
253  {
254  BYTE LB;
255  BYTE HB;
256  } flagBytes;
257  WORD flagVal;
258  };
259 
262 
263  BYTE fill;
264  BYTE strId;
265 } SERPORT;
266 
267 
268 typedef struct SERPORTS_ {
269 #if defined(HAS_NZ_DEBUGGING)
270  SERPORT debug;
271 #endif
272 
273 #if defined(HAS_SERPORT_UART1)
274  SERPORT uart1;
275 #endif
276 #if defined(HAS_SERPORT_UART2)
277  SERPORT uart2;
278 #endif
279 #if defined(HAS_SERPORT_UART2)
280  SERPORT uart3;
281 #endif
282 #if defined(HAS_SERPORT_UART4)
283  SERPORT uart4;
284 #endif
285 #if defined(HAS_SERPORT_SPI1)
286  SERPORT spi1;
287 #endif
288 #if defined(HAS_SERPORT_SPI3)
289  SERPORT spi3;
290 #endif
291 #if defined(HAS_SERPORT_I2C1)
292  SERPORT i2c1;
293 #endif
294 #if defined(HAS_SERPORT_I2C2)
295  SERPORT i2c2;
296 #endif
297 #if defined(HAS_SERPORT_I2C3)
298  SERPORT i2c3;
299 #endif
300 #if defined(HAS_SERPORT_UDP1)
301  SERPORT udp1;
302 #endif
303 #if defined(HAS_SERPORT_UDP2)
304  SERPORT udp2;
305 #endif
306 #if defined(HAS_SERPORT_UDP3)
307  SERPORT udp3;
308 #endif
309 #if defined(HAS_SERPORT_TCP1)
310  SERPORT tcp1;
311 #endif
312 #if defined(HAS_SERPORT_TCP2)
313  SERPORT tcp2;
314 #endif
315 #if defined(HAS_SERPORT_TCP3)
316  SERPORT tcp3;
317 #endif
318 #if defined(HAS_SERPORT_USB)
319  SERPORT usb;
320 #endif
321 #if defined(HAS_SERPORT_USER1)
322  SERPORT user1;
323 #endif
324 #if defined(HAS_SERPORT_USER2)
325  SERPORT user2;
326 #endif
327 #if defined(HAS_SERPORT_USER3)
328  SERPORT user3;
329 #endif
330 #if defined(HAS_SERPORT_USER4)
331  SERPORT user4;
332 #endif
333 #if defined(HAS_SERPORT_USER5)
334  SERPORT user5;
335 #endif
336 #if defined(HAS_SERPORT_USER6)
337  SERPORT user6;
338 #endif
339 #if defined(HAS_SERPORT_USER7)
340  SERPORT user7;
341 #endif
342 #if defined(HAS_SERPORT_USER8)
343  SERPORT user8;
344 #endif
345 } SERPORTS;
346 
347 
351 typedef union __attribute__((__packed__)) {
352  BYTE val;
353 
354  struct {
355  unsigned char uart1:1; //---- ---x = Serial 1
356  unsigned char uart2:1; //---- --x- = Serial 2
357  unsigned char uart3:1; //---- -x-- = Serial 3
358  unsigned char uart4:1; //---- x--- = Serial 4
359  unsigned char spi1:1; //---x ---- = SPI 1
360  unsigned char spi3:1; //--x- ---- = SPI 3
361  unsigned char i2c1:1; //-x-- ---- = I2C 1
362  unsigned char i2c2:1; //x--- ---- = I2C 2
363  } bits;
365 
366 
370 typedef union __attribute__((__packed__)) {
371  BYTE val;
372 
373  struct {
374  unsigned char i2c3:1; //---- ---x = I2C 3
375  unsigned char udp1:1; //---- --x- = UDP 1
376  unsigned char udp2:1; //---- -x-- = UDP 2
377  unsigned char udp3:1; //---- x--- = UDP 3
378  unsigned char tcp1:1; //---x ---- = TCP 1
379  unsigned char tcp2:1; //--x- ---- = TCP 2
380  unsigned char tcp3:1; //-x-- ---- = TCP 3
381  unsigned char usb:1; //x--- ---- = USB CDC 1
382  } bits;
384 
385 
389 typedef union __attribute__((__packed__)) {
390  BYTE val;
391 
392  struct {
393  unsigned char user1:1; //---- ---x = User 1
394  unsigned char user2:1; //---- --x- = User 2
395  unsigned char user3:1; //---- -x-- = User 3
396  unsigned char user4:1; //---- x--- = User 4
397  unsigned char user5:1; //---x ---- = User 5
398  unsigned char user6:1; //--x- ---- = User 6
399  unsigned char user7:1; //-x-- ---- = User 7
400  unsigned char user8:1; //x--- ---- = Debug
401  } bits;
403 
404 
408 typedef union __attribute__((__packed__)) {
409  BYTE val;
410 
411  struct {
412  unsigned char res1:1; //---- ---x = Reserved
413  unsigned char res2:1; //---- --x- = Reserved
414  unsigned char res3:1; //---- -x-- = Reserved
415  unsigned char res4:1; //---- x--- = Reserved
416  unsigned char res5:1; //---x ---- = Reserved
417  unsigned char res6:1; //--x- ---- = Reserved
418  unsigned char res7:1; //-x-- ---- = Reserved
419  unsigned char res8:1; //x--- ---- = Reserved
420  } bits;
422 
423 
428 typedef struct __attribute__((aligned(2), packed)) _SER_INFO
429 {
430  BYTE count; //Number of "Serial Data Ports".
431  BYTE padd1; //Padding
432 
433  union {
434  BYTE avail[4];
435  struct
436  {
437  SER_AVAIL_0TO7 avail_0to7;
438  SER_AVAIL_8TO15 avail_8to15;
439  SER_AVAIL_16TO23 avail_16to23;
440  SER_AVAIL_24TO31 avail_24to31;
441  } block;
442  };
443 
444  BYTE* buf; //Pointer to allocated memory space used for all CIRBUF buffers
445 } SER_INFO;
446 
447 
448 
452 
462 //typedef struct __attribute__((aligned(2), packed)) _SER_CONFIG
463 typedef struct __attribute__((__packed__))
464 {
465  BYTE flags;
466  BYTE strId;
467  BYTE txType;
468  BYTE rxType;
469  WORD txSize;
470  WORD rxSize;
471 } SER_CONFIG;
472 
473 
478 typedef struct __attribute__((__packed__))
479 {
480  BYTE conf[4];
482 
483 
488 typedef struct __attribute__((__packed__))
489 {
490  BYTE conf[4];
492 
497 typedef struct __attribute__((__packed__))
498 {
499  BYTE conf[4];
501 
502 
507 typedef struct __attribute__((__packed__))
508 {
509  BYTE conf[4];
511 
512 
517 typedef struct __attribute__((__packed__))
518 {
519  BYTE conf[4];
521 
522 
527 typedef struct __attribute__((__packed__))
528 {
529  BYTE conf[4];
531 
532 
537 typedef struct __attribute__((__packed__))
538 {
540  BYTE res;
541 
542  SER_CONFIG uart1;
543  SER_CONFIG uart2;
544  SER_CONFIG uart3;
545  SER_CONFIG uart4;
546  SER_CONFIG spi1;
547  SER_CONFIG spi3;
548  SER_CONFIG i2c1;
549  SER_CONFIG i2c2;
550 
551  SER_CONFIG_UART ser1Conf;
552  SER_CONFIG_UART ser2Conf;
553  SER_CONFIG_UART ser3Conf;
554  SER_CONFIG_UART ser4Conf;
555  SER_CONFIG_SPI spi1Conf;
556  SER_CONFIG_SPI spi3Conf;
557  SER_CONFIG_I2C i2c1Conf;
558  SER_CONFIG_I2C i2c2Conf;
559 
560  BYTE reserve[26];
562 
563 
568 typedef struct __attribute__((__packed__))
569 {
571  BYTE res;
572 
573  SER_CONFIG i2c3;
574  SER_CONFIG udp1;
575  SER_CONFIG udp2;
576  SER_CONFIG udp3;
577  SER_CONFIG tcp1;
578  SER_CONFIG tcp2;
579  SER_CONFIG tcp3;
580  SER_CONFIG usb;
581 
582  SER_CONFIG_I2C i2c3Conf;
583  SER_CONFIG_UDP udp1Conf;
584  SER_CONFIG_UDP udp2Conf;
585  SER_CONFIG_UDP udp3Conf;
586  SER_CONFIG_TCP tcp1Conf;
587  SER_CONFIG_TCP tcp2Conf;
588  SER_CONFIG_TCP tcp3Conf;
589  SER_CONFIG_USB usbConf;
590 
591  BYTE reserve[26];
593 
594 
599 typedef struct __attribute__((__packed__))
600 {
602  BYTE res;
603 
604  SER_CONFIG user1;
605  SER_CONFIG user2;
606  SER_CONFIG user3;
607  SER_CONFIG user4;
608  SER_CONFIG user5;
609  SER_CONFIG user6;
610  SER_CONFIG user7;
611  SER_CONFIG user8;
612 
613  BYTE user1Conf[4];
614  BYTE user2Conf[4];
615  BYTE user3Conf[4];
616  BYTE user4Conf[4];
617  BYTE user5Conf[4];
618  BYTE user6Conf[4];
619  BYTE user7Conf[4];
620  BYTE user8Conf[4];
621 
622  BYTE reserve[26];
624 
625 
630 typedef struct __attribute__((__packed__))
631 {
633  BYTE res;
634 
635  SER_CONFIG res1;
636  SER_CONFIG res2;
637  SER_CONFIG res3;
638  SER_CONFIG res4;
639  SER_CONFIG res5;
640  SER_CONFIG res6;
641  SER_CONFIG res7;
642  SER_CONFIG res8;
643 
644  BYTE reserve[26];
646 
647 
648 
650 // "Serial Data Port" includes and Macros
652 
653 #if defined(HAS_NZ_DEBUGGING)
654  #define SERPORT_DEBUG_INIT() debugInit()
655  #define SERPORT_DEBUG_TASK() debugService()
656 #else
657  #define SERPORT_DEBUG_INIT()
658  #define SERPORT_DEBUG_TASK()
659 #endif
660 #if defined(HAS_SERPORT_UART1) || defined(HAS_SERPORT_UART2) || defined(HAS_SERPORT_UART3) || defined(HAS_SERPORT_UART4)
661  #include "nz_serUart.h"
662 #endif
663 #if defined(HAS_SERPORT_UART1)
664  #define SERPORT_UART1_INIT() serUart1Init()
665  #define SERPORT_UART1_TASK() serUart1Task()
666 #else
667  #define SERPORT_UART1_INIT()
668  #define SERPORT_UART1_TASK()
669 #endif
670 
671 #if defined(HAS_SERPORT_UART2)
672  #define SERPORT_UART2_INIT() serUart2Init()
673  #define SERPORT_UART2_TASK() serUart2Task()
674 #else
675  #define SERPORT_UART2_INIT()
676  #define SERPORT_UART2_TASK()
677 #endif
678 
679 #if defined(HAS_SERPORT_UART3)
680  #define SERPORT_UART3_INIT() serUart3Init()
681  #define SERPORT_UART3_TASK() serUart3Task()
682 #else
683  #define SERPORT_UART3_INIT()
684  #define SERPORT_UART3_TASK()
685 #endif
686 
687 #if defined(HAS_SERPORT_UART4)
688  #define SERPORT_UART4_INIT() serUart4Init()
689  #define SERPORT_UART4_TASK() serUart4Task()
690 #else
691  #define SERPORT_UART4_INIT()
692  #define SERPORT_UART4_TASK()
693 #endif
694 
695 #if defined(HAS_SERPORT_SPI1) || defined(HAS_SERPORT_SPI3) || defined(HAS_SERPORT_SPI4)
696  #include "serSPI.h"
697 #endif
698 #if defined(HAS_SERPORT_SPI1)
699  #define SERPORT_SPI1_INIT() serSPI1Init()
700  #define SERPORT_SPI1_TASK() serSPI1Task()
701 #else
702  #define SERPORT_SPI1_INIT()
703  #define SERPORT_SPI1_TASK()
704 #endif
705 
706 #if defined(HAS_SERPORT_SPI3)
707  #define SERPORT_SPI3_INIT() serSPI3Init()
708  #define SERPORT_SPI3_TASK() serSPI3Task()
709 #else
710  #define SERPORT_SPI3_INIT()
711  #define SERPORT_SPI3_TASK()
712 #endif
713 
714 #if defined(HAS_SERPORT_I2C1) || defined(HAS_SERPORT_I2C2) || defined(HAS_SERPORT_I2C3)
715  #include "nz_serI2C.h"
716 #endif
717 #if defined(HAS_SERPORT_I2C1)
718  #define SERPORT_I2C1_INIT() serI2C1Init()
719  #define SERPORT_I2C1_TASK() serI2CTask(&i2c1Info)
720 #else
721  #define SERPORT_I2C1_INIT()
722  #define SERPORT_I2C1_TASK()
723 #endif
724 
725 #if defined(HAS_SERPORT_I2C2)
726  #define SERPORT_I2C2_INIT() serI2C2Init()
727  #define SERPORT_I2C2_TASK() serI2CTask(&i2c2Info)
728 #else
729  #define SERPORT_I2C2_INIT()
730  #define SERPORT_I2C2_TASK()
731 #endif
732 
733 #if defined(HAS_SERPORT_I2C3)
734  #define SERPORT_I2C3_INIT() serI2C3Init()
735  #define SERPORT_I2C3_TASK() serI2CTask(&i2c3Info)
736 #else
737  #define SERPORT_I2C3_INIT()
738  #define SERPORT_I2C3_TASK()
739 #endif
740 
741 #if defined(HAS_SERPORT_UDP1) || defined(HAS_SERPORT_UDP2) || defined(HAS_SERPORT_UDP3)
742  #include "nz_serUDP.h"
743 #endif
744 #if defined(HAS_SERPORT_UDP1)
745  #define SERPORT_UDP1_INIT() serUDP1Init()
746  #define SERPORT_UDP1_TASK() serUDP1Task()
747 #else
748  #define SERPORT_UDP1_INIT()
749  #define SERPORT_UDP1_TASK()
750 #endif
751 
752 #if defined(HAS_SERPORT_UDP2)
753  #define SERPORT_UDP2_INIT() serUDP2Init()
754  #define SERPORT_UDP2_TASK() serUDP2Task()
755 #else
756  #define SERPORT_UDP2_INIT()
757  #define SERPORT_UDP2_TASK()
758 #endif
759 
760 #if defined(HAS_SERPORT_UDP3)
761  #define SERPORT_UDP3_INIT() serUDP3Init()
762  #define SERPORT_UDP3_TASK() serUDP3Task()
763 #else
764  #define SERPORT_UDP3_INIT()
765  #define SERPORT_UDP3_TASK()
766 #endif
767 
768 #if defined(HAS_SERPORT_TCP1) || defined(HAS_SERPORT_TCP2) || defined(HAS_SERPORT_TCP3)
769  #include "nz_serUDP.h"
770 #endif
771 #if defined(HAS_SERPORT_TCP1)
772  #define SERPORT_TCP1_INIT() serTCP1Init()
773  #define SERPORT_TCP1_TASK() serTCP1Task()
774 #else
775  #define SERPORT_TCP1_INIT()
776  #define SERPORT_TCP1_TASK()
777 #endif
778 
779 #if defined(HAS_SERPORT_TCP2)
780  #define SERPORT_TCP2_INIT() serTCP2Init()
781  #define SERPORT_TCP2_TASK() serTCP2Task()
782 #else
783  #define SERPORT_TCP2_INIT()
784  #define SERPORT_TCP2_TASK()
785 #endif
786 
787 #if defined(HAS_SERPORT_TCP3)
788  #define SERPORT_TCP3_INIT() serTCP3Init()
789  #define SERPORT_TCP3_TASK() serTCP3Task()
790 #else
791  #define SERPORT_TCP3_INIT()
792  #define SERPORT_TCP3_TASK()
793 #endif
794 
795 #if defined(HAS_SERPORT_USB)
796  #include "nz_serUSB.h"
797  #define SERPORT_USB_INIT() serUSBInit()
798  #define SERPORT_USB_TASK() serUSBTask()
799 #else
800  #define SERPORT_USB_INIT()
801  #define SERPORT_USB_TASK()
802 #endif
803 
804 
805 #if defined(HAS_SERPORT_USER1) || defined(HAS_SERPORT_USER2) || defined(HAS_SERPORT_USER3) || defined(HAS_SERPORT_USER4) || defined(HAS_SERPORT_USER5) || defined(HAS_SERPORT_USER6) || defined(HAS_SERPORT_USER7) || defined(HAS_SERPORT_USER8)
806  #include "nz_serUDP.h"
807 #endif
808 #if defined(HAS_SERPORT_USER1)
809  #define SERPORT_USER1_INIT() serUser1Init()
810  #define SERPORT_USER1_TASK() serUser1Task()
811 #else
812  #define SERPORT_USER1_INIT()
813  #define SERPORT_USER1_TASK()
814 #endif
815 #if defined(HAS_SERPORT_USER2)
816  #define SERPORT_USER2_INIT() serUser2Init()
817  #define SERPORT_USER2_TASK() serUser2Task()
818 #else
819  #define SERPORT_USER2_INIT()
820  #define SERPORT_USER2_TASK()
821 #endif
822 #if defined(HAS_SERPORT_USER3)
823  #define SERPORT_USER3_INIT() serUser3Init()
824  #define SERPORT_USER3_TASK() serUser3Task()
825 #else
826  #define SERPORT_USER3_INIT()
827  #define SERPORT_USER3_TASK()
828 #endif
829 #if defined(HAS_SERPORT_USER4)
830  #define SERPORT_USER4_INIT() serUser4Init()
831  #define SERPORT_USER4_TASK() serUser4Task()
832 #else
833  #define SERPORT_USER4_INIT()
834  #define SERPORT_USER4_TASK()
835 #endif
836 #if defined(HAS_SERPORT_USER5)
837  #define SERPORT_USER5_INIT() serUser5Init()
838  #define SERPORT_USER5_TASK() serUser5Task()
839 #else
840  #define SERPORT_USER5_INIT()
841  #define SERPORT_USER5_TASK()
842 #endif
843 #if defined(HAS_SERPORT_USER6)
844  #define SERPORT_USER6_INIT() serUser6Init()
845  #define SERPORT_USER6_TASK() serUser6Task()
846 #else
847  #define SERPORT_USER6_INIT()
848  #define SERPORT_USER6_TASK()
849 #endif
850 #if defined(HAS_SERPORT_USER7)
851  #define SERPORT_USER7_INIT() serUser7Init()
852  #define SERPORT_USER7_TASK() serUser7Task()
853 #else
854  #define SERPORT_USER7_INIT()
855  #define SERPORT_USER7_TASK()
856 #endif
857 #if defined(HAS_SERPORT_USER8)
858  #define SERPORT_USER8_INIT() serUser8Init()
859  #define SERPORT_USER8_TASK() serUser8Task()
860 #else
861  #define SERPORT_USER8_INIT()
862  #define SERPORT_USER8_TASK()
863 #endif
864 
865 
866 
868 // Make all "Serial Data Ports" available externally
870 
871 #if !defined(THIS_IS_NZ_SERDATA_PORTS_C)
872  extern SER_INFO serInfo;
873 
874  extern SERPORTS serports;
875 #endif
876 
877 
878 
880 // Define TX and RX "Circular Buffers" for all "Serial Data Ports"
882 #define CIRBUF_TX_DEBUG (&serports.debug.cbufTx)
883 #define CIRBUF_RX_DEBUG (&serports.debug.cbufRx)
884 
885 #define CIRBUF_TX_UART1 (&serports.uart1.cbufTx)
886 #define CIRBUF_RX_UART1 (&serports.uart1.cbufRx)
887 #define CIRBUF_TX_UART2 (&serports.uart2.cbufTx)
888 #define CIRBUF_RX_UART2 (&serports.uart2.cbufRx)
889 #define CIRBUF_TX_UART3 (&serports.uart3.cbufTx)
890 #define CIRBUF_RX_UART3 (&serports.uart3.cbufRx)
891 #define CIRBUF_TX_UART4 (&serports.uart4.cbufTx)
892 #define CIRBUF_RX_UART4 (&serports.uart4.cbufRx)
893 #define CIRBUF_TX_SPI1 (&serports.spi1.cbufTx)
894 #define CIRBUF_RX_SPI1 (&serports.spi1.cbufRx)
895 #define CIRBUF_TX_SPI3 (&serports.spi3.cbufTx)
896 #define CIRBUF_RX_SPI3 (&serports.spi3.cbufRx)
897 #define CIRBUF_TX_I2C1 (&serports.i2c1.cbufTx)
898 #define CIRBUF_RX_I2C1 (&serports.i2c1.cbufRx)
899 #define CIRBUF_TX_I2C2 (&serports.i2c2.cbufTx)
900 #define CIRBUF_RX_I2C2 (&serports.i2c2.cbufRx)
901 
902 #define CIRBUF_TX_I2C3 (&serports.i2c3.cbufTx)
903 #define CIRBUF_RX_I2C3 (&serports.i2c3.cbufRx)
904 #define CIRBUF_TX_UDP1 (&serports.udp1.cbufTx)
905 #define CIRBUF_RX_UDP1 (&serports.udp1.cbufRx)
906 #define CIRBUF_TX_UDP2 (&serports.udp2.cbufTx)
907 #define CIRBUF_RX_UDP2 (&serports.udp2.cbufRx)
908 #define CIRBUF_TX_UDP3 (&serports.udp3.cbufTx)
909 #define CIRBUF_RX_UDP3 (&serports.udp3.cbufRx)
910 #define CIRBUF_TX_TCP1 (&serports.tcp1.cbufTx)
911 #define CIRBUF_RX_TCP1 (&serports.tcp1.cbufRx)
912 #define CIRBUF_TX_TCP2 (&serports.tcp2.cbufTx)
913 #define CIRBUF_RX_TCP2 (&serports.tcp2.cbufRx)
914 #define CIRBUF_TX_TCP3 (&serports.tcp3.cbufTx)
915 #define CIRBUF_RX_TCP3 (&serports.tcp3.cbufRx)
916 #define CIRBUF_TX_USB (&serports.usb.cbufTx)
917 #define CIRBUF_RX_USB (&serports.usb.cbufRx)
918 
919 #define CIRBUF_TX_USER1 (&serports.user1.cbufTx)
920 #define CIRBUF_RX_USER1 (&serports.user1.cbufRx)
921 #define CIRBUF_TX_USER2 (&serports.user2.cbufTx)
922 #define CIRBUF_RX_USER2 (&serports.user2.cbufRx)
923 #define CIRBUF_TX_USER3 (&serports.user3.cbufTx)
924 #define CIRBUF_RX_USER3 (&serports.user3.cbufRx)
925 #define CIRBUF_TX_USER4 (&serports.user4.cbufTx)
926 #define CIRBUF_RX_USER4 (&serports.user4.cbufRx)
927 #define CIRBUF_TX_USER5 (&serports.user5.cbufTx)
928 #define CIRBUF_RX_USER5 (&serports.user5.cbufRx)
929 #define CIRBUF_TX_USER6 (&serports.user6.cbufTx)
930 #define CIRBUF_RX_USER6 (&serports.user6.cbufRx)
931 #define CIRBUF_TX_USER7 (&serports.user7.cbufTx)
932 #define CIRBUF_RX_USER7 (&serports.user7.cbufRx)
933 #define CIRBUF_TX_USER8 (&serports.user8.cbufTx)
934 #define CIRBUF_RX_USER8 (&serports.user8.cbufRx)
935 
936 
940 void serInit(void);
941 
942 
946 void serDefaultInit(void);
947 
948 
953 void serTask(void);
954 
960 #define getCirbufForSerportID(bufid) ( (bufid&0x01) ? ( &((SERPORT*)(NZ_GLOBALS_SERPORT_FIRST + (bufid/2)))->cbufTx) : ( &((SERPORT*)(NZ_GLOBALS_SERPORT_FIRST + (bufid/2)))->cbufRx) )
961 
962 
963 #define serIsEnabled(pSerport) ( ((pSerport->flags & SERPORT_STAT_ENABLED) != 0) && (pSerport!=NULL) )
964 
965 
966 #endif //#ifndef NZ_SERDATAPORTS_H