/* Output ports Last updated 4.1.01 */ #include "H8.h" #ifndef OutputPorts_H_DEFINED #define OutputPorts_H_DEFINED /* The state of the output ports can be controlled through an 8 bit memory mapped register at address 0xf000. Each port is controlled by 2 bits as follows: Port A bits 7-6 Port B bits 3-2 Port C bits 1-0 The four different values for each 2 bit value controls the port as follows: 00 disconnect port from power supply 01 allows current in one direction 10 allows current in the other direction 11 connect the port to the same polarity of the supply */ #define OutputPorts *(( volatile byte *) 0xf000 ) #define Amask 0xc0 #define Bmask 0x0c #define Cmask 0x03 #define Float 0 #define OnPos 1 #define OnNeg 2 #define Brake 3 void PortA( byte state ) { byte temp; temp = OutputPorts; temp &= ~Amask; temp |= (state << 6); OutputPorts = temp; } void PortB( byte state ) { byte temp; temp = OutputPorts; temp &= ~Bmask; temp |= (state << 2); OutputPorts = temp; } void PortC( byte state ) { byte temp; temp = OutputPorts; temp &= ~Cmask; temp |= (state << 0); OutputPorts = temp; } void OutputPortsFloat( void ) { OutputPorts = 0; } #endif /* OutputPorts_H_DEFINED */