Fixed Bugs

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11274 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
edolomb 2018-01-15 20:11:08 +00:00
parent b28c62685d
commit 9f91962bae
2 changed files with 15 additions and 8 deletions

View File

@ -88,19 +88,26 @@
* @retval false Peripheral is secured. * @retval false Peripheral is secured.
* *
*/ */
bool mtxConfigPeriphSecurity(Matrix *mtxp, uint8_t id, bool mode) { bool mtxConfigPeriphSecurity(Matrix *mtxp, uint32_t id, bool mode) {
mtxDisableWP(mtxp); uint32_t mask;
if (mode) { if (id < 74) {
mtxp->MATRIX_SPSELR[id / 32] |= (MATRIX_SPSELR_NSECP0 << id); mask = id & 0x1F;
} }
else { else {
mtxp->MATRIX_SPSELR[id / 32] &= ~(MATRIX_SPSELR_NSECP0 << id); mask = (id & 0x1F) - 1;
}
mtxDisableWP(mtxp);
if (mode) {
mtxp->MATRIX_SPSELR[id / 32] |= (MATRIX_SPSELR_NSECP0 << mask);
}
else {
mtxp->MATRIX_SPSELR[id / 32] &= ~(MATRIX_SPSELR_NSECP0 << mask);
} }
mtxEnableWP(mtxp); mtxEnableWP(mtxp);
return (MATRIX0->MATRIX_SPSELR[id / 32] & (MATRIX_SPSELR_NSECP0 << id)) & return (MATRIX0->MATRIX_SPSELR[id / 32] & (MATRIX_SPSELR_NSECP0 << mask)) &
(MATRIX1->MATRIX_SPSELR[id / 32] & (MATRIX_SPSELR_NSECP0 << id)); (MATRIX1->MATRIX_SPSELR[id / 32] & (MATRIX_SPSELR_NSECP0 << mask));
} }
/** /**

View File

@ -320,7 +320,7 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
bool mtxConfigPeriphSecurity(Matrix *mtxp, uint8_t id, bool mode); bool mtxConfigPeriphSecurity(Matrix *mtxp, uint32_t id, bool mode);
void mtxConfigDefaultMaster(Matrix *mtxp, uint8_t slaveID, void mtxConfigDefaultMaster(Matrix *mtxp, uint8_t slaveID,
uint8_t type, uint8_t masterID); uint8_t type, uint8_t masterID);
void mtxConfigSlaveSec(Matrix *mtxp, uint8_t slaveID, void mtxConfigSlaveSec(Matrix *mtxp, uint8_t slaveID,