diff --git a/boards/ATMEL_SAM4L_EK/board.h b/boards/ATMEL_SAM4L_EK/board.h
index b350f0f8c..659fc9ebd 100644
--- a/boards/ATMEL_SAM4L_EK/board.h
+++ b/boards/ATMEL_SAM4L_EK/board.h
@@ -31,6 +31,11 @@
#define BOARD_ATMEL_SAM4L_EK
#define BOARD_NAME "Atmel SAM4L-EK"
+/*
+ * Device identifier.
+ */
+#define __ATSAM4LC4C__
+
#if !defined(_FROM_ASM_)
#ifdef __cplusplus
extern "C" {
diff --git a/demos/ARMCM4-SAM4L/.cproject b/demos/ARMCM4-SAM4L/.cproject
new file mode 100644
index 000000000..26b02e69d
--- /dev/null
+++ b/demos/ARMCM4-SAM4L/.cproject
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/demos/ARMCM4-SAM4L/.project b/demos/ARMCM4-SAM4L/.project
new file mode 100644
index 000000000..2121de6f1
--- /dev/null
+++ b/demos/ARMCM4-SAM4L/.project
@@ -0,0 +1,95 @@
+
+
+ ARMCM4-SAM4L
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.autoBuildTarget
+ all
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ -j
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ make
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.fullBuildTarget
+ all
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ true
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+
+
+
+ board
+ 2
+ CHIBIOS/boards/ATMEL_SAM4L_EK
+
+
+ os
+ 2
+ CHIBIOS/os
+
+
+ test
+ 2
+ CHIBIOS/test
+
+
+
diff --git a/demos/ARMCM4-SAM4L/halconf.h b/demos/ARMCM4-SAM4L/halconf.h
index 91d295ccf..3ef53ed1c 100644
--- a/demos/ARMCM4-SAM4L/halconf.h
+++ b/demos/ARMCM4-SAM4L/halconf.h
@@ -45,7 +45,7 @@
* @brief Enables the PAL subsystem.
*/
#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
-#define HAL_USE_PAL TRUE
+#define HAL_USE_PAL FALSE
#endif
/**
diff --git a/os/hal/platforms/SAM4L/hal_lld.c b/os/hal/platforms/SAM4L/hal_lld.c
index 2564ac49d..02dbfb9a3 100644
--- a/os/hal/platforms/SAM4L/hal_lld.c
+++ b/os/hal/platforms/SAM4L/hal_lld.c
@@ -53,6 +53,10 @@
/* Driver exported functions. */
/*===========================================================================*/
+void sam4l_clock_init(void) {
+
+}
+
/**
* @brief Low level HAL driver initialization.
*
diff --git a/os/hal/platforms/SAM4L/hal_lld.h b/os/hal/platforms/SAM4L/hal_lld.h
index 1b7106962..fb78792b9 100644
--- a/os/hal/platforms/SAM4L/hal_lld.h
+++ b/os/hal/platforms/SAM4L/hal_lld.h
@@ -29,14 +29,21 @@
#ifndef _HAL_LLD_H_
#define _HAL_LLD_H_
+#include "sam4l.h"
+
/*===========================================================================*/
/* Driver constants. */
/*===========================================================================*/
+/**
+ * @brief Defines the support for realtime counters in the HAL.
+ */
+#define HAL_IMPLEMENTS_COUNTERS TRUE
+
/**
* @brief Platform name.
*/
-#define PLATFORM_NAME ""
+#define PLATFORM_NAME "SAM4L Series"
/*===========================================================================*/
/* Driver pre-compile time settings. */
@@ -50,10 +57,43 @@
/* Driver data structures and types. */
/*===========================================================================*/
+/**
+ * @brief Type representing a system clock frequency.
+ */
+typedef uint32_t halclock_t;
+
+/**
+ * @brief Type of the realtime free counter value.
+ */
+typedef uint32_t halrtcnt_t;
+
/*===========================================================================*/
/* Driver macros. */
/*===========================================================================*/
+/**
+ * @brief Returns the current value of the system free running counter.
+ * @note This service is implemented by returning the content of the
+ * DWT_CYCCNT register.
+ *
+ * @return The value of the system free running counter of
+ * type halrtcnt_t.
+ *
+ * @notapi
+ */
+#define hal_lld_get_counter_value() DWT_CYCCNT
+
+/**
+ * @brief Realtime counter frequency.
+ * @note The DWT_CYCCNT register is incremented directly by the system
+ * clock so this function returns STM32_HCLK.
+ *
+ * @return The realtime counter frequency of type halclock_t.
+ *
+ * @notapi
+ */
+#define hal_lld_get_counter_frequency() STM32_HCLK
+
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
@@ -61,6 +101,7 @@
#ifdef __cplusplus
extern "C" {
#endif
+ void sam4l_clock_init(void);
void hal_lld_init(void);
#ifdef __cplusplus
}
diff --git a/os/hal/templates/hal_lld.h b/os/hal/templates/hal_lld.h
index 1b7106962..a133c5854 100644
--- a/os/hal/templates/hal_lld.h
+++ b/os/hal/templates/hal_lld.h
@@ -33,6 +33,11 @@
/* Driver constants. */
/*===========================================================================*/
+/**
+ * @brief Defines the support for realtime counters in the HAL.
+ */
+#define HAL_IMPLEMENTS_COUNTERS TRUE
+
/**
* @brief Platform name.
*/
@@ -50,6 +55,16 @@
/* Driver data structures and types. */
/*===========================================================================*/
+/**
+ * @brief Type representing a system clock frequency.
+ */
+typedef uint32_t halclock_t;
+
+/**
+ * @brief Type of the realtime free counter value.
+ */
+typedef uint32_t halrtcnt_t;
+
/*===========================================================================*/
/* Driver macros. */
/*===========================================================================*/