diff options
author | Rocco Marco Guglielmi <roccomarco.guglielmi@gmail.com> | 2017-09-19 13:15:55 +0000 |
---|---|---|
committer | Rocco Marco Guglielmi <roccomarco.guglielmi@gmail.com> | 2017-09-19 13:15:55 +0000 |
commit | b9a8304c863e09340649999a21900fb8f8973dc8 (patch) | |
tree | e63b1cc1db5d90760a0f7006b6e82148f56e4468 | |
parent | f1cfee405840f51feef73a7f74f1c2609e3a319e (diff) | |
download | ChibiOS-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
4 files changed, 80 insertions, 8 deletions
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED/debug/RT-SAMA5D2-XPLAINED (Load and Run).launch b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED/debug/RT-SAMA5D2-XPLAINED (Load and Run).launch index e65e369ac..eae6f9dcc 100644 --- a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED/debug/RT-SAMA5D2-XPLAINED (Load and Run).launch +++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED/debug/RT-SAMA5D2-XPLAINED (Load and Run).launch @@ -33,7 +33,7 @@ <intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
-<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="null-sama_clock_init-(format)" val="4"/><content id="null-boardInit-(format)" val="2"/></contentList>"/>
+<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="null-boardInit-(format)" val="2"/><content id="null-sama_clock_init-(format)" val="4"/><content id="null-_pal_lld_setgroupmode-(format)" val="4"/><content id="mode-_pal_lld_setgroupmode-(format)" val="4"/></contentList>"/>
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED/main.c b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED/main.c index 75977385c..bfca0f50f 100755 --- a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED/main.c +++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED/main.c @@ -54,7 +54,7 @@ int main(void) { /* Redirecting UART0 RX on PB26 and UART0 TX on PB 27. */
palSetGroupMode(PIOB, PAL_PORT_BIT(26) | PAL_PORT_BIT(27), 0U,
- PAL_SAMA_FUNC_PERIPH_C);
+ PAL_SAMA_FUNC_PERIPH_C | PAL_MODE_SECURE);
/*
* Creates the blinker thread.
*/
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
|