<commit_before>/**
 * This Source Code Form is subject to the terms of the
 * Mozilla Public License, v. 2.0.  If a copy of the MPL
 * was not distributed with this file, you can obtain one at
 * https://mozilla.org/MPL/2.0/.
 *
 * Copyright <NAME>, 2015
 *
 * This is used to setup the UART device on an AVR unit.
 */

#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <avr/io.h>
#include <util/setbaud.h>

#ifndef BAUD
#  define BAUD 9600
#  warning BAUD rate not set.  Setting BAUD rate to 9600.
#endif // BAUD

// #define BAUDRATE ((F_CPU)/(BAUD*16UL)-1)

typedef enum {
  UM_Asynchronous,
  UM_Synchronous,
  UM_MasterSPI,
} UARTMode;

/**
 * @brief Enables the UART device for 8-bit data at
 * the specified {@see BAUDRATE}.
 */
static inline void uart_enable(UARTMode syncMode) {
  // UBRR0H = BAUDRATE >> 8;
  // UBRR0L = BAUDRATE & 0xFF;
  UBRR0H = UBRRH_VALUE;
  UBRR0L = UBRRL_VALUE;

  // Set RX/TN enabled
  UCSR0B |= _BV(TXEN0) | _BV(RXEN0);

  // Set frame format: 8-bit data, 1 stop bit
  UCSR0C |= _BV(UCSZ01) | _BV(UCSZ00);
  switch (syncMode) {
  case UM_Asynchronous:
    break;
  case UM_Synchronous:
    UCSR0C |= _BV(UMSEL00);
    break;
  case UM_MasterSPI:<commit_msg>Remove some dead code.<commit_after>/**
 * This Source Code Form is subject to the terms of the
 * Mozilla Public License, v. 2.0.  If a copy of the MPL
 * was not distributed with this file, you can obtain one at
 * https://mozilla.org/MPL/2.0/.
 *
 * Copyright <NAME>, 2015
 *
 * This is used to setup the UART device on an AVR unit.
 */

#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <avr/io.h>
#include <util/setbaud.h>

typedef enum {
  UM_Asynchronous,
  UM_Synchronous,
  UM_MasterSPI,
} UARTMode;

/**
 * @brief Enables the UART device for 8-bit data at
 * the specified {@see BAUD}.
 */
static inline void uart_enable(UARTMode syncMode) {
  UBRR0H = UBRRH_VALUE;
  UBRR0L = UBRRL_VALUE;

  // Set RX/TN enabled
  UCSR0B |= _BV(TXEN0) | _BV(RXEN0);

  // Set frame format: 8-bit data, 1 stop bit
  UCSR0C |= _BV(UCSZ01) | _BV(UCSZ00);
  switch (syncMode) {
  case UM_Asynchronous:
    break;
  case UM_Synchronous:
    UCSR0C |= _BV(UMSEL00);
    break;
  case UM_MasterSPI:
{'fraction_non_alphanumeric': 0.11700680272108843, 'fraction_numerical': 0.02857142857142857, 'mean_word_length': 3.2260536398467434, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 2, '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': '2702249', 'n_tokens_mistral': 940, 'n_tokens_neox': 861, 'n_words': 264}