     /* enable or disable this channel */
     value[0] |= (status << 7);
     /* set the correct analog inputs */
-    byte ain = (channel & 0x0F);
+    byte ain = ((channel & 0x0F) << 2);
     value[1] = (ain << 5) | (ain + 1);
     /* update specified channel configuration */
     write_adc_register(channel, value, 2);
+    /* return error code */
+    return 0;
 }
 
 /*

#define SETUPCON7_REG 0x27

/* ADC values */
#define HZ_1 0x16
#define HZ_10 0x13
#define KHZ_1 0x0A
#define KHZ_2 0x09
#define KHZ_5 0x08
#define KHZ_10 0x07
#define KHZ_15 0x06
#define KHZ_31 0x00
#define HZ_500 0x0B
#define DEBUG_ENABLED true
#define CONTINUOUS_READ_MODE 0
#define SINGLE_CONVERSION_MODE 1
#define CONTINUOUS_CONVERSION_MODE 2
#define DATA_READY digitalRead(MISO) == LOW

int adc_data_mode = CONTINUOUS_CONVERSION_MODE;

/*

    /* initiate ADC */
    init_adc();
    /* set ADC configuration */
    /* enable ch0 and ch1 */
    enable_adc_channel(CH0_REG, true);
    enable_adc_channel(CH1_REG, true);
    /* set the adc data mode */
    set_adc_data_mode(CONTINUOUS_READ_MODE);
    /* set the adc samplingrate to 1007 Hz*/
    set_adc_data_speed(SPS_1007);
    /* wait for ADC */
    delay(100);
}

void loop() {
    byte data[3];
    /* when ADC conversion is finished */
    if (DATA_READY) {
        /* read ADC conversion result */
        read_adc_data(data);
        Serial.write(data[0]);
        Serial.write(data[1]);
        Serial.write(data[2]);
    }
}