git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4914 35acf78f-673a-0410-8e92-d51de3d6d3f4
parent
1d962813e8
commit
b570290ae7
|
@ -53,6 +53,34 @@
|
||||||
/* Driver local functions. */
|
/* Driver local functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
void sam_set_optimal_flash_mode(void) {
|
||||||
|
|
||||||
|
if (SAM_PMCON_PS == SAM_PMCON_PS0) {
|
||||||
|
/* Scalability Level 0.*/
|
||||||
|
if (SAM_CPU_CLK > SAM_FLASH0WS_MAX) {
|
||||||
|
/* One wait state required.*/
|
||||||
|
if (SAM_CPU_CLK <= SAM_FLASH1WS_MAX) {
|
||||||
|
/* Fast read mode disabled.*/
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Fast read mode enabled.*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* No wait state required.*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Scalability Level 1.*/
|
||||||
|
if (SAM_CPU_CLK > SAM_FLASH0WS_MAX) {
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver interrupt handlers. */
|
/* Driver interrupt handlers. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -130,23 +158,30 @@ void sam_clock_init(void) {
|
||||||
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_RCSYS
|
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_RCSYS
|
||||||
/* Nothing to do, already running from SYSIRC.*/
|
/* Nothing to do, already running from SYSIRC.*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_OSC0
|
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_OSC0
|
||||||
SAM_SCIF_UNLOCK(&SCIF->SCIF_OSCCTRL0);
|
SAM_SCIF_UNLOCK(&SCIF->SCIF_OSCCTRL0);
|
||||||
SCIF->SCIF_OSCCTRL0 = SAM_OSCCTRL_GAIN | SAM_OSCCTRL_MODE |
|
SCIF->SCIF_OSCCTRL0 = SAM_OSCCTRL_GAIN | SAM_OSCCTRL_MODE |
|
||||||
SAM_OSCCTRL_STARTUP | SAM_OSCCTRL_OSCEN;
|
SAM_OSCCTRL_STARTUP | SAM_OSCCTRL_OSCEN;
|
||||||
while (!(SCIF->SCIF_PCLKSR & SCIF_PCLKSR_OSC0RDY))
|
while (!(SCIF->SCIF_PCLKSR & SCIF_PCLKSR_OSC0RDY))
|
||||||
;
|
;
|
||||||
#endif
|
sam_set_optimal_flash_mode();
|
||||||
|
#endif /* SAM_MCCTRL_MCSEL == SAM_MCSEL_RCSYS */
|
||||||
|
|
||||||
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_PLL
|
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_PLL
|
||||||
#endif
|
#endif /* SAM_MCCTRL_MCSEL == SAM_MCSEL_PLL */
|
||||||
|
|
||||||
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_DFLL
|
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_DFLL
|
||||||
#endif
|
#endif /* SAM_MCCTRL_MCSEL == SAM_MCSEL_DFLL */
|
||||||
|
|
||||||
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_RC80M
|
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_RC80M
|
||||||
#endif
|
#endif /* SAM_MCCTRL_MCSEL == SAM_MCSEL_RC80M */
|
||||||
|
|
||||||
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_RCFAST
|
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_RCFAST
|
||||||
#endif
|
#endif /* SAM_MCCTRL_MCSEL == SAM_MCSEL_RCFAST */
|
||||||
|
|
||||||
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_RC1M
|
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_RC1M
|
||||||
#endif
|
#endif /* SAM_MCCTRL_MCSEL == SAM_MCSEL_RC1M */
|
||||||
|
|
||||||
#endif /* SAM_NO_INIT */
|
#endif /* SAM_NO_INIT */
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,7 +251,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Power mode.
|
* @brief Power Scalability mode.
|
||||||
*/
|
*/
|
||||||
#if !defined(SAM_PMCON_PS) || defined(__DOXYGEN__)
|
#if !defined(SAM_PMCON_PS) || defined(__DOXYGEN__)
|
||||||
#define SAM_PMCON_PS SAM_PMCON_PS0
|
#define SAM_PMCON_PS SAM_PMCON_PS0
|
||||||
|
@ -321,6 +321,9 @@
|
||||||
#define SAM_PBBCLK_MAX 50000000
|
#define SAM_PBBCLK_MAX 50000000
|
||||||
#define SAM_PBCCLK_MAX 50000000
|
#define SAM_PBCCLK_MAX 50000000
|
||||||
#define SAM_PBDCLK_MAX 50000000
|
#define SAM_PBDCLK_MAX 50000000
|
||||||
|
#define SAM_FLASH0WS_MAX 18000000
|
||||||
|
#define SAM_FLASH1WS_MAX 36000000
|
||||||
|
#define SAM_FLASH1WS_FWU_MAX 12000000
|
||||||
|
|
||||||
#elif SAM_PMCON_PS == SAM_PMCON_PS1
|
#elif SAM_PMCON_PS == SAM_PMCON_PS1
|
||||||
#define SAM_CPUCLK_MAX 12000000
|
#define SAM_CPUCLK_MAX 12000000
|
||||||
|
@ -328,6 +331,9 @@
|
||||||
#define SAM_PBBCLK_MAX 12000000
|
#define SAM_PBBCLK_MAX 12000000
|
||||||
#define SAM_PBCCLK_MAX 12000000
|
#define SAM_PBCCLK_MAX 12000000
|
||||||
#define SAM_PBDCLK_MAX 12000000
|
#define SAM_PBDCLK_MAX 12000000
|
||||||
|
#define SAM_FLASH0WS_MAX 8000000
|
||||||
|
#define SAM_FLASH1WS_MAX 12000000
|
||||||
|
#define SAM_FLASH1WS_FWU_MAX 0
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error "invalid SAM_PMCON_PS value specified"
|
#error "invalid SAM_PMCON_PS value specified"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# List of all the STM32F3xx platform files.
|
# List of all the STM32F3xx platform files.
|
||||||
PLATFORMSRC = ${CHIBIOS}/os/hal/platforms/SAM4L/hal_lld.c
|
PLATFORMSRC = ${CHIBIOS}/os/hal/platforms/SAM4L/hal_lld.c \
|
||||||
|
${CHIBIOS}/os/hal/platforms/SAM4L/asf/flashcalw.c
|
||||||
|
|
||||||
# Required include directories
|
# Required include directories
|
||||||
PLATFORMINC = ${CHIBIOS}/os/hal/platforms/SAM4L
|
PLATFORMINC = ${CHIBIOS}/os/hal/platforms/SAM4L \
|
||||||
|
${CHIBIOS}/os/hal/platforms/SAM4L/asf
|
||||||
|
|
Loading…
Reference in New Issue