//************************* // GPL reminder to be added //************************* #include /* configuration information */ #define CONFIGURE_INIT #include /* for device driver prototypes */ /* configuration information */ #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER #define CONFIGURE_MAXIMUM_TASKS 20 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) #define CONFIGURE_MAXIMUM_DRIVERS 16 #define CONFIGURE_MAXIMUM_PERIODS 5 #define CONFIGURE_MAXIMUM_TIMERS 5 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2 #ifdef PRINT_STACK_REPORT #define CONFIGURE_STACK_CHECKER_ENABLED #endif #include /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ #ifdef RTEMS_DRVMGR_STARTUP #ifdef LEON3 /* Add Timer and UART Driver */ #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER #endif #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART #endif #endif #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ #include #endif #include #include rtems_task Init( rtems_task_argument ignored ) { rtems_status_code status; rtems_isr_entry old_isr_handler; PRINTF("\n\n\n\n\n") PRINTF("***************************\n") PRINTF("** START Flight Software **\n") PRINTF("***************************\n") PRINTF("\n\n") //send_console_outputs_on_apbuart_port(); set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); initLookUpTableForCRC(); // in tc_handler.h init_parameter_dump(); init_local_mode_parameters(); init_housekeeping_parameters(); create_names(); // create all names create_message_queues(); create_all_tasks(); // create all tasks start_all_tasks(); // start all tasks stop_current_mode(); // go in STANDBY mode grspw_timecode_callback = &timecode_irq_handler; spacewire_configure_link(); #ifdef GSA // mask IRQ lines LEON_Mask_interrupt( IRQ_SM ); LEON_Mask_interrupt( IRQ_WF ); // Spectral Matrices simulator configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, IRQ_SPARC_SM, spectral_matrices_isr ); // WaveForms configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR, IRQ_SPARC_WF, waveforms_simulator_isr ); #else // mask IRQ lines LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // reset configuration registers reset_waveform_picker_regs(); reset_spectral_matrix_regs(); // configure IRQ handling for the waveform picker unit status = rtems_interrupt_catch( waveforms_isr, IRQ_SPARC_WAVEFORM_PICKER, &old_isr_handler) ; // configure IRQ handling for the spectral matrix unit // status = rtems_interrupt_catch( spectral_matrices_isr, // IRQ_SPARC_SPECTRAL_MATRIX, // &old_isr_handler) ; // Spectral Matrices simulator configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, IRQ_SPARC_SM, spectral_matrices_isr_simu ); #endif PRINTF("delete INIT\n") status = rtems_task_delete(RTEMS_SELF); } void init_parameter_dump( void ) { parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; parameter_dump_packet.reserved = CCSDS_RESERVED; parameter_dump_packet.userApplication = CCSDS_USER_APP; parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8); parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP; parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; // DATA FIELD HEADER parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); parameter_dump_packet.sid = SID_PARAMETER_DUMP; //****************** // COMMON PARAMETERS parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0; parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1; //****************** // NORMAL PARAMETERS parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_L >> 8); parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_L ); parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_P >> 8); parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_P ); parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DEFAULT_SY_LFR_N_ASM_P >> 8); parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DEFAULT_SY_LFR_N_ASM_P ); parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DEFAULT_SY_LFR_N_BP_P0; parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DEFAULT_SY_LFR_N_BP_P1; //***************** // BURST PARAMETERS parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; //**************** // SBM1 PARAMETERS parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; //**************** // SBM2 PARAMETERS parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; } void init_local_mode_parameters( void ) { // LOCAL PARAMETERS set_local_sbm1_nb_cwf_max(); set_local_sbm2_nb_cwf_max(); set_local_nb_interrupt_f0_MAX(); PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) reset_local_sbm1_nb_cwf_sent(); reset_local_sbm2_nb_cwf_sent(); } void init_housekeeping_parameters( void ) { unsigned int i = 0; unsigned int j = 0; unsigned int k = 0; char *parameters; parameters = (char*) &housekeeping_packet.lfr_status_word; for(i = 0; i< SIZE_HK_PARAMETERS; i++) { parameters[i] = 0x00; } // init status word housekeeping_packet.lfr_status_word[0] = 0x00; housekeeping_packet.lfr_status_word[1] = 0x00; // init software version housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3; housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4; // init sequence counters for (i = 0; i