Paparazzi UAS  v5.15_devel-187-g731cc33
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
syslink_dl.c File Reference

Syslink protocol handling and functionalities. More...

#include "modules/datalink/bitcraze/syslink_dl.h"
#include "subsystems/electrical.h"
#include "mcu_periph/uart.h"
#include <string.h>
#include "led.h"
#include "pprz_mutex.h"
+ Include dependency graph for syslink_dl.c:

Go to the source code of this file.

Functions

 PPRZ_MUTEX (syslink_tx_mtx)
 Protect syslink TX with Mutex when using RTOS. More...
 
static void send_message (syslink_message_t *msg)
 Send a syslink message. More...
 
static void handle_battery (syslink_message_t *msg)
 Handle battery message. More...
 
static void handle_raw_other (syslink_message_t *msg)
 Handle various raw messages. More...
 
static void handle_raw (syslink_message_t *msg)
 Handle raw datalink. More...
 
static void handle_radio (syslink_message_t *msg)
 
static void handle_new_msg (syslink_message_t *msg)
 New RX message. More...
 
static bool syslink_check_free_space (struct syslink_dl *s, long *fd UNUSED, uint16_t len)
 Implementation of syslink as generic device. More...
 
static void syslink_put_buffer (struct syslink_dl *s, long fd UNUSED, const uint8_t *data, uint16_t len)
 
static void syslink_put_byte (struct syslink_dl *s, long fd, const uint8_t b)
 
static void syslink_send_message (struct syslink_dl *s UNUSED, long fd UNUSED)
 
static uint8_t syslink_getch (struct syslink_dl *s)
 
static uint16_t syslink_char_available (struct syslink_dl *s)
 
void syslink_dl_init (void)
 Init function. More...
 
void syslink_dl_periodic (void)
 Periodic function. More...
 
void syslink_dl_event (void)
 Datalink event. More...
 

Variables

struct syslink_dl syslink
 

Detailed Description

Syslink protocol handling and functionalities.

Definition in file syslink_dl.c.

Function Documentation

static void handle_battery ( syslink_message_t msg)
static

Handle battery message.

Definition at line 66 of file syslink_dl.c.

References syslink_dl::charging, syslink_message_t::data, electrical, syslink_message_t::length, syslink_dl::powered, syslink, and Electrical::vsupply.

Referenced by handle_new_msg().

+ Here is the caller graph for this function:

static void handle_new_msg ( syslink_message_t msg)
static

New RX message.

Definition at line 258 of file syslink_dl.c.

References handle_battery(), handle_radio(), handle_raw(), SYSLINK_GROUP, SYSLINK_OW, SYSLINK_PM_BATTERY_STATE, SYSLINK_PM_ONOFF_SWITCHOFF, SYSLINK_RADIO, SYSLINK_RADIO_RAW, and syslink_message_t::type.

Referenced by syslink_dl_event().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void handle_radio ( syslink_message_t msg)
static

Definition at line 238 of file syslink_dl.c.

References syslink_message_t::data, syslink_dl::rssi, syslink, SYSLINK_RADIO_ADDRESS, SYSLINK_RADIO_CHANNEL, SYSLINK_RADIO_DATARATE, SYSLINK_RADIO_RSSI, and syslink_message_t::type.

Referenced by handle_new_msg().

+ Here is the caller graph for this function:

static void handle_raw ( syslink_message_t msg)
static

Handle raw datalink.

From Bitcraze documentation:

This packet carries the raw radio packet. The NRF51 acts as a radio bridge. Because the NRF51 does not have much memory and the STM32 is capable of bursting a lot of data a flow control rules has been made: The STM32 is allowed to send a RADIO_RAW packet only when one RADIO_RAW packet has been received.

The NRF51 is regularly sending CRTP NULL packet or empty packets to the STM32 to get the communication working both ways.

Note: So far RADIO_RAW is the only syslink packet that has flow control constrain, all other packets can be sent full duplex at any moment.

Definition at line 186 of file syslink_dl.c.

References CRTP_BUF_LEN, CRTP_NULL, CRTP_PORT_COMMANDER, CRTP_PORT_PPRZLINK, crtp_message_t::data, syslink_dl::device, handle_raw_other(), syslink_message_t::length, syslink_dl::msg_tx, PPRZ_MUTEX_LOCK, PPRZ_MUTEX_UNLOCK, syslink_dl::rx_buf, syslink_dl::rx_insert_idx, send_message(), crtp_message_t::size, syslink, SYSLINK_RADIO_RAW, SYSLINK_RX_BUF_LEN, syslink_dl::tx_extract_idx, syslink_dl::tx_insert_idx, and syslink_message_t::type.

Referenced by handle_new_msg().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void handle_raw_other ( syslink_message_t msg)
static

Handle various raw messages.

Definition at line 90 of file syslink_dl.c.

References CRTP_MAX_DATA_SIZE, CRTP_PORT_LINK, CRTP_PORT_LOG, CRTP_PORT_MEM, CRTP_PORT_PARAM, crtp_message_t::data, syslink_message_t::length, send_message(), and crtp_message_t::size.

Referenced by handle_raw().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PPRZ_MUTEX ( syslink_tx_mtx  )

Protect syslink TX with Mutex when using RTOS.

static void send_message ( syslink_message_t msg)
static

Send a syslink message.

Definition at line 42 of file syslink_dl.c.

References syslink_message_t::cksum, syslink_message_t::data, syslink_message_t::length, syslink_compute_cksum(), syslink_stx, syslink_message_t::type, and uart_put_buffer().

Referenced by handle_raw(), and handle_raw_other().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static uint16_t syslink_char_available ( struct syslink_dl s)
static

Definition at line 354 of file syslink_dl.c.

References syslink_dl::rx_extract_idx, syslink_dl::rx_insert_idx, and SYSLINK_RX_BUF_LEN.

Referenced by syslink_dl_init().

+ Here is the caller graph for this function:

static bool syslink_check_free_space ( struct syslink_dl s,
long *fd  UNUSED,
uint16_t  len 
)
static

Implementation of syslink as generic device.

Definition at line 288 of file syslink_dl.c.

References CRTP_BUF_LEN, CRTP_MAX_DATA_SIZE, PPRZ_MUTEX_LOCK, syslink_dl::tx_extract_idx, and syslink_dl::tx_insert_idx.

Referenced by syslink_dl_init().

+ Here is the caller graph for this function:

void syslink_dl_event ( void  )

Datalink event.

Definition at line 412 of file syslink_dl.c.

References handle_new_msg(), syslink_dl::msg_rx, syslink_dl::state, syslink, syslink_parse_char(), uart_char_available(), and uart_getch().

+ Here is the call graph for this function:

void syslink_dl_periodic ( void  )

Periodic function.

Definition at line 396 of file syslink_dl.c.

References syslink_dl::charging, LED_OFF, LED_ON, LED_TOGGLE, syslink_dl::powered, and syslink.

static uint8_t syslink_getch ( struct syslink_dl s)
static

Definition at line 347 of file syslink_dl.c.

References syslink_dl::rx_buf, syslink_dl::rx_extract_idx, and SYSLINK_RX_BUF_LEN.

Referenced by syslink_dl_init().

+ Here is the caller graph for this function:

static void syslink_put_buffer ( struct syslink_dl s,
long fd  UNUSED,
const uint8_t data,
uint16_t  len 
)
static

Definition at line 302 of file syslink_dl.c.

References CRTP_BUF_LEN, CRTP_MAX_DATA_SIZE, crtp_message_t::data, Min, syslink_dl::msg_tx, crtp_message_t::size, syslink_dl::tx_extract_idx, and syslink_dl::tx_insert_idx.

Referenced by syslink_dl_init(), and syslink_put_byte().

+ Here is the caller graph for this function:

static void syslink_put_byte ( struct syslink_dl s,
long  fd,
const uint8_t  b 
)
static

Definition at line 336 of file syslink_dl.c.

References syslink_put_buffer().

Referenced by syslink_dl_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void syslink_send_message ( struct syslink_dl *s  UNUSED,
long fd  UNUSED 
)
static

Definition at line 342 of file syslink_dl.c.

References PPRZ_MUTEX_UNLOCK.

Referenced by syslink_dl_init().

+ Here is the caller graph for this function:

Variable Documentation