aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms/MSP430X/hal_lld.c
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-11-10 08:32:19 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-11-10 08:32:19 +0000
commite01d0f6f287023e79ef661e27f37c6109de75186 (patch)
tree459328e8b81f33a6a3c08b00725ba4eebfc4b134 /os/hal/platforms/MSP430X/hal_lld.c
parentd672c60a80d0a00473a4c86fe5ab44f34730b36f (diff)
downloadChibiOS-e01d0f6f287023e79ef661e27f37c6109de75186.tar.gz
ChibiOS-e01d0f6f287023e79ef661e27f37c6109de75186.tar.bz2
ChibiOS-e01d0f6f287023e79ef661e27f37c6109de75186.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4811 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms/MSP430X/hal_lld.c')
-rw-r--r--os/hal/platforms/MSP430X/hal_lld.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/os/hal/platforms/MSP430X/hal_lld.c b/os/hal/platforms/MSP430X/hal_lld.c
new file mode 100644
index 000000000..5cee3e972
--- /dev/null
+++ b/os/hal/platforms/MSP430X/hal_lld.c
@@ -0,0 +1,78 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
+ 2011,2012 Giovanni Di Sirio.
+
+ This file is part of ChibiOS/RT.
+
+ ChibiOS/RT is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/RT is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file MSP430/hal_lld.c
+ * @brief MSP430 HAL subsystem low level driver source.
+ *
+ * @addtogroup HAL
+ * @{
+ */
+
+#include "ch.h"
+#include "hal.h"
+#include "F5XX_F6XX_CORE_LIB/HAL_PMM.h"
+#include "F5XX_F6XX_CORE_LIB/HAL_UCS.h"
+
+#define HZ_TO_KHZ(f_Hz) (f_Hz/1000)
+
+#define SELECT_PMMCOREV(f_Hz) (f_Hz <= 8000000ul ? PMMCOREV_0 : \
+ (f_Hz <= 12000000ul ? PMMCOREV_1 : \
+ (f_Hz <= 20000000ul ? PMMCOREV_2 : PMMCOREV_3)))
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/**
+ * @brief Low level HAL driver initialization.
+ *
+ * @notapi
+ */
+void hal_lld_init(void) {
+ #if MSP430_USE_CLOCK == MSP430_CLOCK_SOURCE_XT2CLK
+ #error "XT2CLK is not implemented"
+ #elif MSP430_USE_CLOCK == MSP430_CLOCK_SOURCE_DCOCLK
+ SetVCore(SELECT_PMMCOREV(DCOCLK)); /* Set core voltage */
+ SELECT_FLLREF(SELREF__REFOCLK); /* Set DCO FLL reference = REFO */
+ SELECT_ACLK(SELA__REFOCLK); /* Set ACLK = REFO */
+ Init_FLL_Settle(HZ_TO_KHZ(DCOCLK),DCOCLK/LFXT1CLK);
+ #else
+ #error "unknown clock source specified"
+ #endif
+}
+
+/** @} */