
#include "utils.h"
#include "hal_math.h"

static uint64_t base_data;

void data_bit_move(uint8_t start_bit, uint8_t bit_len, uint64_t data)
{
    uint64_t mask        = 0;
    uint64_t source_data = (uint64_t)data;
    mask                 = hal_pow(2, bit_len) - 1;
    base_data |= (mask & source_data) << start_bit;
}

void product_array(uint8_t send_array[8])
{
    send_array[0] = (uint8_t)base_data;
    send_array[1] = (uint8_t)(base_data >> 8);
    send_array[2] = (uint8_t)(base_data >> 16);
    send_array[3] = (uint8_t)(base_data >> 24);
    send_array[4] = (uint8_t)(base_data >> 32);
    send_array[5] = (uint8_t)(base_data >> 40);
    send_array[6] = (uint8_t)(base_data >> 48);
    send_array[7] = (uint8_t)(base_data >> 56);
    base_data     = 0;
}