Files
kunlun/plc/halmac/hw_desc/mac_desc_api.c

95 lines
3.0 KiB
C
Raw Permalink Normal View History

2024-09-28 14:24:04 +08:00
/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
#include "iot_config.h"
#include "plc_protocol.h"
#include "mpdu_frame.h"
#include "rx_desc_reg_api.h"
#include "tx_desc_reg_api.h"
#include "mac_desc_api.h"
uint32_t mac_desc_get_pb_head_from_rx_pb_st(uint8_t proto, void *pb_st)
{
/* sg: lower 8bit is used
* spg: all 32bit is used
* gp: all 32bit is used
*/
uint32_t pb_header = 0;
IOT_ASSERT(pb_st);
#if SUPPORT_SMART_GRID
if (PLC_PROTO_TYPE_SG == proto) {
sg_sof_pb_hdr_t *sg_pb_head = (sg_sof_pb_hdr_t *)&pb_header;
sg_pb_head->mac_frame_start = \
(uint8_t)mac_rx_pb_st_get_msdu_start(pb_st);
sg_pb_head->mac_frame_end = \
(uint8_t)mac_rx_pb_st_get_msdu_end(pb_st);
sg_pb_head->seq = (uint8_t)mac_rx_pb_st_get_ssn(pb_st);;
} else
#endif
#if SUPPORT_SOUTHERN_POWER_GRID
if (PLC_PROTO_TYPE_SPG == proto) {
spg_sof_pb_hdr_t *spg_pb_head = (spg_sof_pb_hdr_t *)&pb_header;
spg_pb_head->seq = (uint16_t)mac_rx_pb_st_get_ssn(pb_st);;
} else
#endif
#if SUPPORT_GREEN_PHY
if (PLC_PROTO_TYPE_GP == proto) {
//TODO: add gp code
gp_sof_pb_hdr_t *gp_pb_head = (gp_sof_pb_hdr_t *)&pb_header;
gp_pb_head->ssn = (uint16_t)mac_rx_pb_st_get_ssn(pb_st);
} else
#endif
{
//do not delete this case
}
return pb_header;
}
void mac_beacon_send_fill_pb_start(uint32_t proto, \
tx_pb_start *pb_start, uint32_t bcn_buf)
{
IOT_ASSERT(pb_start && bcn_buf);
switch (proto) {
#if SUPPORT_SMART_GRID
case PLC_PROTO_TYPE_SG:
{
sg_sof_pb_hdr_t sg_pb_header_data = { 0, 1, 1 }; //sg pb header
pb_start->next_pb = NULL;
pb_start->pb_buf_addr = bcn_buf;
pb_start->sof_pb_header = *(uint8_t*)&sg_pb_header_data;
break;
}
#endif
#if SUPPORT_SOUTHERN_POWER_GRID
case PLC_PROTO_TYPE_SPG:
{
spg_sof_pb_hdr_t spg_pb_header_data = { 0, 0 }; //spg pb header
pb_start->next_pb = NULL;
pb_start->pb_buf_addr = bcn_buf;
pb_start->sof_pb_header = *(uint16_t*)&spg_pb_header_data;
break;
}
#endif
default:
IOT_ASSERT(0);
break;
}
}