Crossware

Table of Contents        Previous topic       Next topic       

The Extension Interface->General Purpose Interface Calls->GetPortPins()

extern "C" void GetPortPins(LONG nExtensionState, BYTE nPortAddress, BYTE* pnPins, BYTE* pnHandledPins, LONG bSimulating, WORD AnalogInputs[8], BYTE* pnHandledAnalogPins)

This is called when the simulator is reading the port at sfr address nPortAddress.  It is called continously after the simulation of each instruction and the simuator will detect any transitions that are required to trigger interrupts.

The extension should set or clear any port pins that it is using as inputs to the microcontroller by writing 1's or 0's into the appropriate bit positions of *pnPins.  It should leave unchanged any bits that it is not using, therefore allowing other extensions to handle these pins.

The simulator needs to know which pins have been set or cleared by the extension and so the appropriate bits of *pnHandledPins should be set to indicate which pins have been set or cleared.

If no extensions handle any of the pins, the simulator will use it's internal methods to simulate a read from this port.

Analog Inputs

If a variant has an integral A/D converter and this is supported by the extension for this variant , then the AnalogInputs array should be used to apply the analog levels to the appropriate port pins.  The WORD array allows levels from 0 to 65535 but of course you can only use the full range for 16 bit A/D converters.  In addition to setting the levels for the appropriate A/D input pins, the corresponding bits of *pnHandledAnalogPins should be set to indicate which AnalogInputs arrays contain valid data.