DIR -- for backward compatibility, use INPUT, OUTPUT
 
Syntax

DIR ( expression )
Description


The DIR keyword is for compatibility with PBASIC, and to support multiple ports on newer ARM devices, the INPUT and OUTPUT keywords should be used instead.

DIR (expression) can be used to set or read the direction of the 16 configurable pins.  If DIR (expression) is 1 then the corresponding pin is an output.  If the value is 0 then that pin is an input.

The ARMmite allows control of 24 pins (0..23), with pins 16..23 shared with the AD pins. On reset or power up the AD pins are configured as AD inputs.  To change those to digital IOs, the user must individually specify a control direction using INPUT x, OUTPUT x, DIR(x),  or IO(x) commands.  After that they will remain digital IOs until the next reset or power up.

For the ARMmite, ARMmite PRO, ARMexpress and ARMexpress LITE these pin numbers correspond to the pin numbers shown in the Hardware Section. The numbering was assigned by physical location on the board.  So DIR, HIGH, IN, INPUT, IO, LOW, OUT and OUTPUT use these physical pin assignments. But P0(pin) will use the bit assigned by NXP.   Going forward new board designs will maintain the bit assignment from NXP for all keywords.

For the ARMweb, DINkit, SuperPRO, PROplus and PROstart these pin numbers correspond only to the Port 0 assigned by NXP, for instance DIR 3 corresponds to P0.3

For port pins after Port 0, use the P1 .. P4 commands, and a #define FIOxDIR to access the direction register

Example

' Set pin 4 as an input
DIR(4) = 0

' Set pin 12 as an output
DIR(12) = 1

To extend these to ports for the SuperPRO DIR BASIC style use the followimg macros

#include <LPC17xx.bas>   

#define wrDIR0(pin,output)   if (output) FIO0DIR = FIO0DIR or (1 << pin) else  FIO0DIR = FIO0DIR and not(1 << pin)
#define wrDIR1(pin,output)   if (output) FIO1DIR = FIO1DIR or (1 << pin) else  FIO1DIR = FIO1DIR and not(1 << pin)
#define wrDIR2(pin,output)   if (output) FIO2DIR = FIO2DIR or (1 << pin) else  FIO2DIR = FIO2DIR and not(1 << pin)
#define wrDIR4(pin,output)   if (output) FIO4DIR = FIO4DIR or (1 << pin) else  FIO4DIR = FIO4DIR and not(1 << pin)

wrDIR2(10,1)

while 1
  x=x+1
  P2(10) = x and 1           ' blinky for the SuperPRO and PROplus
  wait(500)
loop

Differences from other BASICs

See also