Skip to content

Commit a3363bb

Browse files
authored
Merge pull request #71 from 107-systems/fix-nested-namespace-error
Fixing build issues when using this library with ESP32.
2 parents 20ff48d + f112ee0 commit a3363bb

File tree

4 files changed

+51
-3
lines changed

4 files changed

+51
-3
lines changed

examples/UAVCAN-Blink/UAVCAN-Blink.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ static int const MKRCAN_MCP2515_CS_PIN = 3;
3030
static int const MKRCAN_MCP2515_INT_PIN = 7;
3131
static CanardPortID const BIT_PORT_ID = 1620U;
3232

33+
#if defined(ESP32)
34+
static int const LED_BUILTIN = 2;
35+
#endif
36+
3337
/**************************************************************************************
3438
* FUNCTION DECLARATION
3539
**************************************************************************************/

examples/UAVCAN-Heartbeat-Subscribe/UAVCAN-Heartbeat-Subscribe.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void onHeartbeat_1_0_Received(CanardTransfer const & transfer, ArduinoUAVCAN & /
114114
char msg[64];
115115
snprintf(msg, 64,
116116
"ID %02X, Uptime = %d, Health = %d, Mode = %d, VSSC = %d",
117-
transfer.remote_node_id, hb.data.uptime, hb.data.health, hb.data.mode, hb.data.vendor_specific_status_code);
117+
transfer.remote_node_id, hb.data.uptime, hb.data.health.value, hb.data.mode.value, hb.data.vendor_specific_status_code);
118118

119119
Serial.println(msg);
120120
}

src/utility/CritSec-esp32.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* This software is distributed under the terms of the MIT License.
3+
* Copyright (c) 2020 LXRobotics.
4+
* Author: Alexander Entinger <alexander.entinger@lxrobotics.com>
5+
* Contributors: https://github.com/107-systems/107-Arduino-UAVCAN/graphs/contributors.
6+
*/
7+
8+
/**************************************************************************************
9+
* INCLUDE
10+
**************************************************************************************/
11+
12+
#include "CritSec.h"
13+
14+
#ifdef ARDUINO_ARCH_ESP32
15+
16+
#include <Arduino.h>
17+
18+
/**************************************************************************************
19+
* GLOBAL VARIABLES
20+
**************************************************************************************/
21+
22+
static portMUX_TYPE mtx = portMUX_INITIALIZER_UNLOCKED;
23+
24+
/**************************************************************************************
25+
* FUNCTION DEFINITION
26+
**************************************************************************************/
27+
28+
void crit_sec_enter()
29+
{
30+
portENTER_CRITICAL(&mtx);
31+
}
32+
33+
void crit_sec_leave()
34+
{
35+
portEXIT_CRITICAL(&mtx);
36+
}
37+
38+
#endif /* ARDUINO_ARCH_ESP32 */

src/utility/convert.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
* NAMESPACE
1919
**************************************************************************************/
2020

21-
namespace arduino::_107_::uavcan
21+
namespace arduino
22+
{
23+
namespace _107_
24+
{
25+
namespace uavcan
2226
{
2327

2428
/**************************************************************************************
@@ -35,6 +39,8 @@ constexpr auto to_integer(Enumeration const value) -> typename std::underlying_t
3539
* NAMESPACE
3640
**************************************************************************************/
3741

38-
} /* arduino::_107_::uavcan */
42+
} /* uavcan */
43+
} /* _107_ */
44+
} /* arduino */
3945

4046
#endif /* ARDUINO_UAVCAN_UTILITY_COVERT_HPP_ */

0 commit comments

Comments
 (0)