Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 589becb

Browse files
committedOct 26, 2022
working
1 parent 7e5974e commit 589becb

File tree

1 file changed

+52
-44
lines changed

1 file changed

+52
-44
lines changed
 

‎src/Arduino_MachineControl.h

+52-44
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
#include "utility/MAX31865/MAX31865.h"
55
#include "utility/THERMOCOUPLE/MAX31855.h"
6+
#ifdef CORE_CM7
67
#include <ArduinoRS485.h>
8+
#endif
79
#include "utility/QEI/QEI.h"
810
#include "utility/ioexpander/ArduinoIOExpander.h"
911
#include "utility/RTC/PCF8563T.h"
@@ -31,9 +33,9 @@ class RTDClass {
3133

3234
/**
3335
* Select the input channel to be read (3 channels available)
34-
*
36+
*
3537
* @param channel (0-2)
36-
*/
38+
*/
3739
void selectChannel(int channel) {
3840

3941
#ifdef TRY_REV2_RECOGNITION
@@ -64,17 +66,17 @@ class RTDClass {
6466
/**
6567
* Enable the CS of the Thermocouple to digital converter
6668
* Disable the CS for the RTD to digital converter
67-
*/
69+
*/
6870
void enableTC() {
6971
rtd_th = 0;
7072
digitalWrite(PI_0, LOW);
7173
digitalWrite(PA_6, HIGH);
7274
}
7375

7476
/**
75-
* Enable the CS of the RDT to digital converter.
77+
* Enable the CS of the RDT to digital converter.
7678
* Disable the CS of the Thermocouple to digital converter
77-
*/
79+
*/
7880
void enableRTD() {
7981
rtd_th = 1;
8082
digitalWrite(PI_0, HIGH);
@@ -83,9 +85,9 @@ class RTDClass {
8385
}
8486

8587
/**
86-
* Disable Chip select for both RTD and thermocouple digital converters.
87-
*
88-
*/
88+
* Disable Chip select for both RTD and thermocouple digital converters.
89+
*
90+
*/
8991
void disableCS() {
9092
digitalWrite(PI_0, HIGH);
9193
digitalWrite(PA_6, HIGH);
@@ -102,9 +104,11 @@ class RTDClass {
102104
extern RTDClass temp_probes;
103105

104106
/**
105-
* The COMMClass is used to initialize the CAN and RS485 LEDs and
106-
* establish the power mode of the CAN bus.
107+
* The COMMClass is used to initialize the CAN and RS485 LEDs and
108+
* establish the power mode of the CAN bus.
107109
*/
110+
111+
#ifdef CORE_CM7
108112
class COMMClass {
109113
public:
110114
// to be tested: check if can be made a big pin initialization
@@ -130,7 +134,7 @@ class COMMClass {
130134
}
131135

132136
/**
133-
* Set the CAN transceiver in Normal mode. In this mode, the transceiver
137+
* Set the CAN transceiver in Normal mode. In this mode, the transceiver
134138
* can transmit and receive data via the bus lines CANH and CANL.
135139
*/
136140
void enableCAN() {
@@ -170,7 +174,11 @@ class COMMClass {
170174
private:
171175
mbed::DigitalOut can_disable = mbed::DigitalOut(PA_13, 0);
172176
};
173-
177+
#elif defined(CORE_CM4)
178+
class COMMClass {
179+
public:
180+
};
181+
#endif
174182
extern COMMClass comm_protocols;
175183

176184
#define ch0_in1 ch_in[0]
@@ -188,7 +196,7 @@ extern COMMClass comm_protocols;
188196

189197
/**
190198
* The AnalogInClass is used to set the resistor configuration for the right type of analog sensor
191-
* i.e. NTC sensors, 4-10mA or 0-10V.
199+
* i.e. NTC sensors, 4-10mA or 0-10V.
192200
*/
193201
class AnalogInClass {
194202
public:
@@ -218,7 +226,7 @@ class AnalogInClass {
218226

219227
/**
220228
* Configure the input resistor dividers to have a ratio of 0.28.
221-
* Maximum input voltage is 10V.
229+
* Maximum input voltage is 10V.
222230
*/
223231
void set0_10V() {
224232
ch0_in1 = 1;
@@ -238,8 +246,8 @@ class AnalogInClass {
238246
}
239247

240248
/**
241-
* Enable a 120 ohm resistor to GND to convert the 4-20mA sensor currents to voltage.
242-
* Note: 24V are available from the carrier to power the 4-20mA sensors.
249+
* Enable a 120 ohm resistor to GND to convert the 4-20mA sensor currents to voltage.
250+
* Note: 24V are available from the carrier to power the 4-20mA sensors.
243251
*/
244252
void set4_20mA() {
245253
ch0_in1 = 1;
@@ -259,8 +267,8 @@ class AnalogInClass {
259267
}
260268

261269
/**
262-
* Enable a 100K resistor in series with the reference voltage.
263-
* The voltage sampled is the voltage division between the 100k resistor and the input resistor (NTC/PTC)
270+
* Enable a 100K resistor in series with the reference voltage.
271+
* The voltage sampled is the voltage division between the 100k resistor and the input resistor (NTC/PTC)
264272
*/
265273
void setNTC() {
266274
ch0_in1 = 0;
@@ -290,10 +298,10 @@ class AnalogInClass {
290298
}
291299
}
292300

293-
mbed::DigitalOut ch_in[12] = {
301+
mbed::DigitalOut ch_in[12] = {
294302
mbed::DigitalOut(PD_4), mbed::DigitalOut(PD_5), mbed::DigitalOut(PE_3), mbed::DigitalOut(PG_3),
295303
mbed::DigitalOut(PD_7), mbed::DigitalOut(PH_6), mbed::DigitalOut(PJ_7), mbed::DigitalOut(PH_15),
296-
mbed::DigitalOut(PH_10), mbed::DigitalOut(PA_4), mbed::DigitalOut(PA_8), mbed::DigitalOut(PC_6)
304+
mbed::DigitalOut(PH_10), mbed::DigitalOut(PA_4), mbed::DigitalOut(PA_8), mbed::DigitalOut(PC_6)
297305
};
298306

299307
private:
@@ -376,8 +384,8 @@ class AnalogOutClass {
376384
extern AnalogOutClass analog_out;
377385

378386

379-
/*
380-
TODO: writeme
387+
/*
388+
TODO: writeme
381389
Use QEI library for mbed since it implements index pin
382390
*/
383391
/**
@@ -410,7 +418,7 @@ class EncoderClass {
410418

411419
extern EncoderClass encoders;
412420

413-
/*
421+
/*
414422
using gpio expander class https://www.i2cdevlib.com/devices/tca6424a#source
415423
Ask Giampaolo for proper porting
416424
Expander interrupt is PI_5
@@ -421,32 +429,32 @@ extern EncoderClass encoders;
421429

422430

423431
/**
424-
* The ProgrammableDIOClass is used to initialize the IOExpanders and configure the
432+
* The ProgrammableDIOClass is used to initialize the IOExpanders and configure the
425433
* thermal shutdown mode of the high side switches.
426434
*/
427435
class ProgrammableDIOClass : public ArduinoIOExpanderClass {
428436
public:
429437

430438
/**
431-
* Test connection with the IOExpander and set all the pins to the default mode.
439+
* Test connection with the IOExpander and set all the pins to the default mode.
432440
* @return true if OK, false if fault
433441
*/
434442
bool init() {
435443
return begin(IO_ADD);
436444
}
437445

438446
/**
439-
* Configures the thermal shutdown of the high-side switches (TPS4H160) to operate in latch mode.
440-
* The output latches off when thermal shutdown occurs.
447+
* Configures the thermal shutdown of the high-side switches (TPS4H160) to operate in latch mode.
448+
* The output latches off when thermal shutdown occurs.
441449
*/
442450
void setLatch() {
443451
prog_latch_retry = 0;
444452
}
445453

446454
/**
447-
* Configures the thermal shutdown of the high-side switches (TPS4H160) to operate in auto-retry mode.
448-
* The output automatically recovers when TJ < T(SD) – T(hys), but the current is limited to ICL(TSD)
449-
* to avoid repetitive thermal shutdown.
455+
* Configures the thermal shutdown of the high-side switches (TPS4H160) to operate in auto-retry mode.
456+
* The output automatically recovers when TJ < T(SD) – T(hys), but the current is limited to ICL(TSD)
457+
* to avoid repetitive thermal shutdown.
450458
*/
451459
void setRetry() {
452460
prog_latch_retry = 1;
@@ -466,7 +474,7 @@ class DigitalOutputsClass {
466474
public:
467475

468476
/**
469-
* Set all digital outputs at the same time.
477+
* Set all digital outputs at the same time.
470478
* @param val 8 bit integer to set all 8 channels. e.g:
471479
* Set all to HIGH -> val = 255 (0b11111111)
472480
* Set all to LOW -> val = 0 (0b00000000)
@@ -488,17 +496,17 @@ class DigitalOutputsClass {
488496
}
489497

490498
/**
491-
* Configures the thermal shutdown of the high-side switches (TPS4H160) to operate in latch mode.
492-
* The output latches off when thermal shutdown occurs.
499+
* Configures the thermal shutdown of the high-side switches (TPS4H160) to operate in latch mode.
500+
* The output latches off when thermal shutdown occurs.
493501
*/
494502
void setLatch() {
495503
dig_out_latch_retry = 0;
496504
}
497505

498506
/**
499-
* Configures the thermal shutdown of the high-side switches (TPS4H160) to operate in auto-retry mode.
500-
* The output automatically recovers when TJ < T(SD) – T(hys), but the current is limited to ICL(TSD)
501-
* to avoid repetitive thermal shutdown.
507+
* Configures the thermal shutdown of the high-side switches (TPS4H160) to operate in auto-retry mode.
508+
* The output automatically recovers when TJ < T(SD) – T(hys), but the current is limited to ICL(TSD)
509+
* to avoid repetitive thermal shutdown.
502510
*/
503511
void setRetry() {
504512
dig_out_latch_retry = 1;
@@ -519,7 +527,7 @@ extern DigitalOutputsClass digital_outputs;
519527
class ProgrammableDINClass : public ArduinoIOExpanderClass {
520528
public:
521529
/**
522-
* Test connection with the IOExpander and set all the pins to the default mode.
530+
* Test connection with the IOExpander and set all the pins to the default mode.
523531
* @return true if OK, false if fault
524532
*/
525533
bool init() {
@@ -530,9 +538,9 @@ class ProgrammableDINClass : public ArduinoIOExpanderClass {
530538
extern ProgrammableDINClass digital_inputs;
531539

532540
/**
533-
* The RtcControllerClass is a wrapper for the PCF8563TClass() that is used to
541+
* The RtcControllerClass is a wrapper for the PCF8563TClass() that is used to
534542
* set and get the time to/from the PCF8563T RTC.
535-
*
543+
*
536544
*/
537545
class RtcControllerClass : public PCF8563TClass {
538546
public:
@@ -546,31 +554,31 @@ extern RtcControllerClass rtc_controller;
546554

547555
/**
548556
* The USB Class is used to enable/disable the power of the USBA (Host) and configure
549-
* the callbacks for the different host types (i.e. Keyboard, mouse, storage device etc).
557+
* the callbacks for the different host types (i.e. Keyboard, mouse, storage device etc).
550558
*/
551559
class USBClass {
552560
public:
553561
USBClass()
554562
: _power{PB_14, 0}
555563
, _usbflag{PB_15}
556564
{};
557-
565+
558566
/**
559-
* Enable power to USBA VBUS.
567+
* Enable power to USBA VBUS.
560568
*/
561569
void powerEnable() {
562570
_power = 0;
563571
}
564572

565573
/**
566-
* Disable power to USBA VBUS.
574+
* Disable power to USBA VBUS.
567575
*/
568576
void powerDisable() {
569577
_power = 1;
570578
}
571579

572580
/**
573-
* Flag to indicate overcurrent, overtemperature, or reverse−voltage conditions on the USBA VBUS.
581+
* Flag to indicate overcurrent, overtemperature, or reverse−voltage conditions on the USBA VBUS.
574582
* Active−low open−drain output.
575583
* @return true if OK, false if fault
576584
*/

0 commit comments

Comments
 (0)
This repository has been archived.