diff options
Diffstat (limited to 'os/hal/ports/SAMA/SAMA5D2x')
-rw-r--r-- | os/hal/ports/SAMA/SAMA5D2x/sama_matrix.c | 25 | ||||
-rw-r--r-- | os/hal/ports/SAMA/SAMA5D2x/sama_matrix.h | 4 |
2 files changed, 29 insertions, 0 deletions
diff --git a/os/hal/ports/SAMA/SAMA5D2x/sama_matrix.c b/os/hal/ports/SAMA/SAMA5D2x/sama_matrix.c index c8624ea40..db399a3bb 100644 --- a/os/hal/ports/SAMA/SAMA5D2x/sama_matrix.c +++ b/os/hal/ports/SAMA/SAMA5D2x/sama_matrix.c @@ -77,6 +77,31 @@ /*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
+/**
+ * @brief Configures peripheral security
+ *
+ * @param[in] mtxp pointer to a MATRIX register block.
+ * @param[in] id PERIPHERAL_ID.
+ * @param[in] mode SECURE_PER or NOT_SECURE_PER.
+ *
+ * @retval true Peripheral is not secured.
+ * @retval false Peripheral is secured.
+ *
+ */
+bool mtxConfigPeriphSecurity(Matrix *mtxp, uint8_t id, bool mode) {
+
+ mtxDisableWP(mtxp);
+ if (mode) {
+ mtxp->MATRIX_SPSELR[id / 32] |= (MATRIX_SPSELR_NSECP0 << id);
+ }
+ else {
+ mtxp->MATRIX_SPSELR[id / 32] &= ~(MATRIX_SPSELR_NSECP0 << id);
+ }
+ mtxEnableWP(mtxp);
+
+ return (MATRIX0->MATRIX_SPSELR[id / 32] & (MATRIX_SPSELR_NSECP0 << id)) &
+ (MATRIX1->MATRIX_SPSELR[id / 32] & (MATRIX_SPSELR_NSECP0 << id));
+}
/**
* @brief Associates slave with a kind of master
diff --git a/os/hal/ports/SAMA/SAMA5D2x/sama_matrix.h b/os/hal/ports/SAMA/SAMA5D2x/sama_matrix.h index 52a3bb3f1..b9133a85b 100644 --- a/os/hal/ports/SAMA/SAMA5D2x/sama_matrix.h +++ b/os/hal/ports/SAMA/SAMA5D2x/sama_matrix.h @@ -37,6 +37,9 @@ #define NOT_SECURE_READ 0x1u #define NOT_SECURE_WRITE 0x1u +#define SECURE_PER FALSE +#define NOT_SECURE_PER TRUE + #define NO_DEFAULT_MASTER 0x0u #define LAST_DEFAULT_MASTER 0x1u #define FIXED_DEFAULT_MASTER 0x2u @@ -90,6 +93,7 @@ #ifdef __cplusplus extern "C" { #endif + bool mtxConfigPeriphSecurity(Matrix *mtxp, uint8_t id, bool mode); void mtxConfigDefaultMaster(Matrix *mtxp, uint8_t slaveID, uint8_t type, uint8_t masterID); void mtxConfigSlaveSec(Matrix *mtxp, uint8_t slaveID, |