| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #ifndef __SOFT_GS_H
- #define __SOFT_GS_H
- #include "common.h"
- #include "drv_usart.h"
- #include "rkfifo.h"
- #include "vklink.h"
- #include <stdbool.h>
- #include <stdint.h>
- /* 协议类型 */
- typedef enum
- {
- /* 地面站使用 VKLINK 协议 */
- GCS_LINK_PROTOCAL_TYPE_VKLINK = 0,
- } GcsLinkProtocalType;
- /* 地面站连接对象 */
- struct GCS_Link
- {
- /* 协议类型 */
- GcsLinkProtocalType link_protocal_type;
- /* 串口发收消息 */
- VKlink_Msg_Type vklink_rx_msg;
- VKlink_Msg_Type vklink_tx_msg;
- /* 地面站 vklink 协议版本, 现在有 300 版和 400 两个版本 */
- uint16_t vklink_protocal_version;
- /* 地面站连接状态 */
- comp_status link_status;
- uint32_t link_lost_time_us;
- uint32_t last_check_time_us;
- struct _uart_device *uart;
- uint8_t msg_pack_buffer[512];
- /* 常发消息使用记时 */
- uint32_t _last_tx1hz_time_us;
- uint32_t _last_tx2hz_time_us;
- uint32_t _last_tx5hz_time_us;
- uint32_t _last_tx10hz_time_us;
- uint8_t _last_tx1hz_id;
- uint8_t _last_tx2hz_id;
- uint8_t _last_tx5hz_id;
- uint8_t _last_tx10hz_id;
- /* 当前多级模式选中的 sysid */
- uint8_t _current_sysid;
- };
- extern struct GCS_Link gcs_link;
- /* 地面站串口初始化 */
- int gcs_init(struct GCS_Link *gcs, unsigned int gs_bps);
- /* 地面站串口解析和发送消息轮询函数 */
- void gs_receive_msg_poll(struct GCS_Link *pgcs);
- void gs_send_msg_poll(struct GCS_Link *pgcs);
- uint8_t *gs_get_uart_tx_buffer_address(void);
- comp_status gs_get_link_status(struct GCS_Link *pgcs);
- void gs_tx_vklink_msg(struct GCS_Link *pgcs, const VKlink_Msg_Type *msg);
- void gs_set_vklink_protocal_version(struct GCS_Link *gcs, uint16_t version);
- /* 发送 pos 点信息 */
- void gs_send_pos_msg(struct GCS_Link *pgcs, uint32_t pos_num);
- /* 发送 ack 应答信息 */
- void gs_send_ack_msg(struct GCS_Link *pgcs, void *arg);
- /* 发送载荷透传信息 */
- void gs_send_payload_msg(struct GCS_Link *pgcs, const void * pdata, uint32_t len);
- #endif
|