コード例 #1
0
ファイル: sh_abort.c プロジェクト: nevinxu/HM502B2
int32_t  Shell_abort(int32_t argc, char *argv[] ) {
   SHELL_CONTEXT_PTR shell_ptr = Shell_get_context(argv);
   bool     print_usage, shorthelp = FALSE;
   int32_t      return_code = SHELL_EXIT_SUCCESS;
   _task_id    task_id;
   uint32_t     result;

   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
      
      if (argc == 2)  {
         task_id = _task_get_id_from_name( argv[1] );
         if (task_id == MQX_NULL_TASK_ID)  {
            fprintf(shell_ptr->STDOUT, "No task named %s running.\n",argv[1]);
            return_code = SHELL_EXIT_ERROR;
         } else  {
            result = _task_abort(task_id);
            if (result == MQX_OK)  {  
               fprintf(shell_ptr->STDOUT, "Task %s aborted.\n",argv[1]);
            } else  {
               fprintf(shell_ptr->STDOUT, "Unable to abort task %s.\n",argv[1]);
               return_code = SHELL_EXIT_ERROR;
            }
         }
      } else  {
         fprintf(shell_ptr->STDOUT, "Error, %s invoked with incorrect number of arguments\n", argv[0]);
         print_usage = TRUE;
      }
   }

   if (print_usage)  {
      if (shorthelp)  {
         fprintf(shell_ptr->STDOUT, "%s <taskname>\n", argv[0]);
      } else  {
         fprintf(shell_ptr->STDOUT, "Usage: %s <taskname>\n", argv[0]);
         fprintf(shell_ptr->STDOUT, "   <taskname> = MQX Task name\n");
      }
   }

   return return_code;
} /* Endbody */
コード例 #2
0
ファイル: int_xcpt.c プロジェクト: 51104271/CW_FRDM-KE06Z
/*!
 * \brief To provide support for exception handlers, applications can use this ISR
 * to replace the default ISR. The ISR is specific to the PSP.
 * 
 * An application calls _int_install_exception_isr() to install _int_exception_isr().
 * \n The function _int_exception_isr() does the following:
 * \n - If an exception occurs when a task is running and a task exception ISR 
 * exists, MQX runs the ISR; if a task exception ISR does not exist, MQX aborts 
 * the task by calling _task_abort().
 * \n - If an exception occurs when an ISR is running and an ISR exception ISR 
 * exists, MQX aborts the running ISR and runs the ISR’s exception ISR.
 * \n - The function walks the interrupt stack looking for information about the 
 * ISR or task that was running before the exception occurred. If the function 
 * determines that the interrupt stack contains incorrect information, it calls 
 * _mqx_fatal_error() with error code MQX_CORRUPT_INTERRUPT_STACK.
 * 
 * \param[in] parameter Parameter passed to the default ISR (the vector number).
 * 
 * \warning See description.
 * 
 * \see _int_install_exception_isr
 * \see _mqx_fatal_error
 * \see _task_abort     
 */   
void _int_exception_isr
   (
      pointer parameter
   )
{ /* Body */
    KERNEL_DATA_STRUCT_PTR         kernel_data;
    TD_STRUCT_PTR                  td_ptr;
    PSP_INT_CONTEXT_STRUCT_PTR     exception_frame_ptr;
    PSP_INT_CONTEXT_STRUCT_PTR     isr_frame_ptr;
    INTERRUPT_TABLE_STRUCT_PTR     table_ptr;
    INT_EXCEPTION_FPTR             exception_handler;
    uint_32                        isr_vector;
/*    uint_32                        exception_vector; */

    _GET_KERNEL_DATA(kernel_data);
    td_ptr = kernel_data->ACTIVE_PTR;

    /* Stop all interrupts */
    _PSP_SET_DISABLE_SR(kernel_data->DISABLE_SR);
    /*_int_disable(); */

    if ( kernel_data->IN_ISR > 1 ) {
        /* We have entered this function from an exception that happened
         * while an isr was running.
         */
    
        /* Get our current exception frame */
        exception_frame_ptr = kernel_data->INTERRUPT_CONTEXT_PTR;

        /* the current context contains a pointer to the next one */
        isr_frame_ptr = (PSP_INT_CONTEXT_STRUCT_PTR)exception_frame_ptr->PREV_CONTEXT;
        if (isr_frame_ptr == NULL) {
            /* This is not allowable */
            _mqx_fatal_error(MQX_CORRUPT_INTERRUPT_STACK);
        }
        
        isr_vector =  isr_frame_ptr->EXCEPTION_NUMBER;

        /* Call the isr exception handler for the ISR that WAS running */
        table_ptr = kernel_data->INTERRUPT_TABLE_PTR;
#if MQX_CHECK_ERRORS
        if ((table_ptr != NULL) &&
            (isr_vector >= kernel_data->FIRST_USER_ISR_VECTOR) &&
            (isr_vector <= kernel_data->LAST_USER_ISR_VECTOR))
        {
#endif
        /* Call the exception handler for the isr on isr_vector,
         * passing the isr_vector, the exception_vector, the isr_data and
         * the basic frame pointer for the exception
         */
        exception_handler = _int_get_exception_handler(isr_vector);
   
        if (exception_handler) {
            (*exception_handler)(isr_vector, (_mqx_uint)parameter, _int_get_isr_data(isr_vector)/*table_ptr->APP_ISR_DATA*/, exception_frame_ptr);
        }
    
#if MQX_CHECK_ERRORS
        } else {
            /* In this case, the exception occured in this handler */
            _mqx_fatal_error(MQX_INVALID_VECTORED_INTERRUPT);
        }
#endif

        /* Indicate we have popped 1 interrupt stack frame (the exception frame) */
        --kernel_data->IN_ISR;

        /* Reset the stack to point to the interrupt frame */
        /* And off we go. Will never return */
        _psp_exception_return( (pointer)isr_frame_ptr );

    } else {
        /* We have entered this function from an exception that happened
         * while a task was running.
         */

        if (td_ptr->EXCEPTION_HANDLER_PTR != NULL ) {
            (*td_ptr->EXCEPTION_HANDLER_PTR)((_mqx_uint)parameter, 
            td_ptr->STACK_PTR);
        } else {
            /* Abort the current task */
            _task_abort(MQX_NULL_TASK_ID);
        }
   }
}
コード例 #3
0
ファイル: lp_main - Copy.c プロジェクト: NeoXiong/MP3
/*TASK*-----------------------------------------------------------------
*
* Function Name  : localPlay_init_task
* Returned Value : void
* Comments       :
*
*END------------------------------------------------------------------*/
void localPlay_init_task
(
    uint_32 temp
)
{
    MQX_TICK_STRUCT time;
    _mqx_int errcode = 0;

    /* Install MQX default unexpected ISR routines */
    _int_install_unexpected_isr();

    if(_lwevent_create(&player_event, 0)!= MQX_OK)
    {
        printf("\nMake event failed");
    }

    /* Setup time */
    printf("Setting up time......................");
    time.TICKS[0] = 0L;
    time.TICKS[1] = 0L;
    time.HW_TICKS = 0;
    _time_set_ticks(&time);
    printf("[OK]\n");

    /* Init GPIOs */
    lwgpio_init(&btn_next, BSP_SW1, LWGPIO_DIR_INPUT, LWGPIO_VALUE_NOCHANGE);
    lwgpio_set_functionality(&btn_next,BSP_SW1_MUX_GPIO);
    lwgpio_set_attribute(&btn_next, LWGPIO_ATTR_PULL_UP, LWGPIO_AVAL_ENABLE);
    lwgpio_int_init(&btn_next, LWGPIO_INT_MODE_RISING);
    _int_install_isr(lwgpio_int_get_vector(&btn_next), int_service_routine_btn_pause, (void *) &btn_next);
    hmi_init();
    sgtl5000_power_on();
    hmi_install(1, int_service_routine_btn_prev);

    _bsp_int_init(lwgpio_int_get_vector(&btn_next), BTN_ISR_PRIORITY, 0, TRUE);

    lwgpio_init(&btn_prev, BSP_SW2, LWGPIO_DIR_INPUT, LWGPIO_VALUE_NOCHANGE);
    lwgpio_set_functionality(&btn_prev, BSP_SW2_MUX_GPIO);
    lwgpio_set_attribute(&btn_prev, LWGPIO_ATTR_PULL_UP, LWGPIO_AVAL_ENABLE);

#ifdef SD_DETECT_POLLING
    lwgpio_int_init(&btn_prev, LWGPIO_INT_MODE_RISING);
    _int_install_isr(lwgpio_int_get_vector(&btn_prev), int_service_routine_btn_stop, (void *) &btn_prev);
    _bsp_int_init(lwgpio_int_get_vector(&btn_prev), BTN_ISR_PRIORITY, 0, TRUE);
#endif

    hmi_install(2, int_service_routine_btn_next);



    hmi_install(3, int_service_routine_vol_up);
    hmi_install(4, int_service_routine_vol_down);

#if 0
    /* Initialize audio codec */
    printf("Initializing audio codec.............");


    if (errcode != 0)
    {
        printf("[FAIL]\n");
        printf("  Error 0x%X\n", errcode);
    }
    else
    {
        printf("[OK]\n");
    }

//#else
    /* Initialize audio driver and codec */
    /************************************************/
    if ((errcode = msi_snd_init()) != 0)
    {
        printf("Initializing audio driver and codec........[FAIL]\n");
        printf("  Error 0x%X\n", errcode);
        return;
    }
    else
    {
        printf("Initializing audio driver and codec........[OK]\n");
    }
    /************************************************/
#endif
    /* Create tasks */
    errcode = _task_create(0, SDCARD_TASK, 0);
    printf("Creating SD card task................");
    if (errcode == MQX_NULL_TASK_ID)
    {
        printf("[FAIL]\n");
        printf("  Error 0x%X.\n");
    }
    else
    {
        printf("[OK]\n");
    }
#ifdef SD_PLAYER_SHELL_SUPPORTED
    printf("Creating shell task..................");
    errcode = _task_create(0, SHELL_TASK, 0);
    if (errcode == MQX_NULL_TASK_ID)
    {
        printf("[FAIL]\n");
        printf("  Error 0x%X.\n");
    }
    else
    {
        printf("[OK]\n");
    }
#endif

    lwgpio_int_enable(&btn_next, TRUE);

#ifdef SD_DETECT_POLLING
    lwgpio_int_enable(&btn_prev, TRUE);
#endif
    _task_abort(MQX_NULL_TASK_ID);
}