|
1 |
| -#ifndef __MACHINE_CONTROL_H__ |
2 |
| -#define __MACHINE_CONTROL_H__ |
3 |
| - |
4 |
| -#include "utility/MAX31865/MAX31865.h" |
5 |
| -#include "utility/THERMOCOUPLE/MAX31855.h" |
6 |
| -#include <ArduinoRS485.h> |
7 |
| -#include "utility/QEI/QEI.h" |
8 |
| -#include "utility/ioexpander/ArduinoIOExpander.h" |
9 |
| -#include "utility/RTC/PCF8563T.h" |
10 |
| - |
11 |
| -#include <Arduino.h> |
12 |
| -#include <pinDefinitions.h> |
13 |
| -#include <mbed.h> |
| 1 | +#ifndef __ARDUINO_MACHINE_CONTROL_H |
| 2 | +#define __ARDUINO_MACHINE_CONTROL_H |
14 | 3 |
|
15 | 4 | #include "AnalogInClass.h"
|
16 | 5 | #include "AnalogOutClass.h"
|
|
21 | 10 | #include "RtcControllerClass.h"
|
22 | 11 | #include "USBClass.h"
|
23 | 12 | #include "EncoderClass.h"
|
| 13 | +#include "COMMClass.h" |
24 | 14 |
|
25 |
| -namespace machinecontrol { |
26 |
| - |
27 |
| -/** |
28 |
| - * The COMMClass is used to initialize the CAN and RS485 LEDs and |
29 |
| - * establish the power mode of the CAN bus. |
30 |
| - */ |
31 |
| -class COMMClass { |
32 |
| -public: |
33 |
| - // to be tested: check if can be made a big pin initialization |
34 |
| - |
35 |
| - /** |
36 |
| - * Shutdown RS485 and CAN LEDs |
37 |
| - */ |
38 |
| - void init() { |
39 |
| - //SHUTDOWN OF RS485 LEDS |
40 |
| - digitalWrite(PinNameToIndex(PA_0), LOW); |
41 |
| - digitalWrite(PinNameToIndex(PI_9), LOW); |
42 |
| - //SHUTDOWN OF CAN LEDS |
43 |
| - digitalWrite(PinNameToIndex(PB_8), HIGH); |
44 |
| - digitalWrite(PinNameToIndex(PH_13), HIGH); |
45 |
| - |
46 |
| - // SET DEFAULTS for RS485 |
47 |
| - rs485Enable(false); |
48 |
| - rs485ModeRS232(false); |
49 |
| - rs485FullDuplex(false); |
50 |
| - rs485YZTerm(false); |
51 |
| - rs485ABTerm(false); |
52 |
| - rs485Slew(false); |
53 |
| - } |
54 |
| - |
55 |
| - /** |
56 |
| - * Set the CAN transceiver in Normal mode. In this mode, the transceiver |
57 |
| - * can transmit and receive data via the bus lines CANH and CANL. |
58 |
| - */ |
59 |
| - void enableCAN() { |
60 |
| - can_disable = 0; |
61 |
| - } |
62 |
| - |
63 |
| - /** |
64 |
| - * Set the CAN transceiver in standby (low power) mode. In this mode the |
65 |
| - * transceiver will not be able to transmit or correctly receive data via the bus lines. |
66 |
| - * The wake-up filter on the output of the low-power receiver does not latch bus dominant states, |
67 |
| - * but ensures that only bus dominant and bus recessive states that persist longer than tfltr(wake) |
68 |
| - * bus are reflected on pin RXD. |
69 |
| - */ |
70 |
| - void disableCAN() { |
71 |
| - can_disable = 1; |
72 |
| - } |
73 |
| - |
74 |
| - arduino::UART _UART4_ {PA_0, PI_9, NC, NC}; |
75 |
| - mbed::CAN can {PB_8, PH_13}; |
76 |
| - |
77 |
| - RS485Class rs485 {_UART4_, PinNameToIndex(PA_0), PinNameToIndex(PI_13), PinNameToIndex(PI_10)}; |
78 |
| - |
79 |
| - void rs485Enable(bool enable) { digitalWrite(PinNameToIndex(PG_9), enable ? HIGH : LOW); } |
80 |
| - void rs485ModeRS232(bool enable) { digitalWrite(PinNameToIndex(PA_10), enable ? LOW : HIGH); } |
81 |
| - void rs485YZTerm(bool enable) { digitalWrite(PinNameToIndex(PI_15), enable ? HIGH : LOW); } |
82 |
| - void rs485ABTerm(bool enable) { digitalWrite(PinNameToIndex(PI_14), enable ? HIGH : LOW); } |
83 |
| - void rs485Slew(bool enable) { digitalWrite(PinNameToIndex(PG_14), enable ? LOW : HIGH); } |
84 |
| - void rs485FullDuplex(bool enable) { |
85 |
| - digitalWrite(PinNameToIndex(PA_9), enable ? LOW : HIGH); |
86 |
| - if (enable) { |
87 |
| - // RS485 Full Duplex require YZ and AB 120 Ohm termination enabled |
88 |
| - rs485YZTerm(true); |
89 |
| - rs485ABTerm(true); |
90 |
| - } |
91 |
| - } |
92 |
| - |
93 |
| -private: |
94 |
| - mbed::DigitalOut can_disable = mbed::DigitalOut(PA_13, 0); |
95 |
| -}; |
96 |
| - |
97 |
| -extern COMMClass comm_protocols; |
98 |
| - |
99 |
| -} |
100 |
| -#endif |
| 15 | +#endif /* __ARDUINO_MACHINE_CONTROL_H */ |
0 commit comments