#include <type_define.h>
#include "Fucp_Ape0_slot_ind.h"
#include "phy_struct.h"

__APE_DM0 uint32_t g_slot_ind_dm0[8] = {0}; //32byte

void Slot_ind_Task()
{
    uint16_t start_slot = TIME_SLOT();
    g_time_start[0] = TIME_NS();
    RUN_CNT(TRACE_SLOTIND_ADDR, 0);


    uint32_t cur_sfn = get_rx_nr_sfn();
    uint32_t cur_slot = get_rx_nr_slot();

    uint32_t msg_general_len = sizeof(L1GeneralMsgHdr_t);
    uint32_t payload_len = sizeof(L1SlotIndication_t);
    uint32_t msg_len = sizeof(L1MsgHdr_t) + msg_general_len + payload_len;

    L1MsgHdr_t *msg_header = (L1MsgHdr_t *)g_slot_ind_dm0;
    L1GeneralMsgHdr_t* msg_general_hdr = (L1GeneralMsgHdr_t*)(msg_header + 1);
    L1SlotIndication_t *slot_ind = (L1SlotIndication_t *)(msg_general_hdr + 1);


    msg_header->msgNum = 1;
    msg_header->rev = 0;

    msg_general_hdr->msgId = FAPI_SLOT_INDICATION;
    msg_general_hdr->msgSize = payload_len;

    osp_phy_msg_send((char*)msg_header, msg_len);

    RUN_CNT(TRACE_SLOTIND_ADDR, 1);
    TRACE_MAX(TRACE_SLOTIND_ADDR, 2, Time_offset(0) );
}