wf_handler.h
116 lines
| 3.8 KiB
| text/x-c
|
CLexer
/ header / wf_handler.h
paul@pc-solar1.lab-lpp.local
|
r5 | #ifndef WF_HANDLER_H_INCLUDED | ||
#define WF_HANDLER_H_INCLUDED | ||||
paul
|
r45 | #include <rtems.h> | ||
#include <grspw.h> | ||||
#include <stdio.h> | ||||
#include <math.h> | ||||
paul
|
r175 | #include <fsw_params.h> | ||
paul
|
r33 | |||
paul
|
r197 | #include "fsw_init.h" | ||
paul
|
r131 | #include "fsw_params_wf_handler.h" | ||
paul@pc-solar1.lab-lpp.local
|
r18 | |||
paul
|
r187 | #define pi 3.14159265359 | ||
paul
|
r318 | #define T0_IN_FINETIME ( 65536. / 24576. ) | ||
#define T1_IN_FINETIME ( 65536. / 4096. ) | ||||
#define T2_IN_FINETIME ( 65536. / 256. ) | ||||
#define T3_IN_FINETIME ( 65536. / 16. ) | ||||
#define TICKS_PER_T1 16 | ||||
#define TICKS_PER_T2 256 | ||||
#define TICKS_PER_S 65536. | ||||
#define MS_PER_S 1000. | ||||
#define FREQ_F0 24576. | ||||
#define FREQ_F1 4096. | ||||
#define FREQ_F2 256. | ||||
#define FREQ_F3 16. | ||||
#define DELTAT_F0 2731 // (2048. / 24576. / 2.) * 65536. = 2730.667; | ||||
#define DELTAT_F1 16384 // (2048. / 4096. / 2.) * 65536. = 16384; | ||||
#define DELTAT_F2 262144 // (2048. / 256. / 2.) * 65536. = 262144; | ||||
#define OFFSET_2_BYTES 2 | ||||
#define ONE_TICK_CORR_INTERVAL_0_MIN 0.5 | ||||
#define ONE_TICK_CORR_INTERVAL_0_MAX 1.0 | ||||
#define ONE_TICK_CORR_INTERVAL_1_MIN -1.0 | ||||
#define ONE_TICK_CORR_INTERVAL_1_MAX -0.5 | ||||
#define ONE_TICK_CORR 1 | ||||
#define CORR_MULT 2 | ||||
paul@pc-solar1.lab-lpp.local
|
r5 | |||
extern int fdSPW; | ||||
paul
|
r87 | |||
//***************** | ||||
// waveform buffers | ||||
paul
|
r172 | extern volatile int wf_buffer_f0[ ]; | ||
extern volatile int wf_buffer_f1[ ]; | ||||
extern volatile int wf_buffer_f2[ ]; | ||||
extern volatile int wf_buffer_f3[ ]; | ||||
paul
|
r87 | |||
paul
|
r170 | extern waveform_picker_regs_0_1_18_t *waveform_picker_regs; | ||
paul
|
r45 | extern time_management_regs_t *time_management_regs; | ||
extern Packet_TM_LFR_HK_t housekeeping_packet; | ||||
extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; | ||||
extern struct param_local_str param_local; | ||||
paul
|
r56 | extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST; | ||
extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; | ||||
paul
|
r318 | extern rtems_id Task_id[]; /* array of task ids */ | ||
paul
|
r46 | |||
paul
|
r45 | extern unsigned char lfrCurrentMode; | ||
paul@pc-solar1.lab-lpp.local
|
r5 | |||
paul
|
r105 | //********** | ||
// RTEMS_ISR | ||||
paul
|
r106 | void reset_extractSWF( void ); | ||
paul@pc-solar1.lab-lpp.local
|
r5 | rtems_isr waveforms_isr( rtems_vector_number vector ); | ||
paul
|
r105 | |||
//*********** | ||||
// RTEMS_TASK | ||||
paul
|
r38 | rtems_task wfrm_task( rtems_task_argument argument ); | ||
rtems_task cwf3_task( rtems_task_argument argument ); | ||||
rtems_task cwf2_task( rtems_task_argument argument ); | ||||
rtems_task cwf1_task( rtems_task_argument argument ); | ||||
paul
|
r105 | rtems_task swbd_task( rtems_task_argument argument ); | ||
paul@pc-solar1.lab-lpp.local
|
r5 | |||
paul@pc-solar1.lab-lpp.local
|
r17 | //****************** | ||
// general functions | ||||
paul
|
r139 | void WFP_init_rings( void ); | ||
paul
|
r172 | void init_ring( ring_node ring[], unsigned char nbNodes, volatile int buffer[] , unsigned int bufferSize ); | ||
paul
|
r139 | void WFP_reset_current_ring_nodes( void ); | ||
paul
|
r33 | // | ||
paul
|
r92 | int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF ); | ||
paul
|
r33 | // | ||
paul
|
r172 | int send_waveform_CWF3_light(ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id ); | ||
paul
|
r45 | // | ||
paul
|
r98 | void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime, | ||
unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime ); | ||||
paul
|
r238 | void build_snapshot_from_ring(ring_node *ring_node_to_send, unsigned char frequencyChannel , | ||
unsigned long long acquisitionTimeF0_asLong, ring_node *ring_node_swf_extracted, int *swf_extracted); | ||||
paul
|
r257 | double computeCorrection( unsigned char *timePtr ); | ||
void applyCorrection( double correction ); | ||||
paul
|
r168 | void snapshot_resynchronization( unsigned char *timePtr ); | ||
paul
|
r93 | // | ||
paul
|
r45 | rtems_id get_pkts_queue_id( void ); | ||
paul@pc-solar1.lab-lpp.local
|
r23 | |||
//************** | ||||
// wfp registers | ||||
paul
|
r97 | // RESET | ||
void reset_wfp_burst_enable( void ); | ||||
paul
|
r171 | void reset_wfp_status( void ); | ||
void reset_wfp_buffer_addresses( void ); | ||||
paul
|
r97 | void reset_waveform_picker_regs( void ); | ||
// SET | ||||
void set_wfp_data_shaping(void); | ||||
paul
|
r90 | void set_wfp_burst_enable_register( unsigned char mode ); | ||
paul
|
r97 | void set_wfp_delta_snapshot( void ); | ||
void set_wfp_delta_f0_f0_2( void ); | ||||
void set_wfp_delta_f1( void ); | ||||
void set_wfp_delta_f2( void ); | ||||
paul
|
r32 | |||
//***************** | ||||
// local parameters | ||||
paul
|
r56 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ); | ||
paul@pc-solar1.lab-lpp.local
|
r5 | #endif // WF_HANDLER_H_INCLUDED | ||