add interrupts to demo

This commit is contained in:
Alwin Berger 2022-04-19 23:44:08 +02:00
parent 312faf93e4
commit 47d86ca153
2 changed files with 34 additions and 1 deletions

View File

@ -36,6 +36,7 @@ extern void xPortPendSVHandler( void );
extern void xPortSysTickHandler( void ); extern void xPortSysTickHandler( void );
extern void uart_init(); extern void uart_init();
extern int main(); extern int main();
extern void isr_starter( void ); // main_tmr.c
void __attribute__( ( weak ) ) EthernetISR( void ); void __attribute__( ( weak ) ) EthernetISR( void );
@ -176,7 +177,7 @@ const uint32_t * isr_vector[] __attribute__( ( section( ".isr_vector" ) ) ) =
0, /* reserved */ 0, /* reserved */
( uint32_t * ) &xPortPendSVHandler, /* PendSV handler -2 */ ( uint32_t * ) &xPortPendSVHandler, /* PendSV handler -2 */
( uint32_t * ) &xPortSysTickHandler, /* SysTick_Handler -1 */ ( uint32_t * ) &xPortSysTickHandler, /* SysTick_Handler -1 */
0, /* uart0 receive 0 */ ( uint32_t * ) &isr_starter, /* uart0 receive 0 */
0, /* uart0 transmit */ 0, /* uart0 transmit */
0, /* uart1 receive */ 0, /* uart1 receive */
0, /* uart1 transmit */ 0, /* uart1 transmit */
@ -195,6 +196,8 @@ const uint32_t * isr_vector[] __attribute__( ( section( ".isr_vector" ) ) ) =
void _start( void ) void _start( void )
{ {
uart_init(); uart_init();
NVIC_EnableIRQ(0);
NVIC_SetPriority (0, 6); // need to stay above configMAX_SYSCALL_INTERRUPT_PRIORITY
main( 0, 0 ); main( 0, 0 );
exit( 0 ); exit( 0 );
} }

View File

@ -70,12 +70,14 @@ static void prvReplicaA( void * pvParameters );
static void prvReplicaB( void * pvParameters ); static void prvReplicaB( void * pvParameters );
static void prvReplicaC( void * pvParameters ); static void prvReplicaC( void * pvParameters );
static void prvVoterTask( void * pvParameters ); static void prvVoterTask( void * pvParameters );
static void prvSporadicTask( void * pvParameters );
#define mainSAMPLER_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) #define mainSAMPLER_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define mainVOTER_TASK_PRIORITY ( tskIDLE_PRIORITY + 5 ) #define mainVOTER_TASK_PRIORITY ( tskIDLE_PRIORITY + 5 )
#define mainREPLICA_A_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 ) #define mainREPLICA_A_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
#define mainREPLICA_B_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 ) #define mainREPLICA_B_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
#define mainREPLICA_C_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 ) #define mainREPLICA_C_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainSPORADIC_TASK_PRIORITY ( tskIDLE_PRIORITY + 6 )
#define mainQUEUE_LENGTH ( 1 ) #define mainQUEUE_LENGTH ( 1 )
#define mainQUEUE_SEND_FREQUENCY_MS ( 10 / portTICK_PERIOD_MS ) #define mainQUEUE_SEND_FREQUENCY_MS ( 10 / portTICK_PERIOD_MS )
#define voterMAXRETRIES 1 #define voterMAXRETRIES 1
@ -86,6 +88,7 @@ static void prvVoterTask( void * pvParameters );
static TaskHandle_t xReplA = NULL; static TaskHandle_t xReplA = NULL;
static TaskHandle_t xReplB = NULL; static TaskHandle_t xReplB = NULL;
static TaskHandle_t xReplC = NULL; static TaskHandle_t xReplC = NULL;
static TaskHandle_t xSporadic = NULL;
/* The queue used by both tasks. */ /* The queue used by both tasks. */
static QueueHandle_t xQueueOutputA = NULL; static QueueHandle_t xQueueOutputA = NULL;
static QueueHandle_t xQueueOutputB = NULL; static QueueHandle_t xQueueOutputB = NULL;
@ -141,6 +144,13 @@ void main_tmr( void )
mainVOTER_TASK_PRIORITY, mainVOTER_TASK_PRIORITY,
NULL ); NULL );
xTaskCreate( prvSporadicTask, /* The function that implements the task. */
"Spor", /* The text name assigned to the task - for debug only as it is not used by the kernel. */
configMINIMAL_STACK_SIZE, /* The size of the stack to allocate to the task. */
NULL, /* The parameter passed to the task - not used in this case. */
mainSPORADIC_TASK_PRIORITY, /* The priority assigned to the task. */
&xSporadic ); /* The task handle is not required, so NULL is passed. */
/* Start the tasks and timer running. */ /* Start the tasks and timer running. */
vTaskStartScheduler(); vTaskStartScheduler();
} }
@ -250,5 +260,25 @@ static void prvVoterTask( void * pvParameters )
// Finisched one TMR Cycle // Finisched one TMR Cycle
trigger_Qemu_break(); trigger_Qemu_break();
} }
static void prvSporadicTask( void * pvParameters )
{
int tmp = 1;
while (1)
{
ulTaskNotifyTake(pdTRUE,portMAX_DELAY);
for (int i=0; i<1000; i++) {
tmp *= i;
if (i > 2<<16) {
tmp = tmp >> 8;
}
}
}
}
void isr_starter( void )
{
if (xSporadic) {
vTaskNotifyGiveFromISR(xSporadic, NULL);
}
}
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/