//#DOC Main, program entry and main loop
#include "main.h"
#include <otFPGA.h>
#include <otI2cBus.h>
#include <otPCA9505.h>

otPCA9505   port;

void setup()
{
    FpgaInit();
    FpgaHiddenPort(HP_EXT_I2C, true);
    
    I2cBusReset();
    I2cBusFrequency(400, 30);
    
    port.init();    // Default address is 0x20
    //port.setPortDir(0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
    port.setPortDir(otPCA9505::PORT_A, 0xFF);
}

void loop()
{
    while(1)
    {
        port.writePort(otPCA9505::PORT_A, 0x00);
        port.writePort(otPCA9505::PORT_A, 0xFF);
        // Single bit (0) at time, more slow
        //port.setBit(otPCA9505::PORT_A, 0, true);
        //port.setBit(otPCA9505::PORT_A, 0, false);
    }
}