<commit_before>/*
 * Copyright (C) <NAME>. All rights reserved
 *
 * This file is part of EthShield, distributed under the MIT license.
 */

#include "debug.h"

// Do we want debug?
#ifdef UTILS_DEBUG

void debug_init(void) {
    // Get default uart config
    uart_config_t config;
    uart_set_default_config(&config);
    
    // Enable double speed
    config.doublespeed = 1;
    // Disable receive
    config.enable_rx = 0;
    
    // Initialize uart with config
    uart_init(&config);
    
    // Wait a little and send debug message
    _delay_ms(100);
    debug_string_p(PSTR("\r\nUART debug started"));
}

void debug_string(char *string) {
    uart_send_string(string);
}

void debug_string_p(const char *pstring) {
    uart_send_string_p(pstring);
}

void debug_number_(uint16_t value, uint8_t base) {
    // Create buffer
    char buffer[8*sizeof(uint16_t)+1];
    char *str = &buffer[sizeof(buffer)-1];
    // Set ending \0
    *str = '\0';
    uint16_t tmp;
    uint8_t c;
    
    // Make sure we have a base larger than 1
    if (base < 2)
        base = 10;
    
    // Iterate over value
    do {
        // Set temp value
        tmp = value;
        // Calc divider
        value /= base;
        // Get digit
        c = tmp - base * value;
        *--str = c < 10 ? '0' + c : 'A' + c - 10;
    } while (value);
    
    // Send string
    uart_send_array(str);
}

void debug_number(uint16_t value) {
    debug_number_(value, 10);
}

void debug_number_as_hex(uint16_t value) {
    debug_number_(value, 16);
}

void debug_array(uint8_t *data, uint16_t length, char glue) {
    while (length--) {
        uart_send(*data++);
        uart_send(glue);
    }
}<commit_msg>Updated call to match uart header<commit_after>/*
 * Copyright (C) <NAME>. All rights reserved
 *
 * This file is part of EthShield, distributed under the MIT license.
 */

#include "debug.h"

// Do we want debug?
#ifdef UTILS_DEBUG

void debug_init(void) {
    // Get default uart config
    uart_config_t config;
    uart_set_default_config(&config);
    
    // Enable double speed
    config.doublespeed = 1;
    // Disable receive
    config.enable_rx = 0;
    
    // Initialize uart with config
    uart_init(&config);
    
    // Wait a little and send debug message
    _delay_ms(100);
    debug_string_p(PSTR("\r\nUART debug started"));
}

void debug_string(char *string) {
    uart_send_string(string);
}

void debug_string_p(const char *pstring) {
    uart_send_string_p(pstring);
}

void debug_number_(uint16_t value, uint8_t base) {
    // Create buffer
    char buffer[8*sizeof(uint16_t)+1];
    char *str = &buffer[sizeof(buffer)-1];
    // Set ending \0
    *str = '\0';
    uint16_t tmp;
    uint8_t c;
    
    // Make sure we have a base larger than 1
    if (base < 2)
        base = 10;
    
    // Iterate over value
    do {
        // Set temp value
        tmp = value;
        // Calc divider
        value /= base;
        // Get digit
        c = tmp - base * value;
        *--str = c < 10 ? '0' + c : 'A' + c - 10;
    } while (value);
    
    // Send string
    uart_send_string(str);
}

void debug_number(uint16_t value) {
    debug_number_(value, 10);
}

void debug_number_as_hex(uint16_t value) {
    debug_number_(value, 16);
}

void debug_array(uint8_t *data, uint16_t length, char glue) {
    while (length--) {
        uart_send(*data++);
        uart_send(glue);
    }
}
{'fraction_non_alphanumeric': 0.11937665392531609, 'fraction_numerical': 0.0223463687150838, 'mean_word_length': 2.328767123287671, 'pattern_counts': {'":': 0, '<': 9, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6465706', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1175, 'n_words': 319}