<commit_before>#include <armv7m/nvic.h>
#include <armv7m/system.h>
#include <printk.h>
#include <utils.h>
#include <board.h>

void nvic_enable_interrupt(unsigned int num)
{
	unsigned int base = num / 32;
	unsigned int off = num % 32;
	unsigned int nvic_reg;

	switch (base) {
		case 0:
			nvic_reg = NVIC_ISER0;
			break;
		case 1:
			nvic_reg = NVIC_ISER1;
			break;
		case 2:
			nvic_reg = NVIC_ISER2;
			break;
		case 3:
			nvic_reg = NVIC_ISER3;
			break;
	}

	writel(nvic_reg, (1 << off));
}

void nvic_disable_interrupt(unsigned int num)
{
	unsigned int base = num / 32;
	unsigned int off = num % 32;
	unsigned int nvic_reg;

	switch (base) {
		case 0:
			nvic_reg = NVIC_ICER0;
			break;
		case 1:
			nvic_reg = NVIC_ICER1;
			break;
		case 2:
			nvic_reg = NVIC_ICER2;
			break;
		case 3:
			nvic_reg = NVIC_ICER3;
			break;
	}

	writel(nvic_reg, (1 << off));
}

void nvic_set_interrupt(unsigned int num)
{
	unsigned int base = num / 32;
	unsigned int off = num % 32;
	unsigned int nvic_reg;

	switch (base) {
		case 0:
			nvic_reg = NVIC_ISPR0;
			break;
		case 1:
			nvic_reg = NVIC_ISPR1;
			break;
		case 2:
			nvic_reg = NVIC_ISPR2;
			break;
		case 3:
			nvic_reg = NVIC_ISPR3;
			break;
	}

	writel(nvic_reg, (1 << off));
}

void nvic_clear_interrupt(unsigned int num)
{
	unsigned int base = num / 32;
	unsigned int off = num % 32;
	unsigned int nvic_reg;

	switch (base) {
		case 0:
			nvic_reg = NVIC_ICPR0;
			break;
		case 1:
			nvic_reg = NVIC_ICPR1;
			break;
		case 2:
			nvic_reg = NVIC_ICPR2;
			break;
		case 3:
			nvic_reg = NVIC_ICPR3;
			break;
	}

	writel(nvic_reg, (1 << off));
}<commit_msg>armv7m: nvic: simplify nvic register access<commit_after>#include <armv7m/nvic.h>
#include <armv7m/system.h>
#include <printk.h>
#include <utils.h>
#include <board.h>

void nvic_enable_interrupt(unsigned int num)
{
	unsigned int *nvic_reg = (unsigned int *)NVIC_ISER0;

	writel((unsigned int)&nvic_reg[num >> 0x5], (1 << (num & 0x1F)));
}

void nvic_disable_interrupt(unsigned int num)
{
	unsigned int *nvic_reg = (unsigned int *)NVIC_ICER0;

	writel((unsigned int)&nvic_reg[num >> 0x5], (1 << (num & 0x1F)));
}

void nvic_set_interrupt(unsigned int num)
{
	unsigned int *nvic_reg = (unsigned int *)NVIC_ISPR0;

	writel((unsigned int)&nvic_reg[num >> 0x5], (1 << (num & 0x1F)));
}

void nvic_clear_interrupt(unsigned int num)
{

	unsigned int *nvic_reg = (unsigned int *)NVIC_ICPR0;

	writel((unsigned int)&nvic_reg[num >> 0x5], (1 << (num & 0x1F)));
}
{'fraction_non_alphanumeric': 0.1293974929235746, 'fraction_numerical': 0.032753740396279825, 'mean_word_length': 3.659133709981168, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6473686', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1054, 'n_words': 257}