Compare commits
No commits in common. "e1e6315f7f706c8d6d83326dab932b2aadf3a7d2" and "2b308a6b1d6f814901f3724b96109eb18db4b5aa" have entirely different histories.
e1e6315f7f
...
2b308a6b1d
15 changed files with 19 additions and 300 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -12,4 +12,3 @@ build/compile_commands.json
|
|||
build/.cache/clangd/index
|
||||
build/*.*
|
||||
tags
|
||||
*.core
|
||||
|
|
|
|||
4
Doxyfile
4
Doxyfile
|
|
@ -42,13 +42,13 @@ DOXYFILE_ENCODING = UTF-8
|
|||
# title of most generated pages and in a few other places.
|
||||
# The default value is: My Project.
|
||||
|
||||
PROJECT_NAME = "CH32V Project"
|
||||
PROJECT_NAME = "My Project"
|
||||
|
||||
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = 0.0.1
|
||||
PROJECT_NUMBER =
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
|
|
|
|||
|
|
@ -88,6 +88,8 @@ After following the above steps you should now have a working RISC-V toolchain
|
|||
that can be used for development.
|
||||
|
||||
|
||||
|
||||
|
||||
## TODO
|
||||
|
||||
- [X] Add ch32v003fun sources.
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
# I2C Design
|
||||
|
||||
# API / Interface
|
||||
|
||||
Ideally the interface should be as simple and portable as possible.
|
||||
|
||||
We don't want the consummer/user of the interface to need to worry about all
|
||||
the details of implimentation.
|
||||
|
||||
For instance the end-user should be able to in one line setup an I2C bus
|
||||
and on a second line to send or receive data.
|
||||
|
||||
|
||||
I have some functions that I think should ideally be "privite" in normal usage.
|
||||
But I need to still be able to access those functions or methods during the
|
||||
testing.
|
||||
|
||||
|
||||
## Error handling
|
||||
|
||||
Errors need to be handled such that the end-user doesn't miss this information.
|
||||
|
||||
## Timeouts
|
||||
|
||||
Sometimes there is errors in hardware or bus/hardware failures. These need to
|
||||
be found quickly and handled.
|
||||
|
||||
|
||||
|
||||
## Sharing
|
||||
|
||||
The I2C bus needs to be shared sometimes. I need to figure out some ways to
|
||||
ensure safe sharing of the bus/resources.
|
||||
|
||||
I think maybe the sharing should be implimented externally to the HAL.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
# MCU Support
|
||||
|
||||
One issue of note is the need to support multiple families and chipsets.
|
||||
|
||||
For the moments I'm assumign I can use the defines from the CH32FUN project's
|
||||
headers to handle this issue.
|
||||
|
||||
The other point of interest is that the linker file and toolchain file will
|
||||
need to be modified to conditionally select options.
|
||||
|
||||
Maybe I need to create multiple linker files, I'm unsure.
|
||||
|
||||
|
||||
I also don't know if the newer MCUs in the CH32V00X series have alternate boot
|
||||
modes or what.
|
||||
|
||||
|
||||
|
||||
35
otto.sh
35
otto.sh
|
|
@ -12,10 +12,6 @@ TEST_MODULE_DIR="${TEMPLATE_FILES}/test_module"
|
|||
CHIP="ch32v003"
|
||||
PROJECT_NAME="WCH_Template"
|
||||
|
||||
# These global variables are used when accessing my VM's
|
||||
USER="ronin"
|
||||
IP="10.138.198.114"
|
||||
|
||||
generate_tags_file () {
|
||||
echo "generate_tags_file()"
|
||||
# Saving current directory
|
||||
|
|
@ -311,38 +307,15 @@ flash_microcontroller () {
|
|||
wlink --chip=${CHIP} flash ./src/main.elf
|
||||
}
|
||||
|
||||
flash_vm () {
|
||||
build_hex
|
||||
#sftp ${USER}@${IP}:/home/ronin <<< $'put ./build/src/WCH_Template.elf'
|
||||
#ssh ${USER}@${IP}:/home/ronin '/home/ronin/.cargo/bin/wlink flash --speed low /home/ronin/WCH_Template.elf'
|
||||
|
||||
}
|
||||
|
||||
run_c_tests () {
|
||||
generate_tags_file
|
||||
format_source_code
|
||||
clear_cmake_cache
|
||||
cmake -DUNIT_TESTING=ON -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE} ../
|
||||
|
||||
if make AllTests; then
|
||||
echo "Running: AllTests -c -v"
|
||||
./tests/AllTests -v -c
|
||||
else
|
||||
echo "Failed to build AllTests."
|
||||
echo "Press anykey to exit:"
|
||||
read input
|
||||
fi
|
||||
|
||||
read -p "Press anykey to continue:" input
|
||||
|
||||
if make Mock_Tests; then
|
||||
tests/Mock_Tests -v -c
|
||||
else
|
||||
echo "Failed to build Mock_Tests."
|
||||
echo "Press anykey to exit:"
|
||||
read input
|
||||
fi
|
||||
|
||||
make AllTests
|
||||
make Mock_Tests
|
||||
./tests/AllTests -v -c
|
||||
./tests/Mock_Tests -v -c
|
||||
}
|
||||
|
||||
print_menu () {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
IMPORT_TEST_GROUP(simple_test);
|
||||
IMPORT_TEST_GROUP(tg_ADC);
|
||||
IMPORT_TEST_GROUP(tg_wwdg);
|
||||
IMPORT_TEST_GROUP(tg_I2C);
|
||||
IMPORT_TEST_GROUP(test_RegEdit);
|
||||
IMPORT_TEST_GROUP(test_blink);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
project(Tests)
|
||||
|
||||
# TEST_DIRS
|
||||
add_subdirectory(I2C)
|
||||
add_subdirectory(wwdg)
|
||||
add_subdirectory(blink)
|
||||
add_subdirectory(MockRegEdit)
|
||||
|
|
@ -21,7 +20,6 @@ add_executable(AllTests
|
|||
target_link_libraries(AllTests
|
||||
${CPPUTEST_LIBRARIES}
|
||||
# TEST_LINKS
|
||||
test_I2C
|
||||
test_wwdg
|
||||
test_blink
|
||||
test_ADC
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
# File: tests/I2C/CMakeLists.txt
|
||||
|
||||
add_subdirectory(mocks)
|
||||
add_subdirectory(fakes)
|
||||
add_subdirectory(stubs)
|
||||
|
||||
# TEST_RUNNER
|
||||
add_library(test_I2C
|
||||
test_I2C.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(test_I2C
|
||||
${CPPUTEST_LIBRARIES}
|
||||
I2C
|
||||
)
|
||||
|
||||
target_include_directories(test_I2C PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
#Next comes the shared and non-module specific test depencencies.
|
||||
${CMAKE_SOURCE_DIR}/tests/shared/mocks/
|
||||
${CMAKE_SOURCE_DIR}/tests/shared/fakes/
|
||||
${CMAKE_SOURCE_DIR}/tests/shared/stubs/
|
||||
)
|
||||
|
|
@ -1,160 +0,0 @@
|
|||
/*
|
||||
* Author: username
|
||||
* Date: todays_date
|
||||
* filename: test_I2C.c
|
||||
* description: module_purpose
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "I2C.h"
|
||||
#include "I2C_internal.h"
|
||||
}
|
||||
|
||||
TEST_GROUP(tg_I2C)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
|
||||
}
|
||||
void teardown()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
typedef struct
|
||||
{
|
||||
uint32_t clockspeed;
|
||||
uint16_t mode;
|
||||
uint16_t dutycycle;
|
||||
uint16_t ownaddress1;
|
||||
uint16_t ack;
|
||||
uint16_t ack_address;
|
||||
} i2c_config;
|
||||
*/
|
||||
|
||||
TEST(tg_I2C, GetBusReturnsNonNullOnValidIndecies)
|
||||
{
|
||||
i2c_bus_typedef_p i2cbus_ptr = I2C_GetBus(0);
|
||||
CHECK_TRUE_TEXT(i2cbus_ptr != nullptr, "The pointer should have been valid but was nullptr.");
|
||||
}
|
||||
|
||||
TEST(tg_I2C, GetBusReturnsNullOnInvalid)
|
||||
{
|
||||
|
||||
i2c_bus_typedef_p i2cbus_ptr = I2C_GetBus(I2C_BUS_QTY + 1);
|
||||
CHECK_EQUAL_TEXT(nullptr, i2cbus_ptr, "The pointer should be null for invalid indecies.");
|
||||
|
||||
}
|
||||
|
||||
TEST(tg_I2C, BusFailsOnInvalidconfig)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST(tg_I2C, CreateI2CBus_10Bit)
|
||||
{
|
||||
i2c_config i2c1_config = {
|
||||
.clockspeed = I2C_STD_SPEED,
|
||||
.mode = I2C_MODE_MASTER,
|
||||
.dutycycle = 0,
|
||||
.ownaddress = 0,
|
||||
.ack = true,
|
||||
.ack_address = 0,
|
||||
};
|
||||
|
||||
i2c_bus_typedef_p i2c1_ptr = I2C_GetBus(0);
|
||||
|
||||
bool ret = i2c1_ptr->Init(i2c1_ptr, &i2c1_config);
|
||||
CHECK_TRUE(ret);
|
||||
}
|
||||
|
||||
|
||||
TEST_GROUP(tg_I2C_internal)
|
||||
{
|
||||
i2c_config config;
|
||||
void setup()
|
||||
{
|
||||
config.clockspeed = 0;
|
||||
config.mode = 0;
|
||||
|
||||
}
|
||||
void teardown()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
TEST(tg_I2C_internal, i2c_configchecksclockspeed)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
for(config.clockspeed = 0; config.clockspeed < I2C_INVALID_SPEED; config.clockspeed++){
|
||||
ret = is_i2c_config_valid(&config);
|
||||
CHECK_TRUE(ret);
|
||||
}
|
||||
|
||||
config.clockspeed = I2C_INVALID_SPEED;
|
||||
ret = is_i2c_config_valid(&config);
|
||||
CHECK_FALSE_TEXT(ret, "config check accepted invalid i2c clockspeed!");
|
||||
}
|
||||
|
||||
TEST(tg_I2C_internal, i2c_configchecksmode)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
for(config.mode = 0; config.mode < I2C_MODE_INVALID; config.mode++){
|
||||
ret = is_i2c_config_valid(&config);
|
||||
CHECK_TRUE(ret);
|
||||
}
|
||||
|
||||
config.mode = I2C_MODE_INVALID;
|
||||
ret = is_i2c_config_valid(&config);
|
||||
CHECK_FALSE_TEXT(ret, "config check accepted invalid i2c mode!");
|
||||
}
|
||||
|
||||
TEST(tg_I2C_internal, i2c_configchecksdutycycle)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
for(config.dutycycle= 0; config.dutycycle < I2C_DUTYCYCLE_INVALID; config.dutycycle++){
|
||||
ret = is_i2c_config_valid(&config);
|
||||
CHECK_TRUE(ret);
|
||||
}
|
||||
|
||||
config.dutycycle= I2C_DUTYCYCLE_INVALID;
|
||||
ret = is_i2c_config_valid(&config);
|
||||
CHECK_FALSE_TEXT(ret, "config check accepted invalid i2c dutycycle!");
|
||||
}
|
||||
|
||||
TEST(tg_I2C_internal, is10bitaddresschecksCorrectly)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
CHECK_FALSE_TEXT(ret, "check");
|
||||
}
|
||||
|
||||
TEST(tg_I2C_internal, is7bitaddresschecksCorrectly)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
CHECK_FALSE_TEXT(ret, "check");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
#include "wwdg_hw.h"
|
||||
|
||||
|
||||
void wwdg_mock_setup(WWDG_TypeDef *wwdg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void wwdg_mock_reset(void){};
|
||||
|
||||
void wwdg_mock_clock_tick(void){};
|
||||
|
||||
void wwdg_mock_tick_n_times(size_t n){};
|
||||
|
|
@ -9,21 +9,23 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
bool is_enabled;
|
||||
bool is_HSE;
|
||||
bool is_enabled;
|
||||
bool is_HSE;
|
||||
uint32_t clock_rate;
|
||||
} RISCV_APB_CLK;
|
||||
}RISCV_APB_CLK;
|
||||
|
||||
/* Window WatchDog Registers*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t CTLR; /* Control Register */
|
||||
uint16_t RESERVED1;
|
||||
uint16_t CFGR; /* Configuration Register */
|
||||
uint16_t RESERVED2;
|
||||
uint16_t STATR; /* Status Register */
|
||||
uint16_t CTLR; /* Control Register */
|
||||
uint16_t RESERVED1;
|
||||
uint16_t CFGR; /* Configuration Register */
|
||||
uint16_t RESERVED2;
|
||||
uint16_t STATR; /* Status Register */
|
||||
} WWDG_TypeDef;
|
||||
|
||||
|
||||
|
||||
void wwdg_mock_setup(WWDG_TypeDef *wwdg);
|
||||
|
||||
void wwdg_mock_reset(void);
|
||||
|
|
@ -32,4 +34,4 @@ void wwdg_mock_clock_tick(void);
|
|||
|
||||
void wwdg_mock_tick_n_times(size_t n);
|
||||
|
||||
#endif // WWDG_MOCK_H
|
||||
#endif //WWDG_MOCK_H
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue