Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Commit b70498b

Browse files
Ernesto E. Lopez Cmarqdevxper1234
authored
added javadox documentation for Arduino_MachineControl.h (#62)
* added javadox documentation for Arduino_MachineControl.h * RTC: Added javadoc comments * Apply suggestions from code review Accepted revision Co-authored-by: per1234 <[email protected]> * Update Arduino_MachineControl.h Co-authored-by: marqdevx <[email protected]> Co-authored-by: per1234 <[email protected]> Co-authored-by: marqdevx <[email protected]>
1 parent c833895 commit b70498b

File tree

2 files changed

+311
-5
lines changed

2 files changed

+311
-5
lines changed

‎src/Arduino_MachineControl.h‎

Lines changed: 169 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,50 @@
1717

1818
namespacemachinecontrol{
1919

20+
/**
21+
* The RTDClass allows enabling and selecting the different temperature sensor inputs
22+
* (RTD and thermocouples)
23+
*/
2024
classRTDClass{
2125
public:
26+
27+
/**
28+
* Select the input channel to be read (3 channels available)
29+
*
30+
* @param channel (0-2)
31+
*/
2232
voidselectChannel(int channel){
2333
for (int i=0; i<3; i++){
2434
ch_sel[i] = (i == channel ? 1 : 0);
2535
}
2636
delay(150);
2737
}
38+
39+
/**
40+
* Enable the CS of the Thermocouple to digital converter
41+
* Disable the CS for the RTD to digital converter
42+
*/
2843
voidenableTC(){
2944
rtd_th = 0;
3045
digitalWrite(PI_0, LOW);
3146
digitalWrite(PA_6, HIGH);
3247
}
48+
49+
/**
50+
* Enable the CS of the RDT to digital converter.
51+
* Disable the CS of the Thermocouple to digital converter
52+
*/
3353
voidenableRTD(){
3454
rtd_th = 1;
3555
digitalWrite(PI_0, HIGH);
3656
digitalWrite(PA_6, LOW);
3757

3858
}
59+
60+
/**
61+
* Disable Chip select for both RTD and thermocouple digital converters.
62+
*
63+
*/
3964
voiddisableCS(){
4065
digitalWrite(PI_0, HIGH);
4166
digitalWrite(PA_6, HIGH);
@@ -53,9 +78,18 @@ extern RTDClass temp_probes;
5378

5479
static mbed::CAN _can(PB_8, PH_13);
5580

81+
82+
/**
83+
* The COMMClass is used to initialize the CAN and RS485 LEDs and
84+
* establish the power mode of the CAN bus.
85+
*/
5686
classCOMMClass{
5787
public:
5888
// to be tested: check if can be made a big pin initialization
89+
90+
/**
91+
* Shutdown RS485 and CAN LEDs
92+
*/
5993
voidinit(){
6094
//SHUTDOWN OF RS485 LEDS
6195
digitalWrite(PinNameToIndex(PA_0), LOW);
@@ -73,9 +107,21 @@ class COMMClass{
73107
rs485Slew(false);
74108
}
75109

110+
/**
111+
* Set the CAN transceiver in Normal mode. In this mode, the transceiver
112+
* can transmit and receive data via the bus lines CANH and CANL.
113+
*/
76114
voidenableCAN(){
77115
can_disable = 0;
78116
}
117+
118+
/**
119+
* Set the CAN transceiver in standby (low power) mode. In this mode the
120+
* transceiver will not be able to transmit or correctly receive data via the bus lines.
121+
* The wake-up filter on the output of the low-power receiver does not latch bus dominant states,
122+
* but ensures that only bus dominant and bus recessive states that persist longer than tfltr(wake)
123+
* bus are reflected on pin RXD.
124+
*/
79125
voiddisableCAN(){
80126
can_disable = 1;
81127
}
@@ -118,8 +164,18 @@ extern COMMClass comm_protocols;
118164
#definech2_in3 ch_in[10]
119165
#definech2_in4 ch_in[11]
120166

167+
/**
168+
* The AnalogInClass is used to set the resistor configuration for the right type of analog sensor
169+
* i.e. NTC sensors, 4-10mA or 0-10V.
170+
*/
121171
classAnalogInClass{
122172
public:
173+
174+
/**
175+
* read the sampled voltage from the selected channel
176+
* @param channel integer for selecting the analog input (0, 1 or 2)
177+
* @return the analog value between 0.0 and 1.0 normalized to a 16-bit value (uint16_t)
178+
*/
123179
uint16_tread(int channel){
124180
uint16_t value = 0;
125181
switch (channel){
@@ -139,6 +195,10 @@ class AnalogInClass{
139195
return value;
140196
}
141197

198+
/**
199+
* Configure the input resistor dividers to have a ratio of 0.28.
200+
* Maximum input voltage is 10V.
201+
*/
142202
voidset0_10V(){
143203
ch0_in1 = 1;
144204
ch0_in2 = 1;
@@ -156,6 +216,10 @@ class AnalogInClass{
156216
ch2_in4 = 1;
157217
}
158218

219+
/**
220+
* Enable a 120 ohm resistor to GND to convert the 4-20mA sensor currents to voltage.
221+
* Note: 24V are available from the carrier to power the 4-20mA sensors.
222+
*/
159223
voidset4_20mA(){
160224
ch0_in1 = 1;
161225
ch0_in2 = 0;
@@ -173,6 +237,10 @@ class AnalogInClass{
173237
ch2_in4 = 0;
174238
}
175239

240+
/**
241+
* Enable a 100K resistor in series with the reference voltage.
242+
* The voltage sampled is the voltage division between the 100k resistor and the input resistor (NTC/PTC)
243+
*/
176244
voidsetNTC(){
177245
ch0_in1 = 0;
178246
ch0_in2 = 0;
@@ -217,6 +285,12 @@ extern AnalogInClass analog_in;
217285

218286
classAnalogOutClass{
219287
public:
288+
289+
/**
290+
* Set output voltage value (PWM)
291+
* @param index select channel
292+
* @param voltage desired output voltage (max 10.5V)
293+
*/
220294
voidwrite(int index, float voltage){
221295
if (voltage < 0){
222296
voltage = 0;
@@ -237,6 +311,12 @@ class AnalogOutClass{
237311
break;
238312
}
239313
}
314+
315+
/**
316+
* Set the PWM period (frequency)
317+
* @param index select channel
318+
* @param period integer for selecting the period in ms
319+
*/
240320
voidperiod_ms(int index, uint8_t period){
241321
switch (index){
242322
case0:
@@ -279,11 +359,21 @@ extern AnalogOutClass analog_out;
279359
TODO: writeme
280360
Use QEI library for mbed since it implements index pin
281361
*/
362+
/**
363+
* The EncoderClass is a wrapper for manipulating Quadrature Encoder Interface devices.
364+
*/
282365
classEncoderClass{
283366
public:
367+
/**
368+
* returns the encoder variable depending on the index
369+
* @param index integer for selecting the encoder (0 or 1)
370+
* @return enc_0 for index = 0, enc_1 for index = 1
371+
*/
284372
EncoderClass()
285373
: enc_0{PJ_8, PH_12, PH_11, 0}
286374
, enc_1{PC_13, PI_7, PJ_10, 0}{};
375+
376+
287377
QEI& operator[](int index){
288378
switch (index){
289379
case0:
@@ -308,14 +398,35 @@ extern EncoderClass encoders;
308398
TODO: check if Wire and address are correct
309399
*/
310400

401+
402+
/**
403+
* The ProgrammableDIOClass is used to initialize the IOExpanders and configure the
404+
* thermal shutdown mode of the high side switches.
405+
*/
311406
classProgrammableDIOClass : publicArduinoIOExpanderClass{
312407
public:
408+
409+
/**
410+
* Test connection with the IOExpander and set all the pins to the default mode.
411+
* @return true if OK, false if fault
412+
*/
313413
boolinit(){
314414
returnbegin(IO_ADD);
315415
}
416+
417+
/**
418+
* Configures the thermal shutdown of the high-side switches (TPS4H160) to operate in latch mode.
419+
* The output latches off when thermal shutdown occurs.
420+
*/
316421
voidsetLatch(){
317422
prog_latch_retry = 0;
318423
}
424+
425+
/**
426+
* Configures the thermal shutdown of the high-side switches (TPS4H160) to operate in auto-retry mode.
427+
* The output automatically recovers when TJ < T(SD) – T(hys), but the current is limited to ICL(TSD)
428+
* to avoid repetitive thermal shutdown.
429+
*/
319430
voidsetRetry(){
320431
prog_latch_retry = 1;
321432
}
@@ -326,20 +437,48 @@ class ProgrammableDIOClass : public ArduinoIOExpanderClass{
326437
extern ProgrammableDIOClass digital_programmables;
327438

328439

440+
/**
441+
* The DigitalOutputClass is used to interface with the IO Expander and
442+
* set the digital outputs.
443+
*/
329444
classDigitalOutputsClass{
330445
public:
446+
447+
/**
448+
* Set all digital outputs at the same time.
449+
* @param val 8 bit integer to set all 8 channels. e.g:
450+
* Set all to HIGH -> val = 255 (0b11111111)
451+
* Set all to LOW -> val = 0 (0b00000000)
452+
*/
331453
voidsetAll(uint8_t val){
332454
for (int i = 0; i < 8; i++){
333455
out[i] = val & 0x1;
334456
val = val >> 1;
335457
}
336458
}
459+
460+
/**
461+
* Set a particular digital output
462+
* @param index digital output to be set
463+
* @param val set value (HIGH/LOW)
464+
*/
337465
voidset(int index, bool val){
338466
out[index] = val;
339467
}
468+
469+
/**
470+
* Configures the thermal shutdown of the high-side switches (TPS4H160) to operate in latch mode.
471+
* The output latches off when thermal shutdown occurs.
472+
*/
340473
voidsetLatch(){
341474
dig_out_latch_retry = 0;
342475
}
476+
477+
/**
478+
* Configures the thermal shutdown of the high-side switches (TPS4H160) to operate in auto-retry mode.
479+
* The output automatically recovers when TJ < T(SD) – T(hys), but the current is limited to ICL(TSD)
480+
* to avoid repetitive thermal shutdown.
481+
*/
343482
voidsetRetry(){
344483
dig_out_latch_retry = 1;
345484
}
@@ -358,14 +497,22 @@ extern DigitalOutputsClass digital_outputs;
358497

359498
classProgrammableDINClass : publicArduinoIOExpanderClass{
360499
public:
500+
/**
501+
* Test connection with the IOExpander and set all the pins to the default mode.
502+
* @return true if OK, false if fault
503+
*/
361504
boolinit(){
362505
returnbegin(DIN_ADD);
363506
}
364507
};
365508

366509
extern ProgrammableDINClass digital_inputs;
367510

368-
511+
/**
512+
* The RtcControllerClass is a wrapper for the PCF8563TClass() that is used to
513+
* set and get the time to/from the PCF8563T RTC.
514+
*
515+
*/
369516
classRtcControllerClass : publicPCF8563TClass{
370517
public:
371518
mbed::DigitalIn int_pin = mbed::DigitalIn(PB_9,PullUp);
@@ -376,21 +523,41 @@ class RtcControllerClass : public PCF8563TClass{
376523
extern RtcControllerClass rtc_controller;
377524

378525

379-
526+
/**
527+
* The USB Class is used to enable/disable the power of the USBA (Host) and configure
528+
* the callbacks for the different host types (i.e. Keyboard, mouse, storage device etc).
529+
*/
380530
classUSBClass{
381531
public:
532+
/**
533+
* Configures the USB host by providing the list of callbacks to support the behaviour
534+
* of the host (keyboard, mouse, storage device etc)
535+
*
536+
* @param class_table a pointer to the structure containing the list of callbacks
537+
*/
382538
voidinit(consttusbh_class_reg_t *class_table){
383539
usb.Init(USB_CORE_ID_FS, class_table);
384540
}
385541

542+
/**
543+
* Enable power to USBA VBUS.
544+
*/
386545
voidpowerEnable(){
387546
power = 0;
388547
}
389548

549+
/**
550+
* Disable power to USBA VBUS.
551+
*/
390552
voidpowerDisable(){
391553
power = 1;
392554
}
393555

556+
/**
557+
* Flag to indicate overcurrent, overtemperature, or reverse−voltage conditions on the USBA VBUS.
558+
* Active−low open−drain output.
559+
* @return true if OK, false if fault
560+
*/
394561
boolvflagRead(){
395562
return usbflag;
396563
}

0 commit comments

Comments
(0)