migration from OS-II to OS-III with axiintc

migration from OS-II to OS-III with axiintc

Home Forums Real-Time Kernels migration from OS-II to OS-III with axiintc

This topic contains 1 reply, has 2 voices, and was last updated by  Sharbel Bousemaan 4 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #26410

    benjamin heinen
    Participant

    Hi,

    I want to migrate my project from OS-II to OS-III.

    However, i doesn’t found how to use the ucos driver for axiintc, “ucos_axiintc.h”. I want to connect 2 fit and 1 gpio to my axiintc. Can you suggest me an example, or explain me with my code doesn’t work ?

    Here is my code :

    
    #include <app_cfg.h>
    #include <cpu.h>
    #include <ucos_bsp.h>
    #include "bsp.h"
    #include <ucos_int.h>
    #include <xparameters.h>
    #include <KAL/kal.h>
    #include <Source/os.h>
    #include <os_cfg_app.h>
    #include <xgpiops.h>
    //#include <xintc.h>
    #include <ucos_axiintc.h>
    
    #define PL_INTC_IRQ_ID          XPS_IRQ_INT_ID
    #define FIT_1S_IRQ_ID           XPAR_AXI_INTC_0_FIT_TIMER_0_INTERRUPT_INTR
    #define FIT_3S_IRQ_ID			XPAR_AXI_INTC_0_FIT_TIMER_1_INTERRUPT_INTR
    #define GPIO_SW_IRQ_ID			XPAR_AXI_INTC_0_AXI_GPIO_0_IP2INTC_IRPT_INTR
    #define GPIO_SW_DEVICE_ID		XPAR_AXI_GPIO_0_DEVICE_ID
    
    #define XGPIO_IR_MASK		0x3 /**< Mask of all bits */
    
    static OS_TCB StartupTaskTCB;
    
    static CPU_STK StartupTaskStk[UCOS_START_TASK_STACK_SIZE];
    
    static XGpioPs gpSwitch;     //GPIO Device
    // static XIntc axi_intc;
    static AXIINTC_HANDLE handle_axi;
    
    /*
    *********************************************************************************************************
    *                                      LOCAL FUNCTION PROTOTYPES
    *********************************************************************************************************
    */
    
    void  MainTask (void *p_arg);
    
    /*
    *********************************************************************************************************
    *                                               main()
    *
    * Description : Entry point for C code.
    *
    *********************************************************************************************************
    */
    
    void fit_timer_1s_isr(void *p_int_arg, CPU_INT32U source_cpu) {
    	//xil_printf("Timer 1s\n");
    	OS_ERR err;
    
    	//OSSemPost(&semGen,  OS_OPT_POST_1 + OS_OPT_POST_NO_SCHED, &err);
        UCOS_Print ("generate 1s \r\n");
    
    }
    
    void fit_timer_3s_isr(void *p_int_arg, CPU_INT32U source_cpu) {
    	//xil_printf("Timer 3s\n");
    	OS_ERR err;
        UCOS_Print ("generates 3s\r\n");
    
    	//OSSemPost(&semCheck,  OS_OPT_POST_1 + OS_OPT_POST_NO_SCHED, &err);
    }
    
    void gpio_isr(void *p_int_arg, CPU_INT32U source_cpu) {
    	//xil_printf("Timer 3s\n");
    	XGpioPs_IntrClearPin(&gpSwitch, XGPIO_IR_MASK);
    
    	OS_ERR err;
        UCOS_Print ("gpio isr \r\n");
    
    	//OSSemPost(&semCheck,  OS_OPT_POST_1 + OS_OPT_POST_NO_SCHED, &err);
    }
    
    int initialize_axi_intc() {
    	int status;
    
    	/*status = XIntc_Initialize(&axi_intc, XPAR_AXI_INTC_0_DEVICE_ID);
    	if (status != XST_SUCCESS)
    		return XST_FAILURE;
    	*/
    	handle_axi = AXIIntCInit(XPAR_AXI_INTC_0_DEVICE_ID);
    	return XST_SUCCESS;
    }
    
    void initialize_gpio()
    {
    	if (XST_DEVICE_NOT_FOUND == XGpio_Initialize(&gpSwitch, GPIO_SW_DEVICE_ID))
    		UCOS_Print("Erreur init gpio\n");
    	XGpio_InterruptGlobalEnable(&gpSwitch);
    	XGpio_InterruptEnable(&gpSwitch, XGPIO_IR_MASK);
    }
    
    void init_interrupt() {
    	 KAL_ERR kal_err;
    	 CPU_INT32U tick_rate;
    	 UCOS_IntInit();                                             /* Initialize interrupt controller.                     */
    
    	 tick_rate = OS_CFG_TICK_RATE_HZ;
    	 UCOS_TmrTickInit(tick_rate);                                /* Configure and enable OS tick interrupt.              */
    	 KAL_Init(DEF_NULL, &kal_err);
    	 initialize_gpio(); 										// Initialize gpio
    	 initialize_axi_intc(); 									// Initialise le axi_intc
    	 UCOS_StdInOutInit();
    }
    
    int connect_gpio_irq()
    {
    	/*int status = XIntc_Connect(&axi_intc, GPIO_SW_IRQ_ID, gpio_isr, &gpSwitch);
    	if (status == XST_SUCCESS)
    		XIntc_Enable(&axi_intc, GPIO_SW_IRQ_ID);*/
    	AXIIntCIntEnSet(handle_axi, GPIO_SW_IRQ_ID);
    	//return status;
    	return 0;
    }
    
    int connect_fit_timer_1s_irq() {
    	int status;
    	/*
    	* Connect a device driver handler that will be called when an
    	* interrupt for the device occurs, the device driver handler performs
    	* the specific interrupt processing for the device
    	*/
    	/*status = XIntc_Connect(&axi_intc, FIT_1S_IRQ_ID, fit_timer_1s_isr, NULL);
    		if (status != XST_SUCCESS)
    			return status;
    	*/
    	AXIIntCIntEnSet(handle_axi, FIT_1S_IRQ_ID);
    
    	return XST_SUCCESS;
    }
    
    int connect_fit_timer_3s_irq() {
    	int status;
    	/*
    	* Connect a device driver handler that will be called when an
    	* interrupt for the device occurs, the device driver handler performs
    	* the specific interrupt processing for the device
    	*/
    	/*status = XIntc_Connect(&axi_intc, FIT_3S_IRQ_ID, fit_timer_3s_isr, NULL);
    		if (status != XST_SUCCESS)
    			return status;
    
    	XIntc_Enable(&axi_intc, FIT_3S_IRQ_ID);*/
    	AXIIntCIntEnSet(handle_axi, FIT_3S_IRQ_ID);
    
    	return XST_SUCCESS;
    }
    
    void connect_interrupt() {
    
    	connect_gpio_irq();
    	connect_fit_timer_1s_irq();
    	connect_fit_timer_3s_irq();
    	//XIntc_Start(&axi_intc, XIN_REAL_MODE);
    
    	CPU_BOOLEAN succes = UCOS_IntVectSet (FIT_1S_IRQ_ID,
    		                             0,
    		                             0,
    									 (UCOS_INT_FNCT_PTR)fit_timer_1s_isr,
    		                             &handle_axi);
    		if (succes != DEF_OK)
    		    UCOS_Print ("connect fit timer 1 : FAIL \n");
    
    		succes = UCOS_IntVectSet (FIT_3S_IRQ_ID,
    		                             0,
    									 DEF_BIT_00,
    									 (UCOS_INT_FNCT_PTR) fit_timer_3s_isr,
    		                             &handle_axi);
    		if (succes != DEF_OK)
    		    UCOS_Print ("connect fit timer 3 : FAIL \n");
    		succes = UCOS_IntSrcEn(FIT_1S_IRQ_ID);
    		if (succes != DEF_OK)
    		    UCOS_Print ("enable fit timer 1 : FAIL \n");
    		succes = UCOS_IntSrcEn(FIT_3S_IRQ_ID);
    		if (succes != DEF_OK)
    		    UCOS_Print ("enable fit timer 3 : FAIL \n");
    
    		succes = UCOS_IntVectSet(GPIO_SW_IRQ_ID, 0, DEF_BIT_00, gpio_isr, &handle_axi);
    		if (succes != DEF_OK)
    		    UCOS_Print ("connect gpio : FAIL \n");
    		succes = UCOS_IntSrcEn(GPIO_SW_IRQ_ID);
    		if (succes != DEF_OK)
    		    UCOS_Print ("enable gpio : FAIL \n");
    
    }
    
    int main()
    {
    
        OS_ERR  os_err;
        UCOS_LowLevelInit();
        BSP_Init();
        CPU_Init();
        Mem_Init();
        OSInit(&os_err);
    
        OSTaskCreate(&StartupTaskTCB,
                          "Main Task",
    					  MainTask,
                          (void *)0,
                          UCOS_START_TASK_PRIO,
                         &StartupTaskStk[0],
                          0,
                          UCOS_START_TASK_STACK_SIZE,
                          0,
                          0,
                          DEF_NULL,
                         (OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
                         &os_err);
        init_interrupt();
        connect_interrupt();
        OSStart(&os_err);
    
        return 0;
    }
    
    /*
    *********************************************************************************************************
    *                                             MainTask()
    *
    * Description : Startup task example code.
    *
    * Returns     : none.
    *
    * Created by  : main().
    *********************************************************************************************************
    */
    
    void  MainTask (void *p_arg)
    {
        OS_ERR       os_err;
    
        UCOS_Print ("Hello world from the main task\r\n");
    
        while (DEF_TRUE) {
            OSTimeDlyHMSM(0, 0, 3, 0, OS_OPT_TIME_HMSM_STRICT, &os_err);
            UCOS_Print("Periodic output every 3 seconds from the main task\r\n");
        }
    }
    
    

    I will be grateful if you can help me,

    #26429

    Hello Benjamin,

    Which board and processor are you using?
    Are you using the Microblaze Soft processor?

    Regards,
    Sharbel

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

View the complete site map

x
Loading...