mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-11 19:24:10 +01:00
89a6d6d912
This defines the SPI message format as well as a few initial messages for moving data across the link. The v0 messages are place holders for firmware download in the bootloader. The v1 messages are to be used by the main application. Note: This is not the final protocol definition. Subject to change without notice. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1004 ebee16cc-31ac-478f-84a7-5cbb03baadba
59 lines
1.5 KiB
C
59 lines
1.5 KiB
C
#include "pios_opahrs_proto.h"
|
|
#include <string.h> /* memset */
|
|
|
|
void opahrs_msg_v0_init_rx (struct opahrs_msg_v0 * msg)
|
|
{
|
|
/* Make sure we start with bad magic in the rx buffer */
|
|
msg->head.magic = 0;
|
|
msg->head.type = 0;
|
|
msg->tail.magic = 0;
|
|
}
|
|
|
|
void opahrs_msg_v0_init_user_tx (struct opahrs_msg_v0 * msg, enum opahrs_msg_v0_tag tag)
|
|
{
|
|
msg->head.magic = OPAHRS_MSG_MAGIC_HEAD;
|
|
msg->head.type = OPAHRS_MSG_TYPE_USER_V0;
|
|
|
|
msg->payload.user.t = tag;
|
|
|
|
msg->tail.magic = OPAHRS_MSG_MAGIC_TAIL;
|
|
}
|
|
|
|
void opahrs_msg_v0_init_link_tx (struct opahrs_msg_v0 * msg, enum opahrs_msg_link_tag tag)
|
|
{
|
|
msg->head.magic = OPAHRS_MSG_MAGIC_HEAD;
|
|
msg->head.type = OPAHRS_MSG_TYPE_LINK;
|
|
|
|
msg->payload.link.t = tag;
|
|
|
|
msg->tail.magic = OPAHRS_MSG_MAGIC_TAIL;
|
|
}
|
|
|
|
void opahrs_msg_v1_init_rx (struct opahrs_msg_v1 * msg)
|
|
{
|
|
/* Make sure we start with bad magic in the rx buffer */
|
|
msg->head.magic = 0;
|
|
msg->head.type = 0;
|
|
msg->tail.magic = 0;
|
|
}
|
|
|
|
void opahrs_msg_v1_init_user_tx (struct opahrs_msg_v1 * msg, enum opahrs_msg_v1_tag tag)
|
|
{
|
|
msg->head.magic = OPAHRS_MSG_MAGIC_HEAD;
|
|
msg->head.type = OPAHRS_MSG_TYPE_USER_V1;
|
|
|
|
msg->payload.user.t = tag;
|
|
|
|
msg->tail.magic = OPAHRS_MSG_MAGIC_TAIL;
|
|
}
|
|
|
|
void opahrs_msg_v1_init_link_tx (struct opahrs_msg_v1 * msg, enum opahrs_msg_link_tag tag)
|
|
{
|
|
msg->head.magic = OPAHRS_MSG_MAGIC_HEAD;
|
|
msg->head.type = OPAHRS_MSG_TYPE_LINK;
|
|
|
|
msg->payload.link.t = tag;
|
|
|
|
msg->tail.magic = OPAHRS_MSG_MAGIC_TAIL;
|
|
}
|