unit Neo6502Uext

Neo6502 API library for UExt I/O Functions

author: bocianu bocianu@gmail.com


Set of procedures to cover Neo6502 UExt communication capabilities. More about Neo6502:
https://www.olimex.com/Products/Retro-Computers/Neo6502/open-source-hardware
https://www.neo6502.com/

API documentation can be found here:
https://github.com/paulscottrobson/neo6502-firmware/wiki

It's work in progress, so please report any bugs you will find.

Constants:

name:value:description:
GPIO_PINMODE_INPUT1i/o directions
GPIO_PINMODE_OUTPUT2
GPIO_PINMODE_ANALOGUE3
GPIO_HIGH1GPIO pin value for level HIGH
GPIO_LOW0GPIO pin value for level LOW
UART_PROTOCOL_8N10

Interface:

name:description:
NeoUExtInitialize

procedure NeoUExtInitialize;


Initialize the UExt I/O system. This resets the IO system to its default state, where all UEXT pins are I/O pins, inputs and enabled.
    NeoWriteGPIO

    procedure NeoWriteGPIO(pin,val:byte);


    This copies the value to the output latch for selected pin. This will only display on the output pin if it is enabled, and its direction is set to output.
      parameters:
    • pin (byte) - Neo6502 GPIO pin number (1-10)
    • val (byte) - value (0,1);
    NeoReadGPIO

    function NeoReadGPIO(pin:byte):byte;


    If the pin is set to input, reads the level on pin on UEXT Params[0]. If it is set to output this reads the output latch for UEXT port Params[0].
      parameters:
    • pin (byte) - Neo6502 GPIO pin number (1-10)
    • returns:
    • (byte) - level on pin
    NeoSetDirection

    procedure NeoSetDirection(pin,dir:byte);


    Set the port direction for UEXT Port.
      parameters:
    • pin (byte) - Neo6502 GPIO pin number (1-10)
    • dir (byte) - port direction
    NeoWriteI2C

    procedure NeoWriteI2C(dev,reg,val:byte);


    Write to I2C Device dev, Register reg, value val. Does not fail if device not present.
      parameters:
    • dev (byte) - device address
    • reg (byte) - register
    • val (byte) - value
    NeoReadI2C

    function NeoReadI2C(dev,reg:byte):byte;


    Read from I2C Device dev, Register reg. If the device is not present this will cause an error.
      parameters:
    • dev (byte) - device address
    • reg (byte) - register
    • returns:
    • (byte) - value
    NeoReadAnalog

    function NeoReadAnalog(pin:byte):integer;


    Read the analogue value on specified UEXT Pin. This has to be set to analogue type to work. Returns a value from 0..4095, which represents an input value of 0 to 3.3 volts.
      parameters:
    • pin (byte) - GPIO pin number (1-10)
    • returns:
    • (byte) - value in range 0..4095
    NeoCheckI2C

    function NeoCheckI2C(dev:byte):byte;


    Try to read from specified I2C Device. If tha data is present returns non-zero value.
      parameters:
    • dev (byte) - device address
    • returns:
    • (byte) - non zero value for waiting data
    NeoReadBlockI2C

    procedure NeoReadBlockI2C(dev:byte;addr,len:word);


    Try to read a block of memory from specified I2C Device.
      parameters:
    • dev (byte) - device address
    • addr (word) - target memory address
    • len (word) - data lenght
    NeoWriteBlockI2C

    procedure NeoWriteBlockI2C(dev:byte;addr,len:word);


    Try to write a block from memory to specified I2C Device.
      parameters:
    • dev (byte) - device address
    • addr (word) - source memory address
    • len (word) - data lenght
    NeoReadBlockSPI

    procedure NeoReadBlockSPI(addr,len:word);


    Try to read a block of memory from SPI Device.
      parameters:
    • addr (word) - target memory address
    • len (word) - data lenght
    NeoWriteBlockSPI

    procedure NeoWriteBlockSPI(addr,len:word);


    Try to write a block from memory to SPI Device.
      parameters:
    • addr (word) - source memory address
    • len (word) - data lenght
    NeoReadBlockUART

    procedure NeoReadBlockUART(addr,len:word);


    Try to read a block of memory from the UART.
      parameters:
    • addr (word) - target memory address
    • len (word) - data lenght
    NeoWriteBlockUART

    procedure NeoWriteBlockUART(addr,len:word);


    Try to write a block from memory to the UART.
      parameters:
    • addr (word) - source memory address
    • len (word) - data lenght
    NeoSetupUART

    procedure NeoSetupUART(baudrate:cardinal;protocol:byte);


    Set the Baud Rate and Serial Protocol for the UART interface. Currently only 8N1 is supported (0).
      parameters:
    • baudrate (cardinal) - baud rate
    • protocol (byte) - protocol number
    NeoWriteByteUART

    procedure NeoWriteByteUART(b:byte);


    Try to write a byte to the UART.
      parameters:
    • b (byte) - byte of data
    NeoReadByteUART

    function NeoReadByteUART():byte;


    Try to read a byte from the UART.
      returns:
    • (byte) - byte of data
    NeoCheckUART

    function NeoCheckUART():byte;


    See if a byte is available in the UART input buffer.
      returns:
    • (byte) - non zero if data is available.