Sha256: c6c245b44e5e11ed833470bb07ed178ec9706bc19121dc16de59a2e090530e03

Contents?: true

Size: 1.3 KB

Versions: 37

Compression:

Stored size: 1.3 KB

Contents

#include "unity.h"
#include "Types.h"
#include "AdcTemperatureSensor.h"
#include "AT91SAM7X256.h"

AT91S_ADC AdcPeripheral;

void setUp(void)
{
}

void tearDown(void)
{
}

void testShouldStartTemperatureSensorConversionWhenTriggered(void)
{
  AT91C_BASE_ADC->ADC_CR = 0;
  Adc_StartTemperatureSensorConversion();
  TEST_ASSERT_EQUAL(AT91C_ADC_START, AT91C_BASE_ADC->ADC_CR);
}

void testTemperatureSensorSampleReadyShouldReturnChannelConversionCompletionStatus(void)
{
  AT91C_BASE_ADC->ADC_SR = 0;
  TEST_ASSERT_EQUAL(FALSE, Adc_TemperatureSensorSampleReady());
  AT91C_BASE_ADC->ADC_SR = ~AT91C_ADC_EOC4;
  TEST_ASSERT_EQUAL(FALSE, Adc_TemperatureSensorSampleReady());
  AT91C_BASE_ADC->ADC_SR = AT91C_ADC_EOC4;
  TEST_ASSERT_EQUAL(TRUE, Adc_TemperatureSensorSampleReady());
  AT91C_BASE_ADC->ADC_SR = 0xffffffff;
  TEST_ASSERT_EQUAL(TRUE, Adc_TemperatureSensorSampleReady());
}

void testReadTemperatureSensorShouldFetchAndTranslateLatestReadingToMillivolts(void)
{
  uint16 result;

  // ADC bit weight at 10-bit resolution with 3.0V reference = 2.9296875 mV/LSB
  AT91C_BASE_ADC->ADC_CDR4 = 138;
  result = Adc_ReadTemperatureSensor();
  TEST_ASSERT_EQUAL(404, result);

  AT91C_BASE_ADC->ADC_CDR4 = 854;
  result = Adc_ReadTemperatureSensor();
  TEST_ASSERT_EQUAL(2502, result);
}

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
ceedling-0.29.1 vendor/cmock/examples/temp_sensor/test/TestAdcTemperatureSensor.c
ceedling-0.29.0 vendor/cmock/examples/temp_sensor/test/TestAdcTemperatureSensor.c
ceedling-0.18.0 vendor/cmock/examples/test/TestAdcTemperatureSensor.c
ceedling-0.17.0 vendor/cmock/examples/test/TestAdcTemperatureSensor.c
ceedling-0.16.0 vendor/cmock/examples/test/TestAdcTemperatureSensor.c
ceedling-0.15.6 vendor/cmock/examples/test/TestAdcTemperatureSensor.c
ceedling-0.15.5 vendor/cmock/examples/test/TestAdcTemperatureSensor.c
ceedling-0.15.4 vendor/cmock/examples/test/TestAdcTemperatureSensor.c
ceedling-0.15.3 vendor/cmock/examples/test/TestAdcTemperatureSensor.c
ceedling-0.15.2 vendor/cmock/examples/test/TestAdcTemperatureSensor.c
ceedling-0.15.1 vendor/cmock/examples/test/TestAdcTemperatureSensor.c
ceedling-0.15.0 vendor/cmock/examples/test/TestAdcTemperatureSensor.c
ceedling-0.13.0 vendor/cmock/examples/test/TestAdcTemperatureSensor.c
ceedling-0.12.2 examples/temp_sensor/test/test_AdcTemperatureSensor.c
ceedling-0.12.1 examples/temp_sensor/test/test_AdcTemperatureSensor.c
ceedling-0.12.0 examples/temp_sensor/test/test_AdcTemperatureSensor.c
ceedling-0.11.2 examples/temp_sensor/test/test_AdcTemperatureSensor.c
ceedling-0.11.1 examples/temp_sensor/test/test_AdcTemperatureSensor.c
ceedling-0.11.0 examples/temp_sensor/test/test_AdcTemperatureSensor.c
ceedling-0.10.0 examples/temp_sensor/test/test_AdcTemperatureSensor.c