|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
42 #ifndef BLUEGIGA_SPI_DEV
43 #error "bluegiga: must define a BLUEGIGA_SPI_DEV"
47 #ifndef BLUEGIGA_DRDY_GPIO
48 #define BLUEGIGA_DRDY_GPIO SUPERBITRF_DRDY_PORT
51 #ifndef BLUEGIGA_DRDY_GPIO_PIN
52 #define BLUEGIGA_DRDY_GPIO_PIN SUPERBITRF_DRDY_PIN
55 #define TxStrengthOfSender(x) (x[1])
56 #define RssiOfSender(x) (x[2])
57 #define Pprz_StxOfMsg(x) (x[3])
58 #define SenderIdOfBGMsg(x) (x[5])
84 for (i = 0; i < len; i++) {
94 p->end_of_msg =
p->tx_insert_idx;
104 uint8_t ret =
p->rx_buf[
p->rx_extract_idx];
118 return (
p->rx_extract_idx !=
p->rx_insert_idx);
128 #if PERIODIC_TELEMETRY
139 pprz_msg_send_BLUEGIGA(trans,
dev, AC_ID, &rate, &a2a_rate);
169 p->device.periph = (
void *)(
p);
178 p->rx_insert_idx = 0;
179 p->rx_extract_idx = 0;
180 p->tx_insert_idx = 0;
181 p->tx_extract_idx = 0;
188 p->bytes_recvd_since_last = 0;
189 p->end_of_msg =
p->tx_insert_idx;
198 #if PERIODIC_TELEMETRY
211 p->tx_buf[
p->tx_insert_idx] = data;
222 if (packet_len > 19) {
229 p->work_tx[0] = packet_len;
232 for (i = 0; i < packet_len; i++) {
320 if (packet_len > 0 && packet_len <= trans->
input_length - read_offset) {
325 for (
uint8_t i = 0; i < packet_len; i++) {
345 if (msg_len == 0 || msg_len > 22) {
350 p->work_tx[0] = msg_len;
352 if (msg_len < max_length) {
353 for (
uint8_t i = 0; i < msg_len; i++) {
354 p->work_tx[i + 1] =
msg[i];
358 for (
uint8_t i = 0; i < max_length - 1; i++) {
359 p->work_tx[i + 1] =
msg[i];
#define SenderIdOfBGMsg(x)
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
bool bluegiga_ch_available(struct bluegiga_periph *p)
struct spi_transaction bluegiga_spi
enum SPIClockPolarity cpol
clock polarity control
uint16_t output_length
number of data words to write
uint8_t broadcast_msg[20]
void bluegiga_increment_buf(uint8_t *buf_idx, uint8_t len)
SPI transaction structure.
#define BLUEGIGA_DRDY_GPIO
#define BLUEGIGA_BUFFER_SIZE
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
@ BLUEGIGA_SENDING
The com is sending.
@ BLUEGIGA_SENDING_BROADCAST
The com is switched from data link to rssi scanning.
bool spi_slave_register(struct spi_periph *p, struct spi_transaction *t)
Register one (and only one) transaction to use spi as slave.
#define BLUEGIGA_SPI_BUF_SIZE
static uint8_t dev_get_byte(struct bluegiga_periph *p)
@ SPISelectUnselect
slave is selected before transaction and unselected after
enum SPIBitOrder bitorder
MSB/LSB order.
static void send_bluegiga(struct transport_tx *trans, struct link_device *dev)
static void dev_put_byte(struct bluegiga_periph *p, long fd, uint8_t byte)
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
enum SPISlaveSelect select
slave selection behavior
static void gpio_clear(ioportid_t port, uint16_t pin)
Clear a gpio output to low level.
struct bluegiga_periph bluegiga_p
enum SPIClockPhase cpha
clock phase control
SPICallback after_cb
NULL or function called after the transaction.
static int dev_check_free_space(struct bluegiga_periph *p, long *fd, uint16_t len)
static const struct usb_device_descriptor dev
Architecture independent timing functions.
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
@ SPICpolIdleHigh
CPOL = 1.
uint32_t bytes_recvd_since_last
static void trans_cb(struct spi_transaction *trans)
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
enum BlueGigaStatus coms_status
void bluegiga_init(struct bluegiga_periph *p)
arch independent LED (Light Emitting Diodes) API
@ BLUEGIGA_UNINIT
The com isn't initialized.
void(* SPICallback)(struct spi_transaction *trans)
SPI Callback function.
void bluegiga_broadcast_msg(struct bluegiga_periph *p, char *msg, uint8_t msg_len)
uint8_t rx_buf[BLUEGIGA_BUFFER_SIZE]
static int dev_char_available(struct bluegiga_periph *p)
@ BLUEGIGA_IDLE
The com is in idle.
void bluegiga_load_tx(struct bluegiga_periph *p)
static void dev_send_message(struct bluegiga_periph *p, long fd)
uint16_t input_length
number of data words to read
enum SPIDataSizeSelect dss
data transfer word size
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
volatile uint8_t * input_buf
pointer to receive buffer for DMA
static void dev_put_buffer(struct bluegiga_periph *p, long fd, uint8_t *data, uint16_t len)
#define BLUEGIGA_DRDY_GPIO_PIN
#define TxStrengthOfSender(x)
static void gpio_set(ioportid_t port, uint16_t pin)
Set a gpio output to high level.
enum SPITransactionStatus status
void bluegiga_receive(struct spi_transaction *trans)
#define DefaultPeriodic
Set default periodic telemetry.
void bluegiga_transmit(struct bluegiga_periph *p, uint8_t data)