Added patch to bootloader for Mega2560. (Mark Sproul)
See #181 #392 #505 #543 #544
This commit is contained in:
parent
09b755fb9c
commit
7ab19444ec
|
@ -0,0 +1,189 @@
|
|||
//**************************************************************************************************
|
||||
//*
|
||||
//* Atmel AVR CPU name strings
|
||||
//*
|
||||
//**************************************************************************************************
|
||||
//* Sep 19, 2010 <MLS> Started on avr_cpunames.h
|
||||
//**************************************************************************************************
|
||||
|
||||
//#include "avr_cpunames.h"
|
||||
|
||||
//**************************************************************************************************
|
||||
|
||||
|
||||
#if defined (__AVR_AT94K__)
|
||||
#define _AVR_CPU_NAME_ "AT94k"
|
||||
#elif defined (__AVR_AT43USB320__)
|
||||
#elif defined (__AVR_AT43USB355__)
|
||||
#elif defined (__AVR_AT76C711__)
|
||||
#elif defined (__AVR_AT86RF401__)
|
||||
#elif defined (__AVR_AT90PWM1__)
|
||||
#elif defined (__AVR_AT90PWM2__)
|
||||
#elif defined (__AVR_AT90PWM2B__)
|
||||
#elif defined (__AVR_AT90PWM3__)
|
||||
#elif defined (__AVR_AT90PWM3B__)
|
||||
#elif defined (__AVR_AT90PWM216__)
|
||||
#elif defined (__AVR_AT90PWM316__)
|
||||
#elif defined (__AVR_ATmega32C1__)
|
||||
#elif defined (__AVR_ATmega32M1__)
|
||||
#elif defined (__AVR_ATmega32U4__)
|
||||
#define _AVR_CPU_NAME_ "ATmega32U4"
|
||||
#elif defined (__AVR_ATmega32U6__)
|
||||
#define _AVR_CPU_NAME_ "ATmega32U6"
|
||||
#elif defined (__AVR_ATmega128__)
|
||||
#define _AVR_CPU_NAME_ "Atmega128"
|
||||
#elif defined (__AVR_ATmega1280__)
|
||||
#define _AVR_CPU_NAME_ "ATmega1280"
|
||||
#elif defined (__AVR_ATmega1281__)
|
||||
#define _AVR_CPU_NAME_ "ATmega1281"
|
||||
#elif defined (__AVR_ATmega1284P__)
|
||||
#define _AVR_CPU_NAME_ "ATmega1284"
|
||||
#elif defined (__AVR_ATmega128RFA1__)
|
||||
#define _AVR_CPU_NAME_ "ATmega128RFA1"
|
||||
#elif defined (__AVR_ATmega2560__)
|
||||
#define _AVR_CPU_NAME_ "ATmega2560"
|
||||
#elif defined (__AVR_ATmega2561__)
|
||||
#define _AVR_CPU_NAME_ "ATmega2561"
|
||||
#elif defined (__AVR_AT90CAN32__)
|
||||
#define _AVR_CPU_NAME_ "AT90CAN32"
|
||||
#elif defined (__AVR_AT90CAN64__)
|
||||
#define _AVR_CPU_NAME_ "AT90CAN64"
|
||||
#elif defined (__AVR_AT90CAN128__)
|
||||
#define _AVR_CPU_NAME_ "AT90CAN128"
|
||||
#elif defined (__AVR_AT90USB82__)
|
||||
#define _AVR_CPU_NAME_ "AT90USB82"
|
||||
#elif defined (__AVR_AT90USB162__)
|
||||
#define _AVR_CPU_NAME_ "AT90USB162"
|
||||
#elif defined (__AVR_AT90USB646__)
|
||||
#define _AVR_CPU_NAME_ "AT90USB646"
|
||||
#elif defined (__AVR_AT90USB647__)
|
||||
#define _AVR_CPU_NAME_ "AT90USB647"
|
||||
#elif defined (__AVR_AT90USB1286__)
|
||||
#define _AVR_CPU_NAME_ "AT90USB1286"
|
||||
#elif defined (__AVR_AT90USB1287__)
|
||||
#define _AVR_CPU_NAME_ "AT90USB1287"
|
||||
#elif defined (__AVR_ATmega64__)
|
||||
#define _AVR_CPU_NAME_ "ATmega64"
|
||||
#elif defined (__AVR_ATmega640__)
|
||||
#define _AVR_CPU_NAME_ "ATmega640"
|
||||
#elif defined (__AVR_ATmega644__)
|
||||
#define _AVR_CPU_NAME_ "ATmega644"
|
||||
#elif defined (__AVR_ATmega644P__)
|
||||
#define _AVR_CPU_NAME_ "ATmega644P"
|
||||
#elif defined (__AVR_ATmega645__)
|
||||
#define _AVR_CPU_NAME_ "ATmega645"
|
||||
#elif defined (__AVR_ATmega6450__)
|
||||
#define _AVR_CPU_NAME_ "ATmega6450"
|
||||
#elif defined (__AVR_ATmega649__)
|
||||
#define _AVR_CPU_NAME_ "ATmega649"
|
||||
#elif defined (__AVR_ATmega6490__)
|
||||
#define _AVR_CPU_NAME_ "ATmega6490"
|
||||
#elif defined (__AVR_ATmega103__)
|
||||
#define _AVR_CPU_NAME_ "ATmega103"
|
||||
#elif defined (__AVR_ATmega32__)
|
||||
#define _AVR_CPU_NAME_ "Atmega32"
|
||||
#elif defined (__AVR_ATmega323__)
|
||||
#define _AVR_CPU_NAME_ "ATmega323"
|
||||
#elif defined (__AVR_ATmega324P__)
|
||||
#define _AVR_CPU_NAME_ "ATmega324P"
|
||||
#elif defined (__AVR_ATmega325__)
|
||||
#define _AVR_CPU_NAME_ "ATmega325"
|
||||
#elif defined (__AVR_ATmega325P__)
|
||||
#define _AVR_CPU_NAME_ "ATmega325P"
|
||||
#elif defined (__AVR_ATmega3250__)
|
||||
#define _AVR_CPU_NAME_ "ATmega3250"
|
||||
#elif defined (__AVR_ATmega3250P__)
|
||||
#define _AVR_CPU_NAME_ "ATmega3250P"
|
||||
#elif defined (__AVR_ATmega328P__)
|
||||
#define _AVR_CPU_NAME_ "ATmega328P"
|
||||
#elif defined (__AVR_ATmega329__)
|
||||
#define _AVR_CPU_NAME_ "ATmega329"
|
||||
#elif defined (__AVR_ATmega329P__)
|
||||
#define _AVR_CPU_NAME_ "ATmega329P"
|
||||
#elif defined (__AVR_ATmega3290__)
|
||||
#define _AVR_CPU_NAME_ "ATmega3290"
|
||||
#elif defined (__AVR_ATmega3290P__)
|
||||
#define _AVR_CPU_NAME_ "ATmega3290P"
|
||||
#elif defined (__AVR_ATmega32HVB__)
|
||||
#define _AVR_CPU_NAME_ "ATmega32HVB"
|
||||
#elif defined (__AVR_ATmega406__)
|
||||
#define _AVR_CPU_NAME_ "ATmega406"
|
||||
#elif defined (__AVR_ATmega16__)
|
||||
#define _AVR_CPU_NAME_ "Atmega16"
|
||||
#elif defined (__AVR_ATmega161__)
|
||||
#define _AVR_CPU_NAME_ "ATmega161"
|
||||
#elif defined (__AVR_ATmega162__)
|
||||
#define _AVR_CPU_NAME_ "ATmega162"
|
||||
#elif defined (__AVR_ATmega163__)
|
||||
#define _AVR_CPU_NAME_ "ATmega163"
|
||||
#elif defined (__AVR_ATmega164P__)
|
||||
#define _AVR_CPU_NAME_ "ATmega164P"
|
||||
#elif defined (__AVR_ATmega165__)
|
||||
#define _AVR_CPU_NAME_ "ATmega165"
|
||||
#elif defined (__AVR_ATmega165P__)
|
||||
#define _AVR_CPU_NAME_ "ATmega165P"
|
||||
#elif defined (__AVR_ATmega168__)
|
||||
#define _AVR_CPU_NAME_ "ATmega168"
|
||||
#elif defined (__AVR_ATmega168P__)
|
||||
#define _AVR_CPU_NAME_ "ATmega168P"
|
||||
#elif defined (__AVR_ATmega169__)
|
||||
#define _AVR_CPU_NAME_ "Atmega169"
|
||||
#elif defined (__AVR_ATmega169P__)
|
||||
#define _AVR_CPU_NAME_ "ATmega169P"
|
||||
#elif defined (__AVR_ATmega8HVA__)
|
||||
#define _AVR_CPU_NAME_ "ATmega8HVA"
|
||||
#elif defined (__AVR_ATmega16HVA__)
|
||||
#define _AVR_CPU_NAME_ "ATmega16HVA"
|
||||
#elif defined (__AVR_ATmega8__)
|
||||
#define _AVR_CPU_NAME_ "ATmega8"
|
||||
#elif defined (__AVR_ATmega48__)
|
||||
#define _AVR_CPU_NAME_ "ATmega48"
|
||||
#elif defined (__AVR_ATmega48P__)
|
||||
#define _AVR_CPU_NAME_ "ATmega48P"
|
||||
#elif defined (__AVR_ATmega88__)
|
||||
#define _AVR_CPU_NAME_ "ATmega88"
|
||||
#elif defined (__AVR_ATmega88P__)
|
||||
#define _AVR_CPU_NAME_ "ATmega88P"
|
||||
#elif defined (__AVR_ATmega8515__)
|
||||
#define _AVR_CPU_NAME_ "ATmega8515"
|
||||
#elif defined (__AVR_ATmega8535__)
|
||||
#define _AVR_CPU_NAME_ "ATmega8535"
|
||||
#elif defined (__AVR_AT90S8535__)
|
||||
#elif defined (__AVR_AT90C8534__)
|
||||
#elif defined (__AVR_AT90S8515__)
|
||||
#elif defined (__AVR_AT90S4434__)
|
||||
#elif defined (__AVR_AT90S4433__)
|
||||
#elif defined (__AVR_AT90S4414__)
|
||||
#elif defined (__AVR_ATtiny22__)
|
||||
#elif defined (__AVR_ATtiny26__)
|
||||
#elif defined (__AVR_AT90S2343__)
|
||||
#elif defined (__AVR_AT90S2333__)
|
||||
#elif defined (__AVR_AT90S2323__)
|
||||
#elif defined (__AVR_AT90S2313__)
|
||||
#elif defined (__AVR_ATtiny2313__)
|
||||
#define _AVR_CPU_NAME_ "ATtiny2313"
|
||||
#elif defined (__AVR_ATtiny13__)
|
||||
#elif defined (__AVR_ATtiny13A__)
|
||||
#elif defined (__AVR_ATtiny25__)
|
||||
#elif defined (__AVR_ATtiny45__)
|
||||
#elif defined (__AVR_ATtiny85__)
|
||||
#elif defined (__AVR_ATtiny24__)
|
||||
#elif defined (__AVR_ATtiny44__)
|
||||
#elif defined (__AVR_ATtiny84__)
|
||||
#elif defined (__AVR_ATtiny261__)
|
||||
#elif defined (__AVR_ATtiny461__)
|
||||
#elif defined (__AVR_ATtiny861__)
|
||||
#elif defined (__AVR_ATtiny43U__)
|
||||
#elif defined (__AVR_ATtiny48__)
|
||||
#elif defined (__AVR_ATtiny88__)
|
||||
#elif defined (__AVR_ATtiny167__)
|
||||
#elif defined (__AVR_ATmega8U2__)
|
||||
#define _AVR_CPU_NAME_ "ATmega8U2"
|
||||
#else
|
||||
#error cpu not defined
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined (_AVR_CPU_NAME_)
|
||||
// #define _AVR_CPU_NAME_ "UNKNOWN"
|
||||
#endif
|
|
@ -13,6 +13,7 @@
|
|||
//* Jul 4, 2010 <MLS> Started using vector defs for #ifdefs as defined in <avr/io.h>
|
||||
//* Jul 13, 2010 <MLS> Added support for __AVR_ATmega128__
|
||||
//* Aug 26, 2010 <MLS> Added support for __AVR_ATmega2561__
|
||||
//* Sep 13, 2010 <MLS> Added support for __AVR_AT90CAN32__ __AVR_AT90CAN64__ __AVR_AT90CAN128__
|
||||
//**************************************************************************************************
|
||||
|
||||
//#include "avrinterruptnames.h"
|
||||
|
@ -253,13 +254,69 @@
|
|||
prog_char gAvrInt_LCD_StartFrame[] PROGMEM = "LCD Start of Frame";
|
||||
#endif
|
||||
|
||||
//* these are for the chips with CAN bus support
|
||||
#ifdef CANIT_vect
|
||||
prog_char gAvrInt_CAN_TrafnsferCE[] PROGMEM = "CAN Transfer Complete or Error";
|
||||
#endif
|
||||
#ifdef OVRIT_vect
|
||||
prog_char gAvrInt_CAN_TimerOverRun[] PROGMEM = "CAN Timer Overrun";
|
||||
#endif
|
||||
|
||||
//* these are for __AVR_ATmega128RFA1__
|
||||
#ifdef TRX24_PLL_LOCK_vect
|
||||
prog_char gAvrInt_TRN_PLL_LOCK[] PROGMEM = "TRX24_PLL_LOCK";
|
||||
#endif
|
||||
#ifdef TRX24_PLL_UNLOCK_vect
|
||||
prog_char gAvrInt_TRN_PLL_UNLOCK[] PROGMEM = "TRX24_PLL_UNLOCK";
|
||||
#endif
|
||||
#ifdef TRX24_RX_START_vect
|
||||
prog_char gAvrInt_TRN_RX_START[] PROGMEM = "TRX24_RX_START";
|
||||
#endif
|
||||
#ifdef TRX24_RX_END_vect
|
||||
prog_char gAvrInt_TRN_RX_END[] PROGMEM = "TRX24_RX_END";
|
||||
#endif
|
||||
#ifdef TRX24_CCA_ED_DONE_vect
|
||||
prog_char gAvrInt_TRN_CAAED_DONE[] PROGMEM = "TRX24_CCA_ED_DONE";
|
||||
#endif
|
||||
#ifdef TRX24_XAH_AMI_vect
|
||||
prog_char gAvrInt_TRN_FRAME_MATCH[] PROGMEM = "TRX24_FRAME_ADDRESS_MATCH";
|
||||
#endif
|
||||
#ifdef TRX24_TX_END_vect
|
||||
prog_char gAvrInt_TRN_TX_END[] PROGMEM = "TRX24_TX_END";
|
||||
#endif
|
||||
#ifdef TRX24_AWAKE_vect
|
||||
prog_char gAvrInt_TRN_AWAKE[] PROGMEM = "TRX24_AWAKE";
|
||||
#endif
|
||||
#ifdef SCNT_CMP1_vect
|
||||
prog_char gAvrInt_SCNT_CMP1[] PROGMEM = "SCNT_CMP1";
|
||||
#endif
|
||||
#ifdef SCNT_CMP2_vect
|
||||
prog_char gAvrInt_SCNT_CMP2[] PROGMEM = "SCNT_CMP2";
|
||||
#endif
|
||||
#ifdef SCNT_CMP3_vect
|
||||
prog_char gAvrInt_SCNT_CMP3[] PROGMEM = "SCNT_CMP3";
|
||||
#endif
|
||||
#ifdef SCNT_OVFL_vect
|
||||
prog_char gAvrInt_SCNT_OVFL[] PROGMEM = "SCNT_OVFL";
|
||||
#endif
|
||||
#ifdef SCNT_BACKOFF_vect
|
||||
prog_char gAvrInt_SCNT_BACKOFF[] PROGMEM = "SCNT_BACKOFF";
|
||||
#endif
|
||||
#ifdef AES_READY_vect
|
||||
prog_char gAvrInt_AES_READY[] PROGMEM = "AES_READY";
|
||||
#endif
|
||||
#ifdef BAT_LOW_vect
|
||||
prog_char gAvrInt_BAT_LOW[] PROGMEM = "BAT_LOW";
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//**************************************************************************************************
|
||||
//* these do not have vector defs and have to be done by CPU type
|
||||
#if defined(__AVR_ATmega645__ ) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
|
||||
prog_char gAvrInt_NOT_USED[] PROGMEM = "NOT_USED";
|
||||
#endif
|
||||
#if defined(__AVR_ATmega32U4__)
|
||||
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega128RFA1__)
|
||||
prog_char gAvrInt_RESERVED[] PROGMEM = "Reserved";
|
||||
#endif
|
||||
|
||||
|
@ -309,8 +366,8 @@ PGM_P gInterruptNameTable[] PROGMEM =
|
|||
#endif
|
||||
|
||||
//**************************************************************************************************
|
||||
#pragma mark __AVR_ATmega169__
|
||||
#if defined(__AVR_ATmega169__)
|
||||
#pragma mark __AVR_ATmega169__
|
||||
|
||||
#define _INTERRUPT_NAMES_DEFINED_
|
||||
|
||||
|
@ -439,8 +496,8 @@ PGM_P gInterruptNameTable[] PROGMEM =
|
|||
|
||||
|
||||
//**************************************************************************************************
|
||||
#if defined(__AVR_ATmega324P__ ) || defined(__AVR_ATmega644__ ) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
|
||||
#pragma mark __AVR_ATmega324P__ __AVR_ATmega644__ __AVR_ATmega644P__ __AVR_ATmega1284P__
|
||||
#if defined(__AVR_ATmega324P__ ) || defined(__AVR_ATmega644__ ) || defined(__AVR_ATmega644P__)
|
||||
#pragma mark __AVR_ATmega324P__ __AVR_ATmega644__ __AVR_ATmega644P__
|
||||
|
||||
#define _INTERRUPT_NAMES_DEFINED_
|
||||
|
||||
|
@ -487,6 +544,61 @@ PGM_P gInterruptNameTable[] PROGMEM =
|
|||
|
||||
#endif
|
||||
|
||||
//**************************************************************************************************
|
||||
#if defined(__AVR_ATmega1284P__ )
|
||||
#pragma mark __AVR_ATmega1284P__
|
||||
|
||||
#define _INTERRUPT_NAMES_DEFINED_
|
||||
|
||||
PGM_P gInterruptNameTable[] PROGMEM =
|
||||
{
|
||||
|
||||
gAvrInt_RESET, // 1
|
||||
gAvrInt_INT0, // 2
|
||||
gAvrInt_INT1, // 3
|
||||
gAvrInt_INT2, // 4
|
||||
gAvrInt_PCINT0, // 5
|
||||
gAvrInt_PCINT1, // 6
|
||||
gAvrInt_PCINT2, // 7
|
||||
gAvrInt_PCINT3, // 8
|
||||
gAvrInt_WDT, // 9
|
||||
gAvrInt_TIMER2_COMPA, // 10
|
||||
gAvrInt_TIMER2_COMPB, // 11
|
||||
gAvrInt_TIMER2_OVF, // 12
|
||||
gAvrInt_TIMER1_CAPT, // 13
|
||||
gAvrInt_TIMER1_COMPA, // 14
|
||||
gAvrInt_TIMER1_COMPB, // 15
|
||||
gAvrInt_TIMER1_OVF, // 16
|
||||
gAvrInt_TIMER0_COMPA, // 17
|
||||
gAvrInt_TIMER0_COMPB, // 18
|
||||
gAvrInt_TIMER0_OVF, // 19
|
||||
gAvrInt_SPI_STC, // 20
|
||||
gAvrInt_USART0_RX, // 21
|
||||
gAvrInt_USART0_UDRE, // 22
|
||||
gAvrInt_USART0_TX, // 23
|
||||
gAvrInt_ANALOG_COMP, // 24
|
||||
gAvrInt_ADC, // 25
|
||||
gAvrInt_EE_READY, // 26
|
||||
gAvrInt_TWI, // 27
|
||||
gAvrInt_SPM_READY, // 28
|
||||
|
||||
gAvrInt_USART1_RX, // 29
|
||||
gAvrInt_USART1_UDRE, // 30
|
||||
gAvrInt_USART1_TX, // 31
|
||||
//* these are NOT documented in doc8272.pdf
|
||||
//* they are in iom1284p.h
|
||||
gAvrInt_TIMER3_CAPT, // 32
|
||||
gAvrInt_TIMER3_COMPA, // 33
|
||||
gAvrInt_TIMER3_COMPB, // 34
|
||||
gAvrInt_TIMER3_OVF, // 35
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//**************************************************************************************************
|
||||
#if defined(__AVR_ATmega645__ )
|
||||
#pragma mark __AVR_ATmega645__
|
||||
|
@ -529,6 +641,41 @@ PGM_P gInterruptNameTable[] PROGMEM =
|
|||
|
||||
#endif
|
||||
|
||||
//**************************************************************************************************
|
||||
#if defined(__AVR_ATmega16__ )
|
||||
#pragma mark __AVR_ATmega16__
|
||||
|
||||
#define _INTERRUPT_NAMES_DEFINED_
|
||||
|
||||
PGM_P gInterruptNameTable[] PROGMEM =
|
||||
{
|
||||
|
||||
gAvrInt_RESET, // 1
|
||||
gAvrInt_INT0, // 2
|
||||
gAvrInt_INT1, // 3
|
||||
gAvrInt_TIMER2_COMP, // 4
|
||||
gAvrInt_TIMER2_OVF, // 5
|
||||
gAvrInt_TIMER1_CAPT, // 6
|
||||
gAvrInt_TIMER1_COMPA, // 7
|
||||
gAvrInt_TIMER1_COMPB, // 8
|
||||
gAvrInt_TIMER1_OVF, // 9
|
||||
gAvrInt_TIMER0_OVF, // 10
|
||||
gAvrInt_SPI_STC, // 11
|
||||
gAvrInt_USART_RX, // 12
|
||||
gAvrInt_USART_UDRE, // 13
|
||||
gAvrInt_USART_TX, // 14
|
||||
gAvrInt_ADC, // 15
|
||||
gAvrInt_EE_READY, // 16
|
||||
gAvrInt_ANALOG_COMP, // 17
|
||||
gAvrInt_TWI, // 18
|
||||
gAvrInt_INT2, // 19
|
||||
gAvrInt_TIMER0_COMP, // 20
|
||||
gAvrInt_SPM_READY, // 21
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
//**************************************************************************************************
|
||||
#if defined(__AVR_ATmega32__ )
|
||||
|
@ -629,7 +776,7 @@ PGM_P gInterruptNameTable[] PROGMEM =
|
|||
#endif
|
||||
|
||||
//**************************************************************************************************
|
||||
#if defined(__AVR_AT90USB1286__)
|
||||
#if defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
|
||||
#pragma mark __AVR_AT90USB1286__
|
||||
//* teensy++ 2.0
|
||||
//* http://www.pjrc.com/teensy/pinout.html
|
||||
|
@ -689,8 +836,8 @@ PGM_P gInterruptNameTable[] PROGMEM =
|
|||
|
||||
|
||||
//**************************************************************************************************
|
||||
#if defined(__AVR_ATmega128__)
|
||||
#pragma mark __AVR_ATmega128__
|
||||
#if defined(__AVR_ATmega128__) || defined(__AVR_ATmega64__)
|
||||
#pragma mark __AVR_ATmega64__ __AVR_ATmega128__
|
||||
#define _INTERRUPT_NAMES_DEFINED_
|
||||
|
||||
|
||||
|
@ -737,6 +884,157 @@ PGM_P gInterruptNameTable[] PROGMEM =
|
|||
|
||||
#endif
|
||||
|
||||
//**************************************************************************************************
|
||||
#if defined(__AVR_AT90CAN32__) || defined(__AVR_AT90CAN64__) || defined(__AVR_AT90CAN128__)
|
||||
#pragma mark __AVR_AT90CAN32__ __AVR_AT90CAN64__ __AVR_AT90CAN128__
|
||||
|
||||
#define _INTERRUPT_NAMES_DEFINED_
|
||||
|
||||
PGM_P gInterruptNameTable[] PROGMEM =
|
||||
{
|
||||
|
||||
gAvrInt_RESET, // 1
|
||||
gAvrInt_INT0, // 2
|
||||
gAvrInt_INT1, // 3
|
||||
gAvrInt_INT2, // 4
|
||||
gAvrInt_INT3, // 5
|
||||
gAvrInt_INT4, // 6
|
||||
gAvrInt_INT5, // 7
|
||||
gAvrInt_INT6, // 8
|
||||
gAvrInt_INT7, // 9
|
||||
gAvrInt_TIMER2_COMP, // 10
|
||||
gAvrInt_TIMER2_OVF, // 11
|
||||
gAvrInt_TIMER1_CAPT, // 12
|
||||
gAvrInt_TIMER1_COMPA, // 13
|
||||
gAvrInt_TIMER1_COMPB, // 14
|
||||
gAvrInt_TIMER1_COMPC, // 15
|
||||
gAvrInt_TIMER1_OVF, // 16
|
||||
gAvrInt_TIMER0_COMP, // 17
|
||||
gAvrInt_TIMER0_OVF, // 18
|
||||
gAvrInt_CAN_TrafnsferCE, // 19
|
||||
gAvrInt_CAN_TimerOverRun, // 20
|
||||
gAvrInt_SPI_STC, // 21
|
||||
gAvrInt_USART0_RX, // 22
|
||||
gAvrInt_USART0_UDRE, // 23
|
||||
gAvrInt_USART0_TX, // 24
|
||||
gAvrInt_ANALOG_COMP, // 25
|
||||
gAvrInt_ADC, // 26
|
||||
gAvrInt_EE_READY, // 27
|
||||
gAvrInt_TIMER3_CAPT, // 28
|
||||
gAvrInt_TIMER3_COMPA, // 29
|
||||
gAvrInt_TIMER3_COMPB, // 30
|
||||
gAvrInt_TIMER3_COMPC, // 31
|
||||
gAvrInt_TIMER3_OVF, // 32
|
||||
gAvrInt_USART1_RX, // 33
|
||||
gAvrInt_USART1_UDRE, // 34
|
||||
gAvrInt_USART1_TX, // 35
|
||||
gAvrInt_TWI, // 36
|
||||
gAvrInt_SPM_READY, // 37
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//**************************************************************************************************
|
||||
#if defined (__AVR_ATmega128RFA1__)
|
||||
#pragma mark __AVR_ATmega128RFA1__
|
||||
#define _INTERRUPT_NAMES_DEFINED_
|
||||
|
||||
PGM_P gInterruptNameTable[] PROGMEM =
|
||||
{
|
||||
//* Atmel changed the number scheme for interrupt vectors
|
||||
gAvrInt_RESET, // 0
|
||||
gAvrInt_INT0, // 1
|
||||
gAvrInt_INT1, // 2
|
||||
gAvrInt_INT2, // 3
|
||||
gAvrInt_INT3, // 4
|
||||
gAvrInt_INT4, // 5
|
||||
gAvrInt_INT5, // 6
|
||||
gAvrInt_INT6, // 7
|
||||
gAvrInt_INT7, // 8
|
||||
gAvrInt_PCINT0, // 9
|
||||
gAvrInt_PCINT1, // 10
|
||||
gAvrInt_PCINT2, // 11
|
||||
gAvrInt_WDT, // 12
|
||||
gAvrInt_TIMER2_COMPA, // 13
|
||||
gAvrInt_TIMER2_COMPB, // 14
|
||||
gAvrInt_TIMER2_OVF, // 15
|
||||
gAvrInt_TIMER1_CAPT, // 16
|
||||
gAvrInt_TIMER1_COMPA, // 17
|
||||
gAvrInt_TIMER1_COMPB, // 18
|
||||
gAvrInt_TIMER1_COMPC, // 19
|
||||
gAvrInt_TIMER1_OVF, // 20
|
||||
gAvrInt_TIMER0_COMPA, // 21
|
||||
gAvrInt_TIMER0_COMPB, // 22
|
||||
gAvrInt_TIMER0_OVF, // 23
|
||||
gAvrInt_SPI_STC, // 24
|
||||
gAvrInt_USART0_RX, // 25
|
||||
gAvrInt_USART0_UDRE, // 26
|
||||
gAvrInt_USART0_TX, // 27
|
||||
gAvrInt_ANALOG_COMP, // 28
|
||||
gAvrInt_ADC, // 29
|
||||
gAvrInt_EE_READY, // 30
|
||||
gAvrInt_TIMER3_CAPT, // 31
|
||||
gAvrInt_TIMER3_COMPA, // 32
|
||||
gAvrInt_TIMER3_COMPB, // 33
|
||||
gAvrInt_TIMER3_COMPC, // 34
|
||||
gAvrInt_TIMER3_OVF, // 35
|
||||
gAvrInt_USART1_RX, // 36
|
||||
gAvrInt_USART1_UDRE, // 37
|
||||
gAvrInt_USART1_TX, // 38
|
||||
gAvrInt_TWI, // 39
|
||||
gAvrInt_SPM_READY, // 40
|
||||
gAvrInt_TIMER4_CAPT, // 41
|
||||
gAvrInt_TIMER4_COMPA, // 42
|
||||
gAvrInt_TIMER4_COMPB, // 43
|
||||
gAvrInt_TIMER4_COMPC, // 44
|
||||
gAvrInt_TIMER4_OVF, // 45
|
||||
gAvrInt_TIMER5_CAPT, // 46
|
||||
gAvrInt_TIMER5_COMPA, // 47
|
||||
gAvrInt_TIMER5_COMPB, // 48
|
||||
gAvrInt_TIMER5_COMPC, // 49
|
||||
gAvrInt_TIMER5_OVF, // 50
|
||||
#if 1
|
||||
gAvrInt_RESERVED, // 51
|
||||
gAvrInt_RESERVED, // 52
|
||||
gAvrInt_RESERVED, // 53
|
||||
|
||||
gAvrInt_RESERVED, // 54
|
||||
gAvrInt_RESERVED, // 55
|
||||
gAvrInt_RESERVED, // 56
|
||||
|
||||
#else
|
||||
gAvrInt_USART2_RX, // 51
|
||||
gAvrInt_USART2_UDRE, // 52
|
||||
gAvrInt_USART2_TX, // 53
|
||||
|
||||
gAvrInt_USART3_RX, // 54
|
||||
gAvrInt_USART3_UDRE, // 55
|
||||
gAvrInt_USART3_TX, // 56
|
||||
#endif
|
||||
gAvrInt_TRN_PLL_LOCK, // 57
|
||||
gAvrInt_TRN_PLL_UNLOCK, // 58
|
||||
gAvrInt_TRN_RX_START, // 59
|
||||
gAvrInt_TRN_RX_END, // 60
|
||||
gAvrInt_TRN_CAAED_DONE, // 61
|
||||
gAvrInt_TRN_FRAME_MATCH,// 62
|
||||
gAvrInt_TRN_TX_END, // 63
|
||||
gAvrInt_TRN_AWAKE, // 64
|
||||
|
||||
gAvrInt_SCNT_CMP1, // 65
|
||||
gAvrInt_SCNT_CMP2, // 66
|
||||
gAvrInt_SCNT_CMP3, // 67
|
||||
gAvrInt_SCNT_OVFL, // 68
|
||||
gAvrInt_SCNT_BACKOFF, // 69
|
||||
gAvrInt_AES_READY, // 70
|
||||
gAvrInt_BAT_LOW, // 71
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(_INTERRUPT_NAMES_DEFINED_)
|
||||
#warning No interrupt string defs for this cpu
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -79,9 +79,27 @@ LICENSE:
|
|||
//* Jul 29, 2010 <MLS> Added recchar_timeout for timing out on bootloading
|
||||
//* Aug 23, 2010 <MLS> Added support for atmega2561
|
||||
//* Aug 26, 2010 <MLS> Removed support for BOOT_BY_SWITCH
|
||||
//* Sep 8, 2010 <MLS> Added support for atmega16
|
||||
//* Nov 9, 2010 <MLS> Issue 392:Fixed bug that 3 !!! in code would cause it to jump to monitor
|
||||
//* Jun 24, 2011 <MLS> Removed analogRead (was not used)
|
||||
//* Dec 29, 2011 <MLS> Issue 181: added watch dog timmer support
|
||||
//* Dec 29, 2011 <MLS> Issue 505: bootloader is comparing the seqNum to 1 or the current sequence
|
||||
//* Jan 1, 2012 <MLS> Issue 543: CMD_CHIP_ERASE_ISP now returns STATUS_CMD_FAILED instead of STATUS_CMD_OK
|
||||
//* Jan 1, 2012 <MLS> Issue 543: Write EEPROM now does something (NOT TESTED)
|
||||
//* Jan 1, 2012 <MLS> Issue 544: stk500v2 bootloader doesn't support reading fuses
|
||||
//************************************************************************
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//* these are used to test issues
|
||||
//* http://code.google.com/p/arduino/issues/detail?id=505
|
||||
//* Reported by mark.stubbs, Mar 14, 2011
|
||||
//* The STK500V2 bootloader is comparing the seqNum to 1 or the current sequence
|
||||
//* (IE: Requiring the sequence to be 1 or match seqNum before continuing).
|
||||
//* The correct behavior is for the STK500V2 to accept the PC's sequence number, and echo it back for the reply message.
|
||||
#define _FIX_ISSUE_505_
|
||||
//************************************************************************
|
||||
//* Issue 181: added watch dog timmer support
|
||||
#define _FIX_ISSUE_181_
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <avr/io.h>
|
||||
|
@ -95,11 +113,20 @@ LICENSE:
|
|||
#include "command.h"
|
||||
|
||||
|
||||
#if defined(_MEGA_BOARD_) || defined(_BOARD_AMBER128_) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
|
||||
#if defined(_MEGA_BOARD_) || defined(_BOARD_AMBER128_) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) \
|
||||
|| defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1284P__) || defined(ENABLE_MONITOR)
|
||||
#undef ENABLE_MONITOR
|
||||
#define ENABLE_MONITOR
|
||||
static void RunMonitor(void);
|
||||
#endif
|
||||
|
||||
#ifndef EEWE
|
||||
#define EEWE 1
|
||||
#endif
|
||||
#ifndef EEMWE
|
||||
#define EEMWE 2
|
||||
#endif
|
||||
|
||||
//#define _DEBUG_SERIAL_
|
||||
//#define _DEBUG_WITH_LEDS_
|
||||
|
||||
|
@ -131,8 +158,8 @@ LICENSE:
|
|||
#define PROGLED_PORT PORTD
|
||||
#define PROGLED_DDR DDRD
|
||||
#define PROGLED_PIN PINE7
|
||||
#elif defined( _CEREBOTPLUS_BOARD_ )
|
||||
//* this is for the Cerebot 2560 board
|
||||
#elif defined( _CEREBOTPLUS_BOARD_ ) || defined(_CEREBOT_II_BOARD_)
|
||||
//* this is for the Cerebot 2560 board and the Cerebot-ii
|
||||
//* onbarod leds are on PORTE4-7
|
||||
#define PROGLED_PORT PORTE
|
||||
#define PROGLED_DDR DDRE
|
||||
|
@ -149,6 +176,47 @@ LICENSE:
|
|||
#define PROGLED_PORT PORTA
|
||||
#define PROGLED_DDR DDRA
|
||||
#define PROGLED_PIN PINA3
|
||||
#elif defined( _BOARD_MEGA16 )
|
||||
//* onbarod led is PORTA7
|
||||
#define PROGLED_PORT PORTA
|
||||
#define PROGLED_DDR DDRA
|
||||
#define PROGLED_PIN PINA7
|
||||
#define UART_BAUDRATE_DOUBLE_SPEED 0
|
||||
|
||||
#elif defined( _BOARD_BAHBOT_ )
|
||||
//* dosent have an onboard LED but this is what will probably be added to this port
|
||||
#define PROGLED_PORT PORTB
|
||||
#define PROGLED_DDR DDRB
|
||||
#define PROGLED_PIN PINB0
|
||||
|
||||
#elif defined( _BOARD_ROBOTX_ )
|
||||
#define PROGLED_PORT PORTB
|
||||
#define PROGLED_DDR DDRB
|
||||
#define PROGLED_PIN PINB6
|
||||
#elif defined( _BOARD_CUSTOM1284_BLINK_B0_ )
|
||||
#define PROGLED_PORT PORTB
|
||||
#define PROGLED_DDR DDRB
|
||||
#define PROGLED_PIN PINB0
|
||||
#elif defined( _BOARD_CUSTOM1284_ )
|
||||
#define PROGLED_PORT PORTD
|
||||
#define PROGLED_DDR DDRD
|
||||
#define PROGLED_PIN PIND5
|
||||
#elif defined( _AVRLIP_ )
|
||||
#define PROGLED_PORT PORTB
|
||||
#define PROGLED_DDR DDRB
|
||||
#define PROGLED_PIN PINB5
|
||||
#elif defined( _BOARD_STK500_ )
|
||||
#define PROGLED_PORT PORTA
|
||||
#define PROGLED_DDR DDRA
|
||||
#define PROGLED_PIN PINA7
|
||||
#elif defined( _BOARD_STK502_ )
|
||||
#define PROGLED_PORT PORTB
|
||||
#define PROGLED_DDR DDRB
|
||||
#define PROGLED_PIN PINB5
|
||||
#elif defined( _BOARD_STK525_ )
|
||||
#define PROGLED_PORT PORTB
|
||||
#define PROGLED_DDR DDRB
|
||||
#define PROGLED_PIN PINB7
|
||||
#else
|
||||
#define PROGLED_PORT PORTG
|
||||
#define PROGLED_DDR DDRG
|
||||
|
@ -164,6 +232,7 @@ LICENSE:
|
|||
#define F_CPU 16000000UL
|
||||
#endif
|
||||
|
||||
#define _BLINK_LOOP_COUNT_ (F_CPU / 2250)
|
||||
/*
|
||||
* UART Baudrate, AVRStudio AVRISP only accepts 115200 bps
|
||||
*/
|
||||
|
@ -228,12 +297,33 @@ LICENSE:
|
|||
#define SIGNATURE_BYTES 0x1E9801
|
||||
#elif defined (__AVR_ATmega2561__)
|
||||
#define SIGNATURE_BYTES 0x1e9802
|
||||
#elif defined (__AVR_ATmega1284P__)
|
||||
#define SIGNATURE_BYTES 0x1e9705
|
||||
#elif defined (__AVR_ATmega640__)
|
||||
#define SIGNATURE_BYTES 0x1e9608
|
||||
#elif defined (__AVR_ATmega64__)
|
||||
#define SIGNATURE_BYTES 0x1E9602
|
||||
#elif defined (__AVR_ATmega169__)
|
||||
#define SIGNATURE_BYTES 0x1e9405
|
||||
#elif defined (__AVR_AT90USB1287__)
|
||||
#define SIGNATURE_BYTES 0x1e9782
|
||||
#else
|
||||
#error "no signature definition for MCU available"
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \
|
||||
#if defined(_BOARD_ROBOTX_) || defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__)
|
||||
#define UART_BAUD_RATE_LOW UBRR1L
|
||||
#define UART_STATUS_REG UCSR1A
|
||||
#define UART_CONTROL_REG UCSR1B
|
||||
#define UART_ENABLE_TRANSMITTER TXEN1
|
||||
#define UART_ENABLE_RECEIVER RXEN1
|
||||
#define UART_TRANSMIT_COMPLETE TXC1
|
||||
#define UART_RECEIVE_COMPLETE RXC1
|
||||
#define UART_DATA_REG UDR1
|
||||
#define UART_DOUBLE_SPEED U2X1
|
||||
|
||||
#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega8535__)
|
||||
/* ATMega8 with one USART */
|
||||
#define UART_BAUD_RATE_LOW UBRRL
|
||||
|
@ -258,6 +348,28 @@ LICENSE:
|
|||
#define UART_RECEIVE_COMPLETE RXC0
|
||||
#define UART_DATA_REG UDR0
|
||||
#define UART_DOUBLE_SPEED U2X0
|
||||
#elif defined(UBRR0L) && defined(UCSR0A) && defined(TXEN0)
|
||||
/* ATMega with two USART, use UART0 */
|
||||
#define UART_BAUD_RATE_LOW UBRR0L
|
||||
#define UART_STATUS_REG UCSR0A
|
||||
#define UART_CONTROL_REG UCSR0B
|
||||
#define UART_ENABLE_TRANSMITTER TXEN0
|
||||
#define UART_ENABLE_RECEIVER RXEN0
|
||||
#define UART_TRANSMIT_COMPLETE TXC0
|
||||
#define UART_RECEIVE_COMPLETE RXC0
|
||||
#define UART_DATA_REG UDR0
|
||||
#define UART_DOUBLE_SPEED U2X0
|
||||
#elif defined(UBRRL) && defined(UCSRA) && defined(UCSRB) && defined(TXEN) && defined(RXEN)
|
||||
//* catch all
|
||||
#define UART_BAUD_RATE_LOW UBRRL
|
||||
#define UART_STATUS_REG UCSRA
|
||||
#define UART_CONTROL_REG UCSRB
|
||||
#define UART_ENABLE_TRANSMITTER TXEN
|
||||
#define UART_ENABLE_RECEIVER RXEN
|
||||
#define UART_TRANSMIT_COMPLETE TXC
|
||||
#define UART_RECEIVE_COMPLETE RXC
|
||||
#define UART_DATA_REG UDR
|
||||
#define UART_DOUBLE_SPEED U2X
|
||||
#else
|
||||
#error "no UART definition for MCU available"
|
||||
#endif
|
||||
|
@ -323,26 +435,16 @@ void __jumpMain(void)
|
|||
|
||||
asm volatile ( ".set __stack, %0" :: "i" (RAMEND) );
|
||||
|
||||
// ldi r16,high(RAMEND)
|
||||
// out SPH,r16 ; Set stack pointer to top of RAM
|
||||
//* set stack pointer to top of RAM
|
||||
|
||||
// asm volatile ( "ldi 16, 0x10");
|
||||
asm volatile ( "ldi 16, %0" :: "i" (RAMEND >> 8) );
|
||||
// asm volatile ( "out 0x3E,16");
|
||||
// asm volatile ( "out %0,16" :: "i" (SPH_REG) );
|
||||
asm volatile ( "out %0,16" :: "i" (AVR_STACK_POINTER_HI_ADDR) );
|
||||
|
||||
// asm volatile ( "ldi 16, 0x00");
|
||||
asm volatile ( "ldi 16, %0" :: "i" (RAMEND & 0x0ff) );
|
||||
// asm volatile ( "out 0x3d,16");
|
||||
// asm volatile ( "out %0,16" :: "i" (SPL_REG) );
|
||||
asm volatile ( "out %0,16" :: "i" (AVR_STACK_POINTER_LO_ADDR) );
|
||||
|
||||
|
||||
|
||||
asm volatile ( "clr __zero_reg__" ); // GCC depends on register r1 set to 0
|
||||
asm volatile ( "out %0, __zero_reg__" :: "I" (_SFR_IO_ADDR(SREG)) ); // set SREG to 0
|
||||
// asm volatile ( "rjmp main"); // jump to main()
|
||||
asm volatile ( "jmp main"); // jump to main()
|
||||
}
|
||||
|
||||
|
@ -403,7 +505,7 @@ uint32_t count = 0;
|
|||
if (count > MAX_TIME_COUNT)
|
||||
{
|
||||
unsigned int data;
|
||||
#if (FLASHEND > 0x0FFFF)
|
||||
#if (FLASHEND > 0x10000)
|
||||
data = pgm_read_word_far(0); //* get the first word of the user program
|
||||
#else
|
||||
data = pgm_read_word_near(0); //* get the first word of the user program
|
||||
|
@ -422,6 +524,8 @@ uint32_t count = 0;
|
|||
return UART_DATA_REG;
|
||||
}
|
||||
|
||||
//* for watch dog timer startup
|
||||
void (*app_start)(void) = 0x0000;
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
|
@ -442,7 +546,36 @@ int main(void)
|
|||
unsigned long boot_timer;
|
||||
unsigned int boot_state;
|
||||
#ifdef ENABLE_MONITOR
|
||||
unsigned int exPointCntr = 0;
|
||||
unsigned int exPointCntr = 0;
|
||||
unsigned int rcvdCharCntr = 0;
|
||||
#endif
|
||||
|
||||
//* some chips dont set the stack properly
|
||||
asm volatile ( ".set __stack, %0" :: "i" (RAMEND) );
|
||||
asm volatile ( "ldi 16, %0" :: "i" (RAMEND >> 8) );
|
||||
asm volatile ( "out %0,16" :: "i" (AVR_STACK_POINTER_HI_ADDR) );
|
||||
asm volatile ( "ldi 16, %0" :: "i" (RAMEND & 0x0ff) );
|
||||
asm volatile ( "out %0,16" :: "i" (AVR_STACK_POINTER_LO_ADDR) );
|
||||
|
||||
#ifdef _FIX_ISSUE_181_
|
||||
//************************************************************************
|
||||
//* Dec 29, 2011 <MLS> Issue #181, added watch dog timmer support
|
||||
//* handle the watch dog timer
|
||||
uint8_t mcuStatusReg;
|
||||
mcuStatusReg = MCUSR;
|
||||
|
||||
__asm__ __volatile__ ("cli");
|
||||
__asm__ __volatile__ ("wdr");
|
||||
MCUSR = 0;
|
||||
WDTCSR |= _BV(WDCE) | _BV(WDE);
|
||||
WDTCSR = 0;
|
||||
__asm__ __volatile__ ("sei");
|
||||
// check if WDT generated the reset, if so, go straight to app
|
||||
if (mcuStatusReg & _BV(WDRF))
|
||||
{
|
||||
app_start();
|
||||
}
|
||||
//************************************************************************
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -450,8 +583,9 @@ int main(void)
|
|||
boot_state = 0;
|
||||
|
||||
#ifdef BLINK_LED_WHILE_WAITING
|
||||
boot_timeout = 20000; //* should be about 1 second
|
||||
// boot_timeout = 90000; //* should be about 4 seconds
|
||||
// boot_timeout = 170000;
|
||||
boot_timeout = 20000; //* should be about 1 second
|
||||
#else
|
||||
boot_timeout = 3500000; // 7 seconds , approx 2us per step when optimize "s"
|
||||
#endif
|
||||
|
@ -516,7 +650,7 @@ int main(void)
|
|||
boot_state = 1; // (after ++ -> boot_state=2 bootloader timeout, jump to main 0x00000 )
|
||||
}
|
||||
#ifdef BLINK_LED_WHILE_WAITING
|
||||
if ((boot_timer % 7000) == 0)
|
||||
if ((boot_timer % _BLINK_LOOP_COUNT_) == 0)
|
||||
{
|
||||
//* toggle the LED
|
||||
PROGLED_PORT ^= (1<<PROGLED_PIN); // turn LED ON
|
||||
|
@ -547,10 +681,13 @@ int main(void)
|
|||
{
|
||||
// c = recchar();
|
||||
c = recchar_timeout();
|
||||
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MONITOR
|
||||
if (c == '!')
|
||||
rcvdCharCntr++;
|
||||
|
||||
if ((c == '!') && (rcvdCharCntr < 10))
|
||||
{
|
||||
exPointCntr++;
|
||||
if (exPointCntr == 3)
|
||||
|
@ -579,6 +716,11 @@ int main(void)
|
|||
break;
|
||||
|
||||
case ST_GET_SEQ_NUM:
|
||||
#ifdef _FIX_ISSUE_505_
|
||||
seqNum = c;
|
||||
msgParseState = ST_MSG_SIZE_1;
|
||||
checksum ^= c;
|
||||
#else
|
||||
if ( (c == 1) || (c == seqNum) )
|
||||
{
|
||||
seqNum = c;
|
||||
|
@ -589,6 +731,7 @@ int main(void)
|
|||
{
|
||||
msgParseState = ST_START;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case ST_MSG_SIZE_1:
|
||||
|
@ -655,20 +798,41 @@ int main(void)
|
|||
unsigned char signatureIndex = msgBuffer[6];
|
||||
|
||||
if ( signatureIndex == 0 )
|
||||
answerByte = (SIGNATURE_BYTES >>16) & 0x000000FF;
|
||||
{
|
||||
answerByte = (SIGNATURE_BYTES >> 16) & 0x000000FF;
|
||||
}
|
||||
else if ( signatureIndex == 1 )
|
||||
{
|
||||
answerByte = (SIGNATURE_BYTES >> 8) & 0x000000FF;
|
||||
}
|
||||
else
|
||||
{
|
||||
answerByte = SIGNATURE_BYTES & 0x000000FF;
|
||||
}
|
||||
}
|
||||
else if ( msgBuffer[4] & 0x50 )
|
||||
{
|
||||
answerByte = 0; //read fuse/lock bits not implemented, return dummy value
|
||||
//* Issue 544: stk500v2 bootloader doesn't support reading fuses
|
||||
//* I cant find the docs that say what these are supposed to be but this was figured out by trial and error
|
||||
// answerByte = boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS);
|
||||
// answerByte = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);
|
||||
// answerByte = boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS);
|
||||
if (msgBuffer[4] == 0x50)
|
||||
{
|
||||
answerByte = boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS);
|
||||
}
|
||||
else if (msgBuffer[4] == 0x58)
|
||||
{
|
||||
answerByte = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);
|
||||
}
|
||||
else
|
||||
{
|
||||
answerByte = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
answerByte = 0; // for all others command are not implemented, return dummy value for AVRDUDE happy <Worapoht>
|
||||
// flag = 1; // Remark this line for AVRDUDE <Worapoht>
|
||||
}
|
||||
if ( !flag )
|
||||
{
|
||||
|
@ -804,7 +968,8 @@ int main(void)
|
|||
case CMD_CHIP_ERASE_ISP:
|
||||
eraseAddress = 0;
|
||||
msgLength = 2;
|
||||
msgBuffer[1] = STATUS_CMD_OK;
|
||||
// msgBuffer[1] = STATUS_CMD_OK;
|
||||
msgBuffer[1] = STATUS_CMD_FAILED; //* isue 543, return FAILED instead of OK
|
||||
break;
|
||||
|
||||
case CMD_LOAD_ADDRESS:
|
||||
|
@ -855,7 +1020,9 @@ int main(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
#if (!defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) && !defined(__AVR_ATmega2561__))
|
||||
//* issue 543, this should work, It has not been tested.
|
||||
// #if (!defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) && !defined(__AVR_ATmega2561__) && !defined(__AVR_ATmega1284P__) && !defined(__AVR_ATmega640__))
|
||||
#if (defined(EEARL) && defined(EEARH) && defined(EEMWE) && defined(EEWE) && defined(EEDR))
|
||||
/* write EEPROM */
|
||||
do {
|
||||
EEARL = address; // Setup EEPROM address
|
||||
|
@ -890,11 +1057,12 @@ int main(void)
|
|||
|
||||
// Read FLASH
|
||||
do {
|
||||
#if defined(RAMPZ)
|
||||
//#if defined(RAMPZ)
|
||||
#if (FLASHEND > 0x10000)
|
||||
data = pgm_read_word_far(address);
|
||||
#else
|
||||
#else
|
||||
data = pgm_read_word_near(address);
|
||||
#endif
|
||||
#endif
|
||||
*p++ = (unsigned char)data; //LSB
|
||||
*p++ = (unsigned char)(data >> 8); //MSB
|
||||
address += 2; // Select next word in memory
|
||||
|
@ -1056,16 +1224,10 @@ unsigned long gEepromIndex;
|
|||
#define true 1
|
||||
#define false 0
|
||||
|
||||
#if defined(__AVR_ATmega128__)
|
||||
#define kCPU_NAME "ATmega128"
|
||||
#elif defined(__AVR_ATmega1280__)
|
||||
#define kCPU_NAME "ATmega1280"
|
||||
#elif defined(__AVR_ATmega1281__)
|
||||
#define kCPU_NAME "ATmega1281"
|
||||
#elif defined(__AVR_ATmega2560__)
|
||||
#define kCPU_NAME "ATmega2560"
|
||||
#elif defined(__AVR_ATmega2561__)
|
||||
#define kCPU_NAME "ATmega2561"
|
||||
#include "avr_cpunames.h"
|
||||
|
||||
#ifndef _AVR_CPU_NAME_
|
||||
#error cpu name not defined
|
||||
#endif
|
||||
|
||||
#ifdef _VECTORS_SIZE
|
||||
|
@ -1077,8 +1239,8 @@ unsigned long gEepromIndex;
|
|||
|
||||
void PrintDecInt(int theNumber, int digitCnt);
|
||||
|
||||
#ifdef kCPU_NAME
|
||||
prog_char gTextMsg_CPU_Name[] PROGMEM = kCPU_NAME;
|
||||
#ifdef _AVR_CPU_NAME_
|
||||
prog_char gTextMsg_CPU_Name[] PROGMEM = _AVR_CPU_NAME_;
|
||||
#else
|
||||
prog_char gTextMsg_CPU_Name[] PROGMEM = "UNKNOWN";
|
||||
#endif
|
||||
|
@ -1086,16 +1248,16 @@ void PrintDecInt(int theNumber, int digitCnt);
|
|||
prog_char gTextMsg_Explorer[] PROGMEM = "Arduino explorer stk500V2 by MLS";
|
||||
prog_char gTextMsg_Prompt[] PROGMEM = "Bootloader>";
|
||||
prog_char gTextMsg_HUH[] PROGMEM = "Huh?";
|
||||
prog_char gTextMsg_COMPILED_ON[] PROGMEM = "Compiled on = ";
|
||||
prog_char gTextMsg_CPU_Type[] PROGMEM = "CPU Type = ";
|
||||
prog_char gTextMsg_AVR_ARCH[] PROGMEM = "__AVR_ARCH__ = ";
|
||||
prog_char gTextMsg_AVR_LIBC[] PROGMEM = "AVR LibC Ver = ";
|
||||
prog_char gTextMsg_GCC_VERSION[] PROGMEM = "GCC Version = ";
|
||||
prog_char gTextMsg_CPU_SIGNATURE[] PROGMEM = "CPU signature= ";
|
||||
prog_char gTextMsg_FUSE_BYTE_LOW[] PROGMEM = "Low fuse = ";
|
||||
prog_char gTextMsg_FUSE_BYTE_HIGH[] PROGMEM = "High fuse = ";
|
||||
prog_char gTextMsg_FUSE_BYTE_EXT[] PROGMEM = "Ext fuse = ";
|
||||
prog_char gTextMsg_FUSE_BYTE_LOCK[] PROGMEM = "Lock fuse = ";
|
||||
prog_char gTextMsg_COMPILED_ON[] PROGMEM = "Compiled on = ";
|
||||
prog_char gTextMsg_CPU_Type[] PROGMEM = "CPU Type = ";
|
||||
prog_char gTextMsg_AVR_ARCH[] PROGMEM = "__AVR_ARCH__= ";
|
||||
prog_char gTextMsg_AVR_LIBC[] PROGMEM = "AVR LibC Ver= ";
|
||||
prog_char gTextMsg_GCC_VERSION[] PROGMEM = "GCC Version = ";
|
||||
prog_char gTextMsg_CPU_SIGNATURE[] PROGMEM = "CPU ID = ";
|
||||
prog_char gTextMsg_FUSE_BYTE_LOW[] PROGMEM = "Low fuse = ";
|
||||
prog_char gTextMsg_FUSE_BYTE_HIGH[] PROGMEM = "High fuse = ";
|
||||
prog_char gTextMsg_FUSE_BYTE_EXT[] PROGMEM = "Ext fuse = ";
|
||||
prog_char gTextMsg_FUSE_BYTE_LOCK[] PROGMEM = "Lock fuse = ";
|
||||
prog_char gTextMsg_GCC_DATE_STR[] PROGMEM = __DATE__;
|
||||
prog_char gTextMsg_AVR_LIBC_VER_STR[] PROGMEM = __AVR_LIBC_VERSION_STRING__;
|
||||
prog_char gTextMsg_GCC_VERSION_STR[] PROGMEM = __VERSION__;
|
||||
|
@ -1109,13 +1271,13 @@ void PrintDecInt(int theNumber, int digitCnt);
|
|||
prog_char gTextMsg_SPACE[] PROGMEM = " ";
|
||||
prog_char gTextMsg_WriteToEEprom[] PROGMEM = "Writting EE";
|
||||
prog_char gTextMsg_ReadingEEprom[] PROGMEM = "Reading EE";
|
||||
prog_char gTextMsg_EEPROMerrorCnt[] PROGMEM = "eeprom error count=";
|
||||
prog_char gTextMsg_EEPROMerrorCnt[] PROGMEM = "EE err cnt=";
|
||||
prog_char gTextMsg_PORT[] PROGMEM = "PORT";
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//* Help messages
|
||||
prog_char gTextMsg_HELP_MSG_0[] PROGMEM = "0=Zero address ctrs";
|
||||
prog_char gTextMsg_HELP_MSG_0[] PROGMEM = "0=Zero addr";
|
||||
prog_char gTextMsg_HELP_MSG_QM[] PROGMEM = "?=CPU stats";
|
||||
prog_char gTextMsg_HELP_MSG_AT[] PROGMEM = "@=EEPROM test";
|
||||
prog_char gTextMsg_HELP_MSG_B[] PROGMEM = "B=Blink LED";
|
||||
|
@ -1123,7 +1285,8 @@ void PrintDecInt(int theNumber, int digitCnt);
|
|||
prog_char gTextMsg_HELP_MSG_F[] PROGMEM = "F=Dump FLASH";
|
||||
prog_char gTextMsg_HELP_MSG_H[] PROGMEM = "H=Help";
|
||||
prog_char gTextMsg_HELP_MSG_L[] PROGMEM = "L=List I/O Ports";
|
||||
prog_char gTextMsg_HELP_MSG_Q[] PROGMEM = "Q=Quit & jump to user pgm";
|
||||
// prog_char gTextMsg_HELP_MSG_Q[] PROGMEM = "Q=Quit & jump to user pgm";
|
||||
prog_char gTextMsg_HELP_MSG_Q[] PROGMEM = "Q=Quit";
|
||||
prog_char gTextMsg_HELP_MSG_R[] PROGMEM = "R=Dump RAM";
|
||||
prog_char gTextMsg_HELP_MSG_V[] PROGMEM = "V=show interrupt Vectors";
|
||||
prog_char gTextMsg_HELP_MSG_Y[] PROGMEM = "Y=Port blink";
|
||||
|
@ -1142,7 +1305,11 @@ char theChar;
|
|||
|
||||
while (theChar != 0)
|
||||
{
|
||||
#if (FLASHEND > 0x10000)
|
||||
theChar = pgm_read_byte_far((uint32_t)dataPtr + ii);
|
||||
#else
|
||||
theChar = pgm_read_byte_near((uint32_t)dataPtr + ii);
|
||||
#endif
|
||||
if (theChar != 0)
|
||||
{
|
||||
sendchar(theChar);
|
||||
|
@ -1293,46 +1460,6 @@ unsigned char fuseByte;
|
|||
|
||||
}
|
||||
|
||||
#ifndef sbi
|
||||
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
|
||||
#endif
|
||||
|
||||
//************************************************************************
|
||||
int analogRead(uint8_t pin)
|
||||
{
|
||||
uint8_t low, high;
|
||||
|
||||
// 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).
|
||||
// ADMUX = (analog_reference << 6) | (pin & 0x07);
|
||||
ADMUX = (1 << 6) | (pin & 0x07);
|
||||
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||
// 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)) | (((pin >> 3) & 0x01) << MUX5);
|
||||
#endif
|
||||
|
||||
// without a delay, we seem to read from the wrong channel
|
||||
//delay(1);
|
||||
|
||||
// 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;
|
||||
|
||||
// combine the two bytes
|
||||
return (high << 8) | low;
|
||||
}
|
||||
|
||||
//************************************************************************
|
||||
static void BlinkLED(void)
|
||||
|
@ -1388,7 +1515,11 @@ unsigned char *ramPtr;
|
|||
switch(dumpWhat)
|
||||
{
|
||||
case kDUMP_FLASH:
|
||||
#if (FLASHEND > 0x10000)
|
||||
theValue = pgm_read_byte_far(myAddressPointer);
|
||||
#else
|
||||
theValue = pgm_read_byte_near(myAddressPointer);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case kDUMP_EEPROM:
|
||||
|
@ -1435,7 +1566,11 @@ int errorCount;
|
|||
PrintFromPROGMEMln(gTextMsg_WriteToEEprom, 0);
|
||||
PrintNewLine();
|
||||
ii = 0;
|
||||
#if (FLASHEND > 0x10000)
|
||||
while (((theChar = pgm_read_byte_far(gTextMsg_Explorer + ii)) != '*') && (ii < 512))
|
||||
#else
|
||||
while (((theChar = pgm_read_byte_near(gTextMsg_Explorer + ii)) != '*') && (ii < 512))
|
||||
#endif
|
||||
{
|
||||
eeprom_write_byte((uint8_t *)ii, theChar);
|
||||
if (theChar == 0)
|
||||
|
@ -1456,7 +1591,11 @@ int errorCount;
|
|||
PrintNewLine();
|
||||
errorCount = 0;
|
||||
ii = 0;
|
||||
#if (FLASHEND > 0x10000)
|
||||
while (((theChar = pgm_read_byte_far(gTextMsg_Explorer + ii)) != '*') && (ii < 512))
|
||||
#else
|
||||
while (((theChar = pgm_read_byte_near(gTextMsg_Explorer + ii)) != '*') && (ii < 512))
|
||||
#endif
|
||||
{
|
||||
theEEPROMchar = eeprom_read_byte((uint8_t *)ii);
|
||||
if (theEEPROMchar == 0)
|
||||
|
@ -1487,10 +1626,12 @@ int errorCount;
|
|||
|
||||
|
||||
#if (FLASHEND > 0x08000)
|
||||
#include "avrinterruptnames.h"
|
||||
#ifndef _INTERRUPT_NAMES_DEFINED_
|
||||
#warning Interrupt vectors not defined
|
||||
#endif
|
||||
//* this includes the interrupt names for the monitor portion. There is no longer enough
|
||||
//* memory to include this
|
||||
// #include "avrinterruptnames.h"
|
||||
// #ifndef _INTERRUPT_NAMES_DEFINED_
|
||||
// #warning Interrupt vectors not defined
|
||||
// #endif
|
||||
#endif
|
||||
|
||||
//************************************************************************
|
||||
|
@ -1534,12 +1675,18 @@ unsigned long absoluteAddr;
|
|||
|
||||
|
||||
//* the AVR is LITTLE ENDIAN, swap the byte order
|
||||
#if (FLASHEND > 0x10000)
|
||||
byte1 = pgm_read_byte_far(myMemoryPtr++);
|
||||
byte2 = pgm_read_byte_far(myMemoryPtr++);
|
||||
word1 = (byte2 << 8) + byte1;
|
||||
|
||||
byte3 = pgm_read_byte_far(myMemoryPtr++);
|
||||
byte4 = pgm_read_byte_far(myMemoryPtr++);
|
||||
#else
|
||||
byte1 = pgm_read_byte_near(myMemoryPtr++);
|
||||
byte2 = pgm_read_byte_near(myMemoryPtr++);
|
||||
byte3 = pgm_read_byte_near(myMemoryPtr++);
|
||||
byte4 = pgm_read_byte_near(myMemoryPtr++);
|
||||
#endif
|
||||
word1 = (byte2 << 8) + byte1;
|
||||
word2 = (byte4 << 8) + byte3;
|
||||
|
||||
|
||||
|
@ -1596,7 +1743,11 @@ unsigned long absoluteAddr;
|
|||
|
||||
#if defined(_INTERRUPT_NAMES_DEFINED_)
|
||||
sendchar(0x20);
|
||||
#if (FLASHEND > 0x10000)
|
||||
stringPointer = pgm_read_word_far(&(gInterruptNameTable[vectorIndex]));
|
||||
#else
|
||||
stringPointer = pgm_read_word_near(&(gInterruptNameTable[vectorIndex]));
|
||||
#endif
|
||||
PrintFromPROGMEM((char *)stringPointer, 0);
|
||||
#endif
|
||||
PrintNewLine();
|
||||
|
@ -1895,13 +2046,7 @@ int ii, jj;
|
|||
{
|
||||
theChar = theChar & 0x5F;
|
||||
}
|
||||
#if defined( _CEREBOTPLUS_BOARD_ )
|
||||
if (theChar == 0x5F)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
if (theChar >= 0x20)
|
||||
{
|
||||
sendchar(theChar);
|
||||
|
@ -1979,12 +2124,6 @@ int ii, jj;
|
|||
AVR_PortOutput();
|
||||
break;
|
||||
|
||||
#if defined( _CEREBOTPLUS_BOARD_ )
|
||||
case 0x5F:
|
||||
//* do nothing
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
PrintFromPROGMEMln(gTextMsg_HUH, 0);
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue