Skip to content

Commit dc95506

Browse files
committed
Merge branch 'platforms-arm' of https://github.com/arduino/ARM into platforms-arm
2 parents 46b9f96 + 1d99429 commit dc95506

File tree

9 files changed

+100
-52
lines changed

9 files changed

+100
-52
lines changed

hardware/arduino/sam/cores/sam/Arduino.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ typedef struct _PinDescription
175175
EPioType ulPinType ;
176176
uint32_t ulPinConfiguration ;
177177
uint32_t ulPinAttribute ;
178-
EAnalogChannel ulAnalogChannel ; /* Describe which Analog pin is linked to a MCU pin */
179-
EAnalogChannel ulADCChannelNumber ; /* We use the same enum than for ADC pins to describe the ADC channel in use on this pin */
178+
EAnalogChannel ulAnalogChannel ; /* Analog pin in the Arduino context (label on the board) */
179+
EAnalogChannel ulADCChannelNumber ; /* ADC Channel number in the SAM device */
180180
EPWMChannel ulPWMChannel ;
181181
ETCChannel ulTCChannel ;
182182
} PinDescription ;

hardware/arduino/sam/cores/sam/main.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919
#define ARDUINO_MAIN
2020
#include "Arduino.h"
2121

22+
/*
23+
* Cortex-M3 Systick IT handler
24+
*/
25+
extern void SysTick_Handler( void )
26+
{
27+
// Increment tick count each ms
28+
TimeTick_Increment() ;
29+
}
30+
2231
/*
2332
* \brief Main entry point of Arduino application
2433
*/

hardware/arduino/sam/cores/sam/validation/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void loop( void )
8585
// Serial1.write( "test1\n" ) ; // send a string
8686
// Serial1.write( "test2" ) ; // send another string
8787

88-
Serial1.print("Analog ins: ");
88+
Serial1.print("Analog pins: ");
8989
for (int i=A0; i<=MAX_ANALOG; i++) {
9090
int a = analogRead(i);
9191
Serial1.print(a, DEC);

hardware/arduino/sam/cores/sam/wiring.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ void delayMicroseconds( uint32_t dwUs )
5555
}
5656

5757
/*
58-
* Cortex-M3 Systick IT handler
58+
* Cortex-M3 Systick IT handler: MOVED TO MAIN DUE TO WEAK SYMBOL ISSUE NOT RESOLVED
5959
*/
60-
extern void SysTick_Handler( void )
60+
/*extern void SysTick_Handler( void )
6161
{
6262
// Increment tick count each ms
6363
TimeTick_Increment() ;
64-
}
64+
}*/
6565

6666
#if defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
6767
extern signed int putchar( signed int c ) ;
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
#*******************************************************
22
#
3-
# Connect to J-Link and debug application in flash.
3+
# Connect to J-Link and debug application in flash on SAM3X.
44
#
55

6-
# define 'reset' command
6+
# Define 'reset' command
77
define reset
88

99
# Connect to the J-Link gdb server
1010
target remote localhost:2331
11+
1112
# Reset the chip to get to a known state
1213
monitor reset
1314

1415
# Select flash device
15-
monitor flash device = AT91SAM3U4E
16+
monitor flash device = AT91SAM3X8E
17+
1618
# Enable flash download and flash breakpoints
1719
monitor flash download = 1
20+
1821
# Load the program
1922
load
2023

21-
# Reset peripheral (RSTC_CR)
22-
set *0x400e1200 = 0xA5000004
24+
# Reset peripheral (RSTC_CR)
25+
set *0x400e1a00 = 0xA5000004
2326

24-
# Initializing PC and stack pointer
27+
# Initialize PC and stack pointer
2528
mon reg sp=(0x80000)
26-
set *0x80004 = *0x80004 & 0xFFFFFFFE
29+
#set *0x80004 = *0x80004 & 0xFFFFFFFE
2730
mon reg pc=(0x80004)
31+
2832
info reg
2933

3034
break main
3135

32-
# end of 'reset' command
36+
# End of 'reset' command
3337
end
Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,37 @@
1-
#*************************************************
1+
#*******************************************************
22
#
3-
# Connect to J-Link and debug application in sram on SAM3U
3+
# Connect to J-Link and debug application in sram on SAM3X.
44
#
5-
# Note:
6-
# First,users should do Step1 and Step2 according to your project,
7-
# then do Step3.
8-
9-
# Step1: Connect to the J-Link gdb server
10-
#target remote localhost:2331
11-
#mon reset
12-
13-
# Step2: Load file(eg. getting-started project)
14-
#load bin/basic-dhrystone-project-at91sam3u-ek-at91sam3u4-sram.elf
15-
#symbol-file bin/basic-dhrystone-project-at91sam3u-ek-at91sam3u4-sram.elf
16-
17-
# Step3: Initializing PC and stack pointer
18-
# Perpheral reset RSTC_CR
19-
set *0x400e1200 = 0xA5000004
20-
# Modify pc value to even before writing pc register
5+
6+
# Define 'reset' command
7+
define reset
8+
9+
# Connect to the J-Link gdb server
10+
target remote localhost:2331
11+
12+
# Reset the chip to get to a known state
13+
monitor reset
14+
15+
# Select flash device
16+
monitor flash device = AT91SAM3X8E
17+
18+
# Enable flash download and flash breakpoints
19+
monitor flash download = 1
20+
21+
# Load the program
22+
load
23+
24+
# Reset peripheral (RSTC_CR)
25+
set *0x400e1a00 = 0xA5000004
26+
27+
# Initialize PC and stack pointer
2128
mon reg sp=(0x20000000)
22-
set *0x20000004 = *0x20000004 & 0xFFFFFFFE
29+
#set *0x20000004 = *0x20000004 & 0xFFFFFFFE
2330
mon reg pc=(0x20000004)
31+
32+
info reg
33+
34+
break main
35+
36+
# End of 'reset' command
37+
end
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
#*******************************************************
22
#
3-
# Connect to J-Link and debug application in flash.
3+
# Connect to J-Link and debug application in flash on SAM3X.
44
#
55

6-
# define 'reset' command
6+
# Define 'reset' command
77
define reset
88

99
# Connect to the J-Link gdb server
1010
target remote localhost:2331
11+
1112
# Reset the chip to get to a known state
1213
monitor reset
1314

1415
# Select flash device
15-
monitor flash device = AT91SAM3U4E
16+
monitor flash device = AT91SAM3X8H
17+
1618
# Enable flash download and flash breakpoints
1719
monitor flash download = 1
20+
1821
# Load the program
1922
load
2023

21-
# Reset peripheral (RSTC_CR)
22-
set *0x400e1200 = 0xA5000004
24+
# Reset peripheral (RSTC_CR)
25+
set *0x400e1a00 = 0xA5000004
2326

24-
# Initializing PC and stack pointer
27+
# Initialize PC and stack pointer
2528
mon reg sp=(0x80000)
26-
set *0x80004 = *0x80004 & 0xFFFFFFFE
29+
#set *0x80004 = *0x80004 & 0xFFFFFFFE
2730
mon reg pc=(0x80004)
31+
2832
info reg
2933

3034
break main
3135

32-
# end of 'reset' command
36+
# End of 'reset' command
3337
end
Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
11
#*******************************************************
22
#
3-
# Connect to J-Link and debug application in flash.
3+
# Connect to J-Link and debug application in sram on SAM3X.
44
#
55

6-
# define 'reset' command
6+
# Define 'reset' command
77
define reset
88

99
# Connect to the J-Link gdb server
1010
target remote localhost:2331
11+
1112
# Reset the chip to get to a known state
1213
monitor reset
1314

15+
# Select flash device
16+
monitor flash device = AT91SAM3X8H
17+
18+
# Enable flash download and flash breakpoints
19+
monitor flash download = 1
20+
1421
# Load the program
1522
load
1623

17-
# Reset peripheral (RSTC_CR)
18-
set *0x400e1200 = 0xA5000004
24+
# Reset peripheral (RSTC_CR)
25+
set *0x400e1a00 = 0xA5000004
1926

20-
# Initializing PC and stack pointer
27+
# Initialize PC and stack pointer
2128
mon reg sp=(0x20000000)
22-
set *0x20000004 = *0x20000004 & 0xFFFFFFFE
29+
#set *0x20000004 = *0x20000004 & 0xFFFFFFFE
2330
mon reg pc=(0x20000004)
31+
2432
info reg
2533

2634
break main
2735

28-
# end of 'reset' command
36+
# End of 'reset' command
2937
end

hardware/atmel/sam/variants/sam3x_ek/variant.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ extern const PinDescription g_APinDescription[]=
7070

7171
// 10 - Analog pins
7272
// ----------------------
73-
{ PIOA, PIO_PA3, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC0, ADC7, NO_PWM, NO_TC }, // AD0
73+
{ PIOA, PIO_PA3, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC0, ADC1, NO_PWM, NO_TC }, // AD0
7474

7575
{ NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC } // END
7676
} ;
@@ -109,9 +109,6 @@ void USART0_Handler( void )
109109
extern "C" {
110110
#endif
111111

112-
// Should be made in a better way...
113-
extern void analogOutputInit(void);
114-
115112
/**
116113
*
117114
*/
@@ -148,6 +145,18 @@ extern void init( void )
148145
g_APinDescription[PIN_LED_RED].ulPinConfiguration ) ;
149146

150147
PIO_Clear( g_APinDescription[PIN_LED_RED].pPort, g_APinDescription[PIN_LED_RED].ulPin ) ;
148+
149+
// Initialize 10bit Analog Controller
150+
pmc_enable_periph_clk( ID_ADC ) ;
151+
adc_init( ADC, SystemCoreClock, ADC_FREQ_MAX, ADC_STARTUP_FAST ) ;
152+
adc_configure_timing(ADC, 0, ADC_SETTLING_TIME_3, 1);
153+
adc_configure_trigger(ADC, ADC_TRIG_SW, 0); // Disable hardware trigger.
154+
adc_disable_interrupt( ADC, 0xFFFFFFFF ) ; // Disable all ADC interrupts.
155+
adc_disable_all_channel( ADC ) ;
156+
157+
// Initialize analogOutput module
158+
analogOutputInit();
159+
151160
}
152161
#ifdef __cplusplus
153162
}

0 commit comments

Comments
 (0)