mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
Fixed Watchdog compile problems
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2404 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
07798bb2db
commit
13e3d37ef4
@ -119,6 +119,7 @@ SRC += $(HOME_DIR)/uavtalk_comms.c
|
||||
SRC += $(HOME_DIR)/saved_settings.c
|
||||
SRC += $(HOME_DIR)/gpio_in.c
|
||||
SRC += $(HOME_DIR)/stopwatch.c
|
||||
SRC += $(HOME_DIR)/watchdog.c
|
||||
SRC += $(FLIGHTLIB)/fifo_buffer.c
|
||||
ifeq ($(USE_USB), YES)
|
||||
SRC += $(HOME_DIR)/pios_usb_hid_desc.c
|
||||
@ -134,7 +135,6 @@ SRC += $(PIOSSTM32F10X)/pios_irq.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_adc.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_gpio.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_spi.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_wdg.c
|
||||
|
||||
# PIOS USB related files (seperated to make code maintenance more easy)
|
||||
ifeq ($(USE_USB), YES)
|
||||
@ -156,19 +156,19 @@ SRC += $(CMSISDIR)/system_stm32f10x.c
|
||||
|
||||
## Used parts of the STM-Library
|
||||
SRC += $(STMSPDSRCDIR)/stm32f10x_adc.c
|
||||
#SRC += $(STMSPDSRCDIR)/stm32f10x_bkp.c
|
||||
#SRC += $(STMSPDSRCDIR)/stm32f10x_crc.c
|
||||
#SRC += $(STMSPDSRCDIR)/stm32f10x_dac.c
|
||||
SRC += $(STMSPDSRCDIR)/stm32f10x_bkp.c
|
||||
SRC += $(STMSPDSRCDIR)/stm32f10x_crc.c
|
||||
SRC += $(STMSPDSRCDIR)/stm32f10x_dac.c
|
||||
SRC += $(STMSPDSRCDIR)/stm32f10x_dbgmcu.c
|
||||
SRC += $(STMSPDSRCDIR)/stm32f10x_dma.c
|
||||
SRC += $(STMSPDSRCDIR)/stm32f10x_exti.c
|
||||
SRC += $(STMSPDSRCDIR)/stm32f10x_flash.c
|
||||
SRC += $(STMSPDSRCDIR)/stm32f10x_gpio.c
|
||||
SRC += $(STMSPDSRCDIR)/stm32f10x_iwdg.c
|
||||
#SRC += $(STMSPDSRCDIR)/stm32f10x_i2c.c
|
||||
#SRC += $(STMSPDSRCDIR)/stm32f10x_pwr.c
|
||||
SRC += $(STMSPDSRCDIR)/stm32f10x_i2c.c
|
||||
SRC += $(STMSPDSRCDIR)/stm32f10x_pwr.c
|
||||
SRC += $(STMSPDSRCDIR)/stm32f10x_rcc.c
|
||||
#SRC += $(STMSPDSRCDIR)/stm32f10x_rtc.c
|
||||
SRC += $(STMSPDSRCDIR)/stm32f10x_rtc.c
|
||||
SRC += $(STMSPDSRCDIR)/stm32f10x_spi.c
|
||||
SRC += $(STMSPDSRCDIR)/stm32f10x_tim.c
|
||||
SRC += $(STMSPDSRCDIR)/stm32f10x_usart.c
|
||||
|
32
flight/PipXtreme/inc/watchdog.h
Normal file
32
flight/PipXtreme/inc/watchdog.h
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file watchdog.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief RF Module hardware layer
|
||||
* @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 _WATCHDOG_H_
|
||||
#define _WATCHDOG_H_
|
||||
|
||||
uint16_t watchdog_Init(uint16_t delayMs);
|
||||
void watchdog_Clear(void);
|
||||
|
||||
#endif
|
@ -41,6 +41,7 @@
|
||||
#include "uavtalk_comms.h"
|
||||
#include "gpio_in.h"
|
||||
#include "stopwatch.h"
|
||||
#include "watchdog.h"
|
||||
#include "saved_settings.h"
|
||||
|
||||
#include "main.h"
|
||||
@ -104,13 +105,13 @@ volatile int32_t psu_adc;
|
||||
|
||||
watchdog_timer = 0;
|
||||
|
||||
PIOS_WDG_Clear();
|
||||
watchdog_Clear();
|
||||
}
|
||||
|
||||
void enableWatchdog(void)
|
||||
{ // enable a watchdog
|
||||
watchdog_timer = 0;
|
||||
watchdog_delay = PIOS_WDG_Init(1000); // 1 second watchdog timeout
|
||||
watchdog_delay = watchdog_Init(1000); // 1 second watchdog timeout
|
||||
}
|
||||
|
||||
#endif
|
||||
|
80
flight/PipXtreme/watchdog.c
Normal file
80
flight/PipXtreme/watchdog.c
Normal file
@ -0,0 +1,80 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_WDG Watchdog Functions
|
||||
* @brief PIOS Comamnds to initialize and clear watchdog timer
|
||||
* @{
|
||||
*
|
||||
* @file pios_spi.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Thorsten Klose (tk@midibox.org) (tk@midibox.org)
|
||||
* @brief Hardware Abstraction Layer for SPI ports of STM32
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @notes
|
||||
*
|
||||
* The PIOS Watchdog provides a HAL to initialize a watchdog
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 "pios.h"
|
||||
#include "stm32f10x_iwdg.h"
|
||||
#include "stm32f10x_dbgmcu.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize the watchdog timer for a specified timeout
|
||||
*
|
||||
* It is important to note that this function returns the achieved timeout
|
||||
* for this hardware. For hardware indendence this should be checked when
|
||||
* scheduling updates. Other hardware dependent details may need to be
|
||||
* considered such as a window time which sets a minimum update time,
|
||||
* and this function should return a recommended delay for clearing.
|
||||
*
|
||||
* For the STM32 nominal clock rate is 32 khz, but for the maximum clock rate of
|
||||
* 60 khz and a prescalar of 4 yields a clock rate of 15 khz. The delay that is
|
||||
* set in the watchdog assumes the nominal clock rate, but the delay for FreeRTOS
|
||||
* to use is 75% of the minimal delay.
|
||||
*
|
||||
* @param[in] delayMs The delay period in ms
|
||||
* @returns Maximum recommended delay between updates
|
||||
*/
|
||||
uint16_t watchdog_Init(uint16_t delayMs)
|
||||
{
|
||||
uint16_t delay = ((uint32_t) delayMs * 60) / 16;
|
||||
if (delay > 0x0fff)
|
||||
delay = 0x0fff;
|
||||
|
||||
DBGMCU_Config(DBGMCU_IWDG_STOP, ENABLE); // make the watchdog stop counting in debug mode
|
||||
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
|
||||
IWDG_SetPrescaler(IWDG_Prescaler_16);
|
||||
IWDG_SetReload(delay);
|
||||
IWDG_ReloadCounter();
|
||||
IWDG_Enable();
|
||||
|
||||
return ((((uint32_t) delay * 16) / 60) * .75f);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear the watchdog timer
|
||||
*
|
||||
* This function must be called at the appropriate delay to prevent a reset event occuring
|
||||
*/
|
||||
void watchdog_Clear(void)
|
||||
{
|
||||
IWDG_ReloadCounter();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user