Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
syslink_dl.c File Reference

Syslink protocol handling and functionalities. More...

#include "modules/datalink/bitcraze/syslink_dl.h"
#include "modules/energy/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 int 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 int 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

◆ handle_battery()

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, electrical, msg, syslink_dl::powered, syslink, and Electrical::vsupply.

Referenced by handle_new_msg().

+ Here is the caller graph for this function:

◆ handle_new_msg()

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(), msg, SYSLINK_GROUP, SYSLINK_OW, SYSLINK_PM_BATTERY_STATE, SYSLINK_PM_ONOFF_SWITCHOFF, SYSLINK_RADIO, and SYSLINK_RADIO_RAW.

Referenced by syslink_dl_event().

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

◆ handle_radio()

static void handle_radio ( syslink_message_t msg)
static

Definition at line 238 of file syslink_dl.c.

References msg, syslink_dl::rssi, rssi, syslink, SYSLINK_RADIO_ADDRESS, SYSLINK_RADIO_CHANNEL, SYSLINK_RADIO_DATARATE, and SYSLINK_RADIO_RSSI.

Referenced by handle_new_msg().

+ Here is the caller graph for this function:

◆ handle_raw()

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(), if(), syslink_message_t::length, msg, 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, split(), 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:

◆ handle_raw_other()

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, if(), msg, 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()

PPRZ_MUTEX ( syslink_tx_mtx  )

Protect syslink TX with Mutex when using RTOS.

◆ send_message()

static void send_message ( syslink_message_t msg)
static

Send a syslink message.

Definition at line 42 of file syslink_dl.c.

References msg, syslink_compute_cksum(), syslink_stx, 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:

◆ syslink_char_available()

static int syslink_char_available ( struct syslink_dl s)
static

Definition at line 355 of file syslink_dl.c.

References s, and SYSLINK_RX_BUF_LEN.

Referenced by syslink_dl_init().

+ Here is the caller graph for this function:

◆ syslink_check_free_space()

static int 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, and s.

Referenced by syslink_dl_init().

+ Here is the caller graph for this function:

◆ syslink_dl_event()

void syslink_dl_event ( void  )

Datalink event.

Definition at line 413 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:

◆ syslink_dl_init()

◆ syslink_dl_periodic()

void syslink_dl_periodic ( void  )

Periodic function.

Definition at line 397 of file syslink_dl.c.

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

◆ syslink_getch()

static uint8_t syslink_getch ( struct syslink_dl s)
static

Definition at line 348 of file syslink_dl.c.

References s, and SYSLINK_RX_BUF_LEN.

Referenced by syslink_dl_init().

+ Here is the caller graph for this function:

◆ syslink_put_buffer()

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

Definition at line 303 of file syslink_dl.c.

References CRTP_BUF_LEN, CRTP_MAX_DATA_SIZE, crtp_message_t::data, Min, s, and crtp_message_t::size.

Referenced by syslink_dl_init(), and syslink_put_byte().

+ Here is the caller graph for this function:

◆ syslink_put_byte()

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

Definition at line 337 of file syslink_dl.c.

References b, fd, s, and syslink_put_buffer().

Referenced by syslink_dl_init().

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

◆ syslink_send_message()

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

Definition at line 343 of file syslink_dl.c.

References PPRZ_MUTEX_UNLOCK.

Referenced by syslink_dl_init().

+ Here is the caller graph for this function:

Variable Documentation

◆ syslink