Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
pdec.c File Reference
#include "modules/decawave/pdec.h"
#include "mcu_periph/uart.h"
#include "modules/datalink/downlink.h"
#include "modules/core/abi.h"
#include "modules/core/abi_sender_ids.h"
#include <stdio.h>
#include <string.h>
+ Include dependency graph for pdec.c:

Go to the source code of this file.

Data Structures

struct  pdec_cmd_payload
 
struct  pdec_target_cmd_payload
 
struct  pdec_error_payload
 
struct  pdec_distance_payload
 
struct  pdec_device_list_payload
 
struct  pdec_send_data_result_payload
 
struct  pdec_ranging_event_payload
 
struct  pdec_tdoa_report_payload
 
struct  pdec_tdoa_report_event_payload
 

Macros

#define PDEC_SYNC_BYTE   0xff
 
#define PDEC_FRAME_OVERHEAD   4
 
#define PDEC_PACKED   __attribute__((packed))
 

Functions

static void _pdec_init (pdec_t *pdec)
 
static void _pdec_periodic_report (pdec_t *pdec)
 
static void _pdec_event (pdec_t *pdec)
 
static bool pdec_send_frame (pdec_t *pdec, const uint8_t *payload, uint8_t payload_len)
 
static void pdec_parse_distance_result (struct pdec_distance_result *result, const struct pdec_distance_payload *payload)
 
static void pdec_dispatch_frame (pdec_t *pdec)
 
static void pdec_parse_byte (pdec_t *pdec, uint8_t byte)
 
bool pdec_range (uint16_t dst_id)
 
bool pdec_get_distance (uint16_t dst_id)
 
bool pdec_list_devices (void)
 
bool pdec_send_data (uint16_t dst_id, const uint8_t *data, uint8_t len)
 
void pdec_init (void)
 
void pdec_periodic_report (void)
 
void pdec_event (void)
 
void uwb_range (uint16_t dst_id)
 

Variables

pdec_t pdec
 
struct pdec_cmd_payload PDEC_PACKED
 

Data Structure Documentation

◆ pdec_cmd_payload

struct pdec_cmd_payload

Definition at line 28 of file pdec.c.

Data Fields
uint8_t id

◆ pdec_target_cmd_payload

struct pdec_target_cmd_payload

Definition at line 32 of file pdec.c.

Data Fields
uint16_t dst_id
uint8_t id

◆ pdec_error_payload

struct pdec_error_payload

Definition at line 37 of file pdec.c.

Data Fields
uint8_t command
uint8_t id
uint8_t status

◆ pdec_distance_payload

struct pdec_distance_payload

Definition at line 43 of file pdec.c.

Data Fields
float distance
uint16_t dst_id
uint8_t id
uint8_t status

◆ pdec_device_list_payload

struct pdec_device_list_payload

Definition at line 50 of file pdec.c.

Data Fields
uint8_t count
uint16_t device_ids[]
uint8_t id

◆ pdec_send_data_result_payload

struct pdec_send_data_result_payload

Definition at line 56 of file pdec.c.

Data Fields
uint16_t dst_id
uint8_t id
uint8_t sent_len
uint8_t status

◆ pdec_ranging_event_payload

struct pdec_ranging_event_payload

Definition at line 63 of file pdec.c.

Data Fields
float distance
uint16_t dst_id
uint8_t id
uint8_t kind
uint16_t src_id

◆ pdec_tdoa_report_payload

struct pdec_tdoa_report_payload

Definition at line 71 of file pdec.c.

Data Fields
float distance
uint16_t reporter_id

◆ pdec_tdoa_report_event_payload

struct pdec_tdoa_report_event_payload

Definition at line 76 of file pdec.c.

+ Collaboration diagram for pdec_tdoa_report_event_payload:
Data Fields
uint32_t blink_id
uint8_t count
uint8_t expected_count
uint8_t id
struct pdec_tdoa_report_payload reports[]
uint8_t timed_out

Macro Definition Documentation

◆ PDEC_FRAME_OVERHEAD

#define PDEC_FRAME_OVERHEAD   4

Definition at line 19 of file pdec.c.

◆ PDEC_PACKED

Definition at line 20 of file pdec.c.

◆ PDEC_SYNC_BYTE

#define PDEC_SYNC_BYTE   0xff

Definition at line 18 of file pdec.c.

Function Documentation

◆ _pdec_event()

static void _pdec_event ( pdec_t pdec)
static

Definition at line 361 of file pdec.c.

References pdec_t::dev, pdec, pdec_parse_byte(), uart_char_available(), and uart_getch().

Referenced by pdec_event().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _pdec_init()

static void _pdec_init ( pdec_t pdec)
static

Definition at line 310 of file pdec.c.

References pdec_t::dev, foo, pdec, PDEC_RX_SYNC_1, and pdec_t::rx_state.

Referenced by pdec_init().

+ Here is the caller graph for this function:

◆ _pdec_periodic_report()

◆ pdec_dispatch_frame()

static void pdec_dispatch_frame ( pdec_t pdec)
static

Definition at line 120 of file pdec.c.

References pdec_tdoa_report_event::blink_id, pdec_error_response::command, pdec_device_list::count, pdec_tdoa_report_event::count, pdec_t::counters, pdec_device_list::device_ids, pdec_t::devices, pdec_ranging_event::distance, pdec_tdoa_report::distance, pdec_send_data_result::dst_id, pdec_ranging_event::dst_id, pdec_tdoa_report_event::expected_count, foo, get_sys_time_usec(), pdec_ranging_event::kind, pdec_t::last_distance, pdec_t::last_error, pdec_t::last_range, pdec_t::last_ranging_event, pdec_t::last_send_data, pdec_t::last_tdoa_report_event, msg, pdec, PDEC_MAX_DEVICES, PDEC_MAX_PAYLOAD_LEN, PDEC_MAX_TDOA_REPORTS, PDEC_MSG_DEVICE_LIST, PDEC_MSG_DISTANCE, PDEC_MSG_ERROR, PDEC_MSG_RANGE_RESULT, PDEC_MSG_RANGING_EVENT, PDEC_MSG_SEND_DATA_RESULT, PDEC_MSG_TDOA_REPORT_EVENT, pdec_parse_distance_result(), pdec_tdoa_report::reporter_id, pdec_tdoa_report_event::reports, pdec_counters::rx_frames, pdec_t::rx_len, pdec_counters::rx_length_errors, pdec_t::rx_payload, pdec_counters::rx_unknown_messages, pdec_send_data_result::sent_len, pdec_ranging_event::src_id, pdec_error_response::status, pdec_send_data_result::status, pdec_tdoa_report_event::timed_out, pdec_device_list::total_count, pdec_tdoa_report_event::total_count, pdec_device_list::truncated, pdec_tdoa_report_event::truncated, pdec_error_response::updated, pdec_device_list::updated, pdec_send_data_result::updated, pdec_ranging_event::updated, pdec_tdoa_report_event::updated, and UWB_PDEC_ID.

Referenced by pdec_parse_byte().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pdec_event()

void pdec_event ( void  )

Definition at line 427 of file pdec.c.

References _pdec_event(), and pdec.

+ Here is the call graph for this function:

◆ pdec_get_distance()

bool pdec_get_distance ( uint16_t  dst_id)

Definition at line 377 of file pdec.c.

References pdec_target_cmd_payload::dst_id, pdec_target_cmd_payload::id, pdec, PDEC_CMD_GET_DISTANCE, and pdec_send_frame().

+ Here is the call graph for this function:

◆ pdec_init()

void pdec_init ( void  )

Definition at line 417 of file pdec.c.

References _pdec_init(), and pdec.

+ Here is the call graph for this function:

◆ pdec_list_devices()

bool pdec_list_devices ( void  )

Definition at line 386 of file pdec.c.

References pdec_cmd_payload::id, pdec, PDEC_CMD_LIST_DEVICES, and pdec_send_frame().

+ Here is the call graph for this function:

◆ pdec_parse_byte()

static void pdec_parse_byte ( pdec_t pdec,
uint8_t  byte 
)
static

Definition at line 263 of file pdec.c.

References byte, pdec_t::counters, pdec, pdec_dispatch_frame(), PDEC_RX_CHECKSUM, PDEC_RX_LEN, PDEC_RX_PAYLOAD, PDEC_RX_SYNC_1, PDEC_RX_SYNC_2, PDEC_SYNC_BYTE, pdec_t::rx_checksum, pdec_counters::rx_checksum_errors, pdec_t::rx_idx, pdec_t::rx_len, pdec_t::rx_payload, and pdec_t::rx_state.

Referenced by _pdec_event().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pdec_parse_distance_result()

static void pdec_parse_distance_result ( struct pdec_distance_result result,
const struct pdec_distance_payload payload 
)
static

◆ pdec_periodic_report()

void pdec_periodic_report ( void  )

Definition at line 422 of file pdec.c.

References _pdec_periodic_report(), and pdec.

+ Here is the call graph for this function:

◆ pdec_range()

bool pdec_range ( uint16_t  dst_id)

Definition at line 368 of file pdec.c.

References pdec_target_cmd_payload::dst_id, pdec_target_cmd_payload::id, pdec, PDEC_CMD_RANGE, and pdec_send_frame().

Referenced by uwb_range().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pdec_send_data()

bool pdec_send_data ( uint16_t  dst_id,
const uint8_t data,
uint8_t  len 
)

◆ pdec_send_frame()

static bool pdec_send_frame ( pdec_t pdec,
const uint8_t payload,
uint8_t  payload_len 
)
static

Definition at line 85 of file pdec.c.

References checksum, pdec_t::counters, pdec_t::dev, fd, foo, frame, pdec, PDEC_FRAME_OVERHEAD, PDEC_MAX_PAYLOAD_LEN, PDEC_SYNC_BYTE, pdec_counters::tx_drops, pdec_counters::tx_frames, and uart_put_buffer().

Referenced by pdec_get_distance(), pdec_list_devices(), pdec_range(), and pdec_send_data().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ uwb_range()

void uwb_range ( uint16_t  dst_id)

Definition at line 433 of file pdec.c.

References pdec_target_cmd_payload::dst_id, and pdec_range().

+ Here is the call graph for this function:

Variable Documentation

◆ pdec

◆ PDEC_PACKED

struct pdec_tdoa_report_event_payload PDEC_PACKED