package stamp.core; public class PROP extends CPU { /** * A constant representing pin P16. */ public final static int pin16 = (1<<0)+512; //stampSOUT serial out (pin 1 of spin stamp) /** * A constant representing pin P17. */ public final static int pin17 = (1<<1)+512; //stampSIN serial in (pin 2 of spin stamp) /** * A constant representing pin P18. */ public final static int pin18 = (1<<2)+512; //stampATN digital in (pin 3 of spin stamp) /** * A constant representing pin P19. */ public final static int pin19 = (1<<3)+512; /** * A constant representing pin P20. */ public final static int pin20 = (1<<4)+512; /** * A constant representing pin P21. */ public final static int pin21 = (1<<5)+512; /** * A constant representing pin P22. */ public final static int pin22 = (1<<6)+512; /** * A constant representing pin P23. */ public final static int pin23 = (1<<7)+512; /** * A constant representing pin P24. */ public final static int pin24 = (1<<0)+768; /** * A constant representing pin P25. */ public final static int pin25 = (1<<1)+768; /** * A constant representing pin P26. */ public final static int pin26 = (1<<2)+768; /** * A constant representing pin P27. */ public final static int pin27 = (1<<3)+768; /** * A constant representing pin P28. */ public final static int pin28 = (1<<4)+768; //propSCL external eeprom SCL /** * A constant representing pin P29. */ public final static int pin29 = (1<<5)+768; //propSDA external eeprom SDA /** * A constant representing pin P30. */ public final static int pin30 = (1<<6)+768; //propTX programming output /** * A constant representing pin P31. */ public final static int pin31 = (1<<7)+768; //propRX programming input /** * An array representing all of the pins on the module. The nth element of the * array refers to the nth pin. i.e. PROP.pins[5] == PROP.pin5 */ public static int pins[] = {PROP.pin0, PROP.pin1, PROP.pin2, PROP.pin3, PROP.pin4, PROP.pin5, PROP.pin6, PROP.pin7, PROP.pin8, PROP.pin9, PROP.pin10,PROP.pin11, PROP.pin12,PROP.pin13,PROP.pin14,PROP.pin15, PROP.pin16,PROP.pin17,PROP.pin18,PROP.pin19, PROP.pin20,PROP.pin21,PROP.pin22,PROP.pin23, PROP.pin24,PROP.pin25,PROP.pin26,PROP.pin27, PROP.pin28,PROP.pin29,PROP.pin30,PROP.pin31}; /** * A constant representing the first I/O port on the Propeller. This port * contains pins 16-23. */ public final static int PORTC = 0x02FF; /** * A constant representing the second I/O port on the Propeller. This port * contains pins 24-31. */ public final static int PORTD = 0x03FF; /** * Output a value onto a port. * The lower 8 bits of value will be written to the port. Pins on the port * will not be converted to outputs first. This method does not * affect the direction of the port. *
* This method will disturb any virtual peripherals which are using the port. * * @param port the port to control. Can be either CPU.PORTA, CPU.PORTB, PROP.PORTC and PROP,PORTD. * @param value the value to write to the port. */ public static void writePort(int port, byte value) { if (port == PORTA) CPU.writeRegister(0x06, value); else if ( port == PORTB ) CPU.writeRegister(0x07, value); else if ( port == PORTC ) CPU.writeRegister(0x08, value); else if ( port == PORTD ) CPU.writeRegister(0x09, value); } /** * Read the value on a port. * Read the value currently on a port. * * @param port the port to read. Can be either CPU.PORTA, or CPU.PORTB. * @return the value on the port. */ public static byte readPort(int port) { if (port == PORTA) return (byte) CPU.readRegister(0x06); else if (port == PORTB) return (byte) CPU.readRegister(0x07); else if (port == PORTC) return (byte) CPU.readRegister(0x08); else if (port == PORTD) return (byte) CPU.readRegister(0x09); else return 0; } }