typedef unsigned char cfg_u8;
typedef union {
    struct {
        cfg_u8 offset;
        cfg_u8 value;
    };
    struct {
        cfg_u8 command;
        cfg_u8 param;
    };
} cfg_reg;

#define CFG_META_SWITCH (255)
#define CFG_META_DELAY  (254)
#define CFG_META_BURST  (253)

/* Example C code */
/*
    // Externally implemented function that can write n-bytes to the device
    // Refer to the device data sheet for more information.
    extern int i2c_write(unsigned char *data, int n);
    // Externally implemented function that delays execution by n milliseconds
    extern int delay(int n);
    // Example implementation.  Call like:
    //     transmit_registers(registers, sizeof(registers)/sizeof(registers[0]));
    void transmit_registers(cfg_reg *r, int n)
    {
        int i = 0;
        while (i < n) {
            switch (r[i].command) {
            case CFG_META_SWITCH:
                // Used in legacy applications.  Ignored here.
                break;
            case CFG_META_DELAY:
                delay(r[i].param);
                break;
            case CFG_META_BURST:
                i2c_write((unsigned char *)&r[i+1], r[i].param);
                i +=  (r[i].param / 2) + 1;
                break;
            default:
                i2c_write((unsigned char *)&r[i], 2);
                break;
            }
            i++;
        }
    }
 */

cfg_reg registers[] = {
#define CHECKSUM (0)
// -----------------------------------------------------------------------------
// Reset
// -----------------------------------------------------------------------------
// Select Page 0
    { 0x00, 0x00 },
// Reset Device
    { 0x01, 0x01 },
// 1mS Delay
// -----------------------------------------------------------------------------
// Begin Device Memory
// -----------------------------------------------------------------------------
// Page 0 (0x00) Dump
// Select Page 0
    { 0x00, 0x00 },
    { 0x02, 0x81 },
// 2s Delay After Disabling Sleep
    { 0x07, 0x00 },
// ASI Configuration
    { 0x13, 0x87 },
    { 0x14, 0x46 },
// Micbias Configuration
    { 0x3b, 0xf0 },
// CH1 CFG, Gain, Volume, Gain cal, phase cal
    { 0x3c, 0x00 },
// CH2 CFG, Gain, Volume, Gain cal, phase cal
    { 0x41, 0x00 },
// CH3 CFG, Gain, Volume, Gain cal, phase cal
    { 0x46, 0x00 },
// CH4 CFG, Gain, Volume, Gain cal, phase cal
    { 0x4b, 0x00 },
// Input Channel Enable
    { 0x74, 0xfc },
// Power up/down
// Select page 0
    { 0x00, 0x00 },
    { 0x75, 0x80 },

};

