##// END OF EJS Templates
timecode handling modified:...
paul -
r248:c648c60c0eef R3a
parent child
Show More
@@ -1,2 +1,2
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
2 ce0c2f17257170a8529605f68687c18f23973087 header/lfr_common_headers
2 084fd0db5e4139a1096789935e32ef498192f395 header/lfr_common_headers
@@ -18,6 +18,8
18
18
19 extern rtems_name Task_name[20]; /* array of task names */
19 extern rtems_name Task_name[20]; /* array of task names */
20 extern rtems_id Task_id[20]; /* array of task ids */
20 extern rtems_id Task_id[20]; /* array of task ids */
21 extern rtems_name timecode_timer_name;
22 extern rtems_id timecode_timer_id;
21 extern unsigned char pa_bia_status_info;
23 extern unsigned char pa_bia_status_info;
22
24
23 // RTEMS TASKS
25 // RTEMS TASKS
@@ -29,6 +31,7 int create_all_tasks( void );
29 int start_all_tasks( void );
31 int start_all_tasks( void );
30 //
32 //
31 rtems_status_code create_message_queues( void );
33 rtems_status_code create_message_queues( void );
34 rtems_status_code create_timecode_timer( void );
32 rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
35 rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
33 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
36 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
34 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
37 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
@@ -15,6 +15,8
15
15
16 extern spw_stats spacewire_stats;
16 extern spw_stats spacewire_stats;
17 extern spw_stats spacewire_stats_backup;
17 extern spw_stats spacewire_stats_backup;
18 extern rtems_name timecode_timer_name;
19 extern rtems_id timecode_timer_id;
18
20
19 // RTEMS TASK
21 // RTEMS TASK
20 rtems_task spiq_task( rtems_task_argument argument );
22 rtems_task spiq_task( rtems_task_argument argument );
@@ -31,6 +33,7 void spacewire_set_NP( unsigned char val
31 void spacewire_set_RE( unsigned char val, unsigned int regAddr ); // RMAP Enable
33 void spacewire_set_RE( unsigned char val, unsigned int regAddr ); // RMAP Enable
32 void spacewire_compute_stats_offsets( void );
34 void spacewire_compute_stats_offsets( void );
33 void spacewire_update_statistics( void );
35 void spacewire_update_statistics( void );
36 void increase_an_unsigned_char_counter( unsigned char *counter );
34
37
35 void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header );
38 void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header );
36 void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header );
39 void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header );
@@ -43,6 +46,9 void spw_send_asm_f1( ring_node *ring_no
43 void spw_send_asm_f2( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_ASM_t *header );
46 void spw_send_asm_f2( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_ASM_t *header );
44 void spw_send_k_dump( ring_node *ring_node_to_send );
47 void spw_send_k_dump( ring_node *ring_node_to_send );
45
48
49 rtems_timer_service_routine timecode_timer_routine( rtems_id timer_id, void *user_data );
50 unsigned int check_timecode_and_previous_timecode_coherency(unsigned char currentTimecodeCtr);
51 unsigned int check_timecode_and_internal_time_coherency(unsigned char timecode, unsigned char internalTime);
46 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc );
52 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc );
47
53
48 void (*grspw_timecode_callback) ( void *pDev, void *regs, int minor, unsigned int tc );
54 void (*grspw_timecode_callback) ( void *pDev, void *regs, int minor, unsigned int tc );
@@ -26,6 +26,8
26 rtems_name misc_name[5];
26 rtems_name misc_name[5];
27 rtems_name Task_name[20]; /* array of task names */
27 rtems_name Task_name[20]; /* array of task names */
28 rtems_id Task_id[20]; /* array of task ids */
28 rtems_id Task_id[20]; /* array of task ids */
29 rtems_name timecode_timer_name;
30 rtems_id timecode_timer_id;
29 int fdSPW = 0;
31 int fdSPW = 0;
30 int fdUART = 0;
32 int fdUART = 0;
31 unsigned char lfrCurrentMode;
33 unsigned char lfrCurrentMode;
@@ -35,7 +35,7
35 #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
35 #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
36 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 #define CONFIGURE_MAXIMUM_DRIVERS 16
37 #define CONFIGURE_MAXIMUM_PERIODS 5
37 #define CONFIGURE_MAXIMUM_PERIODS 5
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // [spiq] [wtdg] [spacewire_reset_link]
39 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
39 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
40 #ifdef PRINT_STACK_REPORT
40 #ifdef PRINT_STACK_REPORT
41 #define CONFIGURE_STACK_CHECKER_ENABLED
41 #define CONFIGURE_STACK_CHECKER_ENABLED
@@ -160,6 +160,12 rtems_task Init( rtems_task_argument ign
160
160
161 create_names(); // create all names
161 create_names(); // create all names
162
162
163 status = create_timecode_timer(); // create the timer used by timecode_irq_handler
164 if (status != RTEMS_SUCCESSFUL)
165 {
166 PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status)
167 }
168
163 status = create_message_queues(); // create message queues
169 status = create_message_queues(); // create message queues
164 if (status != RTEMS_SUCCESSFUL)
170 if (status != RTEMS_SUCCESSFUL)
165 {
171 {
@@ -317,6 +323,8 void create_names( void ) // create all
317 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
323 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
318 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
324 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
319 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
325 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
326
327 timecode_timer_name = rtems_build_name( 'S', 'P', 'T', 'C' );
320 }
328 }
321
329
322 int create_all_tasks( void ) // create all tasks which run in the software
330 int create_all_tasks( void ) // create all tasks which run in the software
@@ -750,6 +758,24 rtems_status_code create_message_queues(
750 return ret;
758 return ret;
751 }
759 }
752
760
761 rtems_status_code create_timecode_timer( void )
762 {
763 rtems_status_code status;
764
765 status = rtems_timer_create( timecode_timer_name, &timecode_timer_id );
766
767 if ( status != RTEMS_SUCCESSFUL )
768 {
769 PRINTF1("in create_timer_timecode *** ERR creating SPTC timer, %d\n", status)
770 }
771 else
772 {
773 PRINTF("in create_timer_timecode *** OK creating SPTC timer\n")
774 }
775
776 return status;
777 }
778
753 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
779 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
754 {
780 {
755 rtems_status_code status;
781 rtems_status_code status;
@@ -342,7 +342,7 rtems_task dumb_task( rtems_task_argumen
342 unsigned int fine_time = 0;
342 unsigned int fine_time = 0;
343 rtems_event_set event_out;
343 rtems_event_set event_out;
344
344
345 char *DumbMessages[13] = {"in DUMB *** default", // RTEMS_EVENT_0
345 char *DumbMessages[14] = {"in DUMB *** default", // RTEMS_EVENT_0
346 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
346 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
347 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
347 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
348 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
348 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
@@ -354,7 +354,8 rtems_task dumb_task( rtems_task_argumen
354 "tick", // RTEMS_EVENT_9
354 "tick", // RTEMS_EVENT_9
355 "VHDL ERR *** waveform picker", // RTEMS_EVENT_10
355 "VHDL ERR *** waveform picker", // RTEMS_EVENT_10
356 "VHDL ERR *** unexpected ready matrix values", // RTEMS_EVENT_11
356 "VHDL ERR *** unexpected ready matrix values", // RTEMS_EVENT_11
357 "WATCHDOG timer" // RTEMS_EVENT_12
357 "WATCHDOG timer", // RTEMS_EVENT_12
358 "TIMECODE timer" // RTEMS_EVENT_13
358 };
359 };
359
360
360 BOOT_PRINTF("in DUMB *** \n")
361 BOOT_PRINTF("in DUMB *** \n")
@@ -362,7 +363,7 rtems_task dumb_task( rtems_task_argumen
362 while(1){
363 while(1){
363 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
364 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
364 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
365 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
365 | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12,
366 | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12 | RTEMS_EVENT_13,
366 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
367 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
367 intEventOut = (unsigned int) event_out;
368 intEventOut = (unsigned int) event_out;
368 for ( i=0; i<32; i++)
369 for ( i=0; i<32; i++)
@@ -375,6 +376,10 rtems_task dumb_task( rtems_task_argumen
375 {
376 {
376 PRINTF1("%s\n", DumbMessages[12])
377 PRINTF1("%s\n", DumbMessages[12])
377 }
378 }
379 if (i==13)
380 {
381 PRINTF1("%s\n", DumbMessages[13])
382 }
378 }
383 }
379 }
384 }
380 }
385 }
@@ -22,6 +22,9 Header_TM_LFR_SCIENCE_CWF_t headerCWF;
22 Header_TM_LFR_SCIENCE_SWF_t headerSWF;
22 Header_TM_LFR_SCIENCE_SWF_t headerSWF;
23 Header_TM_LFR_SCIENCE_ASM_t headerASM;
23 Header_TM_LFR_SCIENCE_ASM_t headerASM;
24
24
25 unsigned char previousTimecodeCtr = 0;
26 unsigned int *grspwPtr = (unsigned int *) (REGS_ADDR_GRSPW + APB_OFFSET_GRSPW_TIME_REGISTER);
27
25 //***********
28 //***********
26 // RTEMS TASK
29 // RTEMS TASK
27 rtems_task spiq_task(rtems_task_argument unused)
30 rtems_task spiq_task(rtems_task_argument unused)
@@ -658,41 +661,146 void spacewire_update_statistics( void )
658 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
661 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
659 }
662 }
660
663
661 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
664 void increase_unsigned_char_counter( unsigned char *counter )
662 {
665 {
663 // a valid timecode has been received, write it in the HK report
666 // update the number of valid timecodes that have been received
664 unsigned int *grspwPtr;
667 if (*counter == 255)
665 unsigned char timecodeCtr;
668 {
666 unsigned char updateTimeCtr;
669 *counter = 0;
670 }
671 else
672 {
673 *counter = *counter + 1;
674 }
675 }
667
676
668 grspwPtr = (unsigned int *) (REGS_ADDR_GRSPW + APB_OFFSET_GRSPW_TIME_REGISTER);
677 rtems_timer_service_routine timecode_timer_routine( rtems_id timer_id, void *user_data )
678 {
679
680 unsigned char currentTimecodeCtr;
681
682 currentTimecodeCtr = (unsigned char) (grspwPtr[0] & TIMECODE_MASK);
669
683
670 housekeeping_packet.hk_lfr_dpu_spw_last_timc = (unsigned char) (grspwPtr[0] & 0xff); // [1111 1111]
684 if (currentTimecodeCtr == previousTimecodeCtr)
671 timecodeCtr = (unsigned char) (grspwPtr[0] & 0x3f); // [0011 1111]
685 {
672 updateTimeCtr = time_management_regs->coarse_time_load & 0x3f; // [0011 1111]
686 //************************
687 // HK_LFR_TIMECODE_MISSING
688 // the timecode value has not changed, no valid timecode has been received, the timecode is MISSING
689 increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_timecode_missing );
690 }
691 else if (currentTimecodeCtr == (previousTimecodeCtr+1))
692 {
693 // the timecode value has changed and the value is valid, this is unexpected because
694 // the timer should not have fired, the timecode_irq_handler should have been raised
695 }
696 else
697 {
698 //************************
699 // HK_LFR_TIMECODE_INVALID
700 // the timecode value has changed and the value is not valid, no tickout has been generated
701 // this is why the timer has fired
702 increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_timecode_invalid );
703 }
673
704
674 // update the number of valid timecodes that have been received
705 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_13 );
675 if (housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt == 255)
706 }
707
708 unsigned int check_timecode_and_previous_timecode_coherency(unsigned char currentTimecodeCtr)
709 {
710 unsigned char ret;
711
712 ret = LFR_DEFAULT;
713
714 if (currentTimecodeCtr == 0)
676 {
715 {
677 housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = 0;
716 if (previousTimecodeCtr == 63)
717 {
718 ret = LFR_SUCCESSFUL;
719 }
720 else
721 {
722 ret = LFR_DEFAULT;
723 }
678 }
724 }
679 else
725 else
680 {
726 {
681 housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt + 1;
727 if (currentTimecodeCtr == (previousTimecodeCtr +1))
682 }
683
684 // check the value of the timecode with respect to the last TC_LFR_UPDATE_TIME => SSS-CP-FS-370
685 if (timecodeCtr != updateTimeCtr)
686 {
687 if (housekeeping_packet.hk_lfr_time_timecode_ctr == 255)
688 {
728 {
689 housekeeping_packet.hk_lfr_time_timecode_ctr = 0;
729 ret = LFR_SUCCESSFUL;
690 }
730 }
691 else
731 else
692 {
732 {
693 housekeeping_packet.hk_lfr_time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr + 1;
733 ret = LFR_DEFAULT;
694 }
734 }
695 }
735 }
736
737 return ret;
738 }
739
740 unsigned int check_timecode_and_internal_time_coherency(unsigned char timecode, unsigned char internalTime)
741 {
742 unsigned int ret;
743
744 ret = LFR_DEFAULT;
745
746 if (timecode == internalTime)
747 {
748 ret = LFR_SUCCESSFUL;
749 }
750 else
751 {
752 ret = LFR_DEFAULT;
753 }
754
755 return ret;
756 }
757
758 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
759 {
760 // a tickout has been emitted, perform actions on the incoming timecode
761
762 unsigned char incomingTimecode;
763 unsigned char updateTime;
764 unsigned char internalTime;
765 rtems_status_code status;
766
767 incomingTimecode = (unsigned char) (grspwPtr[0] & TIMECODE_MASK);
768 updateTime = time_management_regs->coarse_time_load & TIMECODE_MASK;
769 internalTime = time_management_regs->coarse_time & TIMECODE_MASK;
770
771 housekeeping_packet.hk_lfr_dpu_spw_last_timc = incomingTimecode;
772
773 // update the number of tickout that have been generated
774 increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt );
775
776 //**************************
777 // HK_LFR_TIMECODE_ERRONEOUS
778 // MISSING and INVALID are handled by the timecode_timer_routine service routine
779 if (check_timecode_and_previous_timecode_coherency( incomingTimecode ) == LFR_DEFAULT)
780 {
781 // this is unexpected but a tickout has been raised and the timecode is erroneous
782 increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_timecode_erroneous );
783 }
784
785 //************************
786 // HK_LFR_TIME_TIMECODE_IT
787 // check the coherency between the SpaceWire timecode and the Internal Time
788 if (check_timecode_and_internal_time_coherency( incomingTimecode, internalTime ) == LFR_DEFAULT)
789 {
790 increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_time_timecode_it );
791 }
792
793 //********************
794 // HK_LFR_TIMECODE_CTR
795 // check the value of the timecode with respect to the last TC_LFR_UPDATE_TIME => SSS-CP-FS-370
796 if (incomingTimecode != updateTime)
797 {
798 increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_time_timecode_ctr );
799 }
800
801 // launch the timecode timer to detect missing or invalid timecodes
802 previousTimecodeCtr = incomingTimecode; // update the previousTimecodeCtr value
803 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT, timecode_timer_routine, NULL );
696 }
804 }
697
805
698 void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header )
806 void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header )
General Comments 0
You need to be logged in to leave comments. Login now