basics.h
Go to the documentation of this file.
1 #ifndef BASICS_H_INCLUDED
2 #define BASICS_H_INCLUDED
3 
4 /*
5  Authors:
6  Hugo Elias
7  Moritz "Morty" Struebe (morty@gmx.net)
8 
9  (c) Shadow Robot Company 2007
10  This code is licensed under the GPL.
11 
12 */
13 
14 #ifdef S_SPLINT_S
15  #define rom
16  #define overlay
17  #define near
18  #define __wparam
19 #else
20  #ifdef SDCC
21  #define rom __code
22  #define overlay
23  #define near
24  #else
25  #define __wparam
26  #endif
27 #endif
28 
29 /* Data type abbreviations*/
30 
31 #ifdef SDCC
32  #define int8u unsigned char
33  #define int8s signed char
34 
35  #define int16u unsigned int
36  #define int16s signed int
37 
38  #define int24u unsigned long
39  #define int24s signed long
40 
41  #define int32u unsigned long
42  #define int32s signed long
43 #else
44  #define int8u unsigned char
45  #define int8s signed char
46 
47  #define int16u unsigned short
48  #define int16s signed short
49 
50  #define int24u unsigned short long
51  #define int24s signed short long
52 
53  #define int32u unsigned long
54  #define int32s signed long
55 #endif
56 
57 
58 // Long long / 64 bit is not supported by C16 - C30 does, though.
59 // #define int64u unsigned long long
60 // #define int64s signed long long
61 
62 typedef struct int64
63 {
66 } int64u;
67 
68 
69 //#include "this_node.h"
70 
71 typedef union union16
72 {
74  int8u byte[2];
75 } union16_t;
76 
77 typedef union union32
78 {
80  int16u word[2];
81  int8u byte[4];
82 } union32_t;
83 
84 typedef union union64
85 {
86  int32u dword[2];
87  int16u word[4];
88  int8u byte[8];
89 } union64_t;
90 
91 
92 // WARNING: Only works with overlay or global values. NOT VALUES ON THE STACK!
93 #ifdef SDCC
94  #define shift_right_signed_32(x) x >>= 1;
95 #else
96  #define shift_right_signed_32(x) x >>= 1; \
97  _asm \
98  btfsc x+3, 6, 1 \
99  bsf x+3, 7, 1 \
100  _endasm
101 #endif
102 
103 #ifdef SDCC
104  #define shift_right_signed_16(x) x >>= 1;
105 #else
106  #define shift_right_signed_16(x) x >>= 1; \
107  _asm \
108  btfsc x+1, 6, 1 \
109  bsf x+1, 7, 1 \
110  _endasm
111 #endif
112 
113 void ShiftLeft64(union union64 *p);
114 
115 void Reset_func(void);
116 void ClrWdt_func(void);
117 
118 extern const int8u basic_lshift[];
119 
120 /* The @sef tells splint these parameters must be side-effect free, because they may be invoked more
121 * than once */
122 
123 /*@notfunction@*/
124 #define abs(x ) ((x) > 0 ? (x) : -(x))
125 /*@notfunction@*/
126 #define abslimit(val, lim) { \
127  if ((val) > (lim)) (val) = (lim); \
128  else if ((val) < -(lim)) (val) = -(lim); \
129  }
130 
131 /*@notfunction@*/
132 #define rshift_sgn(val, shift) (((val) > 0) ? ((val) >> (shift)) : -((-(val))>>(shift)))
133 
134 
135 #ifdef SDCC
136  /* These defines map from non-SDCC bit variables to SDCC bit variables. */
137  #define RXM0SIDL_EXIDEN RXM0SIDLbits.EXIDEN
138  #define RXM1SIDL_EXIDEN RXM1SIDLbits.EXIDEN
139  #define ECANCON_MDSEL1 ECANCONbits.MDSEL1
140  #define ECANCON_MDSEL0 ECANCONbits.MDSEL0
141  #define COMSTAT_FIFOEMPTY COMSTATbits.FIFOEMPTY
142  #define PIR3_RXBnIF PIR3bits.RXBnIF
143  #define COMSTAT_RXBnOVFL COMSTATbits.RXBnOVFL
144  #define PIR3_IRXIF PIR3bits.IRXIF
145 
146  #define TXB0CON_TXREQ TXB0CONbits.TXREQ
147  #define TXB1CON_TXREQ TXB1CONbits.TXREQ
148  #define TXB2CON_TXREQ TXB2CONbits.TXREQ
149  #define BSEL0_B0TXEN BSEL0bits.B0TXEN
150  #define B0CON_TXREQ B0CONbits.TXREQ
151 
152  #define BSEL0_B1TXEN BSEL0bits.B1TXEN
153  #define B1CON_TXREQ B1CONbits.TXREQ
154  #define BSEL0_B2TXEN BSEL0bits.B2TXEN
155  #define B2CON_TXREQ B2CONbits.TXREQ
156  #define BSEL0_B3TXEN BSEL0bits.B3TXEN
157  #define B3CON_TXREQ B3CONbits.TXREQ
158  #define BSEL0_B4TXEN BSEL0bits.B4TXEN
159  #define B4CON_TXREQ B4CONbits.TXREQ
160  #define BSEL0_B5TXEN BSEL0bits.B5TXEN
161  #define B5CON_TXREQ B5CONbits.TXREQ
162  #define RXB0CON_RXFUL RXB0CONbits.RXFUL
163  #define PIR3_RXB0IF PIR3bits.RXB0IF
164  #define COMSTAT_RXB0OVFL COMSTATbits.RXB0OVFL
165 
166  #define RXB0CON_FILHIT0 RXB0CONbits.FILHIT0
167  #define RXB1CON_RXFUL RXB1CONbits.RXFUL
168  #define PIR3_RXB1IF PIR3bits.RXB1IF
169  #define COMSTAT_RXB1OVFL COMSTATbits.RXB1OVFL
170 
171  #define RXFCON0_RXF0EN RXFCON0bits.RXF0EN
172  #define RXFCON0_RXF1EN RXFCON0bits.RXF1EN
173  #define RXFCON0_RXF2EN RXFCON0bits.RXF2EN
174  #define RXFCON0_RXF3EN RXFCON0bits.RXF3EN
175  #define B0CON_RXFUL B0CONbits.RXFUL
176  #define B1CON_RXFUL B1CONbits.RXFUL
177  #define B2CON_RXFUL B2CONbits.RXFUL
178  #define B3CON_RXFUL B3CONbits.RXFUL
179  #define B4CON_RXFUL B4CONbits.RXFUL
180  #define B5CON_RXFUL B5CONbits.RXFUL
181 
182 
183 
184  #define _asm __asm
185  #define _endasm __endasm
186 
187  /* Can't copy aggregates! */
188  #define msg_copy(dest, src) { dest.messageID=src.messageID; dest.d.dword[0]=src.d.dword[0]; dest.d.dword[1]=src.d.dword[1]; dest.length=src.length; dest.flags=src.flags; }
189 #else /* !SDCC */
190  #define msg_copy(dest, src) dest=src
191 #endif /* SDCC */
192 
193 
194 /* Delays code */
195 #ifdef SDCC
196  #include <delay.h>
197  #define Delay1TCY Nop
198  #define Delay10TCYx delay10tcy
199  #define Delay100TCYx delay100tcy
200  #define Delay10KTCYx delay10ktcy;
201  #define Delay1KTCYx delay1ktcy;
202 #else /* !SDCC */
203  #ifdef GCC
204  #define Delay1TCY
205  #define Delay10TCYx(x)
206  #define Delay100TCYx(x)
207  #define Delay10KTCYx(x)
208  #define Delay1KTCYx(x)
209  #define delay1mtcy(x)
210  #define CARRY_BIT 0
211  #else /* !GCC */
212  #include <delays.h>
213  #define delay1mtcy(x) { int8u d; for (d=0;d<100; d++) Delay10KTCYx(d); }
214  #define CARRY_BIT 0
215  #endif /* GCC */
216 #endif /* SDCC */
217 
218 
219 
220 #endif
unsigned short int16u
int32u high
Definition: basics.h:65
const int8u basic_lshift[]
int16u word
Definition: basics.h:73
void ShiftLeft64(union union64 *p)
Definition: basics.h:71
struct int64 int64u
void Reset_func(void)
Use this instead of Reset to keep optimization.
unsigned int int32u
union union32 union32_t
Definition: basics.h:77
int32u dword
Definition: basics.h:79
unsigned char int8u
Definition: basics.h:62
int32u low
Definition: basics.h:64
Definition: basics.h:84
union union16 union16_t
void ClrWdt_func(void)
Clear Watchdog Timer.
union union64 union64_t


sr_external_dependencies
Author(s): Ugo Cupcic
autogenerated on Fri Jan 1 2021 03:23:17