# HG changeset patch
# User paul
# Date 2015-12-16 14:54:47
# Node ID 1c5814170464a101efc8b49279169308e2f55bca
# Parent 3412b0dcc87a04990c516bed5cdb59cc6a980fc9
STAT task removec
LOAD task added for periodical watchdog timer reload
diff --git a/.hgsubstate b/.hgsubstate
--- a/.hgsubstate
+++ b/.hgsubstate
@@ -1,2 +1,2 @@
3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
-e1bf35e31e3c8c1d1448d2e485c71f5f1259615c header/lfr_common_headers
+721463c11a484e6a3439e16c99f8bd27720b9265 header/lfr_common_headers
diff --git a/header/fsw_misc.h b/header/fsw_misc.h
--- a/header/fsw_misc.h
+++ b/header/fsw_misc.h
@@ -19,16 +19,24 @@ enum lfr_reset_cause_t{
UNEXP_RESET
};
+extern gptimer_regs_t *gptimer_regs;
+
#define LFR_RESET_CAUSE_UNKNOWN_CAUSE 0
-rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic
-rtems_id HK_id; // id of the HK rate monotonic period
+rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic
+rtems_id HK_id; // id of the HK rate monotonic period
-void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
+void timer_configure( unsigned char timer, unsigned int clock_divider,
unsigned char interrupt_level, rtems_isr (*timer_isr)() );
-void timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer );
-void timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer );
-void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider);
+void timer_start( unsigned char timer );
+void timer_stop( unsigned char timer );
+void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider);
+
+// WATCHDOG
+rtems_isr watchdog_isr( rtems_vector_number vector );
+void watchdog_configure(void);
+void watchdog_stop(void);
+void watchdog_start(void);
// SERIAL LINK
int send_console_outputs_on_apbuart_port( void );
@@ -36,7 +44,7 @@ int enable_apbuart_transmitter( void );
void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
// RTEMS TASKS
-rtems_task stat_task( rtems_task_argument argument );
+rtems_task load_task( rtems_task_argument argument );
rtems_task hous_task( rtems_task_argument argument );
rtems_task dumb_task( rtems_task_argument unused );
diff --git a/header/processing/fsw_processing.h b/header/processing/fsw_processing.h
--- a/header/processing/fsw_processing.h
+++ b/header/processing/fsw_processing.h
@@ -97,11 +97,9 @@ extern volatile spectral_matrix_regs_t *
extern rtems_name misc_name[5];
extern rtems_id Task_id[20]; /* array of task ids */
-//
ring_node * getRingNodeForAveraging( unsigned char frequencyChannel);
// ISR
rtems_isr spectral_matrices_isr( rtems_vector_number vector );
-rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
//******************
// Spectral Matrices
diff --git a/src/fsw_init.c b/src/fsw_init.c
--- a/src/fsw_init.c
+++ b/src/fsw_init.c
@@ -141,7 +141,7 @@ rtems_task Init( rtems_task_argument ign
pa_bia_status_info = 0x00;
// waveform picker initialization
- WFP_init_rings(); // initialize the waveform rings
+ WFP_init_rings(); LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings
WFP_reset_current_ring_nodes();
reset_waveform_picker_regs();
@@ -221,14 +221,6 @@ rtems_task Init( rtems_task_argument ign
PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
}
- //******************************
- //
- LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
- configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
- IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
- //
- //*******************************
-
// configure IRQ handling for the waveform picker unit
status = rtems_interrupt_catch( waveforms_isr,
IRQ_SPARC_WAVEFORM_PICKER,
@@ -299,7 +291,7 @@ void create_names( void ) // create all
Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
- Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
+ Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' );
Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
@@ -481,12 +473,12 @@ int create_all_tasks( void ) // create a
//*****
// MISC
- if (status == RTEMS_SUCCESSFUL) // STAT
+ if (status == RTEMS_SUCCESSFUL) // LOAD
{
status = rtems_task_create(
- Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
+ Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE,
RTEMS_DEFAULT_MODES,
- RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
+ RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD]
);
}
if (status == RTEMS_SUCCESSFUL) // DUMB
@@ -667,11 +659,11 @@ int start_all_tasks( void ) // start all
BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
}
}
- if (status == RTEMS_SUCCESSFUL) // STAT
+ if (status == RTEMS_SUCCESSFUL) // LOAD
{
- status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
+ status = rtems_task_start( Task_id[TASKID_LOAD], load_task, 1 );
if (status!=RTEMS_SUCCESSFUL) {
- BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
+ BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n")
}
}
diff --git a/src/fsw_misc.c b/src/fsw_misc.c
--- a/src/fsw_misc.c
+++ b/src/fsw_misc.c
@@ -7,7 +7,7 @@
#include "fsw_misc.h"
-void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
+void timer_configure(unsigned char timer, unsigned int clock_divider,
unsigned char interrupt_level, rtems_isr (*timer_isr)() )
{
/** This function configures a GPTIMER timer instantiated in the VHDL design.
@@ -33,10 +33,10 @@ void configure_timer(gptimer_regs_t *gpt
PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
}
- timer_set_clock_divider( gptimer_regs, timer, clock_divider);
+ timer_set_clock_divider( timer, clock_divider);
}
-void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
+void timer_start(unsigned char timer)
{
/** This function starts a GPTIMER timer.
*
@@ -52,7 +52,7 @@ void timer_start(gptimer_regs_t *gptimer
gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
}
-void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
+void timer_stop(unsigned char timer)
{
/** This function stops a GPTIMER timer.
*
@@ -66,7 +66,7 @@ void timer_stop(gptimer_regs_t *gptimer_
gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
}
-void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
+void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider)
{
/** This function sets the clock divider of a GPTIMER timer.
*
@@ -79,6 +79,70 @@ void timer_set_clock_divider(gptimer_reg
gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
}
+// WATCHDOG
+
+rtems_isr watchdog_isr( rtems_vector_number vector )
+{
+ rtems_status_code status_code;
+
+ status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_12 );
+}
+
+void watchdog_configure(void)
+{
+ /** This function configure the watchdog.
+ *
+ * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
+ * @param timer is the number of the timer in the IP core (several timers can be instantiated).
+ *
+ * The watchdog is a timer provided by the GPTIMER IP core of the GRLIB.
+ *
+ */
+
+ LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt during configuration
+
+ timer_configure( TIMER_WATCHDOG, CLKDIV_WATCHDOG, IRQ_SPARC_GPTIMER_WATCHDOG, watchdog_isr );
+
+ LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt
+}
+
+void watchdog_stop(void)
+{
+ LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt line
+ timer_stop( TIMER_WATCHDOG );
+ LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt
+}
+
+void watchdog_reload(void)
+{
+ /** This function reloads the watchdog timer counter with the timer reload value.
+ *
+ *
+ */
+
+ gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register
+}
+
+void watchdog_start(void)
+{
+ /** This function starts the watchdog timer.
+ *
+ * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
+ * @param timer is the number of the timer in the IP core (several timers can be instantiated).
+ *
+ */
+
+ LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG );
+
+ gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000010; // clear pending IRQ if any
+ gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register
+ gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000001; // EN enable the timer
+ gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000008; // IE interrupt enable
+
+ LEON_Unmask_interrupt( IRQ_GPTIMER_WATCHDOG );
+
+}
+
int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port
{
struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
@@ -117,25 +181,44 @@ void set_apbuart_scaler_reload_register(
//************
// RTEMS TASKS
-rtems_task stat_task(rtems_task_argument argument)
+rtems_task load_task(rtems_task_argument argument)
{
- int i;
- int j;
+ BOOT_PRINTF("in LOAD *** \n")
+
+ rtems_status_code status;
+ unsigned int i;
+ unsigned int j;
+ rtems_name name_watchdog_rate_monotonic; // name of the watchdog rate monotonic
+ rtems_id watchdog_period_id; // id of the watchdog rate monotonic period
+
+ name_watchdog_rate_monotonic = rtems_build_name( 'L', 'O', 'A', 'D' );
+
+ status = rtems_rate_monotonic_create( name_watchdog_rate_monotonic, &watchdog_period_id );
+ if( status != RTEMS_SUCCESSFUL ) {
+ PRINTF1( "in LOAD *** rtems_rate_monotonic_create failed with status of %d\n", status )
+ }
+
i = 0;
j = 0;
- BOOT_PRINTF("in STAT *** \n")
+
+ watchdog_configure();
+
+ watchdog_start();
+
while(1){
- rtems_task_wake_after(1000);
- PRINTF1("%d\n", j)
- if (i == CPU_USAGE_REPORT_PERIOD) {
-// #ifdef PRINT_TASK_STATISTICS
-// rtems_cpu_usage_report();
-// rtems_cpu_usage_reset();
-// #endif
+ status = rtems_rate_monotonic_period( watchdog_period_id, WATCHDOG_PERIOD );
+ watchdog_reload();
+ i = i + 1;
+ if ( i == 10 )
+ {
i = 0;
+ j = j + 1;
+ PRINTF1("%d\n", j)
}
- else i++;
- j++;
+ if (j == 3 )
+ {
+ status = rtems_task_delete(RTEMS_SELF);
+ }
}
}
@@ -255,7 +338,7 @@ rtems_task dumb_task( rtems_task_argumen
unsigned int fine_time = 0;
rtems_event_set event_out;
- char *DumbMessages[12] = {"in DUMB *** default", // RTEMS_EVENT_0
+ char *DumbMessages[13] = {"in DUMB *** default", // RTEMS_EVENT_0
"in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
"in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
"in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
@@ -266,7 +349,8 @@ rtems_task dumb_task( rtems_task_argumen
"VHDL ERR *** spectral matrix", // RTEMS_EVENT_8
"tick", // RTEMS_EVENT_9
"VHDL ERR *** waveform picker", // RTEMS_EVENT_10
- "VHDL ERR *** unexpected ready matrix values" // RTEMS_EVENT_11
+ "VHDL ERR *** unexpected ready matrix values", // RTEMS_EVENT_11
+ "WATCHDOG timer" // RTEMS_EVENT_12
};
BOOT_PRINTF("in DUMB *** \n")
@@ -274,7 +358,7 @@ rtems_task dumb_task( rtems_task_argumen
while(1){
rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
| RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
- | RTEMS_EVENT_8 | RTEMS_EVENT_9,
+ | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12,
RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
intEventOut = (unsigned int) event_out;
for ( i=0; i<32; i++)
@@ -283,11 +367,9 @@ rtems_task dumb_task( rtems_task_argumen
{
coarse_time = time_management_regs->coarse_time;
fine_time = time_management_regs->fine_time;
- if (i==8)
+ if (i==12)
{
- }
- if (i==10)
- {
+ PRINTF1("%s\n", DumbMessages[12])
}
}
}
diff --git a/src/processing/fsw_processing.c b/src/processing/fsw_processing.c
--- a/src/processing/fsw_processing.c
+++ b/src/processing/fsw_processing.c
@@ -246,55 +246,6 @@ rtems_isr spectral_matrices_isr( rtems_v
spectral_matrix_isr_error_handler( statusReg );
}
-rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
-{
- rtems_status_code status_code;
-
- //***
- // F0
- nb_sm_f0 = nb_sm_f0 + 1;
- if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
- {
- ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
- if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
- {
- status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
- }
- nb_sm_f0 = 0;
- }
-
- //***
- // F1
- nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
- if (nb_sm_f0_aux_f1 == 6)
- {
- nb_sm_f0_aux_f1 = 0;
- nb_sm_f1 = nb_sm_f1 + 1;
- }
- if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
- {
- ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
- if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
- {
- status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
- }
- nb_sm_f1 = 0;
- }
-
- //***
- // F2
- nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
- if (nb_sm_f0_aux_f2 == 96)
- {
- nb_sm_f0_aux_f2 = 0;
- ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
- if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
- {
- status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
- }
- }
-}
-
//******************
// Spectral Matrices
diff --git a/src/tc_handler.c b/src/tc_handler.c
--- a/src/tc_handler.c
+++ b/src/tc_handler.c
@@ -566,12 +566,6 @@ int stop_current_mode( void )
LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
- //
- LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
- timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
- LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
- //
-
// suspend several tasks
if (lfrCurrentMode != LFR_MODE_STANDBY) {
status = suspend_science_tasks();