<commit_before>/*
 * ths1206_control.c
 *
 * Description:
 *
 * (C) 2016 Visaoni
 * Licensed under the MIT License.
 */

// TODO: ensure timing works out with abstractions
// May need to macro and/or switch to precalculated masks

#include "ths1206_control.h"
#include "pin_control.h"
#include "store_readings.h"


static uint8_t trigger_level = 1;


void TC_init_defaults()
{
   TC_write( TC_CSR1_BIT | TC_RESET_BIT );  // Sets reset in CR1
   TC_write( TC_CSR1_BIT );  // Clear reset in CR1
}

void TC_init( uint16_t CSR0, uint16_t CSR1 )
{
   // TODO: In general, should account for multiple channels
   //       Won't use more than one here though
   //       Doesn't follow nice patterns with multiple channels
   //       Up to 4 channels selected with 5 bits
   if(      (CSR1 & TC_TRIG0_BIT) == 0 && (CSR1 & TC_TRIG1_BIT) == 0 )
   {
      trigger_level = 1;
   }
   else if( (CSR1 & TC_TRIG0_BIT) == 1 && (CSR1 & TC_TRIG1_BIT) == 0 )
   {
      trigger_level = 4;
   }
   else if( (CSR1 & TC_TRIG0_BIT) == 0 && (CSR1 & TC_TRIG1_BIT) == 1 )
   {
      trigger_level = 8;
   }
   else if( (CSR1 & TC_TRIG0_BIT) == 1 && (CSR1 & TC_TRIG1_BIT) == 1 )
   {
      trigger_level = 14;<commit_msg>Properly sets trigger level when default initialized<commit_after>/*
 * ths1206_control.c
 *
 * Description:
 *
 * (C) 2016 Visaoni
 * Licensed under the MIT License.
 */

// TODO: ensure timing works out with abstractions
// May need to macro and/or switch to precalculated masks

#include "ths1206_control.h"
#include "pin_control.h"
#include "store_readings.h"


static uint8_t trigger_level = 1;


void TC_init_defaults()
{
   trigger_level = 1;

   TC_write( TC_CSR1_BIT | TC_RESET_BIT );  // Sets reset in CR1
   TC_write( TC_CSR1_BIT );  // Clear reset in CR1
}

void TC_init( uint16_t CSR0, uint16_t CSR1 )
{
   // TODO: In general, should account for multiple channels
   //       Won't use more than one here though
   //       Doesn't follow nice patterns with multiple channels
   //       Up to 4 channels selected with 5 bits
   if(      (CSR1 & TC_TRIG0_BIT) == 0 && (CSR1 & TC_TRIG1_BIT) == 0 )
   {
      trigger_level = 1;
   }
   else if( (CSR1 & TC_TRIG0_BIT) == 1 && (CSR1 & TC_TRIG1_BIT) == 0 )
   {
      trigger_level = 4;
   }
   else if( (CSR1 & TC_TRIG0_BIT) == 0 && (CSR1 & TC_TRIG1_BIT) == 1 )
   {
      trigger_level = 8;
   }
   else if( (CSR1 & TC_TRIG0_BIT) == 1 && (CSR1 & TC_TRIG1_BIT) == 1 )
   {
      trigger_level = 14;
{'fraction_non_alphanumeric': 0.11482084690553745, 'fraction_numerical': 0.04519543973941368, 'mean_word_length': 2.734042553191489, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '517585', 'n_tokens_mistral': 1029, 'n_tokens_neox': 933, 'n_words': 261}