Playing with Arduino

A page to record my playing with Arduino
garretlab
Internal Structure of Arduino Software

Introduction

I am analyzing the implementation and internal structure of the Arduino Software 1.0.5. The goal is to clarify the software that comes with arduino-1.0.5-windows.zip as far as I can.

I checked the code for Arduino Uno where #if is used. It means Arduino Mega or Leonardo may have different behavior.

If you have any comments, suggestions, corrections or anything, please contact to 'garretlab at gmail.com' by e-mail. Note that I am a Japanese, please use plain English.

Arduino related

Arduino Software

hardware/arduino/cores/arduino/wiring_digital.c
pinMode() Configures the specified pin to behave either as an input or an output.
digitalRead() Returns the value of the digital input port.
digitalWrite() Sets the specified digital pin to HIGH or LOW.
turnOffPWM() Stops PWM output of a specified timer. Please refer to the explanation of the analogWrite() but not yet written.
hardware/arduino/cores/arduino/wiring_analog.c
analogReference() Sets the reference voltage for analog input.
analogRead() Reads the value from analog pin using analog-digital(AD) converter.
analogWrite() Outputs PWM(Pulse Width Modulation) wave.
hardware/arduino/cores/arduino/Tone.cpp
tone()
toneBegin()
noTone()
disableTimer()
TIMER2_COMPA_vect
hardware/arduino/cores/arduino/wiring.c
init() Initializes the timer counter, AD converter and serial communication of ATmega328P.
millis() Returns the number of milliseconds held by Arduino.
micros() Returns the number of microseconds held by Arduino.
TIMER0_OVF_vect
delay()
delayMicroseconds()
hardware/arduino/cores/arduino/WInterrupts.c
attachInterrupt()
detachInterrupt()
hardware/arduino/cores/arduino/wiring_shift.c
shiftIn()
shiftOut()
hardware/arduino/cores/arduino/wiring_pulse.c
pulseIn()
hardware/arduino/cores/arduino/HardwareSerial.cpp
Registers
HardwareSerial
Serial.begin()/HardwareSerial::begin()
Serial.end()/HardwareSerial::end()
Serial.read()/HardwareSerial::read()
Serial.peek()/HardwareSerial::peek()
Serial.available()/HardwareSerial::available()
Serial.flush()/HardwareSerial::flush()
Serial.write()/HardwareSerial::write()
if(Serial)/HardwareSerial::operator bool()
USART_RX_vect
USART_UDRE_vect
store_char
hardware/arduino/cores/arduino/HardwareSerial.h
HardwareSerial
hardware/arduino/cores/arduino/wiring_private.h
sbi() A macro to set the bit(the second argument) of the address(the first argument) to 1.
cbi() A macro to set the bit(the second argument) of the address(the first argument) to 0.
hardware/arduino/cores/arduino/Arduino.h
digaitalPinToBitMask() A macro that returns the bitmask of a specified pin.
digitalPinToPort() A macro that returns the port of a specified pin.
digitalPinToTimer() A macro that returns the timer of a specified pin.
portModeRegister() A macro that returns a mode register that controlls the mode of the specified port.
portOutputRegister() A macro that returns an output port register of the specified port.
portInputRegister() A macro that returns an input port register of the specified port.
bitRead()
bitSet()
bitClear()
bitWrite()
clockCyclesPerMicrosecond()
clockCyclesToMicroseconds()
microsecondsToClockCycles()
interrupts()
noInterrupts()

Libraries

libraries/SPI/SPI.cpp
SPI Related Registers
SPIClass::begin()
SPIClass::end()
SPIClass::setBitOrder()
SPIClass::setDataMode()
SPIClass::setClockDivider()
libraries/SPI/SPI.h
SPIClass::transfer()

AVR-GCC related

hardware/tools/avr/avr/include/avr/pgmspace.h
pgm_read_byte() A macro that reads a byte of data stored in a specified address(PROGMEM area).
pgm_read_byte_near() A macro that reads a byte of data stored in a specified address(PROGMEM area).
__LPM() A macro that reads a byte of data stored in a specified address(PROGMEM area).
__LPM_enhanced__() An assembler code that reads a byte of data stored in a specified address(PROGMEM area).
pgm_read_word() A macro that reads a word of data stored in a specified address(PROGMEM area).
pgm_read_word_near() A macro that reads a word of data stored in a specified address(PROGMEM area).
__LPM__word() A macro that reads a word of data stored in a specified address(PROGMEM area).
__LPM_word_enhanced__() An assembler code that reads a word of data stored in a specified address(PROGMEM area).
hardware/tools/avr/avr/include/avr/common.h
SREG A status register of ATmega328P.
hardware/tools/avr/avr/include/avr/sfr_defs.h
_BV() A macro that shifts 1 to left by the specified numnber.
_SFR_ADDR() A macro that returns the address of the argument.
_SFR_MEM_ADDR() A macro that returns the address of the argument.
_SFR_BYTE() A macro that returns a byte of data of the specified address.
_SFR_WORD() A macro that returns two bytes of data of the specified address.
_SFR_IO8() A macro that returns a byte of data at an address of io_addr + __SFR_OFFSET.
_SFR_MEM8() A macro that returns a byte of data of the specified address.
_SFR_MEM16() A macro to return two bytes of data of the specified address.
_MMIO_BYTE() A macro that returns a byte of data at the specified address
_MMIO_WORD() A macro that returns two bytes of data at the specified address.
bit_is_set() A macro that checks if the second argumen-th bit of the first argument is 1.
_VECTOR() A macro to convert an interrupt vector number to a real address.
hardware/tools/avr/avr/include/avr/iom328p.h
DDRx Registers which determine if the digital pin is output mode or input mode.
PORTxn Registers for bi-directional I/O.
ADMUX A register that controls the reference voltage, the presentation of the ADC conversion(left adjust or right adjust) and analog channel selection.
ADCSRA A register to control AD conversion.
ADCL/ADCH Registers which store the result of AD conversion.
TCCRnx Registers to control timers and counters.
OCRnx Registers are registers to set the duty ratio for PWM output.
TIMSKn Registers related to timer interruption.
Interrupt Vectors Definitions of the interrupt vectors.
TCNTn Registers incremented by each timer clock.
TIFRn Registers to control timer interruption.
EICRA A registers to control external interrupt.
EIMSK A registers to control external interrupt.
USART0 USART0(Universal Synchronous and Asynchronous serial Receiver and Transmitter) related registers.
hardware/tools/avr/avr/include/avr/interrupt.h
cli() A macro that executes an assembler instruction to disable interrupts.
sei() A macro that executes an assembler instruction to enable interrupts.
ISR() A macro to define a function to register to interrupt vectors.
SIGNAL() A macro to define a function to register to interrupt vectors.


Turn on JavaScript to display a menu.

Playing with Arduino
Copyright © 2012 garretlab all rights reserved.
inserted by FC2 system