24inline constexpr Channel chain[]{ Channel::V1, Channel::I1, Channel::V2, Channel::I2, Channel::V3, Channel::I3 };
27inline constexpr uint8_t
REF_MASK{ (1U << 7) | (1U << 6) };
28inline constexpr uint8_t
AVCC{ 1U << 6 };
35 const uint8_t pin{
static_cast< uint8_t
>(admux &
MUX_MASK) };
43 TEST_FAIL_MESSAGE(
"ADMUX selects an input that is no channel of the chain");
51 TEST_ASSERT_EQUAL_UINT8(0,
static_cast< uint8_t
>(Channel::V1));
52 TEST_ASSERT_EQUAL_UINT8(1,
static_cast< uint8_t
>(Channel::I1));
53 TEST_ASSERT_EQUAL_UINT8(2,
static_cast< uint8_t
>(Channel::V2));
54 TEST_ASSERT_EQUAL_UINT8(3,
static_cast< uint8_t
>(Channel::I2));
55 TEST_ASSERT_EQUAL_UINT8(4,
static_cast< uint8_t
>(Channel::V3));
56 TEST_ASSERT_EQUAL_UINT8(5,
static_cast< uint8_t
>(Channel::I3));
69 static_assert(
AdcChain::pinOf(Channel::I3) == 5,
"pinOf() must be constexpr");
100 TEST_ASSERT_EQUAL_UINT8(
static_cast< uint8_t
>(Channel::V1),
static_cast< uint8_t
>(
AdcChain::channelAfterNext(Channel::V3)));
101 TEST_ASSERT_EQUAL_UINT8(
static_cast< uint8_t
>(Channel::I1),
static_cast< uint8_t
>(
AdcChain::channelAfterNext(Channel::I3)));
119 for (uint8_t round = 0; round != 30; ++round)
128 constexpr uint8_t ROUNDS{ 60 };
133 uint8_t admuxOf[ROUNDS + 2]{};
139 for (uint8_t round = 0; round != ROUNDS; ++round)
145 TEST_ASSERT_EQUAL_UINT8(
static_cast< uint8_t
>(believed),
static_cast< uint8_t
>(
channelOfAdmux(admuxOf[round])));
163 constexpr Former former[6]{
177 const Former &f{ former[
static_cast< uint8_t
>(ch)] };
178 TEST_ASSERT_EQUAL_UINT8(f.index,
static_cast< uint8_t
>(ch));
The six ADC conversions of the 3-phase board, and the ADMUX pipeline of the free-running ADC.
constexpr Channel channelAfterNext(const Channel ch)
The channel two steps after another one in the chain V1, I1, V2, I2, V3, I3.
constexpr Channel channelConverted(const uint8_t round)
The channel round round converts, once the pipeline is full.
constexpr uint8_t admuxOf(const PcbVersion board, const Channel ch)
The ADMUX value that converts a channel: reference, left-adjusted result, analog input.
constexpr uint8_t refBits(const PcbVersion board)
The reference bits of ADMUX on a board.
constexpr uint8_t admuxWrittenAfter(const PcbVersion board, const Channel converted)
The ADMUX value the interrupt writes after the conversion of a channel.
constexpr uint8_t NO_OF_CONVERSIONS
constexpr uint8_t pinOf(const Channel ch)
The analog input of a channel (A0 = 0).
void test_reference_per_board(void)
constexpr uint8_t REF_MASK
constexpr uint8_t ADLAR_BIT
void test_admux_of_is_reference_adlar_and_pin(void)
void test_channel_converted_by_round(void)
void test_channel_table_matches_the_former_literals(void)
void test_after_next_of_every_position(void)
constexpr uint8_t INTERNAL_1V1
void test_admux_written_after_selects_the_channel_after_next(void)
constexpr Channel chain[]
constexpr PcbVersion boards[]
constexpr uint8_t MUX_MASK
void test_pipeline_order(void)
void test_order_of_the_chain(void)
static Channel channelOfAdmux(const uint8_t admux)
The channel an ADMUX value selects, from its analog input.