Пример #1
0
void usb_host_hid_mouse_recv_callback
   (
      /* [IN] pointer to pipe */
      _usb_pipe_handle  pipe_handle,

      /* [IN] user-defined parameter */
      void             *user_parm,

      /* [IN] buffer address */
      unsigned char         *buffer,

      /* [IN] length of data transferred */
      uint32_t           buflen,

      /* [IN] status, hopefully USB_OK or USB_DONE */
      USB_STATUS        status
   )
{ /* Body */

    if (status == USB_OK) {
        /* notify application that data are available */
        _lwevent_set(&USB_Mouse_Event, USB_EVENT_DATA);
    }
    else {
        /* notify application that data are available */
        _lwevent_set(&USB_Mouse_Event, USB_EVENT_DATA_CORRUPTED);
    }  
}
Пример #2
0
void switch_poll(void)
{
    
    /* Read pin status to switches list */
    if (IO_OK != ioctl(file_switches, GPIO_IOCTL_READ, (char_ptr) &switches))
    {
        _task_block();
    }

    
    /* Test if SW1 was pressed */
    if (((switches[SW1] & GPIO_PIN_STATUS) == 0))   { 
        if ((switch_state & IO_SW1_MASK) == 0)  {
            switch_state |= IO_SW1_MASK;
            _lwevent_set(&meter_shared_event, IO_SW1_MASK);
        }
    }
    else  {
        switch_state &= ~IO_SW1_MASK;
    } 

    /* Test if SW2 was pressed */
    if (((switches[SW2] & GPIO_PIN_STATUS) == 0))   { 
        if ((switch_state & IO_SW2_MASK) == 0)  {
            switch_state |= IO_SW2_MASK;
            /* Set SW2 click mask */
            _lwevent_set(&meter_shared_event, IO_SW2_MASK);
        }
    }
    else  {
        switch_state &= ~IO_SW2_MASK;
    } 

    /* Test if SW3 was pressed */
    if (((switches[SW3] & GPIO_PIN_STATUS) == 0))   { 
        if ((switch_state & IO_SW3_MASK) == 0)  {
            switch_state |= IO_SW3_MASK;
            /* Set SW2 click mask */
            _lwevent_set(&meter_shared_event, IO_SW3_MASK);
        }
    }
    else  {
        switch_state &= ~IO_SW3_MASK;
    } 
 
    /* Test if SW4 was pressed */
    if (((switches[SW4] & GPIO_PIN_STATUS) == 0))   { 
        if ((switch_state & IO_SW4_MASK) == 0)  {
            switch_state |= IO_SW4_MASK;
            /* Set SW2 click mask */
            _lwevent_set(&meter_shared_event, IO_SW4_MASK);
        }
    }
    else  {
        switch_state &= ~IO_SW4_MASK;
    } 
}
Пример #3
0
static void my_interrupt (pointer rtc_registers_ptr)
{
    state = _rtc_get_status ();

    if( state & RTC_RTCISR_SW)
    {
        _lwevent_set(&lwevent,LWE_STOPWATCH);
    }
    if( state &   RTC_RTCISR_ALM)
    {
        _lwevent_set(&lwevent,LWE_ALARM);
    }
    _rtc_clear_requests (state);
}
// sensor read task
void RdSensData_task(uint32_t task_init_data)
{
	// initialize the physical sensors over I2C and the sensor data structures
	RdSensData_Init();

	// initialize the user high frequency (typically 200Hz) task
	UserHighFrequencyTaskInit();

	// loop indefinitely (typically 200Hz)
	while(1)
	{
		// wait here for the sampling event (hardware clock, typically at 200Hz)
		// the Kalman filter and magnetic fusion tasks execute while this task is blocked here
		// FALSE means any bit (of the 1 bit enabled by the mask) unblocks
		// and NULL means timeout is infinite
		_lwevent_wait_for(&(mqxglobals.SamplingEventStruct), 1, FALSE, NULL);

		// reset the Kalman filter task flag
		mqxglobals.RunKF_Event_Flag = 0;
		// read the sensors
		RdSensData_Run();
		// run the user high frequency task
		UserHighFrequencyTaskRun();

		// use the Kalman filter flag set by the sensor read task (typically every 8 iterations)
		// with a mask of 1 (least significant bit set) to enable the Kalman filter task to run
		if (mqxglobals.RunKF_Event_Flag)
			_lwevent_set(&(mqxglobals.RunKFEventStruct), 1);

	}  // end of infinite loop
}
Пример #5
0
void usb_host_hid_mouse_ctrl_callback
   (
      /* [IN] pointer to pipe */
      _usb_pipe_handle  pipe_handle,

      /* [IN] user-defined parameter */
      void             *user_parm,

      /* [IN] buffer address */
      unsigned char         *buffer,

      /* [IN] length of data transferred */
      uint32_t           buflen,

      /* [IN] status, hopefully USB_OK or USB_DONE */
      uint32_t           status
   )
{ /* Body */
   if (status == USBERR_ENDPOINT_STALLED) {
      printf("\nHID Set_Protocol Request BOOT is not supported!\n");
      fflush(stdout);
   }
   else if (status) {
      printf("\nHID Set_Protocol Request BOOT failed!: 0x%x ... END!\n", status);
      fflush(stdout);
   } /* Endif */

    if(mouse_hid_device.DEV_STATE == USB_DEVICE_SETTING_PROTOCOL)
        mouse_hid_device.DEV_STATE = USB_DEVICE_INUSE;
    
    /* notify application that status has changed */
    _lwevent_set(&USB_Mouse_Event, USB_EVENT_CTRL);
   
} /* Endbody */
Пример #6
0
void usb_host_hid_ctrl_callback(
    /* [IN] pointer to pipe */
    _usb_pipe_handle pipe_handle,
    /* [IN] user-defined parameter */
    pointer user_parm,
    /* [IN] buffer address */
    uchar_ptr buffer,
    /* [IN] length of data transferred */
    uint_32 buflen,
    /* [IN] status, hopefully USB_OK or USB_DONE */
    USB_STATUS status
)
{
    if(status == USBERR_ENDPOINT_STALLED) {
        printf("\nHID Set_Protocol Request BOOT is not supported!\n");
        fflush(stdout);
    }
    else if(status) {
        printf("\nHID Set_Protocol Request BOOT failed!: 0x%x ... END!\n", status);
        fflush(stdout);
        _task_block();
    }

    if(hid_device.DEV_STATE == USB_DEVICE_SETTING_PROTOCOL)
        hid_device.DEV_STATE = USB_DEVICE_INUSE;

    /* notify application that status has changed */
    _lwevent_set(&USB_Event, USB_EVENT_CTRL);
}
Пример #7
0
/******************************************************************************
*   @name        process_play_button
*
*   @brief       process play button
*
*   @return      None
*
*   @comment
*
*******************************************************************************/
static void process_play_button(void)
{
   if(USB_DEVICE_INTERFACED == audio_stream.DEV_STATE)
   {
      play = 1 - play;
      /* play */
      if (TRUE == play)
      {
         printf("Playing ...\n");
         _lwevent_set(&USB_Event, USB_EVENT_RECEIVED_DATA);
#if (defined BSP_TWRMCF51JE) || (defined BSP_TWRMCF51MM)||(defined BSP_MCF51JMEVB)
         EnableCmtInterrupt();
#elif (defined BSP_TWRMCF51JF)
         EnableFTM0Interrupt();
#else
         _audio_timer_unmask_int(BSP_LAST_TIMER);
#endif
      }
      /* stop */
      else
      {
         printf("\nPaused.\n");
#if (defined BSP_TWRMCF51JE) || (defined BSP_TWRMCF51MM)||(defined BSP_MCF51JMEVB)
         DisableCmtInterrupt();
#elif (defined BSP_TWRMCF51JF)
         DisableFTM0Interrupt();
#else
         _audio_timer_mask_int(BSP_LAST_TIMER);
#endif
      }
   }
}
Пример #8
0
/* ===================================================================*/
void TU1_OnCounterRestart(LDD_TUserData *UserDataPtr) {
	/* Write your code here ... */
	time_count++;
	if (time_count == TIME_TO_SEND) {
		time_count = 0;
		_lwevent_set(&an_event, EVT_BIT_MASK);
	}
}
Пример #9
0
void EXT_SDDETECT_ISR(void *pin)
{
    int sd_pin;
    boolean inserted;

    // if(sd_pin = lwgpio_int_get_flag((LWGPIO_STRUCT_PTR) pin)) {
    inserted = !lwgpio_get_value((LWGPIO_STRUCT_PTR) pin);

    // printf("sd detect pin changed %d,insert state %d,cur_musicPlayMS %d\n",sd_pin,inserted,cur_musicPlayMS);
    //if(cur_musicPlayMS != mp_sBT) {
    if(inserted)
        _lwevent_set(&sddetect_event,SD_ATTACHED_EVENT);
    else
        _lwevent_set(&sddetect_event,SD_DETTACHED_EVENT);
    //}
    lwgpio_int_clear_flag((LWGPIO_STRUCT_PTR) pin);
    // }
}
Пример #10
0
void usb_host_hid_keyboard_event(
    /* [IN] pointer to device instance */
    _usb_device_instance_handle dev_handle,
    /* [IN] pointer to interface descriptor */
    _usb_interface_descriptor_handle intf_handle,
    /* [IN] code number for event causing callback */
    uint_32 event_code)
{
    INTERFACE_DESCRIPTOR_PTR intf_ptr = (INTERFACE_DESCRIPTOR_PTR) intf_handle;

    fflush(stdout);
    switch (event_code) {

    case USB_ATTACH_EVENT:
        printf("----- Attach Event -----\n");
        /* Drop through config event for the same processing */
    case USB_CONFIG_EVENT:
        printf("State = %d", hid_device.DEV_STATE);
        printf("  Class = %d", intf_ptr->bInterfaceClass);
        printf("  SubClass = %d", intf_ptr->bInterfaceSubClass);
        printf("  Protocol = %d\n", intf_ptr->bInterfaceProtocol);
        fflush(stdout);

        if(hid_device.DEV_STATE == USB_DEVICE_IDLE) {
            hid_device.DEV_HANDLE = dev_handle;
            hid_device.INTF_HANDLE = intf_handle;
            hid_device.DEV_STATE = USB_DEVICE_ATTACHED;
        }
        else {
            printf("HID device already attached\n");
            fflush(stdout);
        }
        break;

    case USB_INTF_EVENT:
        printf("----- Interfaced Event -----\n");
        hid_device.DEV_STATE = USB_DEVICE_INTERFACED;
        break;

    case USB_DETACH_EVENT:
        /* Use only the interface with desired protocol */
        printf("\n----- Detach Event -----\n");
        printf("State = %d", hid_device.DEV_STATE);
        printf("  Class = %d", intf_ptr->bInterfaceClass);
        printf("  SubClass = %d", intf_ptr->bInterfaceSubClass);
        printf("  Protocol = %d\n", intf_ptr->bInterfaceProtocol);
        fflush(stdout);

        hid_device.DEV_HANDLE = NULL;
        hid_device.INTF_HANDLE = NULL;
        hid_device.DEV_STATE = USB_DEVICE_DETACHED;
        break;
    }

    /* notify application that status has changed */
    _lwevent_set(&USB_Event, USB_EVENT_CTRL);
}
Пример #11
0
static void button_isr
    (
         void   *pin
    )
{
    lwgpio_toggle_value (&led1);
    lwgpio_int_clear_flag (pin);
    _lwevent_set (&app_event, SW_EVENT_MASK);
}
Пример #12
0
uint32_t OS_Event_set(os_event_handle handle, uint32_t bitmask)
{
    LWEVENT_STRUCT *event = (LWEVENT_STRUCT*)handle;
    if (_lwevent_set(event, bitmask) != MQX_OK)
    {
        return (uint32_t)OS_EVENT_ERROR;
    }
    return (uint32_t)OS_EVENT_OK;
}
Пример #13
0
void usb_class_audio_control_init
(
    /* [IN]  structure with USB pipe information on the interface */
    PIPE_BUNDLE_STRUCT_PTR      pbs_ptr,

    /* [IN] audio call struct pointer */
    CLASS_CALL_STRUCT_PTR       ccs_ptr
)
{ /* Body */
    AUDIO_CONTROL_INTERFACE_STRUCT_PTR if_ptr = ccs_ptr->class_intf_handle;
    USB_STATUS                    status;

#ifdef _HOST_DEBUG_
    DEBUG_LOG_TRACE("usb_class_audio_control_init");
#endif

    /* Make sure the device is still attached */
    USB_lock();
    status = usb_host_class_intf_init(pbs_ptr, if_ptr, &audio_control_anchor);
    if (status == USB_OK) {
        /*
        ** We generate a code_key based on the attached device. This is used to
        ** verify that the device has not been detached and replaced with another.
        */
        ccs_ptr->code_key = 0;
        ccs_ptr->code_key = usb_host_class_intf_validate(ccs_ptr);

        if_ptr->AUDIO_G.IFNUM = ((INTERFACE_DESCRIPTOR_PTR)if_ptr->AUDIO_G.G.intf_handle)->bInterfaceNumber;
        if_ptr->interrupt_pipe = usb_hostdev_get_pipe_handle(pbs_ptr, USB_INTERRUPT_PIPE, 0);
  
        if (MQX_OK != (status = _lwevent_create(&if_ptr->control_event, 0))) {
           status = USBERR_INIT_FAILED;
        }
        else {
        /* prepare events to be auto or manual */
            _lwevent_set_auto_clear(&if_ptr->control_event, USB_AUDIO_CTRL_PIPE_FREE | USB_AUDIO_CTRL_INT_PIPE_FREE);
            /* pre-set events */
            _lwevent_set(&if_ptr->control_event, USB_AUDIO_CTRL_PIPE_FREE | USB_AUDIO_CTRL_INT_PIPE_FREE);
        }
    } /* Endif */

    /* Signal that an error has occured by setting the "code_key" */
    if (status) {
        ccs_ptr->code_key = 0;
    } /* Endif */

    USB_unlock();

#ifdef _HOST_DEBUG_
    if (status)
        DEBUG_LOG_TRACE("usb_class_audio_control_init, SUCCESSFUL");
    else
        DEBUG_LOG_TRACE("usb_class_audio_control_init, FAILED");
#endif

} /* Endbody */
Пример #14
0
void usb_host_mass_device_event
   (
      /* [IN] pointer to device instance */
      _usb_device_instance_handle      dev_handle,

      /* [IN] pointer to interface descriptor */
      _usb_interface_descriptor_handle intf_handle,

      /* [IN] code number for event causing callback */
      uint_32           event_code
   )
{
   INTERFACE_DESCRIPTOR_PTR   intf_ptr =
      (INTERFACE_DESCRIPTOR_PTR)intf_handle;

   switch (event_code) {
      case USB_CONFIG_EVENT:
         /* Drop through into attach, same processing */
      case USB_ATTACH_EVENT:
         if (device.STATE == USB_DEVICE_IDLE ||
            device.STATE == USB_DEVICE_DETACHED)
         {
            device.DEV_HANDLE = dev_handle;
            device.INTF_HANDLE = intf_handle;
            device.STATE = USB_DEVICE_ATTACHED;
            device.SUPPORTED = TRUE;
            _lwevent_set(&USB_Event,USB_EVENT);
         }
         break;
      case USB_INTF_EVENT:
         device.STATE = USB_DEVICE_INTERFACED;
         break;
      case USB_DETACH_EVENT:
         device.DEV_HANDLE = NULL;
         device.INTF_HANDLE = NULL;
         device.STATE = USB_DEVICE_DETACHED;
         _lwevent_set(&USB_Event,USB_EVENT);
         break;
      default:
         device.STATE = USB_DEVICE_IDLE;
         break;
   } 
} 
// Kalman filter sensor fusion task
void Fusion_task(uint32_t task_init_data)
{
	uint16_t LedGreenCounter = 0;

	// initialize the sensor fusion algorithms
	Fusion_Init();

	// initialize the user medium frequency (typically 25Hz) task
	UserMediumFrequencyTaskInit();

	// infinite loop controlled by MQX-Lite events
	while(1)
	{
		// ensure the red LED (power up check) is off (line high)
		LED_RED_SetVal(NULL);
		
		// set the output test pin to zero (for timing measurements)
		TestPin_KF_Time_ClrVal(NULL);

		// wait for the sensor fusion event to occur
		// FALSE means any bit (of the 1 bit enabled by the mask) unblocks
		// and NULL means timeout is infinite
		_lwevent_wait_for(&(mqxglobals.RunKFEventStruct), 1, FALSE, NULL);

		// set the output test pin to high to denote sensor fusion running
		TestPin_KF_Time_SetVal(NULL);

		// flash the green LED to denote the sensor fusion is running
		if (++LedGreenCounter >= 5)
		{
			LED_GREEN_NegVal(NULL);
			LedGreenCounter = 0;
		}

		// reset the magnetic calibration flag (this is set by the fusion algorithm)
		mqxglobals.MagCal_Event_Flag = 0;
		// call the sensor fusion algorithms
		Fusion_Run();

		// run the user medium frequency (typically 25Hz) user task
		UserMediumFrequencyTaskRun();

		// enable the magnetic calibration event if the flag for a new magnetic calibration
		// with a mask of 1 (least significant bit set)
		// was set by the sensor fusion algorithms
		if (mqxglobals.MagCal_Event_Flag)
		{
			_lwevent_set(&(mqxglobals.MagCalEventStruct), 1);
		}

	} // end of infinite loop

	return;
}
Пример #16
0
void button_task
(
    uint32_t initial_data
)
{

    LWGPIO_STRUCT   button;
    LWGPIO_VALUE    button_state      = LWGPIO_VALUE_HIGH;
    uint32_t        button_integrator = BUTTON_INTEGRATOR_MAXIMUM;

    /* set the pin to input */
    if (!lwgpio_init(&button, BSP_BUTTON2, LWGPIO_DIR_INPUT, LWGPIO_VALUE_NOCHANGE))    {
        /* Button initialization failed. */
        _task_block();
    }

    /* Set multiplexer to GPIO functionality */
    lwgpio_set_functionality(&button, BSP_SW2_MUX_GPIO);
    /* Enable pull up */
    lwgpio_set_attribute(&button, LWGPIO_ATTR_PULL_UP, LWGPIO_AVAL_ENABLE);

    while(1)
    {

        /* Update the integrator based on the input signal. */
        if (LWGPIO_VALUE_LOW == lwgpio_get_value(&button))        {
            if (button_integrator > 0)  {
                button_integrator--;
            }
        }
        else if (button_integrator < BUTTON_INTEGRATOR_MAXIMUM)    {
            button_integrator++;
        }

        /* Defensive code if integrator got corrupted */
        if (button_integrator > BUTTON_INTEGRATOR_MAXIMUM)
            button_integrator = BUTTON_INTEGRATOR_MAXIMUM;


        /* Post event if integrator reaches limit */
        if ((button_integrator == 0) )   {
            if (button_state == LWGPIO_VALUE_LOW) {
                button_state = LWGPIO_VALUE_HIGH;
                _lwevent_set(&app_event, SW_EVENT_MASK);
            }
        }
        else {
            button_state = LWGPIO_VALUE_LOW;
        }

        _time_delay(BUTTON_SAMPLE_PERIOD_MS);
    }
}
Пример #17
0
static int usb_host_aoa_in_tr_callback
#else
static void usb_host_aoa_in_tr_callback
#endif
(  /* device to host */
    /* [IN] pointer to pipe */
    _usb_pipe_handle pipe_handle,
    
    /* [IN] user-defined parameter */
    void * user_parm,
    
    /* [IN] buffer address */
    unsigned char * buffer,
    
    /* [IN] length of data transferred */
    uint32_t  buflen,
    
    /* [IN] status, hopefully USB_OK or USB_DONE */
    uint32_t status )
{
    struct _usb_accessoy_host_info_  * acc_host_info = (struct _usb_accessoy_host_info_  *)user_parm;
#ifdef ACCESSORY_PRINTF
    printf("receive status=%d, buff len %d\n",status,buflen);
#endif

    if(status == USB_OK) {
        acc_host_info->received_size = buflen;
        _lwevent_set(&(acc_host_info->acc_event),USBH_AOA_RECV_COMP_EVENT);
    }
    else {
        acc_host_info->received_size = 0;
        _lwevent_set(&(acc_host_info->acc_event),USBH_AOA_RECV_FAIL_EVENT);
    }
    
#ifdef TR_CALLBACK_COMPLETE
    return TR_CALLBACK_COMPLETE;
#endif
    
}
Пример #18
0
void simulated_ISR_task 
   (
      uint_32 initial_data
   )
{

   while (TRUE) {
      _time_delay_ticks(200);
      if (_lwevent_set(&lwevent,0x01) != MQX_OK) {
         printf("\nSet Event failed");
         _task_block();
      }
   }
}
Пример #19
0
static void timer_wakeup_isr
    (
        void   *parameter
    )
{
    /* Stop the timer */
    hwtimer_stop(&lpttimer);
    
    /* Do not return to sleep after isr again */
    _lpm_wakeup_core ();

    /* Signal the timer event */
    _lwevent_set (&app_event, TIMER_EVENT_MASK);
}
Пример #20
0
void FTM_OnCounterRestart(LDD_TUserData *UserDataPtr)
{
	// this function is called (typically at 200Hz) by the hardware clock interrupt and drives the sensor
	// read function and indirectly the fusion and magnetic calibration functions which
	// are software locked to the sensor read process

	// always enable the sensor read task
	// update time stamp counter
	mqxglobals.FTMTimestamp += (uint32)mqxglobals.FTMReload;
	// enable the (typically 200Hz) sensor read event FSL_SAMPLING_EVENT
	// with a mask of 1 (least significant bit set)
	_lwevent_set(&(mqxglobals.SamplingEventStruct), 1);

	return;
}
Пример #21
0
void usb_host_hid_recv_callback(
    /* [IN] pointer to pipe */
    _usb_pipe_handle pipe_handle,
    /* [IN] user-defined parameter */
    pointer user_parm,
    /* [IN] buffer address */
    uchar_ptr buffer,
    /* [IN] length of data transferred */
    uint_32 buflen,
    /* [IN] status, hopefully USB_OK or USB_DONE */
    USB_STATUS status
)
{
    /* notify application that data are available */
    _lwevent_set(&USB_Event, USB_EVENT_DATA);
}
Пример #22
0
/*TASK---------------------------------------------------------------
*
* Task Name   :  LWEventA
* Comments    :
*
*END*--------------------------------------------------------------*/
void LWEventA
   (
      uint32_t   parameter
   )
{
   _mqx_uint event_result;

   while ( TRUE ) {
      /* set lwevent bit */
      event_result = _lwevent_set(&lwevent, 1);
      if (event_result != MQX_OK) {
         /* setting the event event.Event1 failed */
      } /* endif */
      _time_delay_ticks(1);
   }
}
Пример #23
0
static void my_rtc_isr
    (
        pointer rtc_registers_ptr
    )
{
    uint_32 state = _rtc_get_status ();

    if (state & RTC_RTCISR_ALM)
    {
        /* Do not return to sleep after isr again */
        _lpm_wakeup_core ();

        _lwevent_set(&app_event, RTC_EVENT_MASK);
    }
    _rtc_clear_requests (state);
}
Пример #24
0
void int_service_routine_btn_pause(void *pin)                  //SW1
{
    lwgpio_int_clear_flag((LWGPIO_STRUCT_PTR) pin);

    pause_trigger = !pause_trigger;
    if(TRUE == pause_trigger)            //pause a song
    {
        if((mp_sMicroSDplay == cur_musicPlayMS)||(mp_sMSDplay == cur_musicPlayMS))
        {
            _lwevent_clear(&player_event, PLAYER_EVENT_MSK_SONG_RESUME);
        }
        else if(mp_sAccessory == cur_musicPlayMS)
        {
            //AccessoryPausePlay();
            AccessroyHidEvent |= ACCPAUSEPLAY;
        }
        else if(mp_sBT == cur_musicPlayMS)
        {
            BtAVRCPEvent |= ACCPAUSEPLAY;
        }
        printf("Paused\n");
    }
    else                                //resume a song
    {
        if((mp_sMicroSDplay == cur_musicPlayMS)||(mp_sMSDplay == cur_musicPlayMS))
        {
            _lwevent_set(&player_event, PLAYER_EVENT_MSK_SONG_RESUME);
        }
        else if(mp_sAccessory == cur_musicPlayMS)
        {
            //AccessoryResumePlay();
            AccessroyHidEvent |= ACCRESUMEPLAY;
        }
        else if(mp_sBT == cur_musicPlayMS)
        {
            BtAVRCPEvent |= ACCRESUMEPLAY;
        }
        printf("Resume\n");
    }

    //decoding = FALSE;
    //printf("SW1 pressed. %d \n", trigger);
}
Пример #25
0
void LWEventA
   (
      uint_32   parameter
   )
{
   _mqx_uint event_result;

   /* 
   ** LOOP - 
   */
   while ( TRUE ) {
      /* set lwevent bit */
      event_result = _lwevent_set(&lwevent, 1);
      if (event_result != MQX_OK) {
         /* setting the event event.Event1 failed */
      } /* endif */
      _time_delay_ticks(1);
   } /* endwhile */ 
} /*end of task*/
Пример #26
0
int usb_try_accessory_callback
#else
void usb_try_accessory_callback
#endif
   (
      /* [IN] pointer to pipe */
      _usb_pipe_handle  pipe_handle,

      /* [IN] user-defined parameter */
      void *           user_parm,

      /* [IN] buffer address */
      unsigned char *         buffer,

      /* [IN] length of data transferred */
      uint32_t           length_data_transfered,

      /* [IN] status, hopefully USB_OK or USB_DONE */
      USB_STATUS        status
   )
{ /* Body */
    struct _usb_accessoy_host_info_  * acc_host_info = (struct _usb_accessoy_host_info_  *)user_parm;
    if(status == USB_OK) {
        _lwevent_set(&(acc_host_info->acc_event), USBH_TRY_AOA_CALLBACK_EVENT);
        acc_host_info->try_acc_status++; // this function will be called by accessory hid .
        printf("try accessory callback ok\n");
    }
    else
        printf("try accessory callback fail\n");

#if 1
    if(acc_host_info->try_acc_status >= WAITING_ACCESSORY) {
        LWGPIO_STRUCT  vbus;
        init_set_vbus_low(&vbus);
        delay_set_vbus_high(&vbus);
    }
#endif    

#ifdef TR_CALLBACK_COMPLETE
    return TR_CALLBACK_COMPLETE;
#endif
}
Пример #27
0
void int_service_routine_btn_stop(void *pin)                   //SW2
{

    lwgpio_int_clear_flag((LWGPIO_STRUCT_PTR) pin);
#if 0
    //_lwevent_set(&player_event, PLAYER_EVENT_MSK_PREV_BTN_PRESSED);

    if(TRUE == trigger)
        _lwevent_set(&player_event, PLAYER_EVENT_MSK_SONG_RESUME);    //if pause a song, resume firstly

    decoding = FALSE;

#endif
    if ((ModeSwitchEvent & MODESWITCH) == 0)
        ModeSwitchEvent |= MODESWITCH;
    printf("Auto\n");


    //printf("SW2 pressed.\n");
}
Пример #28
0
static void SAMPLE_TIMER_ISR(void * p)
{
    VQPIT_REG_STRUCT_PTR  qpit_ptr = sample_qpit_ptr;
    qpit_ptr->TIMERS[SAMPLE_PIT_CH].TFLG |= QPIT_TFLG_TIF;
    qpit_ptr->TIMERS[SAMPLE_PIT_CH].TCTRL &= (~ QPIT_TCTRL_TIE); // ~(QPIT_TCTRL_TIE|QPIT_TCTRL_TEN)
	// todo
	if(WAIT_START_SAMPLE_STATE == sample_state){
		// set wait sample stop time
            sample_timer_set(0, 0,STOP_SAMPLE_TIME_US);
		sample_state = WAIT_STOP_SAMPLE_STATE;
		// set event ,could sample adc
#ifdef ALWAYS_SAMPLING
	   sample_value = adc_measure_pm2p5();
#else
		_lwevent_set(&sample_event, 1);
#endif
	}
        else if (WAIT_STOP_SAMPLE_STATE == sample_state) {
            sample_timer_set(0, SAMPLE_PERIOD_TIME_MS,SAMPLE_PERIOD_TIME_US);
		sample_state = WAIT_NEXT_START_STATE;
		// set led low
		lwgpio_set_value(&pm2p5_ledgpio, SAMPLE_LED_LOW);
		sample_value = 0;
        } 
	else if(WAIT_NEXT_START_STATE == sample_state) {
        sample_timer_set(0, 0 ,START_SAMPLE_TIME_US);
		sample_state = WAIT_START_SAMPLE_STATE;
		// set led high
		lwgpio_set_value(&pm2p5_ledgpio, SAMPLE_LED_HIGH);

		//_lwevent_set(&sample_event, 1);

	}
	else {
		printf("error sample state!\n");
	}

    /* Enable PIT interrupt neeed due to errata on Kinetis PIT */
    qpit_ptr->TIMERS[SAMPLE_PIT_CH].TCTRL |= QPIT_TCTRL_TIE;
}
Пример #29
0
/*FUNCTION*----------------------------------------------------------------
*
* Function Name  : usb_class_audio_int_callback
* Returned Value : None
* Comments       :
*     Called on interrupt endpoint data reception.
*
*END*--------------------------------------------------------------------*/
static void usb_class_audio_int_callback
(
    /* [IN] pointer to pipe */
    _usb_pipe_handle  pipe,

    /* [IN] user-defined parameter */
    void             *param,

    /* [IN] buffer address */
    void             *buffer,

    /* [IN] length of data transferred */
    uint32_t           len,

    /* [IN] status, hopefully USB_OK or USB_DONE */
    uint32_t           status
)
{ /* Body */
    CLASS_CALL_STRUCT_PTR         audio_instance = (CLASS_CALL_STRUCT_PTR) param;
    AUDIO_CONTROL_INTERFACE_STRUCT_PTR if_ptr;

#ifdef _HOST_DEBUG_
    DEBUG_LOG_TRACE("usb_class_audio_int_callback");
#endif
    if_ptr = (AUDIO_CONTROL_INTERFACE_STRUCT_PTR) audio_instance->class_intf_handle;

#ifdef _HOST_DEBUG_
    DEBUG_LOG_TRACE("usb_class_audio_int_callback, SUCCESSFUL");
#endif

    if (NULL!=pipe)
    {
        if_ptr->interrupt_callback(pipe,param,buffer,len,status);
    }

    usb_class_audio_init_ipipe(audio_instance,if_ptr->interrupt_callback,if_ptr->interrupt_callback_param);

    _lwevent_set(&USB_Event, USB_EVENT_DATA);

} /*EndBody */
Пример #30
0
int_32 Shell_play(int_32 argc, char_ptr argv[]) {
	boolean print_usage, shorthelp = FALSE;
	int_32 return_code = SHELL_EXIT_ERROR;
	char_ptr c = NULL;
	
	print_usage = Shell_check_help_request(argc, argv, &shorthelp);

	/* Check if help should be printed out */
	if (print_usage) {
		if (shorthelp) {
			printf("%s <device> <filename>\n", argv[0]);
		} else {
			printf("Usage: %s <device> <filename>\n", argv[0]);
			printf("   device        = playback device (i.e. \"sai:\")\n");
			printf("   filename      = file(mp3/wma/wav) to play\n");
		}
		return (SHELL_EXIT_SUCCESS);
	}
	
	/* Check if there is enough parameters */
	if (argc < 3) {
		printf("  Error: Not enough parameters.\n");
		return (SHELL_EXIT_ERROR);
	}
	
	
	strcpy(full_path, argv[2]);
	// get the short file name
	c = argv[2];
	while(*c != '\0') c++;
	while((*c != '\\') && (*c !='/')) c--;
	c++;
	// update the current file name for file searching.
	set_cur_file(c);
	
	_lwevent_set(&player_event, PLAYER_EVENT_MSK_SHELL_COMMAND);

	return (return_code);
}