Initial import of support files for all Digistump boards - Digispark, Pro, DigiX - including libraries, examples, tools, and other support files for the Arduino IDE

This commit is contained in:
Erik Tylek Kettenburg
2014-12-19 08:45:50 -08:00
parent 97abdbf157
commit 7e7473a2d6
3567 changed files with 722870 additions and 0 deletions

View File

@@ -0,0 +1,321 @@
/*
pins_arduino.c - pin definitions for the Arduino board
Part of Arduino / Wiring Lite
Copyright (c) 2005 David A. Mellis
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
$Id: pins_arduino.c 565 2009-03-25 10:50:00Z dmellis $
Modified 28-08-2009 for attiny84 R.Wiersma
Modified 09-10-2009 for attiny45 A.Saporetti
Modified for Atmel ATTiny2313 mcu by Ren<65> Bohne
Corrected 17-05-2010 for ATtiny84 B.Cook ...
The default analog_reference leaves chip pin 13 (digital pin 10; PA0)
unconnected. So the pin can be set to a non-floating state and so the
pin can be used as another digital pin, support for digital pin 10 was
added.
*/
#include <avr/io.h>
#include "pins_arduino.h"
#include "wiring_private.h"
#if defined( __AVR_ATtinyX313__ )
// On the Arduino board, digital pins are also used
// for the analog output (software PWM). Analog input
// pins are a separate set.
// ATMEL ATTINY2313
//
// +-\/-+
// (D 17) PA2 1| |29 VCC
// RX (D 0) PD0 2| |19 PB7 (D 16)
// TX (D 1) PD1 3| |18 PB6 (D 15)
// (D 2) PA1 4| |17 PB5 (D 14)
// (D 3) PA0 5| |16 PB4 (D 13)*
// INT0 (D 4) PD2 6| |15 PB3 (D 12)*
// INT1 (D 5) PD3 7| |14 PB2 (D 11)*
// (D 6) PD4 8| |13 PB1 (D 10)
// *(D 7) PD5 9| |12 PB0 (D 9)
// GND 10| |11 PD6 (D 8)
// +----+
//
// * indicates PWM port
// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing)
const uint8_t PROGMEM port_to_mode_PGM[] =
{
NOT_A_PORT,
&DDRA,
&DDRB,
NOT_A_PORT,
&DDRD,
};
const uint8_t PROGMEM port_to_output_PGM[] =
{
NOT_A_PORT,
&PORTA,
&PORTB,
NOT_A_PORT,
&PORTD,
};
const uint8_t PROGMEM port_to_input_PGM[] =
{
NOT_A_PORT,
&PINA,
&PINB,
NOT_A_PORT,
&PIND,
};
const uint8_t PROGMEM digital_pin_to_port_PGM[] =
{
PORT_D_ID, /* 0 */
PORT_D_ID,
PORT_A_ID,
PORT_A_ID,
PORT_D_ID,
PORT_D_ID,
PORT_D_ID,
PORT_D_ID,
PORT_D_ID, /* 8 */
PORT_B_ID,
PORT_B_ID,
PORT_B_ID,
PORT_B_ID,
PORT_B_ID,
PORT_B_ID, /* 14 */
PORT_B_ID,
PORT_B_ID,
PORT_A_ID,
};
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
{
_BV(0), /* 0 */
_BV(1),
_BV(1),
_BV(0),
_BV(2),
_BV(3),
_BV(4),
_BV(5),
_BV(6), /* 8 */
_BV(0),
_BV(1),
_BV(2),
_BV(3),
_BV(4),
_BV(5), /* 14 */
_BV(6),
_BV(7),
_BV(2),
};
const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
{
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
TIMER0B,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
TIMER0A,
TIMER1A,
TIMER1B,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
};
#endif
#if defined( __AVR_ATtinyX4__ )
// ATMEL ATTINY84 / ARDUINO
//
// +-\/-+
// VCC 1| |14 GND
// (D 0) PB0 2| |13 AREF (D 10)
// (D 1) PB1 3| |12 PA1 (D 9)
// PB3 4| |11 PA2 (D 8)
// PWM INT0 (D 2) PB2 5| |10 PA3 (D 7)
// PWM (D 3) PA7 6| |9 PA4 (D 6)
// PWM (D 4) PA6 7| |8 PA5 (D 5) PWM
// +----+
// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing)
const uint8_t PROGMEM port_to_mode_PGM[] =
{
NOT_A_PORT,
&DDRA,
&DDRB,
};
const uint8_t PROGMEM port_to_output_PGM[] =
{
NOT_A_PORT,
&PORTA,
&PORTB,
};
const uint8_t PROGMEM port_to_input_PGM[] =
{
NOT_A_PORT,
&PINA,
&PINB,
};
const uint8_t PROGMEM port_to_pcmask_PGM[] =
{
NOT_A_PORT,
&PCMSK0,
&PCMSK1,
};
const uint8_t PROGMEM digital_pin_to_port_PGM[] =
{
PORT_B_ID, /* 0 */
PORT_B_ID,
PORT_B_ID,
PORT_A_ID,
PORT_A_ID,
PORT_A_ID,
PORT_A_ID,
PORT_A_ID,
PORT_A_ID, /* 8 */
PORT_A_ID,
PORT_A_ID,
};
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
{
_BV(0), /* 0, port B */
_BV(1),
_BV(2),
_BV(7), /* 3 port B */
_BV(6),
_BV(5),
_BV(4),
_BV(3),
_BV(2),
_BV(1),
_BV(0),
};
const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
{
NOT_ON_TIMER,
NOT_ON_TIMER,
TIMER0A, /* OC0A */
TIMER0B, /* OC0B */
TIMER1A, /* OC1A */
TIMER1B, /* OC1B */
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
};
#endif
#if defined( __AVR_ATtinyX5__ )
// ATMEL ATTINY45 / ARDUINO
//
// +-\/-+
// Ain0 (D 5) PB5 1| |8 VCC
// Ain3 (D 3) PB3 2| |7 PB2 (D 2) INT0 Ain1
// Ain2 (D 4) PB4 3| |6 PB1 (D 1) pwm1
// GND 4| |5 PB0 (D 0) pwm0
// +----+
// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing) tiny45 only port B
const uint8_t PROGMEM port_to_mode_PGM[] =
{
NOT_A_PORT,
&DDRB,
};
const uint8_t PROGMEM port_to_output_PGM[] =
{
NOT_A_PORT,
&PORTB,
};
const uint8_t PROGMEM port_to_input_PGM[] =
{
NOT_A_PIN,
&PINB,
};
const uint8_t PROGMEM digital_pin_to_port_PGM[] =
{
PORT_B_ID, /* 0 */
PORT_B_ID,
PORT_B_ID,
PORT_B_ID,
PORT_B_ID,
PORT_B_ID, /* 5 */
};
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
{
_BV(0), /* 0, port B */
_BV(1),
_BV(2),
_BV(3), /* 3 port B */
_BV(4),
_BV(5),
};
const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
{
TIMER0A, /* OC0A */
TIMER1A, /* OC1A? */
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
};
#endif

View File

@@ -0,0 +1,115 @@
/*
pins_arduino.h - Pin definition functions for Arduino
Part of Arduino - http://www.arduino.cc/
Copyright (c) 2007 David A. Mellis
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
$Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
Modified 28-08-2009 for attiny84 R.Wiersma
Modified 14-10-2009 for attiny45 Saposoft
*/
#ifndef Pins_Arduino_h
#define Pins_Arduino_h
#include <avr/pgmspace.h>
#include "core_build_options.h"
#if defined( __AVR_ATtinyX313__ )
#define PORT_A_ID 1
#define PORT_B_ID 2
#define PORT_D_ID 4
#endif
#if defined( __AVR_ATtinyX4__ )
#define PORT_A_ID 1
#define PORT_B_ID 2
#endif
#if defined( __AVR_ATtinyX5__ )
#define PORT_B_ID 1
#endif
#define NOT_A_PIN 0
#define NOT_A_PORT 0
#define NOT_ON_TIMER 0
#define TIMER0A 1
#define TIMER0B 2
#define TIMER1A 3
#define TIMER1B 4
//changed it to uint16_t to uint8_t
extern const uint8_t PROGMEM port_to_mode_PGM[];
extern const uint8_t PROGMEM port_to_input_PGM[];
extern const uint8_t PROGMEM port_to_output_PGM[];
extern const uint8_t PROGMEM port_to_pcmask_PGM[];
extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
// extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
// Get the bit location within the hardware port of the given virtual pin.
// This comes from the pins_*.c file for the active board configuration.
//
// These perform slightly better as macros compared to inline functions
//
#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
#define analogInPinToBit(P) (P)
// in the following lines modified pgm_read_word in pgm_read_byte, word doesn't work on attiny45
#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_output_PGM + (P))) )
#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_input_PGM + (P))) )
#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_mode_PGM + (P))) )
#define portPcMaskRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_pcmask_PGM + (P))) )
#if defined(__AVR_ATtinyX5__)
#define digitalPinToPCICR(p) (((p) >= 0 && (p) <= 5) ? (&GIMSK) : ((uint8_t *)NULL))
#define digitalPinToPCICRbit(p) (PCIE)
#define digitalPinToPCMSK(p) (((p) >= 0 && (p) <= 5) ? (&PCMSK) : ((uint8_t *)NULL))
#define digitalPinToPCMSKbit(p) (p)
#endif
#if defined(__AVR_ATtinyX4__)
#define digitalPinToPCICR(p) (((p) >= 0 && (p) <= 10) ? (&GIMSK) : ((uint8_t *)NULL))
#define digitalPinToPCICRbit(p) (((p) <= 2) ? PCIE1 : PCIE0)
#define digitalPinToPCMSK(p) (((p) <= 2) ? (&PCMSK1) : (((p) <= 10) ? (&PCMSK0) : ((uint8_t *)NULL)))
#define digitalPinToPCMSKbit(p) (((p) <= 2) ? (p) : (10 - (p)))
#endif
#if defined(__AVR_ATtiny4313__)
#define digitalPinToPCX(p,s1,s2,s3,s4,s5) \
(((p) >= 0) \
? (((p) <= 1) ? (s1) /* 0 - 1 ==> D0 - D1 */ \
: (((p) <= 3) ? (s2) /* 2 - 3 ==> A1 - A0 */ \
: (((p) <= 8) ? (s3) /* 4 - 8 ==> D2 - D6 */ \
: (((p) <= 16) ? (s4) /* 9 - 16 ==> B0 - B7 */ \
: (s5))))) \
: (s5))
// s1 D s2 A s3 D s4 B
#define digitalPinToPCICR(p) digitalPinToPCX( p, &GIMSK, &GIMSK, &GIMSK, &GIMSK, NULL )
#define digitalPinToPCICRbit(p) digitalPinToPCX( p, PCIE2, PCIE1, PCIE2, PCIE0, 0 )
#define digitalPinToPCMSK(p) digitalPinToPCX( p, &PCMSK2, &PCMSK1, &PCMSK2, &PCMSK0, NULL )
#define digitalPinToPCMSKbit(p) digitalPinToPCX( p, p, 3-p, p-2, p-9, 0 )
#endif
#endif

View File

@@ -0,0 +1,233 @@
/*
pins_arduino.h - Pin definition functions for Arduino
Part of Arduino - http://www.arduino.cc/
Copyright (c) 2007 David A. Mellis
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
$Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
*/
#ifndef Pins_Arduino_h
#define Pins_Arduino_h
#define ATTINYX7 1
#define SERIAL_BUFFER_SIZE 16
#include <avr/pgmspace.h>
#define NUM_DIGITAL_PINS 14
#define NUM_ANALOG_INPUTS 10
#define analogInputToDigitalPin(p) ((p < 7) ? p+6 : (p ==7) ? 5 : (p==9) ? 4 : (p==10) ? 13 : -1)
#define digitalPinHasPWM(p) ((p) == 0 || (p) == 1)
#define SS 12
#define MOSI 10
#define MISO 8
#define SCK 11
static const uint8_t SDA = 0;
static const uint8_t SCL = 2;
//Ax constants cannot be used for digitalRead/digitalWrite/analogWrite functions, only analogRead().
static const uint8_t A4 = NUM_DIGITAL_PINS+9;
static const uint8_t A5 = NUM_DIGITAL_PINS+7;
static const uint8_t A6 = NUM_DIGITAL_PINS+0;
static const uint8_t A7 = NUM_DIGITAL_PINS+1;
static const uint8_t A8 = NUM_DIGITAL_PINS+2;
static const uint8_t A9 = NUM_DIGITAL_PINS+3;
static const uint8_t A10 = NUM_DIGITAL_PINS+4;
static const uint8_t A11 = NUM_DIGITAL_PINS+5;
static const uint8_t A12 = NUM_DIGITAL_PINS+6;
static const uint8_t A13 = NUM_DIGITAL_PINS+10;
//----------------------------------------------------------
//----------------------------------------------------------
//Core Configuration (used to be in core_build_options.h)
//If Software Serial communications doesn't work, run the TinyTuner sketch provided with the core to give you a calibrated OSCCAL value.
//Change the value here with the tuned value. By default this option uses the default value which the compiler will optimise out.
#define TUNED_OSCCAL_VALUE OSCCAL
//e.g
//#define TUNED_OSCCAL_VALUE 0x57
//Choosing not to initialise saves power and flash. 1 = initialise.
#define INITIALIZE_ANALOG_TO_DIGITAL_CONVERTER 1
#define INITIALIZE_SECONDARY_TIMERS 0
#define TIMER_TO_USE_FOR_MILLIS 0
#define HAVE_BOOTLOADER 1
/*
Where to put the software serial? (Arduino Digital pin numbers)
*/
//WARNING, if using software, TX is on AIN0, RX is on AIN1. Comparator is favoured to use its interrupt for the RX pin.
#define USE_SOFTWARE_SERIAL 0
//Please define the port on which the analog comparator is found.
#define ANALOG_COMP_DDR DDRA
#define ANALOG_COMP_PORT PORTA
#define ANALOG_COMP_PIN PINA
#define ANALOG_COMP_AIN0_BIT 6
#define ANALOG_COMP_AIN1_BIT 7
/*
Analog reference bit masks.
*/
// VCC used as analog reference, disconnected from PA0 (AREF)
#define DEFAULT (0)
// External voltage reference at PA0 (AREF) pin, internal reference turned off
#define EXTERNAL (1)
// Internal 1.1V voltage reference
#define INTERNAL (2)
//----------------------------------------------------------
//----------------------------------------------------------
//----------------------------------------------------------
//----------------------------------------------------------
#define digitalPinToPCICR(p) (&PCIFR)
#define digitalPinToPCICRbit(p) (((p) >= 3 && (p) <= 10) ? 4 : 5)
#define digitalPinToPCMSK(p) (((p) >= 3 && (p) <= 10) ? (&PCMSK0) : (((p) >= 0 && (p) <= 2) ? (&PCMSK1) : ((uint8_t *)NULL)))
#define digitalPinToPCMSKbit(p) (((p) >= 3 && (p) <= 10) ? (10 - (p)) : (p))
#ifdef ARDUINO_MAIN
// On the Arduino board, digital pins are also used
// for the analog output (software PWM). Analog input
// pins are a separate set.
// ATMEL ATTINY167
//
// +-\/-+
// RX (D 0) PA0 1| |20 PB0 (D 4)
// TX (D 1) PA1 2| |19 PB1 (D 5)
// *(D 12) PA2 3| |18 PB2 (D 6)
// (D 3) PA3 4| |17 PB3 (D 7)*
// AVCC 5| |16 GND
// AGND 6| |15 VCC
// INT1 (D 11) PA4 7| |14 PB4 (D 8)
// (D 13) PA5 8| |13 PB5 (D 9)
// (D 10) PA6 9| |12 PB6 (D 2)* INT0
// (D 14) PA7 10| |11 PB7 (D 15)
// +----+
//
// * indicates PWM pin.
// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing)
const uint16_t PROGMEM port_to_mode_PGM[] =
{
NOT_A_PORT,
(uint16_t)&DDRA,
(uint16_t)&DDRB,
};
const uint16_t PROGMEM port_to_output_PGM[] =
{
NOT_A_PORT,
(uint16_t)&PORTA,
(uint16_t)&PORTB,
};
const uint16_t PROGMEM port_to_input_PGM[] =
{
NOT_A_PORT,
(uint16_t)&PINA,
(uint16_t)&PINB,
};
const uint8_t PROGMEM digital_pin_to_port_PGM[] =
{
PB, /* 0 */
PB,
PB, /* 2 */
PB, /* 3 */
PB, /* 4 */
PA,
PA,
PA,
PA,
PA,
PA, /* 10 */
PA,
PA,
PB, /* 15 */
};
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
{
_BV(0), /* 0 */
_BV(1),
_BV(2), /* 2 */
_BV(3), /* 3 */
_BV(6), /* 4 */
_BV(7),
_BV(0),
_BV(1),
_BV(2),
_BV(3),
_BV(4), /* 10 */
_BV(5),
_BV(6),
_BV(7),
};
const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
{
TIMER1A,
TIMER1B,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
};
#endif
#endif
//Old code, just here for temporary backup until I decide it is not needed.
//WARNING, if using software, RX must be on a pin which has a Pin change interrupt <= 7 (e.g. PCINT6, or PCINT1, but not PCINT8)
/*#define USE_SOFTWARE_SERIAL 1
//These are set to match Optiboot pins.
#define SOFTWARE_SERIAL_PORT PORTB
#define SOFTWARE_SERIAL_TX 0
#define SOFTWARE_SERIAL_PIN PINB
#define SOFTWARE_SERIAL_RX 1*/

View File

@@ -0,0 +1,233 @@
/*
pins_arduino.h - Pin definition functions for Arduino
Part of Arduino - http://www.arduino.cc/
Copyright (c) 2007 David A. Mellis
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
$Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
*/
#ifndef Pins_Arduino_h
#define Pins_Arduino_h
#define ATTINYX7 1
#define SERIAL_BUFFER_SIZE 32
#include <avr/pgmspace.h>
#define NUM_DIGITAL_PINS 14
#define NUM_ANALOG_INPUTS 10
#define analogInputToDigitalPin(p) ((p < 7) ? p+6 : (p ==7) ? 5 : (p==9) ? 4 : (p==10) ? 13 : -1)
#define digitalPinHasPWM(p) ((p) == 0 || (p) == 1)
#define SS 12
#define MOSI 10
#define MISO 8
#define SCK 11
static const uint8_t SDA = 0;
static const uint8_t SCL = 2;
//Ax constants cannot be used for digitalRead/digitalWrite/analogWrite functions, only analogRead().
static const uint8_t A4 = NUM_DIGITAL_PINS+9;
static const uint8_t A5 = NUM_DIGITAL_PINS+7;
static const uint8_t A6 = NUM_DIGITAL_PINS+0;
static const uint8_t A7 = NUM_DIGITAL_PINS+1;
static const uint8_t A8 = NUM_DIGITAL_PINS+2;
static const uint8_t A9 = NUM_DIGITAL_PINS+3;
static const uint8_t A10 = NUM_DIGITAL_PINS+4;
static const uint8_t A11 = NUM_DIGITAL_PINS+5;
static const uint8_t A12 = NUM_DIGITAL_PINS+6;
static const uint8_t A13 = NUM_DIGITAL_PINS+10;
//----------------------------------------------------------
//----------------------------------------------------------
//Core Configuration (used to be in core_build_options.h)
//If Software Serial communications doesn't work, run the TinyTuner sketch provided with the core to give you a calibrated OSCCAL value.
//Change the value here with the tuned value. By default this option uses the default value which the compiler will optimise out.
#define TUNED_OSCCAL_VALUE OSCCAL
//e.g
//#define TUNED_OSCCAL_VALUE 0x57
//Choosing not to initialise saves power and flash. 1 = initialise.
#define INITIALIZE_ANALOG_TO_DIGITAL_CONVERTER 1
#define INITIALIZE_SECONDARY_TIMERS 0
#define TIMER_TO_USE_FOR_MILLIS 0
#define HAVE_BOOTLOADER 1
/*
Where to put the software serial? (Arduino Digital pin numbers)
*/
//WARNING, if using software, TX is on AIN0, RX is on AIN1. Comparator is favoured to use its interrupt for the RX pin.
#define USE_SOFTWARE_SERIAL 0
//Please define the port on which the analog comparator is found.
#define ANALOG_COMP_DDR DDRA
#define ANALOG_COMP_PORT PORTA
#define ANALOG_COMP_PIN PINA
#define ANALOG_COMP_AIN0_BIT 6
#define ANALOG_COMP_AIN1_BIT 7
/*
Analog reference bit masks.
*/
// VCC used as analog reference, disconnected from PA0 (AREF)
#define DEFAULT (0)
// External voltage reference at PA0 (AREF) pin, internal reference turned off
#define EXTERNAL (1)
// Internal 1.1V voltage reference
#define INTERNAL (2)
//----------------------------------------------------------
//----------------------------------------------------------
//----------------------------------------------------------
//----------------------------------------------------------
#define digitalPinToPCICR(p) (&PCIFR)
#define digitalPinToPCICRbit(p) (((p) >= 3 && (p) <= 10) ? 4 : 5)
#define digitalPinToPCMSK(p) (((p) >= 3 && (p) <= 10) ? (&PCMSK0) : (((p) >= 0 && (p) <= 2) ? (&PCMSK1) : ((uint8_t *)NULL)))
#define digitalPinToPCMSKbit(p) (((p) >= 3 && (p) <= 10) ? (10 - (p)) : (p))
#ifdef ARDUINO_MAIN
// On the Arduino board, digital pins are also used
// for the analog output (software PWM). Analog input
// pins are a separate set.
// ATMEL ATTINY167
//
// +-\/-+
// RX (D 0) PA0 1| |20 PB0 (D 4)
// TX (D 1) PA1 2| |19 PB1 (D 5)
// *(D 12) PA2 3| |18 PB2 (D 6)
// (D 3) PA3 4| |17 PB3 (D 7)*
// AVCC 5| |16 GND
// AGND 6| |15 VCC
// INT1 (D 11) PA4 7| |14 PB4 (D 8)
// (D 13) PA5 8| |13 PB5 (D 9)
// (D 10) PA6 9| |12 PB6 (D 2)* INT0
// (D 14) PA7 10| |11 PB7 (D 15)
// +----+
//
// * indicates PWM pin.
// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing)
const uint16_t PROGMEM port_to_mode_PGM[] =
{
NOT_A_PORT,
(uint16_t)&DDRA,
(uint16_t)&DDRB,
};
const uint16_t PROGMEM port_to_output_PGM[] =
{
NOT_A_PORT,
(uint16_t)&PORTA,
(uint16_t)&PORTB,
};
const uint16_t PROGMEM port_to_input_PGM[] =
{
NOT_A_PORT,
(uint16_t)&PINA,
(uint16_t)&PINB,
};
const uint8_t PROGMEM digital_pin_to_port_PGM[] =
{
PB, /* 0 */
PB,
PB, /* 2 */
PB, /* 3 */
PB, /* 4 */
PA,
PA,
PA,
PA,
PA,
PA, /* 10 */
PA,
PA,
PB, /* 15 */
};
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
{
_BV(0), /* 0 */
_BV(1),
_BV(2), /* 2 */
_BV(3), /* 3 */
_BV(6), /* 4 */
_BV(7),
_BV(0),
_BV(1),
_BV(2),
_BV(3),
_BV(4), /* 10 */
_BV(5),
_BV(6),
_BV(7),
};
const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
{
TIMER1A,
TIMER1B,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
};
#endif
#endif
//Old code, just here for temporary backup until I decide it is not needed.
//WARNING, if using software, RX must be on a pin which has a Pin change interrupt <= 7 (e.g. PCINT6, or PCINT1, but not PCINT8)
/*#define USE_SOFTWARE_SERIAL 1
//These are set to match Optiboot pins.
#define SOFTWARE_SERIAL_PORT PORTB
#define SOFTWARE_SERIAL_TX 0
#define SOFTWARE_SERIAL_PIN PINB
#define SOFTWARE_SERIAL_RX 1*/

View File

@@ -0,0 +1,233 @@
/*
pins_arduino.h - Pin definition functions for Arduino
Part of Arduino - http://www.arduino.cc/
Copyright (c) 2007 David A. Mellis
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
$Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
*/
#ifndef Pins_Arduino_h
#define Pins_Arduino_h
#define ATTINYX7 1
#define SERIAL_BUFFER_SIZE 64
#include <avr/pgmspace.h>
#define NUM_DIGITAL_PINS 14
#define NUM_ANALOG_INPUTS 10
#define analogInputToDigitalPin(p) ((p < 7) ? p+6 : (p ==7) ? 5 : (p==9) ? 4 : (p==10) ? 13 : -1)
#define digitalPinHasPWM(p) ((p) == 0 || (p) == 1)
#define SS 12
#define MOSI 10
#define MISO 8
#define SCK 11
static const uint8_t SDA = 0;
static const uint8_t SCL = 2;
//Ax constants cannot be used for digitalRead/digitalWrite/analogWrite functions, only analogRead().
static const uint8_t A4 = NUM_DIGITAL_PINS+9;
static const uint8_t A5 = NUM_DIGITAL_PINS+7;
static const uint8_t A6 = NUM_DIGITAL_PINS+0;
static const uint8_t A7 = NUM_DIGITAL_PINS+1;
static const uint8_t A8 = NUM_DIGITAL_PINS+2;
static const uint8_t A9 = NUM_DIGITAL_PINS+3;
static const uint8_t A10 = NUM_DIGITAL_PINS+4;
static const uint8_t A11 = NUM_DIGITAL_PINS+5;
static const uint8_t A12 = NUM_DIGITAL_PINS+6;
static const uint8_t A13 = NUM_DIGITAL_PINS+10;
//----------------------------------------------------------
//----------------------------------------------------------
//Core Configuration (used to be in core_build_options.h)
//If Software Serial communications doesn't work, run the TinyTuner sketch provided with the core to give you a calibrated OSCCAL value.
//Change the value here with the tuned value. By default this option uses the default value which the compiler will optimise out.
#define TUNED_OSCCAL_VALUE OSCCAL
//e.g
//#define TUNED_OSCCAL_VALUE 0x57
//Choosing not to initialise saves power and flash. 1 = initialise.
#define INITIALIZE_ANALOG_TO_DIGITAL_CONVERTER 1
#define INITIALIZE_SECONDARY_TIMERS 0
#define TIMER_TO_USE_FOR_MILLIS 0
#define HAVE_BOOTLOADER 1
/*
Where to put the software serial? (Arduino Digital pin numbers)
*/
//WARNING, if using software, TX is on AIN0, RX is on AIN1. Comparator is favoured to use its interrupt for the RX pin.
#define USE_SOFTWARE_SERIAL 0
//Please define the port on which the analog comparator is found.
#define ANALOG_COMP_DDR DDRA
#define ANALOG_COMP_PORT PORTA
#define ANALOG_COMP_PIN PINA
#define ANALOG_COMP_AIN0_BIT 6
#define ANALOG_COMP_AIN1_BIT 7
/*
Analog reference bit masks.
*/
// VCC used as analog reference, disconnected from PA0 (AREF)
#define DEFAULT (0)
// External voltage reference at PA0 (AREF) pin, internal reference turned off
#define EXTERNAL (1)
// Internal 1.1V voltage reference
#define INTERNAL (2)
//----------------------------------------------------------
//----------------------------------------------------------
//----------------------------------------------------------
//----------------------------------------------------------
#define digitalPinToPCICR(p) (&PCIFR)
#define digitalPinToPCICRbit(p) (((p) >= 3 && (p) <= 10) ? 4 : 5)
#define digitalPinToPCMSK(p) (((p) >= 3 && (p) <= 10) ? (&PCMSK0) : (((p) >= 0 && (p) <= 2) ? (&PCMSK1) : ((uint8_t *)NULL)))
#define digitalPinToPCMSKbit(p) (((p) >= 3 && (p) <= 10) ? (10 - (p)) : (p))
#ifdef ARDUINO_MAIN
// On the Arduino board, digital pins are also used
// for the analog output (software PWM). Analog input
// pins are a separate set.
// ATMEL ATTINY167
//
// +-\/-+
// RX (D 0) PA0 1| |20 PB0 (D 4)
// TX (D 1) PA1 2| |19 PB1 (D 5)
// *(D 12) PA2 3| |18 PB2 (D 6)
// (D 3) PA3 4| |17 PB3 (D 7)*
// AVCC 5| |16 GND
// AGND 6| |15 VCC
// INT1 (D 11) PA4 7| |14 PB4 (D 8)
// (D 13) PA5 8| |13 PB5 (D 9)
// (D 10) PA6 9| |12 PB6 (D 2)* INT0
// (D 14) PA7 10| |11 PB7 (D 15)
// +----+
//
// * indicates PWM pin.
// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing)
const uint16_t PROGMEM port_to_mode_PGM[] =
{
NOT_A_PORT,
(uint16_t)&DDRA,
(uint16_t)&DDRB,
};
const uint16_t PROGMEM port_to_output_PGM[] =
{
NOT_A_PORT,
(uint16_t)&PORTA,
(uint16_t)&PORTB,
};
const uint16_t PROGMEM port_to_input_PGM[] =
{
NOT_A_PORT,
(uint16_t)&PINA,
(uint16_t)&PINB,
};
const uint8_t PROGMEM digital_pin_to_port_PGM[] =
{
PB, /* 0 */
PB,
PB, /* 2 */
PB, /* 3 */
PB, /* 4 */
PA,
PA,
PA,
PA,
PA,
PA, /* 10 */
PA,
PA,
PB, /* 15 */
};
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
{
_BV(0), /* 0 */
_BV(1),
_BV(2), /* 2 */
_BV(3), /* 3 */
_BV(6), /* 4 */
_BV(7),
_BV(0),
_BV(1),
_BV(2),
_BV(3),
_BV(4), /* 10 */
_BV(5),
_BV(6),
_BV(7),
};
const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
{
TIMER1A,
TIMER1B,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
};
#endif
#endif
//Old code, just here for temporary backup until I decide it is not needed.
//WARNING, if using software, RX must be on a pin which has a Pin change interrupt <= 7 (e.g. PCINT6, or PCINT1, but not PCINT8)
/*#define USE_SOFTWARE_SERIAL 1
//These are set to match Optiboot pins.
#define SOFTWARE_SERIAL_PORT PORTB
#define SOFTWARE_SERIAL_TX 0
#define SOFTWARE_SERIAL_PIN PINB
#define SOFTWARE_SERIAL_RX 1*/