Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

Commit

Permalink
Move on to libsbp.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfine committed Mar 24, 2015
1 parent c9eacce commit 5a0697f
Show file tree
Hide file tree
Showing 32 changed files with 482 additions and 485 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "ChibiOS-RT"]
path = ChibiOS-RT
url = https://github.com/mabl/ChibiOS.git
[submodule "libsbp"]
path = libsbp
url = https://github.com/swift-nav/libsbp.git
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ endif

all: firmware # tests

firmware: libopencm3/lib/libopencm3_stm32f4.a libswiftnav/build/src/libswiftnav-static.a
firmware: libopencm3/lib/libopencm3_stm32f4.a libsbp/c/build/src/libsbp-static.a libswiftnav/build/src/libswiftnav-static.a
@printf "BUILD src\n"; \
$(MAKE) -r -C src $(MAKEFLAGS)

Expand All @@ -38,6 +38,12 @@ libopencm3/lib/libopencm3_stm32f4.a:
@printf "BUILD libopencm3\n"; \
$(MAKE) -C libopencm3 $(MAKEFLAGS) lib/stm32/f4

libsbp/c/build/src/libsbp-static.a:
@printf "BUILD libsbp\n"; \
mkdir -p libsbp/c/build; cd libsbp/c/build; \
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-gcc-arm-embedded.cmake $(CMAKEFLAGS) ../
$(MAKE) -C libsbp/c/build $(MAKEFLAGS)

libswiftnav/build/src/libswiftnav-static.a: .FORCE
@printf "BUILD libswiftnav\n"; \
mkdir -p libswiftnav/build; cd libswiftnav/build; \
Expand All @@ -49,6 +55,8 @@ clean:
$(MAKE) -C src $(MAKEFLAGS) clean
@printf "CLEAN libopencm3\n"; \
$(MAKE) -C libopencm3 $(MAKEFLAGS) clean
@printf "CLEAN libsbp\n"; \
$(RM) -rf libsbp/c/build
@printf "CLEAN libswiftnav\n"; \
$(RM) -rf libswiftnav/build
$(Q)for i in tests/*; do \
Expand All @@ -63,4 +71,3 @@ docs:
doxygen docs/Doxyfile

.FORCE:

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Documentation available online at http://docs.swift-nav.com/piksi_firmware
Checking Out Submodules
=========================

ChibiOS, libopencm3 and libswiftnav are submodules of this git repository.
ChibiOS, libopencm3, libsbp and libswiftnav are submodules of this git repository.
Check them out using:

git submodule init
Expand Down
1 change: 1 addition & 0 deletions libsbp
Submodule libsbp added at b0773d
2 changes: 1 addition & 1 deletion libswiftnav
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function build () {
# Pulls down git submodules and builds the project, assuming that
# all other system, ARM GCC, and python dependencies have been
# installed.
log_info "Initializing Git submodules for ChibiOS, libopencm3, and libswiftnav..."
log_info "Initializing Git submodules for ChibiOS, libopencm3, libsbp and libswiftnav..."
git submodule init
git submodule update
log_info "Building piksi_firmware..."
Expand Down
7 changes: 5 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ CSRC := $(PORTSRC) \
$(SWIFTNAV_ROOT)/src/minIni/minGlue.o \
$(SWIFTNAV_ROOT)/src/init.o \
$(SWIFTNAV_ROOT)/src/sbp.o \
$(SWIFTNAV_ROOT)/src/sbp_piksi.o \
$(SWIFTNAV_ROOT)/src/sbp_fileio.o \
$(SWIFTNAV_ROOT)/src/sbp_utils.o \
$(SWIFTNAV_ROOT)/src/error.o \
$(SWIFTNAV_ROOT)/src/cw.o \
$(SWIFTNAV_ROOT)/src/track.o \
Expand Down Expand Up @@ -157,6 +157,7 @@ TCPPSRC =
ASMSRC = $(PORTASM)

INCDIR = $(PORTINC) $(KERNINC) $(CHIBIOS)/os/various \
$(SWIFTNAV_ROOT)/libsbp/c/include \
$(SWIFTNAV_ROOT)/libswiftnav/include \
$(SWIFTNAV_ROOT)/src \
$(SWIFTNAV_ROOT)/libopencm3/include
Expand Down Expand Up @@ -217,6 +218,8 @@ DINCDIR =

# List the default directory to look for the libraries here
DLIBDIR = $(SWIFTNAV_ROOT)/libopencm3/lib \
$(SWIFTNAV_ROOT)/libsbp/c/build/src \
$(SWIFTNAV_ROOT)/libswiftnav/build/src \
$(SWIFTNAV_ROOT)/libswiftnav/build/lapacke \
$(SWIFTNAV_ROOT)/libswiftnav/build/CBLAS/src \
$(SWIFTNAV_ROOT)/libswiftnav/build/clapack-3.2.1-CMAKE/BLAS/SRC \
Expand All @@ -225,7 +228,7 @@ DLIBDIR = $(SWIFTNAV_ROOT)/libopencm3/lib \
$(SWIFTNAV_ROOT)/libswiftnav/build/src

# List all default libraries here
DLIBS = -lopencm3_stm32f4 -lswiftnav-static \
DLIBS = -lopencm3_stm32f4 -lsbp-static -lswiftnav-static \
-llapacke -llapack -lcblas -lblas \
-lf2c -lm -lc -lnosys

Expand Down
7 changes: 3 additions & 4 deletions src/acq.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include "board/nap/acq_channel.h"
#include "acq.h"
#include "sbp_piksi.h"
#include "sbp.h"

/** \defgroup acq Acquisition
Expand Down Expand Up @@ -47,15 +46,15 @@ void acq_set_prn(u8 prn)
*/
void acq_send_result(u8 prn, float snr, float cp, float cf)
{
acq_result_msg_t acq_result_msg;
msg_acq_result_t acq_result_msg;

acq_result_msg.prn = prn;
acq_result_msg.snr = snr;
acq_result_msg.cp = cp;
acq_result_msg.cf = cf;

sbp_send_msg(MSG_ACQ_RESULT,
sizeof(acq_result_msg_t),
sbp_send_msg(SBP_MSG_ACQ_RESULT,
sizeof(msg_acq_result_t),
(u8 *)&acq_result_msg);
}

Expand Down
31 changes: 7 additions & 24 deletions src/base_obs.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <math.h>

#include <libswiftnav/logging.h>
#include <libswiftnav/sbp_utils.h>
#include <libswiftnav/pvt.h>
#include <libswiftnav/constants.h>
#include <libswiftnav/ephemeris.h>
Expand All @@ -26,6 +25,7 @@
#include "position.h"
#include "nmea.h"
#include "sbp.h"
#include "sbp_utils.h"
#include "solution.h"
#include "manage.h"
#include "simulator.h"
Expand Down Expand Up @@ -77,15 +77,6 @@ static void base_pos_callback(u16 sender_id, u8 len, u8 msg[], void* context)
chMtxUnlock();
}

/** SBP callback for the old style observation messages.
* Just prints a deprecation warning. */
static void obs_old_callback(u16 sender_id, u8 len, u8 msg[], void* context)
{
(void) context; (void) len; (void) msg; (void) sender_id;
log_warn("Receiving an old deprecated observation message.\n");
log_warn("Please update your base station firmware.\n");
}

/** Update the #base_obss state given a new set of obss.
* First sorts by PRN and computes the TDCP Doppler for the observation set. If
* #base_pos_known is false then a single point position solution is also
Expand Down Expand Up @@ -220,7 +211,7 @@ static void obs_callback(u16 sender_id, u8 len, u8 msg[], void* context)
return;

/* Relay observations using sender_id = 0. */
sbp_send_msg_(MSG_PACKED_OBS, len, msg, 0);
sbp_send_msg_(SBP_MSG_OBS, len, msg, 0);

/* GPS time of observation. */
gps_time_t t;
Expand All @@ -231,7 +222,7 @@ static void obs_callback(u16 sender_id, u8 len, u8 msg[], void* context)

/* Decode the message header to get the time and how far through the sequence
* we are. */
unpack_obs_header((msg_obs_header_t*)msg, &t, &total, &count);
unpack_obs_header((observation_header_t*)msg, &t, &total, &count);

/* Check to see if the observation is aligned with our internal observations,
* i.e. is it going to time match one of our local obs. */
Expand Down Expand Up @@ -264,7 +255,7 @@ static void obs_callback(u16 sender_id, u8 len, u8 msg[], void* context)

/* Calculate the number of observations in this message by looking at the SBP
* `len` field. */
u8 obs_in_msg = (len - sizeof(msg_obs_header_t)) / sizeof(msg_obs_content_t);
u8 obs_in_msg = (len - sizeof(observation_header_t)) / sizeof(packed_obs_content_t);

/* If this is the first packet in the sequence then reset the base_obss_rx
* state. */
Expand All @@ -274,7 +265,7 @@ static void obs_callback(u16 sender_id, u8 len, u8 msg[], void* context)
}

/* Pull out the contents of the message. */
msg_obs_content_t *obs = (msg_obs_content_t *)(msg + sizeof(msg_obs_header_t));
packed_obs_content_t *obs = (packed_obs_content_t *)(msg + sizeof(observation_header_t));
for (u8 i=0; i<obs_in_msg; i++) {
/* Check if we have an ephemeris for this satellite, we will need this to
* fill in satellite position etc. parameters. */
Expand Down Expand Up @@ -325,25 +316,17 @@ void base_obs_setup()

static sbp_msg_callbacks_node_t base_pos_node;
sbp_register_cbk(
MSG_BASE_POS,
SBP_MSG_BASE_POS,
&base_pos_callback,
&base_pos_node
);

static sbp_msg_callbacks_node_t obs_old_node;
sbp_register_cbk(
MSG_OLD_OBS,
&obs_old_callback,
&obs_old_node
);

static sbp_msg_callbacks_node_t obs_packed_node;
sbp_register_cbk(
MSG_PACKED_OBS,
SBP_MSG_OBS,
&obs_callback,
&obs_packed_node
);
}

/* \} */

6 changes: 3 additions & 3 deletions src/board/nap/nap_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <libopencm3/stm32/f4/gpio.h>
#include <libopencm3/stm32/f4/rcc.h>
#include <libswiftnav/sbp.h>
#include <libsbp/sbp.h>

#include "../../error.h"
#include "../../peripherals/spi.h"
Expand Down Expand Up @@ -171,15 +171,15 @@ void nap_rd_dna_callback(u16 sender_id, u8 len, u8 msg[], void* context)
(void)sender_id; (void)len; (void)msg; (void) context;
u8 dna[8];
nap_rd_dna(dna);
sbp_send_msg(MSG_NAP_DEVICE_DNA, 8, dna);
sbp_send_msg(SBP_MSG_NAP_DEVICE_DNA, 8, dna);
}

/** Setup NAP callbacks. */
void nap_callbacks_setup(void)
{
static sbp_msg_callbacks_node_t nap_dna_node;

sbp_register_cbk(MSG_NAP_DEVICE_DNA, &nap_rd_dna_callback,
sbp_register_cbk(SBP_MSG_NAP_DEVICE_DNA, &nap_rd_dna_callback,
&nap_dna_node);
}

Expand Down
6 changes: 3 additions & 3 deletions src/cw.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include <math.h>
#include <stdio.h>
#include <libswiftnav/sbp.h>
#include <libsbp/sbp.h>

#include "board/nap/cw_channel.h"
#include "sbp.h"
Expand Down Expand Up @@ -42,7 +42,7 @@ void cw_start_callback(u16 sender_id, u8 len, u8 msg[], void* context)
void cw_setup()
{
static sbp_msg_callbacks_node_t cw_start_callback_node;
sbp_register_cbk(MSG_CW_START, &cw_start_callback, &cw_start_callback_node);
sbp_register_cbk(SBP_MSG_CW_START, &cw_start_callback, &cw_start_callback_node);
}

/** Schedule a load of samples into the CW channel's sample ram.
Expand Down Expand Up @@ -184,7 +184,7 @@ void cw_send_result(float freq, u64 power)
msg.freq = freq;
msg.power = power;

sbp_send_msg(MSG_CW_RESULTS, sizeof(msg), (u8*)&msg);
sbp_send_msg(SBP_MSG_CW_RESULTS, sizeof(msg), (u8*)&msg);
}

/** Get a point from the CW correlations array
Expand Down
6 changes: 2 additions & 4 deletions src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
#include <stdlib.h>
#include <string.h>

#include <libswiftnav/edc.h>
#include <libswiftnav/sbp.h>
#include <libsbp/sbp.h>

#include "board/leds.h"
#include "peripherals/usart.h"
Expand Down Expand Up @@ -72,7 +71,7 @@ void _screaming_death(const char *pos, const char *msg)
/* Continuously send error message */
#define APPROX_ONE_SEC 33000000
while (1) {
sbp_send_message(&sbp_state, MSG_PRINT, 0, len, (u8*)err_msg, &fallback_write);
sbp_send_message(&sbp_state, SBP_MSG_PRINT, 0, len, (u8*)err_msg, &fallback_write);
led_toggle(LED_RED);
for (u32 d = 0; d < 5*APPROX_ONE_SEC; d++) {
__asm__("nop");
Expand All @@ -83,4 +82,3 @@ void _screaming_death(const char *pos, const char *msg)
/** \} */

/** \} */

Loading

0 comments on commit 5a0697f

Please sign in to comment.