Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
76989ef
First integration of P Gahtow XpressNetMaster library
glaserf Feb 2, 2021
01e4ba3
Resolved PR comments
glaserf Feb 3, 2021
cce8438
Removed unnecessary XpressNet message class
glaserf Feb 4, 2021
367ad8c
Several fixes to XN library: The rx buffer now holds multiple entries…
glaserf Feb 5, 2021
74cc1ca
Make room for XpressNet messages with more than 8 bytes in the receiv…
glaserf Feb 15, 2021
fa3caad
Merge branch 'master' into xpressnet
deltaphi Feb 16, 2021
fcd477a
Merge pull request #1 from deltaphi/xpressnet
glaserf Feb 18, 2021
5b11141
Made includes more test-friendly
deltaphi Feb 19, 2021
2fed512
Merge branch 'master' into xpressnet
deltaphi Feb 21, 2021
b66cbdb
Merge pull request #2 from deltaphi/xpressnet
glaserf Feb 21, 2021
c4de993
Merge pull request #3 from deltaphi/master
glaserf Feb 22, 2021
5f96b56
Merge pull request #4 from deltaphi/master
glaserf Feb 22, 2021
1d2fc08
Merge pull request #5 from deltaphi/master
glaserf Feb 28, 2021
e163c0d
First try of adding XpressNet to UnitTests
glaserf Mar 2, 2021
466de7f
Actually add XN mock implementation
glaserf Mar 2, 2021
90d2fa0
Finally got ctests to compile. Hoorray
glaserf Mar 9, 2021
3ca9edd
Run clang-format on all files.
deltaphi Jun 5, 2021
1905f26
Make existing Unit Tests pass.
deltaphi Jun 5, 2021
2b37391
Update CodeCoverage.cmake
deltaphi Jun 5, 2021
431da01
Merge branch 'master' into xpressnet
deltaphi Jun 5, 2021
8760407
Add missing braces
deltaphi Jun 5, 2021
734d4f0
Switch to RR32Can utilities
deltaphi Jun 5, 2021
cb26d8c
Merge remote-tracking branch 'origin/master' into xpressnet
deltaphi Mar 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions c6021light/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ add_executable(c6021lightTest
"test/integration/StopGoRequest.cpp"
"test/integration/CanEngineDBRequest.cpp"
"test/mocks/LocoNet.cpp"
"test/mocks/XpressNetMaster.cpp"
"test/mocks/RoutingForwarderMock.cpp"
"test/integration/SlotServerProcessing.cpp"
"test/integration/EngineRouting.cpp"

"src/tasks/RoutingTask/CANForwarder.cpp"
"src/tasks/RoutingTask/I2CForwarder.cpp"
"src/tasks/RoutingTask/XpressNetForwarder.cpp"
"src/tasks/RoutingTask/LocoNetForwarder.cpp"
"src/tasks/RoutingTask/LocoNetHelpers.cpp"
"src/tasks/RoutingTask/LocoNetPrinter.cpp"
Expand Down
27 changes: 27 additions & 0 deletions c6021light/include/WProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,24 @@
#include <type_traits>

#include <FreeRTOS.h>
#include <task.h>
#include <portmacro.h>

typedef uint8_t byte; // Arduino pre-defined data types

/// The I/O mode of a GPIO
enum PinMode {
OUTPUT = 0, // Assume Push-Pull
INPUT,
INPUT_PULLUP
};

/// The I/O value of a GPIO
enum PinValue {
LOW = 0,
HIGH
};

/**
* \brief Possible GPIO ports of the Bluepill board.
*
Expand All @@ -35,13 +44,17 @@ enum PinNames : uint8_t {
/// Macro to define ISR functions.
#define ISR(f) extern "C" void f(void)

/// Arduino uses function-style casts..
#define word(h, l) ((uint16_t) ((h << 8) | (l & 0xFF)))

/// Macro to obtain the contents of the output register for a GPIO*
#define portOutputRegister(port) (&(GPIO_ODR(port)))

/// Macro to obtain the contents of the input register for a GPIO*
#define portInputRegister(port) (&(GPIO_IDR(port)))
uint32_t digitalPinToPort(PinNames pin);
uint16_t digitalPinToBitMask(PinNames pin);
void digitalWrite(PinNames pin, PinValue value);
void pinMode(PinNames pin, PinMode mode);

/// Forwarding functions for implicit conversion
Expand All @@ -59,11 +72,25 @@ inline uint16_t digitalPinToBitMask(std::underlying_type<PinNames>::type pin) {
return digitalPinToBitMask(static_cast<PinNames>(pin));
}

inline void digitalWrite(std::underlying_type<PinNames>::type pin, PinValue value) {
return digitalWrite(static_cast<PinNames>(pin), value);
}

#define noInterrupts() (portDISABLE_INTERRUPTS())
#define interrupts() (portENABLE_INTERRUPTS())

#define delay(ms) (vTaskDelay(pdMS_TO_TICKS(ms)))

/// Dirty emulation of Arduino tick functions
inline uint32_t millis(void) {
return xTaskGetTickCount() * portTICK_PERIOD_MS;
}

/// TODO this needs to be done properly, millis resolution is not sufficient
inline uint32_t micros(void) {
return millis() * 1000;
}

/*
01 VBAT
02 PC 13
Expand Down
Loading
Loading