##// END OF EJS Templates
SID corrected in TM_LFR_TC_EXE packets...
SID corrected in TM_LFR_TC_EXE packets fsw ready to test the spectral matrix unit tests performed on the Virtex 5 board

File last commit:

r31:bd675edcd40d default
r31:bd675edcd40d default
Show More
fsw_misc.c
241 lines | 10.2 KiB | text/x-c | CLexer
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5 #include <fsw_misc.h>
#include <fsw_params.h>
extern rtems_id Task_id[]; /* array of task ids */
extern int fdSPW;
paul@pc-solar1.lab-lpp.local
fsw-0-2 delivery to LESIA...
r16 extern TMHeader_t housekeeping_header;
extern char housekeeping_data[];
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17 extern Packet_TM_LFR_HK_t housekeeping_packet;
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5
int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
unsigned char interrupt_level, rtems_isr (*timer_isr)() )
{ // configure the timer for the waveforms simulation
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21 rtems_status_code status;
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5 rtems_isr_entry old_isr_handler;
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
paul
SID corrected in TM_LFR_TC_EXE packets...
r31 if (status==RTEMS_SUCCESSFUL)
{
PRINTF("In configure_timer *** rtems_interrupt_catch successfullly configured\n")
}
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5
paul
SID corrected in TM_LFR_TC_EXE packets...
r31 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
return 1;
}
int timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
{
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
return 1;
}
paul
SID corrected in TM_LFR_TC_EXE packets...
r31 int timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
{
gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
return 1;
}
int timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
{
gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
return 1;
}
paul@pc-solar1.lab-lpp.local
All modes implemented for the waveforms...
r23 void update_spacewire_statistics()
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21 {
paul@pc-solar1.lab-lpp.local
All modes implemented for the waveforms...
r23 rtems_status_code status;
spw_stats spacewire_stats_grspw;
status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
spacewire_stats.packets_received = spacewire_stats_backup.packets_received
+ spacewire_stats_grspw.packets_received;
spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
+ spacewire_stats_grspw.packets_sent;
spacewire_stats.parity_err = spacewire_stats_backup.parity_err
+ spacewire_stats_grspw.parity_err;
spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
+ spacewire_stats_grspw.disconnect_err;
spacewire_stats.escape_err = spacewire_stats_backup.escape_err
+ spacewire_stats_grspw.escape_err;
spacewire_stats.credit_err = spacewire_stats_backup.credit_err
+ spacewire_stats_grspw.credit_err;
spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
+ spacewire_stats_grspw.write_sync_err;
spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
+ spacewire_stats_grspw.rx_rmap_header_crc_err;
spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
+ spacewire_stats_grspw.rx_rmap_data_crc_err;
spacewire_stats.early_ep = spacewire_stats_backup.early_ep
+ spacewire_stats_grspw.early_ep;
spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
+ spacewire_stats_grspw.invalid_address;
spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
+ spacewire_stats_grspw.rx_eep_err;
spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
+ spacewire_stats_grspw.rx_truncated;
//spacewire_stats.tx_link_err;
//****************************
// DPU_SPACEWIRE_IF_STATISTICS
housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
//housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
//housekeeping_packet.hk_lfr_dpu_spw_last_timc;
//******************************************
// ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
// housekeeping_packet.hk_lfr_dpu_spw_rx_ahb;
// housekeeping_packet.hk_lfr_dpu_spw_tx_ahb;
housekeeping_packet.hk_lfr_dpu_spw_header_crc = (unsigned char) spacewire_stats.rx_rmap_header_crc_err;
housekeeping_packet.hk_lfr_dpu_spw_data_crc = (unsigned char) spacewire_stats.rx_rmap_data_crc_err;
//*********************************************
// ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5 }
paul@pc-solar1.lab-lpp.local
commit before release
r25 int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5 {
paul@pc-solar1.lab-lpp.local
Updates of the ICD taken into account...
r18 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21
apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB;
PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5
return 0;
}
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17 int set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
{
paul@pc-solar1.lab-lpp.local
Updates of the ICD taken into account...
r18 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21
apbuart_regs->scaler = value;
paul@pc-solar1.lab-lpp.local
commit before release
r25 PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17
return 0;
}
//************
// RTEMS TASKS
paul@pc-solar1.lab-lpp.local
Message queue implemented for valid TC processing...
r9 rtems_task stat_task(rtems_task_argument argument)
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21 {
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17 int i;
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21 int j;
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17 i = 0;
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21 j = 0;
PRINTF("in STAT *** \n")
while(1){
rtems_task_wake_after(1000);
PRINTF1("%d\n", j)
paul@pc-solar1.lab-lpp.local
Minor updates to use the time management VHDL module
r12 if (i == 2) {
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21 #ifdef PRINT_TASK_STATISTICS
rtems_cpu_usage_report();
paul@pc-solar1.lab-lpp.local
Minor updates to use the time management VHDL module
r12 rtems_cpu_usage_reset();
#endif
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21 i = 0;
}
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17 else i++;
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21 j++;
}
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5 }
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21
rtems_task hous_task(rtems_task_argument argument)
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17 {
paul@pc-solar1.lab-lpp.local
Updates of the ICD taken into account...
r18 int result;
rtems_status_code status;
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17 PRINTF("in HOUS ***\n")
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21 if (rtems_rate_monotonic_ident( HK_name, &HK_id) != RTEMS_SUCCESSFUL) {
status = rtems_rate_monotonic_create( HK_name, &HK_id );
paul@pc-solar1.lab-lpp.local
Updates of the ICD taken into account...
r18 if( status != RTEMS_SUCCESSFUL ) {
PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
}
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17 }
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
paul@pc-solar1.lab-lpp.local
All modes implemented for the waveforms...
r23 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21 housekeeping_packet.reserved = 0x00;
housekeeping_packet.userApplication = 0x00;
paul@pc-solar1.lab-lpp.local
All modes implemented for the waveforms...
r23 housekeeping_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8);
housekeeping_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK);
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17 housekeeping_packet.packetSequenceControl[0] = 0xc0;
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21 housekeeping_packet.packetSequenceControl[1] = 0x00;
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17 housekeeping_packet.packetLength[0] = 0x00;
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21 housekeeping_packet.packetLength[1] = 0x77;
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17 housekeeping_packet.dataFieldHeader[0] = 0x10;
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21 housekeeping_packet.dataFieldHeader[1] = TM_TYPE_HK;
housekeeping_packet.dataFieldHeader[2] = TM_SUBTYPE_HK;
paul@pc-solar1.lab-lpp.local
All modes implemented for the waveforms...
r23 housekeeping_packet.dataFieldHeader[3] = TM_DESTINATION_ID_GROUND;
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17
status = rtems_rate_monotonic_cancel(HK_id);
paul@pc-solar1.lab-lpp.local
All modes implemented for the waveforms...
r23 if( status != RTEMS_SUCCESSFUL ) {
PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
}
else {
PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
}
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17 while(1){ // launch the rate monotonic task
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
paul@pc-solar1.lab-lpp.local
All modes implemented for the waveforms...
r23 if ( status != RTEMS_SUCCESSFUL ) {
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_period *** code %d\n", status);
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17 }
paul@pc-solar1.lab-lpp.local
All modes implemented for the waveforms...
r23 else {
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17 housekeeping_packet.dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24);
housekeeping_packet.dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16);
housekeeping_packet.dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8);
housekeeping_packet.dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time);
housekeeping_packet.dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
housekeeping_packet.dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
paul@pc-solar1.lab-lpp.local
All modes implemented for the waveforms...
r23 housekeeping_packet.sid = SID_HK;
update_spacewire_statistics();
paul
SID corrected in TM_LFR_TC_EXE packets...
r31 // SEND PACKET
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17 result = write ( fdSPW, &housekeeping_packet, LEN_TM_LFR_HK);
paul
SID corrected in TM_LFR_TC_EXE packets...
r31 if (status == -1) {
while (true) {
if (status != RTEMS_SUCCESSFUL) {
result = write ( fdSPW, &housekeeping_packet, LEN_TM_LFR_HK);
PRINTF("x")
sched_yield();
}
else {
PRINTF("\n")
break;
}
}
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17 }
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21 }
}
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5
paul@pc-solar1.lab-lpp.local
automatic reconnexion of the spacewire link...
r17 PRINTF("in HOUS *** deleting task\n")
paul@pc-solar1.lab-lpp.local
Current version with modes NORMAL and SBM1 operational
r21
status = rtems_task_delete( RTEMS_SELF ); // should not return
printf( "rtems_task_delete returned with status of %d.\n", status );
exit( 1 );
paul@pc-solar1.lab-lpp.local
fsw-0-2 delivery to LESIA...
r16 }