aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-12-16 09:03:56 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-12-16 09:03:56 +0000
commitb570290ae7fc9b1d2c13140032f9eff85523ca8f (patch)
treea934dbe6ee0558bf5c86956b515db8fd644f0599 /os/hal/platforms
parent1d962813e838255e2cfc548fc1865d173ea9e3b2 (diff)
downloadChibiOS-b570290ae7fc9b1d2c13140032f9eff85523ca8f.tar.gz
ChibiOS-b570290ae7fc9b1d2c13140032f9eff85523ca8f.tar.bz2
ChibiOS-b570290ae7fc9b1d2c13140032f9eff85523ca8f.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4914 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms')
-rw-r--r--os/hal/platforms/SAM4L/hal_lld.c47
-rw-r--r--os/hal/platforms/SAM4L/hal_lld.h8
-rw-r--r--os/hal/platforms/SAM4L/platform.mk7
3 files changed, 52 insertions, 10 deletions
diff --git a/os/hal/platforms/SAM4L/hal_lld.c b/os/hal/platforms/SAM4L/hal_lld.c
index edc40ecb0..095195706 100644
--- a/os/hal/platforms/SAM4L/hal_lld.c
+++ b/os/hal/platforms/SAM4L/hal_lld.c
@@ -53,6 +53,34 @@
/* 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. */
/*===========================================================================*/
@@ -130,23 +158,30 @@ void sam_clock_init(void) {
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_RCSYS
/* Nothing to do, already running from SYSIRC.*/
#endif
+
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_OSC0
SAM_SCIF_UNLOCK(&SCIF->SCIF_OSCCTRL0);
SCIF->SCIF_OSCCTRL0 = SAM_OSCCTRL_GAIN | SAM_OSCCTRL_MODE |
SAM_OSCCTRL_STARTUP | SAM_OSCCTRL_OSCEN;
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
-#endif
+#endif /* SAM_MCCTRL_MCSEL == SAM_MCSEL_PLL */
+
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_DFLL
-#endif
+#endif /* SAM_MCCTRL_MCSEL == SAM_MCSEL_DFLL */
+
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_RC80M
-#endif
+#endif /* SAM_MCCTRL_MCSEL == SAM_MCSEL_RC80M */
+
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_RCFAST
-#endif
+#endif /* SAM_MCCTRL_MCSEL == SAM_MCSEL_RCFAST */
+
#if SAM_MCCTRL_MCSEL == SAM_MCSEL_RC1M
-#endif
+#endif /* SAM_MCCTRL_MCSEL == SAM_MCSEL_RC1M */
#endif /* SAM_NO_INIT */
}
diff --git a/os/hal/platforms/SAM4L/hal_lld.h b/os/hal/platforms/SAM4L/hal_lld.h
index 879d31bde..db1e0a98c 100644
--- a/os/hal/platforms/SAM4L/hal_lld.h
+++ b/os/hal/platforms/SAM4L/hal_lld.h
@@ -251,7 +251,7 @@
#endif
/**
- * @brief Power mode.
+ * @brief Power Scalability mode.
*/
#if !defined(SAM_PMCON_PS) || defined(__DOXYGEN__)
#define SAM_PMCON_PS SAM_PMCON_PS0
@@ -321,6 +321,9 @@
#define SAM_PBBCLK_MAX 50000000
#define SAM_PBCCLK_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
#define SAM_CPUCLK_MAX 12000000
@@ -328,6 +331,9 @@
#define SAM_PBBCLK_MAX 12000000
#define SAM_PBCCLK_MAX 12000000
#define SAM_PBDCLK_MAX 12000000
+#define SAM_FLASH0WS_MAX 8000000
+#define SAM_FLASH1WS_MAX 12000000
+#define SAM_FLASH1WS_FWU_MAX 0
#else
#error "invalid SAM_PMCON_PS value specified"
diff --git a/os/hal/platforms/SAM4L/platform.mk b/os/hal/platforms/SAM4L/platform.mk
index 26adf9a54..d97d0d018 100644
--- a/os/hal/platforms/SAM4L/platform.mk
+++ b/os/hal/platforms/SAM4L/platform.mk
@@ -1,6 +1,7 @@
# 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
-PLATFORMINC = ${CHIBIOS}/os/hal/platforms/SAM4L
-
+PLATFORMINC = ${CHIBIOS}/os/hal/platforms/SAM4L \
+ ${CHIBIOS}/os/hal/platforms/SAM4L/asf