3-phase PV router
Loading...
Searching...
No Matches
test_main.cpp File Reference

Native tests for adc_chain.h: the six conversions, the reference and the ADMUX pipeline. More...

#include <unity.h>
#include "adc_chain.h"
Include dependency graph for test_main.cpp:

Go to the source code of this file.

Enumerations

enum class  Channel
 

Functions

static Channel channelOfAdmux (const uint8_t admux)
 The channel an ADMUX value selects, from its analog input.
 
int main (int, char **)
 
void setUp (void)
 
void tearDown (void)
 
void test_admux_of_is_reference_adlar_and_pin (void)
 
void test_admux_written_after_selects_the_channel_after_next (void)
 
void test_after_next_of_every_position (void)
 
void test_channel_converted_by_round (void)
 
void test_channel_table_matches_the_former_literals (void)
 
void test_order_of_the_chain (void)
 
void test_pins (void)
 
void test_pipeline_order (void)
 
void test_reference_per_board (void)
 

Variables

constexpr uint8_t ADLAR_BIT { 1U << 5 }
 
constexpr uint8_t AVCC { 1U << 6 }
 
constexpr PcbVersion boards [] { PcbVersion::OLD, PcbVersion::NEW }
 
constexpr Channel chain [] { Channel::V1, Channel::I1, Channel::V2, Channel::I2, Channel::V3, Channel::I3 }
 
constexpr uint8_t INTERNAL_1V1 { (1U << 7) | (1U << 6) }
 
constexpr uint8_t MUX_MASK { 0x0F }
 
constexpr uint8_t REF_MASK { (1U << 7) | (1U << 6) }
 

Detailed Description

Native tests for adc_chain.h: the six conversions, the reference and the ADMUX pipeline.

The ADC converts six channels in a fixed chain V1, I1, V2, I2, V3, I3. It runs free: when the ISR of a finished conversion runs, the next conversion has already started with the previous ADMUX, so the ADMUX written now applies to the conversion after next. The pipeline test plays this out and checks that the channel really converted is the one the ISR believes it handles, on each board. The last test pins the values of the table that processing.cpp wrote by hand before it was built from adc_chain.h.

Definition in file test_main.cpp.

Enumeration Type Documentation

◆ Channel

enum class AdcChain::Channel : uint8_t
strong

The six conversions, in the order of the chain: a V then an I, for each phase

Definition at line 34 of file adc_chain.h.

Function Documentation

◆ channelOfAdmux()

static Channel channelOfAdmux ( const uint8_t admux)
static

The channel an ADMUX value selects, from its analog input.

Definition at line 33 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int ,
char **  )

Definition at line 186 of file test_main.cpp.

Here is the call graph for this function:

◆ setUp()

void setUp ( void )

Definition at line 18 of file test_main.cpp.

◆ tearDown()

void tearDown ( void )

Definition at line 19 of file test_main.cpp.

◆ test_admux_of_is_reference_adlar_and_pin()

void test_admux_of_is_reference_adlar_and_pin ( void )

Definition at line 80 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_admux_written_after_selects_the_channel_after_next()

void test_admux_written_after_selects_the_channel_after_next ( void )

Definition at line 106 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_after_next_of_every_position()

void test_after_next_of_every_position ( void )

Definition at line 93 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_channel_converted_by_round()

void test_channel_converted_by_round ( void )

Definition at line 117 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_channel_table_matches_the_former_literals()

void test_channel_table_matches_the_former_literals ( void )

< the pin the ADMUX of this entry selects

Definition at line 155 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_order_of_the_chain()

void test_order_of_the_chain ( void )

Definition at line 47 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_pins()

void test_pins ( void )

Definition at line 59 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_pipeline_order()

void test_pipeline_order ( void )

Definition at line 126 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_reference_per_board()

void test_reference_per_board ( void )

Definition at line 72 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ADLAR_BIT

uint8_t ADLAR_BIT { 1U << 5 }
inlineconstexpr

left-adjusted result

Definition at line 30 of file test_main.cpp.

◆ AVCC

uint8_t AVCC { 1U << 6 }
inlineconstexpr

REFS0 alone: AVcc

Definition at line 28 of file test_main.cpp.

◆ boards

PcbVersion boards[] { PcbVersion::OLD, PcbVersion::NEW }
inlineconstexpr

Definition at line 23 of file test_main.cpp.

◆ chain

Channel chain[] { Channel::V1, Channel::I1, Channel::V2, Channel::I2, Channel::V3, Channel::I3 }
inlineconstexpr

Definition at line 24 of file test_main.cpp.

◆ INTERNAL_1V1

uint8_t INTERNAL_1V1 { (1U << 7) | (1U << 6) }
inlineconstexpr

REFS1 and REFS0: internal 1.1 V

Definition at line 29 of file test_main.cpp.

◆ MUX_MASK

uint8_t MUX_MASK { 0x0F }
inlineconstexpr

MUX3..0: the analog input

Definition at line 26 of file test_main.cpp.

◆ REF_MASK

uint8_t REF_MASK { (1U << 7) | (1U << 6) }
inlineconstexpr

REFS1, REFS0

Definition at line 27 of file test_main.cpp.