/*
 * Author: username
 * Date: 2024
 * filename: RegEdit.c
 * description: module_purpose
 */

#include "RegEdit.h"

void RegEdit_SetRegister(void *reg)
{
    uint8_t *reg_ptr = (uint8_t *)reg;
    *reg_ptr         = 0xFF;
}

void RegEdit_ClearRegister(void *reg)
{
    uint8_t *reg_ptr = (uint8_t *)reg;
    *reg_ptr         = 0x00;
}

void RegEdit_SetBit(void *reg, uint8_t bit_num)
{
    uint8_t *reg_ptr = (uint8_t *)reg;
    *reg_ptr |= (uint8_t)(1 << bit_num);
}

void RegEdit_ClearBit(void *reg, uint8_t bit_num)
{
    uint8_t *reg_ptr = (uint8_t *)reg;
    *reg_ptr &= ~(1 << bit_num);
}

bool RegEdit_IsBitSet(void *reg, uint8_t bit_num)
{
    uint8_t *reg_ptr = (uint8_t *)reg;
    return *reg_ptr & (1 << bit_num);
}

void RegEdit_OR_Num(void *reg, uint8_t num)
{
    uint8_t *reg_ptr = (uint8_t *)reg;
    *reg_ptr |= num;
}

void RegEdit_AND_Num(void *reg, uint8_t num)
{
    uint8_t *reg_ptr = (uint8_t *)reg;
    *reg_ptr &= num;
}

void RegEdit_SetNum(void *reg, uint8_t num)
{
    uint8_t *reg_ptr = (uint8_t *)reg;
    *reg_ptr         = num;
}

uint8_t RegEdit_ReadReg(void *reg)
{
    uint8_t *reg_ptr = (uint8_t *)reg;
    return *reg_ptr;
}
