Digi XBee(R) ANSI C Host Library
platform_config.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2012 Digi International Inc.,
3  * All rights not expressly granted are reserved.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
7  * You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
10  * =======================================================================
11  */
12 
23 #ifndef __XBEE_PLATFORM_DOS
24 #define __XBEE_PLATFORM_DOS
25 
26  // macros used to declare a packed structure (no alignment of elements)
27  // The more-flexible XBEE_PACKED() replaced PACKED_STRUCT in 2019.
28  #define PACKED_STRUCT _Packed struct
29  #define XBEE_PACKED(name, decl) PACKED_STRUCT name decl
30 
31  #define _f_memcpy memcpy
32  #define _f_memset memset
33 
34  // stdint.h for int8_t, uint8_t, int16_t, etc. types
35  #ifdef __WATCOMC__
36  #include <stdint.h>
37  #else
38  typedef signed char int8_t;
39  typedef unsigned char uint8_t;
40  typedef short int16_t;
41  typedef unsigned short uint16_t;
42  typedef long int32_t;
43  typedef unsigned long uint32_t;
44 
45  typedef unsigned short uint_fast8_t;
46  typedef signed short int_fast8_t;
47 
48  #define __FUNCTION__ ""
49  #endif
50  // This type isn't in stdint.h
51  typedef int bool_t;
52 
53 
54  // Load platform's endian header to learn whether we're big or little.
55  //#include <endian.h> // Not available on Watcom DOS, so do manually:
56  #define LITTLE_ENDIAN 1234
57  #define BIG_ENDIAN 4321
58 
59  #define BYTE_ORDER LITTLE_ENDIAN
60 
61 // On the DOS platform, some pointers are "far". Many platforms just have
62 // a single pointer type and will define FAR to nothing.
63 // For now, don't need far data, so use small or medium memory model.
64  #define FAR
65 
66  #define INTERRUPT_ENABLE _enable()
67  #define INTERRUPT_DISABLE _disable()
68 
69 // Elements needed to keep track of serial port settings. Must have a
70 // baudrate member, other fields are platform-specific.
71 typedef struct xbee_serial_t {
72  uint32_t baudrate;
73  uint16_t flags;
74  #define XST_INIT_OK 0x0001 // Ser port initialized OK
75  uint16_t comport; // 1 = COM1, 2 = COM2 etc.
76  uint16_t port; // I/O address of UART: COM1 = 0x3F8 etc.
77  void (__interrupt FAR *prev_int)(); // Previous COM port interrupt handler
78  uint16_t intvec; // Interrupt vector number: 0x0C for COM1 etc.
79  uint16_t picmask; // PIC mask bit (corresponding to IRQ): 1<<4 for IRQ4
80  uint8_t lsr_mask; // Mask of line status conditions that are enabled.
81  // These determined by UART hardware...
82  #define XST_MASK_DR 0x01 // Data Ready
83  #define XST_MASK_OE 0x02 // Overrun error
84  #define XST_MASK_PE 0x04 // Parity error
85  #define XST_MASK_FE 0x08 // Frame error
86  #define XST_MASK_BI 0x10 // Break interrupt
87  #define XST_MASK_THRE 0x20 // Tx holding reg empty
88  #define XST_MASK_TEMT 0x40 // Tx shift register empty
89  #define XST_MASK_FIFOE 0x80 // Rx FIFO error
90  struct xbee_cbuf_t * txbuf; // Transmit circular buffer
91  struct xbee_cbuf_t * rxbuf; // Receive circular buffer
92  uint16_t isr_count; // For debug - count UART interrupts
93  uint16_t isr_rent; // For debug - count ISR reentry
94  uint16_t oe; // Overrun error count
95  uint16_t pe; // Parity error count
96  uint16_t fe; // Frame error count
97  uint16_t bi; // Break interrupt count
99 
100 // DOS epoch is 1/1/1970
101 #define ZCL_TIME_EPOCH_DELTA ZCL_TIME_EPOCH_DELTA_1970
102 
103 // our millisecond timer has a ?ms resolution
104 #include <time.h>
105 #define XBEE_MS_TIMER_RESOLUTION (1000 / CLOCKS_PER_SEC)
106 
107 #define WPAN_MAX_CONVERSATIONS 6
108 #define WPAN_CONVERSATION_TIMEOUT 15
109 
110 #include <dos.h>
111 #include <conio.h>
112 #include <stddef.h>
113 
114 // console using ANSI.SYS escape codes
115 void gotoxy_ansi( int col, int row);
116 void clrscr_ansi( void);
117 
118 #ifdef __WATCOMC__
119  // console using BIOS calls
120  void gotoxy00_bios( int col, int row);
121  void getxy_bios( int *col, int *row);
122  void clrscr_bios( void);
123 
124  // gotoxy is commonly 1-based, but BIOS calls in gotoxy00() are 0-based
125  #define gotoxy00(x,y) gotoxy00_bios(x,y)
126  #define gotoxy(x,y) gotoxy00_bios((x)-1, (y)-1)
127  #define getxy(x,y) getxy_bios(x,y)
128  #define clrscr() clrscr_bios()
129 #else
130  // Borland C is 1's based, but we assume 0's based.
131  #define gotoxy00(x,y) gotoxy((x)+1, (y)+1)
132 #endif
133 
134 #endif // __XBEE_PLATFORM_DOS
135 
unsigned long uint32_t
32-bit unsigned integer
Definition: platform_config.h:43
signed char int8_t
8-bit signed integer
Definition: platform_config.h:38
#define FAR
On platforms with "far" pointers, define to the proper keyword; empty definition if not required...
Definition: platform.h:396
Definition: platform_config.h:71
unsigned short uint16_t
16-bit unsigned integer
Definition: platform_config.h:41
unsigned char uint8_t
8-bit unsigned integer
Definition: platform_config.h:39
short int16_t
16-bit signed integer
Definition: platform_config.h:40
long int32_t
32-bit signed integer
Definition: platform_config.h:42
Circular buffer used by transparent serial cluster handler.
Definition: cbuf.h:31
int bool_t
Variable that can hold 0 or 1, may be an int for speed purporses or uint8_t for size optimization...
Definition: platform_config.h:51