     for (int i = 0; i < write_len; i++) {
         SPI.transfer(value[i]);
     }
-    /* when debug enabled
-    /* return if ADC id was valid */
+    /* when debug enabled */
     if (DEBUG_ENABLED) {
         Serial.println("wrote to ADC register: ");
         for (int i = 0; i < write_len; i++) {

*/
int write_adc_register(byte reg, byte *value, int write_len) {
    /* when specified register is invalid */
    if (reg < 0x00 || reg > 0xFF) {
        if (DEBUG_ENABLED) {
            Serial.println("register out of range");
        }

}

/*
==================================
sets the adc data conversion rate
@param int - speed of conversion
@return int - error code
==================================
*/
int set_adc_data_speed(int speed) {
    byte value[2];
    read_adc_register(FILTCON0_REG, value, 2);
    value[0] &= 0xE0;
    value[0] |= speed >> 7;
    value[1] |= speed;
    write_adc_register(FILTCON0_REG, value, 2);
    return 0;
}

/*
===========================
sets the adc data read mode
@param int - data read mode
@return int - error code
===========================
*/
int set_adc_data_mode(int mode) {
    byte value[2];
    if (mode == CONTINUOUS_READ_MODE) {
        /* set the adc to continuous read mode, the data register can be read directly when DATA_READY */
        set_adc_data_mode(CONTINUOUS_CONVERSION_MODE);
        read_adc_register(IFMODE_REG, value, 2);
        value[1] |= 0x08;
        write_adc_register(IFMODE_REG, value, 2);
    } else if (mode == SINGLE_CONVERSION_MODE) {
        /* set the adc to single conversion mode, the conversion has to be triggered manually */
        read_adc_register(IFMODE_REG, value, 2);
        value[1] &= 0xF7;
        write_adc_register(IFMODE_REG, value, 2);
        read_adc_register(ADCMODE_REG, value, 2);
        value[1] &= 0x8F;
        value[1] |= 0x10;
        write_adc_register(ADCMODE_REG, value, 2);
    } else if (mode == CONTINUOUS_CONVERSION_MODE) {
        /* set the adc to continuous conversion mode, the communication register has to be notified for a read */
        read_adc_register(IFMODE_REG, value, 2);
        value[1] &= 0xF7;
        write_adc_register(IFMODE_REG, value, 2);
        read_adc_register(ADCMODE_REG, value, 2);
        value[1] &= 0x8F;
        value[1] |= 0x00;
        write_adc_register(ADCMODE_REG, value, 2);
    } else {
        /* unknown data read mode */
        return 1;
    }
    return 0;
}

/*
==========================================
reads the ADC conversion result
@return byte[] - the ADC conversion result
==========================================
*/
int read_adc_data(byte *value) {
    if (adc_data_mode == CONTINUOUS_CONVERSION_MODE) {
        /* send communication register id 0x00 */
        SPI.transfer(0x00);
        /* send read command to the data register 0x04 */
        SPI.transfer(0x40 | DATA_REG);
    }
    /* read the received value 24 bits */
    value[0] = SPI.transfer(0x00);
    value[1] = SPI.transfer(0x00);
