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];
Main include for ABI (AirBorneInterface).
#define BLUEGIGA_DRDY_GPIO_PIN
#define TxStrengthOfSender(x)
static void dev_put_byte(struct bluegiga_periph *p, long fd, uint8_t byte)
static void send_bluegiga(struct transport_tx *trans, struct link_device *dev)
static uint8_t dev_get_byte(struct bluegiga_periph *p)
void bluegiga_broadcast_msg(struct bluegiga_periph *p, char *msg, uint8_t msg_len)
static void dev_send_message(struct bluegiga_periph *p, long fd)
#define SenderIdOfBGMsg(x)
static void dev_put_buffer(struct bluegiga_periph *p, long fd, uint8_t *data, uint16_t len)
void bluegiga_receive(struct spi_transaction *trans)
enum BlueGigaStatus coms_status
#define BLUEGIGA_DRDY_GPIO
bool bluegiga_ch_available(struct bluegiga_periph *p)
static int dev_check_free_space(struct bluegiga_periph *p, long *fd, uint16_t len)
struct spi_transaction bluegiga_spi
static void trans_cb(struct spi_transaction *trans)
uint8_t broadcast_msg[20]
void bluegiga_load_tx(struct bluegiga_periph *p)
static int dev_char_available(struct bluegiga_periph *p)
void bluegiga_transmit(struct bluegiga_periph *p, uint8_t data)
struct bluegiga_periph bluegiga_p
void bluegiga_init(struct bluegiga_periph *p)
void bluegiga_increment_buf(uint8_t *buf_idx, uint8_t len)
Bluegiga Bluetooth chip I/O.
@ BLUEGIGA_SENDING_BROADCAST
The com is switched from data link to rssi scanning.
@ BLUEGIGA_IDLE
The com is in idle.
@ BLUEGIGA_UNINIT
The com isn't initialized.
@ BLUEGIGA_SENDING
The com is sending.
#define BLUEGIGA_SPI_BUF_SIZE
uint8_t rx_buf[BLUEGIGA_BUFFER_SIZE]
uint32_t bytes_recvd_since_last
#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.
static void gpio_set(ioportid_t port, uint16_t pin)
Set a gpio output to high level.
static void gpio_clear(ioportid_t port, uint16_t pin)
Clear a gpio output to low level.
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
Some architecture independent helper functions for GPIOs.
enum SPIClockPolarity cpol
clock polarity control
enum SPIClockPhase cpha
clock phase control
enum SPISlaveSelect select
slave selection behavior
SPICallback after_cb
NULL or function called after the transaction.
enum SPIDataSizeSelect dss
data transfer word size
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
uint16_t input_length
number of data words to read
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
volatile uint8_t * input_buf
pointer to receive buffer for DMA
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
enum SPIBitOrder bitorder
MSB/LSB order.
uint16_t output_length
number of data words to write
enum SPITransactionStatus status
void(* SPICallback)(struct spi_transaction *trans)
SPI Callback function.
bool spi_slave_register(struct spi_periph *periph, struct spi_transaction *trans)
Register a spi transaction in slave mode (only one transaction can be registered).
@ SPICpolIdleHigh
CPOL = 1.
@ SPISelectUnselect
slave is selected before transaction and unselected after
SPI transaction structure.
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
arch independent LED (Light Emitting Diodes) API
Architecture independent SPI (Serial Peripheral Interface) API.
static const struct usb_device_descriptor dev
Architecture independent timing functions.
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
signed char int8_t
Typedef defining 8 bit char type.