36 #include "modulesettings.h"
37 #include "attitudeactual.h"
40 #include "flightbatterystate.h"
41 #include "manualcontrolcommand.h"
43 #if defined(PIOS_MSP_STACK_SIZE)
44 #define STACK_SIZE_BYTES PIOS_MSP_STACK_SIZE
46 #define STACK_SIZE_BYTES 800
48 #define THREAD_PRIORITY PIOS_THREAD_PRIO_LOW
51 #define MSP_TIMEOUT 10 // ms
52 #define MSP_BRIDGE_MAGIC 0x97a4dc58
58 struct pios_com_dev *
com;
91 if (len <
sizeof(*att))
94 AttitudeActualData attActual;
95 AttitudeActualGet(&attActual);
97 const float rpy[3] = {
98 (float)att->
angx / 10.0f,
99 (
float)att->
angy / -10.0f,
102 attActual.Roll = rpy[0];
103 attActual.Pitch = rpy[1];
104 attActual.Yaw = rpy[2];
113 AttitudeActualSet(&attActual);
121 if (len <
sizeof(*imu))
127 accels.x = (float)imu->
accx * 9.8f / 512;
128 accels.y = (
float)imu->
accy * 9.8f / 512;
129 accels.z = (float)imu->
accz * 9.8f / 512;
135 gyros.x = (float)imu->
gyrx / 4.096f;
136 gyros.y = (
float)imu->
gyry / 4.096f;
137 gyros.z = (float)imu->
gyrz / 4.096f;
146 if (len <
sizeof(*analog))
149 FlightBatteryStateData batt;
150 FlightBatteryStateGet(&batt);
151 batt.Voltage = (float)analog->
vbat / 10.0f;
153 batt.Current = (
float)analog->
amperage;
155 FlightBatteryStateSet(&batt);
157 ManualControlCommandData cntrl;
158 ManualControlCommandGet(&cntrl);
159 cntrl.RawRssi = analog->
rssi;
160 cntrl.Rssi = analog->
rssi * 100 / 1024;
161 ManualControlCommandSet(&cntrl);
173 ModuleSettingsMSPSpeedGet(&baud);
291 memset(msp, 0,
sizeof(*msp));
305 #define INIT_CHECK_UAVO(name) name##Initialize(); check &= (name##Handle() != NULL)
#define INIT_CHECK_UAVO(name)
static bool msp_handler(enum msp_message_id msg_id, void *data, uint8_t len, void *context)
uint32_t PIOS_Thread_Systime(void)
int32_t msp_send_com(struct msp_parser *parser, struct pios_com_dev *com, enum msp_message_id msg_id, void *payload, uint8_t len)
Construct and send an MSP message via PIOS_COM.
void RPY2Quaternion(const float rpy[3], float q[4])
static void set_baudrate(struct msp_bridge *m)
bool PIOS_Modules_IsEnabled(enum pios_modules module)
struct pios_com_dev * com
enum msp_message_id msg_id
static bool msp_unpack_raw_imu(void *data, uint8_t len)
int32_t msp_register_handler(struct msp_parser *parser, msp_handler_t handler, void *context)
Register a handler for valid received messages.
void * PIOS_malloc(size_t size)
struct msp_parser * parser
static struct msp_bridge * msp
void PIOS_HAL_ConfigureSerialSpeed(uintptr_t com_id, HwSharedSpeedBpsOptions speed)
uint8_t data[XFER_BYTES_PER_PACKET]
static int32_t mspUavoBridge_Init(void)
Initialize the MSP to UAVO bridge module.
#define MODULE_INITCALL(ifn, sfn)
static int32_t mspUavoBridge_Start(void)
Start the MSP to UAVO bridge module.
static bool msp_unpack_analog(void *data, uint8_t len)
enum msp_message_id expected
struct pios_thread * PIOS_Thread_Create(void(*fp)(void *), const char *namep, size_t stack_bytes, void *argp, enum pios_thread_prio_e prio)
static TaskInfoRunningElem task
int32_t TaskMonitorAdd(TaskInfoRunningElem task, struct pios_thread *threadp)
static bool msp_unpack_attitude(void *data, uint8_t len)
bool PIOS_Thread_Period_Elapsed(const uint32_t prev_systime, const uint32_t increment_ms)
Determine if a period has elapsed since a datum.
void PIOS_free(void *buf)
void PIOS_Thread_Sleep(uint32_t time_ms)
Header for Coordinate conversions library in coordinate_conversions.c.
static bool msp_bridge_validate(struct msp_bridge *m)
Includes PiOS and core architecture components.
static void mspUavoBridge_Task(void *parameters)
MSP to UAVO bridge main task.
uintptr_t pios_com_msp_id
int32_t msp_process_com(struct msp_parser *parser, struct pios_com_dev *com)
Process MSP stream from PIOS_COM.
static struct msp_message_list_item message_list[]
struct msp_parser * msp_parser_init(enum msp_parser_type type)
Initialize a new parser instance.
static enum msp_message_id get_next_message(void)
static bool module_enabled
#define PIOS_Assert(test)