arduino.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
21 #ifndef ARDUINO_HPP
22 #define ARDUINO_HPP
23 
24 extern "C" {
25 #include <stdint.h>
26 #include "irq.h"
27 #include "periph/gpio.h"
28 #include "arduino_board.h"
29 
35 unsigned long millis();
36 }
37 
38 #include "serialport.hpp"
39 
43 typedef bool boolean;
44 
48 typedef uint8_t byte;
49 
53 enum {
57 };
58 
62 enum {
63  LOW = 0,
64  HIGH = 1
65 };
66 
67 #ifndef ARDUINO_UART_DEV
71 #define ARDUINO_UART_DEV UART_DEV(0)
72 #endif
73 
78 
85 void pinMode(int pin, int mode);
86 
93 void digitalWrite(int pin, int state);
94 
102 int digitalRead(int pin);
103 
109 void delay(unsigned long msec);
110 
116 void delayMicroseconds(unsigned long usec);
117 
123 unsigned long micros();
124 
125 #if MODULE_PERIPH_ADC || DOXYGEN
134 int analogRead(int pin);
135 #endif
136 
137 #if MODULE_PERIPH_PWM || DOXYGEN
146 #ifndef ARDUINO_PWM_FREQU
147 #define ARDUINO_PWM_FREQU (1000U)
148 #endif
149 
153 #define ARDUINO_PWM_MODE PWM_LEFT
154 
158 #define ARDUINO_PWM_STEPS (256U)
159 
166 void analogWrite(int pin, int value);
167 #endif
168 
172 static inline void interrupts(void)
173 {
174  irq_enable();
175 }
176 
180 static inline void noInterrupts(void)
181 {
182  irq_disable();
183 }
184 
185 #endif /* ARDUINO_HPP */
Configuration of the Arduino API for Arduino Atmega boards.
Arduino Serial Interface.
Definition: serialport.hpp:45
Low-level GPIO peripheral driver interface definitions.
MAYBE_INLINE unsigned irq_disable(void)
This function sets the IRQ disable bit in the status register.
MAYBE_INLINE unsigned irq_enable(void)
This function clears the IRQ disable bit in the status register.
void delayMicroseconds(unsigned long usec)
Sleep for a given amount of time [microseconds].
int analogRead(int pin)
Read the current value of the given analog pin.
void delay(unsigned long msec)
Sleep for a given amount of time [milliseconds].
unsigned long millis()
Returns the number of milliseconds since start.
static void interrupts(void)
Enables interrupts.
Definition: arduino.hpp:172
#define ARDUINO_UART_DEV
UART device to use for Arduino serial.
Definition: arduino.hpp:71
void analogWrite(int pin, int value)
Write an analog value to a pin.
unsigned long micros()
Returns the number of microseconds since start.
static SerialPort Serial(ARDUINO_UART_DEV)
Primary serial port (mapped to ARDUINO_UART_DEV)
uint8_t byte
Arduino byte data type definion.
Definition: arduino.hpp:48
void pinMode(int pin, int mode)
Configure a pin as either input or output.
void digitalWrite(int pin, int state)
Set the value for the given pin.
int digitalRead(int pin)
Read the current state of the given pin.
static void noInterrupts(void)
Disables interrupts.
Definition: arduino.hpp:180
bool boolean
Arduino boolean data type definion.
Definition: arduino.hpp:43
@ OUTPUT
configure pin as output
Definition: arduino.hpp:55
@ INPUT_PULLUP
configure pin as input with pull-up resistor
Definition: arduino.hpp:56
@ INPUT
configure pin as input
Definition: arduino.hpp:54
@ HIGH
pin is set
Definition: arduino.hpp:64
@ LOW
pin is cleared
Definition: arduino.hpp:63
IRQ driver interface.
Definition of the Arduino 'Serial' interface.