<commit_before>/**
 * @file Cosa/Board/ATtinyX5.hh
 * @version 1.0
 *
 * @section License
 * Copyright (C) 2012-2014, <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General
 * Public License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA  02111-1307  USA
 *
 * This file is part of the Arduino Che Cosa project.
 */

#ifndef COSA_BOARD_ATTINYX5_HH
#define COSA_BOARD_ATTINYX5_HH

/**
 * Compiler warning on unused varable.
 */
#if !defined(UNUSED)
#define UNUSED(x) (void) (x)
#endif

/**
 * Cosa ATTINYX5 Board pin symbol definitions for the ATtinyX5
 * processors. Cosa does not use pin numbers as Arduino/Wiring,
 * instead strong data type is used (enum types) for the specific pin
 * classes; DigitalPin, AnalogPin, PWMPin, etc.
 *
 * The pin numbers are only symbolically mapped, i.e. a pin
 * number/digit will not work, symbols must be used, Board::D2.
 *
 * The static inline functions, SFR, BIT and UART, rely on compiler
 * optimizations to be reduced. 
 *
 * @section Circuit
 * @code
 *                  ATinyX5   
 *                +----U----+
 * (D5/RESET)---1-|PB5   VCC|-8-----------------(VCC)
 * (D3/A3)------2-|PB3   PB2|-7--(D2/A1/EXT0/SCL/SCK)
 * (LED/D4/A2)--3-|PB4   PB1|-6-------------(D1/MOSI)
 * (GND)--------4-|GND   PB0|-5---------(D0/SDA/MISO)
 *                +---------+
 * @endcode
 */
class Board {
  friend class Pin;
  friend class UART;
private:
  /**
   * Do not allow instances. This is a static singleton; name space.
   */
  Board() {}

  /**
   * Return Special Function Register for given Arduino pin number.
   * @param[in] pin number.
   * @return special register pointer.
   */
  static volatile uint8_t* SFR(uint8_t pin) 
  { 
    UNUSED(pin);
    return (&PINB);
  }

  /**
   * Return Pin Change Mask Register for given Arduino pin number.
   * @param[in] pin number.
   * @return pin change mask register pointer.
   */
  static volatile uint8_t* PCIMR(uint8_t pin) 
  { 
    UNUSED(pin);
    return (&PCMSK);
  }

  /**
   * Return Universal Serial Interface SFR register.
   * @return special register pointer.
   */
  static volatile uint8_t* USI() 
  { 
    return (&PINB);
  }

  /**
   * Return bit position for given Arduino pin number in Special
   * Function Register. 
   * @param[in] pin number.
   * @return pin bit position.
   */
  static uint8_t BIT(uint8_t pin)
  {
    UNUSED(pin);
    return (pin);
  }
  
public:
  /**
   * Digital pin symbols
   */
  enum DigitalPin {
    D0 = 0,
    D1,
    D2,
    D3,
    D4,
    D5,
    LED = D4
  } __attribute__((packed));

  /**
   * Analog pin symbols
   */
  enum AnalogPin {
    A0 = 5,
    A1 = 2,
    A2 = 3,
    A3 = 4
  } __attribute__((packed));

  /**
   * Reference voltage; ARef pin, Vcc or internal 2V56.
   */
  enum Reference {
    AVCC_REFERENCE = 0,
    APIN_REFERENCE = _BV(REFS0),
    A1V1_REFERENCE = _BV(REFS1),
    A2V56_REFERENCE = (_BV(REFS2) | _BV(REFS1))
  } __attribute__((packed));

  /**
   * PWM pin symbols; sub-set of digital pins to allow compile 
   * time checking
   */
  enum PWMPin {
    PWM0 = D0,<commit_msg>Fixed ATtinyX5 analog pin numbering.<commit_after>/**
 * @file Cosa/Board/ATtinyX5.hh
 * @version 1.0
 *
 * @section License
 * Copyright (C) 2012-2014, <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General
 * Public License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA  02111-1307  USA
 *
 * This file is part of the Arduino Che Cosa project.
 */

#ifndef COSA_BOARD_ATTINYX5_HH
#define COSA_BOARD_ATTINYX5_HH

/**
 * Compiler warning on unused varable.
 */
#if !defined(UNUSED)
#define UNUSED(x) (void) (x)
#endif

/**
 * Cosa ATTINYX5 Board pin symbol definitions for the ATtinyX5
 * processors. Cosa does not use pin numbers as Arduino/Wiring,
 * instead strong data type is used (enum types) for the specific pin
 * classes; DigitalPin, AnalogPin, PWMPin, etc.
 *
 * The pin numbers are only symbolically mapped, i.e. a pin
 * number/digit will not work, symbols must be used, Board::D2.
 *
 * The static inline functions, SFR, BIT and UART, rely on compiler
 * optimizations to be reduced. 
 *
 * @section Circuit
 * @code
 *                  ATinyX5   
 *                +----U----+
 * (D5/RESET)---1-|PB5   VCC|-8-----------------(VCC)
 * (D3/A3)------2-|PB3   PB2|-7--(D2/A1/EXT0/SCL/SCK)
 * (LED/D4/A2)--3-|PB4   PB1|-6-------------(D1/MOSI)
 * (GND)--------4-|GND   PB0|-5---------(D0/SDA/MISO)
 *                +---------+
 * @endcode
 */
class Board {
  friend class Pin;
  friend class UART;
private:
  /**
   * Do not allow instances. This is a static singleton; name space.
   */
  Board() {}

  /**
   * Return Special Function Register for given Arduino pin number.
   * @param[in] pin number.
   * @return special register pointer.
   */
  static volatile uint8_t* SFR(uint8_t pin) 
  { 
    UNUSED(pin);
    return (&PINB);
  }

  /**
   * Return Pin Change Mask Register for given Arduino pin number.
   * @param[in] pin number.
   * @return pin change mask register pointer.
   */
  static volatile uint8_t* PCIMR(uint8_t pin) 
  { 
    UNUSED(pin);
    return (&PCMSK);
  }

  /**
   * Return Universal Serial Interface SFR register.
   * @return special register pointer.
   */
  static volatile uint8_t* USI() 
  { 
    return (&PINB);
  }

  /**
   * Return bit position for given Arduino pin number in Special
   * Function Register. 
   * @param[in] pin number.
   * @return pin bit position.
   */
  static uint8_t BIT(uint8_t pin)
  {
    UNUSED(pin);
    return (pin);
  }
  
public:
  /**
   * Digital pin symbols
   */
  enum DigitalPin {
    D0 = 0,
    D1,
    D2,
    D3,
    D4,
    D5,
    LED = D4
  } __attribute__((packed));

  /**
   * Analog pin symbols
   */
  enum AnalogPin {
    A0 = 5,
    A1 = 2,
    A2 = 4,
    A3 = 3
  } __attribute__((packed));

  /**
   * Reference voltage; ARef pin, Vcc or internal 2V56.
   */
  enum Reference {
    AVCC_REFERENCE = 0,
    APIN_REFERENCE = _BV(REFS0),
    A1V1_REFERENCE = _BV(REFS1),
    A2V56_REFERENCE = (_BV(REFS2) | _BV(REFS1))
  } __attribute__((packed));

  /**
   * PWM pin symbols; sub-set of digital pins to allow compile 
   * time checking
   */
  enum PWMPin {
    PWM0 = D0,
{'fraction_non_alphanumeric': 0.12657712657712658, 'fraction_numerical': 0.02591235924569258, 'mean_word_length': 2.487228003784295, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1535966', 'n_tokens_mistral': 2631, 'n_tokens_neox': 2462, 'n_words': 835}