Merge branch 'platforms-arm' of https://github.com/arduino/ARM into platforms-arm

This commit is contained in:
Thibaut VIARD 2012-04-29 00:51:47 +02:00
commit dc95506b06
9 changed files with 97 additions and 49 deletions

View File

@ -175,8 +175,8 @@ typedef struct _PinDescription
EPioType ulPinType ; EPioType ulPinType ;
uint32_t ulPinConfiguration ; uint32_t ulPinConfiguration ;
uint32_t ulPinAttribute ; uint32_t ulPinAttribute ;
EAnalogChannel ulAnalogChannel ; /* Describe which Analog pin is linked to a MCU pin */ EAnalogChannel ulAnalogChannel ; /* Analog pin in the Arduino context (label on the board) */
EAnalogChannel ulADCChannelNumber ; /* We use the same enum than for ADC pins to describe the ADC channel in use on this pin */ EAnalogChannel ulADCChannelNumber ; /* ADC Channel number in the SAM device */
EPWMChannel ulPWMChannel ; EPWMChannel ulPWMChannel ;
ETCChannel ulTCChannel ; ETCChannel ulTCChannel ;
} PinDescription ; } PinDescription ;

View File

@ -19,6 +19,15 @@
#define ARDUINO_MAIN #define ARDUINO_MAIN
#include "Arduino.h" #include "Arduino.h"
/*
* Cortex-M3 Systick IT handler
*/
extern void SysTick_Handler( void )
{
// Increment tick count each ms
TimeTick_Increment() ;
}
/* /*
* \brief Main entry point of Arduino application * \brief Main entry point of Arduino application
*/ */

View File

@ -85,7 +85,7 @@ void loop( void )
// Serial1.write( "test1\n" ) ; // send a string // Serial1.write( "test1\n" ) ; // send a string
// Serial1.write( "test2" ) ; // send another string // Serial1.write( "test2" ) ; // send another string
Serial1.print("Analog ins: "); Serial1.print("Analog pins: ");
for (int i=A0; i<=MAX_ANALOG; i++) { for (int i=A0; i<=MAX_ANALOG; i++) {
int a = analogRead(i); int a = analogRead(i);
Serial1.print(a, DEC); Serial1.print(a, DEC);

View File

@ -55,13 +55,13 @@ void delayMicroseconds( uint32_t dwUs )
} }
/* /*
* Cortex-M3 Systick IT handler * Cortex-M3 Systick IT handler: MOVED TO MAIN DUE TO WEAK SYMBOL ISSUE NOT RESOLVED
*/ */
extern void SysTick_Handler( void ) /*extern void SysTick_Handler( void )
{ {
// Increment tick count each ms // Increment tick count each ms
TimeTick_Increment() ; TimeTick_Increment() ;
} }*/
#if defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */ #if defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
extern signed int putchar( signed int c ) ; extern signed int putchar( signed int c ) ;

View File

@ -1,33 +1,37 @@
#******************************************************* #*******************************************************
# #
# Connect to J-Link and debug application in flash. # Connect to J-Link and debug application in flash on SAM3X.
# #
# define 'reset' command # Define 'reset' command
define reset define reset
# Connect to the J-Link gdb server # Connect to the J-Link gdb server
target remote localhost:2331 target remote localhost:2331
# Reset the chip to get to a known state # Reset the chip to get to a known state
monitor reset monitor reset
# Select flash device # Select flash device
monitor flash device = AT91SAM3U4E monitor flash device = AT91SAM3X8E
# Enable flash download and flash breakpoints # Enable flash download and flash breakpoints
monitor flash download = 1 monitor flash download = 1
# Load the program # Load the program
load load
# Reset peripheral (RSTC_CR) # Reset peripheral (RSTC_CR)
set *0x400e1200 = 0xA5000004 set *0x400e1a00 = 0xA5000004
# Initializing PC and stack pointer # Initialize PC and stack pointer
mon reg sp=(0x80000) mon reg sp=(0x80000)
set *0x80004 = *0x80004 & 0xFFFFFFFE #set *0x80004 = *0x80004 & 0xFFFFFFFE
mon reg pc=(0x80004) mon reg pc=(0x80004)
info reg info reg
break main break main
# end of 'reset' command # End of 'reset' command
end end

View File

@ -1,23 +1,37 @@
#************************************************* #*******************************************************
# #
# Connect to J-Link and debug application in sram on SAM3U # Connect to J-Link and debug application in sram on SAM3X.
# #
# Note:
# First,users should do Step1 and Step2 according to your project,
# then do Step3.
# Step1: Connect to the J-Link gdb server # Define 'reset' command
#target remote localhost:2331 define reset
#mon reset
# Step2: Load file(eg. getting-started project) # Connect to the J-Link gdb server
#load bin/basic-dhrystone-project-at91sam3u-ek-at91sam3u4-sram.elf target remote localhost:2331
#symbol-file bin/basic-dhrystone-project-at91sam3u-ek-at91sam3u4-sram.elf
# Step3: Initializing PC and stack pointer # Reset the chip to get to a known state
# Perpheral reset RSTC_CR monitor reset
set *0x400e1200 = 0xA5000004
# Modify pc value to even before writing pc register # Select flash device
monitor flash device = AT91SAM3X8E
# Enable flash download and flash breakpoints
monitor flash download = 1
# Load the program
load
# Reset peripheral (RSTC_CR)
set *0x400e1a00 = 0xA5000004
# Initialize PC and stack pointer
mon reg sp=(0x20000000) mon reg sp=(0x20000000)
set *0x20000004 = *0x20000004 & 0xFFFFFFFE #set *0x20000004 = *0x20000004 & 0xFFFFFFFE
mon reg pc=(0x20000004) mon reg pc=(0x20000004)
info reg
break main
# End of 'reset' command
end

View File

@ -1,33 +1,37 @@
#******************************************************* #*******************************************************
# #
# Connect to J-Link and debug application in flash. # Connect to J-Link and debug application in flash on SAM3X.
# #
# define 'reset' command # Define 'reset' command
define reset define reset
# Connect to the J-Link gdb server # Connect to the J-Link gdb server
target remote localhost:2331 target remote localhost:2331
# Reset the chip to get to a known state # Reset the chip to get to a known state
monitor reset monitor reset
# Select flash device # Select flash device
monitor flash device = AT91SAM3U4E monitor flash device = AT91SAM3X8H
# Enable flash download and flash breakpoints # Enable flash download and flash breakpoints
monitor flash download = 1 monitor flash download = 1
# Load the program # Load the program
load load
# Reset peripheral (RSTC_CR) # Reset peripheral (RSTC_CR)
set *0x400e1200 = 0xA5000004 set *0x400e1a00 = 0xA5000004
# Initializing PC and stack pointer # Initialize PC and stack pointer
mon reg sp=(0x80000) mon reg sp=(0x80000)
set *0x80004 = *0x80004 & 0xFFFFFFFE #set *0x80004 = *0x80004 & 0xFFFFFFFE
mon reg pc=(0x80004) mon reg pc=(0x80004)
info reg info reg
break main break main
# end of 'reset' command # End of 'reset' command
end end

View File

@ -1,29 +1,37 @@
#******************************************************* #*******************************************************
# #
# Connect to J-Link and debug application in flash. # Connect to J-Link and debug application in sram on SAM3X.
# #
# define 'reset' command # Define 'reset' command
define reset define reset
# Connect to the J-Link gdb server # Connect to the J-Link gdb server
target remote localhost:2331 target remote localhost:2331
# Reset the chip to get to a known state # Reset the chip to get to a known state
monitor reset monitor reset
# Select flash device
monitor flash device = AT91SAM3X8H
# Enable flash download and flash breakpoints
monitor flash download = 1
# Load the program # Load the program
load load
# Reset peripheral (RSTC_CR) # Reset peripheral (RSTC_CR)
set *0x400e1200 = 0xA5000004 set *0x400e1a00 = 0xA5000004
# Initializing PC and stack pointer # Initialize PC and stack pointer
mon reg sp=(0x20000000) mon reg sp=(0x20000000)
set *0x20000004 = *0x20000004 & 0xFFFFFFFE #set *0x20000004 = *0x20000004 & 0xFFFFFFFE
mon reg pc=(0x20000004) mon reg pc=(0x20000004)
info reg info reg
break main break main
# end of 'reset' command # End of 'reset' command
end end

View File

@ -70,7 +70,7 @@ extern const PinDescription g_APinDescription[]=
// 10 - Analog pins // 10 - Analog pins
// ---------------------- // ----------------------
{ PIOA, PIO_PA3, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC0, ADC7, NO_PWM, NO_TC }, // AD0 { PIOA, PIO_PA3, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC0, ADC1, NO_PWM, NO_TC }, // AD0
{ NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC } // END { NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC } // END
} ; } ;
@ -109,9 +109,6 @@ void USART0_Handler( void )
extern "C" { extern "C" {
#endif #endif
// Should be made in a better way...
extern void analogOutputInit(void);
/** /**
* *
*/ */
@ -148,6 +145,18 @@ extern void init( void )
g_APinDescription[PIN_LED_RED].ulPinConfiguration ) ; g_APinDescription[PIN_LED_RED].ulPinConfiguration ) ;
PIO_Clear( g_APinDescription[PIN_LED_RED].pPort, g_APinDescription[PIN_LED_RED].ulPin ) ; PIO_Clear( g_APinDescription[PIN_LED_RED].pPort, g_APinDescription[PIN_LED_RED].ulPin ) ;
// Initialize 10bit Analog Controller
pmc_enable_periph_clk( ID_ADC ) ;
adc_init( ADC, SystemCoreClock, ADC_FREQ_MAX, ADC_STARTUP_FAST ) ;
adc_configure_timing(ADC, 0, ADC_SETTLING_TIME_3, 1);
adc_configure_trigger(ADC, ADC_TRIG_SW, 0); // Disable hardware trigger.
adc_disable_interrupt( ADC, 0xFFFFFFFF ) ; // Disable all ADC interrupts.
adc_disable_all_channel( ADC ) ;
// Initialize analogOutput module
analogOutputInit();
} }
#ifdef __cplusplus #ifdef __cplusplus
} }