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++) {
128 #if PERIODIC_TELEMETRY
136 if (now_ts > last_ts) {
139 pprz_msg_send_BLUEGIGA(trans, dev, AC_ID, &rate, &a2a_rate);
169 p->
device.periph = (
void *)(p);
198 #if PERIODIC_TELEMETRY
222 if (packet_len > 19) {
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) {
352 if (msg_len < max_length) {
353 for (
uint8_t i = 0; i < msg_len; i++) {
358 for (
uint8_t i = 0; i < max_length - 1; i++) {
362 memcpy(
broadcast_msg, msg + max_length - 1, msg_len - (max_length - 1));
void bluegiga_increment_buf(uint8_t *buf_idx, uint8_t len)
enum SPIClockPolarity cpol
clock polarity control
uint8_t work_tx[BLUEGIGA_SPI_BUF_SIZE]
bool spi_slave_register(struct spi_periph *p, struct spi_transaction *t)
Register one (and only one) transaction to use spi as slave.
struct link_device device
Generic device interface.
#define BLUEGIGA_BUFFER_SIZE
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
uint16_t output_length
number of data words to write
static uint8_t dev_get_byte(struct bluegiga_periph *p)
static void gpio_clear(ioportid_t port, uint16_t pin)
Clear a gpio output to low level.
Periodic telemetry system header (includes downlink utility and generated code).
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
uint8_t work_rx[BLUEGIGA_SPI_BUF_SIZE]
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)
Some architecture independent helper functions for GPIOs.
#define SenderIdOfBGMsg(x)
Main include for ABI (AirBorneInterface).
uint8_t rx_buf[BLUEGIGA_BUFFER_SIZE]
SPI transaction structure.
struct bluegiga_periph bluegiga_p
void(* SPICallback)(struct spi_transaction *trans)
SPI Callback function.
enum SPIBitOrder bitorder
MSB/LSB order.
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
The com is switched from data link to rssi scanning.
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
enum SPISlaveSelect select
slave selection behavior
uint32_t bytes_recvd_since_last
static void trans_cb(struct spi_transaction *trans)
#define BLUEGIGA_DRDY_GPIO
enum BlueGigaStatus coms_status
void bluegiga_init(struct bluegiga_periph *p)
Architecture independent SPI (Serial Peripheral Interface) API.
enum SPIClockPhase cpha
clock phase control
void bluegiga_load_tx(struct bluegiga_periph *p)
Architecture independent timing functions.
static int dev_char_available(struct bluegiga_periph *p)
SPICallback after_cb
NULL or function called after the transaction.
uint8_t tx_buf[BLUEGIGA_BUFFER_SIZE]
#define DefaultPeriodic
Set default periodic telemetry.
#define BLUEGIGA_DRDY_GPIO_PIN
uint16_t input_length
number of data words to read
static const struct usb_device_descriptor dev
static int dev_check_free_space(struct bluegiga_periph *p, long *fd, uint16_t len)
The com isn't initialized.
#define BLUEGIGA_SPI_BUF_SIZE
#define TxStrengthOfSender(x)
slave is selected before transaction and unselected after
void bluegiga_transmit(struct bluegiga_periph *p, uint8_t data)
void bluegiga_receive(struct spi_transaction *trans)
void bluegiga_broadcast_msg(struct bluegiga_periph *p, char *msg, uint8_t msg_len)
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
arch independent LED (Light Emitting Diodes) API
static void dev_send_message(struct bluegiga_periph *p, long fd)
bool bluegiga_ch_available(struct bluegiga_periph *p)
struct spi_transaction bluegiga_spi
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
static void dev_put_buffer(struct bluegiga_periph *p, long fd, uint8_t *data, uint16_t len)
static void gpio_set(ioportid_t port, uint16_t pin)
Set a gpio output to high level.
uint8_t broadcast_msg[20]
Bluegiga Bluetooth chip I/O.
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
enum SPITransactionStatus status