Ejemplo n.º 1
0
// (adc-setclock 'num 'num 'num) -> num
any plisp_adc_setclock(any ex) {
  s32 sfreq; // signed version for negative checking.
  u32 freq;
  unsigned id, timer_id = 0;
  any x, y;

  x = cdr(ex);
  NeedNum(ex, y = EVAL(car(x)));
  id = unBox(y); // get adc id.
  MOD_CHECK_ID(ex, adc, id);

  x = cdr(x);
  NeedNum(ex, y = EVAL(car(x)));
  sfreq = unBox(y); // get frequency.
  if (sfreq < 0)
    err(ex, y, "frequency must be 0 or positive");

  freq = (u32) sfreq;
  if (freq > 0) {
    x = cdr(x);
    NeedNum(ex, y = EVAL(car(x)));
    timer_id = unBox(y); // get timer id.
    MOD_CHECK_ID(ex, timer, timer_id);
    MOD_CHECK_RES_ID(ex, adc, id, timer, timer_id);
  }

  platform_adc_set_timer(id, timer_id);
  freq = platform_adc_set_clock(id, freq);
  return box(freq);
}
Ejemplo n.º 2
0
void platform_setup_adcs()
{
  unsigned id;

  for( id = 0; id < NUM_ADC; id ++ )
    adc_init_ch_state( id );
  
  CloseADC10();   // Ensure the ADC is off before setting the configuration
  OpenADC10(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5);
  ConfigIntADC10(ADC_INT_ON | ADC_INT_PRI_3 | ADC_INT_SUB_PRI_1);

  platform_adc_set_clock( 0, 0 );
}
Ejemplo n.º 3
0
static void platform_setup_adcs()
{
  unsigned id;
  
  for( id = 0; id < NUM_ADC; id ++ )
    adc_init_ch_state( id );
  
  NVIC_SetPriority(ADC_IRQn, ((0x01<<3)|0x01));

  ADC_Init(LPC_ADC, 13000000);
  
  // Default enables CH0, disable channel
  ADC_ChannelCmd( LPC_ADC, 0, DISABLE );
  
  // Default enables ADC interrupt only on global, switch to per-channel
  ADC_IntConfig( LPC_ADC, ADC_ADGINTEN, DISABLE );
    
  platform_adc_set_clock( 0, 0 );
}
Ejemplo n.º 4
0
// PicoC: realclock = adc_setclock(id, freq, timer_id);
static void adc_setclock(pstate *p, val *r, val **param, int n)
{
  s32 sfreq; // signed version for negative checking
  u32 freq;
  unsigned id, timer_id = 0;
  
  id = param[0]->Val->UnsignedInteger;
  MOD_CHECK_ID(adc, id);
  sfreq = param[1]->Val->LongInteger;
  if (sfreq < 0)
    return pmod_error("frequency must be 0 or positive");
  freq = (u32) sfreq;
  if (freq > 0) {
    timer_id = param[2]->Val->UnsignedInteger;
    MOD_CHECK_ID(timer, timer_id);
    MOD_CHECK_RES_ID(adc, id, timer, timer_id);
  }
  
  platform_adc_set_timer(id, timer_id);
  freq = platform_adc_set_clock(id, freq);
  r->Val->UnsignedLongInteger = freq;
}
Ejemplo n.º 5
0
// Lua: realclock = setclock( id, freq, [timer_id] )
static int adc_setclock( lua_State *L )
{
	s32 sfreq; // signed version for negative checking
	u32 freq;
	unsigned id, timer_id = 0;

	id = luaL_checkinteger( L, 1 );
	MOD_CHECK_ID( adc, id );
	sfreq = luaL_checkinteger( L, 2 );
	if ( sfreq < 0 )
		return luaL_error( L, "frequency must be 0 or positive" );
	freq = ( u32 ) sfreq;
	if ( freq > 0 ) {
		timer_id = luaL_checkinteger( L, 3 );
		MOD_CHECK_ID( timer, timer_id );
		MOD_CHECK_RES_ID( adc, id, timer, timer_id );
	}

	platform_adc_set_timer( id, timer_id );
	freq = platform_adc_set_clock( id, freq );
	lua_pushinteger( L, freq );
	return 1;
}