Skip to content

Commit 80beb87

Browse files
committed
Invert TEMP channels on PMCr2
1 parent 3ca0bc1 commit 80beb87

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/Arduino_MachineControl.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
#include <pinDefinitions.h>
1414
#include <mbed.h>
1515

16+
#if __has_include("portenta_info.h")
17+
#include "portenta_info.h"
18+
#define TRY_REV2_RECOGNITION
19+
uint8_t* boardInfo();
20+
#define PMC_R2_SKU (24 << 8 | 3)
21+
#endif
22+
1623
namespace machinecontrol {
1724

1825
/**
@@ -28,6 +35,26 @@ class RTDClass {
2835
* @param channel (0-2)
2936
*/
3037
void selectChannel(int channel) {
38+
39+
#ifdef TRY_REV2_RECOGNITION
40+
// check if OTP data is present AND the board is mounted on a r2 carrier
41+
auto info = (PortentaBoardInfo*)boardInfo();
42+
if (info->magic == 0xB5 && info->carrier == PMC_R2_SKU) {
43+
// reverse channels 0 and 2
44+
switch (channel) {
45+
case 0:
46+
channel = 2;
47+
break;
48+
case 2:
49+
channel = 0;
50+
break;
51+
default:
52+
break;
53+
}
54+
}
55+
#endif
56+
#undef TRY_REV2_RECOGNITION
57+
3158
for (int i=0; i<3; i++) {
3259
ch_sel[i] = (i == channel ? 1 : 0);
3360
}

0 commit comments

Comments
 (0)