Paparazzi UAS
v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
|
#include "link_mcu_usart.h"
#include "mcu_periph/uart.h"
#include "led.h"
#include "subsystems/commands.h"
Go to the source code of this file.
Data Structures | |
struct | InterMcuData |
Macros | |
#define | InterMcuBuffer() uart_char_available(&(INTERMCU_LINK)) |
#define | InterMcuUartSend1(c) uart_put_byte(&(INTERMCU_LINK), 0, c) |
#define | InterMcuUartSetBaudrate(_a) uart_periph_set_baudrate(&(INTERMCU_LINK), _a) |
#define | InterMcuUartSendMessage() {} |
#define | InterMcuUartGetch() uart_getch(&(INTERMCU_LINK)) |
#define | INTERMCU_SYNC1 0xB5 |
#define | INTERMCU_SYNC2 0x62 |
#define | InterMcuInitCheksum() { intermcu_data.send_ck_a = intermcu_data.send_ck_b = 0; } |
#define | InterMcuUpdateChecksum(c) { intermcu_data.send_ck_a += c; intermcu_data.send_ck_b += intermcu_data.send_ck_a; } |
#define | InterMcuTrailer() { InterMcuUartSend1(intermcu_data.send_ck_a); InterMcuUartSend1(intermcu_data.send_ck_b); InterMcuUartSendMessage(); } |
#define | InterMcuSend1(c) { uint8_t i8=c; InterMcuUartSend1(i8); InterMcuUpdateChecksum(i8); } |
#define | InterMcuSend2(c) { uint16_t i16=c; InterMcuSend1(i16&0xff); InterMcuSend1(i16 >> 8); } |
#define | InterMcuSend1ByAddr(x) { InterMcuSend1(*x); } |
#define | InterMcuSend2ByAddr(x) { InterMcuSend1(*x); InterMcuSend1(*(x+1)); } |
#define | InterMcuSend4ByAddr(x) { InterMcuSend1(*x); InterMcuSend1(*(x+1)); InterMcuSend1(*(x+2)); InterMcuSend1(*(x+3)); } |
#define | InterMcuHeader(nav_id, msg_id, len) |
#define | MSG_INTERMCU_ID 100 |
#define | MSG_INTERMCU_COMMAND_ID 0x05 |
#define | MSG_INTERMCU_COMMAND_LENGTH (2*(COMMANDS_NB)) |
#define | MSG_INTERMCU_COMMAND(_intermcu_payload, nr) (uint16_t)(*((uint8_t*)_intermcu_payload+0+(2*(nr)))|*((uint8_t*)_intermcu_payload+1+(2*(nr)))<<8) |
#define | InterMcuSend_INTERMCU_COMMAND(cmd) |
#define | MSG_INTERMCU_RADIO_ID 0x08 |
#define | MSG_INTERMCU_RADIO_LENGTH (2*(RADIO_CONTROL_NB_CHANNEL)) |
#define | MSG_INTERMCU_RADIO(_intermcu_payload, nr) (uint16_t)(*((uint8_t*)_intermcu_payload+0+(2*(nr)))|*((uint8_t*)_intermcu_payload+1+(2*(nr)))<<8) |
#define | InterMcuSend_INTERMCU_RADIO(cmd) |
#define | MSG_INTERMCU_FBW_ID 0x06 |
#define | MSG_INTERMCU_FBW_MOD(_intermcu_payload) (uint8_t)(*((uint8_t*)_intermcu_payload+0)) |
#define | MSG_INTERMCU_FBW_STAT(_intermcu_payload) (uint8_t)(*((uint8_t*)_intermcu_payload+1)) |
#define | MSG_INTERMCU_FBW_ERR(_intermcu_payload) (uint8_t)(*((uint8_t*)_intermcu_payload+2)) |
#define | MSG_INTERMCU_FBW_VOLT(_intermcu_payload) (uint16_t)(*((uint8_t*)_intermcu_payload+3)|*((uint8_t*)_intermcu_payload+1+3)<<8) |
#define | MSG_INTERMCU_FBW_CURRENT(_intermcu_payload) (uint16_t)(*((uint8_t*)_intermcu_payload+5)|*((uint8_t*)_intermcu_payload+1+5)<<8) |
#define | InterMcuSend_INTERMCU_FBW(mod, stat, err, volt, current) |
#define | MSG_INTERMCU_TRIM_ID 0x07 |
#define | MSG_INTERMCU_TRIM_ROLL(_intermcu_payload) (uint16_t)(*((uint8_t*)_intermcu_payload+0)|*((uint8_t*)_intermcu_payload+1)<<8) |
#define | MSG_INTERMCU_TRIM_PITCH(_intermcu_payload) (uint16_t)(*((uint8_t*)_intermcu_payload+2)|*((uint8_t*)_intermcu_payload+3)<<8) |
#define | InterMcuSend_INTERMCU_TRIM(roll, pitch) |
#define | LINK_MCU_UNINIT 0 |
#define | LINK_MCU_GOT_SYNC1 1 |
#define | LINK_MCU_GOT_SYNC2 2 |
#define | LINK_MCU_GOT_CLASS 3 |
#define | LINK_MCU_GOT_ID 4 |
#define | LINK_MCU_GOT_LEN1 5 |
#define | LINK_MCU_GOT_LEN2 6 |
#define | LINK_MCU_GOT_PAYLOAD 7 |
#define | LINK_MCU_GOT_CHECKSUM1 8 |
#define | INTERMCU_MAX_PAYLOAD 255 |
Functions | |
void | intermcu_parse (uint8_t c) |
void | parse_mavpilot_msg (void) |
void | link_mcu_init (void) |
void | link_mcu_event_task (void) |
Variables | |
struct InterMcuData | intermcu_data |
struct link_mcu_msg | link_mcu_from_ap_msg |
struct link_mcu_msg | link_mcu_from_fbw_msg |
struct InterMcuData |
#define INTERMCU_MAX_PAYLOAD 255 |
Definition at line 141 of file link_mcu_usart.c.
Referenced by intermcu_parse().
#define INTERMCU_SYNC1 0xB5 |
Definition at line 42 of file link_mcu_usart.c.
Referenced by intermcu_parse().
#define INTERMCU_SYNC2 0x62 |
Definition at line 43 of file link_mcu_usart.c.
Referenced by intermcu_parse().
#define InterMcuBuffer | ( | ) | uart_char_available(&(INTERMCU_LINK)) |
Definition at line 33 of file link_mcu_usart.c.
Referenced by link_mcu_event_task().
#define InterMcuHeader | ( | nav_id, | |
msg_id, | |||
len | |||
) |
Definition at line 55 of file link_mcu_usart.c.
#define InterMcuInitCheksum | ( | ) | { intermcu_data.send_ck_a = intermcu_data.send_ck_b = 0; } |
Definition at line 45 of file link_mcu_usart.c.
#define InterMcuSend1 | ( | c | ) | { uint8_t i8=c; InterMcuUartSend1(i8); InterMcuUpdateChecksum(i8); } |
Definition at line 49 of file link_mcu_usart.c.
#define InterMcuSend1ByAddr | ( | x | ) | { InterMcuSend1(*x); } |
Definition at line 51 of file link_mcu_usart.c.
#define InterMcuSend2 | ( | c | ) | { uint16_t i16=c; InterMcuSend1(i16&0xff); InterMcuSend1(i16 >> 8); } |
Definition at line 50 of file link_mcu_usart.c.
#define InterMcuSend2ByAddr | ( | x | ) | { InterMcuSend1(*x); InterMcuSend1(*(x+1)); } |
Definition at line 52 of file link_mcu_usart.c.
#define InterMcuSend4ByAddr | ( | x | ) | { InterMcuSend1(*x); InterMcuSend1(*(x+1)); InterMcuSend1(*(x+2)); InterMcuSend1(*(x+3)); } |
Definition at line 53 of file link_mcu_usart.c.
#define InterMcuSend_INTERMCU_COMMAND | ( | cmd | ) |
Definition at line 75 of file link_mcu_usart.c.
#define InterMcuSend_INTERMCU_FBW | ( | mod, | |
stat, | |||
err, | |||
volt, | |||
current | |||
) |
Definition at line 105 of file link_mcu_usart.c.
#define InterMcuSend_INTERMCU_RADIO | ( | cmd | ) |
Definition at line 88 of file link_mcu_usart.c.
#define InterMcuSend_INTERMCU_TRIM | ( | roll, | |
pitch | |||
) |
Definition at line 119 of file link_mcu_usart.c.
#define InterMcuTrailer | ( | ) | { InterMcuUartSend1(intermcu_data.send_ck_a); InterMcuUartSend1(intermcu_data.send_ck_b); InterMcuUartSendMessage(); } |
Definition at line 47 of file link_mcu_usart.c.
#define InterMcuUartGetch | ( | ) | uart_getch(&(INTERMCU_LINK)) |
Definition at line 37 of file link_mcu_usart.c.
Referenced by link_mcu_event_task().
#define InterMcuUartSend1 | ( | c | ) | uart_put_byte(&(INTERMCU_LINK), 0, c) |
Definition at line 34 of file link_mcu_usart.c.
#define InterMcuUartSendMessage | ( | ) | {} |
Definition at line 36 of file link_mcu_usart.c.
#define InterMcuUartSetBaudrate | ( | _a | ) | uart_periph_set_baudrate(&(INTERMCU_LINK), _a) |
Definition at line 35 of file link_mcu_usart.c.
#define InterMcuUpdateChecksum | ( | c | ) | { intermcu_data.send_ck_a += c; intermcu_data.send_ck_b += intermcu_data.send_ck_a; } |
Definition at line 46 of file link_mcu_usart.c.
#define LINK_MCU_GOT_CHECKSUM1 8 |
Definition at line 138 of file link_mcu_usart.c.
Referenced by intermcu_parse().
#define LINK_MCU_GOT_CLASS 3 |
Definition at line 133 of file link_mcu_usart.c.
Referenced by intermcu_parse().
#define LINK_MCU_GOT_ID 4 |
Definition at line 134 of file link_mcu_usart.c.
Referenced by intermcu_parse().
#define LINK_MCU_GOT_LEN1 5 |
Definition at line 135 of file link_mcu_usart.c.
Referenced by intermcu_parse().
#define LINK_MCU_GOT_LEN2 6 |
Definition at line 136 of file link_mcu_usart.c.
Referenced by intermcu_parse().
#define LINK_MCU_GOT_PAYLOAD 7 |
Definition at line 137 of file link_mcu_usart.c.
Referenced by intermcu_parse().
#define LINK_MCU_GOT_SYNC1 1 |
Definition at line 131 of file link_mcu_usart.c.
Referenced by intermcu_parse().
#define LINK_MCU_GOT_SYNC2 2 |
Definition at line 132 of file link_mcu_usart.c.
Referenced by intermcu_parse().
#define LINK_MCU_UNINIT 0 |
Definition at line 130 of file link_mcu_usart.c.
Referenced by intermcu_parse(), and link_mcu_init().
#define MSG_INTERMCU_COMMAND | ( | _intermcu_payload, | |
nr | |||
) | (uint16_t)(*((uint8_t*)_intermcu_payload+0+(2*(nr)))|*((uint8_t*)_intermcu_payload+1+(2*(nr)))<<8) |
Definition at line 73 of file link_mcu_usart.c.
Referenced by parse_mavpilot_msg().
#define MSG_INTERMCU_COMMAND_ID 0x05 |
Definition at line 71 of file link_mcu_usart.c.
Referenced by parse_mavpilot_msg().
#define MSG_INTERMCU_COMMAND_LENGTH (2*(COMMANDS_NB)) |
Definition at line 72 of file link_mcu_usart.c.
#define MSG_INTERMCU_FBW_CURRENT | ( | _intermcu_payload | ) | (uint16_t)(*((uint8_t*)_intermcu_payload+5)|*((uint8_t*)_intermcu_payload+1+5)<<8) |
Definition at line 103 of file link_mcu_usart.c.
Referenced by parse_mavpilot_msg().
Definition at line 100 of file link_mcu_usart.c.
Referenced by parse_mavpilot_msg().
#define MSG_INTERMCU_FBW_ID 0x06 |
Definition at line 97 of file link_mcu_usart.c.
Referenced by parse_mavpilot_msg().
Definition at line 98 of file link_mcu_usart.c.
Referenced by parse_mavpilot_msg().
Definition at line 99 of file link_mcu_usart.c.
Referenced by parse_mavpilot_msg().
#define MSG_INTERMCU_FBW_VOLT | ( | _intermcu_payload | ) | (uint16_t)(*((uint8_t*)_intermcu_payload+3)|*((uint8_t*)_intermcu_payload+1+3)<<8) |
Definition at line 101 of file link_mcu_usart.c.
Referenced by parse_mavpilot_msg().
#define MSG_INTERMCU_ID 100 |
Definition at line 68 of file link_mcu_usart.c.
Referenced by parse_mavpilot_msg().
#define MSG_INTERMCU_RADIO | ( | _intermcu_payload, | |
nr | |||
) | (uint16_t)(*((uint8_t*)_intermcu_payload+0+(2*(nr)))|*((uint8_t*)_intermcu_payload+1+(2*(nr)))<<8) |
Definition at line 86 of file link_mcu_usart.c.
Referenced by parse_mavpilot_msg().
#define MSG_INTERMCU_RADIO_ID 0x08 |
Definition at line 84 of file link_mcu_usart.c.
Referenced by parse_mavpilot_msg().
#define MSG_INTERMCU_RADIO_LENGTH (2*(RADIO_CONTROL_NB_CHANNEL)) |
Definition at line 85 of file link_mcu_usart.c.
#define MSG_INTERMCU_TRIM_ID 0x07 |
Definition at line 115 of file link_mcu_usart.c.
Referenced by parse_mavpilot_msg().
#define MSG_INTERMCU_TRIM_PITCH | ( | _intermcu_payload | ) | (uint16_t)(*((uint8_t*)_intermcu_payload+2)|*((uint8_t*)_intermcu_payload+3)<<8) |
Definition at line 117 of file link_mcu_usart.c.
Referenced by parse_mavpilot_msg().
#define MSG_INTERMCU_TRIM_ROLL | ( | _intermcu_payload | ) | (uint16_t)(*((uint8_t*)_intermcu_payload+0)|*((uint8_t*)_intermcu_payload+1)<<8) |
Definition at line 116 of file link_mcu_usart.c.
Referenced by parse_mavpilot_msg().
void intermcu_parse | ( | uint8_t | c | ) |
Definition at line 160 of file link_mcu_usart.c.
References InterMcuData::ck_a, InterMcuData::ck_b, InterMcuData::error_cnt, intermcu_data, INTERMCU_MAX_PAYLOAD, INTERMCU_SYNC1, INTERMCU_SYNC2, InterMcuData::len, LINK_MCU_GOT_CHECKSUM1, LINK_MCU_GOT_CLASS, LINK_MCU_GOT_ID, LINK_MCU_GOT_LEN1, LINK_MCU_GOT_LEN2, LINK_MCU_GOT_PAYLOAD, LINK_MCU_GOT_SYNC1, LINK_MCU_GOT_SYNC2, LINK_MCU_UNINIT, InterMcuData::msg_available, InterMcuData::msg_buf, InterMcuData::msg_class, InterMcuData::msg_id, InterMcuData::msg_idx, and InterMcuData::status.
Referenced by link_mcu_event_task().
void link_mcu_event_task | ( | void | ) |
Definition at line 374 of file link_mcu_usart.c.
References intermcu_data, intermcu_parse(), InterMcuBuffer, InterMcuUartGetch, InterMcuData::msg_available, and parse_mavpilot_msg().
void link_mcu_init | ( | void | ) |
Definition at line 283 of file link_mcu_usart.c.
References DefaultPeriodic, InterMcuData::error_cnt, intermcu_data, link_mcu_on_can_msg(), LINK_MCU_UNINIT, InterMcuData::msg_available, ppz_can_init(), register_periodic_telemetry(), send_commands(), send_fbw_status(), and InterMcuData::status.
|
inline |
Definition at line 297 of file link_mcu_usart.c.
References ap_state, fbw_state, inter_mcu_received_ap, inter_mcu_received_fbw, intermcu_data, LED_TOGGLE, InterMcuData::msg_buf, InterMcuData::msg_class, InterMcuData::msg_id, MSG_INTERMCU_COMMAND, MSG_INTERMCU_COMMAND_ID, MSG_INTERMCU_FBW_CURRENT, MSG_INTERMCU_FBW_ERR, MSG_INTERMCU_FBW_ID, MSG_INTERMCU_FBW_MOD, MSG_INTERMCU_FBW_STAT, MSG_INTERMCU_FBW_VOLT, MSG_INTERMCU_ID, MSG_INTERMCU_RADIO, MSG_INTERMCU_RADIO_ID, MSG_INTERMCU_TRIM_ID, MSG_INTERMCU_TRIM_PITCH, MSG_INTERMCU_TRIM_ROLL, and RADIO_CONTROL_NB_CHANNEL.
Referenced by link_mcu_event_task().
struct InterMcuData intermcu_data |
Definition at line 156 of file link_mcu_usart.c.
Referenced by intermcu_parse(), link_mcu_event_task(), link_mcu_init(), and parse_mavpilot_msg().
struct link_mcu_msg link_mcu_from_ap_msg |
Definition at line 241 of file link_mcu_usart.c.
struct link_mcu_msg link_mcu_from_fbw_msg |
Definition at line 242 of file link_mcu_usart.c.