2020-05-27 04:20:52 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020 Nordic Semiconductor ASA
|
|
|
|
* Copyright (c) 2020 Oticon A/S
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "irq_ctrl.h"
|
|
|
|
#include "posix_core.h"
|
|
|
|
#include "posix_board_if.h"
|
|
|
|
#include "board_soc.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Replacement for ARMs NVIC functions()
|
|
|
|
*/
|
|
|
|
void NVIC_SetPendingIRQ(IRQn_Type IRQn)
|
|
|
|
{
|
|
|
|
hw_irq_ctrl_raise_im_from_sw(IRQn);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
|
|
|
|
{
|
|
|
|
hw_irq_ctrl_clear_irq(IRQn);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NVIC_DisableIRQ(IRQn_Type IRQn)
|
|
|
|
{
|
|
|
|
hw_irq_ctrl_disable_irq(IRQn);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NVIC_EnableIRQ(IRQn_Type IRQn)
|
|
|
|
{
|
|
|
|
hw_irq_ctrl_enable_irq(IRQn);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
|
|
|
|
{
|
|
|
|
hw_irq_ctrl_prio_set(IRQn, priority);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t NVIC_GetPriority(IRQn_Type IRQn)
|
|
|
|
{
|
|
|
|
return hw_irq_ctrl_get_prio(IRQn);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NVIC_SystemReset(void)
|
|
|
|
{
|
|
|
|
posix_print_warning("%s called. Exiting\n", __func__);
|
|
|
|
posix_exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Replacements for some other CMSIS functions
|
|
|
|
*/
|
|
|
|
void __enable_irq(void)
|
|
|
|
{
|
2020-11-11 05:56:47 +08:00
|
|
|
hw_irq_ctrl_change_lock(false);
|
2020-05-27 04:20:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void __disable_irq(void)
|
|
|
|
{
|
2020-11-11 05:56:47 +08:00
|
|
|
hw_irq_ctrl_change_lock(true);
|
2020-05-27 04:20:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t __get_PRIMASK(void)
|
|
|
|
{
|
|
|
|
return hw_irq_ctrl_get_current_lock();
|
|
|
|
}
|
2021-11-19 17:47:36 +08:00
|
|
|
|
|
|
|
void __set_PRIMASK(uint32_t primask)
|
|
|
|
{
|
|
|
|
hw_irq_ctrl_change_lock(primask != 0);
|
|
|
|
}
|