/* Set interrupt vector priority level. 
Set the priority level of an external interrupt or exception. */
enum status_code system_interrupt_set_priority(const enum system_interrupt_vector vector, const enum system_interrupt_priority_level priority_level)
/* Set interrupt vector priority level. 
Set the priority level of an external interrupt or exception. */
enum status_code system_interrupt_set_priority(const enum system_interrupt_vector vector, const enum system_interrupt_priority_level priority_level)
{
	enum status_code status = STATUS_OK;
	if (vector >= _SYSTEM_INTERRUPT_EXTERNAL_VECTOR_START) {
		uint8_t register_num = vector / 4;
		uint8_t priority_pos = ((vector % 4) * 8) + (8 - __NVIC_PRIO_BITS);
		NVIC->IP[register_num] =
				(NVIC->IP[register_num] & ~(_SYSTEM_INTERRUPT_PRIORITY_MASK << priority_pos)) |
				(priority_level << priority_pos);
	} else if (vector == SYSTEM_INTERRUPT_SYSTICK) {
		SCB->SHP[1] = (priority_level << _SYSTEM_INTERRUPT_SYSTICK_PRI_POS);
	} else {
		Assert(false);
		status = STATUS_ERR_INVALID_ARG;
	}
	return status;
}