36 #ifndef BLUEGIGA_SPI_DEV
37 #error "bluegiga: must define a BLUEGIGA_SPI_DEV"
41 #ifndef BLUEGIGA_DRDY_GPIO
42 #define BLUEGIGA_DRDY_GPIO SUPERBITRF_DRDY_PORT
45 #ifndef BLUEGIGA_DRDY_GPIO_PIN
46 #define BLUEGIGA_DRDY_GPIO_PIN SUPERBITRF_DRDY_PIN
108 #if PERIODIC_TELEMETRY
116 if (now_ts > last_ts) {
118 pprz_msg_send_BLUEGIGA(trans, dev, AC_ID, &rate, 20,
telemetry_copy);
166 for (
int i = 0; i < 255; i++) {
179 #if PERIODIC_TELEMETRY
201 if (packet_len > 19) {
211 for (i = 0; i < packet_len; i++) {
284 if (packet_len > 0 && packet_len <= trans->
input_length) {
286 for (
uint8_t i = 0; i < packet_len; i++) {
static uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
void bluegiga_increment_buf(uint8_t *buf_idx, uint8_t len)
put_byte_t put_byte
put one byte
enum SPIClockPolarity cpol
clock polarity control
struct link_device device
Generic device interface.
signed char bluegiga_rssi[256]
#define BLUEGIGA_BUFFER_SIZE
uint8_t(* get_byte_t)(void *)
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
Generic transmission transport header.
uint16_t output_length
number of data words to write
static uint8_t dev_get_byte(struct bluegiga_periph *p)
check_free_space_t check_free_space
check if transmit buffer is not full
Periodic telemetry system header (includes downlink utility and generated code).
Some architecture independent helper functions for GPIOs.
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.
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)
void * periph
pointer to parent implementation
#define BLUEGIGA_DRDY_GPIO
enum BlueGigaStatus coms_status
void bluegiga_init(struct bluegiga_periph *p)
Architecture independent SPI (Serial Peripheral Interface) API.
The com is switched from data link to rssi scanning.
enum SPIClockPhase cpha
clock phase control
void gpio_set(uint32_t port, uint16_t pin)
Set a gpio output to high level.
void bluegiga_load_tx(struct bluegiga_periph *p)
Architecture independent timing functions.
bool_t bluegiga_ch_available(struct bluegiga_periph *p)
static int dev_char_available(struct bluegiga_periph *p)
SPICallback after_cb
NULL or function called after the transaction.
void gpio_clear(uint32_t port, uint16_t pin)
Clear a gpio output to low level.
uint8_t tx_buf[BLUEGIGA_BUFFER_SIZE]
#define DefaultPeriodic
Set default periodic telemetry.
get_byte_t get_byte
get a new char
int(* char_available_t)(void *)
void bluegiga_request_all_rssi(struct bluegiga_periph *p)
#define BLUEGIGA_DRDY_GPIO_PIN
static int dev_check_free_space(struct bluegiga_periph *p, uint8_t len)
uint16_t input_length
number of data words to read
static const struct usb_device_descriptor dev
void(* put_byte_t)(void *, uint8_t)
bool_t spi_slave_register(struct spi_periph *p, struct spi_transaction *t)
Register one (and only one) transaction to use spi as slave.
void bluegiga_scan(struct bluegiga_periph *p)
The com isn't initialized.
void(* send_message_t)(void *)
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)
enum SPIDataSizeSelect dss
data transfer word size
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
unsigned char telemetry_copy[20]
volatile uint8_t * input_buf
pointer to receive buffer for DMA
int(* check_free_space_t)(void *, uint8_t)
Function pointers definition.
char_available_t char_available
check if a new character is available
struct spi_transaction bluegiga_spi
static void dev_send_message(struct bluegiga_periph *p)
void gpio_setup_output(uint32_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
send_message_t send_message
send completed buffer
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
static void dev_put_byte(struct bluegiga_periph *p, uint8_t byte)