##// END OF EJS Templates
Message queue implemented for valid TC processing...
Message queue implemented for valid TC processing Default action coded

File last commit:

r9:515486994c1d default
r9:515486994c1d default
Show More
fsw_init.c
255 lines | 9.2 KiB | text/x-c | CLexer
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5 //*************************
// GPL reminder to be added
//*************************
#include <rtems.h>
/* configuration information */
#define CONFIGURE_INIT
#include <bsp.h> /* for device driver prototypes */
/* configuration information */
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 10
#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 100
#define CONFIGURE_MAXIMUM_DRIVERS 16
#define CONFIGURE_MAXIMUM_PERIODS 1
paul@pc-solar1.lab-lpp.local
Message queue implemented for valid TC processing...
r9 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5
#include <rtems/confdefs.h>
/* 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 <drvmgr/drvmgr_confdefs.h>
#endif
#include <fsw_init.h>
paul@pc-solar1.lab-lpp.local
Message queue implemented for valid TC processing...
r9 #include <fsw_config.c>
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5
char *link_status(int status);
char *lstates[6] = {"Error-reset",
"Error-wait",
"Ready",
"Started",
"Connecting",
"Run"
};
rtems_task Init( rtems_task_argument ignored )
{
rtems_status_code status;
//send_console_outputs_on_serial_port();
InitLookUpTableForCRC(); // in tc_handler.h
admin@pc-p-leroy3.LAB-LPP.LOCAL
Beginning of the message queue implementation for the actions handler
r8
create_message_queue();
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5 create_all_tasks();
start_all_tasks();
configure_spw_link();
// configure timer for spectral matrices simulation
configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
IRQ_SPARC_SM, spectral_matrices_isr );
// configure timer for waveforms simulation
configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
IRQ_SPARC_WF, waveforms_isr );
LEON_Unmask_interrupt( IRQ_SM );
LEON_Unmask_interrupt( IRQ_WF );
status = rtems_task_delete(RTEMS_SELF);
}
paul@pc-solar1.lab-lpp.local
Message queue implemented for valid TC processing...
r9 rtems_task spiq_task(rtems_task_argument unused)
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5 {
rtems_event_set event_out;
struct grspw_regs_str *grspw_regs;
grspw_regs = (struct grspw_regs_str *) REGS_ADDR_GRSPW;
while(1){
PRINTF("In SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
if (rtems_task_suspend(Task_id[1])!=RTEMS_SUCCESSFUL) // suspend RECV task
PRINTF("In SPIQ *** Error suspending RECV Task\n")
configure_spw_link();
if (rtems_task_restart(Task_id[1], 1)!=RTEMS_SUCCESSFUL) // restart RECV task
PRINTF("In SPIQ *** Error resume RECV Task\n")
}
}
int create_all_tasks()
{
rtems_status_code status;
paul@pc-solar1.lab-lpp.local
Message queue implemented for valid TC processing...
r9 Task_name[1] = rtems_build_name( 'R', 'E', 'C', 'V' );
Task_name[2] = rtems_build_name( 'A', 'C', 'T', 'N' );
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5 Task_name[3] = rtems_build_name( 'S', 'P', 'I', 'Q' );
Task_name[4] = rtems_build_name( 'S', 'M', 'I', 'Q' );
Task_name[5] = rtems_build_name( 'S', 'T', 'A', 'T' );
Task_name[6] = rtems_build_name( 'A', 'V', 'F', '0' );
Task_name[7] = rtems_build_name( 'B', 'P', 'F', '0' );
Task_name[8] = rtems_build_name( 'W', 'F', 'R', 'M' );
// RECV
status = rtems_task_create(
Task_name[1], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
RTEMS_DEFAULT_MODES,
RTEMS_DEFAULT_ATTRIBUTES, &Task_id[1]
paul@pc-solar1.lab-lpp.local
Message queue implemented for valid TC processing...
r9 );
// ACTN
status = rtems_task_create(
Task_name[2], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
RTEMS_DEFAULT_MODES,
RTEMS_DEFAULT_ATTRIBUTES, &Task_id[2]
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5 );
// SPIQ
status = rtems_task_create(
Task_name[3], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
RTEMS_DEFAULT_MODES,
RTEMS_DEFAULT_ATTRIBUTES, &Task_id[3]
);
// SMIQ
status = rtems_task_create(
Task_name[4], 10, RTEMS_MINIMUM_STACK_SIZE * 2,
RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
RTEMS_DEFAULT_ATTRIBUTES, &Task_id[4]
);
// STAT
status = rtems_task_create(
Task_name[5], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
RTEMS_DEFAULT_MODES,
RTEMS_DEFAULT_ATTRIBUTES, &Task_id[5]
);
// AVF0
status = rtems_task_create(
Task_name[6], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[6]
);
// BPF0
status = rtems_task_create(
Task_name[7], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
RTEMS_DEFAULT_MODES,
RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[7]
);
// WFRM
status = rtems_task_create(
Task_name[8], 100, RTEMS_MINIMUM_STACK_SIZE * 2,
RTEMS_DEFAULT_MODES,
RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[8]
);
return 0;
}
int start_all_tasks()
{
rtems_status_code status;
paul@pc-solar1.lab-lpp.local
Message queue implemented for valid TC processing...
r9 status = rtems_task_start( Task_id[3], spiq_task, 1 );
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_SPIQ\n")
paul@pc-solar1.lab-lpp.local
Message queue implemented for valid TC processing...
r9 status = rtems_task_start( Task_id[1], recv_task, 1 );
if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_RECV\n")
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5
paul@pc-solar1.lab-lpp.local
Message queue implemented for valid TC processing...
r9 status = rtems_task_start( Task_id[2], actn_task, 1 );
if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_ACTN\n")
status = rtems_task_start( Task_id[4], smiq_task, 1 );
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPPR\n")
paul@pc-solar1.lab-lpp.local
Message queue implemented for valid TC processing...
r9 status = rtems_task_start( Task_id[5], stat_task, 1 );
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_STAT\n")
paul@pc-solar1.lab-lpp.local
Message queue implemented for valid TC processing...
r9 status = rtems_task_start( Task_id[6], avf0_task, 1 );
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_AVF0\n")
paul@pc-solar1.lab-lpp.local
Message queue implemented for valid TC processing...
r9 status = rtems_task_start( Task_id[7], bpf0_task, 1 );
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPF0\n")
paul@pc-solar1.lab-lpp.local
Message queue implemented for valid TC processing...
r9 status = rtems_task_start( Task_id[8], wfrm_task, 1 );
paul@pc-solar1.lab-lpp.local
Naming convention changed...
r5 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_WFRM\n")
return 0;
}
int configure_spw_link()
{
rtems_status_code status;
close(fdSPW); // close the device if it is already open
fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){
PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" not started, retry\n")
close(fdSPW); // close the device
fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
rtems_task_wake_after(100);
}
PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n")
// sets a few parameters of the link
status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RMAPEN, 1); // sets the RMAP enable bit
if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RMAPEN\n")
//
status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
//
status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[3]); // sets the task ID to which an event is sent when a
if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
//
status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts
if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
//
status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // sets the link-error interrupt bit
if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
//
//status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DESTKEY, CCSDS_DESTINATION_ID); // sets the destination key
//if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
//
PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n")
return RTEMS_SUCCESSFUL;
}
char *link_status(int status){
return lstates[status];
}
rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send)
{
rtems_status_code status;
status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
if (status!=RTEMS_SUCCESSFUL) printf("In write_spw *** Error SPACEWIRE_IOCTRL_SEND\n");
return status;
}