# HG changeset patch # User paul # Date 2016-02-24 06:52:49 # Node ID 42c0a3b87048c8a9cbd84ef6ae5b0187ca288f0d # Parent f2bc176d9a3a5ed292c3cfb44c3c11ab00f5f3c5 modifications following #634: reset cause is set to unknown spacewire link state is copied in the hk packets diff --git a/.hgsubstate b/.hgsubstate --- a/.hgsubstate +++ b/.hgsubstate @@ -1,2 +1,2 @@ 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters -449d1ebc41af2e62571508883dab8043a33f16df header/lfr_common_headers +1f3d7ce688e982a378d739596c8e3f8972f40b9d header/lfr_common_headers diff --git a/header/fsw_spacewire.h b/header/fsw_spacewire.h --- a/header/fsw_spacewire.h +++ b/header/fsw_spacewire.h @@ -35,6 +35,7 @@ void spacewire_read_statistics( void ); void spacewire_get_last_error( void ); void update_hk_lfr_last_er_fields(unsigned int rid, unsigned char code); void update_hk_with_grspw_stats(void ); +void spacewire_update_hk_lfr_link_state( unsigned char *hk_lfr_status_word_0 ); void increase_unsigned_char_counter( unsigned char *counter ); void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header ); diff --git a/src/fsw_misc.c b/src/fsw_misc.c --- a/src/fsw_misc.c +++ b/src/fsw_misc.c @@ -275,7 +275,7 @@ rtems_task hous_task(rtems_task_argument status = rtems_rate_monotonic_cancel(HK_id); DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) - set_hk_lfr_reset_cause( POWER_ON ); + set_hk_lfr_reset_cause( UNKNOWN_CAUSE ); while(1){ // launch the rate monotonic task status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); @@ -295,6 +295,8 @@ rtems_task hous_task(rtems_task_argument housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time); + spacewire_update_hk_lfr_link_state( &housekeeping_packet.lfr_status_word[0] ); + spacewire_read_statistics(); update_hk_with_grspw_stats(); @@ -679,8 +681,11 @@ void set_hk_lfr_calib_enable( bool state void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ) { + housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf8; // [1111 1000] + housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | (lfr_reset_cause & 0x07 ); // [0000 0111] + } void hk_lfr_le_me_he_update() diff --git a/src/fsw_spacewire.c b/src/fsw_spacewire.c --- a/src/fsw_spacewire.c +++ b/src/fsw_spacewire.c @@ -800,6 +800,19 @@ void update_hk_with_grspw_stats( void ) housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) grspw_stats.rx_truncated; } +void spacewire_update_hk_lfr_link_state( unsigned char *hk_lfr_status_word_0 ) +{ + unsigned int *statusRegisterPtr; + unsigned char linkState; + + statusRegisterPtr = (unsigned int *) (REGS_ADDR_GRSPW + APB_OFFSET_GRSPW_STATUS_REGISTER); + linkState = (unsigned char) ( ( (*statusRegisterPtr) >> 21) & 0x07); // [0000 0111] + + *hk_lfr_status_word_0 = *hk_lfr_status_word_0 & 0xf8; // [1111 1000] set link state to 0 + + *hk_lfr_status_word_0 = *hk_lfr_status_word_0 | linkState; // update hk_lfr_dpu_spw_link_state +} + void increase_unsigned_char_counter( unsigned char *counter ) { // update the number of valid timecodes that have been received