mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-30 03:27:33 +08:00
[telemetry] Bluegiga: cleanup
- LED not hardcoded - SPI LINK configurable form airframe file - subsystem for shared and fixedwing
This commit is contained in:
committed by
Felix Ruess
parent
dad0fbb8a6
commit
cdfa5a0bda
@@ -283,7 +283,6 @@ clean:
|
|||||||
$(Q)rm -f $(GEN_HEADERS)
|
$(Q)rm -f $(GEN_HEADERS)
|
||||||
$(Q)find . -mindepth 2 -name Makefile -a ! -path "./sw/ext/*" -exec sh -c 'echo "Cleaning {}"; $(MAKE) -C `dirname {}` $@' \;
|
$(Q)find . -mindepth 2 -name Makefile -a ! -path "./sw/ext/*" -exec sh -c 'echo "Cleaning {}"; $(MAKE) -C `dirname {}` $@' \;
|
||||||
$(Q)$(MAKE) -C $(EXT) clean
|
$(Q)$(MAKE) -C $(EXT) clean
|
||||||
$(Q)$(MAKE) -C $(TOOLS)/bluegiga_usb_dongle clean
|
|
||||||
$(Q)find . -name '*~' -exec rm -f {} \;
|
$(Q)find . -name '*~' -exec rm -f {} \;
|
||||||
|
|
||||||
cleanspaces:
|
cleanspaces:
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ BARO_LED ?= none
|
|||||||
AHRS_ALIGNER_LED ?= 2
|
AHRS_ALIGNER_LED ?= 2
|
||||||
GPS_LED ?= none
|
GPS_LED ?= none
|
||||||
SYS_TIME_LED ?= 1
|
SYS_TIME_LED ?= 1
|
||||||
|
MODEM_LED ?= 3
|
||||||
|
|
||||||
#
|
#
|
||||||
# default uart configuration
|
# default uart configuration
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# Hey Emacs, this is a -*- makefile -*-
|
||||||
|
|
||||||
|
# include shared part for ap
|
||||||
|
ifeq ($(TARGET),ap)
|
||||||
|
include $(CFG_SHARED)/telemetry_bluegiga.makefile
|
||||||
|
endif
|
||||||
|
|
||||||
|
ap.srcs += $(SRC_FIRMWARE)/datalink.c $(SRC_FIRMWARE)/ap_downlink.c
|
||||||
|
|
||||||
|
# avoid fbw_telemetry_mode error
|
||||||
|
ap.srcs += $(SRC_FIRMWARE)/fbw_downlink.c
|
||||||
|
|
||||||
|
fbw.srcs += $(SRC_FIRMWARE)/fbw_downlink.c
|
||||||
|
|
||||||
@@ -1,17 +1,9 @@
|
|||||||
#
|
#
|
||||||
# The bluegiga module as telemetry downlink/uplink
|
# The bluegiga module as telemetry downlink/uplink for rotorcraft
|
||||||
#
|
#
|
||||||
#
|
|
||||||
ap.CFLAGS += -DUSE_$(MODEM_PORT)
|
|
||||||
ap.CFLAGS += -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
|
|
||||||
|
|
||||||
ap.CFLAGS += -DDOWNLINK -DPERIODIC_TELEMETRY -DDOWNLINK_DEVICE=bluegiga_p
|
ifeq ($(TARGET), ap)
|
||||||
ap.CFLAGS += -DDOWNLINK_TRANSPORT=pprz_tp -DDATALINK=BLUEGIGA
|
include $(CFG_SHARED)/telemetry_bluegiga.makefile
|
||||||
#ap.CFLAGS += -DDefaultPeriodic='&telemetry_Main'
|
endif
|
||||||
ap.CFLAGS += -DUSE_SPI2_SLAVE -DSPI_SLAVE
|
|
||||||
|
|
||||||
# for some reason the following line required to get GPS over datalink working
|
|
||||||
ap.CFLAGS += -DUSE_UART3 -DUART3_BAUD=B38400
|
|
||||||
|
|
||||||
ap.srcs += subsystems/datalink/downlink.c subsystems/datalink/bluegiga.c subsystems/datalink/pprz_transport.c subsystems/datalink/telemetry.c
|
|
||||||
ap.srcs += $(SRC_FIRMWARE)/datalink.c $(SRC_FIRMWARE)/rotorcraft_telemetry.c
|
ap.srcs += $(SRC_FIRMWARE)/datalink.c $(SRC_FIRMWARE)/rotorcraft_telemetry.c
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#
|
||||||
|
# The bluegiga module as telemetry downlink/uplink
|
||||||
|
#
|
||||||
|
# On Lisa-s, the Superbit-RF module can be replaced with a
|
||||||
|
# bluegiga-bluetooth 4 low power board. This subsystem puts
|
||||||
|
# the telemetry over this bluetooth 4 link.
|
||||||
|
#
|
||||||
|
# Bluegiga is a SPI-slave device without Chip select but with a compulsory DRDY
|
||||||
|
#
|
||||||
|
# Required:
|
||||||
|
# #define BLUEGIGA_SPI_DEV: the SPI device which MUST have a SLAVE mode without chipselect
|
||||||
|
#
|
||||||
|
# Optional: (defaults to SUPERBITRF DRDY)
|
||||||
|
# #define BLUEGIGA_DRDY_GPIO
|
||||||
|
# #define BLUEGIGA_DRDY_GPIO_PIN
|
||||||
|
|
||||||
|
# Include SPI if not yet included
|
||||||
|
include $(CFG_SHARED)/spi_master.makefile
|
||||||
|
|
||||||
|
# Set downlink to paparazzi transport over bluegiga protocol over SPI slave
|
||||||
|
ap.CFLAGS += -DDOWNLINK -DPERIODIC_TELEMETRY -DDOWNLINK_DEVICE=bluegiga_p
|
||||||
|
ap.CFLAGS += -DDOWNLINK_TRANSPORT=pprz_tp -DDATALINK=BLUEGIGA
|
||||||
|
|
||||||
|
BLUEGIGA_SPI_DEV ?= SPI2
|
||||||
|
BLUEGIGA_SPI_DEV_LOWER=$(shell echo $(BLUEGIGA_SPI_DEV) | tr A-Z a-z)
|
||||||
|
ap.CFLAGS += -DUSE_$(BLUEGIGA_SPI_DEV)_SLAVE -DSPI_SLAVE -DBLUEGIGA_SPI_DEV=$(BLUEGIGA_SPI_DEV_LOWER)
|
||||||
|
|
||||||
|
# LED
|
||||||
|
MODEM_LED ?= none
|
||||||
|
ifneq ($(MODEM_LED),none)
|
||||||
|
ap.CFLAGS += -DMODEM_LED=$(MODEM_LED)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ap.srcs += $(SRC_SUBSYSTEMS)/datalink/downlink.c $(SRC_SUBSYSTEMS)/datalink/bluegiga.c
|
||||||
|
ap.srcs += $(SRC_SUBSYSTEMS)/datalink/pprz_transport.c $(SRC_SUBSYSTEMS)/datalink/telemetry.c
|
||||||
@@ -1313,7 +1313,7 @@ void dma1_channel2_isr(void) {
|
|||||||
|
|
||||||
// SPI arch slave init
|
// SPI arch slave init
|
||||||
#if USE_SPI2_SLAVE
|
#if USE_SPI2_SLAVE
|
||||||
#warning "STM32-SPI2 slave: Configured not to use the NSS pin"
|
PRINT_CONFIG_MSG("STM32-SPI2 slave: Configured not to use the NSS pin")
|
||||||
|
|
||||||
#ifndef STM32F1
|
#ifndef STM32F1
|
||||||
#error "SPI2 slave on STM32 only implemented for STM32F1"
|
#error "SPI2 slave on STM32 only implemented for STM32F1"
|
||||||
|
|||||||
@@ -31,19 +31,16 @@
|
|||||||
#include "mcu_periph/gpio.h"
|
#include "mcu_periph/gpio.h"
|
||||||
|
|
||||||
#ifndef BLUEGIGA_SPI_DEV
|
#ifndef BLUEGIGA_SPI_DEV
|
||||||
#define BLUEGIGA_SPI_DEV spi2
|
#error "bluegiga: must define a BLUEGIGA_SPI_DEV"
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef BLUEGIGA_SLAVE_IDX
|
|
||||||
#define BLUEGIGA_SLAVE_IDX SPI_SLAVE2
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Bluegiga: DRDY defaults to SuperbitRf DRDY
|
||||||
#ifndef BLUEGIGA_DRDY_GPIO
|
#ifndef BLUEGIGA_DRDY_GPIO
|
||||||
#define BLUEGIGA_DRDY_GPIO GPIOC
|
#define BLUEGIGA_DRDY_GPIO SUPERBITRF_DRDY_PORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef BLUEGIGA_DRDY_GPIO_PIN
|
#ifndef BLUEGIGA_DRDY_GPIO_PIN
|
||||||
#define BLUEGIGA_DRDY_GPIO_PIN GPIO6
|
#define BLUEGIGA_DRDY_GPIO_PIN SUPERBITRF_DRDY_PIN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum BlueGigaStatus coms_status;
|
enum BlueGigaStatus coms_status;
|
||||||
@@ -73,14 +70,16 @@ static void trans_cb(struct spi_transaction *trans __attribute__((unused)))
|
|||||||
void bluegiga_init(void)
|
void bluegiga_init(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
LED_INIT(3);
|
#ifdef MODEM_LED
|
||||||
|
LED_INIT(MODEM_LED);
|
||||||
|
#endif
|
||||||
|
|
||||||
// configure the SPI bus.
|
// configure the SPI bus.
|
||||||
bluegiga_spi.input_buf = bluegiga_p.work_rx;
|
bluegiga_spi.input_buf = bluegiga_p.work_rx;
|
||||||
bluegiga_spi.output_buf = bluegiga_p.work_tx;
|
bluegiga_spi.output_buf = bluegiga_p.work_tx;
|
||||||
bluegiga_spi.input_length = 20;
|
bluegiga_spi.input_length = 20;
|
||||||
bluegiga_spi.output_length = 20;
|
bluegiga_spi.output_length = 20;
|
||||||
bluegiga_spi.slave_idx = BLUEGIGA_SLAVE_IDX;
|
bluegiga_spi.slave_idx = 0; // Not used for SPI-Slave: always NSS pin
|
||||||
bluegiga_spi.select = SPISelectUnselect;
|
bluegiga_spi.select = SPISelectUnselect;
|
||||||
bluegiga_spi.cpol = SPICpolIdleHigh;
|
bluegiga_spi.cpol = SPICpolIdleHigh;
|
||||||
bluegiga_spi.cpha = SPICphaEdge2;
|
bluegiga_spi.cpha = SPICphaEdge2;
|
||||||
@@ -191,7 +190,9 @@ void bluegiga_receive(void)
|
|||||||
bluegiga_p.tx_insert_idx = 0;
|
bluegiga_p.tx_insert_idx = 0;
|
||||||
bluegiga_p.tx_extract_idx = 0;
|
bluegiga_p.tx_extract_idx = 0;
|
||||||
|
|
||||||
LED_OFF(3);
|
#ifdef MODEM_LED
|
||||||
|
LED_OFF(MODEM_LED);
|
||||||
|
#endif
|
||||||
coms_status = BLUEGIGA_UNINIT;
|
coms_status = BLUEGIGA_UNINIT;
|
||||||
gpio_set(BLUEGIGA_DRDY_GPIO, BLUEGIGA_DRDY_GPIO_PIN); // Reset interrupt pin
|
gpio_set(BLUEGIGA_DRDY_GPIO, BLUEGIGA_DRDY_GPIO_PIN); // Reset interrupt pin
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#define BLUEGIGA_DATA_LINK_H
|
#define BLUEGIGA_DATA_LINK_H
|
||||||
|
|
||||||
#include "mcu_periph/link_device.h"
|
#include "mcu_periph/link_device.h"
|
||||||
#include "generated/airframe.h"
|
|
||||||
|
|
||||||
/* The different statuses the communication can be in */
|
/* The different statuses the communication can be in */
|
||||||
enum BlueGigaStatus {
|
enum BlueGigaStatus {
|
||||||
@@ -91,7 +90,9 @@ static inline void bluegiga_read_buffer(struct pprz_transport *t)
|
|||||||
// reached end of circular read buffer or message received
|
// reached end of circular read buffer or message received
|
||||||
// if received, decode and advance
|
// if received, decode and advance
|
||||||
if (t->trans_rx.msg_received) {
|
if (t->trans_rx.msg_received) {
|
||||||
LED_TOGGLE(3);
|
#ifdef MODEM_LED
|
||||||
|
LED_TOGGLE(MODEM_LED);
|
||||||
|
#endif
|
||||||
pprz_parse_payload(t);
|
pprz_parse_payload(t);
|
||||||
t->trans_rx.msg_received = FALSE;
|
t->trans_rx.msg_received = FALSE;
|
||||||
}
|
}
|
||||||
@@ -99,7 +100,7 @@ static inline void bluegiga_read_buffer(struct pprz_transport *t)
|
|||||||
} while (BlueGigaChAvailable()); // continue till all messages read
|
} while (BlueGigaChAvailable()); // continue till all messages read
|
||||||
}
|
}
|
||||||
|
|
||||||
// transmit previous date in buffer and parse data received
|
// transmit previous data in buffer and parse data received
|
||||||
#define BlueGigaCheckAndParse(_dev,_trans) { \
|
#define BlueGigaCheckAndParse(_dev,_trans) { \
|
||||||
if (BlueGigaChAvailable()) \
|
if (BlueGigaChAvailable()) \
|
||||||
bluegiga_read_buffer( &(_trans) ); \
|
bluegiga_read_buffer( &(_trans) ); \
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ static inline void DlCheckAndParse(void)
|
|||||||
#elif defined DATALINK && DATALINK == BLUEGIGA
|
#elif defined DATALINK && DATALINK == BLUEGIGA
|
||||||
|
|
||||||
#define DatalinkEvent() { \
|
#define DatalinkEvent() { \
|
||||||
BlueGigaCheckAndParse(BLUEGIGA, pprz_tp); \
|
BlueGigaCheckAndParse(BLUEGIGA_SPI_DEV, pprz_tp); \
|
||||||
DlCheckAndParse(); \
|
DlCheckAndParse(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,9 @@
|
|||||||
#include "subsystems/datalink/pprzlog_transport.h"
|
#include "subsystems/datalink/pprzlog_transport.h"
|
||||||
#include "subsystems/datalink/xbee.h"
|
#include "subsystems/datalink/xbee.h"
|
||||||
#include "subsystems/datalink/w5100.h"
|
#include "subsystems/datalink/w5100.h"
|
||||||
|
#if DATALINK == BLUEGIGA
|
||||||
#include "subsystems/datalink/bluegiga.h"
|
#include "subsystems/datalink/bluegiga.h"
|
||||||
|
#endif
|
||||||
#if USE_SUPERBITRF
|
#if USE_SUPERBITRF
|
||||||
#include "subsystems/datalink/superbitrf.h"
|
#include "subsystems/datalink/superbitrf.h"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user