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 : #pragma once 25 : #include "ccsds_types.h" 26 : #include "hw/lfr_regs.h" 27 : #include <stdbool.h> 28 : #include <stdint.h> 29 : 30 : enum lfr_reset_cause_t 31 : { 32 : UNKNOWN_CAUSE, 33 : POWER_ON, 34 : TC_RESET, 35 : WATCHDOG, 36 : ERROR_RESET, 37 : UNEXP_RESET 38 : }; 39 : 40 : typedef struct 41 : { 42 : unsigned char dpu_spw_parity; 43 : unsigned char dpu_spw_disconnect; 44 : unsigned char dpu_spw_escape; 45 : unsigned char dpu_spw_credit; 46 : unsigned char dpu_spw_write_sync; 47 : unsigned char timecode_erroneous; 48 : unsigned char timecode_missing; 49 : unsigned char timecode_invalid; 50 : unsigned char time_timecode_it; 51 : unsigned char time_not_synchro; 52 : unsigned char time_timecode_ctr; 53 : unsigned char ahb_correctable; 54 : } hk_lfr_le_t; 55 : 56 : typedef struct 57 : { 58 : unsigned char dpu_spw_early_eop; 59 : unsigned char dpu_spw_invalid_addr; 60 : unsigned char dpu_spw_eep; 61 : unsigned char dpu_spw_rx_too_big; 62 : } hk_lfr_me_t; 63 : 64 : void init_housekeeping_parameters(void); 65 : void increment_seq_counter(unsigned short* packetSequenceControl); 66 : void getTime(unsigned char* time); 67 : unsigned long long int getTimeAsUnsignedLongLongInt(); 68 : 69 : static inline void encode_temperatures(Packet_TM_LFR_HK_t* hk_packet) 70 : { 71 : // SEL1 SEL0 72 : // 0 0 => PCB 73 : // 0 1 => FPGA 74 : // 1 0 => SCM 75 : 76 74 : const unsigned char* const temp_scm_ptr = (unsigned char*)&time_management_regs->temp_scm; 77 74 : const unsigned char* const temp_pcb_ptr = (unsigned char*)&time_management_regs->temp_pcb; 78 74 : const unsigned char* const temp_fpga_ptr = (unsigned char*)&time_management_regs->temp_fpga; 79 : 80 : 81 74 : hk_packet->hk_lfr_temp_scm[0] = temp_scm_ptr[2]; 82 74 : hk_packet->hk_lfr_temp_scm[1] = temp_scm_ptr[3]; 83 74 : hk_packet->hk_lfr_temp_pcb[0] = temp_pcb_ptr[2]; 84 74 : hk_packet->hk_lfr_temp_pcb[1] = temp_pcb_ptr[3]; 85 74 : hk_packet->hk_lfr_temp_fpga[0] = temp_fpga_ptr[2]; 86 74 : hk_packet->hk_lfr_temp_fpga[1] = temp_fpga_ptr[3]; 87 : } 88 : 89 : static inline void encode_f3_E_field( 90 : int16_t V, int16_t E1, int16_t E2, Packet_TM_LFR_HK_t* hk_packet) 91 : { 92 74 : const unsigned char* const _v = (unsigned char*)&V; 93 74 : const unsigned char* const _e1 = (unsigned char*)&E1; 94 74 : const unsigned char* const _e2 = (unsigned char*)&E2; 95 : 96 74 : hk_packet->hk_lfr_sc_v_f3[0] = _v[0]; 97 74 : hk_packet->hk_lfr_sc_v_f3[1] = _v[1]; 98 74 : hk_packet->hk_lfr_sc_e1_f3[0] = _e1[0]; 99 74 : hk_packet->hk_lfr_sc_e1_f3[1] = _e1[1]; 100 74 : hk_packet->hk_lfr_sc_e2_f3[0] = _e2[0]; 101 74 : hk_packet->hk_lfr_sc_e2_f3[1] = _e2[1]; 102 : } 103 : 104 : void encode_cpu_load(Packet_TM_LFR_HK_t* hk_packet); 105 : void set_hk_lfr_sc_potential_flag(bool state); 106 : void set_sy_lfr_pas_filter_enabled(bool state); 107 : void set_sy_lfr_watchdog_enabled(bool state); 108 : void set_hk_lfr_calib_enable(bool state); 109 : void set_hk_lfr_reset_cause(enum lfr_reset_cause_t lfr_reset_cause); 110 : void hk_lfr_le_me_he_update(); 111 : void set_hk_lfr_time_not_synchro(); 112 : void update_hk_lfr_last_er_fields(unsigned int rid, unsigned char code);