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

[sam] Fixing arduino_due_x variant

This commit is contained in:
Thibaut VIARD 2012-03-26 18:09:10 +02:00
parent 2aa1f3ea34
commit 042149a9b1
7 changed files with 48 additions and 40 deletions

View File

@ -126,7 +126,11 @@ typedef enum _EPWMChannel
PWM_CH0=0,
PWM_CH1,
PWM_CH2,
PWM_CH3
PWM_CH3,
PWM_CH4,
PWM_CH5,
PWM_CH6,
PWM_CH7
} EPWMChannel ;
// Definitions for TC channels
@ -138,7 +142,19 @@ typedef enum _ETCChannel
TC0_CHA1,
TC0_CHB1,
TC0_CHA2,
TC0_CHB2
TC0_CHB2,
TC1_CHA3,
TC1_CHB3,
TC1_CHA4,
TC1_CHB4,
TC1_CHA5,
TC1_CHB5,
TC2_CHA6,
TC2_CHB6,
TC2_CHA7,
TC2_CHB7,
TC2_CHA8,
TC2_CHB8
} ETCChannel ;
/**

View File

@ -48,7 +48,7 @@ extern "C" {
/**INDENT-ON**/
/// @endcond
#if SAM3S || SAM3N || SAM3XA
#if SAM3S_SERIES || SAM3N_SERIES || SAM3XA_SERIES
/**
* \brief Initializes the given ADC with the specified ADC clock and startup time.
@ -75,8 +75,6 @@ uint32_t adc_init(Adc *p_adc, uint32_t ul_mck, uint32_t ul_adc_clock, uint8_t uc
p_adc->ADC_PTCR = (ADC_PTCR_RXTDIS | ADC_PTCR_TXTDIS);
p_adc->ADC_RCR = 0;
p_adc->ADC_RNCR = 0;
p_adc->ADC_TCR = 0;
p_adc->ADC_TNCR = 0;
ul_prescal = ul_mck/(2 * ul_adc_clock) - 1;
p_adc->ADC_MR |= ADC_MR_PRESCAL( ul_prescal ) | ( (uc_startup<<ADC_MR_STARTUP_Pos) & ADC_MR_STARTUP_Msk);
@ -155,7 +153,7 @@ void adc_configure_sequence(Adc *p_adc, adc_channel_num_t ch_list[], uint8_t uc_
}
}
#if SAM3S || SAM3XA
#if SAM3S_SERIES || SAM3XA_SERIES
/**
* \brief Configures ADC timing.
*
@ -171,7 +169,7 @@ void adc_configure_timing(Adc *p_adc, uint8_t uc_tracking, adc_settling_time_t s
| settling
| ADC_MR_TRACKTIM( uc_tracking ) ;
}
#elif SAM3N
#elif SAM3N_SERIES
/**
* \brief Configures ADC timing.
*
@ -185,7 +183,7 @@ void adc_configure_timing(Adc *p_adc, uint8_t uc_tracking)
}
#endif
#if SAM3S || SAM3XA
#if SAM3S_SERIES || SAM3XA_SERIES
/**
* \brief enable analog change.
*
@ -199,7 +197,7 @@ void adc_enable_anch( Adc *pAdc )
}
#endif
#if SAM3S || SAM3XA
#if SAM3S_SERIES || SAM3XA_SERIES
/**
* \brief disable analog change.
*
@ -449,7 +447,7 @@ void adc_set_comparison_channel(Adc *p_adc, adc_channel_num_t channel)
}
}
#if SAM3S || SAM3XA
#if SAM3S_SERIES || SAM3XA_SERIES
/**
* \brief Enables differential input for the specified channel.
*
@ -516,9 +514,9 @@ void adc_set_input_gain(Adc *p_adc, adc_channel_num_t channel, adc_gainvalue_t g
{
p_adc->ADC_CGR |= (0x03u << (2*channel)) & (gain << (2*channel));
}
#endif /* SAM3S || SAM3XA */
#endif /* SAM3S_SERIES || SAM3XA_SERIES */
#if SAM3S8 || SAM3SD8
#if SAM3SD8_SERIES
/**
* \brief set adc auto calibration mode.
*
@ -529,7 +527,7 @@ void adc_set_calibmode(Adc *p_adc)
{
p_adc->ADC_CR |= ADC_CR_AUTOCAL;
}
#endif /* SAM3S8 || SAM3SD8 */
#endif /* SAM3SD8_SERIES */
/**
* \brief Returns the actual ADC clock.
@ -609,7 +607,7 @@ uint32_t adc_check_ovr(Adc *p_adc,adc_channel_num_t adc_ch)
return p_adc->ADC_OVER & (0x01u << adc_ch);
}
#if SAM3S || SAM3XA
#if SAM3S_SERIES || SAM3XA_SERIES
/**
* \brief Adapts performance versus power consumption.
*
@ -625,7 +623,7 @@ void adc_set_bias_current(Adc *p_adc, uint8_t uc_ibctl)
}
#endif
#if SAM3S || SAM3XA
#if SAM3S_SERIES || SAM3XA_SERIES
/**
* \brief turn on temperature sensor.
*
@ -638,7 +636,7 @@ void adc_enable_ts(Adc *p_adc)
}
#endif
#if SAM3S || SAM3XA
#if SAM3S_SERIES || SAM3XA_SERIES
/**
* \brief turn off temperature sensor.
*
@ -798,9 +796,9 @@ Pdc *adc_get_pdc_base(Adc *p_adc)
/**INDENT-OFF**/
#ifdef __cplusplus
}
#endif // SAM3S || SAM3N || SAM3XA
#endif
/**INDENT-ON**/
/// @endcond
#endif /* SAM3S || SAM3N || SAM3XA */
#endif /* SAM3S_SERIES || SAM3N_SERIES || SAM3XA_SERIES */

View File

@ -37,7 +37,7 @@ SYSTEM_PATH = ../../../system
CMSIS_ROOT_PATH = $(SYSTEM_PATH)/CMSIS
CMSIS_ARM_PATH=$(CMSIS_ROOT_PATH)/CMSIS/Include
CMSIS_ATMEL_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL
CMSIS_CHIP_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL/$(CHIP_SERIE)
#CMSIS_CHIP_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL/$(CHIP_SERIE)
ARDUINO_PATH = ../../../cores/sam
VARIANT_BASE_PATH = ../../../variants

View File

@ -19,7 +19,7 @@
# Makefile for compiling libArduino
.SUFFIXES: .o .a .c .s
CHIP=__SAM3U4E__
CHIP=__SAM3X8E__
VARIANT=arduino_due_x
LIBNAME=libvariant_$(VARIANT)
TOOLCHAIN=gcc
@ -37,7 +37,7 @@ SYSTEM_PATH = ../../../system
CMSIS_ROOT_PATH = $(SYSTEM_PATH)/CMSIS
CMSIS_ARM_PATH=$(CMSIS_ROOT_PATH)/CMSIS/Include
CMSIS_ATMEL_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL
CMSIS_CHIP_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL/$(CHIP_SERIE)
#CMSIS_CHIP_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL/$(CHIP_SERIE)
ARDUINO_PATH = ../../../cores/sam
VARIANT_BASE_PATH = ../../../variants

View File

@ -124,7 +124,7 @@ extern const PinDescription g_APinDescription[]=
// 2
{ PIOB, PIO_PB25B_TIOA0, ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NO_PWM, TC0_CHA0 }, // TIOA0
{ PIOC, PIO_PC28B_TIOA7, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NO_PWM, TC0_CHA7 }, // TIOA7
{ PIOC, PIO_PC28B_TIOA7, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NO_PWM, TC2_CHA7 }, // TIOA7
{ PIOA, PIO_PA29A_SPI0_NPCS1,ID_PIOA,PIO_PERIPH_A,PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // NPCS1
// 5
@ -136,15 +136,15 @@ extern const PinDescription g_APinDescription[]=
// 10
// * 10 TIOA0 | PA28 PC29???
{ PIOA, PIO_PA1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NO_PWM, TC0_CHA0 }, // TIOA0
{ PIOD, PIO_PD7B_TIOA8, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NO_PWM, TC0_CHA8 }, // TIOA8
{ PIOD, PIO_PD8B_TIOB8, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NO_PWM, TC0_CHB8 }, // TIOB8
{ PIOD, PIO_PD7B_TIOA8, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NO_PWM, TC2_CHA8 }, // TIOA8
{ PIOD, PIO_PD8B_TIOB8, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NO_PWM, TC2_CHB8 }, // TIOB8
// 13 - AMBER LED
{ PIOB, PIO_PB27B_TIOB0, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NO_PWM, TC0_CHB0 }, // TIOB0
// 14/15 - USART2 (Serial4)
{ PIOA, PIO_PA22A_TXD2, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // TXD2
{ PIOA, PIO_PA23A_RXD2, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // RXD2
{ PIOD, PIO_PD4B_TXD3, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // TXD3
{ PIOD, PIO_PD5B_RXD3, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // RXD3
// 16/17 - USART1 (Serial3)
{ PIOA, PIO_PA13A_TXD1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // TXD1
@ -261,7 +261,7 @@ extern const PinDescription g_APinDescription[]=
// 83 - USART1 (Serial3) all pins
{ PIOA, PIO_PA13A_TXD1|PIO_PA12A_RXD1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NO_PWM, NO_TC },
// 84 - USART2 (Serial4) all pins
{ PIOA, PIO_PA22A_TXD2|PIO_PA23A_RXD2, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NO_PWM, NO_TC },
{ PIOD, PIO_PD4B_TXD3|PIO_PD5B_RXD3, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NO_PWM, NO_TC },
// END
{ NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NO_PWM, NO_TC }
@ -361,19 +361,13 @@ extern void init( void )
// Initialize 10bit Analog Controller
PMC_EnablePeripheral( ID_ADC ) ;
adc_init( ADC, SystemCoreClock, ADC_FREQ_MAX, ADC_STARTUP ) ;
adc_configure_timing( ADC, 15 ) ;
adc_configure_trigger( ADC, ADC_TRIG_SW ) ;
// adc_configure_timing( ADC, 15 ) ;
adc_configure_timing(ADC, 0, ADC_SETTLING_TIME_3, 1);
// adc_configure_trigger( ADC, ADC_TRIG_SW ) ;
adc_configure_trigger(ADC, ADC_TRIG_SW, 0); /* Disable hardware trigger. */
adc_disable_interrupt( ADC, 0xFFFFFFFF ) ; /* Disable all adc interrupt. */
adc_disable_channel( ADC, ADC_ALL_CHANNEL ) ;
// Initialize 12bit Analog Controller
PMC_EnablePeripheral( ID_ADC12B ) ;
adc12_init( ADC12B, SystemCoreClock, ADC12_FREQ_MAX, ADC12_STARTUP_FAST, 1 ) ;
adc12_configure_timing( ADC12B, 15 ) ;
adc12_configure_trigger( ADC12B, ADC_TRIG_SW ) ;
adc12_disable_interrupt( ADC12B, 0xFFFFFFFF ) ; /* Disable all adc interrupt. */
adc12_disable_channel( ADC12B, ADC_ALL_CHANNEL ) ;
// Initialize analogOutput module
analogOutputInit();
}

View File

@ -42,8 +42,8 @@
/*----------------------------------------------------------------------------*/
#ifndef arduino_due
#define arduino_due
#ifndef arduino_due_x
#define arduino_due_x
#endif
/** Name of the board */
@ -58,7 +58,7 @@
#define VARIANT_MAINOSC 12000000
/** Master clock frequency */
#define VARIANT_MCK 96000000
#define VARIANT_MCK 84000000
/*----------------------------------------------------------------------------
* Pins