-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Vidar Lillebø <[email protected]>
- Loading branch information
1 parent
bc01a4c
commit 15dbf4f
Showing
5 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
|
||
/*** | ||
*/ | ||
|
||
#include "nrf54l15_enga_application.h" | ||
#include "nrf54l15_enga_global.h" | ||
#include "nrf54l15_enga_types.h" | ||
#include "tfm_hal_platform.h" | ||
#include "tfm_plat_defs.h" | ||
#include <hal/nrf_tampc.h> | ||
#include <helpers/nrfx_reset_reason.h> | ||
|
||
bool boot_reason_sectamper; | ||
|
||
#define RESET_BY_PERIPHERAL false | ||
#define TAMPER_EVENT_HANDLER tfm_core_panic | ||
|
||
int init_tampc(void) { | ||
|
||
#if 0 | ||
if (((volatile uint32_t *)0x5010E600)[0] & NRFX_RESET_REASON_SECTAMPER_MASK) { | ||
((volatile uint32_t *)0x5010E600)[0] = NRFX_RESET_REASON_SECTAMPER_MASK; | ||
boot_reason_sectamper = true; | ||
} | ||
#endif | ||
|
||
nrf_tampc_event_clear(NRF_TAMPC, NRF_TAMPC_EVENT_WRITE_ERROR); | ||
nrf_tampc_int_enable(NRF_TAMPC, NRF_TAMPC_ALL_INTS_MASK); | ||
|
||
nrf_tampc_protector_ctrl_value_set( | ||
NRF_TAMPC, NRF_TAMPC_PROTECT_GLITCH_DOMAIN_FAST, true); | ||
nrf_tampc_protector_ctrl_value_set( | ||
NRF_TAMPC, NRF_TAMPC_PROTECT_GLITCH_DOMAIN_SLOW, true); | ||
nrf_tampc_protector_ctrl_value_set(NRF_TAMPC, NRF_TAMPC_PROTECT_RESETEN_INT, | ||
RESET_BY_PERIPHERAL); | ||
|
||
NVIC_ClearPendingIRQ(TAMPC_IRQn); | ||
NVIC_ClearTargetState(TAMPC_IRQn); | ||
NVIC_EnableIRQ(TAMPC_IRQn); | ||
|
||
return TFM_PLAT_ERR_SUCCESS; | ||
} | ||
|
||
void TAMPC_Handler(void) { | ||
SPMLOG_ERRMSG("TAMPC Exception:\r\n"); | ||
|
||
if (nrf_tampc_event_check(NRF_TAMPC, NRF_TAMPC_EVENT_WRITE_ERROR)) { | ||
SPMLOG_ERRMSG("\tWrite error.\r\n"); | ||
nrf_tampc_event_clear(NRF_TAMPC, NRF_TAMPC_EVENT_WRITE_ERROR); | ||
NVIC_ClearPendingIRQ(TAMPC_IRQn); | ||
tfm_core_panic(); | ||
} | ||
|
||
if (nrf_tampc_event_check(NRF_TAMPC, NRF_TAMPC_EVENT_TAMPER)) { | ||
SPMLOG_ERRMSG("\tTamper event.\r\n"); | ||
nrf_tampc_event_clear(NRF_TAMPC, NRF_TAMPC_EVENT_TAMPER); | ||
NVIC_ClearPendingIRQ(TAMPC_IRQn); | ||
TAMPER_EVENT_HANDLER(); | ||
} | ||
} |