Compare commits

..

No commits in common. "38dea7ead4e1747034a96505e8281e31dbd8c65f" and "968570e898415205f379c54867685d45510c996f" have entirely different histories.

3 changed files with 18 additions and 44 deletions

View file

@ -1,29 +1,8 @@
/*
* Author: Jake Goodwin
* Date: 2025
* Author: username
* Date: 2024
* filename: ADC.c
* description:
*/
/*DEVNOTES:
* The CH32v003 micro-controllers have 8channels for the ADC that are
* external and 2 internal channels.
*
* The channels/inputs are labeled as AIN0-AIN7
*/
/*CH32v003 ADC TO PINs:
* A0 --> PA2
* A1 --> PA1
* A2 --> PC2
* A3 --> PD2
* A4 --> PD3
* A5 --> PD5
* A6 --> PD6
* A7 --> PD4
*
* Because they don't exactly match up, I'll need to write up my own
* way to do the mapping.
* description: module_purpose
*/
#include "ADC.h"

View file

@ -1,8 +1,8 @@
/**
* @brief Interface to the AVR ADC hardware.
* @details This file is...
* @author Jake Goodwin
* @date 2025
* @author Jake G
* @date 2024
* @copyright None
* @file ADC.h
*/

View file

@ -9,9 +9,13 @@
#include "CppUTestExt/MockSupport.h"
#include <cstdint>
//This define allows us to dircetly include the device header without error.
#define _AVR_IO_H_
extern "C"
{
#include "ch32v003hw.h"
#include <iotn404.h> //ATtiny404 header fille.
#include "ADC.h"
}
@ -36,8 +40,6 @@ TEST(test_ADC, FirstTest)
TEST(test_ADC, ADC_SetupSetsRegisters)
{
/*
//Clears control register A for ADC0
mock().expectOneCall("RegEdit_SetNum")
.withPointerParameter("reg", (void *) &ADC0.CTRLA)
@ -68,13 +70,11 @@ TEST(test_ADC, ADC_SetupSetsRegisters)
.withPointerParameter("reg", (void *) &ADC0.CTRLD)
.withUnsignedIntParameter("bit_num", 4);
*/
ADC_Setup();
}
TEST(test_ADC, ADC_InitPortAPin7UsesCorrectRegisters)
{
/*
//Check for setting the direction to input.
mock().expectOneCall("RegEdit_ClearBit")
.withPointerParameter("reg", (void *) &PORTA.DIR)
@ -91,13 +91,13 @@ TEST(test_ADC, ADC_InitPortAPin7UsesCorrectRegisters)
.withPointerParameter("reg", (void *) &PORTA.PIN7CTRL)
.withUnsignedIntParameter("bit_num", PORT_ISC_INPUT_DISABLE_gc);
*/
ADC_Init(7);
}
TEST(test_ADC, ADC_InitPortAPin0UsesCorrectRegisters)
{
/*
//Check for setting the direction to input.
mock().expectOneCall("RegEdit_ClearBit")
.withPointerParameter("reg", (void *) &PORTA.DIR)
@ -114,42 +114,38 @@ TEST(test_ADC, ADC_InitPortAPin0UsesCorrectRegisters)
.withPointerParameter("reg", (void *) &PORTA.PIN0CTRL)
.withUnsignedIntParameter("bit_num", PORT_ISC_INPUT_DISABLE_gc);
*/
ADC_Init(0);
}
TEST(test_ADC, ADC_InitDoesNothingOnHighPinNumbers)
{
//mock().expectNoCall("RegEdit_SetBit");
mock().expectNoCall("RegEdit_SetBit");
ADC_Init(8);
}
TEST(test_ADC, ADC_EnablePasses)
{
/*
mock().expectOneCall("RegEdit_SetBit")
.withPointerParameter("reg", (void *) &ADC0.CTRLA)
.withUnsignedIntParameter("bit_num", 0);
*/
ADC_Enable();
}
TEST(test_ADC, ADC_DisablePasses)
{
/*
mock().expectOneCall("RegEdit_ClearBit")
.withPointerParameter("reg", (void *) &ADC0.CTRLA)
.withUnsignedIntParameter("bit_num", 0);
*/
ADC_Disable();
}
TEST(test_ADC, ADC_SetPinSetsRightRegisters)
{
/*
//It clears existing MUXPOS register values.
mock().expectOneCall("RegEdit_ClearRegister")
.withPointerParameter("reg", (void *) &ADC0.MUXPOS);
@ -159,7 +155,6 @@ TEST(test_ADC, ADC_SetPinSetsRightRegisters)
.withPointerParameter("reg", (void *) &ADC0.MUXPOS)
.withUnsignedIntParameter("num", 4);
*/
ADC_SetPin(4);
}