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
This commit is contained in:
Rocco Marco Guglielmi 2017-09-19 13:15:55 +00:00
parent f1cfee4058
commit b9a8304c86
4 changed files with 80 additions and 8 deletions

View File

@ -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"/>

View File

@ -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.
*/

View File

@ -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 */
/** @} */

View File

@ -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