2010년 5월 13일 목요일

T2에서의 ADC Mapping

* Configuration *
generic configuration TestC() {
  provides interface DeviceMetadata;
  provides interface Read<uint16_t> as Test;
  provides interface ReadStream<uint16_t>;
}
implementation {
  components new AdcReadClientC();
  Test = ADCReadClientC;
  components new AdcReadStreamClientC();
  ReadStream = AdcReadStreamClientC;
  components TestP;
  DeviceMetadata = TestP;
  AdcReadClientC.AdcConfigure –> TestP;
  AdcReadStreamClientC.AdcConfigure –> TestP;
}

* Module *
#include “Msp430Adc12.h”
module TestP {
  provides interface DeviceMetadata;
  provides interface AdcConfigure<const msp430adc12_channel_config_t *>
}
implementation {
  msp430adc12_channel_config_t config = {
    inch:INPUT_CHANNEL_A2,
    sref:REFERENCE_VREFplus_AVss,
    ref2_5v:REFVOLT_LEVEL_1_5,
    adc12ssel:SHT_SOURCE_ACLK,
    adc12div:SHT_CLOCK_DIV_1,
    sht:SAMPLE_HOLD_4_CYCLES,
    sampcon_ssel:SAMPCON_SOURCE_SMCLK,
    sampcon_id:SAMPCON_CLOCK_DIV_1
  };
  command uint8_t DeviceMetadata.getSignificantBits() {
    return 12;
  }
  async command const msp430adc12_channel_config_t * AdcConfigure.getConfiguration() {
    return &config;
  }
}

위와 같이 컴포넌트를 작성하여 최상위 어플리케이션에서 wiring을 통해 사용하면 된다.

댓글 없음:

댓글 쓰기