1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-29 10:24:12 +01:00

[SAM] Test app working on SAM3X-EK

This commit is contained in:
Thibault RICHARD 2012-04-28 19:59:24 +02:00
parent fc82f1e556
commit 1d99429752
3 changed files with 17 additions and 8 deletions

View File

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

View File

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

View File

@ -70,7 +70,7 @@ extern const PinDescription g_APinDescription[]=
// 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
} ;
@ -109,9 +109,6 @@ void USART0_Handler( void )
extern "C" {
#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 ) ;
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
}