Skip to content

Commit

Permalink
Merge pull request #841 from paparazzi/link_mcu_can
Browse files Browse the repository at this point in the history
intermcu link via CAN
  • Loading branch information
flixr committed Oct 7, 2014
2 parents 8c8fcb6 + a4d202d commit 52ba7e5
Show file tree
Hide file tree
Showing 10 changed files with 381 additions and 46 deletions.
12 changes: 12 additions & 0 deletions conf/firmwares/subsystems/fixedwing/intermcu_can.makefile
@@ -0,0 +1,12 @@
# Hey Emacs, this is a -*- makefile -*-

# InterMCU type CAN

ifneq ($(TARGET),sim)
$(TARGET).CFLAGS += -DINTER_MCU -DMCU_CAN_LINK
$(TARGET).srcs += link_mcu_can.c
$(TARGET).srcs += mcu_periph/can.c
$(TARGET).srcs += $(SRC_ARCH)/mcu_periph/can_arch.c
endif

SEPARATE_FBW=1
8 changes: 4 additions & 4 deletions sw/airborne/firmwares/fixedwing/main_ap.c
Expand Up @@ -37,8 +37,8 @@
#include "firmwares/fixedwing/main_ap.h"
#include "mcu.h"
#include "mcu_periph/sys_time.h"

#include "link_mcu_spi.h"
#include "inter_mcu.h"
#include "link_mcu.h"

// Sensors
#if USE_GPS
Expand Down Expand Up @@ -213,7 +213,7 @@ void init_ap( void ) {
ins_init();

/************* Links initialization ***************/
#if defined MCU_SPI_LINK || defined MCU_UART_LINK
#if defined MCU_SPI_LINK || defined MCU_UART_LINK || defined MCU_CAN_LINK
link_mcu_init();
#endif
#if USE_AUDIO_TELEMETRY
Expand Down Expand Up @@ -575,7 +575,7 @@ void attitude_loop( void ) {

ap_state->commands[COMMAND_PITCH] = h_ctl_elevator_setpoint;

#if defined MCU_SPI_LINK || defined MCU_UART_LINK
#if defined MCU_SPI_LINK || defined MCU_UART_LINK || defined MCU_CAN_LINK
link_mcu_send();
#elif defined INTER_MCU && defined SINGLE_MCU
/**Directly set the flag indicating to FBW that shared buffer is available*/
Expand Down
18 changes: 9 additions & 9 deletions sw/airborne/firmwares/fixedwing/main_fbw.c
Expand Up @@ -48,17 +48,10 @@
#include "subsystems/datalink/telemetry.h"
#endif

#ifdef MCU_SPI_LINK
#include "link_mcu_spi.h"
#endif

#ifdef MCU_UART_LINK
#include "link_mcu_usart.h"
#endif

uint8_t fbw_mode;

#include "inter_mcu.h"
#include "link_mcu.h"

#ifdef USE_NPS
#include "nps_autopilot.h"
Expand Down Expand Up @@ -130,8 +123,10 @@ void init_fbw( void ) {
#ifdef INTER_MCU
inter_mcu_init();
#endif
#ifdef MCU_SPI_LINK
#if defined MCU_SPI_LINK || defined MCU_CAN_LINK
link_mcu_init();
#endif
#ifdef MCU_SPI_LINK
link_mcu_restart();
#endif

Expand Down Expand Up @@ -317,6 +312,11 @@ void periodic_task_fbw( void ) {
link_mcu_periodic_task();
#endif

#ifdef MCU_CAN_LINK
inter_mcu_fill_fbw_state();
link_mcu_periodic_task();
#endif

#if PERIODIC_TELEMETRY
periodic_telemetry_send_Fbw();
#endif
Expand Down
12 changes: 8 additions & 4 deletions sw/airborne/inter_mcu.c
Expand Up @@ -14,9 +14,13 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
* along with paparazzi; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*/

/**
* @file inter_mcu.c
* Communication between fbw and ap processes.
*
*/

Expand All @@ -28,7 +32,7 @@ static struct ap_state _ap_state;
struct fbw_state* fbw_state = &_fbw_state;
struct ap_state* ap_state = &_ap_state;
#else /* SINGLE_MCU */
#include "link_mcu_spi.h"
#include "link_mcu.h"
struct fbw_state* fbw_state = &link_mcu_from_fbw_msg.payload.from_fbw;
struct ap_state* ap_state = &link_mcu_from_ap_msg.payload.from_ap;
#endif /* ! SINGLE_MCU */
Expand Down
22 changes: 11 additions & 11 deletions sw/airborne/inter_mcu.h
@@ -1,5 +1,4 @@
/* $Id$
*
/*
* Copyright (C) 2003-2005 Pascal Brisset, Antoine Drouin
*
* This file is part of paparazzi.
Expand All @@ -15,19 +14,20 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* along with paparazzi; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*/

/** \brief Communication between fbw and ap processes
/**
* @file inter_mcu.h
* Communication between fbw and ap processes.
*
* This unit contains the data structure used to communicate between the
* "fly by wire" process and the "autopilot" process. It must be linked once in a
* monoprocessor architecture, twice in a twin-processors (the historical
* Atmel AVRs mega8-mega128 one) architecture. In the latter case, the
* inter-mcu communication process (e.g. SPI) must fill and read these data structures.
*/
* monoprocessor architecture, twice in a twin-processors architecture.
* In the latter case, the inter-mcu communication process (e.g. SPI) must fill and
* read these data structures.
*/

#ifndef INTER_MCU_H
#define INTER_MCU_H
Expand Down
37 changes: 37 additions & 0 deletions sw/airborne/link_mcu.h
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2003-2014 The Paparazzi Team
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*/

/**
* @file link_mcu.h
* Common transport functions for the communication between FBW and AP.
*/

#ifndef LINK_MCU_H
#define LINK_MCU_H

#ifdef MCU_SPI_LINK
#include "link_mcu_spi.h"
#elif defined MCU_UART_LINK
#include "link_mcu_usart.h"
#elif defined MCU_CAN_LINK
#include "link_mcu_can.h"
#endif

#endif /* LINK_MCU_H */

0 comments on commit 52ba7e5

Please sign in to comment.