/**
 * \file    utils.c
 * \brief   System adaptation layer utilities
 *
 * \par     Copyright (c) 2018 UWE Technologies Corp., Ltd. All Rights Reserved.
 * \author  James
 * \date    2018-03-05
 * \version 
 * 
 * \history 
 *  Date        Note
 *  2018-03-05  Original Creation
 * 
 */

#include "types.h"
#include "utils.h"

void delay(int cnt)
{
	while(cnt--)
	{
		asm ("nop");
	}
}

u32_t set_bits_get(u32_t value)
{
    u32_t cnt = 0;
    u32_t i;
    
    for (i = 0; i < 32; i++)
    {
        if (SAL_IS_BIT_SET(value, i))
            cnt++;
    }
    return cnt;
}

u32_t clear_bits_get(u32_t value)
{
    u32_t cnt = 0;
    u32_t i;
    
    for (i = 0; i < 32; i++)
    {
        if (SAL_IS_BIT_CLEARED(value, i))
            cnt++;
    }
    return cnt;
}
