51 #ifndef NZ_SERDATAPORTS_H
52 #define NZ_SERDATAPORTS_H
106 #define SERPORT_ID_DEBUG 0
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
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
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
135 #define SERPORT_ID_MAX SERPORT_ID_USER8
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)
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)
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)
213 SERPORT_TYPE_UNDEFINED=0,
214 SERPORT_TYPE_SOFTWARE,
225 SERPORT_TYPE_BLUETOOTH,
230 #if (SERPORT_TYPE_MAX >= 32)
231 #error "Size of SERPORT.flagBits.type too small for all SERPORT_TYPES!"
235 #define SERPORT_STAT_ENABLED 0x8000
241 typedef struct __attribute__((__packed__))
_SERPORT
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;
269 #if defined(HAS_NZ_DEBUGGING)
273 #if defined(HAS_SERPORT_UART1)
276 #if defined(HAS_SERPORT_UART2)
279 #if defined(HAS_SERPORT_UART2)
282 #if defined(HAS_SERPORT_UART4)
285 #if defined(HAS_SERPORT_SPI1)
288 #if defined(HAS_SERPORT_SPI3)
291 #if defined(HAS_SERPORT_I2C1)
294 #if defined(HAS_SERPORT_I2C2)
297 #if defined(HAS_SERPORT_I2C3)
300 #if defined(HAS_SERPORT_UDP1)
303 #if defined(HAS_SERPORT_UDP2)
306 #if defined(HAS_SERPORT_UDP3)
309 #if defined(HAS_SERPORT_TCP1)
312 #if defined(HAS_SERPORT_TCP2)
315 #if defined(HAS_SERPORT_TCP3)
318 #if defined(HAS_SERPORT_USB)
321 #if defined(HAS_SERPORT_USER1)
324 #if defined(HAS_SERPORT_USER2)
327 #if defined(HAS_SERPORT_USER3)
330 #if defined(HAS_SERPORT_USER4)
333 #if defined(HAS_SERPORT_USER5)
336 #if defined(HAS_SERPORT_USER6)
339 #if defined(HAS_SERPORT_USER7)
342 #if defined(HAS_SERPORT_USER8)
351 typedef union __attribute__((__packed__)) {
355 unsigned char uart1:1;
356 unsigned char uart2:1;
357 unsigned char uart3:1;
358 unsigned char uart4:1;
359 unsigned char spi1:1;
360 unsigned char spi3:1;
361 unsigned char i2c1:1;
362 unsigned char i2c2:1;
370 typedef union __attribute__((__packed__)) {
374 unsigned char i2c3:1;
375 unsigned char udp1:1;
376 unsigned char udp2:1;
377 unsigned char udp3:1;
378 unsigned char tcp1:1;
379 unsigned char tcp2:1;
380 unsigned char tcp3:1;
389 typedef union __attribute__((__packed__)) {
393 unsigned char user1:1;
394 unsigned char user2:1;
395 unsigned char user3:1;
396 unsigned char user4:1;
397 unsigned char user5:1;
398 unsigned char user6:1;
399 unsigned char user7:1;
400 unsigned char user8:1;
408 typedef union __attribute__((__packed__)) {
412 unsigned char res1:1;
413 unsigned char res2:1;
414 unsigned char res3:1;
415 unsigned char res4:1;
416 unsigned char res5:1;
417 unsigned char res6:1;
418 unsigned char res7:1;
419 unsigned char res8:1;
428 typedef struct __attribute__((aligned(2), packed))
_SER_INFO
463 typedef struct __attribute__((__packed__))
478 typedef struct __attribute__((__packed__))
488 typedef struct __attribute__((__packed__))
497 typedef struct __attribute__((__packed__))
507 typedef struct __attribute__((__packed__))
517 typedef struct __attribute__((__packed__))
527 typedef struct __attribute__((__packed__))
537 typedef struct __attribute__((__packed__))
568 typedef struct __attribute__((__packed__))
599 typedef struct __attribute__((__packed__))
630 typedef struct __attribute__((__packed__))
653 #if defined(HAS_NZ_DEBUGGING)
654 #define SERPORT_DEBUG_INIT() debugInit()
655 #define SERPORT_DEBUG_TASK() debugService()
657 #define SERPORT_DEBUG_INIT()
658 #define SERPORT_DEBUG_TASK()
660 #if defined(HAS_SERPORT_UART1) || defined(HAS_SERPORT_UART2) || defined(HAS_SERPORT_UART3) || defined(HAS_SERPORT_UART4)
663 #if defined(HAS_SERPORT_UART1)
664 #define SERPORT_UART1_INIT() serUart1Init()
665 #define SERPORT_UART1_TASK() serUart1Task()
667 #define SERPORT_UART1_INIT()
668 #define SERPORT_UART1_TASK()
671 #if defined(HAS_SERPORT_UART2)
672 #define SERPORT_UART2_INIT() serUart2Init()
673 #define SERPORT_UART2_TASK() serUart2Task()
675 #define SERPORT_UART2_INIT()
676 #define SERPORT_UART2_TASK()
679 #if defined(HAS_SERPORT_UART3)
680 #define SERPORT_UART3_INIT() serUart3Init()
681 #define SERPORT_UART3_TASK() serUart3Task()
683 #define SERPORT_UART3_INIT()
684 #define SERPORT_UART3_TASK()
687 #if defined(HAS_SERPORT_UART4)
688 #define SERPORT_UART4_INIT() serUart4Init()
689 #define SERPORT_UART4_TASK() serUart4Task()
691 #define SERPORT_UART4_INIT()
692 #define SERPORT_UART4_TASK()
695 #if defined(HAS_SERPORT_SPI1) || defined(HAS_SERPORT_SPI3) || defined(HAS_SERPORT_SPI4)
698 #if defined(HAS_SERPORT_SPI1)
699 #define SERPORT_SPI1_INIT() serSPI1Init()
700 #define SERPORT_SPI1_TASK() serSPI1Task()
702 #define SERPORT_SPI1_INIT()
703 #define SERPORT_SPI1_TASK()
706 #if defined(HAS_SERPORT_SPI3)
707 #define SERPORT_SPI3_INIT() serSPI3Init()
708 #define SERPORT_SPI3_TASK() serSPI3Task()
710 #define SERPORT_SPI3_INIT()
711 #define SERPORT_SPI3_TASK()
714 #if defined(HAS_SERPORT_I2C1) || defined(HAS_SERPORT_I2C2) || defined(HAS_SERPORT_I2C3)
717 #if defined(HAS_SERPORT_I2C1)
718 #define SERPORT_I2C1_INIT() serI2C1Init()
719 #define SERPORT_I2C1_TASK() serI2CTask(&i2c1Info)
721 #define SERPORT_I2C1_INIT()
722 #define SERPORT_I2C1_TASK()
725 #if defined(HAS_SERPORT_I2C2)
726 #define SERPORT_I2C2_INIT() serI2C2Init()
727 #define SERPORT_I2C2_TASK() serI2CTask(&i2c2Info)
729 #define SERPORT_I2C2_INIT()
730 #define SERPORT_I2C2_TASK()
733 #if defined(HAS_SERPORT_I2C3)
734 #define SERPORT_I2C3_INIT() serI2C3Init()
735 #define SERPORT_I2C3_TASK() serI2CTask(&i2c3Info)
737 #define SERPORT_I2C3_INIT()
738 #define SERPORT_I2C3_TASK()
741 #if defined(HAS_SERPORT_UDP1) || defined(HAS_SERPORT_UDP2) || defined(HAS_SERPORT_UDP3)
742 #include "nz_serUDP.h"
744 #if defined(HAS_SERPORT_UDP1)
745 #define SERPORT_UDP1_INIT() serUDP1Init()
746 #define SERPORT_UDP1_TASK() serUDP1Task()
748 #define SERPORT_UDP1_INIT()
749 #define SERPORT_UDP1_TASK()
752 #if defined(HAS_SERPORT_UDP2)
753 #define SERPORT_UDP2_INIT() serUDP2Init()
754 #define SERPORT_UDP2_TASK() serUDP2Task()
756 #define SERPORT_UDP2_INIT()
757 #define SERPORT_UDP2_TASK()
760 #if defined(HAS_SERPORT_UDP3)
761 #define SERPORT_UDP3_INIT() serUDP3Init()
762 #define SERPORT_UDP3_TASK() serUDP3Task()
764 #define SERPORT_UDP3_INIT()
765 #define SERPORT_UDP3_TASK()
768 #if defined(HAS_SERPORT_TCP1) || defined(HAS_SERPORT_TCP2) || defined(HAS_SERPORT_TCP3)
769 #include "nz_serUDP.h"
771 #if defined(HAS_SERPORT_TCP1)
772 #define SERPORT_TCP1_INIT() serTCP1Init()
773 #define SERPORT_TCP1_TASK() serTCP1Task()
775 #define SERPORT_TCP1_INIT()
776 #define SERPORT_TCP1_TASK()
779 #if defined(HAS_SERPORT_TCP2)
780 #define SERPORT_TCP2_INIT() serTCP2Init()
781 #define SERPORT_TCP2_TASK() serTCP2Task()
783 #define SERPORT_TCP2_INIT()
784 #define SERPORT_TCP2_TASK()
787 #if defined(HAS_SERPORT_TCP3)
788 #define SERPORT_TCP3_INIT() serTCP3Init()
789 #define SERPORT_TCP3_TASK() serTCP3Task()
791 #define SERPORT_TCP3_INIT()
792 #define SERPORT_TCP3_TASK()
795 #if defined(HAS_SERPORT_USB)
797 #define SERPORT_USB_INIT() serUSBInit()
798 #define SERPORT_USB_TASK() serUSBTask()
800 #define SERPORT_USB_INIT()
801 #define SERPORT_USB_TASK()
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"
808 #if defined(HAS_SERPORT_USER1)
809 #define SERPORT_USER1_INIT() serUser1Init()
810 #define SERPORT_USER1_TASK() serUser1Task()
812 #define SERPORT_USER1_INIT()
813 #define SERPORT_USER1_TASK()
815 #if defined(HAS_SERPORT_USER2)
816 #define SERPORT_USER2_INIT() serUser2Init()
817 #define SERPORT_USER2_TASK() serUser2Task()
819 #define SERPORT_USER2_INIT()
820 #define SERPORT_USER2_TASK()
822 #if defined(HAS_SERPORT_USER3)
823 #define SERPORT_USER3_INIT() serUser3Init()
824 #define SERPORT_USER3_TASK() serUser3Task()
826 #define SERPORT_USER3_INIT()
827 #define SERPORT_USER3_TASK()
829 #if defined(HAS_SERPORT_USER4)
830 #define SERPORT_USER4_INIT() serUser4Init()
831 #define SERPORT_USER4_TASK() serUser4Task()
833 #define SERPORT_USER4_INIT()
834 #define SERPORT_USER4_TASK()
836 #if defined(HAS_SERPORT_USER5)
837 #define SERPORT_USER5_INIT() serUser5Init()
838 #define SERPORT_USER5_TASK() serUser5Task()
840 #define SERPORT_USER5_INIT()
841 #define SERPORT_USER5_TASK()
843 #if defined(HAS_SERPORT_USER6)
844 #define SERPORT_USER6_INIT() serUser6Init()
845 #define SERPORT_USER6_TASK() serUser6Task()
847 #define SERPORT_USER6_INIT()
848 #define SERPORT_USER6_TASK()
850 #if defined(HAS_SERPORT_USER7)
851 #define SERPORT_USER7_INIT() serUser7Init()
852 #define SERPORT_USER7_TASK() serUser7Task()
854 #define SERPORT_USER7_INIT()
855 #define SERPORT_USER7_TASK()
857 #if defined(HAS_SERPORT_USER8)
858 #define SERPORT_USER8_INIT() serUser8Init()
859 #define SERPORT_USER8_TASK() serUser8Task()
861 #define SERPORT_USER8_INIT()
862 #define SERPORT_USER8_TASK()
871 #if !defined(THIS_IS_NZ_SERDATA_PORTS_C)
882 #define CIRBUF_TX_DEBUG (&serports.debug.cbufTx)
883 #define CIRBUF_RX_DEBUG (&serports.debug.cbufRx)
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)
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)
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)
960 #define getCirbufForSerportID(bufid) ( (bufid&0x01) ? ( &((SERPORT*)(NZ_GLOBALS_SERPORT_FIRST + (bufid/2)))->cbufTx) : ( &((SERPORT*)(NZ_GLOBALS_SERPORT_FIRST + (bufid/2)))->cbufRx) )
963 #define serIsEnabled(pSerport) ( ((pSerport->flags & SERPORT_STAT_ENABLED) != 0) && (pSerport!=NULL) )
966 #endif //#ifndef NZ_SERDATAPORTS_H