Split project structure to fw/hw, KiCad gitignore

This commit is contained in:
Ilya Elenskiy
2020-04-19 14:32:24 +02:00
parent 5d0b62bef5
commit a3b1d9cb11
16 changed files with 148 additions and 108 deletions

11
Firmware/test/README Normal file
View File

@@ -0,0 +1,11 @@
This directory is intended for PIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html

41
Firmware/test/test_demo.c Normal file
View File

@@ -0,0 +1,41 @@
#include <stdint.h>
#include <unity.h>
#include <util/delay.h>
#include "fifo.h"
#include "unittest_transport.h"
void test_fifo(void)
{
uint8_t buf[3];
fifo_t f;
fifo_init(&f, buf, sizeof(buf));
fifo_put(&f, 0x11);
fifo_put(&f, 0x22);
fifo_put(&f, 0x33);
TEST_ASSERT_EQUAL(fifo_get_nowait(&f), 0x11);
TEST_ASSERT_EQUAL(fifo_get_nowait(&f), 0x22);
TEST_ASSERT_EQUAL(fifo_get_nowait(&f), 0x33);
}
int main()
{
// NOTE!!! Wait for >2 secs
// if board doesn't support software reset via Serial.DTR/RTS
_delay_ms(2000);
DDRB |= 0x2;
PORTB &= ~0x2;
UNITY_BEGIN(); // IMPORTANT LINE!
RUN_TEST(test_fifo);
UNITY_END(); // stop unit testing
PORTB |= 0x2;
DDRB |= 0x4;
PORTB &= ~0x4;
while (1)
;
}

View File

@@ -0,0 +1,32 @@
#ifndef UNITTEST_TRANSPORT_H
#define UNITTEST_TRANSPORT_H
#include <avr/io.h>
#include <stdint.h>
#include "uart.h"
void unittest_uart_begin()
{
// Set Baudrate according to datasheet (16MHz -> 9600 Baud -> 103)
UBRR0 = 103;
UCSR0B |= (1<<TXEN0);
// Reset Complete-Flags
UCSR0A = (1 << RXC0) | (1 << TXC0);
}
void unittest_uart_putchar(char c)
{
loop_until_bit_is_set(UCSR0A, UDRE0);
UDR0 = c;
}
void unittest_uart_flush()
{
}
void unittest_uart_end()
{
}
#endif