aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/SAMA/LLD
diff options
context:
space:
mode:
authorRocco Marco Guglielmi <roccomarco.guglielmi@gmail.com>2017-09-19 13:15:55 +0000
committerRocco Marco Guglielmi <roccomarco.guglielmi@gmail.com>2017-09-19 13:15:55 +0000
commitb9a8304c863e09340649999a21900fb8f8973dc8 (patch)
treee63b1cc1db5d90760a0f7006b6e82148f56e4468 /os/hal/ports/SAMA/LLD
parentf1cfee405840f51feef73a7f74f1c2609e3a319e (diff)
downloadChibiOS-b9a8304c863e09340649999a21900fb8f8973dc8.tar.gz
ChibiOS-b9a8304c863e09340649999a21900fb8f8973dc8.tar.bz2
ChibiOS-b9a8304c863e09340649999a21900fb8f8973dc8.zip
Added secure/non-secure configuration capability in SAMA PAL driver
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10647 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/ports/SAMA/LLD')
-rw-r--r--os/hal/ports/SAMA/LLD/PIOv1/hal_pal_lld.c33
-rw-r--r--os/hal/ports/SAMA/LLD/PIOv1/hal_pal_lld.h51
2 files changed, 78 insertions, 6 deletions
diff --git a/os/hal/ports/SAMA/LLD/PIOv1/hal_pal_lld.c b/os/hal/ports/SAMA/LLD/PIOv1/hal_pal_lld.c
index 8b5a616dc..35dbb08c1 100644
--- a/os/hal/ports/SAMA/LLD/PIOv1/hal_pal_lld.c
+++ b/os/hal/ports/SAMA/LLD/PIOv1/hal_pal_lld.c
@@ -50,6 +50,37 @@
/* Driver exported functions. */
/*===========================================================================*/
-#endif /* HAL_USE_PAL */
+/**
+ * @brief Pads mode setup.
+ * @details This function programs a pads group belonging to the same port
+ * with the specified mode.
+ * @note @p PAL_MODE_UNCONNECTED is implemented as push pull at minimum
+ * speed.
+ *
+ * @param[in] port the port identifier
+ * @param[in] mask the group mask
+ * @param[in] mode the mode
+ *
+ * @notapi
+ */
+void _pal_lld_setgroupmode(ioportid_t port,
+ ioportmask_t mask,
+ iomode_t mode) {
+
+ uint32_t mskr = (mask);
+ uint32_t cfgr = (mode & (PAL_SAMA_CFGR_MASK));
+#if SAMA_HAL_IS_SECURE
+ if(mode && PAL_SAMA_SECURE_MASK) {
+ port->SIOSR = mask;
+ }
+ else {
+ port->SIONR = mask;
+ }
+#endif /* SAMA_HAL_IS_SECURE */
+ port->MSKR = mskr;
+ port->CFGR = cfgr;
+}
+
+#endif /* HAL_USE_PAL */
/** @} */
diff --git a/os/hal/ports/SAMA/LLD/PIOv1/hal_pal_lld.h b/os/hal/ports/SAMA/LLD/PIOv1/hal_pal_lld.h
index 920f192d7..ae877c5a4 100644
--- a/os/hal/ports/SAMA/LLD/PIOv1/hal_pal_lld.h
+++ b/os/hal/ports/SAMA/LLD/PIOv1/hal_pal_lld.h
@@ -83,6 +83,34 @@
#define PAL_SAMA_DRVSTR_ME (2U << 16U)
#define PAL_SAMA_DRVSTR_HI (3U << 16U)
+#define PAL_SAMA_EVTSEL_MASK (7U << 24U)
+#define PAL_SAMA_EVTSEL_FALLING (0U << 24U)
+#define PAL_SAMA_EVTSEL_RISING (1U << 24U)
+#define PAL_SAMA_EVTSEL_BOTH (2U << 24U)
+#define PAL_SAMA_EVTSEL_LOW (3U << 24U)
+#define PAL_SAMA_EVTSEL_HIGH (4U << 24U)
+
+#define PAL_SAMA_PCFS_MASK (1U << 29U)
+#define PAL_SAMA_ICFS_MASK (1U << 30U)
+
+
+#define PAL_SAMA_CFGR_MASK PAL_SAMA_FUNC_MASK | \
+ PAL_SAMA_DIR_MASK | \
+ PAL_SAMA_PUEN_MASK | \
+ PAL_SAMA_PDEN_MASK | \
+ PAL_SAMA_IFEN_MASK | \
+ PAL_SAMA_IFSCEN_MASK | \
+ PAL_SAMA_OPD_MASK | \
+ PAL_SAMA_SCHMITT_MASK | \
+ PAL_SAMA_DRVSTR_MASK
+
+#if SAMA_HAL_IS_SECURE
+#define PAL_SAMA_SECURE_MASK (1U << 31U)
+
+#define PAL_SAMA_NON_SECURE (0U << 31U)
+#define PAL_SAMA_SECURE (1U << 31U)
+#endif /* SAMA_HAL_IS_SECURE */
+
/**
* @name Standard I/O mode flags
* @{
@@ -135,6 +163,20 @@
*/
#define PAL_MODE_OUTPUT_OPENDRAIN (PAL_SAMA_DIR_OUTPUT | \
PAL_SAMA_OPD_OPENDRAIN)
+
+#if SAMA_HAL_IS_SECURE || defined(__DOXYGEN__)
+/**
+ * @brief Secure pad.
+ * @note Available only on Secure HAL.
+ */
+#define PAL_MODE_SECURE PAL_SAMA_SECURE
+
+/**
+ * @brief Non secure pad.
+ * @note Available only on Secure HAL.
+ */
+#define PAL_MODE_NON_SECURE PAL_SAMA_NON_SECURE
+#endif
/** @} */
/* Discarded definitions from the Atmel headers, the PAL driver uses its own
@@ -431,10 +473,7 @@ typedef uint32_t iopadid_t;
* @notapi
*/
#define pal_lld_setgroupmode(port, mask, offset, mode) \
- do { \
- (port)->MSKR = ((mask) << (offset)); \
- (port)->CFGR = (mode); \
- } while (false)
+ _pal_lld_setgroupmode(port, mask << offset, mode)
/**
* @brief Writes a logical state on an output pad.
@@ -493,7 +532,9 @@ typedef uint32_t iopadid_t;
#ifdef __cplusplus
extern "C" {
#endif
-
+ void _pal_lld_setgroupmode(ioportid_t port,
+ ioportmask_t mask,
+ iomode_t mode);
#ifdef __cplusplus
}
#endif