arduino-mighty-1284p-0~svn20130430.orig/0000755000175000017500000000000012140060725016761 5ustar shevekshevekarduino-mighty-1284p-0~svn20130430.orig/bootloaders/0000755000175000017500000000000012137772502021307 5ustar shevekshevekarduino-mighty-1284p-0~svn20130430.orig/bootloaders/standard/0000755000175000017500000000000012140055246023100 5ustar shevekshevekarduino-mighty-1284p-0~svn20130430.orig/bootloaders/standard/ATmegaBOOT.c0000644000175000017500000007653612137772502025116 0ustar shevekshevek/**********************************************************/ /* Serial Bootloader for Atmel megaAVR Controllers */ /* */ /* tested with ATmega8, ATmega128 and ATmega168 */ /* should work with other mega's, see code for details */ /* */ /* ATmegaBOOT.c */ /* */ /* */ /* 20090308: integrated Mega changes into main bootloader */ /* source by D. Mellis */ /* 20080930: hacked for Arduino Mega (with the 1280 */ /* processor, backwards compatible) */ /* by D. Cuartielles */ /* 20070626: hacked for Arduino Diecimila (which auto- */ /* resets when a USB connection is made to it) */ /* by D. Mellis */ /* 20060802: hacked for Arduino by D. Cuartielles */ /* based on a previous hack by D. Mellis */ /* and D. Cuartielles */ /* */ /* Monitor and debug functions were added to the original */ /* code by Dr. Erik Lins, chip45.com. (See below) */ /* */ /* Thanks to Karl Pitrich for fixing a bootloader pin */ /* problem and more informative LED blinking! */ /* */ /* For the latest version see: */ /* http://www.chip45.com/ */ /* */ /* ------------------------------------------------------ */ /* */ /* based on stk500boot.c */ /* Copyright (c) 2003, Jason P. Kyle */ /* All rights reserved. */ /* see avr1.org for original file and information */ /* */ /* This program is free software; you can redistribute it */ /* and/or modify it under the terms of the GNU General */ /* Public License as published by the Free Software */ /* Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /* This program 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 General Public */ /* License for more details. */ /* */ /* You should have received a copy of the GNU General */ /* Public License along with this program; if not, write */ /* to the Free Software Foundation, Inc., */ /* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* */ /* Licence can be viewed at */ /* http://www.fsf.org/licenses/gpl.txt */ /* */ /* Target = Atmel AVR m128,m64,m32,m16,m8,m162,m163,m169, */ /* m8515,m8535. ATmega161 has a very small boot block so */ /* isn't supported. */ /* */ /* Tested with m168 */ /**********************************************************/ /* $Id$ */ /* some includes */ #include #include #include #include #include #include /* the current avr-libc eeprom functions do not support the ATmega168 */ /* own eeprom write/read functions are used instead */ #if !defined(__AVR_ATmega168__) || !defined(__AVR_ATmega328P__) #include #endif /* Use the F_CPU defined in Makefile */ /* 20060803: hacked by DojoCorp */ /* 20070626: hacked by David A. Mellis to decrease waiting time for auto-reset */ /* set the waiting time for the bootloader */ /* get this from the Makefile instead */ /* #define MAX_TIME_COUNT (F_CPU>>4) */ /* 20070707: hacked by David A. Mellis - after this many errors give up and launch application */ #define MAX_ERROR_COUNT 5 #define NUM_LED_FLASHES 3 /* set the UART baud rate */ /* 20060803: hacked by DojoCorp */ //#define BAUD_RATE 115200 #ifndef BAUD_RATE #define BAUD_RATE 19200 #endif /* SW_MAJOR and MINOR needs to be updated from time to time to avoid warning message from AVR Studio */ /* never allow AVR Studio to do an update !!!! */ #define HW_VER 0x02 #define SW_MAJOR 0x01 #define SW_MINOR 0x10 /* Adjust to suit whatever pin your hardware uses to enter the bootloader */ /* ATmega128 has two UARTS so two pins are used to enter bootloader and select UART */ /* ATmega1280 has four UARTS, but for Arduino Mega, we will only use RXD0 to get code */ /* BL0... means UART0, BL1... means UART1 */ #ifdef __AVR_ATmega128__ #define BL_DDR DDRF #define BL_PORT PORTF #define BL_PIN PINF #define BL0 PINF7 #define BL1 PINF6 #elif defined __AVR_ATmega1280__ /* we just don't do anything for the MEGA and enter bootloader on reset anyway*/ #elif defined __AVR_ATmega1284P__ #else /* other ATmegas have only one UART, so only one pin is defined to enter bootloader */ #define BL_DDR DDRD #define BL_PORT PORTD #define BL_PIN PIND #define BL PIND6 #endif /* onboard LED is used to indicate, that the bootloader was entered (3x flashing) */ /* if monitor functions are included, LED goes on after monitor was entered */ #if defined __AVR_ATmega128__ || defined __AVR_ATmega1280__ /* Onboard LED is connected to pin PB7 (e.g. Crumb128, PROBOmega128, Savvy128, Arduino Mega) */ #define LED_DDR DDRB #define LED_PORT PORTB #define LED_PIN PINB #define LED PINB7 #elif defined __AVR_ATmega1284P__ #define LED_DDR DDRB #define LED_PORT PORTB #define LED_PIN PINB #define LED PINB0 #else /* Onboard LED is connected to pin PB5 in Arduino NG, Diecimila, and Duomilanuove */ /* other boards like e.g. Crumb8, Crumb168 are using PB2 */ #define LED_DDR DDRB #define LED_PORT PORTB #define LED_PIN PINB #define LED PINB5 #endif /* monitor functions will only be compiled when using ATmega128, due to bootblock size constraints */ #if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) #define MONITOR 1 #endif /* define various device id's */ /* manufacturer byte is always the same */ #define SIG1 0x1E // Yep, Atmel is the only manufacturer of AVR micros. Single source :( #if defined __AVR_ATmega1280__ #define SIG2 0x97 #define SIG3 0x03 #define PAGE_SIZE 0x80U //128 words #elif defined __AVR_ATmega1284P__ #define SIG2 0x97 #define SIG3 0x05 #define PAGE_SIZE 0x080U //128 words #elif defined __AVR_ATmega1281__ #define SIG2 0x97 #define SIG3 0x04 #define PAGE_SIZE 0x80U //128 words #elif defined __AVR_ATmega128__ #define SIG2 0x97 #define SIG3 0x02 #define PAGE_SIZE 0x80U //128 words #elif defined __AVR_ATmega64__ #define SIG2 0x96 #define SIG3 0x02 #define PAGE_SIZE 0x80U //128 words #elif defined __AVR_ATmega32__ #define SIG2 0x95 #define SIG3 0x02 #define PAGE_SIZE 0x40U //64 words #elif defined __AVR_ATmega16__ #define SIG2 0x94 #define SIG3 0x03 #define PAGE_SIZE 0x40U //64 words #elif defined __AVR_ATmega8__ #define SIG2 0x93 #define SIG3 0x07 #define PAGE_SIZE 0x20U //32 words #elif defined __AVR_ATmega88__ #define SIG2 0x93 #define SIG3 0x0a #define PAGE_SIZE 0x20U //32 words #elif defined __AVR_ATmega168__ #define SIG2 0x94 #define SIG3 0x06 #define PAGE_SIZE 0x40U //64 words #elif defined __AVR_ATmega328P__ #define SIG2 0x95 #define SIG3 0x0F #define PAGE_SIZE 0x40U //64 words #elif defined __AVR_ATmega162__ #define SIG2 0x94 #define SIG3 0x04 #define PAGE_SIZE 0x40U //64 words #elif defined __AVR_ATmega163__ #define SIG2 0x94 #define SIG3 0x02 #define PAGE_SIZE 0x40U //64 words #elif defined __AVR_ATmega169__ #define SIG2 0x94 #define SIG3 0x05 #define PAGE_SIZE 0x40U //64 words #elif defined __AVR_ATmega8515__ #define SIG2 0x93 #define SIG3 0x06 #define PAGE_SIZE 0x20U //32 words #elif defined __AVR_ATmega8535__ #define SIG2 0x93 #define SIG3 0x08 #define PAGE_SIZE 0x20U //32 words #endif /* function prototypes */ void putch(char); char getch(void); void getNch(uint8_t); void byte_response(uint8_t); void nothing_response(void); char gethex(void); void puthex(char); void flash_led(uint8_t); /* some variables */ union address_union { uint16_t word; uint8_t byte[2]; } address; union length_union { uint16_t word; uint8_t byte[2]; } length; struct flags_struct { unsigned eeprom : 1; unsigned rampz : 1; } flags; uint8_t buff[256]; uint8_t address_high; uint8_t pagesz=0x80; uint8_t i; uint8_t bootuart = 0; uint8_t error_count = 0; void (*app_start)(void) = 0x0000; /* main program starts here */ int main(void) { uint8_t ch,ch2; uint16_t w; #ifdef WATCHDOG_MODS ch = MCUSR; MCUSR = 0; WDTCSR |= _BV(WDCE) | _BV(WDE); WDTCSR = 0; // Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot. if (! (ch & _BV(EXTRF))) // if its a not an external reset... app_start(); // skip bootloader #else asm volatile("nop\n\t"); #endif /* set pin direction for bootloader pin and enable pullup */ /* for ATmega128, two pins need to be initialized */ #ifdef __AVR_ATmega128__ BL_DDR &= ~_BV(BL0); BL_DDR &= ~_BV(BL1); BL_PORT |= _BV(BL0); BL_PORT |= _BV(BL1); #else /* We run the bootloader regardless of the state of this pin. Thus, don't put it in a different state than the other pins. --DAM, 070709 This also applies to Arduino Mega -- DC, 080930 BL_DDR &= ~_BV(BL); BL_PORT |= _BV(BL); */ #endif #ifdef __AVR_ATmega128__ /* check which UART should be used for booting */ if(bit_is_clear(BL_PIN, BL0)) { bootuart = 1; } else if(bit_is_clear(BL_PIN, BL1)) { bootuart = 2; } #endif #if defined __AVR_ATmega1280__ || defined __AVR_ATmega1284P__ /* the mega1280 chip has four serial ports ... we could eventually use any of them, or not? */ /* however, we don't wanna confuse people, to avoid making a mess, we will stick to RXD0, TXD0 */ bootuart = 1; #endif /* check if flash is programmed already, if not start bootloader anyway */ if(pgm_read_byte_near(0x0000) != 0xFF) { #ifdef __AVR_ATmega128__ /* no UART was selected, start application */ if(!bootuart) { app_start(); } #else /* check if bootloader pin is set low */ /* we don't start this part neither for the m8, nor m168 */ //if(bit_is_set(BL_PIN, BL)) { // app_start(); // } #endif } #ifdef __AVR_ATmega128__ /* no bootuart was selected, default to uart 0 */ if(!bootuart) { bootuart = 1; } #endif /* initialize UART(s) depending on CPU defined */ #if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1284P__) if(bootuart == 1) { UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1); UBRR0H = (F_CPU/(BAUD_RATE*16L)-1) >> 8; UCSR0A = 0x00; UCSR0C = 0x06; UCSR0B = _BV(TXEN0)|_BV(RXEN0); } if(bootuart == 2) { UBRR1L = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1); UBRR1H = (F_CPU/(BAUD_RATE*16L)-1) >> 8; UCSR1A = 0x00; UCSR1C = 0x06; UCSR1B = _BV(TXEN1)|_BV(RXEN1); } #elif defined __AVR_ATmega163__ UBRR = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1); UBRRHI = (F_CPU/(BAUD_RATE*16L)-1) >> 8; UCSRA = 0x00; UCSRB = _BV(TXEN)|_BV(RXEN); #elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) #ifdef DOUBLE_SPEED UCSR0A = (1<> 8; #else UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1); UBRR0H = (F_CPU/(BAUD_RATE*16L)-1) >> 8; #endif UCSR0B = (1<>8; // set baud rate UBRRL = (((F_CPU/BAUD_RATE)/16)-1); UCSRB = (1<> 8; UCSRA = 0x00; UCSRC = 0x06; UCSRB = _BV(TXEN)|_BV(RXEN); #endif #if defined __AVR_ATmega1280__ /* Enable internal pull-up resistor on pin D0 (RX), in order to supress line noise that prevents the bootloader from timing out (DAM: 20070509) */ /* feature added to the Arduino Mega --DC: 080930 */ DDRE &= ~_BV(PINE0); PORTE |= _BV(PINE0); #endif /* set LED pin as output */ LED_DDR |= _BV(LED); /* flash onboard LED to signal entering of bootloader */ #if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1284P__) // 4x for UART0, 5x for UART1 flash_led(NUM_LED_FLASHES + bootuart); #else flash_led(NUM_LED_FLASHES); #endif /* 20050803: by DojoCorp, this is one of the parts provoking the system to stop listening, cancelled from the original */ //putch('\0'); /* forever loop */ for (;;) { /* get character from UART */ ch = getch(); /* A bunch of if...else if... gives smaller code than switch...case ! */ /* Hello is anyone home ? */ if(ch=='0') { nothing_response(); } /* Request programmer ID */ /* Not using PROGMEM string due to boot block in m128 being beyond 64kB boundry */ /* Would need to selectively manipulate RAMPZ, and it's only 9 characters anyway so who cares. */ else if(ch=='1') { if (getch() == ' ') { putch(0x14); putch('A'); putch('V'); putch('R'); putch(' '); putch('I'); putch('S'); putch('P'); putch(0x10); } else { if (++error_count == MAX_ERROR_COUNT) app_start(); } } /* AVR ISP/STK500 board commands DON'T CARE so default nothing_response */ else if(ch=='@') { ch2 = getch(); if (ch2>0x85) getch(); nothing_response(); } /* AVR ISP/STK500 board requests */ else if(ch=='A') { ch2 = getch(); if(ch2==0x80) byte_response(HW_VER); // Hardware version else if(ch2==0x81) byte_response(SW_MAJOR); // Software major version else if(ch2==0x82) byte_response(SW_MINOR); // Software minor version else if(ch2==0x98) byte_response(0x03); // Unknown but seems to be required by avr studio 3.56 else byte_response(0x00); // Covers various unnecessary responses we don't care about } /* Device Parameters DON'T CARE, DEVICE IS FIXED */ else if(ch=='B') { getNch(20); nothing_response(); } /* Parallel programming stuff DON'T CARE */ else if(ch=='E') { getNch(5); nothing_response(); } /* P: Enter programming mode */ /* R: Erase device, don't care as we will erase one page at a time anyway. */ else if(ch=='P' || ch=='R') { nothing_response(); } /* Leave programming mode */ else if(ch=='Q') { nothing_response(); #ifdef WATCHDOG_MODS // autoreset via watchdog (sneaky!) WDTCSR = _BV(WDE); while (1); // 16 ms #endif } /* Set address, little endian. EEPROM in bytes, FLASH in words */ /* Perhaps extra address bytes may be added in future to support > 128kB FLASH. */ /* This might explain why little endian was used here, big endian used everywhere else. */ else if(ch=='U') { address.byte[0] = getch(); address.byte[1] = getch(); nothing_response(); } /* Universal SPI programming command, disabled. Would be used for fuses and lock bits. */ else if(ch=='V') { if (getch() == 0x30) { getch(); ch = getch(); getch(); if (ch == 0) { byte_response(SIG1); } else if (ch == 1) { byte_response(SIG2); } else { byte_response(SIG3); } } else { getNch(3); byte_response(0x00); } } /* Write memory, length is big endian and is in bytes */ else if(ch=='d') { length.byte[1] = getch(); length.byte[0] = getch(); flags.eeprom = 0; if (getch() == 'E') flags.eeprom = 1; for (w=0; w127) address_high = 0x01; //Only possible with m128, m256 will need 3rd address byte. FIXME else address_high = 0x00; #if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega1284P__) RAMPZ = address_high; #endif address.word = address.word << 1; //address * 2 -> byte location /* if ((length.byte[0] & 0x01) == 0x01) length.word++; //Even up an odd number of bytes */ if ((length.byte[0] & 0x01)) length.word++; //Even up an odd number of bytes cli(); //Disable interrupts, just to be sure #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega1284P__) while(bit_is_set(EECR,EEPE)); //Wait for previous EEPROM writes to complete #else while(bit_is_set(EECR,EEWE)); //Wait for previous EEPROM writes to complete #endif asm volatile( "clr r17 \n\t" //page_word_count "lds r30,address \n\t" //Address of FLASH location (in bytes) "lds r31,address+1 \n\t" "ldi r28,lo8(buff) \n\t" //Start of buffer array in RAM "ldi r29,hi8(buff) \n\t" "lds r24,length \n\t" //Length of data to be written (in bytes) "lds r25,length+1 \n\t" "length_loop: \n\t" //Main loop, repeat for number of words in block "cpi r17,0x00 \n\t" //If page_word_count=0 then erase page "brne no_page_erase \n\t" "wait_spm1: \n\t" "lds r16,%0 \n\t" //Wait for previous spm to complete "andi r16,1 \n\t" "cpi r16,1 \n\t" "breq wait_spm1 \n\t" "ldi r16,0x03 \n\t" //Erase page pointed to by Z "sts %0,r16 \n\t" "spm \n\t" #ifdef __AVR_ATmega163__ ".word 0xFFFF \n\t" "nop \n\t" #endif "wait_spm2: \n\t" "lds r16,%0 \n\t" //Wait for previous spm to complete "andi r16,1 \n\t" "cpi r16,1 \n\t" "breq wait_spm2 \n\t" "ldi r16,0x11 \n\t" //Re-enable RWW section "sts %0,r16 \n\t" "spm \n\t" #ifdef __AVR_ATmega163__ ".word 0xFFFF \n\t" "nop \n\t" #endif "no_page_erase: \n\t" "ld r0,Y+ \n\t" //Write 2 bytes into page buffer "ld r1,Y+ \n\t" "wait_spm3: \n\t" "lds r16,%0 \n\t" //Wait for previous spm to complete "andi r16,1 \n\t" "cpi r16,1 \n\t" "breq wait_spm3 \n\t" "ldi r16,0x01 \n\t" //Load r0,r1 into FLASH page buffer "sts %0,r16 \n\t" "spm \n\t" "inc r17 \n\t" //page_word_count++ "cpi r17,%1 \n\t" "brlo same_page \n\t" //Still same page in FLASH "write_page: \n\t" "clr r17 \n\t" //New page, write current one first "wait_spm4: \n\t" "lds r16,%0 \n\t" //Wait for previous spm to complete "andi r16,1 \n\t" "cpi r16,1 \n\t" "breq wait_spm4 \n\t" #ifdef __AVR_ATmega163__ "andi r30,0x80 \n\t" // m163 requires Z6:Z1 to be zero during page write #endif "ldi r16,0x05 \n\t" //Write page pointed to by Z "sts %0,r16 \n\t" "spm \n\t" #ifdef __AVR_ATmega163__ ".word 0xFFFF \n\t" "nop \n\t" "ori r30,0x7E \n\t" // recover Z6:Z1 state after page write (had to be zero during write) #endif "wait_spm5: \n\t" "lds r16,%0 \n\t" //Wait for previous spm to complete "andi r16,1 \n\t" "cpi r16,1 \n\t" "breq wait_spm5 \n\t" "ldi r16,0x11 \n\t" //Re-enable RWW section "sts %0,r16 \n\t" "spm \n\t" #ifdef __AVR_ATmega163__ ".word 0xFFFF \n\t" "nop \n\t" #endif "same_page: \n\t" "adiw r30,2 \n\t" //Next word in FLASH "sbiw r24,2 \n\t" //length-2 "breq final_write \n\t" //Finished "rjmp length_loop \n\t" "final_write: \n\t" "cpi r17,0 \n\t" "breq block_done \n\t" "adiw r24,2 \n\t" //length+2, fool above check on length after short page write "rjmp write_page \n\t" "block_done: \n\t" "clr __zero_reg__ \n\t" //restore zero register #if defined __AVR_ATmega168__ || __AVR_ATmega328P__ || __AVR_ATmega128__ || __AVR_ATmega1280__ || __AVR_ATmega1281__ || __AVR_ATmega1284P__ : "=m" (SPMCSR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31" #else : "=m" (SPMCR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31" #endif ); /* Should really add a wait for RWW section to be enabled, don't actually need it since we never */ /* exit the bootloader without a power cycle anyhow */ } putch(0x14); putch(0x10); } else { if (++error_count == MAX_ERROR_COUNT) app_start(); } } /* Read memory block mode, length is big endian. */ else if(ch=='t') { length.byte[1] = getch(); length.byte[0] = getch(); #if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1284P__) if (address.word>0x7FFF) flags.rampz = 1; // No go with m256, FIXME else flags.rampz = 0; #endif address.word = address.word << 1; // address * 2 -> byte location if (getch() == 'E') flags.eeprom = 1; else flags.eeprom = 0; if (getch() == ' ') // Command terminator { putch(0x14); for (w=0; w < length.word; w++) // Can handle odd and even lengths okay { if (flags.eeprom) // Byte access EEPROM read { #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) while(EECR & (1<= 'a') { return (a - 'a' + 0x0a); } else if(a >= '0') { return(a - '0'); } return a; } char gethex(void) { return (gethexnib() << 4) + gethexnib(); } void puthex(char ch) { char ah; ah = ch >> 4; if(ah >= 0x0a) { ah = ah - 0x0a + 'a'; } else { ah += '0'; } ch &= 0x0f; if(ch >= 0x0a) { ch = ch - 0x0a + 'a'; } else { ch += '0'; } putch(ah); putch(ch); } void putch(char ch) { #if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1284P__) if(bootuart == 1) { while (!(UCSR0A & _BV(UDRE0))); UDR0 = ch; } else if (bootuart == 2) { while (!(UCSR1A & _BV(UDRE1))); UDR1 = ch; } #elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) while (!(UCSR0A & _BV(UDRE0))); UDR0 = ch; #else /* m8,16,32,169,8515,8535,163 */ while (!(UCSRA & _BV(UDRE))); UDR = ch; #endif } char getch(void) { #if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1284P__) uint32_t count = 0; if(bootuart == 1) { while(!(UCSR0A & _BV(RXC0))) { /* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/ /* HACKME:: here is a good place to count times*/ count++; if (count > MAX_TIME_COUNT) app_start(); } return UDR0; } else if(bootuart == 2) { while(!(UCSR1A & _BV(RXC1))) { /* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/ /* HACKME:: here is a good place to count times*/ count++; if (count > MAX_TIME_COUNT) app_start(); } return UDR1; } return 0; #elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) uint32_t count = 0; while(!(UCSR0A & _BV(RXC0))) { /* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/ /* HACKME:: here is a good place to count times*/ count++; if (count > MAX_TIME_COUNT) app_start(); } return UDR0; #else /* m8,16,32,169,8515,8535,163 */ uint32_t count = 0; while(!(UCSRA & _BV(RXC))) { /* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/ /* HACKME:: here is a good place to count times*/ count++; if (count > MAX_TIME_COUNT) app_start(); } return UDR; #endif } void getNch(uint8_t count) { while(count--) { #if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1284P__) if(bootuart == 1) { while(!(UCSR0A & _BV(RXC0))); UDR0; } else if(bootuart == 2) { while(!(UCSR1A & _BV(RXC1))); UDR1; } #elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) getch(); #else /* m8,16,32,169,8515,8535,163 */ /* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/ //while(!(UCSRA & _BV(RXC))); //UDR; getch(); // need to handle time out #endif } } void byte_response(uint8_t val) { if (getch() == ' ') { putch(0x14); putch(val); putch(0x10); } else { if (++error_count == MAX_ERROR_COUNT) app_start(); } } void nothing_response(void) { if (getch() == ' ') { putch(0x14); putch(0x10); } else { if (++error_count == MAX_ERROR_COUNT) app_start(); } } void flash_led(uint8_t count) { while (count--) { LED_PORT |= _BV(LED); _delay_ms(100); LED_PORT &= ~_BV(LED); _delay_ms(100); } } /* end of file ATmegaBOOT.c */ arduino-mighty-1284p-0~svn20130430.orig/bootloaders/standard/ATmegaBOOT_1284P_8MHz.hex0000644000175000017500000001201512137772502027102 0ustar shevekshevek:020000021000EC :10F800000C9446FC0C9465FC0C9465FC0C9465FC13 :10F810000C9465FC0C9465FC0C9465FC0C9465FCE4 :10F820000C9465FC0C9465FC0C9465FC0C9465FCD4 :10F830000C9465FC0C9465FC0C9465FC0C9465FCC4 :10F840000C9465FC0C9465FC0C9465FC0C9465FCB4 :10F850000C9465FC0C9465FC0C9465FC0C9465FCA4 :10F860000C9465FC0C9465FC0C9465FC0C9465FC94 :10F870000C9465FC0C9465FC0C9465FC0C9465FC84 :10F880000C9465FC0C9465FC0C9465FC11241FBE63 :10F89000CFEFD0E4DEBFCDBF11E0A0E0B1E0E6E005 :10F8A000FFEF01E00BBF02C007900D92A230B1073D :10F8B000D9F712E0A2E0B1E001C01D92AD30B1076E :10F8C000E1F70E945FFD0C9481FF0C9400FC909185 :10F8D0000201913039F49091C00095FFFCCF8093E4 :10F8E000C6000895923031F49091C80095FFFCCF86 :10F8F0008093CE0008951F93982F95959595959593 :10F900009595905D182F1F701A3014F0195A01C088 :10F91000105D892F0E9467FC812F0E9467FC1F9158 :10F920000895EF92FF920F931F938091020181300F :10F93000F1F4EE24FF24870113C00894E11CF11CAC :10F94000011D111D81E0E81689E0F8068DE3080726 :10F9500080E0180728F0E0910401F0910501099575 :10F960008091C00087FFE9CF8091C60021C082301E :10F97000F1F4EE24FF24870113C00894E11CF11C6C :10F98000011D111D81E0E81689E0F8068DE30807E6 :10F9900080E0180728F0E0910401F0910501099535 :10F9A0008091C80087FFE9CF8091CE0001C080E040 :10F9B0001F910F91FF90EF9008951F930E9491FC6B :10F9C000182F0E9467FC113614F0175503C010332E :10F9D0000CF01053812F1F9108951F930E94DDFC9E :10F9E000182F0E94DDFC1295107F810F1F91089542 :10F9F0009091020112C0913039F42091C00027FF8C :10FA0000FCCF2091C60008C0923031F42091C8008C :10FA100027FFFCCF2091CE008150882361F7089505 :10FA20001F93182F0E9491FC803251F484E10E94B0 :10FA300067FC812F0E9467FC80E10E9467FC0CC07C :10FA4000809103018F5F80930301853029F4E09159 :10FA50000401F091050109951F9108950E9491FC00 :10FA6000803239F484E10E9467FC80E10E9467FCE7 :10FA70000895809103018F5F80930301853029F4FD :10FA8000E0910401F09105010995089515C0289AA7 :10FA90002FEF30E742E0215030404040E1F700C016 :10FAA000000028982FEF30E742E0215030404040DE :10FAB000E1F700C000008150882349F70895BF9204 :10FAC000CF92DF92EF92FF920F931F93CF93DF932A :10FAD00094B714BE8091600088618093600010929A :10FAE000600091FD05C0E0910401F09105010995C8 :10FAF00081E08093020180E18093C4001092C500F0 :10FB00001092C00086E08093C20088E18093C1001B :10FB1000209A84E00E9446FDBB24B3940E9491FC8D :10FB2000803309F441C08133E1F40E9491FC8032BA :10FB300009F0C3C184E10E9467FC81E40E9467FC74 :10FB400086E50E9467FC82E50E9467FC80E20E94D5 :10FB500067FC89E40E9467FC83E50E9467FC80E5FE :10FB600029C1803439F40E9491FC8638E8F00E9463 :10FB700091FC1AC0813499F40E9491FC803811F4F0 :10FB800082E098C1813811F481E094C1823811F487 :10FB900080E190C1883909F08CC183E08BC1823447 :10FBA00031F484E10E94F8FC0E942EFDB7CF853429 :10FBB00011F485E0F7CF8035B9F38235A9F38135AB :10FBC00031F40E942EFD88E080936000FFCF8535E0 :10FBD00049F40E9491FC809306010E9491FC80935D :10FBE0000701E2CF8635C9F40E9491FC803389F485 :10FBF0000E9491FC0E9491FC082F0E9491FC00231E :10FC000011F48EE157C1013011F487E953C185E049 :10FC100051C183E00E94F8FC4CC1843609F0D0C089 :10FC20000E9491FC809309020E9491FC809308023B :10FC300080910C028E7F80930C020E9491FC85348F :10FC400029F480910C02816080930C0258E0C52E4B :10FC500051E0D52E760100E010E007C00E9491FC33 :10FC6000F70181937F010F5F1F4F809108029091F0 :10FC700009020817190790F30E9491FC803209F0DD :10FC80001CC180910C0280FF29C0809106019091D7 :10FC90000701880F991F909307018093060100E0E8 :10FCA00010E014C0F60161916F01809106019091FE :10FCB00007010E9473FF8091060190910701019650 :10FCC00090930701809306010F5F1F4F80910802F8 :10FCD000909109020817190728F36BC0809107015A :10FCE000880F880B8B2180930B028BBF80910601BC :10FCF00090910701880F991F909307018093060147 :10FD00008091080280FF09C0809108029091090249 :10FD100001969093090280930802F894F999FECF16 :10FD20001127E0910601F0910701C8E0D1E0809130 :10FD3000080290910902103091F40091570001706F :10FD40000130D9F303E000935700E8950091570084 :10FD500001700130D9F301E100935700E895099053 :10FD600019900091570001700130D9F301E0009320 :10FD70005700E8951395103898F011270091570017 :10FD800001700130D9F305E000935700E895009128 :10FD9000570001700130D9F301E100935700E89555 :10FDA0003296029709F0C7CF103011F00296E5CFD6 :10FDB000112484E10E9467FC80E10E9467FCAECEC2 :10FDC000843709F063C00E9491FC809309020E946D :10FDD00091FC809308028091060190910701209187 :10FDE0000C0297FF02C0226001C02D7F20930C02FD :10FDF000880F991F90930701809306010E9491FC40 :10FE000020910C02853411F4216001C02E7F2093D3 :10FE10000C020E9491FC803209F080CE84E10E94A5 :10FE200067FC00E010E02AC080910C0280FF07C050 :10FE300080910601909107010E946BFF12C0E09132 :10FE40000601F091070181FD02C084910AC0CF0133 :10FE5000A0E0B0E080509040AF4FBF4FABBFFC017F :10FE600087910E9467FC809106019091070101969D :10FE700090930701809306010F5F1F4F8091080246 :10FE8000909109020817190778F296CF853779F40F :10FE90000E9491FC803289F484E10E9467FC8EE12B :10FEA0000E9467FC87E90E9467FC85E083CF863764 :10FEB00021F480E00E9410FD31CE809103018F5F1C :10FEC00080930301853009F029CEE0910401F0917F :10FED0000501099523CEF999FECF92BD81BDF89A0F :10FEE000992780B50895262FF999FECF1FBA92BDA4 :10FEF00081BD20BD0FB6F894FA9AF99A0FBE01960B :06FF00000895F894FFCF04 :02FF0600800079 :040000031000F800F1 :00000001FF arduino-mighty-1284p-0~svn20130430.orig/bootloaders/standard/ATmegaBOOT_1284P.hex0000644000175000017500000001201512137772502026234 0ustar shevekshevek:020000021000EC :10F800000C9446FC0C9465FC0C9465FC0C9465FC13 :10F810000C9465FC0C9465FC0C9465FC0C9465FCE4 :10F820000C9465FC0C9465FC0C9465FC0C9465FCD4 :10F830000C9465FC0C9465FC0C9465FC0C9465FCC4 :10F840000C9465FC0C9465FC0C9465FC0C9465FCB4 :10F850000C9465FC0C9465FC0C9465FC0C9465FCA4 :10F860000C9465FC0C9465FC0C9465FC0C9465FC94 :10F870000C9465FC0C9465FC0C9465FC0C9465FC84 :10F880000C9465FC0C9465FC0C9465FC11241FBE63 :10F89000CFEFD0E4DEBFCDBF11E0A0E0B1E0E6E005 :10F8A000FFEF01E00BBF02C007900D92A230B1073D :10F8B000D9F712E0A2E0B1E001C01D92AD30B1076E :10F8C000E1F70E945FFD0C9481FF0C9400FC909185 :10F8D0000201913039F49091C00095FFFCCF8093E4 :10F8E000C6000895923031F49091C80095FFFCCF86 :10F8F0008093CE0008951F93982F95959595959593 :10F900009595905D182F1F701A3014F0195A01C088 :10F91000105D892F0E9467FC812F0E9467FC1F9158 :10F920000895EF92FF920F931F938091020181300F :10F93000F1F4EE24FF24870113C00894E11CF11CAC :10F94000011D111D81E0E81682E1F8068AE708072B :10F9500080E0180728F0E0910401F0910501099575 :10F960008091C00087FFE9CF8091C60021C082301E :10F97000F1F4EE24FF24870113C00894E11CF11C6C :10F98000011D111D81E0E81682E1F8068AE70807EB :10F9900080E0180728F0E0910401F0910501099535 :10F9A0008091C80087FFE9CF8091CE0001C080E040 :10F9B0001F910F91FF90EF9008951F930E9491FC6B :10F9C000182F0E9467FC113614F0175503C010332E :10F9D0000CF01053812F1F9108951F930E94DDFC9E :10F9E000182F0E94DDFC1295107F810F1F91089542 :10F9F0009091020112C0913039F42091C00027FF8C :10FA0000FCCF2091C60008C0923031F42091C8008C :10FA100027FFFCCF2091CE008150882361F7089505 :10FA20001F93182F0E9491FC803251F484E10E94B0 :10FA300067FC812F0E9467FC80E10E9467FC0CC07C :10FA4000809103018F5F80930301853029F4E09159 :10FA50000401F091050109951F9108950E9491FC00 :10FA6000803239F484E10E9467FC80E10E9467FCE7 :10FA70000895809103018F5F80930301853029F4FD :10FA8000E0910401F09105010995089515C0289AA7 :10FA90002FEF31EE44E0215030404040E1F700C00C :10FAA000000028982FEF31EE44E0215030404040D4 :10FAB000E1F700C000008150882349F70895BF9204 :10FAC000CF92DF92EF92FF920F931F93CF93DF932A :10FAD00094B714BE8091600088618093600010929A :10FAE000600091FD05C0E0910401F09105010995C8 :10FAF00081E08093020180E18093C4001092C500F0 :10FB00001092C00086E08093C20088E18093C1001B :10FB1000209A84E00E9446FDBB24B3940E9491FC8D :10FB2000803309F441C08133E1F40E9491FC8032BA :10FB300009F0C3C184E10E9467FC81E40E9467FC74 :10FB400086E50E9467FC82E50E9467FC80E20E94D5 :10FB500067FC89E40E9467FC83E50E9467FC80E5FE :10FB600029C1803439F40E9491FC8638E8F00E9463 :10FB700091FC1AC0813499F40E9491FC803811F4F0 :10FB800082E098C1813811F481E094C1823811F487 :10FB900080E190C1883909F08CC183E08BC1823447 :10FBA00031F484E10E94F8FC0E942EFDB7CF853429 :10FBB00011F485E0F7CF8035B9F38235A9F38135AB :10FBC00031F40E942EFD88E080936000FFCF8535E0 :10FBD00049F40E9491FC809306010E9491FC80935D :10FBE0000701E2CF8635C9F40E9491FC803389F485 :10FBF0000E9491FC0E9491FC082F0E9491FC00231E :10FC000011F48EE157C1013011F487E953C185E049 :10FC100051C183E00E94F8FC4CC1843609F0D0C089 :10FC20000E9491FC809309020E9491FC809308023B :10FC300080910C028E7F80930C020E9491FC85348F :10FC400029F480910C02816080930C0258E0C52E4B :10FC500051E0D52E760100E010E007C00E9491FC33 :10FC6000F70181937F010F5F1F4F809108029091F0 :10FC700009020817190790F30E9491FC803209F0DD :10FC80001CC180910C0280FF29C0809106019091D7 :10FC90000701880F991F909307018093060100E0E8 :10FCA00010E014C0F60161916F01809106019091FE :10FCB00007010E9473FF8091060190910701019650 :10FCC00090930701809306010F5F1F4F80910802F8 :10FCD000909109020817190728F36BC0809107015A :10FCE000880F880B8B2180930B028BBF80910601BC :10FCF00090910701880F991F909307018093060147 :10FD00008091080280FF09C0809108029091090249 :10FD100001969093090280930802F894F999FECF16 :10FD20001127E0910601F0910701C8E0D1E0809130 :10FD3000080290910902103091F40091570001706F :10FD40000130D9F303E000935700E8950091570084 :10FD500001700130D9F301E100935700E895099053 :10FD600019900091570001700130D9F301E0009320 :10FD70005700E8951395103898F011270091570017 :10FD800001700130D9F305E000935700E895009128 :10FD9000570001700130D9F301E100935700E89555 :10FDA0003296029709F0C7CF103011F00296E5CFD6 :10FDB000112484E10E9467FC80E10E9467FCAECEC2 :10FDC000843709F063C00E9491FC809309020E946D :10FDD00091FC809308028091060190910701209187 :10FDE0000C0297FF02C0226001C02D7F20930C02FD :10FDF000880F991F90930701809306010E9491FC40 :10FE000020910C02853411F4216001C02E7F2093D3 :10FE10000C020E9491FC803209F080CE84E10E94A5 :10FE200067FC00E010E02AC080910C0280FF07C050 :10FE300080910601909107010E946BFF12C0E09132 :10FE40000601F091070181FD02C084910AC0CF0133 :10FE5000A0E0B0E080509040AF4FBF4FABBFFC017F :10FE600087910E9467FC809106019091070101969D :10FE700090930701809306010F5F1F4F8091080246 :10FE8000909109020817190778F296CF853779F40F :10FE90000E9491FC803289F484E10E9467FC8EE12B :10FEA0000E9467FC87E90E9467FC85E083CF863764 :10FEB00021F480E00E9410FD31CE809103018F5F1C :10FEC00080930301853009F029CEE0910401F0917F :10FED0000501099523CEF999FECF92BD81BDF89A0F :10FEE000992780B50895262FF999FECF1FBA92BDA4 :10FEF00081BD20BD0FB6F894FA9AF99A0FBE01960B :06FF00000895F894FFCF04 :02FF0600800079 :040000031000F800F1 :00000001FF arduino-mighty-1284p-0~svn20130430.orig/bootloaders/standard/Makefile0000644000175000017500000000235312137772502024552 0ustar shevekshevek# Makefile for ATmegaBOOT # E.Lins, 18.7.2005 # $Id$ # program name should not be changed... PROGRAM = ATmegaBOOT_1284P # enter the target CPU frequency AVR_FREQ = 16000000L MCU_TARGET = atmega1284p LDSECTION = --section-start=.text=0x1F800 OBJ = $(PROGRAM).o OPTIMIZE = -Os DEFS = -DWATCHDOG_MODS -DBAUD_RATE=57600 LIBS = CC = avr-gcc # Override is only needed by avr-lib build system. override CFLAGS = -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS) override LDFLAGS = -Wl,$(LDSECTION) #override LDFLAGS = -Wl,-Map,$(PROGRAM).map,$(LDSECTION) OBJCOPY = avr-objcopy OBJDUMP = avr-objdump all: CFLAGS += '-DMAX_TIME_COUNT=16000000L>>1' -DADABOOT all: $(PROGRAM).hex $(PROGRAM).hex: $(PROGRAM).elf $(OBJCOPY) -j .text -j .data -O ihex $< $@ $(PROGRAM).elf: $(OBJ) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(OBJ): ATmegaBOOT.c avr-gcc $(CFLAGS) $(LDFLAGS) -c -Wall -mmcu=$(MCU_TARGET) ATmegaBOOT.c -o $(PROGRAM).o %.lst: %.elf $(OBJDUMP) -h -S $< > $@ %.srec: %.elf $(OBJCOPY) -j .text -j .data -O srec $< $@ %.bin: %.elf $(OBJCOPY) -j .text -j .data -O binary $< $@ clean: rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex arduino-mighty-1284p-0~svn20130430.orig/bootloaders/optiboot/0000755000175000017500000000000012140055246023137 5ustar shevekshevekarduino-mighty-1284p-0~svn20130430.orig/bootloaders/optiboot/optiboot.c0000644000175000017500000006052312137772502025157 0ustar shevekshevek/**********************************************************/ /* Optiboot bootloader for Arduino */ /* */ /* http://optiboot.googlecode.com */ /* */ /* Arduino-maintained version : See README.TXT */ /* http://code.google.com/p/arduino/ */ /* */ /* Heavily optimised bootloader that is faster and */ /* smaller than the Arduino standard bootloader */ /* */ /* Enhancements: */ /* Fits in 512 bytes, saving 1.5K of code space */ /* Background page erasing speeds up programming */ /* Higher baud rate speeds up programming */ /* Written almost entirely in C */ /* Customisable timeout with accurate timeconstant */ /* Optional virtual UART. No hardware UART required. */ /* Optional virtual boot partition for devices without. */ /* */ /* What you lose: */ /* Implements a skeleton STK500 protocol which is */ /* missing several features including EEPROM */ /* programming and non-page-aligned writes */ /* High baud rate breaks compatibility with standard */ /* Arduino flash settings */ /* */ /* Fully supported: */ /* ATmega168 based devices (Diecimila etc) */ /* ATmega328P based devices (Duemilanove etc) */ /* */ /* Alpha test */ /* ATmega1280 based devices (Arduino Mega) */ /* */ /* Work in progress: */ /* ATmega644P based devices (Sanguino) */ /* ATtiny84 based devices (Luminet) */ /* */ /* Does not support: */ /* USB based devices (eg. Teensy) */ /* */ /* Assumptions: */ /* The code makes several assumptions that reduce the */ /* code size. They are all true after a hardware reset, */ /* but may not be true if the bootloader is called by */ /* other means or on other hardware. */ /* No interrupts can occur */ /* UART and Timer 1 are set to their reset state */ /* SP points to RAMEND */ /* */ /* Code builds on code, libraries and optimisations from: */ /* stk500boot.c by Jason P. Kyle */ /* Arduino bootloader http://arduino.cc */ /* Spiff's 1K bootloader http://spiffie.org/know/arduino_1k_bootloader/bootloader.shtml */ /* avr-libc project http://nongnu.org/avr-libc */ /* Adaboot http://www.ladyada.net/library/arduino/bootloader.html */ /* AVR305 Atmel Application Note */ /* */ /* This program is free software; you can redistribute it */ /* and/or modify it under the terms of the GNU General */ /* Public License as published by the Free Software */ /* Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /* This program 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 General Public */ /* License for more details. */ /* */ /* You should have received a copy of the GNU General */ /* Public License along with this program; if not, write */ /* to the Free Software Foundation, Inc., */ /* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* */ /* Licence can be viewed at */ /* http://www.fsf.org/licenses/gpl.txt */ /* */ /**********************************************************/ /**********************************************************/ /* */ /* Optional defines: */ /* */ /**********************************************************/ /* */ /* BIG_BOOT: */ /* Build a 1k bootloader, not 512 bytes. This turns on */ /* extra functionality. */ /* */ /* BAUD_RATE: */ /* Set bootloader baud rate. */ /* */ /* LUDICROUS_SPEED: */ /* 230400 baud :-) */ /* */ /* SOFT_UART: */ /* Use AVR305 soft-UART instead of hardware UART. */ /* */ /* LED_START_FLASHES: */ /* Number of LED flashes on bootup. */ /* */ /* LED_DATA_FLASH: */ /* Flash LED when transferring data. For boards without */ /* TX or RX LEDs, or for people who like blinky lights. */ /* */ /* SUPPORT_EEPROM: */ /* Support reading and writing from EEPROM. This is not */ /* used by Arduino, so off by default. */ /* */ /* TIMEOUT_MS: */ /* Bootloader timeout period, in milliseconds. */ /* 500,1000,2000,4000,8000 supported. */ /* */ /**********************************************************/ /**********************************************************/ /* Version Numbers! */ /* */ /* Arduino Optiboot now includes this Version number in */ /* the source and object code. */ /* */ /* Version 3 was released as zip from the optiboot */ /* repository and was distributed with Arduino 0022. */ /* Version 4 starts with the arduino repository commit */ /* that brought the arduino repository up-to-date with */ /* the optiboot source tree changes since v3. */ /* */ /**********************************************************/ /**********************************************************/ /* Edit History: */ /* */ /* Jan 2012: */ /* 4.5 WestfW: fix NRWW value for m1284. */ /* 4.4 WestfW: use attribute OS_main instead of naked for */ /* main(). This allows optimizations that we */ /* count on, which are prohibited in naked */ /* functions due to PR42240. (keeps us less */ /* than 512 bytes when compiler is gcc4.5 */ /* (code from 4.3.2 remains the same.) */ /* 4.4 WestfW and Maniacbug: Add m1284 support. This */ /* does not change the 328 binary, so the */ /* version number didn't change either. (?) */ /* June 2011: */ /* 4.4 WestfW: remove automatic soft_uart detect (didn't */ /* know what it was doing or why.) Added a */ /* check of the calculated BRG value instead. */ /* Version stays 4.4; existing binaries are */ /* not changed. */ /* 4.4 WestfW: add initialization of address to keep */ /* the compiler happy. Change SC'ed targets. */ /* Return the SW version via READ PARAM */ /* 4.3 WestfW: catch framing errors in getch(), so that */ /* AVRISP works without HW kludges. */ /* http://code.google.com/p/arduino/issues/detail?id=368n*/ /* 4.2 WestfW: reduce code size, fix timeouts, change */ /* verifySpace to use WDT instead of appstart */ /* 4.1 WestfW: put version number in binary. */ /**********************************************************/ #define OPTIBOOT_MAJVER 4 #define OPTIBOOT_MINVER 5 #define MAKESTR(a) #a #define MAKEVER(a, b) MAKESTR(a*256+b) asm(" .section .version\n" "optiboot_version: .word " MAKEVER(OPTIBOOT_MAJVER, OPTIBOOT_MINVER) "\n" " .section .text\n"); #include #include #include // uses sts instructions, but this version uses out instructions // This saves cycles and program memory. #include "boot.h" // We don't use as those routines have interrupt overhead we don't need. #include "pin_defs.h" #include "stk500.h" #ifndef LED_START_FLASHES #define LED_START_FLASHES 0 #endif #ifdef LUDICROUS_SPEED #define BAUD_RATE 230400L #endif /* set the UART baud rate defaults */ #ifndef BAUD_RATE #if F_CPU >= 8000000L #define BAUD_RATE 115200L // Highest rate Avrdude win32 will support #elsif F_CPU >= 1000000L #define BAUD_RATE 9600L // 19200 also supported, but with significant error #elsif F_CPU >= 128000L #define BAUD_RATE 4800L // Good for 128kHz internal RC #else #define BAUD_RATE 1200L // Good even at 32768Hz #endif #endif #if 0 /* Switch in soft UART for hard baud rates */ /* * I don't understand what this was supposed to accomplish, where the * constant "280" came from, or why automatically (and perhaps unexpectedly) * switching to a soft uart is a good thing, so I'm undoing this in favor * of a range check using the same calc used to config the BRG... */ #if (F_CPU/BAUD_RATE) > 280 // > 57600 for 16MHz #ifndef SOFT_UART #define SOFT_UART #endif #endif #else // 0 #if (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 > 250 #error Unachievable baud rate (too slow) BAUD_RATE #endif // baud rate slow check #if (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 < 3 #error Unachievable baud rate (too fast) BAUD_RATE #endif // baud rate fastn check #endif /* Watchdog settings */ #define WATCHDOG_OFF (0) #define WATCHDOG_16MS (_BV(WDE)) #define WATCHDOG_32MS (_BV(WDP0) | _BV(WDE)) #define WATCHDOG_64MS (_BV(WDP1) | _BV(WDE)) #define WATCHDOG_125MS (_BV(WDP1) | _BV(WDP0) | _BV(WDE)) #define WATCHDOG_250MS (_BV(WDP2) | _BV(WDE)) #define WATCHDOG_500MS (_BV(WDP2) | _BV(WDP0) | _BV(WDE)) #define WATCHDOG_1S (_BV(WDP2) | _BV(WDP1) | _BV(WDE)) #define WATCHDOG_2S (_BV(WDP2) | _BV(WDP1) | _BV(WDP0) | _BV(WDE)) #ifndef __AVR_ATmega8__ #define WATCHDOG_4S (_BV(WDP3) | _BV(WDE)) #define WATCHDOG_8S (_BV(WDP3) | _BV(WDP0) | _BV(WDE)) #endif /* Function Prototypes */ /* The main function is in init9, which removes the interrupt vector table */ /* we don't need. It is also 'naked', which means the compiler does not */ /* generate any entry or exit code itself. */ int main(void) __attribute__ ((OS_main)) __attribute__ ((section (".init9"))); void putch(char); uint8_t getch(void); static inline void getNch(uint8_t); /* "static inline" is a compiler hint to reduce code size */ void verifySpace(); static inline void flash_led(uint8_t); uint8_t getLen(); static inline void watchdogReset(); void watchdogConfig(uint8_t x); #ifdef SOFT_UART void uartDelay() __attribute__ ((naked)); #endif void appStart() __attribute__ ((naked)); /* * NRWW memory * Addresses below NRWW (Non-Read-While-Write) can be programmed while * continuing to run code from flash, slightly speeding up programming * time. Beware that Atmel data sheets specify this as a WORD address, * while optiboot will be comparing against a 16-bit byte address. This * means that on a part with 128kB of memory, the upper part of the lower * 64k will get NRWW processing as well, even though it doesn't need it. * That's OK. In fact, you can disable the overlapping processing for * a part entirely by setting NRWWSTART to zero. This reduces code * space a bit, at the expense of being slightly slower, overall. * * RAMSTART should be self-explanatory. It's bigger on parts with a * lot of peripheral registers. */ #if defined(__AVR_ATmega168__) #define RAMSTART (0x100) #define NRWWSTART (0x3800) #elif defined(__AVR_ATmega328P__) #define RAMSTART (0x100) #define NRWWSTART (0x7000) #elif defined (__AVR_ATmega644P__) #define RAMSTART (0x100) #define NRWWSTART (0xE000) #elif defined (__AVR_ATmega1284P__) #define RAMSTART (0x100) #define NRWWSTART (0xE000) #elif defined(__AVR_ATtiny84__) #define RAMSTART (0x100) #define NRWWSTART (0x0000) #elif defined(__AVR_ATmega1280__) #define RAMSTART (0x200) #define NRWWSTART (0xE000) #elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__) #define RAMSTART (0x100) #define NRWWSTART (0x1800) #endif /* C zero initialises all global variables. However, that requires */ /* These definitions are NOT zero initialised, but that doesn't matter */ /* This allows us to drop the zero init code, saving us memory */ #define buff ((uint8_t*)(RAMSTART)) #ifdef VIRTUAL_BOOT_PARTITION #define rstVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+4)) #define wdtVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+6)) #endif /* main program starts here */ int main(void) { uint8_t ch; /* * Making these local and in registers prevents the need for initializing * them, and also saves space because code no longer stores to memory. * (initializing address keeps the compiler happy, but isn't really * necessary, and uses 4 bytes of flash.) */ register uint16_t address = 0; register uint8_t length; // After the zero init loop, this is the first code to run. // // This code makes the following assumptions: // No interrupts will execute // SP points to RAMEND // r1 contains zero // // If not, uncomment the following instructions: // cli(); asm volatile ("clr __zero_reg__"); #ifdef __AVR_ATmega8__ SP=RAMEND; // This is done by hardware reset #endif // Adaboot no-wait mod ch = MCUSR; MCUSR = 0; if (!(ch & _BV(EXTRF))) appStart(); #if LED_START_FLASHES > 0 // Set up Timer 1 for timeout counter TCCR1B = _BV(CS12) | _BV(CS10); // div 1024 #endif #ifndef SOFT_UART #ifdef __AVR_ATmega8__ UCSRA = _BV(U2X); //Double speed mode USART UCSRB = _BV(RXEN) | _BV(TXEN); // enable Rx & Tx UCSRC = _BV(URSEL) | _BV(UCSZ1) | _BV(UCSZ0); // config USART; 8N1 UBRRL = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); #else UCSR0A = _BV(U2X0); //Double speed mode USART0 UCSR0B = _BV(RXEN0) | _BV(TXEN0); UCSR0C = _BV(UCSZ00) | _BV(UCSZ01); UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); #endif #endif // Set up watchdog to trigger after 500ms watchdogConfig(WATCHDOG_1S); /* Set LED pin as output */ LED_DDR |= _BV(LED); #ifdef SOFT_UART /* Set TX pin as output */ UART_DDR |= _BV(UART_TX_BIT); #endif #if LED_START_FLASHES > 0 /* Flash onboard LED to signal entering of bootloader */ flash_led(LED_START_FLASHES * 2); #endif /* Forever loop */ for (;;) { /* get character from UART */ ch = getch(); if(ch == STK_GET_PARAMETER) { unsigned char which = getch(); verifySpace(); if (which == 0x82) { /* * Send optiboot version as "minor SW version" */ putch(OPTIBOOT_MINVER); } else if (which == 0x81) { putch(OPTIBOOT_MAJVER); } else { /* * GET PARAMETER returns a generic 0x03 reply for * other parameters - enough to keep Avrdude happy */ putch(0x03); } } else if(ch == STK_SET_DEVICE) { // SET DEVICE is ignored getNch(20); } else if(ch == STK_SET_DEVICE_EXT) { // SET DEVICE EXT is ignored getNch(5); } else if(ch == STK_LOAD_ADDRESS) { // LOAD ADDRESS uint16_t newAddress; newAddress = getch(); newAddress = (newAddress & 0xff) | (getch() << 8); #ifdef RAMPZ // Transfer top bit to RAMPZ RAMPZ = (newAddress & 0x8000) ? 1 : 0; #endif newAddress += newAddress; // Convert from word address to byte address address = newAddress; verifySpace(); } else if(ch == STK_UNIVERSAL) { // UNIVERSAL command is ignored getNch(4); putch(0x00); } /* Write memory, length is big endian and is in bytes */ else if(ch == STK_PROG_PAGE) { // PROGRAM PAGE - we support flash programming only, not EEPROM uint8_t *bufPtr; uint16_t addrPtr; getch(); /* getlen() */ length = getch(); getch(); // If we are in RWW section, immediately start page erase if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address); // While that is going on, read in page contents bufPtr = buff; do *bufPtr++ = getch(); while (--length); // If we are in NRWW section, page erase has to be delayed until now. // Todo: Take RAMPZ into account if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address); // Read command terminator, start reply verifySpace(); // If only a partial page is to be programmed, the erase might not be complete. // So check that here boot_spm_busy_wait(); #ifdef VIRTUAL_BOOT_PARTITION if ((uint16_t)(void*)address == 0) { // This is the reset vector page. We need to live-patch the code so the // bootloader runs. // // Move RESET vector to WDT vector uint16_t vect = buff[0] | (buff[1]<<8); rstVect = vect; wdtVect = buff[8] | (buff[9]<<8); vect -= 4; // Instruction is a relative jump (rjmp), so recalculate. buff[8] = vect & 0xff; buff[9] = vect >> 8; // Add jump to bootloader at RESET vector buff[0] = 0x7f; buff[1] = 0xce; // rjmp 0x1d00 instruction } #endif // Copy buffer into programming buffer bufPtr = buff; addrPtr = (uint16_t)(void*)address; ch = SPM_PAGESIZE / 2; do { uint16_t a; a = *bufPtr++; a |= (*bufPtr++) << 8; __boot_page_fill_short((uint16_t)(void*)addrPtr,a); addrPtr += 2; } while (--ch); // Write from programming buffer __boot_page_write_short((uint16_t)(void*)address); boot_spm_busy_wait(); #if defined(RWWSRE) // Reenable read access to flash boot_rww_enable(); #endif } /* Read memory block mode, length is big endian. */ else if(ch == STK_READ_PAGE) { // READ PAGE - we only read flash getch(); /* getlen() */ length = getch(); getch(); verifySpace(); #ifdef VIRTUAL_BOOT_PARTITION do { // Undo vector patch in bottom page so verify passes if (address == 0) ch=rstVect & 0xff; else if (address == 1) ch=rstVect >> 8; else if (address == 8) ch=wdtVect & 0xff; else if (address == 9) ch=wdtVect >> 8; else ch = pgm_read_byte_near(address); address++; putch(ch); } while (--length); #else #ifdef RAMPZ // Since RAMPZ should already be set, we need to use EPLM directly. // do putch(pgm_read_byte_near(address++)); // while (--length); do { uint8_t result; __asm__ ("elpm %0,Z\n":"=r"(result):"z"(address)); putch(result); address++; } while (--length); #else do putch(pgm_read_byte_near(address++)); while (--length); #endif #endif } /* Get device signature bytes */ else if(ch == STK_READ_SIGN) { // READ SIGN - return what Avrdude wants to hear verifySpace(); putch(SIGNATURE_0); putch(SIGNATURE_1); putch(SIGNATURE_2); } else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */ // Adaboot no-wait mod watchdogConfig(WATCHDOG_16MS); verifySpace(); } else { // This covers the response to commands like STK_ENTER_PROGMODE verifySpace(); } putch(STK_OK); } } void putch(char ch) { #ifndef SOFT_UART while (!(UCSR0A & _BV(UDRE0))); UDR0 = ch; #else __asm__ __volatile__ ( " com %[ch]\n" // ones complement, carry set " sec\n" "1: brcc 2f\n" " cbi %[uartPort],%[uartBit]\n" " rjmp 3f\n" "2: sbi %[uartPort],%[uartBit]\n" " nop\n" "3: rcall uartDelay\n" " rcall uartDelay\n" " lsr %[ch]\n" " dec %[bitcnt]\n" " brne 1b\n" : : [bitcnt] "d" (10), [ch] "r" (ch), [uartPort] "I" (_SFR_IO_ADDR(UART_PORT)), [uartBit] "I" (UART_TX_BIT) : "r25" ); #endif } uint8_t getch(void) { uint8_t ch; #ifdef LED_DATA_FLASH #ifdef __AVR_ATmega8__ LED_PORT ^= _BV(LED); #else LED_PIN |= _BV(LED); #endif #endif #ifdef SOFT_UART __asm__ __volatile__ ( "1: sbic %[uartPin],%[uartBit]\n" // Wait for start edge " rjmp 1b\n" " rcall uartDelay\n" // Get to middle of start bit "2: rcall uartDelay\n" // Wait 1 bit period " rcall uartDelay\n" // Wait 1 bit period " clc\n" " sbic %[uartPin],%[uartBit]\n" " sec\n" " dec %[bitCnt]\n" " breq 3f\n" " ror %[ch]\n" " rjmp 2b\n" "3:\n" : [ch] "=r" (ch) : [bitCnt] "d" (9), [uartPin] "I" (_SFR_IO_ADDR(UART_PIN)), [uartBit] "I" (UART_RX_BIT) : "r25" ); #else while(!(UCSR0A & _BV(RXC0))) ; if (!(UCSR0A & _BV(FE0))) { /* * A Framing Error indicates (probably) that something is talking * to us at the wrong bit rate. Assume that this is because it * expects to be talking to the application, and DON'T reset the * watchdog. This should cause the bootloader to abort and run * the application "soon", if it keeps happening. (Note that we * don't care that an invalid char is returned...) */ watchdogReset(); } ch = UDR0; #endif #ifdef LED_DATA_FLASH #ifdef __AVR_ATmega8__ LED_PORT ^= _BV(LED); #else LED_PIN |= _BV(LED); #endif #endif return ch; } #ifdef SOFT_UART // AVR305 equation: #define UART_B_VALUE (((F_CPU/BAUD_RATE)-23)/6) // Adding 3 to numerator simulates nearest rounding for more accurate baud rates #define UART_B_VALUE (((F_CPU/BAUD_RATE)-20)/6) #if UART_B_VALUE > 255 #error Baud rate too slow for soft UART #endif void uartDelay() { __asm__ __volatile__ ( "ldi r25,%[count]\n" "1:dec r25\n" "brne 1b\n" "ret\n" ::[count] "M" (UART_B_VALUE) ); } #endif void getNch(uint8_t count) { do getch(); while (--count); verifySpace(); } void verifySpace() { if (getch() != CRC_EOP) { watchdogConfig(WATCHDOG_16MS); // shorten WD timeout while (1) // and busy-loop so that WD causes ; // a reset and app start. } putch(STK_INSYNC); } #if LED_START_FLASHES > 0 void flash_led(uint8_t count) { do { TCNT1 = -(F_CPU/(1024*16)); TIFR1 = _BV(TOV1); while(!(TIFR1 & _BV(TOV1))); #ifdef __AVR_ATmega8__ LED_PORT ^= _BV(LED); #else LED_PIN |= _BV(LED); #endif watchdogReset(); } while (--count); } #endif // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( "wdr\n" ); } void watchdogConfig(uint8_t x) { WDTCSR = _BV(WDCE) | _BV(WDE); WDTCSR = x; } void appStart() { watchdogConfig(WATCHDOG_OFF); __asm__ __volatile__ ( #ifdef VIRTUAL_BOOT_PARTITION // Jump to WDT vector "ldi r30,4\n" "clr r31\n" #else // Jump to RST vector "clr r30\n" "clr r31\n" #endif "ijmp\n" ); } arduino-mighty-1284p-0~svn20130430.orig/bootloaders/optiboot/optiboot_atmega1284p.hex0000644000175000017500000000273412137772502027536 0ustar shevekshevek:020000000504F5 :020000021000EC :10FC00000F92CDB7DEB7112484B714BE81FFF1D0B7 :10FC100085E08093810082E08093C00088E180933A :10FC2000C10086E08093C20080E18093C4008EE032 :10FC3000CAD0209A26E080E39CEF31E090938500C3 :10FC40008093840036BBB09BFECF189AA8952150B4 :10FC5000A9F700E010E0EE24E394E1E1DE2EF3E00A :10FC6000FF2EA5D0813471F4A2D08983B2D08981CE :10FC7000823809F48BC0813811F484E001C083E03C :10FC80008FD08BC0823411F484E103C0853419F421 :10FC900085E0A7D082C0853591F489D0A82EBB24F9 :10FCA00086D0082F10E0102F00270A291B29812F4A :10FCB000881F8827881F8BBF000F111F6DC08635D6 :10FCC00021F484E08ED080E0DBCF843609F040C0A0 :10FCD0006ED06DD0C82E6BD080EE0030180718F4AF :10FCE000F801F7BEE895A12C51E0B52E60D0F501E2 :10FCF00081935F01CE16D1F7F0EE00301F0718F0A8 :10FD0000F801F7BEE89565D007B600FCFDCFF80115 :10FD1000A0E0B1E02C9130E011968C91119790E029 :10FD2000982F8827822B932B12960C01E7BEE8951B :10FD30001124329682E0A030B80761F785E0F8011F :10FD400087BFE89507B600FCFDCFD7BEE89525C074 :10FD50008437A9F42CD02BD0B82E29D03AD0CB2C74 :10FD60004801F40186911CD00894811C911CCA940E :10FD7000C1F70F5F1F4FBA940B0D111D0EC08537D1 :10FD800039F427D08EE10CD087E90AD085E078CF0E :10FD9000813511F488E017D01CD080E101D061CF0B :10FDA0009091C00095FFFCCF8093C600089580918C :10FDB000C00087FFFCCF8091C00084FD01C0A895E2 :10FDC0008091C6000895E0E6F0E098E1908380839A :10FDD0000895EDDF803219F088E0F5DFFFCF84E190 :10FDE000DFCFCF93C82FE3DFC150E9F7F2DFCF9128 :0CFDF000089580E0E8DFEE27FF2709946B :040000031000FC00ED :00000001FF arduino-mighty-1284p-0~svn20130430.orig/bootloaders/optiboot/stk500.h0000644000175000017500000000314412137772502024347 0ustar shevekshevek/* STK500 constants list, from AVRDUDE */ #define STK_OK 0x10 #define STK_FAILED 0x11 // Not used #define STK_UNKNOWN 0x12 // Not used #define STK_NODEVICE 0x13 // Not used #define STK_INSYNC 0x14 // ' ' #define STK_NOSYNC 0x15 // Not used #define ADC_CHANNEL_ERROR 0x16 // Not used #define ADC_MEASURE_OK 0x17 // Not used #define PWM_CHANNEL_ERROR 0x18 // Not used #define PWM_ADJUST_OK 0x19 // Not used #define CRC_EOP 0x20 // 'SPACE' #define STK_GET_SYNC 0x30 // '0' #define STK_GET_SIGN_ON 0x31 // '1' #define STK_SET_PARAMETER 0x40 // '@' #define STK_GET_PARAMETER 0x41 // 'A' #define STK_SET_DEVICE 0x42 // 'B' #define STK_SET_DEVICE_EXT 0x45 // 'E' #define STK_ENTER_PROGMODE 0x50 // 'P' #define STK_LEAVE_PROGMODE 0x51 // 'Q' #define STK_CHIP_ERASE 0x52 // 'R' #define STK_CHECK_AUTOINC 0x53 // 'S' #define STK_LOAD_ADDRESS 0x55 // 'U' #define STK_UNIVERSAL 0x56 // 'V' #define STK_PROG_FLASH 0x60 // '`' #define STK_PROG_DATA 0x61 // 'a' #define STK_PROG_FUSE 0x62 // 'b' #define STK_PROG_LOCK 0x63 // 'c' #define STK_PROG_PAGE 0x64 // 'd' #define STK_PROG_FUSE_EXT 0x65 // 'e' #define STK_READ_FLASH 0x70 // 'p' #define STK_READ_DATA 0x71 // 'q' #define STK_READ_FUSE 0x72 // 'r' #define STK_READ_LOCK 0x73 // 's' #define STK_READ_PAGE 0x74 // 't' #define STK_READ_SIGN 0x75 // 'u' #define STK_READ_OSCCAL 0x76 // 'v' #define STK_READ_FUSE_EXT 0x77 // 'w' #define STK_READ_OSCCAL_EXT 0x78 // 'x' arduino-mighty-1284p-0~svn20130430.orig/bootloaders/optiboot/boot.h0000644000175000017500000010233312137772502024264 0ustar shevekshevek/* Modified to use out for SPM access ** Peter Knight, Optiboot project http://optiboot.googlecode.com ** ** Todo: Tidy up ** ** "_short" routines execute 1 cycle faster and use 1 less word of flash ** by using "out" instruction instead of "sts". ** ** Additional elpm variants that trust the value of RAMPZ */ /* Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007 Eric B. Weddington All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* $Id: boot.h,v 1.27.2.3 2008/09/30 13:58:48 arcanum Exp $ */ #ifndef _AVR_BOOT_H_ #define _AVR_BOOT_H_ 1 /** \file */ /** \defgroup avr_boot : Bootloader Support Utilities \code #include #include \endcode The macros in this module provide a C language interface to the bootloader support functionality of certain AVR processors. These macros are designed to work with all sizes of flash memory. Global interrupts are not automatically disabled for these macros. It is left up to the programmer to do this. See the code example below. Also see the processor datasheet for caveats on having global interrupts enabled during writing of the Flash. \note Not all AVR processors provide bootloader support. See your processor datasheet to see if it provides bootloader support. \todo From email with Marek: On smaller devices (all except ATmega64/128), __SPM_REG is in the I/O space, accessible with the shorter "in" and "out" instructions - since the boot loader has a limited size, this could be an important optimization. \par API Usage Example The following code shows typical usage of the boot API. \code #include #include #include void boot_program_page (uint32_t page, uint8_t *buf) { uint16_t i; uint8_t sreg; // Disable interrupts. sreg = SREG; cli(); eeprom_busy_wait (); boot_page_erase (page); boot_spm_busy_wait (); // Wait until the memory is erased. for (i=0; i #include #include #include /* Check for SPM Control Register in processor. */ #if defined (SPMCSR) # define __SPM_REG SPMCSR #elif defined (SPMCR) # define __SPM_REG SPMCR #else # error AVR processor does not provide bootloader support! #endif /* Check for SPM Enable bit. */ #if defined(SPMEN) # define __SPM_ENABLE SPMEN #elif defined(SELFPRGEN) # define __SPM_ENABLE SELFPRGEN #else # error Cannot find SPM Enable bit definition! #endif /** \ingroup avr_boot \def BOOTLOADER_SECTION Used to declare a function or variable to be placed into a new section called .bootloader. This section and its contents can then be relocated to any address (such as the bootloader NRWW area) at link-time. */ #define BOOTLOADER_SECTION __attribute__ ((section (".bootloader"))) /* Create common bit definitions. */ #ifdef ASB #define __COMMON_ASB ASB #else #define __COMMON_ASB RWWSB #endif #ifdef ASRE #define __COMMON_ASRE ASRE #else #define __COMMON_ASRE RWWSRE #endif /* Define the bit positions of the Boot Lock Bits. */ #define BLB12 5 #define BLB11 4 #define BLB02 3 #define BLB01 2 /** \ingroup avr_boot \def boot_spm_interrupt_enable() Enable the SPM interrupt. */ #define boot_spm_interrupt_enable() (__SPM_REG |= (uint8_t)_BV(SPMIE)) /** \ingroup avr_boot \def boot_spm_interrupt_disable() Disable the SPM interrupt. */ #define boot_spm_interrupt_disable() (__SPM_REG &= (uint8_t)~_BV(SPMIE)) /** \ingroup avr_boot \def boot_is_spm_interrupt() Check if the SPM interrupt is enabled. */ #define boot_is_spm_interrupt() (__SPM_REG & (uint8_t)_BV(SPMIE)) /** \ingroup avr_boot \def boot_rww_busy() Check if the RWW section is busy. */ #define boot_rww_busy() (__SPM_REG & (uint8_t)_BV(__COMMON_ASB)) /** \ingroup avr_boot \def boot_spm_busy() Check if the SPM instruction is busy. */ #define boot_spm_busy() (__SPM_REG & (uint8_t)_BV(__SPM_ENABLE)) /** \ingroup avr_boot \def boot_spm_busy_wait() Wait while the SPM instruction is busy. */ #define boot_spm_busy_wait() do{}while(boot_spm_busy()) #define __BOOT_PAGE_ERASE (_BV(__SPM_ENABLE) | _BV(PGERS)) #define __BOOT_PAGE_WRITE (_BV(__SPM_ENABLE) | _BV(PGWRT)) #define __BOOT_PAGE_FILL _BV(__SPM_ENABLE) #define __BOOT_RWW_ENABLE (_BV(__SPM_ENABLE) | _BV(__COMMON_ASRE)) #define __BOOT_LOCK_BITS_SET (_BV(__SPM_ENABLE) | _BV(BLBSET)) #define __boot_page_fill_short(address, data) \ (__extension__({ \ __asm__ __volatile__ \ ( \ "movw r0, %3\n\t" \ "out %0, %1\n\t" \ "spm\n\t" \ "clr r1\n\t" \ : \ : "i" (_SFR_IO_ADDR(__SPM_REG)), \ "r" ((uint8_t)__BOOT_PAGE_FILL), \ "z" ((uint16_t)address), \ "r" ((uint16_t)data) \ : "r0" \ ); \ })) #define __boot_page_fill_normal(address, data) \ (__extension__({ \ __asm__ __volatile__ \ ( \ "movw r0, %3\n\t" \ "sts %0, %1\n\t" \ "spm\n\t" \ "clr r1\n\t" \ : \ : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ "r" ((uint8_t)__BOOT_PAGE_FILL), \ "z" ((uint16_t)address), \ "r" ((uint16_t)data) \ : "r0" \ ); \ })) #define __boot_page_fill_alternate(address, data)\ (__extension__({ \ __asm__ __volatile__ \ ( \ "movw r0, %3\n\t" \ "sts %0, %1\n\t" \ "spm\n\t" \ ".word 0xffff\n\t" \ "nop\n\t" \ "clr r1\n\t" \ : \ : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ "r" ((uint8_t)__BOOT_PAGE_FILL), \ "z" ((uint16_t)address), \ "r" ((uint16_t)data) \ : "r0" \ ); \ })) #define __boot_page_fill_extended(address, data) \ (__extension__({ \ __asm__ __volatile__ \ ( \ "movw r0, %4\n\t" \ "movw r30, %A3\n\t" \ "sts %1, %C3\n\t" \ "sts %0, %2\n\t" \ "spm\n\t" \ "clr r1\n\t" \ : \ : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ "i" (_SFR_MEM_ADDR(RAMPZ)), \ "r" ((uint8_t)__BOOT_PAGE_FILL), \ "r" ((uint32_t)address), \ "r" ((uint16_t)data) \ : "r0", "r30", "r31" \ ); \ })) #define __boot_page_fill_extended_short(address, data) \ (__extension__({ \ __asm__ __volatile__ \ ( \ "movw r0, %4\n\t" \ "movw r30, %A3\n\t" \ "out %1, %C3\n\t" \ "out %0, %2\n\t" \ "spm\n\t" \ "clr r1\n\t" \ : \ : "i" (_SFR_IO_ADDR(__SPM_REG)), \ "i" (_SFR_IO_ADDR(RAMPZ)), \ "r" ((uint8_t)__BOOT_PAGE_FILL), \ "r" ((uint32_t)address), \ "r" ((uint16_t)data) \ : "r0", "r30", "r31" \ ); \ })) #define __boot_page_erase_short(address) \ (__extension__({ \ __asm__ __volatile__ \ ( \ "out %0, %1\n\t" \ "spm\n\t" \ : \ : "i" (_SFR_IO_ADDR(__SPM_REG)), \ "r" ((uint8_t)__BOOT_PAGE_ERASE), \ "z" ((uint16_t)address) \ ); \ })) #define __boot_page_erase_normal(address) \ (__extension__({ \ __asm__ __volatile__ \ ( \ "sts %0, %1\n\t" \ "spm\n\t" \ : \ : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ "r" ((uint8_t)__BOOT_PAGE_ERASE), \ "z" ((uint16_t)address) \ ); \ })) #define __boot_page_erase_alternate(address) \ (__extension__({ \ __asm__ __volatile__ \ ( \ "sts %0, %1\n\t" \ "spm\n\t" \ ".word 0xffff\n\t" \ "nop\n\t" \ : \ : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ "r" ((uint8_t)__BOOT_PAGE_ERASE), \ "z" ((uint16_t)address) \ ); \ })) #define __boot_page_erase_extended(address) \ (__extension__({ \ __asm__ __volatile__ \ ( \ "movw r30, %A3\n\t" \ "sts %1, %C3\n\t" \ "sts %0, %2\n\t" \ "spm\n\t" \ : \ : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ "i" (_SFR_MEM_ADDR(RAMPZ)), \ "r" ((uint8_t)__BOOT_PAGE_ERASE), \ "r" ((uint32_t)address) \ : "r30", "r31" \ ); \ })) #define __boot_page_erase_extended_short(address) \ (__extension__({ \ __asm__ __volatile__ \ ( \ "movw r30, %A3\n\t" \ "out %1, %C3\n\t" \ "out %0, %2\n\t" \ "spm\n\t" \ : \ : "i" (_SFR_IO_ADDR(__SPM_REG)), \ "i" (_SFR_IO_ADDR(RAMPZ)), \ "r" ((uint8_t)__BOOT_PAGE_ERASE), \ "r" ((uint32_t)address) \ : "r30", "r31" \ ); \ })) #define __boot_page_write_short(address) \ (__extension__({ \ __asm__ __volatile__ \ ( \ "out %0, %1\n\t" \ "spm\n\t" \ : \ : "i" (_SFR_IO_ADDR(__SPM_REG)), \ "r" ((uint8_t)__BOOT_PAGE_WRITE), \ "z" ((uint16_t)address) \ ); \ })) #define __boot_page_write_normal(address) \ (__extension__({ \ __asm__ __volatile__ \ ( \ "sts %0, %1\n\t" \ "spm\n\t" \ : \ : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ "r" ((uint8_t)__BOOT_PAGE_WRITE), \ "z" ((uint16_t)address) \ ); \ })) #define __boot_page_write_alternate(address) \ (__extension__({ \ __asm__ __volatile__ \ ( \ "sts %0, %1\n\t" \ "spm\n\t" \ ".word 0xffff\n\t" \ "nop\n\t" \ : \ : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ "r" ((uint8_t)__BOOT_PAGE_WRITE), \ "z" ((uint16_t)address) \ ); \ })) #define __boot_page_write_extended(address) \ (__extension__({ \ __asm__ __volatile__ \ ( \ "movw r30, %A3\n\t" \ "sts %1, %C3\n\t" \ "sts %0, %2\n\t" \ "spm\n\t" \ : \ : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ "i" (_SFR_MEM_ADDR(RAMPZ)), \ "r" ((uint8_t)__BOOT_PAGE_WRITE), \ "r" ((uint32_t)address) \ : "r30", "r31" \ ); \ })) #define __boot_page_write_extended_short(address) \ (__extension__({ \ __asm__ __volatile__ \ ( \ "movw r30, %A3\n\t" \ "out %1, %C3\n\t" \ "out %0, %2\n\t" \ "spm\n\t" \ : \ : "i" (_SFR_IO_ADDR(__SPM_REG)), \ "i" (_SFR_IO_ADDR(RAMPZ)), \ "r" ((uint8_t)__BOOT_PAGE_WRITE), \ "r" ((uint32_t)address) \ : "r30", "r31" \ ); \ })) #define __boot_rww_enable_short() \ (__extension__({ \ __asm__ __volatile__ \ ( \ "out %0, %1\n\t" \ "spm\n\t" \ : \ : "i" (_SFR_IO_ADDR(__SPM_REG)), \ "r" ((uint8_t)__BOOT_RWW_ENABLE) \ ); \ })) #define __boot_rww_enable() \ (__extension__({ \ __asm__ __volatile__ \ ( \ "sts %0, %1\n\t" \ "spm\n\t" \ : \ : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ "r" ((uint8_t)__BOOT_RWW_ENABLE) \ ); \ })) #define __boot_rww_enable_alternate() \ (__extension__({ \ __asm__ __volatile__ \ ( \ "sts %0, %1\n\t" \ "spm\n\t" \ ".word 0xffff\n\t" \ "nop\n\t" \ : \ : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ "r" ((uint8_t)__BOOT_RWW_ENABLE) \ ); \ })) /* From the mega16/mega128 data sheets (maybe others): Bits by SPM To set the Boot Loader Lock bits, write the desired data to R0, write "X0001001" to SPMCR and execute SPM within four clock cycles after writing SPMCR. The only accessible Lock bits are the Boot Lock bits that may prevent the Application and Boot Loader section from any software update by the MCU. If bits 5..2 in R0 are cleared (zero), the corresponding Boot Lock bit will be programmed if an SPM instruction is executed within four cycles after BLBSET and SPMEN (or SELFPRGEN) are set in SPMCR. The Z-pointer is don't care during this operation, but for future compatibility it is recommended to load the Z-pointer with $0001 (same as used for reading the Lock bits). For future compatibility It is also recommended to set bits 7, 6, 1, and 0 in R0 to 1 when writing the Lock bits. When programming the Lock bits the entire Flash can be read during the operation. */ #define __boot_lock_bits_set_short(lock_bits) \ (__extension__({ \ uint8_t value = (uint8_t)(~(lock_bits)); \ __asm__ __volatile__ \ ( \ "ldi r30, 1\n\t" \ "ldi r31, 0\n\t" \ "mov r0, %2\n\t" \ "out %0, %1\n\t" \ "spm\n\t" \ : \ : "i" (_SFR_IO_ADDR(__SPM_REG)), \ "r" ((uint8_t)__BOOT_LOCK_BITS_SET), \ "r" (value) \ : "r0", "r30", "r31" \ ); \ })) #define __boot_lock_bits_set(lock_bits) \ (__extension__({ \ uint8_t value = (uint8_t)(~(lock_bits)); \ __asm__ __volatile__ \ ( \ "ldi r30, 1\n\t" \ "ldi r31, 0\n\t" \ "mov r0, %2\n\t" \ "sts %0, %1\n\t" \ "spm\n\t" \ : \ : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ "r" ((uint8_t)__BOOT_LOCK_BITS_SET), \ "r" (value) \ : "r0", "r30", "r31" \ ); \ })) #define __boot_lock_bits_set_alternate(lock_bits) \ (__extension__({ \ uint8_t value = (uint8_t)(~(lock_bits)); \ __asm__ __volatile__ \ ( \ "ldi r30, 1\n\t" \ "ldi r31, 0\n\t" \ "mov r0, %2\n\t" \ "sts %0, %1\n\t" \ "spm\n\t" \ ".word 0xffff\n\t" \ "nop\n\t" \ : \ : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ "r" ((uint8_t)__BOOT_LOCK_BITS_SET), \ "r" (value) \ : "r0", "r30", "r31" \ ); \ })) /* Reading lock and fuse bits: Similarly to writing the lock bits above, set BLBSET and SPMEN (or SELFPRGEN) bits in __SPMREG, and then (within four clock cycles) issue an LPM instruction. Z address: contents: 0x0000 low fuse bits 0x0001 lock bits 0x0002 extended fuse bits 0x0003 high fuse bits Sounds confusing, doesn't it? Unlike the macros in pgmspace.h, no need to care for non-enhanced cores here as these old cores do not provide SPM support anyway. */ /** \ingroup avr_boot \def GET_LOW_FUSE_BITS address to read the low fuse bits, using boot_lock_fuse_bits_get */ #define GET_LOW_FUSE_BITS (0x0000) /** \ingroup avr_boot \def GET_LOCK_BITS address to read the lock bits, using boot_lock_fuse_bits_get */ #define GET_LOCK_BITS (0x0001) /** \ingroup avr_boot \def GET_EXTENDED_FUSE_BITS address to read the extended fuse bits, using boot_lock_fuse_bits_get */ #define GET_EXTENDED_FUSE_BITS (0x0002) /** \ingroup avr_boot \def GET_HIGH_FUSE_BITS address to read the high fuse bits, using boot_lock_fuse_bits_get */ #define GET_HIGH_FUSE_BITS (0x0003) /** \ingroup avr_boot \def boot_lock_fuse_bits_get(address) Read the lock or fuse bits at \c address. Parameter \c address can be any of GET_LOW_FUSE_BITS, GET_LOCK_BITS, GET_EXTENDED_FUSE_BITS, or GET_HIGH_FUSE_BITS. \note The lock and fuse bits returned are the physical values, i.e. a bit returned as 0 means the corresponding fuse or lock bit is programmed. */ #define boot_lock_fuse_bits_get_short(address) \ (__extension__({ \ uint8_t __result; \ __asm__ __volatile__ \ ( \ "ldi r30, %3\n\t" \ "ldi r31, 0\n\t" \ "out %1, %2\n\t" \ "lpm %0, Z\n\t" \ : "=r" (__result) \ : "i" (_SFR_IO_ADDR(__SPM_REG)), \ "r" ((uint8_t)__BOOT_LOCK_BITS_SET), \ "M" (address) \ : "r0", "r30", "r31" \ ); \ __result; \ })) #define boot_lock_fuse_bits_get(address) \ (__extension__({ \ uint8_t __result; \ __asm__ __volatile__ \ ( \ "ldi r30, %3\n\t" \ "ldi r31, 0\n\t" \ "sts %1, %2\n\t" \ "lpm %0, Z\n\t" \ : "=r" (__result) \ : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ "r" ((uint8_t)__BOOT_LOCK_BITS_SET), \ "M" (address) \ : "r0", "r30", "r31" \ ); \ __result; \ })) /** \ingroup avr_boot \def boot_signature_byte_get(address) Read the Signature Row byte at \c address. For some MCU types, this function can also retrieve the factory-stored oscillator calibration bytes. Parameter \c address can be 0-0x1f as documented by the datasheet. \note The values are MCU type dependent. */ #define __BOOT_SIGROW_READ (_BV(__SPM_ENABLE) | _BV(SIGRD)) #define boot_signature_byte_get_short(addr) \ (__extension__({ \ uint16_t __addr16 = (uint16_t)(addr); \ uint8_t __result; \ __asm__ __volatile__ \ ( \ "out %1, %2\n\t" \ "lpm %0, Z" "\n\t" \ : "=r" (__result) \ : "i" (_SFR_IO_ADDR(__SPM_REG)), \ "r" ((uint8_t) __BOOT_SIGROW_READ), \ "z" (__addr16) \ ); \ __result; \ })) #define boot_signature_byte_get(addr) \ (__extension__({ \ uint16_t __addr16 = (uint16_t)(addr); \ uint8_t __result; \ __asm__ __volatile__ \ ( \ "sts %1, %2\n\t" \ "lpm %0, Z" "\n\t" \ : "=r" (__result) \ : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ "r" ((uint8_t) __BOOT_SIGROW_READ), \ "z" (__addr16) \ ); \ __result; \ })) /** \ingroup avr_boot \def boot_page_fill(address, data) Fill the bootloader temporary page buffer for flash address with data word. \note The address is a byte address. The data is a word. The AVR writes data to the buffer a word at a time, but addresses the buffer per byte! So, increment your address by 2 between calls, and send 2 data bytes in a word format! The LSB of the data is written to the lower address; the MSB of the data is written to the higher address.*/ /** \ingroup avr_boot \def boot_page_erase(address) Erase the flash page that contains address. \note address is a byte address in flash, not a word address. */ /** \ingroup avr_boot \def boot_page_write(address) Write the bootloader temporary page buffer to flash page that contains address. \note address is a byte address in flash, not a word address. */ /** \ingroup avr_boot \def boot_rww_enable() Enable the Read-While-Write memory section. */ /** \ingroup avr_boot \def boot_lock_bits_set(lock_bits) Set the bootloader lock bits. \param lock_bits A mask of which Boot Loader Lock Bits to set. \note In this context, a 'set bit' will be written to a zero value. Note also that only BLBxx bits can be programmed by this command. For example, to disallow the SPM instruction from writing to the Boot Loader memory section of flash, you would use this macro as such: \code boot_lock_bits_set (_BV (BLB11)); \endcode \note Like any lock bits, the Boot Loader Lock Bits, once set, cannot be cleared again except by a chip erase which will in turn also erase the boot loader itself. */ /* Normal versions of the macros use 16-bit addresses. Extended versions of the macros use 32-bit addresses. Alternate versions of the macros use 16-bit addresses and require special instruction sequences after LPM. FLASHEND is defined in the ioXXXX.h file. USHRT_MAX is defined in . */ #if defined(__AVR_ATmega161__) || defined(__AVR_ATmega163__) \ || defined(__AVR_ATmega323__) /* Alternate: ATmega161/163/323 and 16 bit address */ #define boot_page_fill(address, data) __boot_page_fill_alternate(address, data) #define boot_page_erase(address) __boot_page_erase_alternate(address) #define boot_page_write(address) __boot_page_write_alternate(address) #define boot_rww_enable() __boot_rww_enable_alternate() #define boot_lock_bits_set(lock_bits) __boot_lock_bits_set_alternate(lock_bits) #elif (FLASHEND > USHRT_MAX) /* Extended: >16 bit address */ #define boot_page_fill(address, data) __boot_page_fill_extended_short(address, data) #define boot_page_erase(address) __boot_page_erase_extended_short(address) #define boot_page_write(address) __boot_page_write_extended_short(address) #define boot_rww_enable() __boot_rww_enable_short() #define boot_lock_bits_set(lock_bits) __boot_lock_bits_set_short(lock_bits) #else /* Normal: 16 bit address */ #define boot_page_fill(address, data) __boot_page_fill_short(address, data) #define boot_page_erase(address) __boot_page_erase_short(address) #define boot_page_write(address) __boot_page_write_short(address) #define boot_rww_enable() __boot_rww_enable_short() #define boot_lock_bits_set(lock_bits) __boot_lock_bits_set_short(lock_bits) #endif /** \ingroup avr_boot Same as boot_page_fill() except it waits for eeprom and spm operations to complete before filling the page. */ #define boot_page_fill_safe(address, data) \ do { \ boot_spm_busy_wait(); \ eeprom_busy_wait(); \ boot_page_fill(address, data); \ } while (0) /** \ingroup avr_boot Same as boot_page_erase() except it waits for eeprom and spm operations to complete before erasing the page. */ #define boot_page_erase_safe(address) \ do { \ boot_spm_busy_wait(); \ eeprom_busy_wait(); \ boot_page_erase (address); \ } while (0) /** \ingroup avr_boot Same as boot_page_write() except it waits for eeprom and spm operations to complete before writing the page. */ #define boot_page_write_safe(address) \ do { \ boot_spm_busy_wait(); \ eeprom_busy_wait(); \ boot_page_write (address); \ } while (0) /** \ingroup avr_boot Same as boot_rww_enable() except waits for eeprom and spm operations to complete before enabling the RWW mameory. */ #define boot_rww_enable_safe() \ do { \ boot_spm_busy_wait(); \ eeprom_busy_wait(); \ boot_rww_enable(); \ } while (0) /** \ingroup avr_boot Same as boot_lock_bits_set() except waits for eeprom and spm operations to complete before setting the lock bits. */ #define boot_lock_bits_set_safe(lock_bits) \ do { \ boot_spm_busy_wait(); \ eeprom_busy_wait(); \ boot_lock_bits_set (lock_bits); \ } while (0) #endif /* _AVR_BOOT_H_ */ arduino-mighty-1284p-0~svn20130430.orig/bootloaders/optiboot/optiboot_atmega1284p.lst0000644000175000017500000003061312137772502027551 0ustar shevekshevek optiboot_atmega1284p.elf: file format elf32-avr Sections: Idx Name Size VMA LMA File off Algn 0 .text 000001fc 0001fc00 0001fc00 00000054 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE 1 .stab 00000aec 00000000 00000000 00000250 2**2 CONTENTS, READONLY, DEBUGGING 2 .stabstr 0000091a 00000000 00000000 00000d3c 2**0 CONTENTS, READONLY, DEBUGGING 3 .version 00000002 00000000 00000000 00001656 2**0 CONTENTS, READONLY Disassembly of section .text: 0001fc00
: 1fc00: 0f 92 push r0 1fc02: cd b7 in r28, 0x3d ; 61 1fc04: de b7 in r29, 0x3e ; 62 1fc06: 11 24 eor r1, r1 1fc08: 84 b7 in r24, 0x34 ; 52 1fc0a: 14 be out 0x34, r1 ; 52 1fc0c: 81 ff sbrs r24, 1 1fc0e: f1 d0 rcall .+482 ; 0x1fdf2 1fc10: 85 e0 ldi r24, 0x05 ; 5 1fc12: 80 93 81 00 sts 0x0081, r24 1fc16: 82 e0 ldi r24, 0x02 ; 2 1fc18: 80 93 c0 00 sts 0x00C0, r24 1fc1c: 88 e1 ldi r24, 0x18 ; 24 1fc1e: 80 93 c1 00 sts 0x00C1, r24 1fc22: 86 e0 ldi r24, 0x06 ; 6 1fc24: 80 93 c2 00 sts 0x00C2, r24 1fc28: 80 e1 ldi r24, 0x10 ; 16 1fc2a: 80 93 c4 00 sts 0x00C4, r24 1fc2e: 8e e0 ldi r24, 0x0E ; 14 1fc30: ca d0 rcall .+404 ; 0x1fdc6 1fc32: 20 9a sbi 0x04, 0 ; 4 1fc34: 26 e0 ldi r18, 0x06 ; 6 1fc36: 80 e3 ldi r24, 0x30 ; 48 1fc38: 9c ef ldi r25, 0xFC ; 252 1fc3a: 31 e0 ldi r19, 0x01 ; 1 1fc3c: 90 93 85 00 sts 0x0085, r25 1fc40: 80 93 84 00 sts 0x0084, r24 1fc44: 36 bb out 0x16, r19 ; 22 1fc46: b0 9b sbis 0x16, 0 ; 22 1fc48: fe cf rjmp .-4 ; 0x1fc46 1fc4a: 18 9a sbi 0x03, 0 ; 3 1fc4c: a8 95 wdr 1fc4e: 21 50 subi r18, 0x01 ; 1 1fc50: a9 f7 brne .-22 ; 0x1fc3c 1fc52: 00 e0 ldi r16, 0x00 ; 0 1fc54: 10 e0 ldi r17, 0x00 ; 0 1fc56: ee 24 eor r14, r14 1fc58: e3 94 inc r14 1fc5a: e1 e1 ldi r30, 0x11 ; 17 1fc5c: de 2e mov r13, r30 1fc5e: f3 e0 ldi r31, 0x03 ; 3 1fc60: ff 2e mov r15, r31 1fc62: a5 d0 rcall .+330 ; 0x1fdae 1fc64: 81 34 cpi r24, 0x41 ; 65 1fc66: 71 f4 brne .+28 ; 0x1fc84 1fc68: a2 d0 rcall .+324 ; 0x1fdae 1fc6a: 89 83 std Y+1, r24 ; 0x01 1fc6c: b2 d0 rcall .+356 ; 0x1fdd2 1fc6e: 89 81 ldd r24, Y+1 ; 0x01 1fc70: 82 38 cpi r24, 0x82 ; 130 1fc72: 09 f4 brne .+2 ; 0x1fc76 1fc74: 8b c0 rjmp .+278 ; 0x1fd8c 1fc76: 81 38 cpi r24, 0x81 ; 129 1fc78: 11 f4 brne .+4 ; 0x1fc7e 1fc7a: 84 e0 ldi r24, 0x04 ; 4 1fc7c: 01 c0 rjmp .+2 ; 0x1fc80 1fc7e: 83 e0 ldi r24, 0x03 ; 3 1fc80: 8f d0 rcall .+286 ; 0x1fda0 1fc82: 8b c0 rjmp .+278 ; 0x1fd9a 1fc84: 82 34 cpi r24, 0x42 ; 66 1fc86: 11 f4 brne .+4 ; 0x1fc8c 1fc88: 84 e1 ldi r24, 0x14 ; 20 1fc8a: 03 c0 rjmp .+6 ; 0x1fc92 1fc8c: 85 34 cpi r24, 0x45 ; 69 1fc8e: 19 f4 brne .+6 ; 0x1fc96 1fc90: 85 e0 ldi r24, 0x05 ; 5 1fc92: a7 d0 rcall .+334 ; 0x1fde2 1fc94: 82 c0 rjmp .+260 ; 0x1fd9a 1fc96: 85 35 cpi r24, 0x55 ; 85 1fc98: 91 f4 brne .+36 ; 0x1fcbe 1fc9a: 89 d0 rcall .+274 ; 0x1fdae 1fc9c: a8 2e mov r10, r24 1fc9e: bb 24 eor r11, r11 1fca0: 86 d0 rcall .+268 ; 0x1fdae 1fca2: 08 2f mov r16, r24 1fca4: 10 e0 ldi r17, 0x00 ; 0 1fca6: 10 2f mov r17, r16 1fca8: 00 27 eor r16, r16 1fcaa: 0a 29 or r16, r10 1fcac: 1b 29 or r17, r11 1fcae: 81 2f mov r24, r17 1fcb0: 88 1f adc r24, r24 1fcb2: 88 27 eor r24, r24 1fcb4: 88 1f adc r24, r24 1fcb6: 8b bf out 0x3b, r24 ; 59 1fcb8: 00 0f add r16, r16 1fcba: 11 1f adc r17, r17 1fcbc: 6d c0 rjmp .+218 ; 0x1fd98 1fcbe: 86 35 cpi r24, 0x56 ; 86 1fcc0: 21 f4 brne .+8 ; 0x1fcca 1fcc2: 84 e0 ldi r24, 0x04 ; 4 1fcc4: 8e d0 rcall .+284 ; 0x1fde2 1fcc6: 80 e0 ldi r24, 0x00 ; 0 1fcc8: db cf rjmp .-74 ; 0x1fc80 1fcca: 84 36 cpi r24, 0x64 ; 100 1fccc: 09 f0 breq .+2 ; 0x1fcd0 1fcce: 40 c0 rjmp .+128 ; 0x1fd50 1fcd0: 6e d0 rcall .+220 ; 0x1fdae 1fcd2: 6d d0 rcall .+218 ; 0x1fdae 1fcd4: c8 2e mov r12, r24 1fcd6: 6b d0 rcall .+214 ; 0x1fdae 1fcd8: 80 ee ldi r24, 0xE0 ; 224 1fcda: 00 30 cpi r16, 0x00 ; 0 1fcdc: 18 07 cpc r17, r24 1fcde: 18 f4 brcc .+6 ; 0x1fce6 1fce0: f8 01 movw r30, r16 1fce2: f7 be out 0x37, r15 ; 55 1fce4: e8 95 spm 1fce6: a1 2c mov r10, r1 1fce8: 51 e0 ldi r21, 0x01 ; 1 1fcea: b5 2e mov r11, r21 1fcec: 60 d0 rcall .+192 ; 0x1fdae 1fcee: f5 01 movw r30, r10 1fcf0: 81 93 st Z+, r24 1fcf2: 5f 01 movw r10, r30 1fcf4: ce 16 cp r12, r30 1fcf6: d1 f7 brne .-12 ; 0x1fcec 1fcf8: f0 ee ldi r31, 0xE0 ; 224 1fcfa: 00 30 cpi r16, 0x00 ; 0 1fcfc: 1f 07 cpc r17, r31 1fcfe: 18 f0 brcs .+6 ; 0x1fd06 1fd00: f8 01 movw r30, r16 1fd02: f7 be out 0x37, r15 ; 55 1fd04: e8 95 spm 1fd06: 65 d0 rcall .+202 ; 0x1fdd2 1fd08: 07 b6 in r0, 0x37 ; 55 1fd0a: 00 fc sbrc r0, 0 1fd0c: fd cf rjmp .-6 ; 0x1fd08 1fd0e: f8 01 movw r30, r16 1fd10: a0 e0 ldi r26, 0x00 ; 0 1fd12: b1 e0 ldi r27, 0x01 ; 1 1fd14: 2c 91 ld r18, X 1fd16: 30 e0 ldi r19, 0x00 ; 0 1fd18: 11 96 adiw r26, 0x01 ; 1 1fd1a: 8c 91 ld r24, X 1fd1c: 11 97 sbiw r26, 0x01 ; 1 1fd1e: 90 e0 ldi r25, 0x00 ; 0 1fd20: 98 2f mov r25, r24 1fd22: 88 27 eor r24, r24 1fd24: 82 2b or r24, r18 1fd26: 93 2b or r25, r19 1fd28: 12 96 adiw r26, 0x02 ; 2 1fd2a: 0c 01 movw r0, r24 1fd2c: e7 be out 0x37, r14 ; 55 1fd2e: e8 95 spm 1fd30: 11 24 eor r1, r1 1fd32: 32 96 adiw r30, 0x02 ; 2 1fd34: 82 e0 ldi r24, 0x02 ; 2 1fd36: a0 30 cpi r26, 0x00 ; 0 1fd38: b8 07 cpc r27, r24 1fd3a: 61 f7 brne .-40 ; 0x1fd14 1fd3c: 85 e0 ldi r24, 0x05 ; 5 1fd3e: f8 01 movw r30, r16 1fd40: 87 bf out 0x37, r24 ; 55 1fd42: e8 95 spm 1fd44: 07 b6 in r0, 0x37 ; 55 1fd46: 00 fc sbrc r0, 0 1fd48: fd cf rjmp .-6 ; 0x1fd44 1fd4a: d7 be out 0x37, r13 ; 55 1fd4c: e8 95 spm 1fd4e: 25 c0 rjmp .+74 ; 0x1fd9a 1fd50: 84 37 cpi r24, 0x74 ; 116 1fd52: a9 f4 brne .+42 ; 0x1fd7e 1fd54: 2c d0 rcall .+88 ; 0x1fdae 1fd56: 2b d0 rcall .+86 ; 0x1fdae 1fd58: b8 2e mov r11, r24 1fd5a: 29 d0 rcall .+82 ; 0x1fdae 1fd5c: 3a d0 rcall .+116 ; 0x1fdd2 1fd5e: cb 2c mov r12, r11 1fd60: 48 01 movw r8, r16 1fd62: f4 01 movw r30, r8 1fd64: 86 91 elpm r24, Z 1fd66: 1c d0 rcall .+56 ; 0x1fda0 1fd68: 08 94 sec 1fd6a: 81 1c adc r8, r1 1fd6c: 91 1c adc r9, r1 1fd6e: ca 94 dec r12 1fd70: c1 f7 brne .-16 ; 0x1fd62 1fd72: 0f 5f subi r16, 0xFF ; 255 1fd74: 1f 4f sbci r17, 0xFF ; 255 1fd76: ba 94 dec r11 1fd78: 0b 0d add r16, r11 1fd7a: 11 1d adc r17, r1 1fd7c: 0e c0 rjmp .+28 ; 0x1fd9a 1fd7e: 85 37 cpi r24, 0x75 ; 117 1fd80: 39 f4 brne .+14 ; 0x1fd90 1fd82: 27 d0 rcall .+78 ; 0x1fdd2 1fd84: 8e e1 ldi r24, 0x1E ; 30 1fd86: 0c d0 rcall .+24 ; 0x1fda0 1fd88: 87 e9 ldi r24, 0x97 ; 151 1fd8a: 0a d0 rcall .+20 ; 0x1fda0 1fd8c: 85 e0 ldi r24, 0x05 ; 5 1fd8e: 78 cf rjmp .-272 ; 0x1fc80 1fd90: 81 35 cpi r24, 0x51 ; 81 1fd92: 11 f4 brne .+4 ; 0x1fd98 1fd94: 88 e0 ldi r24, 0x08 ; 8 1fd96: 17 d0 rcall .+46 ; 0x1fdc6 1fd98: 1c d0 rcall .+56 ; 0x1fdd2 1fd9a: 80 e1 ldi r24, 0x10 ; 16 1fd9c: 01 d0 rcall .+2 ; 0x1fda0 1fd9e: 61 cf rjmp .-318 ; 0x1fc62 0001fda0 : } } void putch(char ch) { #ifndef SOFT_UART while (!(UCSR0A & _BV(UDRE0))); 1fda0: 90 91 c0 00 lds r25, 0x00C0 1fda4: 95 ff sbrs r25, 5 1fda6: fc cf rjmp .-8 ; 0x1fda0 UDR0 = ch; 1fda8: 80 93 c6 00 sts 0x00C6, r24 [uartBit] "I" (UART_TX_BIT) : "r25" ); #endif } 1fdac: 08 95 ret 0001fdae : [uartBit] "I" (UART_RX_BIT) : "r25" ); #else while(!(UCSR0A & _BV(RXC0))) 1fdae: 80 91 c0 00 lds r24, 0x00C0 1fdb2: 87 ff sbrs r24, 7 1fdb4: fc cf rjmp .-8 ; 0x1fdae ; if (!(UCSR0A & _BV(FE0))) { 1fdb6: 80 91 c0 00 lds r24, 0x00C0 1fdba: 84 fd sbrc r24, 4 1fdbc: 01 c0 rjmp .+2 ; 0x1fdc0 } #endif // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( 1fdbe: a8 95 wdr * don't care that an invalid char is returned...) */ watchdogReset(); } ch = UDR0; 1fdc0: 80 91 c6 00 lds r24, 0x00C6 LED_PIN |= _BV(LED); #endif #endif return ch; } 1fdc4: 08 95 ret 0001fdc6 : "wdr\n" ); } void watchdogConfig(uint8_t x) { WDTCSR = _BV(WDCE) | _BV(WDE); 1fdc6: e0 e6 ldi r30, 0x60 ; 96 1fdc8: f0 e0 ldi r31, 0x00 ; 0 1fdca: 98 e1 ldi r25, 0x18 ; 24 1fdcc: 90 83 st Z, r25 WDTCSR = x; 1fdce: 80 83 st Z, r24 } 1fdd0: 08 95 ret 0001fdd2 : do getch(); while (--count); verifySpace(); } void verifySpace() { if (getch() != CRC_EOP) { 1fdd2: ed df rcall .-38 ; 0x1fdae 1fdd4: 80 32 cpi r24, 0x20 ; 32 1fdd6: 19 f0 breq .+6 ; 0x1fdde watchdogConfig(WATCHDOG_16MS); // shorten WD timeout 1fdd8: 88 e0 ldi r24, 0x08 ; 8 1fdda: f5 df rcall .-22 ; 0x1fdc6 1fddc: ff cf rjmp .-2 ; 0x1fddc while (1) // and busy-loop so that WD causes ; // a reset and app start. } putch(STK_INSYNC); 1fdde: 84 e1 ldi r24, 0x14 ; 20 1fde0: df cf rjmp .-66 ; 0x1fda0 0001fde2 : ::[count] "M" (UART_B_VALUE) ); } #endif void getNch(uint8_t count) { 1fde2: cf 93 push r28 1fde4: c8 2f mov r28, r24 do getch(); while (--count); 1fde6: e3 df rcall .-58 ; 0x1fdae 1fde8: c1 50 subi r28, 0x01 ; 1 1fdea: e9 f7 brne .-6 ; 0x1fde6 verifySpace(); 1fdec: f2 df rcall .-28 ; 0x1fdd2 } 1fdee: cf 91 pop r28 1fdf0: 08 95 ret 0001fdf2 : WDTCSR = _BV(WDCE) | _BV(WDE); WDTCSR = x; } void appStart() { watchdogConfig(WATCHDOG_OFF); 1fdf2: 80 e0 ldi r24, 0x00 ; 0 1fdf4: e8 df rcall .-48 ; 0x1fdc6 __asm__ __volatile__ ( 1fdf6: ee 27 eor r30, r30 1fdf8: ff 27 eor r31, r31 1fdfa: 09 94 ijmp arduino-mighty-1284p-0~svn20130430.orig/bootloaders/optiboot/pin_defs.h0000644000175000017500000000365412137772502025116 0ustar shevekshevek#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__) /* Onboard LED is connected to pin PB5 in Arduino NG, Diecimila, and Duemilanove */ #define LED_DDR DDRB #define LED_PORT PORTB #define LED_PIN PINB #define LED PINB5 /* Ports for soft UART */ #ifdef SOFT_UART #define UART_PORT PORTD #define UART_PIN PIND #define UART_DDR DDRD #define UART_TX_BIT 1 #define UART_RX_BIT 0 #endif #endif #if defined(__AVR_ATmega8__) //Name conversion R.Wiersma #define UCSR0A UCSRA #define UDR0 UDR #define UDRE0 UDRE #define RXC0 RXC #define FE0 FE #define TIFR1 TIFR #define WDTCSR WDTCR #endif /* Luminet support */ #if defined(__AVR_ATtiny84__) /* Red LED is connected to pin PA4 */ #define LED_DDR DDRA #define LED_PORT PORTA #define LED_PIN PINA #define LED PINA4 /* Ports for soft UART - left port only for now. TX/RX on PA2/PA3 */ #ifdef SOFT_UART #define UART_PORT PORTA #define UART_PIN PINA #define UART_DDR DDRA #define UART_TX_BIT 2 #define UART_RX_BIT 3 #endif #endif /* Sanguino support */ #if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) /* Onboard LED is connected to pin PB0 on Sanguino */ #define LED_DDR DDRB #define LED_PORT PORTB #define LED_PIN PINB #define LED PINB1 /* Ports for soft UART */ #ifdef SOFT_UART #define UART_PORT PORTD #define UART_PIN PIND #define UART_DDR DDRD #define UART_TX_BIT 1 #define UART_RX_BIT 0 #endif #endif /* Mega support */ #if defined(__AVR_ATmega1280__) /* Onboard LED is connected to pin PB7 on Arduino Mega */ #define LED_DDR DDRB #define LED_PORT PORTB #define LED_PIN PINB #define LED PINB7 /* Ports for soft UART */ #ifdef SOFT_UART #define UART_PORT PORTE #define UART_PIN PINE #define UART_DDR DDRE #define UART_TX_BIT 1 #define UART_RX_BIT 0 #endif #endif arduino-mighty-1284p-0~svn20130430.orig/bootloaders/optiboot/Makefile0000644000175000017500000003434212137772502024614 0ustar shevekshevek# Makefile for ATmegaBOOT # E.Lins, 18.7.2005 # $Id$ # # Instructions # # To make bootloader .hex file: # make diecimila # make lilypad # make ng # etc... # # To burn bootloader .hex file: # make diecimila_isp # make lilypad_isp # make ng_isp # etc... # program name should not be changed... PROGRAM = optiboot # The default behavior is to build using tools that are in the users # current path variables, but we can also build using an installed # Arduino user IDE setup, or the Arduino source tree. # Uncomment this next lines to build within the arduino environment, # using the arduino-included avrgcc toolset (mac and pc) # ENV ?= arduino # ENV ?= arduinodev # OS ?= macosx # OS ?= windows # enter the parameters for the avrdude isp tool ISPTOOL = avrisp ISPPORT = /dev/ttyUSB0 ISPSPEED = -b 19200 MCU_TARGET = atmega168 LDSECTIONS = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe # Build environments # Start of some ugly makefile-isms to allow optiboot to be built # in several different environments. See the README.TXT file for # details. # default fixpath = $(1) ifeq ($(ENV), arduino) # For Arduino, we assume that we're connected to the optiboot directory # included with the arduino distribution, which means that the full set # of avr-tools are "right up there" in standard places. TOOLROOT = ../../../tools GCCROOT = $(TOOLROOT)/avr/bin/ AVRDUDE_CONF = -C$(TOOLROOT)/avr/etc/avrdude.conf ifeq ($(OS), windows) # On windows, SOME of the tool paths will need to have backslashes instead # of forward slashes (because they use windows cmd.exe for execution instead # of a unix/mingw shell?) We also have to ensure that a consistent shell # is used even if a unix shell is installed (ie as part of WINAVR) fixpath = $(subst /,\,$1) SHELL = cmd.exe endif else ifeq ($(ENV), arduinodev) # Arduino IDE source code environment. Use the unpacked compilers created # by the build (you'll need to do "ant build" first.) ifeq ($(OS), macosx) TOOLROOT = ../../../../build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools endif ifeq ($(OS), windows) TOOLROOT = ../../../../build/windows/work/hardware/tools endif GCCROOT = $(TOOLROOT)/avr/bin/ AVRDUDE_CONF = -C$(TOOLROOT)/avr/etc/avrdude.conf else GCCROOT = /usr/local/avr/bin/ AVRDUDE_CONF = AVRDUDE_ROOT = /usr/local/bin/ endif # # End of build environment code. # the efuse should really be 0xf8; since, however, only the lower # three bits of that byte are used on the atmega168, avrdude gets # confused if you specify 1's for the higher bits, see: # http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/ # # similarly, the lock bits should be 0xff instead of 0x3f (to # unlock the bootloader section) and 0xcf instead of 0x2f (to # lock it), but since the high two bits of the lock byte are # unused, avrdude would get confused. ISPFUSES = $(AVRDUDE_ROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \ -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \ -e -u -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m \ -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m ISPFLASH = $(AVRDUDE_ROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \ -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) -V \ -U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x2f:m STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe" STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \ -lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt OBJ = $(PROGRAM).o OPTIMIZE = -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls DEFS = LIBS = CC = $(GCCROOT)avr-gcc # Override is only needed by avr-lib build system. override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS) override LDFLAGS = $(LDSECTIONS) -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib OBJCOPY = $(GCCROOT)avr-objcopy OBJDUMP = $(call fixpath,$(GCCROOT)avr-objdump) SIZE = $(GCCROOT)avr-size # Test platforms # Virtual boot block test virboot328: TARGET = atmega328 virboot328: MCU_TARGET = atmega328p virboot328: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DVIRTUAL_BOOT' virboot328: AVR_FREQ = 16000000L virboot328: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe virboot328: $(PROGRAM)_atmega328.hex virboot328: $(PROGRAM)_atmega328.lst # 20MHz clocked platforms # # These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue) # pro20: TARGET = pro_20mhz pro20: MCU_TARGET = atmega168 pro20: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' pro20: AVR_FREQ = 20000000L pro20: $(PROGRAM)_pro_20mhz.hex pro20: $(PROGRAM)_pro_20mhz.lst pro20_isp: pro20 pro20_isp: TARGET = pro_20mhz # 2.7V brownout pro20_isp: HFUSE = DD # Full swing xtal (20MHz) 258CK/14CK+4.1ms pro20_isp: LFUSE = C6 # 512 byte boot pro20_isp: EFUSE = 04 pro20_isp: isp # 16MHz clocked platforms # # These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue) # pro16: TARGET = pro_16MHz pro16: MCU_TARGET = atmega168 pro16: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' pro16: AVR_FREQ = 16000000L pro16: $(PROGRAM)_pro_16MHz.hex pro16: $(PROGRAM)_pro_16MHz.lst pro16_isp: pro16 pro16_isp: TARGET = pro_16MHz # 2.7V brownout pro16_isp: HFUSE = DD # Full swing xtal (20MHz) 258CK/14CK+4.1ms pro16_isp: LFUSE = C6 # 512 byte boot pro16_isp: EFUSE = 04 pro16_isp: isp # Diecimila, Duemilanove with m168, and NG use identical bootloaders # Call it "atmega168" for generality and clarity, keep "diecimila" for # backward compatibility of makefile # atmega168: TARGET = atmega168 atmega168: MCU_TARGET = atmega168 atmega168: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' atmega168: AVR_FREQ = 16000000L atmega168: $(PROGRAM)_atmega168.hex atmega168: $(PROGRAM)_atmega168.lst atmega168_isp: atmega168 atmega168_isp: TARGET = atmega168 # 2.7V brownout atmega168_isp: HFUSE = DD # Low power xtal (16MHz) 16KCK/14CK+65ms atmega168_isp: LFUSE = FF # 512 byte boot atmega168_isp: EFUSE = 04 atmega168_isp: isp diecimila: TARGET = diecimila diecimila: MCU_TARGET = atmega168 diecimila: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' diecimila: AVR_FREQ = 16000000L diecimila: $(PROGRAM)_diecimila.hex diecimila: $(PROGRAM)_diecimila.lst diecimila_isp: diecimila diecimila_isp: TARGET = diecimila # 2.7V brownout diecimila_isp: HFUSE = DD # Low power xtal (16MHz) 16KCK/14CK+65ms diecimila_isp: LFUSE = FF # 512 byte boot diecimila_isp: EFUSE = 04 diecimila_isp: isp atmega328: TARGET = atmega328 atmega328: MCU_TARGET = atmega328p atmega328: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' atmega328: AVR_FREQ = 16000000L atmega328: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe atmega328: $(PROGRAM)_atmega328.hex atmega328: $(PROGRAM)_atmega328.lst atmega328_isp: atmega328 atmega328_isp: TARGET = atmega328 atmega328_isp: MCU_TARGET = atmega328p # 512 byte boot, SPIEN atmega328_isp: HFUSE = DE # Low power xtal (16MHz) 16KCK/14CK+65ms atmega328_isp: LFUSE = FF # 2.7V brownout atmega328_isp: EFUSE = 05 atmega328_isp: isp atmega1284: TARGET = atmega1284p atmega1284: MCU_TARGET = atmega1284p atmega1284: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT' atmega1284: AVR_FREQ = 16000000L atmega1284: LDSECTIONS = -Wl,--section-start=.text=0x1fc00 atmega1284: $(PROGRAM)_atmega1284p.hex atmega1284: $(PROGRAM)_atmega1284p.lst atmega1284_isp: atmega1284 atmega1284_isp: TARGET = atmega1284p atmega1284_isp: MCU_TARGET = atmega1284p # 1024 byte boot atmega1284_isp: HFUSE = DE # Low power xtal (16MHz) 16KCK/14CK+65ms atmega1284_isp: LFUSE = FF # 2.7V brownout atmega1284_isp: EFUSE = FD atmega1284_isp: isp atmega1284_slow: TARGET = atmega1284p_slow atmega1284_slow: MCU_TARGET = atmega1284p atmega1284_slow: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=19200' '-DBIGBOOT' atmega1284_slow: AVR_FREQ = 16000000L atmega1284_slow: LDSECTIONS = -Wl,--section-start=.text=0x1fc00 atmega1284_slow: $(PROGRAM)_atmega1284p_slow.hex atmega1284_slow: $(PROGRAM)_atmega1284p_slow.lst atmega1284_slow_isp: atmega1284_slow atmega1284_slow_isp: TARGET = atmega1284p_slow atmega1284_slow_isp: MCU_TARGET = atmega1284p # 1024 byte boot atmega1284_slow_isp: HFUSE = DE # Low power xtal (16MHz) 16KCK/14CK+65ms atmega1284_slow_isp: LFUSE = FF # 2.7V brownout atmega1284_slow_isp: EFUSE = FD atmega1284_slow_isp: isp # Sanguino has a minimum boot size of 1024 bytes, so enable extra functions # sanguino: TARGET = atmega644p sanguino: MCU_TARGET = atmega644p sanguino: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT' sanguino: AVR_FREQ = 16000000L sanguino: LDSECTIONS = -Wl,--section-start=.text=0xfc00 sanguino: $(PROGRAM)_atmega644p.hex sanguino: $(PROGRAM)_atmega644p.lst sanguino_isp: sanguino sanguino_isp: TARGET = atmega644p sanguino_isp: MCU_TARGET = atmega644p # 1024 byte boot sanguino_isp: HFUSE = DE # Low power xtal (16MHz) 16KCK/14CK+65ms sanguino_isp: LFUSE = FF # 2.7V brownout sanguino_isp: EFUSE = 05 sanguino_isp: isp # Mega has a minimum boot size of 1024 bytes, so enable extra functions #mega: TARGET = atmega1280 mega: MCU_TARGET = atmega1280 mega: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT' mega: AVR_FREQ = 16000000L mega: LDSECTIONS = -Wl,--section-start=.text=0x1fc00 mega: $(PROGRAM)_atmega1280.hex mega: $(PROGRAM)_atmega1280.lst mega_isp: mega mega_isp: TARGET = atmega1280 mega_isp: MCU_TARGET = atmega1280 # 1024 byte boot mega_isp: HFUSE = DE # Low power xtal (16MHz) 16KCK/14CK+65ms mega_isp: LFUSE = FF # 2.7V brownout mega_isp: EFUSE = 05 mega_isp: isp # ATmega8 # atmega8: TARGET = atmega8 atmega8: MCU_TARGET = atmega8 atmega8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' atmega8: AVR_FREQ = 16000000L atmega8: LDSECTIONS = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe atmega8: $(PROGRAM)_atmega8.hex atmega8: $(PROGRAM)_atmega8.lst atmega8_isp: atmega8 atmega8_isp: TARGET = atmega8 atmega8_isp: MCU_TARGET = atmega8 # SPIEN, CKOPT, Bootsize=512B atmega8_isp: HFUSE = CC # 2.7V brownout, Low power xtal (16MHz) 16KCK/14CK+65ms atmega8_isp: LFUSE = BF atmega8_isp: isp # ATmega88 # atmega88: TARGET = atmega88 atmega88: MCU_TARGET = atmega88 atmega88: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' atmega88: AVR_FREQ = 16000000L atmega88: LDSECTIONS = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe atmega88: $(PROGRAM)_atmega88.hex atmega88: $(PROGRAM)_atmega88.lst atmega88_isp: atmega88 atmega88_isp: TARGET = atmega88 atmega88_isp: MCU_TARGET = atmega88 # 2.7V brownout atmega88_isp: HFUSE = DD # Low power xtal (16MHz) 16KCK/14CK+65ms atemga88_isp: LFUSE = FF # 512 byte boot atmega88_isp: EFUSE = 04 atmega88_isp: isp # 8MHz clocked platforms # # These are capable of 115200 baud # lilypad: TARGET = lilypad lilypad: MCU_TARGET = atmega168 lilypad: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' lilypad: AVR_FREQ = 8000000L lilypad: $(PROGRAM)_lilypad.hex lilypad: $(PROGRAM)_lilypad.lst lilypad_isp: lilypad lilypad_isp: TARGET = lilypad # 2.7V brownout lilypad_isp: HFUSE = DD # Internal 8MHz osc (8MHz) Slow rising power lilypad_isp: LFUSE = E2 # 512 byte boot lilypad_isp: EFUSE = 04 lilypad_isp: isp lilypad_resonator: TARGET = lilypad_resonator lilypad_resonator: MCU_TARGET = atmega168 lilypad_resonator: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' lilypad_resonator: AVR_FREQ = 8000000L lilypad_resonator: $(PROGRAM)_lilypad_resonator.hex lilypad_resonator: $(PROGRAM)_lilypad_resonator.lst lilypad_resonator_isp: lilypad_resonator lilypad_resonator_isp: TARGET = lilypad_resonator # 2.7V brownout lilypad_resonator_isp: HFUSE = DD # Full swing xtal (20MHz) 258CK/14CK+4.1ms lilypad_resonator_isp: LFUSE = C6 # 512 byte boot lilypad_resonator_isp: EFUSE = 04 lilypad_resonator_isp: isp pro8: TARGET = pro_8MHz pro8: MCU_TARGET = atmega168 pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' pro8: AVR_FREQ = 8000000L pro8: $(PROGRAM)_pro_8MHz.hex pro8: $(PROGRAM)_pro_8MHz.lst pro8_isp: pro8 pro8_isp: TARGET = pro_8MHz # 2.7V brownout pro8_isp: HFUSE = DD # Full swing xtal (20MHz) 258CK/14CK+4.1ms pro8_isp: LFUSE = C6 # 512 byte boot pro8_isp: EFUSE = 04 pro8_isp: isp atmega328_pro8: TARGET = atmega328_pro_8MHz atmega328_pro8: MCU_TARGET = atmega328p atmega328_pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' atmega328_pro8: AVR_FREQ = 8000000L atmega328_pro8: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.hex atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.lst atmega328_pro8_isp: atmega328_pro8 atmega328_pro8_isp: TARGET = atmega328_pro_8MHz atmega328_pro8_isp: MCU_TARGET = atmega328p # 512 byte boot, SPIEN atmega328_pro8_isp: HFUSE = DE # Low power xtal (16MHz) 16KCK/14CK+65ms atmega328_pro8_isp: LFUSE = FF # 2.7V brownout atmega328_pro8_isp: EFUSE = 05 atmega328_pro8_isp: isp # 1MHz clocked platforms # # These are capable of 9600 baud # luminet: TARGET = luminet luminet: MCU_TARGET = attiny84 luminet: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=9600' luminet: CFLAGS += '-DVIRTUAL_BOOT_PARTITION' luminet: AVR_FREQ = 1000000L luminet: LDSECTIONS = -Wl,--section-start=.text=0x1d00 -Wl,--section-start=.version=0x1efe luminet: $(PROGRAM)_luminet.hex luminet: $(PROGRAM)_luminet.lst luminet_isp: luminet luminet_isp: TARGET = luminet luminet_isp: MCU_TARGET = attiny84 # Brownout disabled luminet_isp: HFUSE = DF # 1MHz internal oscillator, slowly rising power luminet_isp: LFUSE = 62 # Self-programming enable luminet_isp: EFUSE = FE luminet_isp: isp # # Generic build instructions # # isp: $(TARGET) $(ISPFUSES) $(ISPFLASH) isp-stk500: $(PROGRAM)_$(TARGET).hex $(STK500-1) $(STK500-2) %.elf: $(OBJ) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(SIZE) $@ clean: rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex %.lst: %.elf $(OBJDUMP) -h -S $< > $@ %.hex: %.elf $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex $< $@ %.srec: %.elf $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O srec $< $@ %.bin: %.elf $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O binary $< $@ arduino-mighty-1284p-0~svn20130430.orig/.gitignore0000644000175000017500000000003612137772502020761 0ustar shevekshevek.*.swp *.orig *.bak *.o *.elf arduino-mighty-1284p-0~svn20130430.orig/README.md0000644000175000017500000000350112137772502020250 0ustar shevekshevek# Mighty 1284P: Platform files for Arduino to run on ATmega1284P ## What is it? Everything you need to run Arduino on ATmega1284P. ## Current state Everything is here and has been initially tested. It should work fine. There is more detailed testing which must be completed before calling it completely 'done' though. The platform now includes optiboot. This bootloader is better in every way than the previous version, so it is recommended in all cases. The prior one is included for reference. ## Installation 1. Download the [ZIP File](https://github.com/maniacbug/mighty-1284p/zipball/master) 2. Unzip it a folder called 'hardware' off your sketches directory, e.g. /Users/maniacbug/Source/Arduino/hardware/mighty-1284p 3. Restart the IDE 4. Select Tools > Board > Mighty 1284p 16MHz using Optiboot 5. To burn the bootloader, follow the Arduino [Bootloader](http://arduino.cc/en/Hacking/Bootloader) instructions. ## Requirements * Works only on Arduino >= 1.0 * Cannot be burned using [USBtinyISP](http://www.ladyada.net/make/usbtinyisp/). That programmer cannot flash to chips with >64k flash size. ## See also http://maniacbug.wordpress.com/2011/11/27/arduino-on-atmega1284p-4/ ## Supported Boards * 'Mighty 1284p 16MHz using Optiboot'. The main board. Use this unless you have some clear reason to use another board. This uses a straightforward pinout that is especially helpful on a breadboard-built unit. * 'avr-developers.com pinouts 16MHz using Optiboot'. Some people prefer the pinouts from avr-developers.com. The classic pinouts. * 'Bobuino'. CrossRoads' board built for maximum compatibility with Arduino Uno-class shields. * 'Original Mighty 1284p 16MHz'. The very first bootloader I ever got working. Not recommended for use, but here as historical record. * 'Original Mighty 1284p 8MHz'. Ditto, but runs at 8MHz.arduino-mighty-1284p-0~svn20130430.orig/variants/0000755000175000017500000000000012137772502020621 5ustar shevekshevekarduino-mighty-1284p-0~svn20130430.orig/variants/bobuino/0000755000175000017500000000000012140055246022247 5ustar shevekshevekarduino-mighty-1284p-0~svn20130430.orig/variants/bobuino/pins.ods0000644000175000017500000005066612137772502023753 0ustar shevekshevekPK&e@…l9Š..mimetypeapplication/vnd.oasis.opendocument.spreadsheetPK&e@û¼£ ……meta.xml james 2012-02-10T20:41:232012-03-04T20:48:40james PT16H54M22S5LibreOffice/3.4$Unix LibreOffice_project/340m1$Build-402PK&e@ settings.xmlíZmoâ8þ~¿å;¥P¶» +`¯×Þõv+B{wûÍ$Xu<‘í@Ù_Î[Õ¦I›æ¥R>±ýÌ0žyf<Îù×—u¶ $E>2úGÇF¸åë‘q»¸è~1¾Ž;ÇÕŠÚ`:hû.pÕ• ”ž";z9—f4<2|ÁM$’J“¤©l=àÉ2óél3=y`”ߌRžÙëív»£ÝÉŠu¯vvÖ G“©6ò]Í~*  "eBaƒããa/úmtb%Ÿ˜f`Œ;$| ˆ>ºTئ?TZ¤¹¥°{´š‘µîùš;*é’ÁDY g$ƒjïéAÊ•1>>ï½yð5¬T3ÈÿPGm² O†'Ÿ•á/®7™ª÷‡_†ŸŠâw]âu)wàœ´,ØeïR¸Fû—ØÑvWNJM©„vc8Dÿ]š )=D[ä-EŸ/™âÒ§ ¸àÌÅ Jªtü›iî’®òú¿LèÂÛøúý…\fyŒª¿ÑôlPTðrŠÚM¡§´O,Tg”>Õ¿ü‰­èBô9áëó”ä€Dßš™+çÑJEÜz»]Þò—ÝR™«~MàÙÊ—u~ò@¥µçöF §¿àãêøn'{‚Uüú.zà lð{îñšÎ×Hœ¹¦/älß@èÜzQp!t­®Çô÷ÃÊ"ÆtÑEú—3Âm`K‘‡Aù—ª(–Ôq€Ï6D[·êëµ>ûäåé8®ã—l« ÈÏA½µJ¶ ˆ „§stŒÚ{{ýÖ”_ë|_áw¾*Ͼ޾B}¶²ýf˜$ tíË üt£`I$œ§”½­,Õ`=~%¿Å/©X:òÓaÂh¶îŒÍü]ÿ(í‰Ú ï£ä’ßû;)kß¿@ð‰Ô±vãs[ù$£5WË™lá.z?èŸ1”ͯM–ÇÏcû[ âQ¤~o9ìêûCÎXMŸu›ë<¦òºžÄBí]©úÎx³zS ÷°Ñ{ñö`/ï½ÊñÿPK ;Ù-™)PK&e@ content.xmlÝmsÛ¶–Çßï§Ðxgî\ÏT‘è1mºcË÷n3Soã½½;LF‘èD[=x%¹ifúᢒçÀ2x-Þm"ùñ#ðïþãżñ{²ÞÌVËWgâEû¬‘,'«élùéÕÙßþ½98ûïÿí»ÕÝÝl’¼œ®&‹d¹mNVË­þ³¡½Ü¼t¹¯ÎÖË—«ñf¶y¹/’ÍËíäåê>Y¦¿zé—~iÏåR6Û¯ó£n û¿Þ&lý±)›ùíøãñg¶…ý_O×ã/ÇþؔՕêÿünuìÿØÌ›w+]ë‹ûñv–»Š?æ³åo¯Î>o·÷/[­/_¾¼ø¢^¬ÖŸZb8¶lîþ‚'ûr÷ë¹-5´’ybN¶i‰¢•–]$Ûñ±×gÊú—´|X|LÖGWÍx;.´êý:Ùè"Z® Ìãäÿ&_¿::º~ÿ„Tóäóx}tœÙÂÙPQÓãCEMýß.ÆÛÏHûZ×:ÓþïúÍ!®Ö‹cÏeÊfªj²žÝ-Ó•ö¿Z­ö—j~ànv{¹²Ýî´Ü¿½Ò_‚Å¿¬gÛdퟋOÆóɾÆW ¨Òt9ÑÒ%šÉï&ä÷7‘©ˆ òÙrÙû›)zè^¿y7ùœ,Æ‡Â³Ç 7gËÍv¼<ÔÌÚ4ª´ÛZ'÷«õv_1wÇw¾ºµäþÚ>os¼ë0¹iÑOëé,ª/Gµt7¢oâæï³äË¿gúÖp< [¶Ð>pgÉ<½Köewr’?î“õÌ(ÏM 4]i:8V÷/½_gû×õâãgb5½Ë1wsL6µ…êàöç–Ék¼ètw&«òìû”¡îžÙ´ö wš¥Í»ñ$iN“É|óýw®/Ü'7Ü¿Íu¿:Ùžu>^N×·g Ý_¥%³ù×Wg߯6ßf‹¹´o‡Ôo»r«‡õ,Y7Þ&_ÒBîÏ73]Òv¤ëÕr•Í|;[||ØØŒÆ›lÖUò¿ã<4Þ—›Ìw'Úþa2›Ž]±Û¯÷‰»Ïs—àʳõqÇ“•ýsµ¹×54=kdêÌÔDóS²Ô-¬û‹Åj𬗙"÷³íDw©w³?ôo[á÷jÂ\.Zå¹r.1xa›/³Íº®ßÇ뙽/¹4¯²ÑËòÊsI_7ÛdQæšÞ¬>϶fËé ¯ªC™J®é—dù_ãåÿÌ׳ÉzÕø!Á¯ (Kv-ìŽß¥¶+ ûÙ¤i³ï ìÿ3Š&+±?ÙîòmOªŸ]æ‹åYúK?±y¯{¶d½%›ÆÝêåÇu2þ­ù1Ñœ> 9uzÄ]ñ/³©yî/Tg(gK+À»žÐÅɪ.®ý¢×tžvqªº‹Sý¡xÚÅuª»¸Îpð´këVتB=±U{^œêôžvqýª.N?itÅ/nPÝÅ)Ù{b³«»¸v§×}ÚʼnvuW÷Ä{UTƇö‹ÁP>©âÖ¼Ö«/¹+Ó)þe¹,“ø9™}ú¼5g}S5á+~Ø$ÍÕýv¶Ï›þ¯·ë‡äøëÞŽáëNcý°nÞ?%Íôínü0ßæDy‚ÜÒt¶¹Ÿ¿î®gw4óÌ;[~jšÇ×Wgóusû±x©-ôÉa—ñq5ýzxõ¸×54Ý|N’í÷ß¹SÛÿï.Ã]óåêãÃl©«Î%Úã5ùá.r€¢öe§ÎUBs’ÌçM¿LZ;­£)Ž©ŽÙa8f—á˜=†cöÓcºAÀ]ÑMsÜ'ãm¢ßï9ZqÀpÌ!Ã1 2è*øê\w—À9Mž»<}¼ýÀÇxþ4·úÅ]¿m׺3…ÍÐûý÷£ÕÂŒº|×Úýû»Vþ(‘Çý<»oÜÌ–ä¾Y­é¯öõ’å°W<50zýö–¾Á˜áöõõß~&?êÇÙVãý·_ß“ù~2[nŽ;17Ä<¹£¯áûÙ’ázõÓY²~丙$Ý3ñvU­VÃýU?§™?&¯Î†º{üùŸíÆ_¯íóB®Ô¹7Wí†èüYÈëÛ‡·’uv7_·g™ýnÐ9\²èÐßýWO;äã :VXûpmžª“^ÕIúªÓ‘B~Ì·?Ý~øéíÛË}Ó2fRãa>~u¶º{ùjôÓÛÑÅíßÞêÿþú—ÿ{Xm¿ýpùÝß¾ýõÅ•|ÿ­ûÇù7 };\ísþ¶ÏiìÓF:Íþælã’4Ëý³¹k sÚöî$톾‰Š Y¤ª}ñ÷½f²êË$3´¨~$8\ÿeHSš£{7 Î‰ÿ¥ß\ˆè•»þSß^?ä·ô(ÐÒ1z®v çw–»$â+ÿáÐ8¬!šé] `E œ>µoµFmÑÝJ©Ýõ¨Ýý¢¶ðt1QÛ«:I_u·µ§¶B©­€îB½w¿‰¤¶ØDè~@d©É¢¦¶Âúrb² êË$³S;¤ ¤¶‚¨¥ßr¹kTîúÏÛµs¹ÔÔ´t j‹"µ©cô…P›8D‹PÎ+Rà´©ÝÑì}ýö¶­mpI ݲ!z•¢»ç!®÷/„néuoLèöªNÒW].5çwåwè8:ïÝo"ù-w'‘ºGY~g²¨ùÝÁzub²êË$³ó;¤ äwâw”~KèžQ¹ëDÓ›$q¨5Ém^‚ä²Hrêhý¡ƒœ8X‹ Î…-R $úáÐ’\a$W ѯ”ä}äý!’«ÃE(&’{U'é«. —𓼋’¼ tÝ÷î7‘$W»“(Ý#¨,É3YÔ$ïb½:±FÙõe’ÙIÒ’¼ ‘|>@A?úšÁ{÷›’á=݉ á6‹ô ÄEÔ—IfG}Hˆú„ú(ýæB”¹ëzÍý‘Å}>—ù–.ü^ùOì°GþA>qˆ‰ž V¤Ài#_÷óšï¿\›Èêg¯ÿ¨ô“1ÒâªÏ?§íMi—ŸÑ†‘ï.0ÌYürM~L{¯µ/øa?Da?z™á{÷›’så}Ý} så6‹öC Ä…õe’ÙaÒÂ~Á>J¿¹3\«v®¾3²¬ÏeR£>ÐÎ%Pß/¢þ‰Õã¨"¨'д[¢´˜wÚ€ø>hø€¿ê6İÒqoàWè!W æjº¶ßM»`{»dÉ ‡¨éK ñûØ!ÿ˜Ÿ}ܦý¼@æi?˜WÿëŸÞ½¶Á%Ì@÷ðP© é›sUüýÄ3ìð9üUú5“&¾ÈZíÂ=[Ð ÈüJ8÷+íB—Žê óM2âïòÈŸP{2z¥BÁ*³éüÏaað3èHW æjz¶ëÝõÂæŽÉ>²Éùjö2üÿÉéæLG³€÷\.z±5xxýî'dÒ< ôO•ºØ.[«êI ‚åõ´¯éÏ⽯_]LŒñ ¨*fþq/;yg gž%¢íìÒA~a¾ÝB&\ùƒênF¯Tt`•Ùtþ°0øA´¶‹«s5}Ûó¦ðî†É> €EÈBÍ_æ@äþv3¸£Ý´ïÈ<íÇ;#ðnô£ /eú‡Ç€A•¤Kܪz ¨`É=íËú³˜ù›ÌÑLOUL à>xòÝÎxKD[áõSÒ›OºúÙ§€lùSêŒF¯Tta•Ùtþ§€°0ø)´Å‹«s5Ûñ¦}°»_²P òg€Pã—yPÀ3¹3žÀ¬ñè#7íyÀð2OëàOå}¸ws¡£êâu£Ý0WÛ9gZcæýÆð™þEmñNû^ý‹ ºöãŽyríζKD›æíÞièÛÁ»Í#Ç;ê«F¯´‹ì³éá–Ã4Ћ«û]¾jØ^V³»sÞ07Lî»ýB>9ØCÍ£*}Ãõ õöiä`Ç,õècËÏ…/VâÔßñß³ˆñ].Ä{± Æ’™_Á@>íÛuõ«)LèÔñ¸çž€|¿„3þѶ{û±ú®î°q|›GŽxÔ™^iÙcÓ">, FÔìeßOîÉ'0S>ú˜ž _¬Ä©!¾ë#¾k/-â{\ˆ÷bA1Œ3!¾‚U{´[êUÿÅ„ º#wÛÏ—pF_"Úpo¿.¯§;lÍžÍ#G<êÄF¯´ ‹ì²é–#´Þ‹«‹p÷&¯gžwß+ä“#>ÔìeßOîÁ'0>ú˜ž _¬Ä©!¾ç#¾c¯,âû\ˆ÷?ÈeX˜Ï„ø ¾Ì£Ýk¯z_C:uG<î±' /á ¾D´ÍÞþó»¾î°Oól9âQ6z¥Xd‡Mˆø°,ñ á^\%X„¸ïúá*‡øB>9âCÍ^ñ}ñäÞ{3ߣYà¹ðÅJœâû>â•E|Ç"~À…x/Ê{&Äóûç o ¢`²ÙcÝ­À„NÍ/q«= ™zIgê%£­öR»\1Ðb¥ëò¨/Qç5z¥ ©ØôAˆDˆx šíÅU‚E¸a€5ÎÕý«Ax'‡øB>5âƒÍ^ññä–{³Ü£Yà¹ðÅJœâ>â¥E|×"~È…x/Ãjz&ÄóïŠCl0\ý®&têŽxÜSOBî]Ò¹wÉhO½tûc¥zlãòÈZ¬Ñ+•°HɦD|XŒxÐU/®, ì>8º5ïæ_È'G|¨ÙË ~ žÜ[ObÞzô1 <¾X‰SCüÐG¼°ˆïÄË6â½XP ~íLˆçß–ØI˜_€xú‰—Š{èIÈ¡K:‡.í¡—nekŸMNøP³—!¼Oîh'1G;ú˜ø‹^¬Ä©Þ7¾Ùe²sÞ¸%ð…Aæ- • ¶7L„ç_jG\1U¬ØÏW>EÐ<3áqk; ™gIgž%£­íÒõtú6Ôw¼ÖÎå‘õ8£W*°Êl:?áÃÂ`ƒævqÕ`n¥zÝlŽðùlr‡š½ á;áÉ­í$fmG³¿sÑ‹•85Âû¾7#û­†ìêØº.¿é( 2oý¨dp½a"<ÿ÷rÄSÅ‚ýá ‚æ™ ;ÛIÈ;K:ï,íl—~§oC}÷Á̹ŸMNøP³—!| <¹³Äœíècàw.z±§Fxßöfd dOÇÖUùÄ`ySÁ’Áô†‰ðü¦7ÄSÅzýá ‚æ™ ÛIÈ:K:ë,ml—:ÛèÛPß}°ëË#'<êpF¯T¶a•Ùt~‡…Á„­íâªÁ"ÜJõºÙáóÙä„5{Â÷“ÛIÌØŽ>f~ç¢+qj„÷]oFÖ5QöMl•ß9†Œ7,›GNxÔàŒ^©°Êl:?áÃÂ`ƒÎvqÕ`n¥zÝlŽðùlr‡š½ áûáÉ}í$ækG³¿sÑ‹•85Âû¦7#»õär´“Þ4°d°»a¢;ÿÖ3ÄC½V¿U8+Ü‘NAžWÊy^©hGºt{}é' çl5œjMF¯TJXe6Îá¬@Oº¸j°ôµRw=d#GæL5–ƒ ^ËËä^t ó¢£Vº¹¸ÅJœ–}£š‘ÝtPr¹ÐIoîV2XÔ0a™ÓW⊡^`_,ã.r ò©RΧJE»È¥³ê;Hß8Y,góȱŒÚ‰Ñ+• V™MçÇrXŒeÐG.®,z­Ô]™Çr&Ë¡/ƒå!€erÿ8…ùÇÑG+Ý\Üb%N Ë;$7ì“WgÃ3Mç_®M|©ö¹Gì«NC þ,”ïëòLë¯xWXß\Õuj\yÓÖŠë3xæq_®éãÍ&.+à?n1§ +åL¬T´Å\:ó­Ú }³â.œÿ¨×½R9€UfÓùùó4™‹«s5ÆKüª“öÁúfÉ>²ÉŸBÍ£é*mB¿ÿMÓÈŸ0‹9ú˜Mû0pÌÓbÿŸRø€·•JDDÔ‰LÇr!=þµÜ%,“us²š?,–›æ:¹OÆÛdj>…;ú^Õ)†ªã²¼¨È¸!œ‚,§”³œRцpéK·ú¦F^È]9Qg0z¥JÀ*³éü@ ƒ ZÂÅUƒ}é¶R½þ1÷NžÏ&r¨ÙËY@&7„S˜!}̦}¸@æì§dª"íé-”GúZ–³‡Åìí¸l‹ èD³}—jVà?Êkê¢ïv¡Ÿ‘ëNM|h·‡@ô©¨Òwâ j³¨©‰nó@¬QöA}™dvj†4Ô7õˆÞÓCôJ»ÎÊ"ÑÞ$9jBE¨©hó2‹±€µXÔÔĶõ Ö"sa‹¨5)G. ̼äáÿ¬$ÿgOÞIOû ©ã»e@vüÎ?z«Œtf²Ó¸¹D&-m5+Ñ ˆ5@y.e)CŠ@R‚›cDï!ŒHs‚Nþûa?‡š‹öѱûtÆß#M¢æ"¶q`±—‹Q¤@ ¸H:TYù§!ù}4½/ëŸöA}-¸ˆï1™Ø;ûè &Ò©È®¾çYJ›EÍEt›bCPÞKÄÅ"‹à–ñ;J‘æÝ‚¯†—CÍÅ@û–àb·ÈEò=$°-$ˆ³ˆ½\Œ"jÀEÒÁȪ¸È?ïÈï@)üîéë¼~{KÿœS-[ñÝ ûxç½µC:uÙÓ÷-2«i³¨ÙŠükmP_&™®!M ]Áí¢wsPF¤9AÏŽ½Ê,aó¹Ô” ´t ÊöŠ”%ßÇÛÆ8D‹Í+R ”%~¬Š²üó”ü†’Â…®‘/E»_ |oȼÝy·Go¬Nröõ‹ÌÚ,j¾¢öúÄ…õe’ÙùÒòÜL!z/3hç6û€ E.“š®v.A×~‘®ä{(`[(hÚ­@QZÌ«S™·ÇãrkⳌž‰<þÉ€Öâ±:·§ ì¾+‚€Ü×…s_¥wE0®{Ȧ6‹š¬µÈ§×©Ú ÆL2;]‘V€;"ÄU‚6ŸÚ]ÑS.—²Á&/±´Èß!M¢Æ¬ÀöD Ö´¯B¶˜WÔ2ï5Ï…ÚžÜ<þ)‡y«6§ã ^`¾Ó€Õ…sTÑ;¤;õ}‹lh³ÈQ‹ÚÞÓë”CPc&™µaY0jÁ]â*Á®D²RÍ9†Éq.—µ¡&/ÚaµäûlŸúhMû(d‹y5@-)³ª)æ_]K<[ ŸÃŸcX$öËuëÝ;¦áâ*^lqã"Y¦ç™"Jï+ ô[Í%²¯€Ë#ç-jjC¯THXe6Ÿ¸aa0qA£¸j0WcÖÌØ}„Û7@ß.Yèȹjú#É~vH#'/æiD·i¿/Yö’ÍVÅ^þ—\â9TøþœýB´ëŸÞ=qçî“[ %pC$Y±çÅ"¢=‘Ò7Za>É@Þv]9~Q³z¥BÁ*³éüø ƒñ ú#ÅUƒ¹³˜Æ¾Ñ qÞ0wL¾…lrô†š½ z€^r›$ù$ÑÇ,à„”‹^¬D Lº&¨*W°\˜öåôY\õûõëw?ñ¼«*œq£%»çì"¢½–Ò \a>ÿ@&w]9ƒQëz¥¢«Ì¦ó38, f0è»W æjÌâ;+¤{Ã57L–Ã`r‡š¿ ‹%Àbró%¹/ÑÇnÚ÷€ dÖ€À¤ë‡ª"pK‰i_QŸÅPÙ ™~dpcиg“€fÆæ¢+Q 3Šrm‡À¿:‹øñäY¾ïbÛ¡{ ‰ûSIÈùF:çíO•.¾2ï²0Ëå‘5(¢W*°Êl:?€ÃÂ`ƒþTqÕ`·=0[ÖØ•WRB»"ä³ÉjöÛ"ø=×!À˜/}̦}¸@f °Ëüu vù1ˆÇæáEe^å«m¤++°…”¸+•„o¤s¼‘¥]©Ì¨ãbªáòȱ‹Ñ+UV™MçÇnXŒ]Е*®ì‹­0R-W´ï_>›»¡f/ƒ]`—ÜJb~Tô1›ö9`à™5À®ò×3Ìü–Ÿ{|.ìÒ.L«Þ ûâuƒþ󦊇œq?+ ùæHç›#KûY™e7zm9zQ{#z¥}XdŸMÞ°,¼ ›U\%˜«QÊHµdíœ7Ì “%o1Ÿ½¡fQ•òÇwµÚ§‘£sµ¢Y`@9¾X‰:@Øk-Űš Âü®VÄßhU¿/”î3è_§+†0îŠ%!÷éÜwdiW,óÊâŠåòÈ!Œš$Ñ+íÁ"{lú@‡eÁ=±â*ÁBÖôÒÖ÷Jv-dEÂ…|r‡š½ „»„ɽ±$æE³bsá‹•¨„½ÖR ß3A˜ß‹Ø®¤ú‘uŸA¿š®bãÖX2ß‘Î|G–¶Æ2f ˆ5–Ë#‡0ê‘D¯´ ‹ì²é!–C4ÆŠ« YÓK[ç+Ù³•9òÉ!jö2î&·Æ’˜5}̈ͅ/V¢öZK1Xc1A¸‚ÅW´Îü*ÓO/T aÜKBÞ;ÒyïÈÒÎXÆ—ð[€eóÈ!ŒZ$Ñ+íÀ";lú@‡eÁ}±â*ÁBÖôÒn}UßBVå \È'‡p¨ÙË@¸@˜ÜKbÎXô1 6¾X‰:@Ø_ŽÁàÍa~g,âÕÉü*Ó“½Z+ÜKAÖ;ÊYï¨ÒÆXÆŸÿ1ÆryÔV¨C½R‹Tlú ?" „°m±â*ÁBÖôÒÖ÷J,d;9ò©!lö2&7ÆR˜1}̈ͅ/V¢öZK1| Ãa~c,âùU¦ã®¸/–‚œw”sÞQ¥}±Ìsˆ/–Ë#‡0jD¯TÂ"%›>ÂaY0„AW¬¸J°5½´µ½’C ÙnÂ…|r‡š½ „‡„É}±æ‹E³bsá‹•¨„½ÖR »õ2A˜ßKy+%—/¥ ÂôÓ C·ÅRñŽrÆ;ª´-–jëÛ±ÅryäFý‘è• X¤`ÓB8, †0hŠW ²¦—¶®Wªm!ÛËA¸OáP³—€°ß{ÒÈ!ŒÙbÑÇl±ùðÅJÔ¯µ:ôŸ´pA˜ß‹ø«]~„é§*†0 ßå|wTiW,%ô틸b¹ÂaY0„AO¬¸J0WÓ1½´5½RÂB¶Ÿ…p1Ÿ¡f/a@˜ÜKa®Xô1 6¾X‰'BØOÉTÊ®>ˆß}N’­<½½š?,–@ÑÉJˆôˇÅÇd½+»i®“ûd¼M¦f´tWbšÜæ[{áMÿ0W.ã¬ÿñ\T,>.Tebö\/ãEÅU=%>×@QqUƒSϵô ¨¸ª9±çZñXT\ÕRœã3ï [Ù àã3ïÁWÙ‡GÇ+fÞ免ïOcUñÍåÉјõS¦›Ë“c1ë÷Ó7—'GbVÓ–›Ë“ã°ðM©ž./OŽÃÂögxƒ¸<9 .†.OŽÃÂßü“Á÷êòä8Ìm°Y™¹÷ñŠi7o**>93o«\ÝffÇ+fvk¯lÕãónVÝæíÇ+æÝšåftz<ö^"ÇÞô§Çcï5Qpì|r¼äPÂÙ‚ÐãSû•ÛÝGWV?×c"—®­§RBÄ]ØHèæo­GšÏz’9³ú(qÃ*:ìUÌÀJ…(+¢©s-ÊUÏ÷UH@\á ŠUœà+õÁ¹s³ˆÅkñ¹b9$Ôªº”ç{¬ºJõSü[[£¶n}‹½x¡ ‚¢ÚW€x-ˆCâLBWÿ¨W¿,£>}0gRÜü»Ê²ÂZÜvȳ é±<#àƒÅÝ~öâËÓ›á‰Z,R—É;CêÀTëÆ· U*éw¯áµìU]µÓ¡«JÕ PX<¤æÆ'XÖé[¨IAIÊ8‰²æãOå8hÇ[Yó+u¤2°R!z–Ö&IœM׫ef6g¦×ƒêimI¹ÑPÈ+BNǘôQ,nà€T K¼â‰-ÂàÁÓÇë>F¼"S)Áç©Z䚀ôÞƒ«‰tÌ>ÇZŠ‘b_aE¦‡ÔG±õ ½‡Åqþ!>Ðð%§«"c:0l¬‡éG*¯S‘i­L<µ÷t‘×úžHEfR,h2nH:zª’c¥B”• Q7 µX”ÅE ¬Y5½®cê­:+ËÂ:Á7uÍ!² üÖ§Ñ&ÕÝﱄß- Z—'€'¥È–sÔÛÔ´Àk ÖhYq›gÒò»ÃéGbUüMqÎnµÐ.÷v[„×¥E©²랺hŽ€÷bËùIÃsØqý]àSzõ«É»Ú VÄàØ†Ô—ïÆÙœ”¨ƒò²ê²yX& ê¤"± ë,L§2RÌ?©)WÒ›Jjz€V ¬ÔÊÀJ…èy@ú‘:ã·,|g­qƒUÓ4O‹6‘·ª°Ž,›ÿU> m‚±h%¶·üv‰-?-Zc¨ö/%nó»©0bM:Z'X<¶„#,ï¤hÁ½Øò<ؼËÉû²# %õëÙx Ç>H¾Ã»·éèí8.Æ,ªiíšê²yL†Ž}rnÙ|·š“§«&Í4ÍSO‚åg¼ Hi@ºE„­¬+u€2°R!zþ'öMñ=ÄHEžÀ^“tÔ+cšõÜðMñ*ÿ,¶.©ÈÙŽHõ +8¢ÿ'Ò¦q¬&•8Œ÷Ò´ÀÂ7©×u|Zvpð5+8¦ÇBÿ‡üľËLP Oq¸êá¥ç©³dB5‘gëh­9Vêe`¥B´ mB,H­)ªµýíq": ¢ÿפõ¦‰.@j0áßó„œHÑÿ ÒâXߤ+Ô+Tê׋¤ÿÊÓ»ôr¯·EUI@úýQÜê܉z˜xGî •ß ¤"Ⱥ©çБZbA HS!ZhŽ•:IX©=ÿ¿Ø‹eˆØe…lózð:6ÔˆA½U`EÉñ`“Än¤¥i]P`U·YÝ„ˆ5µ2¹Dx Å/N¢¦ëRaÆ@ÚUV×rOÕwï¨j-H•ýXA²>³ô6ª•ÏuO›¯Êƒà%Q—)€󼓨*ö7ckJä‘ç}=cü¨Y—‘=Vs¬)¾7ä ~ê5½‡Ïè¨>J@ÚÐ,jzR-¥U+u˜2°R!ŠÚAªBÈú ØP ¹Åo‰›§hí˜ÕS„cËÙ€´É!”±¥E >K¹…[H}ßN¤¸_ê #ަšÙ>KÕàÞHhÿ+i3Ao»òèov`Vl5s^YÂþ)€´€{×¼ÿªa—‰ÚzjUöé±Ð½Q;H-R'°è様ÏÁS°Ôsw}ñï9# ¸´b5 –ÆeûB­X©”• Ñó;H?HDA£dŽÕ HÕ©}vy\–åÍÓh“ꂞï±<ë¬^4Z}õÒ¢Ml1Ãõ/nù@ZÀ½ÏÒú}B"z¯ýœæñ¥µçîŽÂ÷³ÌX…(û±ž•sM×…F¡ßd§Mšå1f)¡åSÆqý“ÎjRß¹­Îi ¬g½å÷Ôeù!€3yªßa¾¤¢hµ:kŠXž€T—ßq.Û+È–ÕZ•:FX©íH-#»ˆ¨ÇÔeeY®ÞªOXµ1 mÎñU6Hh*I³¦¸åS)æ¿ -¿;3OÑž»»Djú¬f¹{R'ÀlâÓ:‡#£ªÌ[Õ ÷®8yW»–Òï2kR… 6?ò[>¬îÝ:!j U,+byR]Îatº ©¦Ö ¬Ô1ÊÀJ…h¿ŸØãS]„P­£À®)^ß‘€´üöíf?±¿×Éü„³Q0 Yàw$ -êª0ˆ;ãv¨ï1io¹¢hRî^[²jYõUOãlDZš•éŤ÷Ê@н—+.Öã„–ó,N·ëNÞ-Lªþ|øk;5-Ócaøîô{+Oœ`Y¨W¬‹[¨ 3fūס¯DêžV ¬ÔÊÀJ…(ê?iª­ixÑfT:*‚š-–‚yª9o7¢g¬Óhꂞï±AP±»UO'Qï9"èd0 ùOøOšê°xŽù\=ÖÛ4¸ÇºH˜ôº8ò[[Èéa6|´nH@z†– ¬ÔÊÀJ…(+¢¨¿ÝPìÁ„Ž^ÇMæN˜>9Us®“m7ÇrV<º^èá¨KåìV‚‘Ýdîb‹g‚×-¸µ‘þjý“wôpyçœý›²z™;ypÀ÷†haf‘÷òÛÃCÿÚLýÝnQëYNœI¯¹ulaf‘wQDàPø9°@¹Õ¢œ¹û‡­.4¿µxFöXµFÿí†úØgÖ³æa¤tõŠuq/ñЬ (k!ÜÐë…Äî+k¡ÀJ¤ ¬TˆL@*Ј…ÚðºØÙBîZ˜‹PA¨¶^åyd‘ç¢5Gµ$¼ŽÛ€tꤎú_ŒLV qGˆ°nÇÇoõ½]6zù]Cõî7Ur>Þ #vi—Y|AXÒ˜cÕç$“*Uèµ›«Æ]Ïæ¼ H»Xh0Z€ThœYóRgrÅ7ŠÕ ¯Ü†ñåäog‹DˆR‹LzÒ¨ybÜ4û?hWŽ/â„.wÅYUHdÇ€&?;ªvQr¬Tˆ2°R!òÒ:Yý<¤E[úr@ª.•=€ô=«ø ô`@Z í¼€´Ø  †n%ð°( Öëí³c‹·Ë@Šù{)!„È}ëü™Ç‹´Ë,?tôXå÷ÛoHHIô,µ/ññ"í2 жöR"ÂÉÕÃY€ÔCÏU@úž*=í2Š&ðRÏ•&ŽkÒ.^jŸ=Á*ÔK³)fž€4¢äX©e`¥B4bi/ µ Äú¶žÔŸ=¢Ê2;HïRË8 â#@Z`}Á‹9—Äo—)€ÍèÛAŠÏ“ëü–%aFRU¤]6¤¤/áƒc ýæÅzÍ"í2¢;Hï%k¾p* uZx†üí2 ¢±;H1qÒïåw`ÒÍŠH5•+¢ ¬Tˆ:vªÓjHùé³€TLÏ Õu÷\@Šy)1ŽRÜHEXŸ=çí2 *Ûf‚©h{¿}·ß¶³ã©Öj€Ûºû'öjQ†8¶B¶Yb—ÞU…¶Ë@Z ­½€OÕô8ÓÂö&€Ô‰a‹Hß#¿Ó†Rlëp@*.ÒÓ,ÕÚ3´ Å"¦B”+¢ ¬Tˆºw€oâ"B,? ið´ H‡XEsž¤Xnßß -ÚĤH;=Ô®¹0TiùjgÇo—)€Ûºâéu±SæÞú`¸8s8>˜„šúxW“ú~b¯šK)io«gºG§Þð%§i—Y€Tø¿6Eȧ3àú¤cÜ·‚ü5HÑ¤ŽŸØ7»«&ŽkÒf>žâŽï·n@c¼jRI@š Rr¬Tˆ2°R!:ä'ö H=>cÒç ï'öêzäY@ÚtARÞ.›Ò&‘zbnþÞƒ m—Í©¿¹؃£Ô¬n„ÈÛPi—)€Û:pi1ÞH=.Pé¬×tŠüNH ´uþÄ~?ù˜€t³"RM%ÇJ…(+¢p@jÍÜ­]ø¤Wâæöžc´, õâ†ï)®_8µó¸ÃHd˜€´Ì¤¢­»bzv©ßHÏ ¢&²™î–À¿AÊe%³úE5‡éî›%Ò.S)ªïoò†T_#>Þa=¶üãÙëøøá¯–¿]†ÒzBò¹r -îÑó% —íà"RM%ÇJ…(+"H=à‘Rõž­ººñÒz{üë#îÀÁ€KiôXbq§šhÒf°bnMfV zêEâ•àøØ"í2b) ^×›™–G§ÌþEòñ¤Š·Ë€ôâ$ͳ€Ô+H»lH=s¬ZØÓÜþLÄK)HÐ,» ¤ØÖ ^ψõ®zŒS(HÕGüÅ}ôªð*¶ø­8{>J@š Qr¬Tˆ2°R!zx)ž’5£˜©e‰Hq/™Z•ΤVÃEX夂@º¾E|bRu9c•e¥ÇÓ÷ˆ·ËH.z©ßzÙ÷7Æ‘²®"ÞOµˆ¯qQc£Ÿ‡‚ðptª«¬—w]ÜWÖË?ØE.òn vB¢G!]±šU³,1]Àl‘—u€œí2¬ï¤¼æç™jñͲpÖkáyrQëJ6¤ï —Ô+¢ ¬Tˆ)Ÿ€˜K©e@ªšô†â‚€Û:"ÙzÖ)§PÁYZb[' ÝRçÒbÂÇi³,’ÿ—Á½…¸¯6¤ž=Ê{W'¤VYÖ£íøÑÐÙ.Ãúxlë@@jeOÒ®¢OÒ‚€KI@š Qr¬Tˆ2°R!òÒ:Yý|˜3a¶˜jÉŸ°®ódùʺ%®Œ1©ãoZ HÅSN@Z €êdNêv°x»Ì¤Â/ ½Ò`¦déÛU1OYžÇß â«Y€Tø¿Z\Ê Ç{QÅË"Ž|AçŠûj Åü½€Ô3ƒAg½=Þ+«¼,¶ŠÃWÃi6íø_ì=W¤õÒAªe½!ªH+$ JŸZDɱR!ÊÀJ…(|©xÄH-ˆe=Nðà‘"NÞZ–ER$¢âôÏÿT{ö%ëÁÒj—Íi1A}ý)@JÊ"¹´ž.â«Í)†ä%Žþ—ÆY–(WtZv€¸¯¦Òm¾ƒ”g{»,+OÌöH9}5¬G3vÚAZßµþ}ƒˆ“F¥O-¢äX©e`¥BÔ±ƒ”̸ LØ‘^ZÙ’|8 łм#eù o©WB ë¤d½ê »ºà& U‰¨8™¨yž*Þ.Si¶¤2y,{a÷sO«RlëîŸØc2ŽÍÞ®·¬Tiùj mÝý7H‰Ž#c¤ž²Dúa$p9}5Ì-ØÖ±ƒ3yò¢OÕ‚€ËJ@š Qr¬Tˆ2°R!ÊÀJ…è?aDi€âŸIEND®B`‚PK&e@Configurations2/images/Bitmaps/PK&e@Configurations2/popupmenu/PK&e@Configurations2/toolpanel/PK&e@Configurations2/statusbar/PK&e@Configurations2/progressbar/PK&e@Configurations2/toolbar/PK&e@Configurations2/menubar/PK&e@Configurations2/floater/PK&e@'Configurations2/accelerator/current.xmlPKPK&e@ styles.xmlÝYkoÛ6ý¾_!(CÑ•%?ºÆnì`h1t@tmºa‰’¹R¢@RvÜ_¿KR”õtÔÇÖuGä¹—‡‡———ÊÅå}Jæ‚°líN'ëà,dÉ’µûþöïܽÜüpÁ☄x±°Hq&=! Œ3±2k·àÙŠ!AÄ*C)+®XŽ3k´ª£Wz(Ó¢5×ີÄ÷r¬±Â6lÑÝø‘5¸nq´k¬° iÝ:Î4¸*óh|¨Ì£ºmŠäv`}ÏýkèÔ¿®¯ŽqÅÓ±c)lCª“|ô4 ºnÏ«¨*³Ù5ÝY,|ó\CïOÂ÷œHÌkðð$l[Ø4ÞŽàýY#—ÖékPÒBÌeß·o}Õç©t ¡ÌصSbænì‘38bb/Â!› ³•«fÇ<+‘ÖîK(Ê"ççë[×íf‘)¡‡µûåL¼hÂLÛSçØúÔ)q¬àsçï-È|_@ê<à\³Œ5;oHzWÝá\5»^á¿Ðï…óe¢aXT¹/B!»=䨄i‹‚Át»Á/ ™þf"…"×ih¦”ðœaN ÜSaž5 9‘!d„˜Üƒ­ZñšŠî ä-œiœ§H5v¯÷çì¡Í_?uŽ»øÎo±8MÙ©2kuc÷šÓ=ušey1'QZ\dP•ÀÕ[Œ`”D=‰Ô ’ Ê׃ê¿ÝŠÃ“d U*„`ô©âÌ>K¦°ºÐnGÙ1^»C¿ÆH½=ù: Sõ‹JBX˜$ó”§êX„ŠÐ:‡ FJLØÈ#*jÛ¬÷¸ÉN×n†pù // ATMEL ATMEGA1284P on Bobuino // // +---\/---+ // (D 4) PB0 1 | | 40 PA0 (D 21) AI 7 // (D 5) PB1 2 | | 39 PA1 (D 20) AI 6 // INT2 (D 6) PB2 3 | | 38 PA2 (D 19) AI 5 // PWM (D 7) PB3 4 | | 37 PA3 (D 18) AI 4 // PWM/SS (D 10) PB4 5 | | 36 PA4 (D 17) AI 3 // MOSI (D 11) PB5 6 | | 35 PA5 (D 16) AI 2 // PWM/MISO (D 12) PB6 7 | | 34 PA6 (D 15) AI 1 // PWM/SCK (D 13) PB7 8 | | 33 PA7 (D 14) AI 0 // RST 9 | | 32 AREF // VCC 10 | | 31 GND // GND 11 | | 30 AVCC // XTAL2 12 | | 29 PC7 (D 29) // XTAL1 13 | | 28 PC6 (D 28) // RX0 (D 0) PD0 14 | | 27 PC5 (D 27) TDI // TX0 (D 1) PD1 15 | | 26 PC4 (D 26) TDO // INT0 RX1 (D 2) PD2 16 | | 25 PC3 (D 25) TMS // INT1 TX1 (D 3) PD3 17 | | 24 PC2 (D 24) TCK // PWM (D 30) PD4 18 | | 23 PC1 (D 23) SDA // PWM (D 8) PD5 19 | | 22 PC0 (D 22) SCL // PWM (D 9) PD6 20 | | 21 PD7 (D 31) PWM // +--------+ // #define NUM_DIGITAL_PINS 32 #define NUM_ANALOG_INPUTS 8 #define analogInputToDigitalPin(p) ((p < NUM_ANALOG_INPUTS) ? 21 - (p) : -1) extern const uint8_t digital_pin_to_pcint[NUM_DIGITAL_PINS]; extern const uint16_t __pcmsk[]; extern const uint8_t digital_pin_to_timer_PGM[NUM_DIGITAL_PINS]; #define ifpin(p,what,ifnot) (((p) >= 0 && (p) < NUM_DIGITAL_PINS) ? (what) : (ifnot)) #define digitalPinHasPWM(p) ifpin(p,pgm_read_byte(digital_pin_to_timer_PGM + (p)) != NOT_ON_TIMER,1==0) #define digitalPinToAnalogPin(p) ( (p) >= 14 && (p) <= 21 ? (p) - 14 : -1 ) #define analogPinToChannel(p) ( (p) < NUM_ANALOG_INPUTS ? NUM_ANALOG_INPUTS - (p) : -1 ) static const uint8_t SS = 10; static const uint8_t MOSI = 11; static const uint8_t MISO = 12; static const uint8_t SCK = 13; static const uint8_t SDA = 23; static const uint8_t SCL = 22; static const uint8_t LED = 13; static const uint8_t A0 = 14; static const uint8_t A1 = 15; static const uint8_t A2 = 16; static const uint8_t A3 = 17; static const uint8_t A4 = 18; static const uint8_t A5 = 19; static const uint8_t A6 = 20; static const uint8_t A7 = 21; #define digitalPinToPCICR(p) ifpin(p,&PCICR,(uint8_t *)0) #define digitalPinToPCICRbit(p) ifpin(p,digital_pin_to_pcint[p] >> 3,(uint8_t *)0) #define digitalPinToPCMSK(p) ifpin(p,__pcmsk[digital_pin_to_pcint[]],(uint8_t *)0) #define digitalPinToPCMSKbit(p) ifpin(p,digital_pin_to_pcint[p] & 0x7,(uint8_t *)0) #ifdef ARDUINO_MAIN #define PA 1 #define PB 2 #define PC 3 #define PD 4 const uint8_t digital_pin_to_pcint[NUM_DIGITAL_PINS] = { 24, // D0 PD0 25, // D1 PD1 26, // D2 PD2 27, // D3 PD3 8, // D4 PB0 9, // D5 PB1 10, // D6 PB2 11, // D7 PB3 29, // D8 PD5 30, // D9 PD6 12, // D10 PB4 13, // D11 PB5 14, // D12 PB6 15, // D13 PB7 7, // D14 PA7 6, // D15 PA6 5, // D16 PA5 4, // D17 PA4 3, // D18 PA3 2, // D19 PA2 1, // D20 PA1 0, // D21 PA0 16, // D22 PC0 17, // D23 PC1 18, // D24 PC2 19, // D25 PC3 20, // D26 PC4 21, // D27 PC5 22, // D28 PC6 23, // D29 PC7 28, // D30 PD4 31, // D31 PD7 }; const uint16_t __pcmsk[] = { (uint16_t)&PCMSK0, (uint16_t)&PCMSK1, (uint16_t)&PCMSK2, (uint16_t)&PCMSK3 }; // 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, (uint16_t) &DDRC, (uint16_t) &DDRD, }; const uint16_t PROGMEM port_to_output_PGM[] = { NOT_A_PORT, (uint16_t) &PORTA, (uint16_t) &PORTB, (uint16_t) &PORTC, (uint16_t) &PORTD, }; const uint16_t PROGMEM port_to_input_PGM[] = { NOT_A_PORT, (uint16_t) &PINA, (uint16_t) &PINB, (uint16_t) &PINC, (uint16_t) &PIND, }; const uint8_t PROGMEM digital_pin_to_port_PGM[NUM_DIGITAL_PINS] = { PD, // D0 PD, // D1 PD, // D2 PD, // D3 PB, // D4 PB, // D5 PB, // D6 PB, // D7 PD, // D8 PD, // D9 PB, // D10 PB, // D11 PB, // D12 PB, // D13 PA, // D14 PA, // D15 PA, // D16 PA, // D17 PA, // D18 PA, // D19 PA, // D20 PA, // D21 PC, // D22 PC, // D23 PC, // D24 PC, // D25 PC, // D26 PC, // D27 PC, // D28 PC, // D29 PD, // D30 PD, // D31 }; const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[NUM_DIGITAL_PINS] = { _BV(0), // D0 PD0 _BV(1), // D1 PD1 _BV(2), // D2 PD2 _BV(3), // D3 PD3 _BV(0), // D4 PB0 _BV(1), // D5 PB1 _BV(2), // D6 PB2 _BV(3), // D7 PB3 _BV(5), // D8 PD5 _BV(6), // D9 PD6 _BV(4), // D10 PB4 _BV(5), // D11 PB5 _BV(6), // D12 PB6 _BV(7), // D13 PB7 _BV(7), // D14 PA7 _BV(6), // D15 PA6 _BV(5), // D16 PA5 _BV(4), // D17 PA4 _BV(3), // D18 PA3 _BV(2), // D19 PA2 _BV(1), // D20 PA1 _BV(0), // D21 PA0 _BV(0), // D22 PC0 _BV(1), // D23 PC1 _BV(2), // D24 PC2 _BV(3), // D25 PC3 _BV(4), // D26 PC4 _BV(5), // D27 PC5 _BV(6), // D28 PC6 _BV(7), // D29 PC7 _BV(4), // D30 PD4 _BV(7), // D31 PD7 }; const uint8_t PROGMEM digital_pin_to_timer_PGM[NUM_DIGITAL_PINS] = { NOT_ON_TIMER, // D0 PD0 NOT_ON_TIMER, // D1 PD1 NOT_ON_TIMER, // D2 PD2 NOT_ON_TIMER, // D3 PD3 NOT_ON_TIMER, // D4 PB0 NOT_ON_TIMER, // D5 PB1 NOT_ON_TIMER, // D6 PB2 TIMER0A, // D7 PB3 TIMER1A, // D8 PD5 TIMER2B, // D9 PD6 TIMER0B, // D10 PB4 NOT_ON_TIMER, // D11 PB5 TIMER3A, // D12 PB6 TIMER3B, // D13 PB7 NOT_ON_TIMER, // D14 PA0 NOT_ON_TIMER, // D15 PA1 NOT_ON_TIMER, // D16 PA2 NOT_ON_TIMER, // D17 PA3 NOT_ON_TIMER, // D18 PA4 NOT_ON_TIMER, // D19 PA5 NOT_ON_TIMER, // D20 PA6 NOT_ON_TIMER, // D21 PA7 NOT_ON_TIMER, // D22 PC0 NOT_ON_TIMER, // D23 PC1 NOT_ON_TIMER, // D24 PC2 NOT_ON_TIMER, // D25 PC3 NOT_ON_TIMER, // D26 PC4 NOT_ON_TIMER, // D27 PC5 NOT_ON_TIMER, // D28 PC6 NOT_ON_TIMER, // D29 PC7 TIMER1B, // D30 PD4 TIMER2A, // D31 PD7 }; #endif // ARDUINO_MAIN #endif // Pins_Arduino_h // vim:ai:cin:sts=2 sw=2 ft=cpp arduino-mighty-1284p-0~svn20130430.orig/variants/standard/0000755000175000017500000000000012140055246022412 5ustar shevekshevekarduino-mighty-1284p-0~svn20130430.orig/variants/standard/pins_arduino.h0000644000175000017500000001143512137772502025270 0ustar shevekshevek#ifndef Pins_Arduino_h #define Pins_Arduino_h #include // ATMEL ATMEGA1284P // // +---\/---+ // (D 0) PB0 1| |40 PA0 (AI 0 / D24) // (D 1) PB1 2| |39 PA1 (AI 1 / D25) // INT2 (D 2) PB2 3| |38 PA2 (AI 2 / D26) // PWM (D 3) PB3 4| |37 PA3 (AI 3 / D27) // PWM/SS (D 4) PB4 5| |36 PA4 (AI 4 / D28) // MOSI (D 5) PB5 6| |35 PA5 (AI 5 / D29) // PWM/MISO (D 6) PB6 7| |34 PA6 (AI 6 / D30) // PWM/SCK (D 7) PB7 8| |33 PA7 (AI 7 / D31) // RST 9| |32 AREF // VCC 10| |31 GND // GND 11| |30 AVCC // XTAL2 12| |29 PC7 (D 23) // XTAL1 13| |28 PC6 (D 22) // RX0 (D 8) PD0 14| |27 PC5 (D 21) TDI // TX0 (D 9) PD1 15| |26 PC4 (D 20) TDO // RX1/INT0 (D 10) PD2 16| |25 PC3 (D 19) TMS // TX1/INT1 (D 11) PD3 17| |24 PC2 (D 18) TCK // PWM (D 12) PD4 18| |23 PC1 (D 17) SDA // PWM (D 13) PD5 19| |22 PC0 (D 16) SCL // PWM (D 14) PD6 20| |21 PD7 (D 15) PWM // +--------+ // /* PCINT15-8: D7-0 : bit 1 PCINT31-24: D15-8 : bit 3 PCINT23-16: D23-16 : bit 2 PCINT7-0: D31-24 : bit 0 */ #define NUM_DIGITAL_PINS 31 #define NUM_ANALOG_INPUTS 8 #define analogInputToDigitalPin(p) ((p < NUM_ANALOG_INPUTS) ? (p) + 24 : -1) #define digitalPinHasPWM(p) ((p) == 3 || (p) == 4 || (p) == 6 || (p) == 7 || (p) == 12 || (p) == 13 || (p) == 14 || (p) == 15) static const uint8_t SS = 4; static const uint8_t MOSI = 5; static const uint8_t MISO = 6; static const uint8_t SCK = 7; static const uint8_t SDA = 17; static const uint8_t SCL = 16; static const uint8_t LED = 7; static const uint8_t A0 = 24; static const uint8_t A1 = 25; static const uint8_t A2 = 26; static const uint8_t A3 = 27; static const uint8_t A4 = 28; static const uint8_t A5 = 29; static const uint8_t A6 = 30; static const uint8_t A7 = 31; #define digitalPinToPCICR(p) (((p) >= 0 && (p) < NUM_DIGITAL_PINS) ? (&PCICR) : ((uint8_t *)0)) #define digitalPinToPCICRbit(p) (((p) <= 7) ? 1 : (((p) <= 15) ? 3 : (((p) <= 23) ? 2 : 0))) #define digitalPinToPCMSK(p) (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0)))) #define digitalPinToPCMSKbit(p) ((p) % 8) #ifdef ARDUINO_MAIN #define PA 1 #define PB 2 #define PC 3 #define PD 4 // 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, (uint16_t) &DDRC, (uint16_t) &DDRD, }; const uint16_t PROGMEM port_to_output_PGM[] = { NOT_A_PORT, (uint16_t) &PORTA, (uint16_t) &PORTB, (uint16_t) &PORTC, (uint16_t) &PORTD, }; const uint16_t PROGMEM port_to_input_PGM[] = { NOT_A_PORT, (uint16_t) &PINA, (uint16_t) &PINB, (uint16_t) &PINC, (uint16_t) &PIND, }; const uint8_t PROGMEM digital_pin_to_port_PGM[] = { PB, /* 0 */ PB, PB, PB, PB, PB, PB, PB, PD, /* 8 */ PD, PD, PD, PD, PD, PD, PD, PC, /* 16 */ PC, PC, PC, PC, PC, PC, PC, PA, /* 24 */ PA, PA, PA, PA, PA, PA, PA /* 31 */ }; const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = { _BV(0), /* 0, port B */ _BV(1), _BV(2), _BV(3), _BV(4), _BV(5), _BV(6), _BV(7), _BV(0), /* 8, port D */ _BV(1), _BV(2), _BV(3), _BV(4), _BV(5), _BV(6), _BV(7), _BV(0), /* 16, port C */ _BV(1), _BV(2), _BV(3), _BV(4), _BV(5), _BV(6), _BV(7), _BV(0), /* 24, port A */ _BV(1), _BV(2), _BV(3), _BV(4), _BV(5), _BV(6), _BV(7) }; const uint8_t PROGMEM digital_pin_to_timer_PGM[] = { NOT_ON_TIMER, /* 0 - PB0 */ NOT_ON_TIMER, /* 1 - PB1 */ NOT_ON_TIMER, /* 2 - PB2 */ TIMER0A, /* 3 - PB3 */ TIMER0B, /* 4 - PB4 */ NOT_ON_TIMER, /* 5 - PB5 */ TIMER3A, /* 6 - PB6 */ TIMER3B, /* 7 - PB7 */ NOT_ON_TIMER, /* 8 - PD0 */ NOT_ON_TIMER, /* 9 - PD1 */ NOT_ON_TIMER, /* 10 - PD2 */ NOT_ON_TIMER, /* 11 - PD3 */ TIMER1B, /* 12 - PD4 */ TIMER1A, /* 13 - PD5 */ TIMER2B, /* 14 - PD6 */ TIMER2A, /* 15 - PD7 */ NOT_ON_TIMER, /* 16 - PC0 */ NOT_ON_TIMER, /* 17 - PC1 */ NOT_ON_TIMER, /* 18 - PC2 */ NOT_ON_TIMER, /* 19 - PC3 */ NOT_ON_TIMER, /* 20 - PC4 */ NOT_ON_TIMER, /* 21 - PC5 */ NOT_ON_TIMER, /* 22 - PC6 */ NOT_ON_TIMER, /* 23 - PC7 */ NOT_ON_TIMER, /* 24 - PA0 */ NOT_ON_TIMER, /* 25 - PA1 */ NOT_ON_TIMER, /* 26 - PA2 */ NOT_ON_TIMER, /* 27 - PA3 */ NOT_ON_TIMER, /* 28 - PA4 */ NOT_ON_TIMER, /* 29 - PA5 */ NOT_ON_TIMER, /* 30 - PA6 */ NOT_ON_TIMER /* 31 - PA7 */ }; #endif // ARDUINO_MAIN #endif // Pins_Arduino_h // vim:ai:cin:sts=2 sw=2 ft=cpp arduino-mighty-1284p-0~svn20130430.orig/variants/avr_developers/0000755000175000017500000000000012140055246023632 5ustar shevekshevekarduino-mighty-1284p-0~svn20130430.orig/variants/avr_developers/pins_arduino.h0000644000175000017500000001310012137772502026477 0ustar shevekshevek/* pins_arduino.h - 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 */ #ifndef Pins_Arduino_h #define Pins_Arduino_h #include // On the Sanguino board, digital pins are also used // for the analog output (software PWM). Analog input // pins are a separate set. // ATMEL ATMEGA644P / SANGUINO (also works for ATmega1284P) // // +---\/---+ // INT0 (D 0) PB0 1| |40 PA0 (AI 0 / D31) // INT1 (D 1) PB1 2| |39 PA1 (AI 1 / D30) // INT2 (D 2) PB2 3| |38 PA2 (AI 2 / D29) // PWM (D 3) PB3 4| |37 PA3 (AI 3 / D28) // PWM (D 4) PB4 5| |36 PA4 (AI 4 / D27) // MOSI (D 5) PB5 6| |35 PA5 (AI 5 / D26) // MISO (D 6) PB6 7| |34 PA6 (AI 6 / D25) // SCK (D 7) PB7 8| |33 PA7 (AI 7 / D24) // RST 9| |32 AREF // VCC 10| |31 GND // GND 11| |30 AVCC // XTAL2 12| |29 PC7 (D 23) // XTAL1 13| |28 PC6 (D 22) // RX0 (D 8) PD0 14| |27 PC5 (D 21) TDI // TX0 (D 9) PD1 15| |26 PC4 (D 20) TDO // RX1 (D 10) PD2 16| |25 PC3 (D 19) TMS // TX1 (D 11) PD3 17| |24 PC2 (D 18) TCK // PWM (D 12) PD4 18| |23 PC1 (D 17) SDA // PWM (D 13) PD5 19| |22 PC0 (D 16) SCL // PWM (D 14) PD6 20| |21 PD7 (D 15) PWM // +--------+ // #define NUM_DIGITAL_PINS 31 #define NUM_ANALOG_INPUTS 8 #define analogInputToDigitalPin(p) ((p < NUM_ANALOG_INPUTS) ? 31 - (p) : -1) #define digitalPinHasPWM(p) ((p) == 3 || (p) == 4 || (p) == 6 || (p) == 7 || (p) == 12 || (p) == 13 || (p) == 14 || (p) == 15) static const uint8_t SS = 4; static const uint8_t MOSI = 5; static const uint8_t MISO = 6; static const uint8_t SCK = 7; static const uint8_t SDA = 17; static const uint8_t SCL = 16; static const uint8_t LED = 7; static const uint8_t A0 = 24; static const uint8_t A1 = 25; static const uint8_t A2 = 26; static const uint8_t A3 = 27; static const uint8_t A4 = 28; static const uint8_t A5 = 29; static const uint8_t A6 = 30; static const uint8_t A7 = 31; #define digitalPinToPCICR(p) (((p) >= 0 && (p) < NUM_DIGITAL_PINS) ? (&PCICR) : ((uint8_t *)0)) #define digitalPinToPCICRbit(p) (((p) <= 7) ? 1 : (((p) <= 15) ? 3 : (((p) <= 23) ? 2 : 0))) #define digitalPinToPCMSK(p) (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0)))) #define digitalPinToPCMSKbit(p) ((p) % 8) #ifdef ARDUINO_MAIN #define PA 1 #define PB 2 #define PC 3 #define PD 4 // 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, (uint16_t) &DDRC, (uint16_t) &DDRD, }; const uint16_t PROGMEM port_to_output_PGM[] = { NOT_A_PORT, (uint16_t) &PORTA, (uint16_t) &PORTB, (uint16_t) &PORTC, (uint16_t) &PORTD, }; const uint16_t PROGMEM port_to_input_PGM[] = { NOT_A_PORT, (uint16_t) &PINA, (uint16_t) &PINB, (uint16_t) &PINC, (uint16_t) &PIND, }; const uint8_t PROGMEM digital_pin_to_port_PGM[] = { PB, /* 0 */ PB, PB, PB, PB, PB, PB, PB, PD, /* 8 */ PD, PD, PD, PD, PD, PD, PD, PC, /* 16 */ PC, PC, PC, PC, PC, PC, PC, PA, /* 24 */ PA, PA, PA, PA, PA, PA, PA /* 31 */ }; const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = { _BV(0), /* 0, port B */ _BV(1), _BV(2), _BV(3), _BV(4), _BV(5), _BV(6), _BV(7), _BV(0), /* 8, port D */ _BV(1), _BV(2), _BV(3), _BV(4), _BV(5), _BV(6), _BV(7), _BV(0), /* 16, port C */ _BV(1), _BV(2), _BV(3), _BV(4), _BV(5), _BV(6), _BV(7), _BV(7), /* 24, port A */ _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, /* 0 - PB0 */ NOT_ON_TIMER, /* 1 - PB1 */ NOT_ON_TIMER, /* 2 - PB2 */ TIMER0A, /* 3 - PB3 */ TIMER0B, /* 4 - PB4 */ NOT_ON_TIMER, /* 5 - PB5 */ NOT_ON_TIMER, /* 6 - PB6 */ NOT_ON_TIMER, /* 7 - PB7 */ NOT_ON_TIMER, /* 8 - PD0 */ NOT_ON_TIMER, /* 9 - PD1 */ NOT_ON_TIMER, /* 10 - PD2 */ NOT_ON_TIMER, /* 11 - PD3 */ TIMER1B, /* 12 - PD4 */ TIMER1A, /* 13 - PD5 */ TIMER2B, /* 14 - PD6 */ TIMER2A, /* 15 - PD7 */ NOT_ON_TIMER, /* 16 - PC0 */ NOT_ON_TIMER, /* 17 - PC1 */ NOT_ON_TIMER, /* 18 - PC2 */ NOT_ON_TIMER, /* 19 - PC3 */ NOT_ON_TIMER, /* 20 - PC4 */ NOT_ON_TIMER, /* 21 - PC5 */ NOT_ON_TIMER, /* 22 - PC6 */ NOT_ON_TIMER, /* 23 - PC7 */ NOT_ON_TIMER, /* 24 - PA0 */ NOT_ON_TIMER, /* 25 - PA1 */ NOT_ON_TIMER, /* 26 - PA2 */ NOT_ON_TIMER, /* 27 - PA3 */ NOT_ON_TIMER, /* 28 - PA4 */ NOT_ON_TIMER, /* 29 - PA5 */ NOT_ON_TIMER, /* 30 - PA6 */ NOT_ON_TIMER /* 31 - PA7 */ }; #endif // ARDUINO_MAIN #endif // Pins_Arduino_h arduino-mighty-1284p-0~svn20130430.orig/variants/avr_developers/README0000644000175000017500000000006512137772502024522 0ustar shevekshevekFrom http://avr-developers.com/corefiles/index.html arduino-mighty-1284p-0~svn20130430.orig/cores/0000755000175000017500000000000012137772502020105 5ustar shevekshevekarduino-mighty-1284p-0~svn20130430.orig/cores/standard/0000755000175000017500000000000012140055246021676 5ustar shevekshevekarduino-mighty-1284p-0~svn20130430.orig/cores/standard/Stream.h0000644000175000017500000000754312137772502023322 0ustar shevekshevek/* Stream.h - base class for character-based streams. Copyright (c) 2010 David A. Mellis. All right reserved. 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA parsing functions based on TextFinder library by Michael Margolis */ #ifndef Stream_h #define Stream_h #include #include "Print.h" // compatability macros for testing /* #define getInt() parseInt() #define getInt(skipChar) parseInt(skipchar) #define getFloat() parseFloat() #define getFloat(skipChar) parseFloat(skipChar) #define getString( pre_string, post_string, buffer, length) readBytesBetween( pre_string, terminator, buffer, length) */ class Stream : public Print { private: unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read unsigned long _startMillis; // used for timeout measurement int timedRead(); // private method to read stream with timeout int timedPeek(); // private method to peek stream with timeout int peekNextDigit(); // returns the next numeric digit in the stream or -1 if timeout public: virtual int available() = 0; virtual int read() = 0; virtual int peek() = 0; virtual void flush() = 0; Stream() {_timeout=1000;} // parsing methods void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second bool find(char *target); // reads data from the stream until the target string is found // returns true if target string is found, false if timed out (see setTimeout) bool find(char *target, size_t length); // reads data from the stream until the target string of given length is found // returns true if target string is found, false if timed out bool findUntil(char *target, char *terminator); // as find but search ends if the terminator string is found bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen); // as above but search ends if the terminate string is found long parseInt(); // returns the first valid (long) integer value from the current position. // initial characters that are not digits (or the minus sign) are skipped // integer is terminated by the first character that is not a digit. float parseFloat(); // float version of parseInt size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer // terminates if length characters have been read or timeout (see setTimeout) // returns the number of characters placed in the buffer (0 means no valid data found) size_t readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character // terminates if length characters have been read, timeout, or if the terminator character detected // returns the number of characters placed in the buffer (0 means no valid data found) // Arduino String functions to be added here protected: long parseInt(char skipChar); // as above but the given skipChar is ignored // as above but the given skipChar is ignored // this allows format characters (typically commas) in values to be ignored float parseFloat(char skipChar); // as above but the given skipChar is ignored }; #endif arduino-mighty-1284p-0~svn20130430.orig/cores/standard/IPAddress.cpp0000644000175000017500000000220012137772502024221 0ustar shevekshevek #include #include IPAddress::IPAddress() { memset(_address, 0, sizeof(_address)); } IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet) { _address[0] = first_octet; _address[1] = second_octet; _address[2] = third_octet; _address[3] = fourth_octet; } IPAddress::IPAddress(uint32_t address) { memcpy(_address, &address, sizeof(_address)); } IPAddress::IPAddress(const uint8_t *address) { memcpy(_address, address, sizeof(_address)); } IPAddress& IPAddress::operator=(const uint8_t *address) { memcpy(_address, address, sizeof(_address)); return *this; } IPAddress& IPAddress::operator=(uint32_t address) { memcpy(_address, (const uint8_t *)&address, sizeof(_address)); return *this; } bool IPAddress::operator==(const uint8_t* addr) { return memcmp(addr, _address, sizeof(_address)) == 0; } size_t IPAddress::printTo(Print& p) const { size_t n = 0; for (int i =0; i < 3; i++) { n += p.print(_address[i], DEC); n += p.print('.'); } n += p.print(_address[3], DEC); return n; } arduino-mighty-1284p-0~svn20130430.orig/cores/standard/WMath.cpp0000644000175000017500000000316112137772502023432 0ustar shevekshevek/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* Part of the Wiring project - http://wiring.org.co Copyright (c) 2004-06 Hernando Barragan Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/ 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$ */ extern "C" { #include "stdlib.h" } void randomSeed(unsigned int seed) { if (seed != 0) { srandom(seed); } } long random(long howbig) { if (howbig == 0) { return 0; } return random() % howbig; } long random(long howsmall, long howbig) { if (howsmall >= howbig) { return howsmall; } long diff = howbig - howsmall; return random(diff) + howsmall; } long map(long x, long in_min, long in_max, long out_min, long out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } unsigned int makeWord(unsigned int w) { return w; } unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; }arduino-mighty-1284p-0~svn20130430.orig/cores/standard/Platform.h0000644000175000017500000000062112137772502023641 0ustar shevekshevek #ifndef __PLATFORM_H__ #define __PLATFORM_H__ #include #include #include #include #include typedef unsigned char u8; typedef unsigned short u16; typedef unsigned long u32; #include "Arduino.h" #if defined(USBCON) #include "USBDesc.h" #include "USBCore.h" #include "USBAPI.h" #endif /* if defined(USBCON) */ #endif arduino-mighty-1284p-0~svn20130430.orig/cores/standard/USBAPI.h0000644000175000017500000001066412137772502023050 0ustar shevekshevek #ifndef __USBAPI__ #define __USBAPI__ #if defined(USBCON) //================================================================================ //================================================================================ // USB class USB_ { public: USB_(); bool configured(); void attach(); void detach(); // Serial port goes down too... void poll(); }; extern USB_ USB; //================================================================================ //================================================================================ // Serial over CDC (Serial1 is the physical port) class Serial_ : public Stream { public: void begin(uint16_t baud_count); void end(void); virtual int available(void); virtual int peek(void); virtual int read(void); virtual void flush(void); virtual size_t write(uint8_t); }; extern Serial_ Serial; //================================================================================ //================================================================================ // Mouse #define MOUSE_LEFT 1 #define MOUSE_RIGHT 2 #define MOUSE_MIDDLE 4 #define MOUSE_ALL (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE) class Mouse_ { private: uint8_t _buttons; void buttons(uint8_t b); public: Mouse_(); void click(uint8_t b = MOUSE_LEFT); void move(signed char x, signed char y, signed char wheel = 0); void press(uint8_t b = MOUSE_LEFT); // press LEFT by default void release(uint8_t b = MOUSE_LEFT); // release LEFT by default bool isPressed(uint8_t b = MOUSE_ALL); // check all buttons by default }; extern Mouse_ Mouse; //================================================================================ //================================================================================ // Keyboard #define KEY_MODIFIER_LEFT_CTRL 0x01 #define KEY_MODIFIER_LEFT_SHIFT 0x02 #define KEY_MODIFIER_LEFT_ALT 0x04 #define KEY_MODIFIER_LEFT_GUI 0x08 #define KEY_MODIFIER_RIGHT_CTRL 0x010 #define KEY_MODIFIER_RIGHT_SHIFT 0x020 #define KEY_MODIFIER_RIGHT_ALT 0x040 #define KEY_MODIFIER_RIGHT_GUI 0x080 // Low level key report: up to 6 keys and shift, ctrl etc at once typedef struct { uint8_t modifiers; uint8_t reserved; uint8_t keys[6]; } KeyReport; // Map a character into a key report // Called from Print to map text to keycodes class KeyMap { public: virtual void charToKey(int c, KeyReport* keyReport) = 0; }; // class Keyboard_ : public Print { private: KeyMap* _keyMap; void sendReport(KeyReport* keys); void setKeyMap(KeyMap* keyMap); public: Keyboard_(); virtual size_t write(uint8_t); }; extern Keyboard_ Keyboard; //================================================================================ //================================================================================ // Low level API typedef struct { uint8_t bmRequestType; uint8_t bRequest; uint8_t wValueL; uint8_t wValueH; uint16_t wIndex; uint16_t wLength; } Setup; //================================================================================ //================================================================================ // HID 'Driver' int HID_GetInterface(uint8_t* interfaceNum); int HID_GetDescriptor(int i); bool HID_Setup(Setup& setup); void HID_SendReport(uint8_t id, const void* data, int len); //================================================================================ //================================================================================ // MSC 'Driver' int MSC_GetInterface(uint8_t* interfaceNum); int MSC_GetDescriptor(int i); bool MSC_Setup(Setup& setup); bool MSC_Data(uint8_t rx,uint8_t tx); //================================================================================ //================================================================================ // CSC 'Driver' int CDC_GetInterface(uint8_t* interfaceNum); int CDC_GetDescriptor(int i); bool CDC_Setup(Setup& setup); //================================================================================ //================================================================================ #define TRANSFER_PGM 0x80 #define TRANSFER_RELEASE 0x40 #define TRANSFER_ZERO 0x20 int USB_SendControl(uint8_t flags, const void* d, int len); int USB_RecvControl(void* d, int len); uint8_t USB_Available(uint8_t ep); int USB_Send(uint8_t ep, const void* data, int len); // blocking int USB_Recv(uint8_t ep, void* data, int len); // non-blocking int USB_Recv(uint8_t ep); // non-blocking void USB_Flush(uint8_t ep); #endif #endif /* if defined(USBCON) */arduino-mighty-1284p-0~svn20130430.orig/cores/standard/new.cpp0000644000175000017500000000050512137772502023202 0ustar shevekshevek#include void * operator new(size_t size) { return malloc(size); } void operator delete(void * ptr) { free(ptr); } int __cxa_guard_acquire(__guard *g) {return !*(char *)(g);}; void __cxa_guard_release (__guard *g) {*(char *)g = 1;}; void __cxa_guard_abort (__guard *) {}; void __cxa_pure_virtual(void) {}; arduino-mighty-1284p-0~svn20130430.orig/cores/standard/WString.h0000644000175000017500000002043412137772502023456 0ustar shevekshevek/* WString.h - String library for Wiring & Arduino ...mostly rewritten by Paul Stoffregen... Copyright (c) 2009-10 Hernando Barragan. All right reserved. Copyright 2011, Paul Stoffregen, paul@pjrc.com 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef String_class_h #define String_class_h #ifdef __cplusplus #include #include #include #include // When compiling programs with this class, the following gcc parameters // dramatically increase performance and memory (RAM) efficiency, typically // with little or no increase in code size. // -felide-constructors // -std=c++0x class __FlashStringHelper; #define F(string_literal) (reinterpret_cast(PSTR(string_literal))) // An inherited class for holding the result of a concatenation. These // result objects are assumed to be writable by subsequent concatenations. class StringSumHelper; // The string class class String { // use a function pointer to allow for "if (s)" without the // complications of an operator bool(). for more information, see: // http://www.artima.com/cppsource/safebool.html typedef void (String::*StringIfHelperType)() const; void StringIfHelper() const {} public: // constructors // creates a copy of the initial value. // if the initial value is null or invalid, or if memory allocation // fails, the string will be marked as invalid (i.e. "if (s)" will // be false). String(const char *cstr = ""); String(const String &str); #ifdef __GXX_EXPERIMENTAL_CXX0X__ String(String &&rval); String(StringSumHelper &&rval); #endif explicit String(char c); explicit String(unsigned char, unsigned char base=10); explicit String(int, unsigned char base=10); explicit String(unsigned int, unsigned char base=10); explicit String(long, unsigned char base=10); explicit String(unsigned long, unsigned char base=10); ~String(void); // memory management // return true on success, false on failure (in which case, the string // is left unchanged). reserve(0), if successful, will validate an // invalid string (i.e., "if (s)" will be true afterwards) unsigned char reserve(unsigned int size); inline unsigned int length(void) const {return len;} // creates a copy of the assigned value. if the value is null or // invalid, or if the memory allocation fails, the string will be // marked as invalid ("if (s)" will be false). String & operator = (const String &rhs); String & operator = (const char *cstr); #ifdef __GXX_EXPERIMENTAL_CXX0X__ String & operator = (String &&rval); String & operator = (StringSumHelper &&rval); #endif // concatenate (works w/ built-in types) // returns true on success, false on failure (in which case, the string // is left unchanged). if the argument is null or invalid, the // concatenation is considered unsucessful. unsigned char concat(const String &str); unsigned char concat(const char *cstr); unsigned char concat(char c); unsigned char concat(unsigned char c); unsigned char concat(int num); unsigned char concat(unsigned int num); unsigned char concat(long num); unsigned char concat(unsigned long num); // if there's not enough memory for the concatenated value, the string // will be left unchanged (but this isn't signalled in any way) String & operator += (const String &rhs) {concat(rhs); return (*this);} String & operator += (const char *cstr) {concat(cstr); return (*this);} String & operator += (char c) {concat(c); return (*this);} String & operator += (unsigned char num) {concat(num); return (*this);} String & operator += (int num) {concat(num); return (*this);} String & operator += (unsigned int num) {concat(num); return (*this);} String & operator += (long num) {concat(num); return (*this);} String & operator += (unsigned long num) {concat(num); return (*this);} friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs); friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr); friend StringSumHelper & operator + (const StringSumHelper &lhs, char c); friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num); friend StringSumHelper & operator + (const StringSumHelper &lhs, int num); friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num); friend StringSumHelper & operator + (const StringSumHelper &lhs, long num); friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num); // comparison (only works w/ Strings and "strings") operator StringIfHelperType() const { return buffer ? &String::StringIfHelper : 0; } int compareTo(const String &s) const; unsigned char equals(const String &s) const; unsigned char equals(const char *cstr) const; unsigned char operator == (const String &rhs) const {return equals(rhs);} unsigned char operator == (const char *cstr) const {return equals(cstr);} unsigned char operator != (const String &rhs) const {return !equals(rhs);} unsigned char operator != (const char *cstr) const {return !equals(cstr);} unsigned char operator < (const String &rhs) const; unsigned char operator > (const String &rhs) const; unsigned char operator <= (const String &rhs) const; unsigned char operator >= (const String &rhs) const; unsigned char equalsIgnoreCase(const String &s) const; unsigned char startsWith( const String &prefix) const; unsigned char startsWith(const String &prefix, unsigned int offset) const; unsigned char endsWith(const String &suffix) const; // character acccess char charAt(unsigned int index) const; void setCharAt(unsigned int index, char c); char operator [] (unsigned int index) const; char& operator [] (unsigned int index); void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0) const; void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const {getBytes((unsigned char *)buf, bufsize, index);} // search int indexOf( char ch ) const; int indexOf( char ch, unsigned int fromIndex ) const; int indexOf( const String &str ) const; int indexOf( const String &str, unsigned int fromIndex ) const; int lastIndexOf( char ch ) const; int lastIndexOf( char ch, unsigned int fromIndex ) const; int lastIndexOf( const String &str ) const; int lastIndexOf( const String &str, unsigned int fromIndex ) const; String substring( unsigned int beginIndex ) const; String substring( unsigned int beginIndex, unsigned int endIndex ) const; // modification void replace(char find, char replace); void replace(const String& find, const String& replace); void toLowerCase(void); void toUpperCase(void); void trim(void); // parsing/conversion long toInt(void) const; protected: char *buffer; // the actual char array unsigned int capacity; // the array length minus one (for the '\0') unsigned int len; // the String length (not counting the '\0') unsigned char flags; // unused, for future features protected: void init(void); void invalidate(void); unsigned char changeBuffer(unsigned int maxStrLen); unsigned char concat(const char *cstr, unsigned int length); // copy and move String & copy(const char *cstr, unsigned int length); #ifdef __GXX_EXPERIMENTAL_CXX0X__ void move(String &rhs); #endif }; class StringSumHelper : public String { public: StringSumHelper(const String &s) : String(s) {} StringSumHelper(const char *p) : String(p) {} StringSumHelper(char c) : String(c) {} StringSumHelper(unsigned char num) : String(num) {} StringSumHelper(int num) : String(num) {} StringSumHelper(unsigned int num) : String(num) {} StringSumHelper(long num) : String(num) {} StringSumHelper(unsigned long num) : String(num) {} }; #endif // __cplusplus #endif // String_class_h arduino-mighty-1284p-0~svn20130430.orig/cores/standard/HID.cpp0000644000175000017500000002634512137772502023027 0ustar shevekshevek /* Copyright (c) 2011, Peter Barrett ** ** Permission to use, copy, modify, and/or distribute this software for ** any purpose with or without fee is hereby granted, provided that the ** above copyright notice and this permission notice appear in all copies. ** ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL ** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR ** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES ** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, ** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS ** SOFTWARE. */ #include "Platform.h" #include "USBAPI.h" #include "USBDesc.h" #if defined(USBCON) #ifdef HID_ENABLED //#define RAWHID_ENABLED // Singletons for mouse and keyboard Mouse_ Mouse; Keyboard_ Keyboard; //================================================================================ //================================================================================ // HID report descriptor #define LSB(_x) ((_x) & 0xFF) #define MSB(_x) ((_x) >> 8) #define RAWHID_USAGE_PAGE 0xFFC0 #define RAWHID_USAGE 0x0C00 #define RAWHID_TX_SIZE 64 #define RAWHID_RX_SIZE 64 extern const u8 _hidReportDescriptor[] PROGMEM; const u8 _hidReportDescriptor[] = { // Mouse 0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 54 0x09, 0x02, // USAGE (Mouse) 0xa1, 0x01, // COLLECTION (Application) 0x09, 0x01, // USAGE (Pointer) 0xa1, 0x00, // COLLECTION (Physical) 0x85, 0x01, // REPORT_ID (1) 0x05, 0x09, // USAGE_PAGE (Button) 0x19, 0x01, // USAGE_MINIMUM (Button 1) 0x29, 0x03, // USAGE_MAXIMUM (Button 3) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x25, 0x01, // LOGICAL_MAXIMUM (1) 0x95, 0x03, // REPORT_COUNT (3) 0x75, 0x01, // REPORT_SIZE (1) 0x81, 0x02, // INPUT (Data,Var,Abs) 0x95, 0x01, // REPORT_COUNT (1) 0x75, 0x05, // REPORT_SIZE (5) 0x81, 0x03, // INPUT (Cnst,Var,Abs) 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 0x09, 0x30, // USAGE (X) 0x09, 0x31, // USAGE (Y) 0x09, 0x38, // USAGE (Wheel) 0x15, 0x81, // LOGICAL_MINIMUM (-127) 0x25, 0x7f, // LOGICAL_MAXIMUM (127) 0x75, 0x08, // REPORT_SIZE (8) 0x95, 0x03, // REPORT_COUNT (3) 0x81, 0x06, // INPUT (Data,Var,Rel) 0xc0, // END_COLLECTION 0xc0, // END_COLLECTION // Keyboard 0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 47 0x09, 0x06, // USAGE (Keyboard) 0xa1, 0x01, // COLLECTION (Application) 0x85, 0x02, // REPORT_ID (2) 0x05, 0x07, // USAGE_PAGE (Keyboard) 0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl) 0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x25, 0x01, // LOGICAL_MAXIMUM (1) 0x75, 0x01, // REPORT_SIZE (1) 0x95, 0x08, // REPORT_COUNT (8) 0x81, 0x02, // INPUT (Data,Var,Abs) 0x95, 0x01, // REPORT_COUNT (1) 0x75, 0x08, // REPORT_SIZE (8) 0x81, 0x03, // INPUT (Cnst,Var,Abs) 0x95, 0x06, // REPORT_COUNT (6) 0x75, 0x08, // REPORT_SIZE (8) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x25, 0x65, // LOGICAL_MAXIMUM (101) 0x05, 0x07, // USAGE_PAGE (Keyboard) 0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated)) 0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application) 0x81, 0x00, // INPUT (Data,Ary,Abs) 0xc0, // END_COLLECTION #if RAWHID_ENABLED // RAW HID 0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE), // 30 0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE), 0xA1, 0x01, // Collection 0x01 0x85, 0x03, // REPORT_ID (3) 0x75, 0x08, // report size = 8 bits 0x15, 0x00, // logical minimum = 0 0x26, 0xFF, 0x00, // logical maximum = 255 0x95, 64, // report count TX 0x09, 0x01, // usage 0x81, 0x02, // Input (array) 0x95, 64, // report count RX 0x09, 0x02, // usage 0x91, 0x02, // Output (array) 0xC0 // end collection #endif }; extern const HIDDescriptor _hidInterface PROGMEM; const HIDDescriptor _hidInterface = { D_INTERFACE(HID_INTERFACE,1,3,0,0), D_HIDREPORT(sizeof(_hidReportDescriptor)), D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x01) }; //================================================================================ //================================================================================ // Driver u8 _hid_protocol = 1; u8 _hid_idle = 1; #define WEAK __attribute__ ((weak)) #define WEAK int WEAK HID_GetInterface(u8* interfaceNum) { interfaceNum[0] += 1; // uses 1 return USB_SendControl(TRANSFER_PGM,&_hidInterface,sizeof(_hidInterface)); } int WEAK HID_GetDescriptor(int i) { return USB_SendControl(TRANSFER_PGM,_hidReportDescriptor,sizeof(_hidReportDescriptor)); } void WEAK HID_SendReport(u8 id, const void* data, int len) { USB_Send(HID_TX, &id, 1); USB_Send(HID_TX | TRANSFER_RELEASE,data,len); } bool WEAK HID_Setup(Setup& setup) { u8 r = setup.bRequest; u8 requestType = setup.bmRequestType; if (REQUEST_DEVICETOHOST_CLASS_INTERFACE == requestType) { if (HID_GET_REPORT == r) { //HID_GetReport(); return true; } if (HID_GET_PROTOCOL == r) { //Send8(_hid_protocol); // TODO return true; } } if (REQUEST_HOSTTODEVICE_CLASS_INTERFACE == requestType) { if (HID_SET_PROTOCOL == r) { _hid_protocol = setup.wValueL; return true; } if (HID_SET_IDLE == r) { _hid_idle = setup.wValueL; return true; } } return false; } //================================================================================ //================================================================================ // Mouse Mouse_::Mouse_() : _buttons(0) { } void Mouse_::click(uint8_t b) { _buttons = b; move(0,0,0); _buttons = 0; move(0,0,0); } void Mouse_::move(signed char x, signed char y, signed char wheel) { u8 m[4]; m[0] = _buttons; m[1] = x; m[2] = y; m[3] = wheel; HID_SendReport(1,m,4); } void Mouse_::buttons(uint8_t b) { if (b != _buttons) { _buttons = b; move(0,0,0); } } void Mouse_::press(uint8_t b) { buttons(_buttons | b); } void Mouse_::release(uint8_t b) { buttons(_buttons & ~b); } bool Mouse_::isPressed(uint8_t b) { if (b & _buttons > 0) return true; return false; } //================================================================================ //================================================================================ // Keyboard Keyboard_::Keyboard_() : _keyMap(0) { } void Keyboard_::sendReport(KeyReport* keys) { HID_SendReport(2,keys,sizeof(KeyReport)); } void Keyboard_::setKeyMap(KeyMap* keyMap) { _keyMap = keyMap; } extern const uint8_t _asciimap[128] PROGMEM; #define SHIFT 0x80 const uint8_t _asciimap[128] = { 0x00, // NUL 0x00, // SOH 0x00, // STX 0x00, // ETX 0x00, // EOT 0x00, // ENQ 0x00, // ACK 0x00, // BEL 0x2a, // BS Backspace 0x2b, // TAB Tab 0x28, // LF Enter 0x00, // VT 0x00, // FF 0x00, // CR 0x00, // SO 0x00, // SI 0x00, // DEL 0x00, // DC1 0x00, // DC2 0x00, // DC3 0x00, // DC4 0x00, // NAK 0x00, // SYN 0x00, // ETB 0x00, // CAN 0x00, // EM 0x00, // SUB 0x00, // ESC 0x00, // FS 0x00, // GS 0x00, // RS 0x00, // US 0x2c, // ' ' 0x1e|SHIFT, // ! 0x34|SHIFT, // " 0x20|SHIFT, // # 0x21|SHIFT, // $ 0x22|SHIFT, // % 0x24|SHIFT, // & 0x34, // ' 0x26|SHIFT, // ( 0x27|SHIFT, // ) 0x25|SHIFT, // * 0x2e|SHIFT, // + 0x36, // , 0x2d, // - 0x37, // . 0x38, // / 0x27, // 0 0x1e, // 1 0x1f, // 2 0x20, // 3 0x21, // 4 0x22, // 5 0x23, // 6 0x24, // 7 0x25, // 8 0x26, // 9 0x33|SHIFT, // : 0x33, // ; 0x36|SHIFT, // < 0x2e, // = 0x37|SHIFT, // > 0x38|SHIFT, // ? 0x1f|SHIFT, // @ 0x04|SHIFT, // A 0x05|SHIFT, // B 0x06|SHIFT, // C 0x07|SHIFT, // D 0x08|SHIFT, // E 0x09|SHIFT, // F 0x0a|SHIFT, // G 0x0b|SHIFT, // H 0x0c|SHIFT, // I 0x0d|SHIFT, // J 0x0e|SHIFT, // K 0x0f|SHIFT, // L 0x10|SHIFT, // M 0x11|SHIFT, // N 0x12|SHIFT, // O 0x13|SHIFT, // P 0x14|SHIFT, // Q 0x15|SHIFT, // R 0x16|SHIFT, // S 0x17|SHIFT, // T 0x18|SHIFT, // U 0x19|SHIFT, // V 0x1a|SHIFT, // W 0x1b|SHIFT, // X 0x1c|SHIFT, // Y 0x1d|SHIFT, // Z 0x2f, // [ 0x31, // bslash 0x30, // ] 0x23|SHIFT, // ^ 0x2d|SHIFT, // _ 0x35, // ` 0x04, // a 0x05, // b 0x06, // c 0x07, // d 0x08, // e 0x09, // f 0x0a, // g 0x0b, // h 0x0c, // i 0x0d, // j 0x0e, // k 0x0f, // l 0x10, // m 0x11, // n 0x12, // o 0x13, // p 0x14, // q 0x15, // r 0x16, // s 0x17, // t 0x18, // u 0x19, // v 0x1a, // w 0x1b, // x 0x1c, // y 0x1d, // z 0x2f|SHIFT, // 0x31|SHIFT, // | 0x30|SHIFT, // } 0x35|SHIFT, // ~ 0 // DEL }; uint8_t USBPutChar(uint8_t c); size_t Keyboard_::write(uint8_t c) { // Keydown { KeyReport keys = {0}; if (_keyMap) _keyMap->charToKey(c,&keys); else { if (c >= 128) { setWriteError(); return 0; } c = pgm_read_byte(_asciimap + c); if (!c) { setWriteError(); return 0; } if (c & 0x80) { keys.modifiers |= KEY_MODIFIER_LEFT_SHIFT; c &= 0x7F; } keys.keys[0] = c; } sendReport(&keys); } // Keyup { KeyReport keys = {0}; sendReport(&keys); } return 1; } #endif #endif /* if defined(USBCON) */arduino-mighty-1284p-0~svn20130430.orig/cores/standard/Stream.cpp0000644000175000017500000001540212137772502023646 0ustar shevekshevek/* Stream.cpp - adds parsing methods to Stream class Copyright (c) 2008 David A. Mellis. All right reserved. 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Created July 2011 parsing functions based on TextFinder library by Michael Margolis */ #include "Arduino.h" #include "Stream.h" #define PARSE_TIMEOUT 1000 // default number of milli-seconds to wait #define NO_SKIP_CHAR 1 // a magic char not found in a valid ASCII numeric field // private method to read stream with timeout int Stream::timedRead() { int c; _startMillis = millis(); do { c = read(); if (c >= 0) return c; } while(millis() - _startMillis < _timeout); return -1; // -1 indicates timeout } // private method to peek stream with timeout int Stream::timedPeek() { int c; _startMillis = millis(); do { c = peek(); if (c >= 0) return c; } while(millis() - _startMillis < _timeout); return -1; // -1 indicates timeout } // returns peek of the next digit in the stream or -1 if timeout // discards non-numeric characters int Stream::peekNextDigit() { int c; while (1) { c = timedPeek(); if (c < 0) return c; // timeout if (c == '-') return c; if (c >= '0' && c <= '9') return c; read(); // discard non-numeric } } // Public Methods ////////////////////////////////////////////////////////////// void Stream::setTimeout(unsigned long timeout) // sets the maximum number of milliseconds to wait { _timeout = timeout; } // find returns true if the target string is found bool Stream::find(char *target) { return findUntil(target, NULL); } // reads data from the stream until the target string of given length is found // returns true if target string is found, false if timed out bool Stream::find(char *target, size_t length) { return findUntil(target, length, NULL, 0); } // as find but search ends if the terminator string is found bool Stream::findUntil(char *target, char *terminator) { return findUntil(target, strlen(target), terminator, strlen(terminator)); } // reads data from the stream until the target string of the given length is found // search terminated if the terminator string is found // returns true if target string is found, false if terminated or timed out bool Stream::findUntil(char *target, size_t targetLen, char *terminator, size_t termLen) { size_t index = 0; // maximum target string length is 64k bytes! size_t termIndex = 0; int c; if( *target == 0) return true; // return true if target is a null string while( (c = timedRead()) > 0){ if( c == target[index]){ //////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1); if(++index >= targetLen){ // return true if all chars in the target match return true; } } else{ index = 0; // reset index if any char does not match } if(termLen > 0 && c == terminator[termIndex]){ if(++termIndex >= termLen) return false; // return false if terminate string found before target string } else termIndex = 0; } return false; } // returns the first valid (long) integer value from the current position. // initial characters that are not digits (or the minus sign) are skipped // function is terminated by the first character that is not a digit. long Stream::parseInt() { return parseInt(NO_SKIP_CHAR); // terminate on first non-digit character (or timeout) } // as above but a given skipChar is ignored // this allows format characters (typically commas) in values to be ignored long Stream::parseInt(char skipChar) { boolean isNegative = false; long value = 0; int c; c = peekNextDigit(); // ignore non numeric leading characters if(c < 0) return 0; // zero returned if timeout do{ if(c == skipChar) ; // ignore this charactor else if(c == '-') isNegative = true; else if(c >= '0' && c <= '9') // is c a digit? value = value * 10 + c - '0'; read(); // consume the character we got with peek c = timedPeek(); } while( (c >= '0' && c <= '9') || c == skipChar ); if(isNegative) value = -value; return value; } // as parseInt but returns a floating point value float Stream::parseFloat() { return parseFloat(NO_SKIP_CHAR); } // as above but the given skipChar is ignored // this allows format characters (typically commas) in values to be ignored float Stream::parseFloat(char skipChar){ boolean isNegative = false; boolean isFraction = false; long value = 0; char c; float fraction = 1.0; c = peekNextDigit(); // ignore non numeric leading characters if(c < 0) return 0; // zero returned if timeout do{ if(c == skipChar) ; // ignore else if(c == '-') isNegative = true; else if (c == '.') isFraction = true; else if(c >= '0' && c <= '9') { // is c a digit? value = value * 10 + c - '0'; if(isFraction) fraction *= 0.1; } read(); // consume the character we got with peek c = timedPeek(); } while( (c >= '0' && c <= '9') || c == '.' || c == skipChar ); if(isNegative) value = -value; if(isFraction) return value * fraction; else return value; } // read characters from stream into buffer // terminates if length characters have been read, or timeout (see setTimeout) // returns the number of characters placed in the buffer // the buffer is NOT null terminated. // size_t Stream::readBytes(char *buffer, size_t length) { size_t count = 0; while (count < length) { int c = timedRead(); if (c < 0) break; *buffer++ = (char)c; count++; } return count; } // as readBytes with terminator character // terminates if length characters have been read, timeout, or if the terminator character detected // returns the number of characters placed in the buffer (0 means no valid data found) size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length) { if (length < 1) return 0; size_t index = 0; while (index < length) { int c = timedRead(); if (c < 0 || c == terminator) break; *buffer++ = (char)c; index++; } return index; // return number of characters, not including null terminator } arduino-mighty-1284p-0~svn20130430.orig/cores/standard/binary.h0000644000175000017500000002421312137772502023344 0ustar shevekshevek#ifndef Binary_h #define Binary_h #define B0 0 #define B00 0 #define B000 0 #define B0000 0 #define B00000 0 #define B000000 0 #define B0000000 0 #define B00000000 0 #define B1 1 #define B01 1 #define B001 1 #define B0001 1 #define B00001 1 #define B000001 1 #define B0000001 1 #define B00000001 1 #define B10 2 #define B010 2 #define B0010 2 #define B00010 2 #define B000010 2 #define B0000010 2 #define B00000010 2 #define B11 3 #define B011 3 #define B0011 3 #define B00011 3 #define B000011 3 #define B0000011 3 #define B00000011 3 #define B100 4 #define B0100 4 #define B00100 4 #define B000100 4 #define B0000100 4 #define B00000100 4 #define B101 5 #define B0101 5 #define B00101 5 #define B000101 5 #define B0000101 5 #define B00000101 5 #define B110 6 #define B0110 6 #define B00110 6 #define B000110 6 #define B0000110 6 #define B00000110 6 #define B111 7 #define B0111 7 #define B00111 7 #define B000111 7 #define B0000111 7 #define B00000111 7 #define B1000 8 #define B01000 8 #define B001000 8 #define B0001000 8 #define B00001000 8 #define B1001 9 #define B01001 9 #define B001001 9 #define B0001001 9 #define B00001001 9 #define B1010 10 #define B01010 10 #define B001010 10 #define B0001010 10 #define B00001010 10 #define B1011 11 #define B01011 11 #define B001011 11 #define B0001011 11 #define B00001011 11 #define B1100 12 #define B01100 12 #define B001100 12 #define B0001100 12 #define B00001100 12 #define B1101 13 #define B01101 13 #define B001101 13 #define B0001101 13 #define B00001101 13 #define B1110 14 #define B01110 14 #define B001110 14 #define B0001110 14 #define B00001110 14 #define B1111 15 #define B01111 15 #define B001111 15 #define B0001111 15 #define B00001111 15 #define B10000 16 #define B010000 16 #define B0010000 16 #define B00010000 16 #define B10001 17 #define B010001 17 #define B0010001 17 #define B00010001 17 #define B10010 18 #define B010010 18 #define B0010010 18 #define B00010010 18 #define B10011 19 #define B010011 19 #define B0010011 19 #define B00010011 19 #define B10100 20 #define B010100 20 #define B0010100 20 #define B00010100 20 #define B10101 21 #define B010101 21 #define B0010101 21 #define B00010101 21 #define B10110 22 #define B010110 22 #define B0010110 22 #define B00010110 22 #define B10111 23 #define B010111 23 #define B0010111 23 #define B00010111 23 #define B11000 24 #define B011000 24 #define B0011000 24 #define B00011000 24 #define B11001 25 #define B011001 25 #define B0011001 25 #define B00011001 25 #define B11010 26 #define B011010 26 #define B0011010 26 #define B00011010 26 #define B11011 27 #define B011011 27 #define B0011011 27 #define B00011011 27 #define B11100 28 #define B011100 28 #define B0011100 28 #define B00011100 28 #define B11101 29 #define B011101 29 #define B0011101 29 #define B00011101 29 #define B11110 30 #define B011110 30 #define B0011110 30 #define B00011110 30 #define B11111 31 #define B011111 31 #define B0011111 31 #define B00011111 31 #define B100000 32 #define B0100000 32 #define B00100000 32 #define B100001 33 #define B0100001 33 #define B00100001 33 #define B100010 34 #define B0100010 34 #define B00100010 34 #define B100011 35 #define B0100011 35 #define B00100011 35 #define B100100 36 #define B0100100 36 #define B00100100 36 #define B100101 37 #define B0100101 37 #define B00100101 37 #define B100110 38 #define B0100110 38 #define B00100110 38 #define B100111 39 #define B0100111 39 #define B00100111 39 #define B101000 40 #define B0101000 40 #define B00101000 40 #define B101001 41 #define B0101001 41 #define B00101001 41 #define B101010 42 #define B0101010 42 #define B00101010 42 #define B101011 43 #define B0101011 43 #define B00101011 43 #define B101100 44 #define B0101100 44 #define B00101100 44 #define B101101 45 #define B0101101 45 #define B00101101 45 #define B101110 46 #define B0101110 46 #define B00101110 46 #define B101111 47 #define B0101111 47 #define B00101111 47 #define B110000 48 #define B0110000 48 #define B00110000 48 #define B110001 49 #define B0110001 49 #define B00110001 49 #define B110010 50 #define B0110010 50 #define B00110010 50 #define B110011 51 #define B0110011 51 #define B00110011 51 #define B110100 52 #define B0110100 52 #define B00110100 52 #define B110101 53 #define B0110101 53 #define B00110101 53 #define B110110 54 #define B0110110 54 #define B00110110 54 #define B110111 55 #define B0110111 55 #define B00110111 55 #define B111000 56 #define B0111000 56 #define B00111000 56 #define B111001 57 #define B0111001 57 #define B00111001 57 #define B111010 58 #define B0111010 58 #define B00111010 58 #define B111011 59 #define B0111011 59 #define B00111011 59 #define B111100 60 #define B0111100 60 #define B00111100 60 #define B111101 61 #define B0111101 61 #define B00111101 61 #define B111110 62 #define B0111110 62 #define B00111110 62 #define B111111 63 #define B0111111 63 #define B00111111 63 #define B1000000 64 #define B01000000 64 #define B1000001 65 #define B01000001 65 #define B1000010 66 #define B01000010 66 #define B1000011 67 #define B01000011 67 #define B1000100 68 #define B01000100 68 #define B1000101 69 #define B01000101 69 #define B1000110 70 #define B01000110 70 #define B1000111 71 #define B01000111 71 #define B1001000 72 #define B01001000 72 #define B1001001 73 #define B01001001 73 #define B1001010 74 #define B01001010 74 #define B1001011 75 #define B01001011 75 #define B1001100 76 #define B01001100 76 #define B1001101 77 #define B01001101 77 #define B1001110 78 #define B01001110 78 #define B1001111 79 #define B01001111 79 #define B1010000 80 #define B01010000 80 #define B1010001 81 #define B01010001 81 #define B1010010 82 #define B01010010 82 #define B1010011 83 #define B01010011 83 #define B1010100 84 #define B01010100 84 #define B1010101 85 #define B01010101 85 #define B1010110 86 #define B01010110 86 #define B1010111 87 #define B01010111 87 #define B1011000 88 #define B01011000 88 #define B1011001 89 #define B01011001 89 #define B1011010 90 #define B01011010 90 #define B1011011 91 #define B01011011 91 #define B1011100 92 #define B01011100 92 #define B1011101 93 #define B01011101 93 #define B1011110 94 #define B01011110 94 #define B1011111 95 #define B01011111 95 #define B1100000 96 #define B01100000 96 #define B1100001 97 #define B01100001 97 #define B1100010 98 #define B01100010 98 #define B1100011 99 #define B01100011 99 #define B1100100 100 #define B01100100 100 #define B1100101 101 #define B01100101 101 #define B1100110 102 #define B01100110 102 #define B1100111 103 #define B01100111 103 #define B1101000 104 #define B01101000 104 #define B1101001 105 #define B01101001 105 #define B1101010 106 #define B01101010 106 #define B1101011 107 #define B01101011 107 #define B1101100 108 #define B01101100 108 #define B1101101 109 #define B01101101 109 #define B1101110 110 #define B01101110 110 #define B1101111 111 #define B01101111 111 #define B1110000 112 #define B01110000 112 #define B1110001 113 #define B01110001 113 #define B1110010 114 #define B01110010 114 #define B1110011 115 #define B01110011 115 #define B1110100 116 #define B01110100 116 #define B1110101 117 #define B01110101 117 #define B1110110 118 #define B01110110 118 #define B1110111 119 #define B01110111 119 #define B1111000 120 #define B01111000 120 #define B1111001 121 #define B01111001 121 #define B1111010 122 #define B01111010 122 #define B1111011 123 #define B01111011 123 #define B1111100 124 #define B01111100 124 #define B1111101 125 #define B01111101 125 #define B1111110 126 #define B01111110 126 #define B1111111 127 #define B01111111 127 #define B10000000 128 #define B10000001 129 #define B10000010 130 #define B10000011 131 #define B10000100 132 #define B10000101 133 #define B10000110 134 #define B10000111 135 #define B10001000 136 #define B10001001 137 #define B10001010 138 #define B10001011 139 #define B10001100 140 #define B10001101 141 #define B10001110 142 #define B10001111 143 #define B10010000 144 #define B10010001 145 #define B10010010 146 #define B10010011 147 #define B10010100 148 #define B10010101 149 #define B10010110 150 #define B10010111 151 #define B10011000 152 #define B10011001 153 #define B10011010 154 #define B10011011 155 #define B10011100 156 #define B10011101 157 #define B10011110 158 #define B10011111 159 #define B10100000 160 #define B10100001 161 #define B10100010 162 #define B10100011 163 #define B10100100 164 #define B10100101 165 #define B10100110 166 #define B10100111 167 #define B10101000 168 #define B10101001 169 #define B10101010 170 #define B10101011 171 #define B10101100 172 #define B10101101 173 #define B10101110 174 #define B10101111 175 #define B10110000 176 #define B10110001 177 #define B10110010 178 #define B10110011 179 #define B10110100 180 #define B10110101 181 #define B10110110 182 #define B10110111 183 #define B10111000 184 #define B10111001 185 #define B10111010 186 #define B10111011 187 #define B10111100 188 #define B10111101 189 #define B10111110 190 #define B10111111 191 #define B11000000 192 #define B11000001 193 #define B11000010 194 #define B11000011 195 #define B11000100 196 #define B11000101 197 #define B11000110 198 #define B11000111 199 #define B11001000 200 #define B11001001 201 #define B11001010 202 #define B11001011 203 #define B11001100 204 #define B11001101 205 #define B11001110 206 #define B11001111 207 #define B11010000 208 #define B11010001 209 #define B11010010 210 #define B11010011 211 #define B11010100 212 #define B11010101 213 #define B11010110 214 #define B11010111 215 #define B11011000 216 #define B11011001 217 #define B11011010 218 #define B11011011 219 #define B11011100 220 #define B11011101 221 #define B11011110 222 #define B11011111 223 #define B11100000 224 #define B11100001 225 #define B11100010 226 #define B11100011 227 #define B11100100 228 #define B11100101 229 #define B11100110 230 #define B11100111 231 #define B11101000 232 #define B11101001 233 #define B11101010 234 #define B11101011 235 #define B11101100 236 #define B11101101 237 #define B11101110 238 #define B11101111 239 #define B11110000 240 #define B11110001 241 #define B11110010 242 #define B11110011 243 #define B11110100 244 #define B11110101 245 #define B11110110 246 #define B11110111 247 #define B11111000 248 #define B11111001 249 #define B11111010 250 #define B11111011 251 #define B11111100 252 #define B11111101 253 #define B11111110 254 #define B11111111 255 #endif arduino-mighty-1284p-0~svn20130430.orig/cores/standard/new.h0000644000175000017500000000106212137772502022646 0ustar shevekshevek/* Header to define new/delete operators as they aren't provided by avr-gcc by default Taken from http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=59453 */ #ifndef NEW_H #define NEW_H #include void * operator new(size_t size); void operator delete(void * ptr); __extension__ typedef int __guard __attribute__((mode (__DI__))); extern "C" int __cxa_guard_acquire(__guard *); extern "C" void __cxa_guard_release (__guard *); extern "C" void __cxa_guard_abort (__guard *); extern "C" void __cxa_pure_virtual(void); #endif arduino-mighty-1284p-0~svn20130430.orig/cores/standard/USBCore.h0000644000175000017500000001725712137772502023334 0ustar shevekshevek // Copyright (c) 2010, Peter Barrett /* ** Permission to use, copy, modify, and/or distribute this software for ** any purpose with or without fee is hereby granted, provided that the ** above copyright notice and this permission notice appear in all copies. ** ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL ** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR ** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES ** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, ** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS ** SOFTWARE. */ #ifndef __USBCORE_H__ #define __USBCORE_H__ // Standard requests #define GET_STATUS 0 #define CLEAR_FEATURE 1 #define SET_FEATURE 3 #define SET_ADDRESS 5 #define GET_DESCRIPTOR 6 #define SET_DESCRIPTOR 7 #define GET_CONFIGURATION 8 #define SET_CONFIGURATION 9 #define GET_INTERFACE 10 #define SET_INTERFACE 11 // bmRequestType #define REQUEST_HOSTTODEVICE 0x00 #define REQUEST_DEVICETOHOST 0x80 #define REQUEST_DIRECTION 0x80 #define REQUEST_STANDARD 0x00 #define REQUEST_CLASS 0x20 #define REQUEST_VENDOR 0x40 #define REQUEST_TYPE 0x60 #define REQUEST_DEVICE 0x00 #define REQUEST_INTERFACE 0x01 #define REQUEST_ENDPOINT 0x02 #define REQUEST_OTHER 0x03 #define REQUEST_RECIPIENT 0x03 #define REQUEST_DEVICETOHOST_CLASS_INTERFACE (REQUEST_DEVICETOHOST + REQUEST_CLASS + REQUEST_INTERFACE) #define REQUEST_HOSTTODEVICE_CLASS_INTERFACE (REQUEST_HOSTTODEVICE + REQUEST_CLASS + REQUEST_INTERFACE) // Class requests #define CDC_SET_LINE_CODING 0x20 #define CDC_GET_LINE_CODING 0x21 #define CDC_SET_CONTROL_LINE_STATE 0x22 #define MSC_RESET 0xFF #define MSC_GET_MAX_LUN 0xFE #define HID_GET_REPORT 0x01 #define HID_GET_IDLE 0x02 #define HID_GET_PROTOCOL 0x03 #define HID_SET_REPORT 0x09 #define HID_SET_IDLE 0x0A #define HID_SET_PROTOCOL 0x0B // Descriptors #define USB_DEVICE_DESC_SIZE 18 #define USB_CONFIGUARTION_DESC_SIZE 9 #define USB_INTERFACE_DESC_SIZE 9 #define USB_ENDPOINT_DESC_SIZE 7 #define USB_DEVICE_DESCRIPTOR_TYPE 1 #define USB_CONFIGURATION_DESCRIPTOR_TYPE 2 #define USB_STRING_DESCRIPTOR_TYPE 3 #define USB_INTERFACE_DESCRIPTOR_TYPE 4 #define USB_ENDPOINT_DESCRIPTOR_TYPE 5 #define USB_DEVICE_CLASS_COMMUNICATIONS 0x02 #define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03 #define USB_DEVICE_CLASS_STORAGE 0x08 #define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF #define USB_CONFIG_POWERED_MASK 0x40 #define USB_CONFIG_BUS_POWERED 0x80 #define USB_CONFIG_SELF_POWERED 0xC0 #define USB_CONFIG_REMOTE_WAKEUP 0x20 // bMaxPower in Configuration Descriptor #define USB_CONFIG_POWER_MA(mA) ((mA)/2) // bEndpointAddress in Endpoint Descriptor #define USB_ENDPOINT_DIRECTION_MASK 0x80 #define USB_ENDPOINT_OUT(addr) ((addr) | 0x00) #define USB_ENDPOINT_IN(addr) ((addr) | 0x80) #define USB_ENDPOINT_TYPE_MASK 0x03 #define USB_ENDPOINT_TYPE_CONTROL 0x00 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01 #define USB_ENDPOINT_TYPE_BULK 0x02 #define USB_ENDPOINT_TYPE_INTERRUPT 0x03 #define TOBYTES(x) ((x) & 0xFF),(((x) >> 8) & 0xFF) #define CDC_V1_10 0x0110 #define CDC_COMMUNICATION_INTERFACE_CLASS 0x02 #define CDC_CALL_MANAGEMENT 0x01 #define CDC_ABSTRACT_CONTROL_MODEL 0x02 #define CDC_HEADER 0x00 #define CDC_ABSTRACT_CONTROL_MANAGEMENT 0x02 #define CDC_UNION 0x06 #define CDC_CS_INTERFACE 0x24 #define CDC_CS_ENDPOINT 0x25 #define CDC_DATA_INTERFACE_CLASS 0x0A #define MSC_SUBCLASS_SCSI 0x06 #define MSC_PROTOCOL_BULK_ONLY 0x50 #define HID_HID_DESCRIPTOR_TYPE 0x21 #define HID_REPORT_DESCRIPTOR_TYPE 0x22 #define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23 // Device typedef struct { u8 len; // 18 u8 dtype; // 1 USB_DEVICE_DESCRIPTOR_TYPE u16 usbVersion; // 0x200 u8 deviceClass; u8 deviceSubClass; u8 deviceProtocol; u8 packetSize0; // Packet 0 u16 idVendor; u16 idProduct; u16 deviceVersion; // 0x100 u8 iManufacturer; u8 iProduct; u8 iSerialNumber; u8 bNumConfigurations; } DeviceDescriptor; // Config typedef struct { u8 len; // 9 u8 dtype; // 2 u16 clen; // total length u8 numInterfaces; u8 config; u8 iconfig; u8 attributes; u8 maxPower; } ConfigDescriptor; // String // Interface typedef struct { u8 len; // 9 u8 dtype; // 4 u8 number; u8 alternate; u8 numEndpoints; u8 interfaceClass; u8 interfaceSubClass; u8 protocol; u8 iInterface; } InterfaceDescriptor; // Endpoint typedef struct { u8 len; // 7 u8 dtype; // 5 u8 addr; u8 attr; u16 packetSize; u8 interval; } EndpointDescriptor; // Interface Association Descriptor // Used to bind 2 interfaces together in CDC compostite device typedef struct { u8 len; // 8 u8 dtype; // 11 u8 firstInterface; u8 interfaceCount; u8 functionClass; u8 funtionSubClass; u8 functionProtocol; u8 iInterface; } IADDescriptor; // CDC CS interface descriptor typedef struct { u8 len; // 5 u8 dtype; // 0x24 u8 subtype; u8 d0; u8 d1; } CDCCSInterfaceDescriptor; typedef struct { u8 len; // 4 u8 dtype; // 0x24 u8 subtype; u8 d0; } CDCCSInterfaceDescriptor4; typedef struct { u8 len; u8 dtype; // 0x24 u8 subtype; // 1 u8 bmCapabilities; u8 bDataInterface; } CMFunctionalDescriptor; typedef struct { u8 len; u8 dtype; // 0x24 u8 subtype; // 1 u8 bmCapabilities; } ACMFunctionalDescriptor; typedef struct { // IAD IADDescriptor iad; // Only needed on compound device // Control InterfaceDescriptor cif; // CDCCSInterfaceDescriptor header; CMFunctionalDescriptor callManagement; // Call Management ACMFunctionalDescriptor controlManagement; // ACM CDCCSInterfaceDescriptor functionalDescriptor; // CDC_UNION EndpointDescriptor cifin; // Data InterfaceDescriptor dif; EndpointDescriptor in; EndpointDescriptor out; } CDCDescriptor; typedef struct { InterfaceDescriptor msc; EndpointDescriptor in; EndpointDescriptor out; } MSCDescriptor; typedef struct { u8 len; // 9 u8 dtype; // 0x21 u8 addr; u8 versionL; // 0x101 u8 versionH; // 0x101 u8 country; u8 desctype; // 0x22 report u8 descLenL; u8 descLenH; } HIDDescDescriptor; typedef struct { InterfaceDescriptor hid; HIDDescDescriptor desc; EndpointDescriptor in; } HIDDescriptor; #define D_DEVICE(_class,_subClass,_proto,_packetSize0,_vid,_pid,_version,_im,_ip,_is,_configs) \ { 18, 1, 0x200, _class,_subClass,_proto,_packetSize0,_vid,_pid,_version,_im,_ip,_is,_configs } #define D_CONFIG(_totalLength,_interfaces) \ { 9, 2, _totalLength,_interfaces, 1, 0, USB_CONFIG_BUS_POWERED, USB_CONFIG_POWER_MA(500) } #define D_INTERFACE(_n,_numEndpoints,_class,_subClass,_protocol) \ { 9, 4, _n, 0, _numEndpoints, _class,_subClass, _protocol, 0 } #define D_ENDPOINT(_addr,_attr,_packetSize, _interval) \ { 7, 5, _addr,_attr,_packetSize, _interval } #define D_IAD(_firstInterface, _count, _class, _subClass, _protocol) \ { 8, 11, _firstInterface, _count, _class, _subClass, _protocol, 0 } #define D_HIDREPORT(_descriptorLength) \ { 9, 0x21, 0x1, 0x1, 0, 1, 0x22, _descriptorLength, 0 } #define D_CDCCS(_subtype,_d0,_d1) { 5, 0x24, _subtype, _d0, _d1 } #define D_CDCCS4(_subtype,_d0) { 4, 0x24, _subtype, _d0 } #endifarduino-mighty-1284p-0~svn20130430.orig/cores/standard/Server.h0000644000175000017500000000015712137772502023327 0ustar shevekshevek#ifndef server_h #define server_h class Server : public Print { public: virtual void begin() =0; }; #endif arduino-mighty-1284p-0~svn20130430.orig/cores/standard/Client.h0000644000175000017500000000127112137772502023275 0ustar shevekshevek#ifndef client_h #define client_h #include "Print.h" #include "Stream.h" #include "IPAddress.h" class Client : public Stream { public: virtual int connect(IPAddress ip, uint16_t port) =0; virtual int connect(const char *host, uint16_t port) =0; virtual size_t write(uint8_t) =0; virtual size_t write(const uint8_t *buf, size_t size) =0; virtual int available() = 0; virtual int read() = 0; virtual int read(uint8_t *buf, size_t size) = 0; virtual int peek() = 0; virtual void flush() = 0; virtual void stop() = 0; virtual uint8_t connected() = 0; virtual operator bool() = 0; protected: uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; }; #endif arduino-mighty-1284p-0~svn20130430.orig/cores/standard/Print.cpp0000644000175000017500000001212012137772502023501 0ustar shevekshevek/* Print.cpp - Base class that provides print() and println() Copyright (c) 2008 David A. Mellis. All right reserved. 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Modified 23 November 2006 by David A. Mellis */ #include #include #include #include #include "Arduino.h" #include "Print.h" // Public Methods ////////////////////////////////////////////////////////////// /* default implementation: may be overridden */ size_t Print::write(const uint8_t *buffer, size_t size) { size_t n = 0; while (size--) { n += write(*buffer++); } return n; } size_t Print::print(const __FlashStringHelper *ifsh) { const char *p = (const char *)ifsh; size_t n = 0; while (1) { unsigned char c = pgm_read_byte(p++); if (c == 0) break; n += write(c); } return n; } size_t Print::print(const String &s) { size_t n = 0; for (uint16_t i = 0; i < s.length(); i++) { n += write(s[i]); } return n; } size_t Print::print(const char str[]) { return write(str); } size_t Print::print(char c) { return write(c); } size_t Print::print(unsigned char b, int base) { return print((unsigned long) b, base); } size_t Print::print(int n, int base) { return print((long) n, base); } size_t Print::print(unsigned int n, int base) { return print((unsigned long) n, base); } size_t Print::print(long n, int base) { if (base == 0) { return write(n); } else if (base == 10) { if (n < 0) { int t = print('-'); n = -n; return printNumber(n, 10) + t; } return printNumber(n, 10); } else { return printNumber(n, base); } } size_t Print::print(unsigned long n, int base) { if (base == 0) return write(n); else return printNumber(n, base); } size_t Print::print(double n, int digits) { return printFloat(n, digits); } size_t Print::println(const __FlashStringHelper *ifsh) { size_t n = print(ifsh); n += println(); return n; } size_t Print::print(const Printable& x) { return x.printTo(*this); } size_t Print::println(void) { size_t n = print('\r'); n += print('\n'); return n; } size_t Print::println(const String &s) { size_t n = print(s); n += println(); return n; } size_t Print::println(const char c[]) { size_t n = print(c); n += println(); return n; } size_t Print::println(char c) { size_t n = print(c); n += println(); return n; } size_t Print::println(unsigned char b, int base) { size_t n = print(b, base); n += println(); return n; } size_t Print::println(int num, int base) { size_t n = print(num, base); n += println(); return n; } size_t Print::println(unsigned int num, int base) { size_t n = print(num, base); n += println(); return n; } size_t Print::println(long num, int base) { size_t n = print(num, base); n += println(); return n; } size_t Print::println(unsigned long num, int base) { size_t n = print(num, base); n += println(); return n; } size_t Print::println(double num, int digits) { size_t n = print(num, digits); n += println(); return n; } size_t Print::println(const Printable& x) { size_t n = print(x); n += println(); return n; } // Private Methods ///////////////////////////////////////////////////////////// size_t Print::printNumber(unsigned long n, uint8_t base) { char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. char *str = &buf[sizeof(buf) - 1]; *str = '\0'; // prevent crash if called with base == 1 if (base < 2) base = 10; do { unsigned long m = n; n /= base; char c = m - base * n; *--str = c < 10 ? c + '0' : c + 'A' - 10; } while(n); return write(str); } size_t Print::printFloat(double number, uint8_t digits) { size_t n = 0; // Handle negative numbers if (number < 0.0) { n += print('-'); number = -number; } // Round correctly so that print(1.999, 2) prints as "2.00" double rounding = 0.5; for (uint8_t i=0; i 0) { n += print("."); } // Extract digits from the remainder one at a time while (digits-- > 0) { remainder *= 10.0; int toPrint = int(remainder); n += print(toPrint); remainder -= toPrint; } return n; } arduino-mighty-1284p-0~svn20130430.orig/cores/standard/Tone.cpp0000644000175000017500000003374712137772502023334 0ustar shevekshevek/* Tone.cpp A Tone Generator Library Written by Brett Hagman 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Version Modified By Date Comments ------- ----------- -------- -------- 0001 B Hagman 09/08/02 Initial coding 0002 B Hagman 09/08/18 Multiple pins 0003 B Hagman 09/08/18 Moved initialization from constructor to begin() 0004 B Hagman 09/09/26 Fixed problems with ATmega8 0005 B Hagman 09/11/23 Scanned prescalars for best fit on 8 bit timers 09/11/25 Changed pin toggle method to XOR 09/11/25 Fixed timer0 from being excluded 0006 D Mellis 09/12/29 Replaced objects with functions 0007 M Sproul 10/08/29 Changed #ifdefs from cpu to register *************************************************/ #include #include #include "Arduino.h" #include "pins_arduino.h" #if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__) #define TCCR2A TCCR2 #define TCCR2B TCCR2 #define COM2A1 COM21 #define COM2A0 COM20 #define OCR2A OCR2 #define TIMSK2 TIMSK #define OCIE2A OCIE2 #define TIMER2_COMPA_vect TIMER2_COMP_vect #define TIMSK1 TIMSK #endif // timerx_toggle_count: // > 0 - duration specified // = 0 - stopped // < 0 - infinitely (until stop() method called, or new play() called) #if !defined(__AVR_ATmega8__) volatile long timer0_toggle_count; volatile uint8_t *timer0_pin_port; volatile uint8_t timer0_pin_mask; #endif volatile long timer1_toggle_count; volatile uint8_t *timer1_pin_port; volatile uint8_t timer1_pin_mask; volatile long timer2_toggle_count; volatile uint8_t *timer2_pin_port; volatile uint8_t timer2_pin_mask; #if defined(TIMSK3) volatile long timer3_toggle_count; volatile uint8_t *timer3_pin_port; volatile uint8_t timer3_pin_mask; #endif #if defined(TIMSK4) volatile long timer4_toggle_count; volatile uint8_t *timer4_pin_port; volatile uint8_t timer4_pin_mask; #endif #if defined(TIMSK5) volatile long timer5_toggle_count; volatile uint8_t *timer5_pin_port; volatile uint8_t timer5_pin_mask; #endif // MLS: This does not make sense, the 3 options are the same #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #define AVAILABLE_TONE_PINS 1 const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ }; static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ }; #elif defined(__AVR_ATmega8__) #define AVAILABLE_TONE_PINS 1 const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1 */ }; static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ }; #else #define AVAILABLE_TONE_PINS 1 // Leave timer 0 to last. const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1, 0 */ }; static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255 */ }; #endif static int8_t toneBegin(uint8_t _pin) { int8_t _timer = -1; // if we're already using the pin, the timer should be configured. for (int i = 0; i < AVAILABLE_TONE_PINS; i++) { if (tone_pins[i] == _pin) { return pgm_read_byte(tone_pin_to_timer_PGM + i); } } // search for an unused timer. for (int i = 0; i < AVAILABLE_TONE_PINS; i++) { if (tone_pins[i] == 255) { tone_pins[i] = _pin; _timer = pgm_read_byte(tone_pin_to_timer_PGM + i); break; } } if (_timer != -1) { // Set timer specific stuff // All timers in CTC mode // 8 bit timers will require changing prescalar values, // whereas 16 bit timers are set to either ck/1 or ck/64 prescalar switch (_timer) { #if defined(TCCR0A) && defined(TCCR0B) case 0: // 8 bit timer TCCR0A = 0; TCCR0B = 0; bitWrite(TCCR0A, WGM01, 1); bitWrite(TCCR0B, CS00, 1); timer0_pin_port = portOutputRegister(digitalPinToPort(_pin)); timer0_pin_mask = digitalPinToBitMask(_pin); break; #endif #if defined(TCCR1A) && defined(TCCR1B) && defined(WGM12) case 1: // 16 bit timer TCCR1A = 0; TCCR1B = 0; bitWrite(TCCR1B, WGM12, 1); bitWrite(TCCR1B, CS10, 1); timer1_pin_port = portOutputRegister(digitalPinToPort(_pin)); timer1_pin_mask = digitalPinToBitMask(_pin); break; #endif #if defined(TCCR2A) && defined(TCCR2B) case 2: // 8 bit timer TCCR2A = 0; TCCR2B = 0; bitWrite(TCCR2A, WGM21, 1); bitWrite(TCCR2B, CS20, 1); timer2_pin_port = portOutputRegister(digitalPinToPort(_pin)); timer2_pin_mask = digitalPinToBitMask(_pin); break; #endif #if defined(TCCR3A) && defined(TCCR3B) && defined(TIMSK3) case 3: // 16 bit timer TCCR3A = 0; TCCR3B = 0; bitWrite(TCCR3B, WGM32, 1); bitWrite(TCCR3B, CS30, 1); timer3_pin_port = portOutputRegister(digitalPinToPort(_pin)); timer3_pin_mask = digitalPinToBitMask(_pin); break; #endif #if defined(TCCR4A) && defined(TCCR4B) && defined(TIMSK4) case 4: // 16 bit timer TCCR4A = 0; TCCR4B = 0; #if defined(WGM42) bitWrite(TCCR4B, WGM42, 1); #elif defined(CS43) #warning this may not be correct // atmega32u4 bitWrite(TCCR4B, CS43, 1); #endif bitWrite(TCCR4B, CS40, 1); timer4_pin_port = portOutputRegister(digitalPinToPort(_pin)); timer4_pin_mask = digitalPinToBitMask(_pin); break; #endif #if defined(TCCR5A) && defined(TCCR5B) && defined(TIMSK5) case 5: // 16 bit timer TCCR5A = 0; TCCR5B = 0; bitWrite(TCCR5B, WGM52, 1); bitWrite(TCCR5B, CS50, 1); timer5_pin_port = portOutputRegister(digitalPinToPort(_pin)); timer5_pin_mask = digitalPinToBitMask(_pin); break; #endif } } return _timer; } // frequency (in hertz) and duration (in milliseconds). void tone(uint8_t _pin, unsigned int frequency, unsigned long duration) { uint8_t prescalarbits = 0b001; long toggle_count = 0; uint32_t ocr = 0; int8_t _timer; _timer = toneBegin(_pin); if (_timer >= 0) { // Set the pinMode as OUTPUT pinMode(_pin, OUTPUT); // if we are using an 8 bit timer, scan through prescalars to find the best fit if (_timer == 0 || _timer == 2) { ocr = F_CPU / frequency / 2 - 1; prescalarbits = 0b001; // ck/1: same for both timers if (ocr > 255) { ocr = F_CPU / frequency / 2 / 8 - 1; prescalarbits = 0b010; // ck/8: same for both timers if (_timer == 2 && ocr > 255) { ocr = F_CPU / frequency / 2 / 32 - 1; prescalarbits = 0b011; } if (ocr > 255) { ocr = F_CPU / frequency / 2 / 64 - 1; prescalarbits = _timer == 0 ? 0b011 : 0b100; if (_timer == 2 && ocr > 255) { ocr = F_CPU / frequency / 2 / 128 - 1; prescalarbits = 0b101; } if (ocr > 255) { ocr = F_CPU / frequency / 2 / 256 - 1; prescalarbits = _timer == 0 ? 0b100 : 0b110; if (ocr > 255) { // can't do any better than /1024 ocr = F_CPU / frequency / 2 / 1024 - 1; prescalarbits = _timer == 0 ? 0b101 : 0b111; } } } } #if defined(TCCR0B) if (_timer == 0) { TCCR0B = prescalarbits; } else #endif #if defined(TCCR2B) { TCCR2B = prescalarbits; } #else { // dummy place holder to make the above ifdefs work } #endif } else { // two choices for the 16 bit timers: ck/1 or ck/64 ocr = F_CPU / frequency / 2 - 1; prescalarbits = 0b001; if (ocr > 0xffff) { ocr = F_CPU / frequency / 2 / 64 - 1; prescalarbits = 0b011; } if (_timer == 1) { #if defined(TCCR1B) TCCR1B = (TCCR1B & 0b11111000) | prescalarbits; #endif } #if defined(TCCR3B) else if (_timer == 3) TCCR3B = (TCCR3B & 0b11111000) | prescalarbits; #endif #if defined(TCCR4B) else if (_timer == 4) TCCR4B = (TCCR4B & 0b11111000) | prescalarbits; #endif #if defined(TCCR5B) else if (_timer == 5) TCCR5B = (TCCR5B & 0b11111000) | prescalarbits; #endif } // Calculate the toggle count if (duration > 0) { toggle_count = 2 * frequency * duration / 1000; } else { toggle_count = -1; } // Set the OCR for the given timer, // set the toggle count, // then turn on the interrupts switch (_timer) { #if defined(OCR0A) && defined(TIMSK0) && defined(OCIE0A) case 0: OCR0A = ocr; timer0_toggle_count = toggle_count; bitWrite(TIMSK0, OCIE0A, 1); break; #endif case 1: #if defined(OCR1A) && defined(TIMSK1) && defined(OCIE1A) OCR1A = ocr; timer1_toggle_count = toggle_count; bitWrite(TIMSK1, OCIE1A, 1); #elif defined(OCR1A) && defined(TIMSK) && defined(OCIE1A) // this combination is for at least the ATmega32 OCR1A = ocr; timer1_toggle_count = toggle_count; bitWrite(TIMSK, OCIE1A, 1); #endif break; #if defined(OCR2A) && defined(TIMSK2) && defined(OCIE2A) case 2: OCR2A = ocr; timer2_toggle_count = toggle_count; bitWrite(TIMSK2, OCIE2A, 1); break; #endif #if defined(TIMSK3) case 3: OCR3A = ocr; timer3_toggle_count = toggle_count; bitWrite(TIMSK3, OCIE3A, 1); break; #endif #if defined(TIMSK4) case 4: OCR4A = ocr; timer4_toggle_count = toggle_count; bitWrite(TIMSK4, OCIE4A, 1); break; #endif #if defined(OCR5A) && defined(TIMSK5) && defined(OCIE5A) case 5: OCR5A = ocr; timer5_toggle_count = toggle_count; bitWrite(TIMSK5, OCIE5A, 1); break; #endif } } } // XXX: this function only works properly for timer 2 (the only one we use // currently). for the others, it should end the tone, but won't restore // proper PWM functionality for the timer. void disableTimer(uint8_t _timer) { switch (_timer) { case 0: #if defined(TIMSK0) TIMSK0 = 0; #elif defined(TIMSK) TIMSK = 0; // atmega32 #endif break; #if defined(TIMSK1) && defined(OCIE1A) case 1: bitWrite(TIMSK1, OCIE1A, 0); break; #endif case 2: #if defined(TIMSK2) && defined(OCIE2A) bitWrite(TIMSK2, OCIE2A, 0); // disable interrupt #endif #if defined(TCCR2A) && defined(WGM20) TCCR2A = (1 << WGM20); #endif #if defined(TCCR2B) && defined(CS22) TCCR2B = (TCCR2B & 0b11111000) | (1 << CS22); #endif #if defined(OCR2A) OCR2A = 0; #endif break; #if defined(TIMSK3) case 3: TIMSK3 = 0; break; #endif #if defined(TIMSK4) case 4: TIMSK4 = 0; break; #endif #if defined(TIMSK5) case 5: TIMSK5 = 0; break; #endif } } void noTone(uint8_t _pin) { int8_t _timer = -1; for (int i = 0; i < AVAILABLE_TONE_PINS; i++) { if (tone_pins[i] == _pin) { _timer = pgm_read_byte(tone_pin_to_timer_PGM + i); tone_pins[i] = 255; } } disableTimer(_timer); digitalWrite(_pin, 0); } #if 0 #if !defined(__AVR_ATmega8__) ISR(TIMER0_COMPA_vect) { if (timer0_toggle_count != 0) { // toggle the pin *timer0_pin_port ^= timer0_pin_mask; if (timer0_toggle_count > 0) timer0_toggle_count--; } else { disableTimer(0); *timer0_pin_port &= ~(timer0_pin_mask); // keep pin low after stop } } #endif ISR(TIMER1_COMPA_vect) { if (timer1_toggle_count != 0) { // toggle the pin *timer1_pin_port ^= timer1_pin_mask; if (timer1_toggle_count > 0) timer1_toggle_count--; } else { disableTimer(1); *timer1_pin_port &= ~(timer1_pin_mask); // keep pin low after stop } } #endif ISR(TIMER2_COMPA_vect) { if (timer2_toggle_count != 0) { // toggle the pin *timer2_pin_port ^= timer2_pin_mask; if (timer2_toggle_count > 0) timer2_toggle_count--; } else { // need to call noTone() so that the tone_pins[] entry is reset, so the // timer gets initialized next time we call tone(). // XXX: this assumes timer 2 is always the first one used. noTone(tone_pins[0]); // disableTimer(2); // *timer2_pin_port &= ~(timer2_pin_mask); // keep pin low after stop } } //#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #if 0 ISR(TIMER3_COMPA_vect) { if (timer3_toggle_count != 0) { // toggle the pin *timer3_pin_port ^= timer3_pin_mask; if (timer3_toggle_count > 0) timer3_toggle_count--; } else { disableTimer(3); *timer3_pin_port &= ~(timer3_pin_mask); // keep pin low after stop } } ISR(TIMER4_COMPA_vect) { if (timer4_toggle_count != 0) { // toggle the pin *timer4_pin_port ^= timer4_pin_mask; if (timer4_toggle_count > 0) timer4_toggle_count--; } else { disableTimer(4); *timer4_pin_port &= ~(timer4_pin_mask); // keep pin low after stop } } ISR(TIMER5_COMPA_vect) { if (timer5_toggle_count != 0) { // toggle the pin *timer5_pin_port ^= timer5_pin_mask; if (timer5_toggle_count > 0) timer5_toggle_count--; } else { disableTimer(5); *timer5_pin_port &= ~(timer5_pin_mask); // keep pin low after stop } } #endif arduino-mighty-1284p-0~svn20130430.orig/cores/standard/wiring.c0000644000175000017500000002013112137772502023345 0ustar shevekshevek/* wiring.c - Partial implementation of the Wiring API for the ATmega8. Part of Arduino - http://www.arduino.cc/ Copyright (c) 2005-2006 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$ */ #include "wiring_private.h" // the prescaler is set so that timer0 ticks every 64 clock cycles, and the // the overflow handler is called every 256 ticks. #define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256)) // the whole number of milliseconds per timer0 overflow #define MILLIS_INC (MICROSECONDS_PER_TIMER0_OVERFLOW / 1000) // the fractional number of milliseconds per timer0 overflow. we shift right // by three to fit these numbers into a byte. (for the clock speeds we care // about - 8 and 16 MHz - this doesn't lose precision.) #define FRACT_INC ((MICROSECONDS_PER_TIMER0_OVERFLOW % 1000) >> 3) #define FRACT_MAX (1000 >> 3) volatile unsigned long timer0_overflow_count = 0; volatile unsigned long timer0_millis = 0; static unsigned char timer0_fract = 0; #if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) SIGNAL(TIM0_OVF_vect) #else SIGNAL(TIMER0_OVF_vect) #endif { // copy these to local variables so they can be stored in registers // (volatile variables must be read from memory on every access) unsigned long m = timer0_millis; unsigned char f = timer0_fract; m += MILLIS_INC; f += FRACT_INC; if (f >= FRACT_MAX) { f -= FRACT_MAX; m += 1; } timer0_fract = f; timer0_millis = m; timer0_overflow_count++; } unsigned long millis() { unsigned long m; uint8_t oldSREG = SREG; // disable interrupts while we read timer0_millis or we might get an // inconsistent value (e.g. in the middle of a write to timer0_millis) cli(); m = timer0_millis; SREG = oldSREG; return m; } unsigned long micros() { unsigned long m; uint8_t oldSREG = SREG, t; cli(); m = timer0_overflow_count; #if defined(TCNT0) t = TCNT0; #elif defined(TCNT0L) t = TCNT0L; #else #error TIMER 0 not defined #endif #ifdef TIFR0 if ((TIFR0 & _BV(TOV0)) && (t < 255)) m++; #else if ((TIFR & _BV(TOV0)) && (t < 255)) m++; #endif SREG = oldSREG; return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond()); } void delay(unsigned long ms) { uint16_t start = (uint16_t)micros(); while (ms > 0) { if (((uint16_t)micros() - start) >= 1000) { ms--; start += 1000; } } } /* Delay for the given number of microseconds. Assumes a 8 or 16 MHz clock. */ void delayMicroseconds(unsigned int us) { // calling avrlib's delay_us() function with low values (e.g. 1 or // 2 microseconds) gives delays longer than desired. //delay_us(us); #if F_CPU >= 16000000L // for the 16 MHz clock on most Arduino boards // for a one-microsecond delay, simply return. the overhead // of the function call yields a delay of approximately 1 1/8 us. if (--us == 0) return; // the following loop takes a quarter of a microsecond (4 cycles) // per iteration, so execute it four times for each microsecond of // delay requested. us <<= 2; // account for the time taken in the preceeding commands. us -= 2; #else // for the 8 MHz internal clock on the ATmega168 // for a one- or two-microsecond delay, simply return. the overhead of // the function calls takes more than two microseconds. can't just // subtract two, since us is unsigned; we'd overflow. if (--us == 0) return; if (--us == 0) return; // the following loop takes half of a microsecond (4 cycles) // per iteration, so execute it twice for each microsecond of // delay requested. us <<= 1; // partially compensate for the time taken by the preceeding commands. // we can't subtract any more than this or we'd overflow w/ small delays. us--; #endif // busy wait __asm__ __volatile__ ( "1: sbiw %0,1" "\n\t" // 2 cycles "brne 1b" : "=w" (us) : "0" (us) // 2 cycles ); } void init() { // this needs to be called before setup() or some functions won't // work there sei(); // on the ATmega168, timer 0 is also used for fast hardware pwm // (using phase-correct PWM would mean that timer 0 overflowed half as often // resulting in different millis() behavior on the ATmega8 and ATmega168) #if defined(TCCR0A) && defined(WGM01) sbi(TCCR0A, WGM01); sbi(TCCR0A, WGM00); #endif // set timer 0 prescale factor to 64 #if defined(__AVR_ATmega128__) // CPU specific: different values for the ATmega128 sbi(TCCR0, CS02); #elif defined(TCCR0) && defined(CS01) && defined(CS00) // this combination is for the standard atmega8 sbi(TCCR0, CS01); sbi(TCCR0, CS00); #elif defined(TCCR0B) && defined(CS01) && defined(CS00) // this combination is for the standard 168/328/1280/2560 sbi(TCCR0B, CS01); sbi(TCCR0B, CS00); #elif defined(TCCR0A) && defined(CS01) && defined(CS00) // this combination is for the __AVR_ATmega645__ series sbi(TCCR0A, CS01); sbi(TCCR0A, CS00); #else #error Timer 0 prescale factor 64 not set correctly #endif // enable timer 0 overflow interrupt #if defined(TIMSK) && defined(TOIE0) sbi(TIMSK, TOIE0); #elif defined(TIMSK0) && defined(TOIE0) sbi(TIMSK0, TOIE0); #else #error Timer 0 overflow interrupt not set correctly #endif // timers 1 and 2 are used for phase-correct hardware pwm // this is better for motors as it ensures an even waveform // note, however, that fast pwm mode can achieve a frequency of up // 8 MHz (with a 16 MHz clock) at 50% duty cycle #if defined(TCCR1B) && defined(CS11) && defined(CS10) TCCR1B = 0; // set timer 1 prescale factor to 64 sbi(TCCR1B, CS11); #if F_CPU >= 8000000L sbi(TCCR1B, CS10); #endif #elif defined(TCCR1) && defined(CS11) && defined(CS10) sbi(TCCR1, CS11); #if F_CPU >= 8000000L sbi(TCCR1, CS10); #endif #endif // put timer 1 in 8-bit phase correct pwm mode #if defined(TCCR1A) && defined(WGM10) sbi(TCCR1A, WGM10); #elif defined(TCCR1) #warning this needs to be finished #endif // set timer 2 prescale factor to 64 #if defined(TCCR2) && defined(CS22) sbi(TCCR2, CS22); #elif defined(TCCR2B) && defined(CS22) sbi(TCCR2B, CS22); #else #warning Timer 2 not finished (may not be present on this CPU) #endif // configure timer 2 for phase correct pwm (8-bit) #if defined(TCCR2) && defined(WGM20) sbi(TCCR2, WGM20); #elif defined(TCCR2A) && defined(WGM20) sbi(TCCR2A, WGM20); #else #warning Timer 2 not finished (may not be present on this CPU) #endif #if defined(TCCR3B) && defined(CS31) && defined(WGM30) sbi(TCCR3B, CS31); // set timer 3 prescale factor to 64 sbi(TCCR3B, CS30); sbi(TCCR3A, WGM30); // put timer 3 in 8-bit phase correct pwm mode #endif #if defined(TCCR4B) && defined(CS41) && defined(WGM40) sbi(TCCR4B, CS41); // set timer 4 prescale factor to 64 sbi(TCCR4B, CS40); sbi(TCCR4A, WGM40); // put timer 4 in 8-bit phase correct pwm mode #endif #if defined(TCCR5B) && defined(CS51) && defined(WGM50) sbi(TCCR5B, CS51); // set timer 5 prescale factor to 64 sbi(TCCR5B, CS50); sbi(TCCR5A, WGM50); // put timer 5 in 8-bit phase correct pwm mode #endif #if defined(ADCSRA) // set a2d prescale factor to 128 // 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range. // XXX: this will not work properly for other clock speeds, and // this code should use F_CPU to determine the prescale factor. sbi(ADCSRA, ADPS2); sbi(ADCSRA, ADPS1); sbi(ADCSRA, ADPS0); // enable a2d conversions sbi(ADCSRA, ADEN); #endif // the bootloader connects pins 0 and 1 to the USART; disconnect them // here so they can be used as normal digital i/o; they will be // reconnected in Serial.begin() #if defined(UCSRB) UCSRB = 0; #elif defined(UCSR0B) UCSR0B = 0; #endif } arduino-mighty-1284p-0~svn20130430.orig/cores/standard/Printable.h0000644000175000017500000000246412137772502024004 0ustar shevekshevek/* Printable.h - Interface class that allows printing of complex types Copyright (c) 2011 Adrian McEwen. All right reserved. 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef Printable_h #define Printable_h #include class Print; /** The Printable class provides a way for new classes to allow themselves to be printed. By deriving from Printable and implementing the printTo method, it will then be possible for users to print out instances of this class by passing them into the usual Print::print and Print::println methods. */ class Printable { public: virtual size_t printTo(Print& p) const = 0; }; #endif arduino-mighty-1284p-0~svn20130430.orig/cores/standard/CDC.cpp0000644000175000017500000001057712137772502023014 0ustar shevekshevek /* Copyright (c) 2011, Peter Barrett ** ** Permission to use, copy, modify, and/or distribute this software for ** any purpose with or without fee is hereby granted, provided that the ** above copyright notice and this permission notice appear in all copies. ** ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL ** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR ** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES ** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, ** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS ** SOFTWARE. */ #include "Platform.h" #include "USBAPI.h" #include #if defined(USBCON) #ifdef CDC_ENABLED void Reboot() { USB.detach(); cli(); asm volatile("jmp 0x7800"); // jump to bootloader - DiskLoader takes up last 2 kB } typedef struct { u32 dwDTERate; u8 bCharFormat; u8 bParityType; u8 bDataBits; u8 lineState; } LineInfo; static volatile LineInfo _usbLineInfo = { 57600, 0x00, 0x00, 0x00, 0x00 }; #define WEAK __attribute__ ((weak)) extern const CDCDescriptor _cdcInterface PROGMEM; const CDCDescriptor _cdcInterface = { D_IAD(0,2,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,1), // CDC communication interface D_INTERFACE(CDC_ACM_INTERFACE,1,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,0), D_CDCCS(CDC_HEADER,0x10,0x01), // Header (1.10 bcd) D_CDCCS(CDC_CALL_MANAGEMENT,1,1), // Device handles call management (not) D_CDCCS4(CDC_ABSTRACT_CONTROL_MANAGEMENT,6), // SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported D_CDCCS(CDC_UNION,CDC_ACM_INTERFACE,CDC_DATA_INTERFACE), // Communication interface is master, data interface is slave 0 D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_ACM),USB_ENDPOINT_TYPE_INTERRUPT,0x10,0x40), // CDC data interface D_INTERFACE(CDC_DATA_INTERFACE,2,CDC_DATA_INTERFACE_CLASS,0,0), D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,0x40,0), D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,0x40,0) }; int WEAK CDC_GetInterface(u8* interfaceNum) { interfaceNum[0] += 2; // uses 2 return USB_SendControl(TRANSFER_PGM,&_cdcInterface,sizeof(_cdcInterface)); } bool WEAK CDC_Setup(Setup& setup) { u8 r = setup.bRequest; u8 requestType = setup.bmRequestType; if (REQUEST_DEVICETOHOST_CLASS_INTERFACE == requestType) { if (CDC_GET_LINE_CODING == r) { USB_SendControl(0,(void*)&_usbLineInfo,7); return true; } } if (REQUEST_HOSTTODEVICE_CLASS_INTERFACE == requestType) { if (CDC_SET_LINE_CODING == r) { USB_RecvControl((void*)&_usbLineInfo,7); return true; } if (CDC_SET_CONTROL_LINE_STATE == r) { if (0 != _usbLineInfo.lineState && 1200 == _usbLineInfo.dwDTERate) // auto-reset is triggered when the port, already open at 1200 bps, is closed Reboot(); _usbLineInfo.lineState = setup.wValueL; return true; } } return false; } int _serialPeek = -1; void Serial_::begin(uint16_t baud_count) { } void Serial_::end(void) { } int Serial_::available(void) { u8 avail = USB_Available(CDC_RX); if (_serialPeek != -1) avail++; return avail; } // peek is nasty int Serial_::peek(void) { if (_serialPeek == -1) _serialPeek = read(); return _serialPeek; } int Serial_::read(void) { int c; if (_serialPeek != -1) { c = _serialPeek; _serialPeek = -1; } else { c = USB_Recv(CDC_RX); } return c; } void Serial_::flush(void) { USB_Flush(CDC_TX); } size_t Serial_::write(uint8_t c) { /* only try to send bytes if the high-level CDC connection itself is open (not just the pipe) - the OS should set lineState when the port is opened and clear lineState when the port is closed. bytes sent before the user opens the connection or after the connection is closed are lost - just like with a UART. */ // TODO - ZE - check behavior on different OSes and test what happens if an // open connection isn't broken cleanly (cable is yanked out, host dies // or locks up, or host virtual serial port hangs) if (_usbLineInfo.lineState > 0) { int r = USB_Send(CDC_TX,&c,1); if (r > 0) { return r; } else { setWriteError(); return 0; } } setWriteError(); return 0; } Serial_ Serial; #endif #endif /* if defined(USBCON) */arduino-mighty-1284p-0~svn20130430.orig/cores/standard/wiring_private.h0000644000175000017500000000333012137772502025106 0ustar shevekshevek/* wiring_private.h - Internal header file. Part of Arduino - http://www.arduino.cc/ Copyright (c) 2005-2006 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 239 2007-01-12 17:58:39Z mellis $ */ #ifndef WiringPrivate_h #define WiringPrivate_h #include #include #include #include #include "Arduino.h" #ifdef __cplusplus extern "C"{ #endif #ifndef cbi #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) #endif #ifndef sbi #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) #endif #define EXTERNAL_INT_0 0 #define EXTERNAL_INT_1 1 #define EXTERNAL_INT_2 2 #define EXTERNAL_INT_3 3 #define EXTERNAL_INT_4 4 #define EXTERNAL_INT_5 5 #define EXTERNAL_INT_6 6 #define EXTERNAL_INT_7 7 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #define EXTERNAL_NUM_INTERRUPTS 8 #elif defined(__AVR_ATmega1284P__) #define EXTERNAL_NUM_INTERRUPTS 3 #else #define EXTERNAL_NUM_INTERRUPTS 2 #endif typedef void (*voidFuncPtr)(void); #ifdef __cplusplus } // extern "C" #endif #endif arduino-mighty-1284p-0~svn20130430.orig/cores/standard/HardwareSerial.h0000644000175000017500000000444612137772502024763 0ustar shevekshevek/* HardwareSerial.h - Hardware serial library for Wiring Copyright (c) 2006 Nicholas Zambetti. All right reserved. 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Modified 28 September 2010 by Mark Sproul */ #ifndef HardwareSerial_h #define HardwareSerial_h #include #include "Stream.h" struct ring_buffer; class HardwareSerial : public Stream { private: ring_buffer *_rx_buffer; ring_buffer *_tx_buffer; volatile uint8_t *_ubrrh; volatile uint8_t *_ubrrl; volatile uint8_t *_ucsra; volatile uint8_t *_ucsrb; volatile uint8_t *_udr; uint8_t _rxen; uint8_t _txen; uint8_t _rxcie; uint8_t _udrie; uint8_t _u2x; public: HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer, volatile uint8_t *ubrrh, volatile uint8_t *ubrrl, volatile uint8_t *ucsra, volatile uint8_t *ucsrb, volatile uint8_t *udr, uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x); void begin(unsigned long); void end(); virtual int available(void); virtual int peek(void); virtual int read(void); virtual void flush(void); virtual size_t write(uint8_t); using Print::write; // pull in write(str) and write(buf, size) from Print }; #if defined(UBRRH) || defined(UBRR0H) extern HardwareSerial Serial; #elif defined(USBCON) #include "USBAPI.h" // extern HardwareSerial Serial_; #endif #if defined(UBRR1H) extern HardwareSerial Serial1; #endif #if defined(UBRR2H) extern HardwareSerial Serial2; #endif #if defined(UBRR3H) extern HardwareSerial Serial3; #endif extern void serialEventRun(void) __attribute__((weak)); #endif arduino-mighty-1284p-0~svn20130430.orig/cores/standard/USBCore.cpp0000644000175000017500000003071212137772502023656 0ustar shevekshevek /* Copyright (c) 2010, Peter Barrett ** ** Permission to use, copy, modify, and/or distribute this software for ** any purpose with or without fee is hereby granted, provided that the ** above copyright notice and this permission notice appear in all copies. ** ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL ** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR ** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES ** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, ** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS ** SOFTWARE. */ #include "Platform.h" #include "USBAPI.h" #include "USBDesc.h" #if defined(USBCON) #define EP_TYPE_CONTROL 0x00 #define EP_TYPE_BULK_IN 0x81 #define EP_TYPE_BULK_OUT 0x80 #define EP_TYPE_INTERRUPT_IN 0xC1 #define EP_TYPE_INTERRUPT_OUT 0xC0 #define EP_TYPE_ISOCHRONOUS_IN 0x41 #define EP_TYPE_ISOCHRONOUS_OUT 0x40 /** Pulse generation counters to keep track of the number of milliseconds remaining for each pulse type */ #define TX_RX_LED_PULSE_MS 100 volatile u8 TxLEDPulse; /**< Milliseconds remaining for data Tx LED pulse */ volatile u8 RxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse */ //================================================================== //================================================================== extern const u16 STRING_LANGUAGE[] PROGMEM; extern const u16 STRING_IPRODUCT[] PROGMEM; extern const u16 STRING_IMANUFACTURER[] PROGMEM; extern const DeviceDescriptor USB_DeviceDescriptor PROGMEM; extern const DeviceDescriptor USB_DeviceDescriptorA PROGMEM; const u16 STRING_LANGUAGE[2] = { (3<<8) | (2+2), 0x0409 // English }; const u16 STRING_IPRODUCT[17] = { (3<<8) | (2+2*16), #if USB_PID == USB_PID_LEONARDO 'A','r','d','u','i','n','o',' ','L','e','o','n','a','r','d','o' #elif USB_PID == USB_PID_MICRO 'A','r','d','u','i','n','o',' ','M','i','c','r','o',' ',' ',' ' #endif }; const u16 STRING_IMANUFACTURER[12] = { (3<<8) | (2+2*11), 'A','r','d','u','i','n','o',' ','L','L','C' }; #ifdef CDC_ENABLED #define DEVICE_CLASS 0x02 #else #define DEVICE_CLASS 0x00 #endif // DEVICE DESCRIPTOR const DeviceDescriptor USB_DeviceDescriptor = D_DEVICE(0x00,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1); const DeviceDescriptor USB_DeviceDescriptorA = D_DEVICE(DEVICE_CLASS,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1); //================================================================== //================================================================== volatile u8 _usbConfiguration = 0; static inline void WaitIN(void) { while (!(UEINTX & (1< len) n = len; len -= n; { LockEP lock(ep); if (ep & TRANSFER_ZERO) { while (n--) Send8(0); } else if (ep & TRANSFER_PGM) { while (n--) Send8(pgm_read_byte(data++)); } else { while (n--) Send8(*data++); } if (!ReadWriteAllowed() || ((len == 0) && (ep & TRANSFER_RELEASE))) // Release full buffer ReleaseTX(); } } TXLED1; // light the TX LED TxLEDPulse = TX_RX_LED_PULSE_MS; return r; } extern const u8 _initEndpoints[] PROGMEM; const u8 _initEndpoints[] = { 0, #ifdef CDC_ENABLED EP_TYPE_INTERRUPT_IN, // CDC_ENDPOINT_ACM EP_TYPE_BULK_OUT, // CDC_ENDPOINT_OUT EP_TYPE_BULK_IN, // CDC_ENDPOINT_IN #endif #ifdef HID_ENABLED EP_TYPE_INTERRUPT_IN // HID_ENDPOINT_INT #endif }; #define EP_SINGLE_64 0x32 // EP0 #define EP_DOUBLE_64 0x36 // Other endpoints static void InitEP(u8 index, u8 type, u8 size) { UENUM = index; UECONX = 1; UECFG0X = type; UECFG1X = size; } static void InitEndpoints() { for (u8 i = 1; i < sizeof(_initEndpoints); i++) { UENUM = i; UECONX = 1; UECFG0X = pgm_read_byte(_initEndpoints+i); UECFG1X = EP_DOUBLE_64; } UERST = 0x7E; // And reset them UERST = 0; } // Handle CLASS_INTERFACE requests static bool ClassInterfaceRequest(Setup& setup) { u8 i = setup.wIndex; #ifdef CDC_ENABLED if (CDC_ACM_INTERFACE == i) return CDC_Setup(setup); #endif #ifdef HID_ENABLED if (HID_INTERFACE == i) return HID_Setup(setup); #endif return false; } int _cmark; int _cend; void InitControl(int end) { SetEP(0); _cmark = 0; _cend = end; } static bool SendControl(u8 d) { if (_cmark < _cend) { if (!WaitForINOrOUT()) return false; Send8(d); if (!((_cmark + 1) & 0x3F)) ClearIN(); // Fifo is full, release this packet } _cmark++; return true; }; // Clipped by _cmark/_cend int USB_SendControl(u8 flags, const void* d, int len) { int sent = len; const u8* data = (const u8*)d; bool pgm = flags & TRANSFER_PGM; while (len--) { u8 c = pgm ? pgm_read_byte(data++) : *data++; if (!SendControl(c)) return -1; } return sent; } // Does not timeout or cross fifo boundaries // Will only work for transfers <= 64 bytes // TODO int USB_RecvControl(void* d, int len) { WaitOUT(); Recv((u8*)d,len); ClearOUT(); return len; } int SendInterfaces() { int total = 0; u8 interfaces = 0; #ifdef CDC_ENABLED total = CDC_GetInterface(&interfaces); #endif #ifdef HID_ENABLED total += HID_GetInterface(&interfaces); #endif return interfaces; } // Construct a dynamic configuration descriptor // This really needs dynamic endpoint allocation etc // TODO static bool SendConfiguration(int maxlen) { // Count and measure interfaces InitControl(0); int interfaces = SendInterfaces(); ConfigDescriptor config = D_CONFIG(_cmark + sizeof(ConfigDescriptor),interfaces); // Now send them InitControl(maxlen); USB_SendControl(0,&config,sizeof(ConfigDescriptor)); SendInterfaces(); return true; } u8 _cdcComposite = 0; static bool SendDescriptor(Setup& setup) { u8 t = setup.wValueH; if (USB_CONFIGURATION_DESCRIPTOR_TYPE == t) return SendConfiguration(setup.wLength); InitControl(setup.wLength); #ifdef HID_ENABLED if (HID_REPORT_DESCRIPTOR_TYPE == t) return HID_GetDescriptor(t); #endif u8 desc_length = 0; const u8* desc_addr = 0; if (USB_DEVICE_DESCRIPTOR_TYPE == t) { if (setup.wLength == 8) _cdcComposite = 1; desc_addr = _cdcComposite ? (const u8*)&USB_DeviceDescriptorA : (const u8*)&USB_DeviceDescriptor; } else if (USB_STRING_DESCRIPTOR_TYPE == t) { if (setup.wValueL == 0) desc_addr = (const u8*)&STRING_LANGUAGE; else if (setup.wValueL == IPRODUCT) desc_addr = (const u8*)&STRING_IPRODUCT; else if (setup.wValueL == IMANUFACTURER) desc_addr = (const u8*)&STRING_IMANUFACTURER; else return false; } if (desc_addr == 0) return false; if (desc_length == 0) desc_length = pgm_read_byte(desc_addr); USB_SendControl(TRANSFER_PGM,desc_addr,desc_length); return true; } // Endpoint 0 interrupt ISR(USB_COM_vect) { SetEP(0); if (!ReceivedSetupInt()) return; Setup setup; Recv((u8*)&setup,8); ClearSetupInt(); u8 requestType = setup.bmRequestType; if (requestType & REQUEST_DEVICETOHOST) WaitIN(); else ClearIN(); bool ok = true; if (REQUEST_STANDARD == (requestType & REQUEST_TYPE)) { // Standard Requests u8 r = setup.bRequest; if (GET_STATUS == r) { Send8(0); // TODO Send8(0); } else if (CLEAR_FEATURE == r) { } else if (SET_FEATURE == r) { } else if (SET_ADDRESS == r) { WaitIN(); UDADDR = setup.wValueL | (1< #include #include #include #include #include "wiring_private.h" static volatile voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS]; // volatile static voidFuncPtr twiIntFunc; void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) { if(interruptNum < EXTERNAL_NUM_INTERRUPTS) { intFunc[interruptNum] = userFunc; // Configure the interrupt mode (trigger on low input, any change, rising // edge, or falling edge). The mode constants were chosen to correspond // to the configuration bits in the hardware register, so we simply shift // the mode into place. // Enable the interrupt. switch (interruptNum) { #if defined(EICRA) && defined(EICRB) && defined(EIMSK) case 2: EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00); EIMSK |= (1 << INT0); break; case 3: EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10); EIMSK |= (1 << INT1); break; case 4: EICRA = (EICRA & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20); EIMSK |= (1 << INT2); break; case 5: EICRA = (EICRA & ~((1 << ISC30) | (1 << ISC31))) | (mode << ISC30); EIMSK |= (1 << INT3); break; case 0: EICRB = (EICRB & ~((1 << ISC40) | (1 << ISC41))) | (mode << ISC40); EIMSK |= (1 << INT4); break; case 1: EICRB = (EICRB & ~((1 << ISC50) | (1 << ISC51))) | (mode << ISC50); EIMSK |= (1 << INT5); break; case 6: EICRB = (EICRB & ~((1 << ISC60) | (1 << ISC61))) | (mode << ISC60); EIMSK |= (1 << INT6); break; case 7: EICRB = (EICRB & ~((1 << ISC70) | (1 << ISC71))) | (mode << ISC70); EIMSK |= (1 << INT7); break; #else case 0: #if defined(EICRA) && defined(ISC00) && defined(EIMSK) EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00); EIMSK |= (1 << INT0); #elif defined(MCUCR) && defined(ISC00) && defined(GICR) MCUCR = (MCUCR & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00); GICR |= (1 << INT0); #elif defined(MCUCR) && defined(ISC00) && defined(GIMSK) MCUCR = (MCUCR & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00); GIMSK |= (1 << INT0); #else #error attachInterrupt not finished for this CPU (case 0) #endif break; case 1: #if defined(EICRA) && defined(ISC10) && defined(ISC11) && defined(EIMSK) EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10); EIMSK |= (1 << INT1); #elif defined(MCUCR) && defined(ISC10) && defined(ISC11) && defined(GICR) MCUCR = (MCUCR & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10); GICR |= (1 << INT1); #elif defined(MCUCR) && defined(ISC10) && defined(GIMSK) && defined(GIMSK) MCUCR = (MCUCR & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10); GIMSK |= (1 << INT1); #else #warning attachInterrupt may need some more work for this cpu (case 1) #endif break; case 2: #if defined(EICRA) && defined(ISC20) && defined(ISC21) && defined(EIMSK) EICRA = (EICRA & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20); EIMSK |= (1 << INT2); #elif defined(MCUCR) && defined(ISC20) && defined(ISC21) && defined(GICR) MCUCR = (MCUCR & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20); GICR |= (1 << INT2); #elif defined(MCUCR) && defined(ISC20) && defined(GIMSK) && defined(GIMSK) MCUCR = (MCUCR & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20); GIMSK |= (1 << INT2); #endif break; #endif } } } void detachInterrupt(uint8_t interruptNum) { if(interruptNum < EXTERNAL_NUM_INTERRUPTS) { // Disable the interrupt. (We can't assume that interruptNum is equal // to the number of the EIMSK bit to clear, as this isn't true on the // ATmega8. There, INT0 is 6 and INT1 is 7.) switch (interruptNum) { #if defined(EICRA) && defined(EICRB) && defined(EIMSK) case 2: EIMSK &= ~(1 << INT0); break; case 3: EIMSK &= ~(1 << INT1); break; case 4: EIMSK &= ~(1 << INT2); break; case 5: EIMSK &= ~(1 << INT3); break; case 0: EIMSK &= ~(1 << INT4); break; case 1: EIMSK &= ~(1 << INT5); break; case 6: EIMSK &= ~(1 << INT6); break; case 7: EIMSK &= ~(1 << INT7); break; #else case 0: #if defined(EIMSK) && defined(INT0) EIMSK &= ~(1 << INT0); #elif defined(GICR) && defined(ISC00) GICR &= ~(1 << INT0); // atmega32 #elif defined(GIMSK) && defined(INT0) GIMSK &= ~(1 << INT0); #else #error detachInterrupt not finished for this cpu #endif break; case 1: #if defined(EIMSK) && defined(INT1) EIMSK &= ~(1 << INT1); #elif defined(GICR) && defined(INT1) GICR &= ~(1 << INT1); // atmega32 #elif defined(GIMSK) && defined(INT1) GIMSK &= ~(1 << INT1); #else #warning detachInterrupt may need some more work for this cpu (case 1) #endif break; #endif } intFunc[interruptNum] = 0; } } /* void attachInterruptTwi(void (*userFunc)(void) ) { twiIntFunc = userFunc; } */ #if defined(EICRA) && defined(EICRB) SIGNAL(INT0_vect) { if(intFunc[EXTERNAL_INT_2]) intFunc[EXTERNAL_INT_2](); } SIGNAL(INT1_vect) { if(intFunc[EXTERNAL_INT_3]) intFunc[EXTERNAL_INT_3](); } SIGNAL(INT2_vect) { if(intFunc[EXTERNAL_INT_4]) intFunc[EXTERNAL_INT_4](); } SIGNAL(INT3_vect) { if(intFunc[EXTERNAL_INT_5]) intFunc[EXTERNAL_INT_5](); } SIGNAL(INT4_vect) { if(intFunc[EXTERNAL_INT_0]) intFunc[EXTERNAL_INT_0](); } SIGNAL(INT5_vect) { if(intFunc[EXTERNAL_INT_1]) intFunc[EXTERNAL_INT_1](); } SIGNAL(INT6_vect) { if(intFunc[EXTERNAL_INT_6]) intFunc[EXTERNAL_INT_6](); } SIGNAL(INT7_vect) { if(intFunc[EXTERNAL_INT_7]) intFunc[EXTERNAL_INT_7](); } #else SIGNAL(INT0_vect) { if(intFunc[EXTERNAL_INT_0]) intFunc[EXTERNAL_INT_0](); } SIGNAL(INT1_vect) { if(intFunc[EXTERNAL_INT_1]) intFunc[EXTERNAL_INT_1](); } #if defined(EICRA) && defined(ISC20) SIGNAL(INT2_vect) { if(intFunc[EXTERNAL_INT_2]) intFunc[EXTERNAL_INT_2](); } #endif #endif /* SIGNAL(SIG_2WIRE_SERIAL) { if(twiIntFunc) twiIntFunc(); } */ arduino-mighty-1284p-0~svn20130430.orig/cores/standard/Udp.h0000644000175000017500000001012412137772502022604 0ustar shevekshevek/* * Udp.cpp: Library to send/receive UDP packets. * * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) * 1) UDP does not guarantee the order in which assembled UDP packets are received. This * might not happen often in practice, but in larger network topologies, a UDP * packet can be received out of sequence. * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being * aware of it. Again, this may not be a concern in practice on small local networks. * For more information, see http://www.cafeaulait.org/course/week12/35.html * * MIT License: * Copyright (c) 2008 Bjoern Hartmann * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * bjoern@cs.stanford.edu 12/30/2008 */ #ifndef udp_h #define udp_h #include #include class UDP : public Stream { public: virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use virtual void stop() =0; // Finish with the UDP socket // Sending UDP packets // Start building up a packet to send to the remote host specific in ip and port // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port virtual int beginPacket(IPAddress ip, uint16_t port) =0; // Start building up a packet to send to the remote host specific in host and port // Returns 1 if successful, 0 if there was a problem resolving the hostname or port virtual int beginPacket(const char *host, uint16_t port) =0; // Finish off this packet and send it // Returns 1 if the packet was sent successfully, 0 if there was an error virtual int endPacket() =0; // Write a single byte into the packet virtual size_t write(uint8_t) =0; // Write size bytes from buffer into the packet virtual size_t write(const uint8_t *buffer, size_t size) =0; // Start processing the next available incoming packet // Returns the size of the packet in bytes, or 0 if no packets are available virtual int parsePacket() =0; // Number of bytes remaining in the current packet virtual int available() =0; // Read a single byte from the current packet virtual int read() =0; // Read up to len bytes from the current packet and place them into buffer // Returns the number of bytes read, or 0 if none are available virtual int read(unsigned char* buffer, size_t len) =0; // Read up to len characters from the current packet and place them into buffer // Returns the number of characters read, or 0 if none are available virtual int read(char* buffer, size_t len) =0; // Return the next byte from the current packet without moving on to the next byte virtual int peek() =0; virtual void flush() =0; // Finish reading the current packet // Return the IP address of the host who sent the current incoming packet virtual IPAddress remoteIP() =0; // Return the port of the host who sent the current incoming packet virtual uint16_t remotePort() =0; protected: uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; }; #endif arduino-mighty-1284p-0~svn20130430.orig/cores/standard/IPAddress.h0000644000175000017500000000564212137772502023703 0ustar shevekshevek/* * * MIT License: * Copyright (c) 2011 Adrian McEwen * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * adrianm@mcqn.com 1/1/2011 */ #ifndef IPAddress_h #define IPAddress_h #include // A class to make it easier to handle and pass around IP addresses class IPAddress : public Printable { private: uint8_t _address[4]; // IPv4 address // Access the raw byte array containing the address. Because this returns a pointer // to the internal structure rather than a copy of the address this function should only // be used when you know that the usage of the returned uint8_t* will be transient and not // stored. uint8_t* raw_address() { return _address; }; public: // Constructors IPAddress(); IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet); IPAddress(uint32_t address); IPAddress(const uint8_t *address); // Overloaded cast operator to allow IPAddress objects to be used where a pointer // to a four-byte uint8_t array is expected operator uint32_t() { return *((uint32_t*)_address); }; bool operator==(const IPAddress& addr) { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); }; bool operator==(const uint8_t* addr); // Overloaded index operator to allow getting and setting individual octets of the address uint8_t operator[](int index) const { return _address[index]; }; uint8_t& operator[](int index) { return _address[index]; }; // Overloaded copy operators to allow initialisation of IPAddress objects from other types IPAddress& operator=(const uint8_t *address); IPAddress& operator=(uint32_t address); virtual size_t printTo(Print& p) const; friend class EthernetClass; friend class UDP; friend class Client; friend class Server; friend class DhcpClass; friend class DNSClient; }; const IPAddress INADDR_NONE(0,0,0,0); #endif arduino-mighty-1284p-0~svn20130430.orig/cores/standard/wiring_pulse.c0000644000175000017500000000512312137772502024561 0ustar shevekshevek/* wiring_pulse.c - pulseIn() function Part of Arduino - http://www.arduino.cc/ Copyright (c) 2005-2006 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.c 248 2007-02-03 15:36:30Z mellis $ */ #include "wiring_private.h" #include "pins_arduino.h" /* Measures the length (in microseconds) of a pulse on the pin; state is HIGH * or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds * to 3 minutes in length, but must be called at least a few dozen microseconds * before the start of the pulse. */ unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout) { // cache the port and bit of the pin in order to speed up the // pulse width measuring loop and achieve finer resolution. calling // digitalRead() instead yields much coarser resolution. uint8_t bit = digitalPinToBitMask(pin); uint8_t port = digitalPinToPort(pin); uint8_t stateMask = (state ? bit : 0); unsigned long width = 0; // keep initialization out of time critical area // convert the timeout from microseconds to a number of times through // the initial loop; it takes 16 clock cycles per iteration. unsigned long numloops = 0; unsigned long maxloops = microsecondsToClockCycles(timeout) / 16; // wait for any previous pulse to end while ((*portInputRegister(port) & bit) == stateMask) if (numloops++ == maxloops) return 0; // wait for the pulse to start while ((*portInputRegister(port) & bit) != stateMask) if (numloops++ == maxloops) return 0; // wait for the pulse to stop while ((*portInputRegister(port) & bit) == stateMask) { if (numloops++ == maxloops) return 0; width++; } // convert the reading to microseconds. The loop has been determined // to be 20 clock cycles long and have about 16 clocks between the edge // and the start of the loop. There will be some error introduced by // the interrupt handlers. return clockCyclesToMicroseconds(width * 21 + 16); } arduino-mighty-1284p-0~svn20130430.orig/cores/standard/WCharacter.h0000644000175000017500000001074012137772502024103 0ustar shevekshevek/* WCharacter.h - Character utility functions for Wiring & Arduino Copyright (c) 2010 Hernando Barragan. All right reserved. 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef Character_h #define Character_h #include // WCharacter.h prototypes inline boolean isAlphaNumeric(int c) __attribute__((always_inline)); inline boolean isAlpha(int c) __attribute__((always_inline)); inline boolean isAscii(int c) __attribute__((always_inline)); inline boolean isWhitespace(int c) __attribute__((always_inline)); inline boolean isControl(int c) __attribute__((always_inline)); inline boolean isDigit(int c) __attribute__((always_inline)); inline boolean isGraph(int c) __attribute__((always_inline)); inline boolean isLowerCase(int c) __attribute__((always_inline)); inline boolean isPrintable(int c) __attribute__((always_inline)); inline boolean isPunct(int c) __attribute__((always_inline)); inline boolean isSpace(int c) __attribute__((always_inline)); inline boolean isUpperCase(int c) __attribute__((always_inline)); inline boolean isHexadecimalDigit(int c) __attribute__((always_inline)); inline int toAscii(int c) __attribute__((always_inline)); inline int toLowerCase(int c) __attribute__((always_inline)); inline int toUpperCase(int c)__attribute__((always_inline)); // Checks for an alphanumeric character. // It is equivalent to (isalpha(c) || isdigit(c)). inline boolean isAlphaNumeric(int c) { return ( isalnum(c) == 0 ? false : true); } // Checks for an alphabetic character. // It is equivalent to (isupper(c) || islower(c)). inline boolean isAlpha(int c) { return ( isalpha(c) == 0 ? false : true); } // Checks whether c is a 7-bit unsigned char value // that fits into the ASCII character set. inline boolean isAscii(int c) { return ( isascii (c) == 0 ? false : true); } // Checks for a blank character, that is, a space or a tab. inline boolean isWhitespace(int c) { return ( isblank (c) == 0 ? false : true); } // Checks for a control character. inline boolean isControl(int c) { return ( iscntrl (c) == 0 ? false : true); } // Checks for a digit (0 through 9). inline boolean isDigit(int c) { return ( isdigit (c) == 0 ? false : true); } // Checks for any printable character except space. inline boolean isGraph(int c) { return ( isgraph (c) == 0 ? false : true); } // Checks for a lower-case character. inline boolean isLowerCase(int c) { return (islower (c) == 0 ? false : true); } // Checks for any printable character including space. inline boolean isPrintable(int c) { return ( isprint (c) == 0 ? false : true); } // Checks for any printable character which is not a space // or an alphanumeric character. inline boolean isPunct(int c) { return ( ispunct (c) == 0 ? false : true); } // Checks for white-space characters. For the avr-libc library, // these are: space, formfeed ('\f'), newline ('\n'), carriage // return ('\r'), horizontal tab ('\t'), and vertical tab ('\v'). inline boolean isSpace(int c) { return ( isspace (c) == 0 ? false : true); } // Checks for an uppercase letter. inline boolean isUpperCase(int c) { return ( isupper (c) == 0 ? false : true); } // Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7 // 8 9 a b c d e f A B C D E F. inline boolean isHexadecimalDigit(int c) { return ( isxdigit (c) == 0 ? false : true); } // Converts c to a 7-bit unsigned char value that fits into the // ASCII character set, by clearing the high-order bits. inline int toAscii(int c) { return toascii (c); } // Warning: // Many people will be unhappy if you use this function. // This function will convert accented letters into random // characters. // Converts the letter c to lower case, if possible. inline int toLowerCase(int c) { return tolower (c); } // Converts the letter c to upper case, if possible. inline int toUpperCase(int c) { return toupper (c); } #endifarduino-mighty-1284p-0~svn20130430.orig/cores/standard/Print.h0000644000175000017500000000463612137772502023163 0ustar shevekshevek/* Print.h - Base class that provides print() and println() Copyright (c) 2008 David A. Mellis. All right reserved. 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef Print_h #define Print_h #include #include // for size_t #include "WString.h" #include "Printable.h" #define DEC 10 #define HEX 16 #define OCT 8 #define BIN 2 class Print { private: int write_error; size_t printNumber(unsigned long, uint8_t); size_t printFloat(double, uint8_t); protected: void setWriteError(int err = 1) { write_error = err; } public: Print() : write_error(0) {} int getWriteError() { return write_error; } void clearWriteError() { setWriteError(0); } virtual size_t write(uint8_t) = 0; size_t write(const char *str) { return write((const uint8_t *)str, strlen(str)); } virtual size_t write(const uint8_t *buffer, size_t size); size_t print(const __FlashStringHelper *); size_t print(const String &); size_t print(const char[]); size_t print(char); size_t print(unsigned char, int = DEC); size_t print(int, int = DEC); size_t print(unsigned int, int = DEC); size_t print(long, int = DEC); size_t print(unsigned long, int = DEC); size_t print(double, int = 2); size_t print(const Printable&); size_t println(const __FlashStringHelper *); size_t println(const String &s); size_t println(const char[]); size_t println(char); size_t println(unsigned char, int = DEC); size_t println(int, int = DEC); size_t println(unsigned int, int = DEC); size_t println(long, int = DEC); size_t println(unsigned long, int = DEC); size_t println(double, int = 2); size_t println(const Printable&); size_t println(void); }; #endif arduino-mighty-1284p-0~svn20130430.orig/cores/standard/wiring_shift.c0000644000175000017500000000310112137772502024540 0ustar shevekshevek/* wiring_shift.c - shiftOut() function Part of Arduino - http://www.arduino.cc/ Copyright (c) 2005-2006 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.c 248 2007-02-03 15:36:30Z mellis $ */ #include "wiring_private.h" uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) { uint8_t value = 0; uint8_t i; for (i = 0; i < 8; ++i) { digitalWrite(clockPin, HIGH); if (bitOrder == LSBFIRST) value |= digitalRead(dataPin) << i; else value |= digitalRead(dataPin) << (7 - i); digitalWrite(clockPin, LOW); } return value; } void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val) { uint8_t i; for (i = 0; i < 8; i++) { if (bitOrder == LSBFIRST) digitalWrite(dataPin, !!(val & (1 << i))); else digitalWrite(dataPin, !!(val & (1 << (7 - i)))); digitalWrite(clockPin, HIGH); digitalWrite(clockPin, LOW); } } arduino-mighty-1284p-0~svn20130430.orig/cores/standard/wiring_analog.c0000644000175000017500000001552312137772502024677 0ustar shevekshevek/* wiring_analog.c - analog input and output Part of Arduino - http://www.arduino.cc/ Copyright (c) 2005-2006 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 Modified 28 September 2010 by Mark Sproul $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ */ #include "wiring_private.h" #include "pins_arduino.h" uint8_t analog_reference = DEFAULT; void analogReference(uint8_t mode) { // can't actually set the register here because the default setting // will connect AVCC and the AREF pin, which would cause a short if // there's something connected to AREF. analog_reference = mode; } int analogRead(uint8_t pin) { uint8_t low, high; // allow for channel or pin numbers #if defined(digitalPinToAnalogPin) if (digitalPinToAnalogPin(pin) != -1 ) pin = digitalPinToAnalogPin(pin); #else if (pin >= A0) pin -= A0; #endif #if defined(analogPinToChannel) uint8_t channel = analogPinToChannel(pin); #else uint8_t channel = pin; #endif #if defined(ADCSRB) && defined(MUX5) // the MUX5 bit of ADCSRB selects whether we're reading from channels // 0 to 7 (MUX5 low) or 8 to 15 (MUX5 high). ADCSRB = (ADCSRB & ~(1 << MUX5)) | (((channel >> 3) & 0x01) << MUX5); #endif // set the analog reference (high two bits of ADMUX) and select the // channel (low 4 bits). this also sets ADLAR (left-adjust result) // to 0 (the default). #if defined(ADMUX) ADMUX = (analog_reference << 6) | (channel & 0x07); #endif // without a delay, we seem to read from the wrong channel //delay(1); #if defined(ADCSRA) && defined(ADCL) // start the conversion sbi(ADCSRA, ADSC); // ADSC is cleared when the conversion finishes while (bit_is_set(ADCSRA, ADSC)); // we have to read ADCL first; doing so locks both ADCL // and ADCH until ADCH is read. reading ADCL second would // cause the results of each conversion to be discarded, // as ADCL and ADCH would be locked when it completed. low = ADCL; high = ADCH; #else // we dont have an ADC, return 0 low = 0; high = 0; #endif // combine the two bytes return (high << 8) | low; } // Right now, PWM output only works on the pins with // hardware support. These are defined in the appropriate // pins_*.c file. For the rest of the pins, we default // to digital output. void analogWrite(uint8_t pin, int val) { // We need to make sure the PWM output is enabled for those pins // that support it, as we turn it off when digitally reading or // writing with them. Also, make sure the pin is in output mode // for consistenty with Wiring, which doesn't require a pinMode // call for the analog output pins. pinMode(pin, OUTPUT); if (val == 0) { digitalWrite(pin, LOW); } else if (val == 255) { digitalWrite(pin, HIGH); } else { switch(digitalPinToTimer(pin)) { // XXX fix needed for atmega8 #if defined(TCCR0) && defined(COM00) && !defined(__AVR_ATmega8__) case TIMER0A: // connect pwm to pin on timer 0 sbi(TCCR0, COM00); OCR0 = val; // set pwm duty break; #endif #if defined(TCCR0A) && defined(COM0A1) case TIMER0A: // connect pwm to pin on timer 0, channel A sbi(TCCR0A, COM0A1); OCR0A = val; // set pwm duty break; #endif #if defined(TCCR0A) && defined(COM0B1) case TIMER0B: // connect pwm to pin on timer 0, channel B sbi(TCCR0A, COM0B1); OCR0B = val; // set pwm duty break; #endif #if defined(TCCR1A) && defined(COM1A1) case TIMER1A: // connect pwm to pin on timer 1, channel A sbi(TCCR1A, COM1A1); OCR1A = val; // set pwm duty break; #endif #if defined(TCCR1A) && defined(COM1B1) case TIMER1B: // connect pwm to pin on timer 1, channel B sbi(TCCR1A, COM1B1); OCR1B = val; // set pwm duty break; #endif #if defined(TCCR2) && defined(COM21) case TIMER2: // connect pwm to pin on timer 2 sbi(TCCR2, COM21); OCR2 = val; // set pwm duty break; #endif #if defined(TCCR2A) && defined(COM2A1) case TIMER2A: // connect pwm to pin on timer 2, channel A sbi(TCCR2A, COM2A1); OCR2A = val; // set pwm duty break; #endif #if defined(TCCR2A) && defined(COM2B1) case TIMER2B: // connect pwm to pin on timer 2, channel B sbi(TCCR2A, COM2B1); OCR2B = val; // set pwm duty break; #endif #if defined(TCCR3A) && defined(COM3A1) case TIMER3A: // connect pwm to pin on timer 3, channel A sbi(TCCR3A, COM3A1); OCR3A = val; // set pwm duty break; #endif #if defined(TCCR3A) && defined(COM3B1) case TIMER3B: // connect pwm to pin on timer 3, channel B sbi(TCCR3A, COM3B1); OCR3B = val; // set pwm duty break; #endif #if defined(TCCR3A) && defined(COM3C1) case TIMER3C: // connect pwm to pin on timer 3, channel C sbi(TCCR3A, COM3C1); OCR3C = val; // set pwm duty break; #endif #if defined(TCCR4A) && defined(COM4A1) case TIMER4A: // connect pwm to pin on timer 4, channel A sbi(TCCR4A, COM4A1); OCR4A = val; // set pwm duty break; #endif #if defined(TCCR4A) && defined(COM4B1) case TIMER4B: // connect pwm to pin on timer 4, channel B sbi(TCCR4A, COM4B1); OCR4B = val; // set pwm duty break; #endif #if defined(TCCR4A) && defined(COM4C1) case TIMER4C: // connect pwm to pin on timer 4, channel C sbi(TCCR4A, COM4C1); OCR4C = val; // set pwm duty break; #endif #if defined(TCCR4A) && defined(COM4D1) case TIMER4D: // connect pwm to pin on timer 4, channel D sbi(TCCR4A, COM4D1); OCR4D = val; // set pwm duty break; #endif #if defined(TCCR5A) && defined(COM5A1) case TIMER5A: // connect pwm to pin on timer 5, channel A sbi(TCCR5A, COM5A1); OCR5A = val; // set pwm duty break; #endif #if defined(TCCR5A) && defined(COM5B1) case TIMER5B: // connect pwm to pin on timer 5, channel B sbi(TCCR5A, COM5B1); OCR5B = val; // set pwm duty break; #endif #if defined(TCCR5A) && defined(COM5C1) case TIMER5C: // connect pwm to pin on timer 5, channel C sbi(TCCR5A, COM5C1); OCR5C = val; // set pwm duty break; #endif case NOT_ON_TIMER: default: if (val < 128) { digitalWrite(pin, LOW); } else { digitalWrite(pin, HIGH); } } } } arduino-mighty-1284p-0~svn20130430.orig/cores/standard/Arduino.h0000644000175000017500000001274512137772502023470 0ustar shevekshevek#ifndef Arduino_h #define Arduino_h #include #include #include #include #include #include #include "binary.h" #ifdef __cplusplus extern "C"{ #endif #define HIGH 0x1 #define LOW 0x0 #define INPUT 0x0 #define OUTPUT 0x1 #define true 0x1 #define false 0x0 #define PI 3.1415926535897932384626433832795 #define HALF_PI 1.5707963267948966192313216916398 #define TWO_PI 6.283185307179586476925286766559 #define DEG_TO_RAD 0.017453292519943295769236907684886 #define RAD_TO_DEG 57.295779513082320876798154814105 #define SERIAL 0x0 #define DISPLAY 0x1 #define LSBFIRST 0 #define MSBFIRST 1 #define CHANGE 1 #define FALLING 2 #define RISING 3 #if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) #define DEFAULT 0 #define EXTERNAL 1 #define INTERNAL 2 #else #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284P__) #define INTERNAL1V1 2 #define INTERNAL2V56 3 #else #define INTERNAL 3 #endif #define DEFAULT 1 #define EXTERNAL 0 #endif // undefine stdlib's abs if encountered #ifdef abs #undef abs #endif #define min(a,b) ((a)<(b)?(a):(b)) #define max(a,b) ((a)>(b)?(a):(b)) #define abs(x) ((x)>0?(x):-(x)) #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) #define radians(deg) ((deg)*DEG_TO_RAD) #define degrees(rad) ((rad)*RAD_TO_DEG) #define sq(x) ((x)*(x)) #define interrupts() sei() #define noInterrupts() cli() #define clockCyclesPerMicrosecond() ( F_CPU / 1000000L ) #define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (F_CPU / 1000L) ) #define microsecondsToClockCycles(a) ( ((a) * (F_CPU / 1000L)) / 1000L ) #define lowByte(w) ((uint8_t) ((w) & 0xff)) #define highByte(w) ((uint8_t) ((w) >> 8)) #define bitRead(value, bit) (((value) >> (bit)) & 0x01) #define bitSet(value, bit) ((value) |= (1UL << (bit))) #define bitClear(value, bit) ((value) &= ~(1UL << (bit))) #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) typedef unsigned int word; #define bit(b) (1UL << (b)) typedef uint8_t boolean; typedef uint8_t byte; void init(void); void pinMode(uint8_t, uint8_t); void digitalWrite(uint8_t, uint8_t); int digitalRead(uint8_t); int analogRead(uint8_t); void analogReference(uint8_t mode); void analogWrite(uint8_t, int); unsigned long millis(void); unsigned long micros(void); void delay(unsigned long); void delayMicroseconds(unsigned int us); unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout); void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); void attachInterrupt(uint8_t, void (*)(void), int mode); void detachInterrupt(uint8_t); void setup(void); void loop(void); // 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. #define analogInPinToBit(P) (P) // On the ATmega1280, the addresses of some of the port registers are // greater than 255, so we can't store them in uint8_t's. extern const uint16_t port_to_mode_PGM[]; extern const uint16_t port_to_input_PGM[]; extern const uint16_t port_to_output_PGM[]; extern const uint8_t digital_pin_to_port_PGM[]; // extern const uint8_t digital_pin_to_bit_PGM[]; extern const uint8_t digital_pin_to_bit_mask_PGM[]; extern const uint8_t 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) #define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) ) #define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) ) #define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) ) #define NOT_A_PIN 0 #define NOT_A_PORT 0 #ifdef ARDUINO_MAIN #define PA 1 #define PB 2 #define PC 3 #define PD 4 #define PE 5 #define PF 6 #define PG 7 #define PH 8 #define PJ 10 #define PK 11 #define PL 12 #endif #define NOT_ON_TIMER 0 #define TIMER0A 1 #define TIMER0B 2 #define TIMER1A 3 #define TIMER1B 4 #define TIMER2 5 #define TIMER2A 6 #define TIMER2B 7 #define TIMER3A 8 #define TIMER3B 9 #define TIMER3C 10 #define TIMER4A 11 #define TIMER4B 12 #define TIMER4C 13 #define TIMER4D 14 #define TIMER5A 15 #define TIMER5B 16 #define TIMER5C 17 #ifdef __cplusplus } // extern "C" #endif #ifdef __cplusplus #include "WCharacter.h" #include "WString.h" #include "HardwareSerial.h" uint16_t makeWord(uint16_t w); uint16_t makeWord(byte h, byte l); #define word(...) makeWord(__VA_ARGS__) unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0); void noTone(uint8_t _pin); // WMath prototypes long random(long); long random(long, long); void randomSeed(unsigned int); long map(long, long, long, long, long); #endif #include "pins_arduino.h" #endif arduino-mighty-1284p-0~svn20130430.orig/cores/standard/WString.cpp0000644000175000017500000003360412137772502024014 0ustar shevekshevek/* WString.cpp - String library for Wiring & Arduino ...mostly rewritten by Paul Stoffregen... Copyright (c) 2009-10 Hernando Barragan. All rights reserved. Copyright 2011, Paul Stoffregen, paul@pjrc.com 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "WString.h" /*********************************************/ /* Constructors */ /*********************************************/ String::String(const char *cstr) { init(); if (cstr) copy(cstr, strlen(cstr)); } String::String(const String &value) { init(); *this = value; } #ifdef __GXX_EXPERIMENTAL_CXX0X__ String::String(String &&rval) { init(); move(rval); } String::String(StringSumHelper &&rval) { init(); move(rval); } #endif String::String(char c) { init(); char buf[2]; buf[0] = c; buf[1] = 0; *this = buf; } String::String(unsigned char value, unsigned char base) { init(); char buf[9]; utoa(value, buf, base); *this = buf; } String::String(int value, unsigned char base) { init(); char buf[18]; itoa(value, buf, base); *this = buf; } String::String(unsigned int value, unsigned char base) { init(); char buf[17]; utoa(value, buf, base); *this = buf; } String::String(long value, unsigned char base) { init(); char buf[34]; ltoa(value, buf, base); *this = buf; } String::String(unsigned long value, unsigned char base) { init(); char buf[33]; ultoa(value, buf, base); *this = buf; } String::~String() { free(buffer); } /*********************************************/ /* Memory Management */ /*********************************************/ inline void String::init(void) { buffer = NULL; capacity = 0; len = 0; flags = 0; } void String::invalidate(void) { if (buffer) free(buffer); buffer = NULL; capacity = len = 0; } unsigned char String::reserve(unsigned int size) { if (buffer && capacity >= size) return 1; if (changeBuffer(size)) { if (len == 0) buffer[0] = 0; return 1; } return 0; } unsigned char String::changeBuffer(unsigned int maxStrLen) { char *newbuffer = (char *)realloc(buffer, maxStrLen + 1); if (newbuffer) { buffer = newbuffer; capacity = maxStrLen; return 1; } return 0; } /*********************************************/ /* Copy and Move */ /*********************************************/ String & String::copy(const char *cstr, unsigned int length) { if (!reserve(length)) { invalidate(); return *this; } len = length; strcpy(buffer, cstr); return *this; } #ifdef __GXX_EXPERIMENTAL_CXX0X__ void String::move(String &rhs) { if (buffer) { if (capacity >= rhs.len) { strcpy(buffer, rhs.buffer); len = rhs.len; rhs.len = 0; return; } else { free(buffer); } } buffer = rhs.buffer; capacity = rhs.capacity; len = rhs.len; rhs.buffer = NULL; rhs.capacity = 0; rhs.len = 0; } #endif String & String::operator = (const String &rhs) { if (this == &rhs) return *this; if (rhs.buffer) copy(rhs.buffer, rhs.len); else invalidate(); return *this; } #ifdef __GXX_EXPERIMENTAL_CXX0X__ String & String::operator = (String &&rval) { if (this != &rval) move(rval); return *this; } String & String::operator = (StringSumHelper &&rval) { if (this != &rval) move(rval); return *this; } #endif String & String::operator = (const char *cstr) { if (cstr) copy(cstr, strlen(cstr)); else invalidate(); return *this; } /*********************************************/ /* concat */ /*********************************************/ unsigned char String::concat(const String &s) { return concat(s.buffer, s.len); } unsigned char String::concat(const char *cstr, unsigned int length) { unsigned int newlen = len + length; if (!cstr) return 0; if (length == 0) return 1; if (!reserve(newlen)) return 0; strcpy(buffer + len, cstr); len = newlen; return 1; } unsigned char String::concat(const char *cstr) { if (!cstr) return 0; return concat(cstr, strlen(cstr)); } unsigned char String::concat(char c) { char buf[2]; buf[0] = c; buf[1] = 0; return concat(buf, 1); } unsigned char String::concat(unsigned char num) { char buf[4]; itoa(num, buf, 10); return concat(buf, strlen(buf)); } unsigned char String::concat(int num) { char buf[7]; itoa(num, buf, 10); return concat(buf, strlen(buf)); } unsigned char String::concat(unsigned int num) { char buf[6]; utoa(num, buf, 10); return concat(buf, strlen(buf)); } unsigned char String::concat(long num) { char buf[12]; ltoa(num, buf, 10); return concat(buf, strlen(buf)); } unsigned char String::concat(unsigned long num) { char buf[11]; ultoa(num, buf, 10); return concat(buf, strlen(buf)); } /*********************************************/ /* Concatenate */ /*********************************************/ StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs) { StringSumHelper &a = const_cast(lhs); if (!a.concat(rhs.buffer, rhs.len)) a.invalidate(); return a; } StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr) { StringSumHelper &a = const_cast(lhs); if (!cstr || !a.concat(cstr, strlen(cstr))) a.invalidate(); return a; } StringSumHelper & operator + (const StringSumHelper &lhs, char c) { StringSumHelper &a = const_cast(lhs); if (!a.concat(c)) a.invalidate(); return a; } StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num) { StringSumHelper &a = const_cast(lhs); if (!a.concat(num)) a.invalidate(); return a; } StringSumHelper & operator + (const StringSumHelper &lhs, int num) { StringSumHelper &a = const_cast(lhs); if (!a.concat(num)) a.invalidate(); return a; } StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num) { StringSumHelper &a = const_cast(lhs); if (!a.concat(num)) a.invalidate(); return a; } StringSumHelper & operator + (const StringSumHelper &lhs, long num) { StringSumHelper &a = const_cast(lhs); if (!a.concat(num)) a.invalidate(); return a; } StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num) { StringSumHelper &a = const_cast(lhs); if (!a.concat(num)) a.invalidate(); return a; } /*********************************************/ /* Comparison */ /*********************************************/ int String::compareTo(const String &s) const { if (!buffer || !s.buffer) { if (s.buffer && s.len > 0) return 0 - *(unsigned char *)s.buffer; if (buffer && len > 0) return *(unsigned char *)buffer; return 0; } return strcmp(buffer, s.buffer); } unsigned char String::equals(const String &s2) const { return (len == s2.len && compareTo(s2) == 0); } unsigned char String::equals(const char *cstr) const { if (len == 0) return (cstr == NULL || *cstr == 0); if (cstr == NULL) return buffer[0] == 0; return strcmp(buffer, cstr) == 0; } unsigned char String::operator<(const String &rhs) const { return compareTo(rhs) < 0; } unsigned char String::operator>(const String &rhs) const { return compareTo(rhs) > 0; } unsigned char String::operator<=(const String &rhs) const { return compareTo(rhs) <= 0; } unsigned char String::operator>=(const String &rhs) const { return compareTo(rhs) >= 0; } unsigned char String::equalsIgnoreCase( const String &s2 ) const { if (this == &s2) return 1; if (len != s2.len) return 0; if (len == 0) return 1; const char *p1 = buffer; const char *p2 = s2.buffer; while (*p1) { if (tolower(*p1++) != tolower(*p2++)) return 0; } return 1; } unsigned char String::startsWith( const String &s2 ) const { if (len < s2.len) return 0; return startsWith(s2, 0); } unsigned char String::startsWith( const String &s2, unsigned int offset ) const { if (offset > len - s2.len || !buffer || !s2.buffer) return 0; return strncmp( &buffer[offset], s2.buffer, s2.len ) == 0; } unsigned char String::endsWith( const String &s2 ) const { if ( len < s2.len || !buffer || !s2.buffer) return 0; return strcmp(&buffer[len - s2.len], s2.buffer) == 0; } /*********************************************/ /* Character Access */ /*********************************************/ char String::charAt(unsigned int loc) const { return operator[](loc); } void String::setCharAt(unsigned int loc, char c) { if (loc < len) buffer[loc] = c; } char & String::operator[](unsigned int index) { static char dummy_writable_char; if (index >= len || !buffer) { dummy_writable_char = 0; return dummy_writable_char; } return buffer[index]; } char String::operator[]( unsigned int index ) const { if (index >= len || !buffer) return 0; return buffer[index]; } void String::getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index) const { if (!bufsize || !buf) return; if (index >= len) { buf[0] = 0; return; } unsigned int n = bufsize - 1; if (n > len - index) n = len - index; strncpy((char *)buf, buffer + index, n); buf[n] = 0; } /*********************************************/ /* Search */ /*********************************************/ int String::indexOf(char c) const { return indexOf(c, 0); } int String::indexOf( char ch, unsigned int fromIndex ) const { if (fromIndex >= len) return -1; const char* temp = strchr(buffer + fromIndex, ch); if (temp == NULL) return -1; return temp - buffer; } int String::indexOf(const String &s2) const { return indexOf(s2, 0); } int String::indexOf(const String &s2, unsigned int fromIndex) const { if (fromIndex >= len) return -1; const char *found = strstr(buffer + fromIndex, s2.buffer); if (found == NULL) return -1; return found - buffer; } int String::lastIndexOf( char theChar ) const { return lastIndexOf(theChar, len - 1); } int String::lastIndexOf(char ch, unsigned int fromIndex) const { if (fromIndex >= len) return -1; char tempchar = buffer[fromIndex + 1]; buffer[fromIndex + 1] = '\0'; char* temp = strrchr( buffer, ch ); buffer[fromIndex + 1] = tempchar; if (temp == NULL) return -1; return temp - buffer; } int String::lastIndexOf(const String &s2) const { return lastIndexOf(s2, len - s2.len); } int String::lastIndexOf(const String &s2, unsigned int fromIndex) const { if (s2.len == 0 || len == 0 || s2.len > len) return -1; if (fromIndex >= len) fromIndex = len - 1; int found = -1; for (char *p = buffer; p <= buffer + fromIndex; p++) { p = strstr(p, s2.buffer); if (!p) break; if ((unsigned int)(p - buffer) <= fromIndex) found = p - buffer; } return found; } String String::substring( unsigned int left ) const { return substring(left, len); } String String::substring(unsigned int left, unsigned int right) const { if (left > right) { unsigned int temp = right; right = left; left = temp; } String out; if (left > len) return out; if (right > len) right = len; char temp = buffer[right]; // save the replaced character buffer[right] = '\0'; out = buffer + left; // pointer arithmetic buffer[right] = temp; //restore character return out; } /*********************************************/ /* Modification */ /*********************************************/ void String::replace(char find, char replace) { if (!buffer) return; for (char *p = buffer; *p; p++) { if (*p == find) *p = replace; } } void String::replace(const String& find, const String& replace) { if (len == 0 || find.len == 0) return; int diff = replace.len - find.len; char *readFrom = buffer; char *foundAt; if (diff == 0) { while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { memcpy(foundAt, replace.buffer, replace.len); readFrom = foundAt + replace.len; } } else if (diff < 0) { char *writeTo = buffer; while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { unsigned int n = foundAt - readFrom; memcpy(writeTo, readFrom, n); writeTo += n; memcpy(writeTo, replace.buffer, replace.len); writeTo += replace.len; readFrom = foundAt + find.len; len += diff; } strcpy(writeTo, readFrom); } else { unsigned int size = len; // compute size needed for result while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { readFrom = foundAt + find.len; size += diff; } if (size == len) return; if (size > capacity && !changeBuffer(size)) return; // XXX: tell user! int index = len - 1; while (index >= 0 && (index = lastIndexOf(find, index)) >= 0) { readFrom = buffer + index + find.len; memmove(readFrom + diff, readFrom, len - (readFrom - buffer)); len += diff; buffer[len] = 0; memcpy(buffer + index, replace.buffer, replace.len); index--; } } } void String::toLowerCase(void) { if (!buffer) return; for (char *p = buffer; *p; p++) { *p = tolower(*p); } } void String::toUpperCase(void) { if (!buffer) return; for (char *p = buffer; *p; p++) { *p = toupper(*p); } } void String::trim(void) { if (!buffer || len == 0) return; char *begin = buffer; while (isspace(*begin)) begin++; char *end = buffer + len - 1; while (isspace(*end) && end >= begin) end--; len = end + 1 - begin; if (begin > buffer) memcpy(buffer, begin, len); buffer[len] = 0; } /*********************************************/ /* Parsing / Conversion */ /*********************************************/ long String::toInt(void) const { if (buffer) return atol(buffer); return 0; } arduino-mighty-1284p-0~svn20130430.orig/cores/standard/main.cpp0000644000175000017500000000030412137772502023332 0ustar shevekshevek#include int main(void) { init(); #if defined(USBCON) USB.attach(); #endif setup(); for (;;) { loop(); if (serialEventRun) serialEventRun(); } return 0; } arduino-mighty-1284p-0~svn20130430.orig/cores/standard/HardwareSerial.cpp0000644000175000017500000002610312137772502025310 0ustar shevekshevek/* HardwareSerial.cpp - Hardware serial library for Wiring Copyright (c) 2006 Nicholas Zambetti. All right reserved. 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Modified 23 November 2006 by David A. Mellis Modified 28 September 2010 by Mark Sproul */ #include #include #include #include #include "Arduino.h" #include "wiring_private.h" // this next line disables the entire HardwareSerial.cpp, // this is so I can support Attiny series and any other chip without a uart #if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H) #include "HardwareSerial.h" // Define constants and variables for buffering incoming serial data. We're // using a ring buffer (I think), in which head is the index of the location // to which to write the next incoming character and tail is the index of the // location from which to read. #if (RAMEND < 1000) #define SERIAL_BUFFER_SIZE 16 #else #define SERIAL_BUFFER_SIZE 64 #endif struct ring_buffer { unsigned char buffer[SERIAL_BUFFER_SIZE]; volatile int head; volatile int tail; }; #if defined(USBCON) ring_buffer rx_buffer = { { 0 }, 0, 0}; ring_buffer tx_buffer = { { 0 }, 0, 0}; #endif #if defined(UBRRH) || defined(UBRR0H) ring_buffer rx_buffer = { { 0 }, 0, 0 }; ring_buffer tx_buffer = { { 0 }, 0, 0 }; #endif #if defined(UBRR1H) ring_buffer rx_buffer1 = { { 0 }, 0, 0 }; ring_buffer tx_buffer1 = { { 0 }, 0, 0 }; #endif #if defined(UBRR2H) ring_buffer rx_buffer2 = { { 0 }, 0, 0 }; ring_buffer tx_buffer2 = { { 0 }, 0, 0 }; #endif #if defined(UBRR3H) ring_buffer rx_buffer3 = { { 0 }, 0, 0 }; ring_buffer tx_buffer3 = { { 0 }, 0, 0 }; #endif inline void store_char(unsigned char c, ring_buffer *buffer) { int i = (unsigned int)(buffer->head + 1) % SERIAL_BUFFER_SIZE; // if we should be storing the received character into the location // just before the tail (meaning that the head would advance to the // current location of the tail), we're about to overflow the buffer // and so we don't write the character or advance the head. if (i != buffer->tail) { buffer->buffer[buffer->head] = c; buffer->head = i; } } #if !defined(USART0_RX_vect) && defined(USART1_RX_vect) // do nothing - on the 32u4 the first USART is USART1 #else #if !defined(USART_RX_vect) && !defined(SIG_USART0_RECV) && \ !defined(SIG_UART0_RECV) && !defined(USART0_RX_vect) && \ !defined(SIG_UART_RECV) #error "Don't know what the Data Received vector is called for the first UART" #else void serialEvent() __attribute__((weak)); void serialEvent() {} #define serialEvent_implemented #if defined(USART_RX_vect) SIGNAL(USART_RX_vect) #elif defined(SIG_USART0_RECV) SIGNAL(SIG_USART0_RECV) #elif defined(SIG_UART0_RECV) SIGNAL(SIG_UART0_RECV) #elif defined(USART0_RX_vect) SIGNAL(USART0_RX_vect) #elif defined(SIG_UART_RECV) SIGNAL(SIG_UART_RECV) #endif { #if defined(UDR0) unsigned char c = UDR0; #elif defined(UDR) unsigned char c = UDR; #else #error UDR not defined #endif store_char(c, &rx_buffer); } #endif #endif #if defined(USART1_RX_vect) void serialEvent1() __attribute__((weak)); void serialEvent1() {} #define serialEvent1_implemented SIGNAL(USART1_RX_vect) { unsigned char c = UDR1; store_char(c, &rx_buffer1); } #elif defined(SIG_USART1_RECV) #error SIG_USART1_RECV #endif #if defined(USART2_RX_vect) && defined(UDR2) void serialEvent2() __attribute__((weak)); void serialEvent2() {} #define serialEvent2_implemented SIGNAL(USART2_RX_vect) { unsigned char c = UDR2; store_char(c, &rx_buffer2); } #elif defined(SIG_USART2_RECV) #error SIG_USART2_RECV #endif #if defined(USART3_RX_vect) && defined(UDR3) void serialEvent3() __attribute__((weak)); void serialEvent3() {} #define serialEvent3_implemented SIGNAL(USART3_RX_vect) { unsigned char c = UDR3; store_char(c, &rx_buffer3); } #elif defined(SIG_USART3_RECV) #error SIG_USART3_RECV #endif void serialEventRun(void) { #ifdef serialEvent_implemented if (Serial.available()) serialEvent(); #endif #ifdef serialEvent1_implemented if (Serial1.available()) serialEvent1(); #endif #ifdef serialEvent2_implemented if (Serial2.available()) serialEvent2(); #endif #ifdef serialEvent3_implemented if (Serial3.available()) serialEvent3(); #endif } #if !defined(USART0_UDRE_vect) && defined(USART1_UDRE_vect) // do nothing - on the 32u4 the first USART is USART1 #else #if !defined(UART0_UDRE_vect) && !defined(UART_UDRE_vect) && !defined(USART0_UDRE_vect) && !defined(USART_UDRE_vect) #error "Don't know what the Data Register Empty vector is called for the first UART" #else #if defined(UART0_UDRE_vect) ISR(UART0_UDRE_vect) #elif defined(UART_UDRE_vect) ISR(UART_UDRE_vect) #elif defined(USART0_UDRE_vect) ISR(USART0_UDRE_vect) #elif defined(USART_UDRE_vect) ISR(USART_UDRE_vect) #endif { if (tx_buffer.head == tx_buffer.tail) { // Buffer empty, so disable interrupts #if defined(UCSR0B) cbi(UCSR0B, UDRIE0); #else cbi(UCSRB, UDRIE); #endif } else { // There is more data in the output buffer. Send the next byte unsigned char c = tx_buffer.buffer[tx_buffer.tail]; tx_buffer.tail = (tx_buffer.tail + 1) % SERIAL_BUFFER_SIZE; #if defined(UDR0) UDR0 = c; #elif defined(UDR) UDR = c; #else #error UDR not defined #endif } } #endif #endif #ifdef USART1_UDRE_vect ISR(USART1_UDRE_vect) { if (tx_buffer1.head == tx_buffer1.tail) { // Buffer empty, so disable interrupts cbi(UCSR1B, UDRIE1); } else { // There is more data in the output buffer. Send the next byte unsigned char c = tx_buffer1.buffer[tx_buffer1.tail]; tx_buffer1.tail = (tx_buffer1.tail + 1) % SERIAL_BUFFER_SIZE; UDR1 = c; } } #endif #ifdef USART2_UDRE_vect ISR(USART2_UDRE_vect) { if (tx_buffer2.head == tx_buffer2.tail) { // Buffer empty, so disable interrupts cbi(UCSR2B, UDRIE2); } else { // There is more data in the output buffer. Send the next byte unsigned char c = tx_buffer2.buffer[tx_buffer2.tail]; tx_buffer2.tail = (tx_buffer2.tail + 1) % SERIAL_BUFFER_SIZE; UDR2 = c; } } #endif #ifdef USART3_UDRE_vect ISR(USART3_UDRE_vect) { if (tx_buffer3.head == tx_buffer3.tail) { // Buffer empty, so disable interrupts cbi(UCSR3B, UDRIE3); } else { // There is more data in the output buffer. Send the next byte unsigned char c = tx_buffer3.buffer[tx_buffer3.tail]; tx_buffer3.tail = (tx_buffer3.tail + 1) % SERIAL_BUFFER_SIZE; UDR3 = c; } } #endif // Constructors //////////////////////////////////////////////////////////////// HardwareSerial::HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer, volatile uint8_t *ubrrh, volatile uint8_t *ubrrl, volatile uint8_t *ucsra, volatile uint8_t *ucsrb, volatile uint8_t *udr, uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x) { _rx_buffer = rx_buffer; _tx_buffer = tx_buffer; _ubrrh = ubrrh; _ubrrl = ubrrl; _ucsra = ucsra; _ucsrb = ucsrb; _udr = udr; _rxen = rxen; _txen = txen; _rxcie = rxcie; _udrie = udrie; _u2x = u2x; } // Public Methods ////////////////////////////////////////////////////////////// void HardwareSerial::begin(unsigned long baud) { uint16_t baud_setting; bool use_u2x = true; #if F_CPU == 16000000UL // hardcoded exception for compatibility with the bootloader shipped // with the Duemilanove and previous boards and the firmware on the 8U2 // on the Uno and Mega 2560. if (baud == 57600) { use_u2x = false; } #endif try_again: if (use_u2x) { *_ucsra = 1 << _u2x; baud_setting = (F_CPU / 4 / baud - 1) / 2; } else { *_ucsra = 0; baud_setting = (F_CPU / 8 / baud - 1) / 2; } if ((baud_setting > 4095) && use_u2x) { use_u2x = false; goto try_again; } // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register) *_ubrrh = baud_setting >> 8; *_ubrrl = baud_setting; sbi(*_ucsrb, _rxen); sbi(*_ucsrb, _txen); sbi(*_ucsrb, _rxcie); cbi(*_ucsrb, _udrie); } void HardwareSerial::end() { // wait for transmission of outgoing data while (_tx_buffer->head != _tx_buffer->tail) ; cbi(*_ucsrb, _rxen); cbi(*_ucsrb, _txen); cbi(*_ucsrb, _rxcie); cbi(*_ucsrb, _udrie); // clear any received data _rx_buffer->head = _rx_buffer->tail; } int HardwareSerial::available(void) { return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % SERIAL_BUFFER_SIZE; } int HardwareSerial::peek(void) { if (_rx_buffer->head == _rx_buffer->tail) { return -1; } else { return _rx_buffer->buffer[_rx_buffer->tail]; } } int HardwareSerial::read(void) { // if the head isn't ahead of the tail, we don't have any characters if (_rx_buffer->head == _rx_buffer->tail) { return -1; } else { unsigned char c = _rx_buffer->buffer[_rx_buffer->tail]; _rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % SERIAL_BUFFER_SIZE; return c; } } void HardwareSerial::flush() { while (_tx_buffer->head != _tx_buffer->tail) ; } size_t HardwareSerial::write(uint8_t c) { int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE; // If the output buffer is full, there's nothing for it other than to // wait for the interrupt handler to empty it a bit // ???: return 0 here instead? while (i == _tx_buffer->tail) ; _tx_buffer->buffer[_tx_buffer->head] = c; _tx_buffer->head = i; sbi(*_ucsrb, _udrie); return 1; } // Preinstantiate Objects ////////////////////////////////////////////////////// #if defined(UBRRH) && defined(UBRRL) HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRIE, U2X); #elif defined(UBRR0H) && defined(UBRR0L) HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRIE0, U2X0); #elif defined(USBCON) // do nothing - Serial object and buffers are initialized in CDC code #else #error no serial port defined (port 0) #endif #if defined(UBRR1H) HardwareSerial Serial1(&rx_buffer1, &tx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRIE1, U2X1); #endif #if defined(UBRR2H) HardwareSerial Serial2(&rx_buffer2, &tx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UDR2, RXEN2, TXEN2, RXCIE2, UDRIE2, U2X2); #endif #if defined(UBRR3H) HardwareSerial Serial3(&rx_buffer3, &tx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UDR3, RXEN3, TXEN3, RXCIE3, UDRIE3, U2X3); #endif #endif // whole file arduino-mighty-1284p-0~svn20130430.orig/cores/standard/USBDesc.h0000644000175000017500000000373612137772502023317 0ustar shevekshevek /* Copyright (c) 2011, Peter Barrett ** ** Permission to use, copy, modify, and/or distribute this software for ** any purpose with or without fee is hereby granted, provided that the ** above copyright notice and this permission notice appear in all copies. ** ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL ** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR ** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES ** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, ** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS ** SOFTWARE. */ #define CDC_ENABLED #define HID_ENABLED #ifdef CDC_ENABLED #define CDC_INTERFACE_COUNT 2 #define CDC_ENPOINT_COUNT 3 #else #define CDC_INTERFACE_COUNT 0 #define CDC_ENPOINT_COUNT 0 #endif #ifdef HID_ENABLED #define HID_INTERFACE_COUNT 1 #define HID_ENPOINT_COUNT 1 #else #define HID_INTERFACE_COUNT 0 #define HID_ENPOINT_COUNT 0 #endif #define CDC_ACM_INTERFACE 0 // CDC ACM #define CDC_DATA_INTERFACE 1 // CDC Data #define CDC_FIRST_ENDPOINT 1 #define CDC_ENDPOINT_ACM (CDC_FIRST_ENDPOINT) // CDC First #define CDC_ENDPOINT_OUT (CDC_FIRST_ENDPOINT+1) #define CDC_ENDPOINT_IN (CDC_FIRST_ENDPOINT+2) #define HID_INTERFACE (CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT) // HID Interface #define HID_FIRST_ENDPOINT (CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT) #define HID_ENDPOINT_INT (HID_FIRST_ENDPOINT) #define INTERFACE_COUNT (MSC_INTERFACE + MSC_INTERFACE_COUNT) #ifdef CDC_ENABLED #define CDC_RX CDC_ENDPOINT_OUT #define CDC_TX CDC_ENDPOINT_IN #endif #ifdef HID_ENABLED #define HID_TX HID_ENDPOINT_INT #endif #define IMANUFACTURER 1 #define IPRODUCT 2 #define USB_PID_LEONARDO 0x0034 #define USB_PID_MICRO 0x0035 #define USB_VID 0x2341 // arduino LLC vid #define USB_PID ARDUINO_MODEL_USB_PID arduino-mighty-1284p-0~svn20130430.orig/boards.txt0000644000175000017500000000623512137772502021013 0ustar shevekshevek############################################################## mighty_opt.name=Mighty 1284p 16MHz using Optiboot mighty_opt.upload.protocol=arduino mighty_opt.upload.maximum_size=130048 mighty_opt.upload.speed=115200 mighty_opt.bootloader.low_fuses=0xff mighty_opt.bootloader.high_fuses=0xde mighty_opt.bootloader.extended_fuses=0xfd mighty_opt.bootloader.path=optiboot mighty_opt.bootloader.file=optiboot_atmega1284p.hex mighty_opt.bootloader.unlock_bits=0x3F mighty_opt.bootloader.lock_bits=0x0F mighty_opt.build.mcu=atmega1284p mighty_opt.build.f_cpu=16000000L #mighty_opt.build.core=arduino:arduino mighty_opt.build.core=standard mighty_opt.build.variant=standard ############################################################## avr_developers.name=avr-developers.com pinouts 16MHz using Optiboot avr_developers.upload.protocol=arduino avr_developers.upload.maximum_size=130048 avr_developers.upload.speed=115200 avr_developers.bootloader.low_fuses=0xff avr_developers.bootloader.high_fuses=0xde avr_developers.bootloader.extended_fuses=0xfd avr_developers.bootloader.path=optiboot avr_developers.bootloader.file=optiboot_atmega1284p.hex avr_developers.bootloader.unlock_bits=0x3F avr_developers.bootloader.lock_bits=0x0F avr_developers.build.mcu=atmega1284p avr_developers.build.f_cpu=16000000L #avr_developers.build.core=arduino:arduino avr_developers.build.core=standard avr_developers.build.variant=avr_developers ############################################################## bobuino.name=Bobuino bobuino.upload.protocol=arduino bobuino.upload.maximum_size=130048 bobuino.upload.speed=115200 bobuino.bootloader.low_fuses=0xff bobuino.bootloader.high_fuses=0xde bobuino.bootloader.extended_fuses=0xfd bobuino.bootloader.path=optiboot bobuino.bootloader.file=optiboot_atmega1284p.hex bobuino.bootloader.unlock_bits=0x3F bobuino.bootloader.lock_bits=0x0F bobuino.build.mcu=atmega1284p bobuino.build.f_cpu=16000000L #bobuino.build.core=arduino:arduino bobuino.build.core=standard bobuino.build.variant=bobuino ############################################################## mighty.name=Original Mighty 1284p 16MHz mighty.upload.protocol=stk500v1 mighty.upload.maximum_size=129024 mighty.upload.speed=57600 mighty.bootloader.low_fuses=0xff mighty.bootloader.high_fuses=0xdc mighty.bootloader.extended_fuses=0xfd mighty.bootloader.path=standard mighty.bootloader.file=ATmegaBOOT_1284P.hex mighty.bootloader.unlock_bits=0x3F mighty.bootloader.lock_bits=0x0F mighty.build.mcu=atmega1284p mighty.build.f_cpu=16000000L #mighty.build.core=arduino:arduino mighty.build.core=standard mighty.build.variant=standard ############################################################## mighty8.name=Original Mighty 1284p 8MHz mighty8.upload.protocol=stk500v1 mighty8.upload.maximum_size=129024 mighty8.upload.speed=28800 mighty8.bootloader.low_fuses=0xff mighty8.bootloader.high_fuses=0xdc mighty8.bootloader.extended_fuses=0xfd mighty8.bootloader.path=standard mighty8.bootloader.file=ATmegaBOOT_1284P_8MHz.hex mighty8.bootloader.unlock_bits=0x3F mighty8.bootloader.lock_bits=0x0F mighty8.build.mcu=atmega1284p mighty8.build.f_cpu=8000000L #mighty8.build.core=arduino:arduino mighty8.build.core=standard mighty8.build.variant=standard