The Internet Power Line Adapter - University of Queensland
The Internet Power Line Adapter - University of Queensland
The Internet Power Line Adapter - University of Queensland
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Home Automation, <strong>Power</strong> <strong>Line</strong>s and the <strong>Internet</strong> Quenten Alick<br />
}<br />
}<br />
if(UseWTI) {<br />
TransmitPacket(USE_WTI);<br />
} else {<br />
TransmitPacket(0);<br />
}<br />
}<br />
void ReadCommand( uint8 command,<br />
near uint8* rawData, /* O: page 1 data from NIC */<br />
uint8* length ) /* O: length <strong>of</strong> data from NIC */<br />
{<br />
StartErrorTimer();<br />
while((ISRstate!=ISR_IDLE) &&<br />
(ISRstate!=ISR_ATTN)) {<br />
TestErrorTimer(); /* test error timer and restart if<br />
expired */<br />
}<br />
NIC_CS = LOW;<br />
ISRstate = ISR_RCV_LEN;<br />
transBfr.buf = rawData;<br />
transBfr.index = 0; /* initialize index */<br />
WriteToSPI(command);<br />
StartErrorTimer();<br />
while(ISRstate != ISR_IDLE) {<br />
TestErrorTimer();<br />
}<br />
*length = transBfr.len;<br />
NIC_CS = HIGH;<br />
}<br />
void riteCommand( uint8 command,<br />
near uint8* rawData, /* I: page 1 data to NIC */<br />
uint8 length ) /* I: length <strong>of</strong> data to NIC */<br />
{<br />
StartErrorTimer();<br />
while((ISRstate!=ISR_IDLE) &&<br />
(ISRstate!=ISR_ATTN)) {<br />
TestErrorTimer();<br />
}<br />
NIC_CS = LOW;<br />
ISRstate = ISR_XMIT_LEN;<br />
transBfr.buf = rawData;<br />
transBfr.len = length;<br />
transBfr.index = 0;<br />
WriteToSPI(command);<br />
StartErrorTimer();<br />
while(ISRstate != ISR_IDLE) {<br />
- 60 -<br />
TestErrorTimer(); /* test error timer and restart<br />
if expired */<br />
}<br />
NIC_CS = HIGH;<br />
}<br />
/*<br />
* Original Author: Stan JK<br />
*<br />
* Modified by: Tony Truong<br />
*<br />
* File: stamdard.h<br />
*/<br />
typedef unsigned char uint8;<br />
typedef struct<br />
{<br />
uint8 LSB;<br />
uint8 MSB;<br />
} uint16;<br />
typedef struct /* allows 8 boolean flags to coexist in<br />
single uint8 */<br />
{<br />
uint8 b0 : 1;<br />
uint8 b1 : 1;<br />
uint8 b2 : 1;<br />
uint8 b3 : 1;<br />
uint8 b4 : 1;<br />
uint8 b5 : 1;<br />
uint8 b6 : 1;<br />
uint8 b7 : 1;<br />
} booleans;<br />
typedef uint8 boolean;<br />
#define FALSE 0<br />
#define TRUE 1<br />
#define INVALID 0<br />
#define VALID 1<br />
#define OFF 0<br />
#define ON 1<br />
#define LOW 0<br />
#define HIGH 1<br />
#define NULL 0<br />
#define DisableInterrupts() _asm("\tsei\n")<br />
#define EnableInterrupts() _asm("\tcli\n")<br />
#define ResetStackPtr() _asm("\trsp\n")