// 信号发送模块
// Author: 周涛
// Date: 2023-8-16

#include "includes.h"

// 定义全局变量
volatile int32 g_adwSignalSendList[SIGNAL_PERIOD_SEND_TIMES] = {0}; // 一个周期信号的发送队列

// 模块初始化
void signal_send_init()
{
    memset(g_adwSignalSendList, 0, sizeof(int32) * SIGNAL_PERIOD_SEND_TIMES);

    // 生成一个周期信号的发送队列
    signal_send_gen_period_send_list();
}

// 组织一个周期信号的发送队列
void signal_send_gen_period_send_list()
{
    uint16 wCounter = 0;
    int32 *pdwSignalAddress = NULL;
    uint32 *pdwHead = NULL;

    // 获得原始信号保存地址
    signal_gen_query_signal_head_address(&pdwSignalAddress);

    // 组织一个周期信号的发送队列
    for (uint8 i = 0; i < SIGNAL_BASE_ID_BIT_LEN; i++)
    {
        pdwHead = pdwSignalAddress;
        for (uint8 j = 0; j < SIGNAL_SIGNAL_SECOND_SEND_TIMES; j++)
        {
            g_adwSignalSendList[wCounter] = *pdwHead;
            pdwHead++;
            wCounter++;
        }
    }

    return;
}

// 查询信号发送队列
void signal_send_query_period_signal_list(int32 **pdwSignalSendList)
{
    *pdwSignalSendList = g_adwSignalSendList;
}