LCOV - code coverage report
Current view: top level - src - fsw_watchdog.c (source / functions) Hit Total Coverage
Test: trace.info Lines: 16 23 69.6 %
Date: 2023-02-20 11:47:15 Functions: 3 5 60.0 %

          Line data    Source code
       1             : /*------------------------------------------------------------------------------
       2             : --  Solar Orbiter's Low Frequency Receiver Flight Software (LFR FSW),
       3             : --  This file is a part of the LFR FSW
       4             : --  Copyright (C) 2021, Plasma Physics Laboratory - CNRS
       5             : --
       6             : --  This program is free software; you can redistribute it and/or modify
       7             : --  it under the terms of the GNU General Public License as published by
       8             : --  the Free Software Foundation; either version 2 of the License, or
       9             : --  (at your option) any later version.
      10             : --
      11             : --  This program is distributed in the hope that it will be useful,
      12             : --  but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             : --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             : --  GNU General Public License for more details.
      15             : --
      16             : --  You should have received a copy of the GNU General Public License
      17             : --  along with this program; if not, write to the Free Software
      18             : --  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      19             : -------------------------------------------------------------------------------*/
      20             : /*--                  Author : Alexis Jeandet
      21             : --                   Contact : Alexis Jeandet
      22             : --                      Mail : alexis.jeandet@lpp.polytechnique.fr
      23             : ----------------------------------------------------------------------------*/
      24             : #include <stdint.h>
      25             : 
      26             : #include <leon.h>
      27             : 
      28             : #include "fsw_compile_warnings.h"
      29             : #include "fsw_debug.h"
      30             : #include "fsw_globals.h"
      31             : #include "fsw_misc.h"
      32             : #include "fsw_processing.h"
      33             : #include "fsw_watchdog.h"
      34             : #include "hw/lfr_regs.h"
      35             : #include "hw/timer.h"
      36             : 
      37             : // WATCHDOG, this ISR should never be triggered.
      38             : 
      39           0 : LFR_NO_RETURN rtems_isr watchdog_isr(rtems_vector_number vector)
      40             : {
      41             :     IGNORE_UNUSED_PARAMETER(vector);
      42             : 
      43             :     DEBUG_CHECK_STATUS(send_event_dumb_task(RTEMS_EVENT_12));
      44             : 
      45             :     LFR_PRINTF("watchdog_isr *** this is the end, exit(0)\n");
      46             : 
      47           0 :     exit(0);
      48             : }
      49             : 
      50           1 : void watchdog_configure(void)
      51             : {
      52             :     /** This function configure the watchdog.
      53             :      *
      54             :      * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
      55             :      * @param timer is the number of the timer in the IP core (several timers can be instantiated).
      56             :      *
      57             :      * The watchdog is a timer provided by the GPTIMER IP core of the GRLIB.
      58             :      *
      59             :      */
      60             : 
      61           1 :     LEON_Mask_interrupt(
      62             :         IRQ_GPTIMER_WATCHDOG); // mask gptimer/watchdog interrupt during configuration
      63             : 
      64           1 :     timer_configure(TIMER_WATCHDOG, CLKDIV_WATCHDOG, IRQ_SPARC_GPTIMER_WATCHDOG, &watchdog_isr);
      65             : 
      66           1 :     LEON_Clear_interrupt(IRQ_GPTIMER_WATCHDOG); // clear gptimer/watchdog interrupt
      67           1 : }
      68             : 
      69           0 : void watchdog_stop(void)
      70             : {
      71           0 :     LEON_Mask_interrupt(IRQ_GPTIMER_WATCHDOG); // mask gptimer/watchdog interrupt line
      72           0 :     timer_stop(TIMER_WATCHDOG);
      73           0 :     LEON_Clear_interrupt(IRQ_GPTIMER_WATCHDOG); // clear gptimer/watchdog interrupt
      74           0 : }
      75             : 
      76        1270 : void watchdog_reload(void)
      77             : {
      78             :     /** This function reloads the watchdog timer counter with the timer reload value.
      79             :      *
      80             :      * @param void
      81             :      *
      82             :      * @return void
      83             :      *
      84             :      */
      85             : 
      86        1270 :     gptimer0->timer[TIMER_WATCHDOG].ctrl = gptimer0->timer[TIMER_WATCHDOG].ctrl | GPTIMER_LD;
      87        1270 : }
      88             : 
      89           1 : void watchdog_start(void)
      90             : {
      91             :     /** This function starts the watchdog timer.
      92             :      *
      93             :      * @param timer is the number of the timer in the IP core (several timers can be instantiated).
      94             :      *
      95             :      */
      96             : 
      97           1 :     LEON_Clear_interrupt(IRQ_GPTIMER_WATCHDOG);
      98             : 
      99           1 :     gptimer0->timer[TIMER_WATCHDOG].ctrl = gptimer0->timer[TIMER_WATCHDOG].ctrl | GPTIMER_CLEAR_IRQ;
     100           1 :     gptimer0->timer[TIMER_WATCHDOG].ctrl = gptimer0->timer[TIMER_WATCHDOG].ctrl | GPTIMER_LD;
     101           1 :     gptimer0->timer[TIMER_WATCHDOG].ctrl = gptimer0->timer[TIMER_WATCHDOG].ctrl | GPTIMER_EN;
     102           1 :     gptimer0->timer[TIMER_WATCHDOG].ctrl = gptimer0->timer[TIMER_WATCHDOG].ctrl | GPTIMER_IE;
     103             : 
     104           1 :     LEON_Unmask_interrupt(IRQ_GPTIMER_WATCHDOG);
     105           1 : }

Generated by: LCOV version 1.14