<commit_before>/*
 * adc_teensy3.cpp - Interface to configure ADC speed and capture data for Teensy 3.x boards.
 * Tiny Scope for Arduino project
 *
 * Copyright (C)2015 <NAME>
 *
 * This file may be redistributed under the terms of the MIT license.
 * A copy of this license has been included with this distribution in the file LICENSE.
 *
 */
#ifdef __MK20DX256__
#include "adc.h"

#define ADC_CLOCK_TO_SAMPLING 15

static unsigned int averagingTable[] = {32, 16,  8,  4,  0, 0};
static unsigned int adcBits[]        = {12, 12, 10, 10, 10, 8};

bool ADCInput::init(uint8_t newInput, uint8_t mode)
{
    input = newInput;
    pinMode(input, INPUT);
    return setMode(mode);
}

/*
 * Get the number of
 */
uint8_t ADCInput::getModeCount(){
    return sizeof(averagingTable);
}

/*
 * Configure ADC for given mode.
 */
bool ADCInput::setMode(uint8_t mode=0){
    if (mode < ADCInput::getModeCount()){
        cur_mode = mode;
        bits = adcBits[cur_mode];
        analogReadRes(bits);
        analogReadAveraging(averagingTable[cur_mode]);
        return true;
    } else {
        return false;
    }
}

/*
 * Return ADC clock in Hz. This is only useful to estimate sampling rate.
 */
uint32_t ADCInput::getClock(){
    return F_CPU/8;
}

/*
 * Return ADC sampling rate, if available, otherwise 0
 */
uint32_t ADCInput::getSampleRate(){
    return ADCInput::getClock() / ADC_CLOCK_TO_SAMPLING;
}

#endif /* __MK20DX256__ */
<commit_msg>Fix: reporting more modes than available (averagingTable is not bytes but ints)<commit_after>/*
 * adc_teensy3.cpp - Interface to configure ADC speed and capture data for Teensy 3.x boards.
 * Tiny Scope for Arduino project
 *
 * Copyright (C)2015 <NAME>
 *
 * This file may be redistributed under the terms of the MIT license.
 * A copy of this license has been included with this distribution in the file LICENSE.
 *
 */
#ifdef __MK20DX256__
#include "adc.h"

#define ADC_CLOCK_TO_SAMPLING 15

static unsigned int averagingTable[] = {32, 16,  8,  4,  0, 0};
static unsigned int adcBits[]        = {12, 12, 10, 10, 10, 8};

bool ADCInput::init(uint8_t newInput, uint8_t mode)
{
    input = newInput;
    pinMode(input, INPUT);
    return setMode(mode);
}

/*
 * Get the number of
 */
uint8_t ADCInput::getModeCount(){
    return sizeof(averagingTable)/sizeof(*averagingTable);
}

/*
 * Configure ADC for given mode.
 */
bool ADCInput::setMode(uint8_t mode=0){
    if (mode < ADCInput::getModeCount()){
        cur_mode = mode;
        bits = adcBits[cur_mode];
        analogReadRes(bits);
        analogReadAveraging(averagingTable[cur_mode]);
        return true;
    } else {
        return false;
    }
}

/*
 * Return ADC clock in Hz. This is only useful to estimate sampling rate.
 */
uint32_t ADCInput::getClock(){
    return F_CPU/8;
}

/*
 * Return ADC sampling rate, if available, otherwise 0
 */
uint32_t ADCInput::getSampleRate(){
    return ADCInput::getClock() / ADC_CLOCK_TO_SAMPLING;
}

#endif /* __MK20DX256__ */

{'fraction_non_alphanumeric': 0.11137281292059219, 'fraction_numerical': 0.03230148048452221, 'mean_word_length': 3.3914327917282128, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5766204', 'n_tokens_mistral': 1088, 'n_tokens_neox': 984, 'n_words': 309}