diff --git a/README.md b/README.md index 2be48ca..9a6e785 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Following the [installation guide](http://hlt.media.mit.edu/?p=1695) to install Also check out this video from Make which explains how to setup and use this core. -http://www.youtube.com/watch?v=30rPt802n1k +[How-To: Shrinkify Your Arduino Projects](http://www.youtube.com/watch?v=30rPt802n1k) Which branch to use? -------------------- diff --git a/variants/tiny14/pins_arduino.h b/variants/tiny14/pins_arduino.h index 1a5711d..7b1655f 100755 --- a/variants/tiny14/pins_arduino.h +++ b/variants/tiny14/pins_arduino.h @@ -23,6 +23,7 @@ Modified 28-08-2009 for attiny84 R.Wiersma Modified 09-10-2009 for attiny45 A.Saporetti + Modified 05-09-2017 for attiny85 A.Neimar */ #ifndef Pins_Arduino_h @@ -42,20 +43,62 @@ // PWM (D 6) PA6 7| |8 PA5 (D 5) PWM // +----+ -const static uint8_t A0 = 0; -const static uint8_t A1 = 1; -const static uint8_t A2 = 2; -const static uint8_t A3 = 3; -const static uint8_t A4 = 4; -const static uint8_t A5 = 5; -const static uint8_t A6 = 6; -const static uint8_t A7 = 7; + +#define NUM_DIGITAL_PINS 12 +#define NUM_ANALOG_INPUTS 8 +#define analogInputToDigitalPin(p) ((p >= 0) && (p <= 7) ? (p) : NOT_AN_INTERRUPT) + +#define digitalPinHasPWM(p) ((p) >= 5 && (p) <= 8) + +#define PIN_SPI_SS (3) +#define PIN_SPI_MOSI (6) +#define PIN_SPI_MISO (5) +#define PIN_SPI_SCK (4) + +static const uint8_t SS = PIN_SPI_SS; +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +#define PIN_SERIAL_RX (9) +#define PIN_SERIAL_TX (10) + +static const uint8_t RX = PIN_SERIAL_RX; +static const uint8_t TX = PIN_SERIAL_TX; + +#define PIN_WIRE_SDA (6) +#define PIN_WIRE_SCL (4) + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + +#define PIN_A0 (0) +#define PIN_A1 (1) +#define PIN_A2 (2) +#define PIN_A3 (3) +#define PIN_A4 (4) +#define PIN_A5 (5) +#define PIN_A6 (6) +#define PIN_A7 (7) + +const static uint8_t A0 = PIN_A0; +const static uint8_t A1 = PIN_A1; +const static uint8_t A2 = PIN_A2; +const static uint8_t A3 = PIN_A3; +const static uint8_t A4 = PIN_A4; +const static uint8_t A5 = PIN_A5; +const static uint8_t A6 = PIN_A6; +const static uint8_t A7 = PIN_A7; #define digitalPinToPCICR(p) ( ((p) >= 0 && (p) <= 10) ? (&GIMSK) : ((uint8_t *)0) ) #define digitalPinToPCICRbit(p) ( ((p) <= 7) ? PCIE0 : PCIE1 ) #define digitalPinToPCMSK(p) ( ((p) <= 7) ? (&PCMSK0) : (((p) <= 10) ? (&PCMSK1) : ((uint8_t *)0)) ) #define digitalPinToPCMSKbit(p) ( ((p) <= 7) ? (p) : (10 - (p)) ) +#define digitalPinToInterrupt(p) ((p) == 8 ? 0 : NOT_AN_INTERRUPT) + +#define analogPinToChannel(P) ((p) <= 7 ? (p) : (p) - 8 ) + #ifdef ARDUINO_MAIN // these arrays map port names (e.g. port B) to the @@ -127,6 +170,7 @@ const uint8_t PROGMEM digital_pin_to_timer_PGM[] = NOT_ON_TIMER, }; + #endif #endif diff --git a/variants/tiny8/pins_arduino.h b/variants/tiny8/pins_arduino.h index 09fd0aa..1af2110 100755 --- a/variants/tiny8/pins_arduino.h +++ b/variants/tiny8/pins_arduino.h @@ -23,6 +23,7 @@ Modified 28-08-2009 for attiny84 R.Wiersma Modified 09-10-2009 for attiny45 A.Saporetti + Modified 04-09-2017 for attiny85 A.deOliveira */ #ifndef Pins_Arduino_h @@ -30,95 +31,149 @@ #include -// ATMEL ATTINY45 / ARDUINO -// -// +-\/-+ -// Ain0 (D 5) PB5 1| |8 Vcc -// Ain3 (D 3) PB3 2| |7 PB2 (D 2) Ain1 -// Ain2 (D 4) PB4 3| |6 PB1 (D 1) pwm1 -// GND 4| |5 PB0 (D 0) pwm0 -// +----+ +#define NUM_DIGITAL_PINS 6 +#define NUM_ANALOG_INPUTS 4 + +#define PIN_SPI_SS (3) +#define PIN_SPI_MOSI (0) +#define PIN_SPI_MISO (1) +#define PIN_SPI_SCK (2) + +static const uint8_t SS = PIN_SPI_SS; +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +#define PIN_SERIAL_RX (3) +#define PIN_SERIAL_TX (4) + +static const uint8_t RX = PIN_SERIAL_RX; +static const uint8_t TX = PIN_SERIAL_TX; + +#define PIN_WIRE_SDA (0) +#define PIN_WIRE_SCL (2) + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + +// Referentes a ADCx +#define PIN_A0 (0) +#define PIN_A1 (1) +#define PIN_A2 (2) +#define PIN_A3 (3) -static const uint8_t A0 = 6; -static const uint8_t A1 = 7; -static const uint8_t A2 = 8; -static const uint8_t A3 = 9; +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; +static const uint8_t A3 = PIN_A3; + +// Referentes a PBx, pino digital + +#define PIN_PB0 (0) +#define PIN_PB1 (1) +#define PIN_PB2 (2) +#define PIN_PB3 (3) +#define PIN_PB4 (4) +#define PIN_PB5 (5) + +static const uint8_t D0 = PIN_PB0; +static const uint8_t D1 = PIN_PB1; +static const uint8_t D2 = PIN_PB2; +static const uint8_t D3 = PIN_PB3; +static const uint8_t D4 = PIN_PB4; +static const uint8_t D5 = PIN_PB5; + +#define analogInputToDigitalPin(p) (((p) == A1 ? D2 : \ + ((p) == A3 ? D3 : \ + ((p) == A2 ? D4 : \ + ((p) == A0 ? D5 : NOT_AN_INTERRUPT))))) + +#define digitalPinHasPWM(p) ((p) == D0 || (p) == D1 || (p) == D3 || (p) == D4) #define digitalPinToPCICR(p) ( ((p) >= 0 && (p) <= 4) ? (&GIMSK) : ((uint8_t *)0) ) #define digitalPinToPCICRbit(p) ( PCIE ) #define digitalPinToPCMSK(p) ( ((p) <= 4) ? (&PCMSK) : ((uint8_t *)0) ) #define digitalPinToPCMSKbit(p) ( (p) ) -#define analogPinToChannel(p) ( (p) < 6 ? (p) : (p) - 6 ) +#define digitalPinToInterrupt(p) ((p) == D2 ? 0 : NOT_AN_INTERRUPT) #define TCCR1A GTCCR #ifdef ARDUINO_MAIN +// ATMEL ATTINY45 / ARDUINO +// +// +-\/-+ +// ADC0 (D 5) PB5 1| |8 Vcc +// ADC3 (D 3) PB3 2| |7 PB2 (D 2) ADC1 +// ADc2 (D 4) PB4 3| |6 PB1 (D 1) AIN1, pwm1 +// GND 4| |5 PB0 (D 0) AIN0, pwm0 +// +----+ + void initVariant() { - GTCCR |= (1 << PWM1B); + GTCCR |= (1 << PWM1B); } // 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 uint16_t PROGMEM port_to_mode_PGM[] = { - NOT_A_PORT, - NOT_A_PORT, - (uint16_t) &DDRB, + NOT_A_PORT, + NOT_A_PORT, + (uint16_t) &DDRB, }; const uint16_t PROGMEM port_to_output_PGM[] = { - NOT_A_PORT, - NOT_A_PORT, - (uint16_t) &PORTB, + NOT_A_PORT, + NOT_A_PORT, + (uint16_t) &PORTB, }; const uint16_t PROGMEM port_to_input_PGM[] = { - NOT_A_PIN, - NOT_A_PIN, - (uint16_t) &PINB, + NOT_A_PIN, + NOT_A_PIN, + (uint16_t) &PINB, }; const uint8_t PROGMEM digital_pin_to_port_PGM[] = { - PB, /* 0 */ - PB, - PB, - PB, - PB, - PB, // 5 - PB, // A0 - PB, - PB, - PB, // A4 + PB, /* 0 */ + PB, + PB, + PB, + PB, + PB, // 5 + PB, // A0 + PB, + PB, + PB, // A4 }; 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), - _BV(5), - _BV(2), - _BV(4), - _BV(3), + _BV(0), /* 0, port B */ + _BV(1), + _BV(2), + _BV(3), /* 3 port B */ + _BV(4), + _BV(5), + _BV(5), // A0 + _BV(2), // A1 + _BV(4), // A2 + _BV(3), // A3 }; const uint8_t PROGMEM digital_pin_to_timer_PGM[] = { - TIMER0A, /* OC0A */ - TIMER0B, - NOT_ON_TIMER, - NOT_ON_TIMER, - TIMER1B, - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, + TIMER0A, /* OC0A */ + TIMER0B, + NOT_ON_TIMER, + NOT_ON_TIMER, + TIMER1B, + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, }; #endif