| Purpose: | Read the status of a Discrete Input. | |||
| Assumes: | Nothing. | |||
| Passed: | R24 | BYTE | bPortAndPin | single Port and Pin specified in the binary format PPPP0ppp |
| Returns: | R24 | BYTE | bValue | status of the selected Discrete Input: 0 when OFF, 1 when ON |
| Alters: | Only R24 and the FLAGs (SREG) | |||
DiscreteOutput | ||||
| Purpose: | Turn a Discrete Output OFF or ON. | |||
| Assumes: | Nothing. | |||
| Passed: | R24 | BYTE | bPortAndPin | single Port and Pin specified in the binary format PPPP0ppp |
| R22 | BYTE | bValueToSet | value to set; 0 turns the pin OFF; anything else turns it ON | |
| Returns: | R24 | BYTE | bStata | bitmapped status of all the Discrete I/O points on that PORT |
| Alters: | R24, the FLAGs (SREG) and the COM1 Transmit buffer | |||
| Example: |
|
||||
| Test it: |
| ||||
| Notes: | The "PPPP0ppp" means that the high four (4) BITs select the PORT, where PORTB = B0001, PORTC = B0010, PORTD = B0011. The low three (3) BITs select the single PIN to be set or read. B000 selects DIO 0, B001 selects DIO 1, B010 selects DIO 2, etc. | ||||
| The PORT options above are for the 328P microcontroller. Other PORT options are valid for other processors. The last possible valid PORT is PORTL = B1010. | |||||
| The EEbWS2812_DefPandP also has this format bit also uses the BIT unused here to use the next byte (EEbWS2812_DefPins) as a bitmask for multiple Discrete Outputs. | |||||
| Dropin: (setup code) |
; Setup for the DiscreteInput() call: ; Passed: R24 BYTE bPortandPin single PORT and Pin selected: PPPP0ppp format ; Returns: R24 BYTE bValue status if the single Discrete Input: 0 or 1 ; Alters: R24 and the FLAGs ; Setup for the DiscreteOutput() call: ; Passed: R24 BYTE bPortandPin single PORT and Pin selected: PPPP0ppp format ; R22 BYTE bValueToSet 0 turns the DO off, any other turns it ON ; Returns: R24 BYTE bStata status of ALL the Discrete I/O on that PORT ; Alters: R24 and the FLAGs | ||||
| Also see: | The Discrete Output Update command and the ReadAtoDValue System Functions. | ||||