コード例 #1
0
/*!
 *  \brief The set bicolor ledb2 value command: set the value of the bicolor ledb2.
 *         Takes up to six parameters
 *         the first parameter is the green parameter, the second parameter is its value in [0,255],
 *         the third parameter is the red parameter, the fourth parameter is its value in [0,255],
 *         the fifth is the time parameter(optional), the sixth is the time value(optional) expressed in seconds.
 *         Format: set_actuator_value actuator=actuatorname green=value red=value [time=date]
 *
 *  \note  This function must be of the type pfShellCmd defined by the shell module.
 *
 *  \param xModId         Input. The module that is calling this function.
 *  \param ac             Input. The argument counter. For this command, should be
 *                        at least 4, at most 6.
 *  \param av             Input. The argument vector.
 *  \param ppcStringReply Input/Output. The response string.
 *                        If Input is NULL, no response string will be output.
 *                        Else a malloc for the response string is performed here;
 *                        the caller must free this string.
 *
 *  \return the status of the command execution.
 */
eExecStatus e_ledb2_set_value( eModId xModId, int ac, signed portCHAR *av[],
                               signed portCHAR **ppcStringReply )
{
   /* 1) Check the input. */
   //  i) Arguments: at least 4, at most 6.
   if( ( 4 > ac ) || ( 6 < ac ) )
   {   // Syntax error.
      *ppcStringReply = (signed portCHAR *)ACTUATOR_ERRMSG_SETVAL_SYNTAXERROR;
      return( SHELL_EXECSTATUS_KO );
   }

   //  ii) Check that the 1st arg is 'green' and that the 3rd is 'red'.
   if( strcmp( (char *)av[0], "green" ) || strcmp( (char *)av[2], "red" ))
   {
      *ppcStringReply = (signed portCHAR *)ACTUATOR_ERRMSG_SETVAL_SYNTAXERROR;
      return( SHELL_EXECSTATUS_KO );
   }

   //  iii) If there is a fifth parameter, check that it is equal to "time" and
   // record a new scheduling.
   if( 6 == ac )
   {
      return( e_actuator_ScheduleCmdSet( CPTIME_SCHEDCMDID_SETLEDB2VAL, ac, av, ppcStringReply ) );
   }

   /* 2) Set the val. */
   LED_Set_Intensity( LEDB2G, atoi( (char *)av[1] ) );
   LED_Set_Intensity( LEDB2R, atoi( (char *)av[3] ) );

   return( SHELL_EXECSTATUS_OK );
}
コード例 #2
0
ファイル: cpled.c プロジェクト: kerichsen/asf
/*  \brief Set the intensity of the LED which are On to a specific value.
 *
 *  \param intensity      Input. The LED intensity (0% to 100%)
 *
 *  \return the status of the command execution.
 */
bool e_ledm_refresh_intensity( U32 intensity )
{
   // Adjust LED intensity
   if( LED_Test( LED_MONO0_GREEN ) ) LED_Set_Intensity(LED_MONO0_GREEN, intensity);
   if( LED_Test( LED_MONO1_GREEN ) ) LED_Set_Intensity(LED_MONO1_GREEN, intensity);
   if( LED_Test( LED_MONO2_GREEN ) ) LED_Set_Intensity(LED_MONO2_GREEN, intensity);
   if( LED_Test( LED_MONO3_GREEN ) ) LED_Set_Intensity(LED_MONO3_GREEN, intensity);
   return true;
}
コード例 #3
0
ファイル: device_audio_task.c プロジェクト: Mazetti/asf
void device_audio_task(void)
#endif
{
#if( BOARD!=EVK1105) || (DEFAULT_DACS!=AUDIO_MIXER_DAC_AIC23B)
  uint32_t  i;
#endif
  uint32_t  fifo_cnt;
  int  stream_status;

#ifdef FREERTOS_USED
  portTickType xLastWakeTime;
  xLastWakeTime = xTaskGetTickCount();
  LED_On(LED0);

  while (true)
  {
    vTaskDelayUntil(&xLastWakeTime, configTSK_USB_DAUDIO_PERIOD);

    // First, check the device enumeration state
    if (!Is_device_enumerated()) { mmi_state=0; continue; }
#else
    // First, check the device enumeration state
    if (!Is_device_enumerated()) { mmi_state=0; return; }
#endif  // FREERTOS_USED

    mmi_display();

#if( BOARD!=EVK1105) || (DEFAULT_DACS!=AUDIO_MIXER_DAC_AIC23B)
    // Microphone emulation
    //
    if ( is_joystick_pressed() )
    {
       if (Is_usb_write_enabled(EP_AUDIO_IN))   // Endpoint buffer free ?
       {
          Usb_reset_endpoint_fifo_access(EP_AUDIO_IN);
          for( i=0 ; i<EP_SIZE_IN ; i++ )   // Fill endpoint with sample raw
          {
             if(mute==false)
             {
                uint8_t sample;
                sample = sample_sound[dat_sample_index++];
                LED_Set_Intensity(LED0, sample);
                Usb_write_endpoint_data(EP_AUDIO_IN, 8, sample);
                if (dat_sample_index >= SAMPLE_SOUND_LEN)
                {  dat_sample_index=0; }
             }
             else
             {
                LED_Set_Intensity(LED0, 0);
                Usb_write_endpoint_data(EP_AUDIO_IN, 8, 0x00);
             }
          }
          Usb_ack_in_ready_send(EP_AUDIO_IN);
       }
    }
#else
    // Handle input stream from microphone
    if( !b_microphone_started && (Is_usb_write_enabled(EP_AUDIO_IN)) && audio_mixer_dacs_input(NULL, 0) )
    {
      // Start ADC conversion. This will launch the IRL in background...
      mic_buf_id = 0;
      mic_frame_id=2;
      microphone[mic_buf_id].size=45;
      audio_mixer_dacs_input(microphone[0].buffer, 45 /*microphone[mic_buf_id].size*/);
      audio_mixer_dacs_input(microphone[1].buffer, 45 /*microphone[mic_buf_id].size*/);
      b_microphone_started=true;
    }
#endif



    // Handle incoming audio samples
    //
    if((Is_usb_out_received(EP_AUDIO_OUT) )
    /*&& (Is_usb_stall(EP_AUDIO_OUT)==false)*/)
    {
       stream_status = usb_stream_input(USB_STREAM_DEVICE, EP_AUDIO_OUT, &fifo_cnt);
       Usb_ack_out_received_free(EP_AUDIO_OUT);
       mmi_activity_display(false, fifo_cnt);
    }
#if USB_RESYNC_AUDIO_STREAM && (USB_RESYNC_AUDIO_STREAM==true)
    usb_stream_resync();
#endif

#ifdef FREERTOS_USED
  }
#endif
}