<commit_before>/*
 * Copyright (C) 2018 <NAME>
 *
 * This file is subject to the terms and conditions of the GNU Lesser
 * General Public License v2.1. See the file LICENSE in the top level
 * directory for more details.
 */

/**
 * @ingroup     sys_arduino_api
 * @{
 *
 * @author      <NAME> <<EMAIL>>
 * @file
 *
 * @brief       Definition of the Arduino 'Wire Library' for TwoWire interfaces
 *
 * This library is the implementation of the [Arduino Wire Library]
 * (https://www.arduino.cc/en/Reference/Wire) for the I2C peripheral
 * interfaces in RIOT. It supports only I2C master mode and the functions
 * that are documented in the official [Arduino Reference]
 * (https://www.arduino.cc/en/Reference/Wire) of this library.
 *
 * The implementation is an adaptation of the original Arduino Wire Library
 * which is published under the following copyright:
 *
 * ```
 * TwoWire.h - TWI/I2C library for Arduino & Wiring
 * Copyright (c) 2006 <NAME>. All right reserved.
 *
 * 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.,
 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 *
 * Modified 2012 by <NAME> (<EMAIL>) to implement repeated starts
 * ```
 *
 * The documentation in this file is partially extracted from the original
 * [Arduino Reference](https://www.arduino.cc/en/Reference/Wire) of this
 * library which is published under the
 * [Creative Commons Attribution-ShareAlike 3.0 License]
 * (https://creativecommons.org/licenses/by-sa/3.0/).
 */

#ifndef WIREPORT_HPP
#define WIREPORT_HPP

#include <inttypes.h>
#include <stddef.h>

/** Default Arduino I2C interface */
#ifndef ARDUINO_I2C_DEV
#define ARDUINO_I2C_DEV    (I2C_DEV(0))
#endif

/** Buffer length used by the Arduino Wire library implementation */
#define WIREPORT_BUFFER_LENGTH 32

/** Class definition for the Arduino Wire library implementation */
class TwoWire
{
  private:

    static uint8_t rxBuffer[];      /**< RX buffer */
    static uint8_t rxBufferIndex;   /**< index for RX buffer read */
    static uint8_t rxBufferLength;  /**< number of bytes in RX buffer */

    static uint8_t txAddress;       /**< adress for transfer */
    static uint8_t txBuffer[];      /**< TX buffer */
    static uint8_t txBufferIndex;   /**< index for TX buffer write */
    static uint8_t txBufferLength;  /**< number of bytes in TX buffer */
    static uint8_t txError;         /**< error code in write operations */

    static uint8_t transmitting;    /**< set by #beginTransmission and reset
                                         by #endTransmission to indicate an
                                         ongoing transmission */
  public:

    /**
     * @brief Constructor
     */
    TwoWire(void);

    /**
     * @brief Initializes the I2C device defined by #ARDUINO_I2C_DEV as master
     */
    void begin(void);

    /**
     * @brief Initializes the I2C device defined by #ARDUINO_I2C_DEV as slave
     *
     * @note Since slave mode is not yet supported by the RIOT port of the
     * Arduino Wire library, calling this method leads to a core panic.<commit_msg>sys/arduino: fix typo 'adress' -> 'address'<commit_after>/*
 * Copyright (C) 2018 Gunar Schorcht
 *
 * This file is subject to the terms and conditions of the GNU Lesser
 * General Public License v2.1. See the file LICENSE in the top level
 * directory for more details.
 */

/**
 * @ingroup     sys_arduino_api
 * @{
 *
 * @author      <NAME> <<EMAIL>>
 * @file
 *
 * @brief       Definition of the Arduino 'Wire Library' for TwoWire interfaces
 *
 * This library is the implementation of the [Arduino Wire Library]
 * (https://www.arduino.cc/en/Reference/Wire) for the I2C peripheral
 * interfaces in RIOT. It supports only I2C master mode and the functions
 * that are documented in the official [Arduino Reference]
 * (https://www.arduino.cc/en/Reference/Wire) of this library.
 *
 * The implementation is an adaptation of the original Arduino Wire Library
 * which is published under the following copyright:
 *
 * ```
 * TwoWire.h - TWI/I2C library for Arduino & Wiring
 * Copyright (c) 2006 <NAME>. All right reserved.
 *
 * 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.,
 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 *
 * Modified 2012 by <NAME> (<EMAIL>) to implement repeated starts
 * ```
 *
 * The documentation in this file is partially extracted from the original
 * [Arduino Reference](https://www.arduino.cc/en/Reference/Wire) of this
 * library which is published under the
 * [Creative Commons Attribution-ShareAlike 3.0 License]
 * (https://creativecommons.org/licenses/by-sa/3.0/).
 */

#ifndef WIREPORT_HPP
#define WIREPORT_HPP

#include <inttypes.h>
#include <stddef.h>

/** Default Arduino I2C interface */
#ifndef ARDUINO_I2C_DEV
#define ARDUINO_I2C_DEV    (I2C_DEV(0))
#endif

/** Buffer length used by the Arduino Wire library implementation */
#define WIREPORT_BUFFER_LENGTH 32

/** Class definition for the Arduino Wire library implementation */
class TwoWire
{
  private:

    static uint8_t rxBuffer[];      /**< RX buffer */
    static uint8_t rxBufferIndex;   /**< index for RX buffer read */
    static uint8_t rxBufferLength;  /**< number of bytes in RX buffer */

    static uint8_t txAddress;       /**< address for transfer */
    static uint8_t txBuffer[];      /**< TX buffer */
    static uint8_t txBufferIndex;   /**< index for TX buffer write */
    static uint8_t txBufferLength;  /**< number of bytes in TX buffer */
    static uint8_t txError;         /**< error code in write operations */

    static uint8_t transmitting;    /**< set by #beginTransmission and reset
                                         by #endTransmission to indicate an
                                         ongoing transmission */
  public:

    /**
     * @brief Constructor
     */
    TwoWire(void);

    /**
     * @brief Initializes the I2C device defined by #ARDUINO_I2C_DEV as master
     */
    void begin(void);

    /**
     * @brief Initializes the I2C device defined by #ARDUINO_I2C_DEV as slave
     *
     * @note Since slave mode is not yet supported by the RIOT port of the
     * Arduino Wire library, calling this method leads to a core panic.
{'fraction_non_alphanumeric': 0.08665136995545958, 'fraction_numerical': 0.01457686597381563, 'mean_word_length': 3.0558292282430215, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 21, 'https://': 8, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2625837', 'n_tokens_mistral': 2171, 'n_tokens_neox': 2038, 'n_words': 878}