1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

OP-1477 - a bit of cleanup, some flash bits moved to a separate file

This commit is contained in:
Alessio Morale 2014-09-16 23:02:53 +02:00
parent 2885a20acb
commit 2cca5162f7
5 changed files with 97 additions and 33 deletions

View File

@ -0,0 +1,35 @@
/**
******************************************************************************
*
* @file gps9flashhandler.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
* @brief Flash handler for GPSV9.
* --
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "inc/gps9flashhandler.h"
extern uintptr_t flash_id;
extern struct pios_flash_driver pios_jedec_flash_driver;
extern uintptr_t flash_id;
bool flash_available()
{
return flash_id > 0;
}

View File

@ -9,15 +9,13 @@
*
* @{
* @addtogroup SystemModule GPSV9 System Module
* @brief Initializes PIOS and other modules runs monitoring
* After initializing all the modules (currently selected by Makefile but in
* future controlled by configuration on SD card) runs basic monitoring and
* alarms.
* @brief Initializes PIOS and other modules runs monitoring, executes mag and gps handlers
*
* @{
*
* @file gpsdsystemmod.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
* @brief System module
* @brief GPS System module
*
* @see The GNU Public License (GPL) Version 3
*
@ -43,19 +41,16 @@
#include "inc/gpsdsysmod.h"
#include "inc/gps9maghandler.h"
#include "inc/gps9gpshandler.h"
#include "inc/gps9flashhandler.h"
#include "inc/gps9protocol.h"
// UAVOs
#include <systemstats.h>
SystemStatsData systemStats;
extern uintptr_t flash_id;
#define DEBUG_THIS_FILE
extern uint32_t pios_com_main_id;
extern struct pios_flash_driver pios_jedec_flash_driver;
extern uintptr_t flash_id;
// Private constants
#define SYSTEM_UPDATE_PERIOD_MS 1
@ -75,9 +70,6 @@ static bool mallocFailed;
static void updateStats();
static void gpspSystemTask(void *parameters);
#define SYS_DATA_OPTIONS_FLASH 0x01
/**
* Create the module task.
* \returns 0 on success or -1 if initialization failed
@ -119,17 +111,20 @@ static void gpspSystemTask(__attribute__((unused)) void *parameters)
MODULE_TASKCREATE_ALL;
if (mallocFailed) {
/* We failed to malloc during task creation,
* system behaviour is undefined. Reset and let
* the BootFault code recover for us.
*/
PIOS_SYS_Reset();
// Nothing to do, this condition needs to be trapped during development.
while (wait_here) {
;
}
}
#if defined(PIOS_INCLUDE_IAP)
/* Record a successful boot */
#if defined(PIOS_INCLUDE_IAP)
PIOS_IAP_WriteBootCount(0);
#endif
/* Right now there is no configuration and uart speed is fixed at 115200.
* TODO:
* 1) add a tiny ubx parser on gps side to intercept CFG-RINV and use that for config storage;
* 2) second ubx parser on uart side that intercept custom configuration message and flash commands.
*/
PIOS_COM_ChangeBaud(pios_com_main_id, 115200);
static TickType_t lastUpdate;
setupGPS();
@ -190,10 +185,10 @@ uint16_t GetFreeIrqStackSize(void)
/**
* Called periodically to update the system stats
*/
SysUbxPkt sysPkt;
static void updateStats()
{
static uint32_t lastUpdate;
static SysUbxPkt sysPkt;
if (PIOS_DELAY_DiffuS(lastUpdate) < 1000 * configTICK_RATE_HZ / STAT_RATE) {
return;
@ -204,21 +199,18 @@ static void updateStats()
sysPkt.fragments.data.HeapRemaining = xPortGetFreeHeapSize();
sysPkt.fragments.data.IRQStackRemaining = GetFreeIrqStackSize();
sysPkt.fragments.data.SystemModStackRemaining = uxTaskGetStackHighWaterMark(NULL) * 4;
sysPkt.fragments.data.options = flash_id > 0 ? SYS_DATA_OPTIONS_FLASH : 0;
sysPkt.fragments.data.options = SYS_DATA_OPTIONS_MAG | (flash_available() ? SYS_DATA_OPTIONS_FLASH : 0);
ubx_buildPacket(&sysPkt.packet, UBX_OP_CUST_CLASS, UBX_OP_SYS, sizeof(SysData));
PIOS_COM_SendBuffer(pios_com_main_id, sysPkt.packet.bynarystream, sizeof(SysUbxPkt));
}
/**
* Update system alarms
*/
/**
* Called by the RTOS when the CPU is idle,
*/
void vApplicationIdleHook(void)
{
// NotificationOnboardLedsRun();
}
{}
/**
* Called by the RTOS when a stack overflow is detected.
*/

View File

@ -0,0 +1,33 @@
/**
******************************************************************************
*
* @file gps9flashhandler.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
* @brief Flash handler for GPSV9
* --
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef GPS9FLASHHANDLER_H_
#define GPS9FLASHHANDLER_H_
#include <openpilot.h>
bool flash_available();
#endif /* GPS9FLASHHANDLER_H_ */

View File

@ -1,4 +1,4 @@
/**
/**magPkt
******************************************************************************
*
* @file gps9maghandler.h

View File

@ -31,9 +31,13 @@
#include <pios_helpers.h>
#include <ubx_utils.h>
#define UBX_OP_CUST_CLASS 0x99
#define UBX_OP_SYS 0x01
#define UBX_OP_MAG 0x02
#define UBX_OP_CUST_CLASS 0x99
#define UBX_OP_SYS 0x01
#define UBX_OP_MAG 0x02
#define SYS_DATA_OPTIONS_FLASH 0x01
#define SYS_DATA_OPTIONS_MAG 0x02
typedef struct {
int16_t X;