aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED/debug/RT-SAMA5D2-XPLAINED (Load and Run).launch2
-rwxr-xr-xdemos/ATSAMA5D2/RT-SAMA5D2-XPLAINED/main.c2
-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
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="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList&gt;&lt;content id=&quot;null-sama_clock_init-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;null-boardInit-(format)&quot; val=&quot;2&quot;/&gt;&lt;/contentList&gt;"/>
+<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList&gt;&lt;content id=&quot;null-boardInit-(format)&quot; val=&quot;2&quot;/&gt;&lt;content id=&quot;null-sama_clock_init-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;null-_pal_lld_setgroupmode-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;mode-_pal_lld_setgroupmode-(format)&quot; val=&quot;4&quot;/&gt;&lt;/contentList&gt;"/>
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;globalVariableList/&gt;&#13;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList/&gt;&#13;&#10;"/>
<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