RTOS kernel in program

Thread Starter

vead

Joined Nov 24, 2011
629
Hello
I have searched on internet about kernel. kernel is center core of operating system that provide basic service to operating system and decide when and how long program should be run on system. I understand what is rtos kernel but when I see sample program, there I don't understand which part of program show the rtos kernel. whole program contain with many header files and c files. I can't figure out which part of program is kernel.I am looking program for rtos kernel. I don't understand where is code for rtos kernel?
kernel in program.jpg
 
Last edited:

Thread Starter

vead

Joined Nov 24, 2011
629
RTOS kernel is huge. The whole collection of files make up all of RTOS.
right , I have mentioned in my post that RTOS program contain with many header files and c files. but my confusion is that how to identify in program that this is kernel code or this part of code for rtos kernel or the collection of this files show the rtos kernel ?
 

Thread Starter

vead

Joined Nov 24, 2011
629
All of it is the kernel.
Take a look at the file main.c
sorry , but I don't understand what are you trying to say. I am posting main .c code
Code:
#include <project.h>
#include <FreeRTOS.h>
#include <task.h>

void prvHardwareSetup();
void vApplicationIdleHook( void );

#define WDT_IRQN               9             /* Watchdog Timer (WDT) interrupt vector number */
#define ONE_MILISECOND_PERIOD  (32767u/1000u) /* 1 ms @ 32.768kHz clock */

/* Function Prototypes */
void SetupWDT(uint16 timerPeriod);
CY_ISR_PROTO(WDT_Isr_Handler);

void vTask1( void *pvParameters ) {
    while(1) {
        //Pin_Red_LED_Write(~Pin_Red_LED_Read());
        Pin_Red_LED_Write(1);
        CyDelayUs(10);
        Pin_Red_LED_Write(0);
        vTaskDelay(configTICK_RATE_HZ/1000); // 1KHz   
    }
}

void vBlinkTaskRed( void *pvParameters ) {
    while(1) {
        //Pin_Red_LED_Write(~Pin_Red_LED_Read());
        vTaskDelay(configTICK_RATE_HZ/1000); // 1KHz   
    }
}

void vPortSetupTimerInterrupt( void );

int main()
{   
   
    //xTaskCreate(vBlinkTaskBlue, (signed portCHAR *) "BlinkBlue", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL);
    xTaskCreate(vTask1, (signed portCHAR *) "BlinkRed", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL);
   
    prvHardwareSetup();
    CyGlobalIntEnable;
   
    vTaskStartScheduler();
   
    return 1; // We should never reach this
}

/* ---------------------------------------------------------------------------
* FreeRTOS support and configuration functions
* --------------------------------------------------------------------------- */

void prvHardwareSetup( void )
{
    /* Port layer functions that need to be copied into the vector table. */
    extern void xPortPendSVHandler( void );
    extern void xPortSysTickHandler( void );
    extern void vPortSVCHandler( void );
    extern cyisraddress CyRamVectors[];

    /* Install the OS Interrupt Handlers. */
    CyRamVectors[ 11 ] = ( cyisraddress ) vPortSVCHandler;
    CyRamVectors[ 14 ] = ( cyisraddress ) xPortPendSVHandler;
    CyRamVectors[ 15 ] = ( cyisraddress ) xPortSysTickHandler;
}

void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName )
{
    /* The stack space has been execeeded for a task, considering allocating more. */
    taskDISABLE_INTERRUPTS();
    for( ;; );
}

void vApplicationMallocFailedHook( void )
{
    /* The heap space has been execeeded. */
    taskDISABLE_INTERRUPTS();
    for( ;; );
}

void vApplicationIdleHook( void )
{
    // Handle Power Saving
    CySysPmSleep();   
}


/******************************************************************
*                SetupWDT()
*
* This function sets up the Watchdog WDT0 to generate an interrupt
* once per second. It is used to wake the PSoC from DeepSleep.
*
******************************************************************/
void SetupWDT(uint16 timerPeriod)
{
    /* Use only timer 0 and do not cascade timers */
    CySysWdtWriteCascade(CY_SYS_WDT_CASCADE_NONE);
   
    /* Setup WDT0 for the specified period "timerPeriod".  */
    CySysWdtWriteMode(CY_SYS_WDT_COUNTER0,CY_SYS_WDT_MODE_INT);  /* Cause interrupt on match */
    CySysWdtWriteMatch(CY_SYS_WDT_COUNTER0,timerPeriod);         /* Set timer period */
    CySysWdtWriteClearOnMatch(CY_SYS_WDT_COUNTER0, 1u);          /* Reset counter on match  */
    CySysWdtEnable(CY_SYS_WDT_COUNTER0_MASK);                    /* Enable WDT0 */
   
    /* Lock WDT registers */
    CySysWdtLock();
   
   
    /* Setup the interrupt handler for the WDTs and enable it */
    CyIntSetVector(WDT_IRQN, WDT_Isr_Handler);
    CyIntEnable(WDT_IRQN);
}   

/******************************************************************
*      Slow Timer Interrupt (WDT)
*
* This interrupt is triggered each time the WDT0 triggers an
* interrupt.  The interrupt is cleared and flow returns to the
* main loop.
*
******************************************************************/
CY_ISR(WDT_Isr_Handler)
{
    /* Clear interrupts state */
    CySysWdtClearInterrupt(CY_SYS_WDT_COUNTER0_INT);
    CyIntClearPending(WDT_IRQN);
}


/* [] END OF FILE */
 

MrChips

Joined Oct 2, 2009
34,809
This is your main loop:

Code:
int main()
{  
   
    //xTaskCreate(vBlinkTaskBlue, (signed portCHAR *) "BlinkBlue", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL);
    xTaskCreate(vTask1, (signed portCHAR *) "BlinkRed", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL);
   
    prvHardwareSetup();
    CyGlobalIntEnable;
   
    vTaskStartScheduler();
   
    return 1; // We should never reach this
}
All the rest of the project files are required to support this program, which is

vTaskStartScheduler();
 
Top