31 #include <pic18fregs.h>
32 #include <boardconfig.h>
56 void eeWriteByte(
unsigned char address,
unsigned char value);
58 unsigned char eeReadByte(
unsigned char address);
61 #define CALL_FUN(x,a) x(a)
62 #define CALL_FUN2(x,a,b) x(a,b)
63 #define CALL_FUN3(x,a,b,c) x(a,b,c)
64 #define CALL_FUN4(x,a,c,d) x(a,b,c,d)
69 #define KPORT(k) k##PORT
70 #define KBIT(k) k##BIT
75 #define DIGITALREAD_(connport,connbit) (PORT##connport##bits.R##connport##connbit)
77 #define DIGITALWRITE_(connport,connbit,val) do{ \
78 if((val) != 0) LAT##connport##bits.LAT##connport##connbit = 1; \
79 else LAT##connport##bits.LAT##connport##connbit = 0; \
81 #define DIGITALCLEAR_(connport,connbit) do{ LAT##connport##bits.LAT##connport##connbit = 0; }while(0)
82 #define DIGITALSET_(connport,connbit) do{ LAT##connport##bits.LAT##connport##connbit = 1; }while(0)
84 #define PIN_MODE_DIGITAL_IN_(connport,connbit) do{\
85 TRIS##connport##bits.TRIS##connport##connbit=1;\
86 bitclr(*(__data unsigned char*)((int)&PORT##connport + (int)&ANSELA-(int)&PORTA),connbit);\
88 #define PIN_MODE_ANALOGIN_(connport,connbit) do{\
89 TRIS##connport##bits.TRIS##connport##connbit=1;\
90 bitset(*(__data unsigned char*)((int)&PORT##connport + (int)&ANSELA-(int)&PORTA),connbit);\
92 #define PIN_MODE_DIGITAL_OUT_(connport,connbit) do{\
93 TRIS##connport##bits.TRIS##connport##connbit=0;\
105 #define digitalRead(conn) CALL_FUN2(DIGITALREAD_,KPORT(conn),KBIT(conn))
112 #define digitalWrite(conn,val) CALL_FUN3(DIGITALWRITE_,KPORT(conn),KBIT(conn),val)
118 #define digitalClear(conn) CALL_FUN2(DIGITALCLEAR_,KPORT(conn),KBIT(conn))
124 #define digitalSet(conn) CALL_FUN2(DIGITALSET_,KPORT(conn),KBIT(conn))
129 #define pinModeDigitalIn(conn) CALL_FUN2(PIN_MODE_DIGITAL_IN_,KPORT(conn),KBIT(conn))
134 #define pinModeAnalogIn(conn) CALL_FUN2(PIN_MODE_ANALOGIN_,KPORT(conn),KBIT(conn))
139 #define pinModeDigitalOut(conn) CALL_FUN2(PIN_MODE_DIGITAL_OUT_,KPORT(conn),KBIT(conn))
141 #define setPinAnsel(conn,val) CALL_FUN3(SET_PIN_ANSEL_,KPORT(conn),KBIT(conn),(val)!=0)*/
146 #define BIT_COPY(dest,src) do{ if((src)!=0) dest = 1 ; else dest = 0 ; } while(0)
148 #define bitset(var,bitno) ((var) |= (1 << (bitno)))
149 #define bitclr(var,bitno) ((var) &= ~(1 << (bitno)))
150 #define bittst(var,bitno) (unsigned char)((var & (1 << (bitno)))!=0)
154 #define abs(x) ((x)<0?-(x):(x))
158 extern volatile DWORD Now;
159 #define elapsed(since) ((time()-(unsigned long)(since))&0x7FFFFFFF) // in time cycles
160 #define microToTime(T) (((unsigned long)T*(FOSC/64000UL))/1000) //microseconds to time cycles
161 #define timeToMicro(T) (((unsigned long)T*(FOSC/64000UL))/1000) //time cycles to microseconds
165 unsigned unsigned long int time(
void);
167 #define timeISR() (Now._dword)
175 #define delayStart(delay, micros) delay = time() + microToTime(micros)
180 #define delayFinished(delay) (elapsed(delay) < 0x3FFFFFFF)
255 #define _PORTZ_ADDR 0x0480
256 #define _PORT_TO_LAT 0x09
257 #define _PORT_TO_TRIS 0x12
258 #define _PORT_TO_ANSEL (-0x48)
260 extern __at(_PORTZ_ADDR) volatile
unsigned char PORTZ;
263 extern __at(_PORTZ_ADDR + _PORT_TO_LAT) volatile
unsigned char LATZ;
264 extern __at(_PORTZ_ADDR + _PORT_TO_LAT) volatile
__LATZbits_t LATZbits;
266 extern __at(_PORTZ_ADDR + _PORT_TO_TRIS) volatile
unsigned char TRICZ;
267 extern __at(_PORTZ_ADDR + _PORT_TO_TRIS) volatile
__TRISZbits_t TRISZbits;
269 extern __at(_PORTZ_ADDR + _PORT_TO_ANSEL) volatile
unsigned char ANSELZ;
270 extern __at(_PORTZ_ADDR + _PORT_TO_ANSEL) volatile
__ANSELZbits_t ANSELZbits;
274 #define KZ0PORT Z // PORTZ0 & LATZ0 are initialized to 0
277 #define KZ1PORT Z // PORTZ1 & LATZ1 are initialized to 1
unsigned unsigned long int time(void)
Get time since bootup in 64/FOSC steps (1us @ 64MHz, 8us @ 8MHz).
Definition: core.c:151
unsigned char eeReadByte(unsigned char address)
Write to eeprom.
Definition: core.c:59
void highInterrupts()
User defined high priority interrupt routine.
void coreInit()
Init core module.
Definition: core.c:75
void lowInterrupts()
User defined low priority interrupt routine.
void eeWriteByte(unsigned char address, unsigned char value)
Write to eeprom.
Definition: core.c:36
Definition: typedefs.h:90
unsigned long t_delay
Delay type.
Definition: core.h:170