Exemple #1
0
void platform_adc_stop( unsigned id )
{
  elua_adc_ch_state *s = adc_get_ch_state( id );
  elua_adc_dev_state *d = adc_get_dev_state( 0 );

  s->op_pending = 0;
  INACTIVATE_CHANNEL( d, id );
  AD1CSSLCLR = (1 << id);
  AD1PCFGSET = (1 << id);

  // If there are no more active channels, stop the sequencer
  if( d->ch_active == 0 )
    d->running = 0;
}
Exemple #2
0
void platform_adc_stop( unsigned id )
{  
  elua_adc_ch_state *s = adc_get_ch_state( id );
  elua_adc_dev_state *d = adc_get_dev_state( 0 );
    
  s->op_pending = 0;
  INACTIVATE_CHANNEL( d, id );
  
  // If there are no more active channels, stop the sequencer
  if( d->ch_active == 0 && d->running == 1 )
  {
    d->running = 0;
    AD0CR &= 0xF8FFFF00; // stop ADC, disable channels
  }
}
Exemple #3
0
void platform_adc_stop( unsigned id )
{  
  elua_adc_ch_state *s = adc_get_ch_state( id );
  elua_adc_dev_state *d = adc_get_dev_state( 0 );
    
  s->op_pending = 0;
  INACTIVATE_CHANNEL( d, id );
  
  // If there are no more active channels, stop the sequencer
  if( d->ch_active == 0 && d->running == 1 )
  {
    d->running = 0;
    NVIC_DisableIRQ( ADC_IRQn );
  }
}
Exemple #4
0
u32 platform_adc_op( unsigned id, int op, u32 data )
{  
  elua_adc_ch_state *s = adc_get_ch_state( id );
  elua_adc_dev_state *d = adc_get_dev_state( 0 );
  u32 res = 0;

  switch( op )
  {
    case PLATFORM_ADC_GET_MAXVAL:
      res = pow( 2, ADC_BIT_RESOLUTION ) - 1;
      break;

    case PLATFORM_ADC_SET_SMOOTHING:
      res = adc_update_smoothing( id, ( u8 )intlog2( ( unsigned ) data ) );
      break;
      
    case PLATFORM_ADC_SET_BLOCKING:
      s->blocking = data;
      break;
      
    case PLATFORM_ADC_IS_DONE:
      res = ( s->op_pending == 0 );
      break;
    
    case PLATFORM_ADC_OP_SET_TIMER:
      if ( d->timer_id != data )
        d->running = 0;
      platform_adc_stop( id );
      d->timer_id = data;
      break;
    
    case PLATFORM_ADC_OP_SET_CLOCK:
      res = platform_adc_setclock( id, data );
      break;
      
    case PLATFORM_ADC_SET_FREERUNNING:
      s->freerunning = data;
      break;
  }
  return res;
}
Exemple #5
0
u32 platform_adc_is_done( unsigned id )
{
  return adc_get_ch_state( id )->op_pending == 0;
}
Exemple #6
0
void platform_adc_set_freerunning( unsigned id, u32 mode )
{
  adc_get_ch_state( id )->freerunning = mode;
}
Exemple #7
0
void platform_adc_set_blocking( unsigned id, u32 mode )
{
  adc_get_ch_state( id )->blocking = mode;
}