RTduino Source Code Reference Manual
Classes | Macros | Typedefs | Functions
Arduino.h File Reference

Arduino Core Header File. More...

#include <rtdevice.h>
#include <rthw.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <math.h>
#include "binary.h"
#include "avr/io.h"
#include "avr/pgmspace.h"
#include "pins_arduino.h"
+ Include dependency graph for Arduino.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pin_map_t
 RTduino pin map structure. More...
 

Macros

#define rt_align(x)   ALIGN(x)
 
#define rt_weak   RT_WEAK
 
#define LOW   0x0
 Represents a low state (0V).
 
#define HIGH   0x1
 Represents a high state (usually 3.3V or 5V).
 
#define CHANGE   0x2
 Represents a change in state.
 
#define FALLING   0x3
 Represents a transition from high to low.
 
#define RISING   0x4
 Represents a transition from low to high.
 
#define INPUT   0x0
 Configures the pin as an input. /.
 
#define OUTPUT   0x1
 Configures the pin as an output. /.
 
#define INPUT_PULLUP   0x2
 Configures the pin as an input with an internal pull-up resistor. /.
 
#define INPUT_FLOATING   INPUT
 Configures the pin as a floating input (same as INPUT). More...
 
#define INPUT_PULLDOWN   0x3
 Configures the pin as an input with an internal pull-down resistor. More...
 
#define OUTPUT_OPEN_DRAIN   0x4
 Configures the pin as an open-drain output. More...
 
#define PI   3.1415926535897932384626433832795
 A constant representing the ratio of a circle's circumference to its diameter.
 
#define HALF_PI   1.5707963267948966192313216916398
 A constant representing half of the mathematical constant π (pi) in programming and mathematics.
 
#define TWO_PI   6.283185307179586476925286766559
 A constant representing two times the mathematical constant π (pi) in programming and mathematics.
 
#define DEG_TO_RAD   0.017453292519943295769236907684886
 A constant for converting degrees to radians in mathematics and programming applications.
 
#define RAD_TO_DEG   57.295779513082320876798154814105
 A constant for converting radians to degrees in mathematical and programming contexts.
 
#define EULER   2.718281828459045235360287471352
 Euler's constant.
 
#define SERIAL   0x0
 
#define DISPLAY   0x1
 
#define LSBFIRST   0
 Least Significant Bit first.
 
#define MSBFIRST   1
 Most Significant Bit first.
 
#define min(a, b)   ((a)<(b)?(a):(b))
 Returns the smaller of two values. More...
 
#define max(a, b)   ((a)>(b)?(a):(b))
 Returns the larger of two values. More...
 
#define constrain(amt, low, high)   ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
 Constrains a value to be within a specified range. More...
 
#define radians(deg)   ((deg)*DEG_TO_RAD)
 Converts degrees to radians. More...
 
#define degrees(rad)   ((rad)*RAD_TO_DEG)
 Converts radians to degrees. More...
 
#define sq(x)   ((x)*(x)) /* x^2 */
 Squares a number. More...
 
#define _NOP()   do { __asm__ volatile ("nop"); } while (0)
 No Operation. More...
 
#define bit(b)   (1UL << (b))
 Computes the value of the specified bit (bit 0 is 1, bit 1 is 2, bit 2 is 4, etc.). More...
 
#define bitRead(value, bit)   (((value) >> (bit)) & 0x01)
 Reads the value of a specific bit. More...
 
#define bitSet(value, bit)   ((value) |= (1UL << (bit)))
 Sets a specific bit. More...
 
#define bitClear(value, bit)   ((value) &= ~(1UL << (bit)))
 Clears a specific bit. More...
 
#define bitToggle(value, bit)   ((value) ^= (1UL << (bit)))
 Toggles a specific bit. More...
 
#define bitWrite(value, bit, bitvalue)   ((bitvalue) ? bitSet(value, bit) : bitClear(value, bit))
 Writes a specific bit. More...
 
#define lowByte(w)   ((uint8_t) ((w) & 0xff))
 Extracts the low-order (rightmost) byte of a variable (e.g. a word). More...
 
#define highByte(w)   ((uint8_t) ((w) >> 8))
 Extracts the high-order (leftmost) byte of a word (or the second lowest byte of a larger data type). More...
 

Typedefs

typedef unsigned int word
 Represents a 16-bit unsigned integer.
 
typedef bool boolean
 Represents a boolean value (true or false).
 
typedef uint8_t byte
 Represents an 8-bit unsigned integer.
 

Functions

void pinMode (uint8_t pin, uint8_t mode)
 Configures the specified pin to behave either as an input or an output. More...
 
void digitalWrite (uint8_t pin, uint8_t val)
 Writes a HIGH or a LOW value to a digital pin. More...
 
int digitalRead (uint8_t pin)
 Reads the value from a specified digital pin, either HIGH or LOW. More...
 
int analogRead (uint8_t pin)
 Reads the analog input on a specified analog pin. More...
 
void analogWrite (uint8_t pin, int val)
 Writes an analog value (PWM wave) to a pin. More...
 
void analogReference (uint8_t mode)
 Configures the reference voltage used for analog input (e.g., external, internal, etc.). More...
 
void analogReadResolution (uint8_t bits)
 Sets the number of bits of resolution for the analogRead function. More...
 
void analogWriteResolution (uint8_t bits)
 Sets the number of bits of resolution for the analogWrite function. More...
 
void analogWriteFrequency (uint32_t frequency)
 Sets the frequency of the PWM on a pin. More...
 
void yield (void)
 Pauses the execution of the current task, allowing other tasks to run. More...
 
void delay (unsigned long ms)
 Delays the program for the specified number of milliseconds. More...
 
void delayMicroseconds (unsigned int us)
 Delays the program for the specified number of microseconds. More...
 
unsigned long millis (void)
 Returns the number of milliseconds since the Arduino board began running the current program. More...
 
unsigned long micros (void)
 Returns the number of microseconds since the Arduino board began running the current program. More...
 
unsigned long pulseIn (uint8_t pin, uint8_t state, unsigned long timeout)
 Measures the duration of a pulse (in us) on the specified pin. More...
 
unsigned long pulseInLong (uint8_t pin, uint8_t state, unsigned long timeout)
 Measures the duration of a pulse (in us) on the specified pin. More...
 
void shiftOut (uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
 Sends out a byte of data on the specified data pin using the specified clock and bit order. More...
 
uint8_t shiftIn (uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder)
 Shifts in data on a specified data pin using a specified clock pin and bit order. More...
 
void interrupts (void)
 Enables interrupts, allowing the execution of interrupt service routines. More...
 
void noInterrupts (void)
 Disables interrupts, preventing the execution of interrupt service routines. More...
 
uint8_t digitalPinToInterrupt (uint8_t pin)
 Converts a digital pin number to the corresponding interrupt number. More...
 
void attachInterrupt (uint8_t interruptNum, void(*userFunc)(void), int mode)
 Attaches an interrupt service routine to a specified interrupt. More...
 
void detachInterrupt (uint8_t interruptNum)
 Detaches an interrupt service routine from a specified interrupt. More...
 
void randomSeed (unsigned long seed)
 Initializes the pseudo-random number generator. More...
 
long map (long x, long in_min, long in_max, long out_min, long out_max)
 Maps a value from one range to another. More...
 
void setup (void)
 Initialization function for the Arduino environment. More...
 
void loop (void)
 Main loop function for the Arduino program. More...
 
void initVariant (void)
 Variant-specific initialization function. More...
 

Detailed Description

Arduino Core Header File.

Author
Meco Man
Date
2021-12-10
Version
1.0

This file is part of RTduino project.

The Arduino.h file is a core header file that plays a pivotal role in Arduino development. It provides fundamental definitions, constants, and functions essential for writing Arduino sketches and working with the Arduino framework.

This file includes declarations for common data types, standard constants, and core functions used in Arduino programming. It serves as the entry point for Arduino sketches, ensuring that the necessary core features are available for use.

Note
SPDX-License-Identifier: LGPL-v2.1
See also

Macro Definition Documentation

◆ _NOP

#define _NOP ( )    do { __asm__ volatile ("nop"); } while (0)

No Operation.

Performs no operation. Used as a placeholder or for creating short delays.