Failure of parameters transfer

Hello,
I'm trying to build an ESP32-TMC2209 application. The setup of the TMC2209 includes invocation of a hardware serial port to send serial commands from the MPU to the TMC2209 driver.

The construction of the HardwareSerial class requires three parameters. The first parameters are defaulted in the TMC2209 driver itself. My understanding is that the third parameter transferred to TMC2209::setup invokes the SerialAddress class, and for this it should get the index of the serial port (0 to 3, in this case) so the transmitted serial port address will comply with the hardware setting of AD0-AD1. However, I get the error messages that I embewdded in the below text

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
void setup()   
{  
  Serial.begin(9600);  
  delay(500);  
  Serial.println("Station initiated");  
}  
/*********************************************************/  
void loop()   
{  
  Serial.println("Acknowledgement");  
}  
/**********************************************************************  ******************  
class HardwareSerial1   
{  
// library that handles hardware serial. Copyright (c) 2006 Nicholas   Zambetti. All right reserved  
  public:  
    HardwareSerial1(int uart_nr);  
};  

HardwareSerial::HardwareSerial(int uart_nr) :   
_uart_nr(uart_nr),   
_uart(NULL),  
_rxBufferSize(256),  
_txBufferSize(0),   
_onReceiveCB(NULL),   
_onReceiveErrorCB(NULL),  
_onReceiveTimeout(true),  
_rxTimeout(10),  
_eventTask(NULL)  
{  
}  
HardwareSerial hardwareSerial;  
/****************************************************************************************/  
class TMC2209  
{  
// authored by Peter Polidoro peter@polidoro.io. Includes HardwareSerial.h (through arduino.h)  
  public:  
    enum SerialAddress  
    {  
      SERIAL_ADDRESS_0=0,  
      SERIAL_ADDRESS_1=1,  
      SERIAL_ADDRESS_2=2,  
      SERIAL_ADDRESS_3=3,  
    };  
    void setup(  
      HardwareSerial & serial,  
      long serial_baud_rate=115200,  
      SerialAddress serial_address=0);    
///// <<<< error for the above line: invalid conversion from 'int' to 'TMC2209 SerialAddress' [-fpermissive]  
};  
void TMC2209::setup(  
  HardwareSerial & serial,  
  long serial_baud_rate,  
  SerialAddress serial_address)  
{  
// The serial_address will become (in subsequesnt method setOperationModeToSerial)  
// a part of the datagram transmitted to the TMC2209 during read or write  
}  

TMC2209 stepper_driver;  
/****************************************************************************************/  
class Stepper   
{  
// a module I wrote that, as a part of the setup, should deliver the selected serial port  
  public:  
    bool   begin(uint8_t ch);  
};  
bool Stepper::begin(uint8_t ch)  
{  
  stepper_driver.setup(ch);  // uint8_t ch is contains the identifier of the serial port   
///// <<<< error for the above line: cannot bind non-const lvalue reference of type 'HardwareSerial&' to an rvalue of type 'HardwareSerial'  
/****************************************************************************************/ 
SerialAddress serial_address=0);

Don't you want:

SerialAddress serial_address=SERIAL_ADDRESS_0);
OK, thank you very much. It realy solved one of the errors. How to solve the other, in row 70?
L46 - why is serial passed by ref? Why not by const ref?
seeplus,
thank you for the reference. All the references to "serial" are to a port built in TMC2209, which is a smart stepper driver. The "setup" method accepts 3 parameters, two of them - L46 and L47 - are default values, while I change the 3rd - L48 drom the deault value (L70).
The core problem is that I can't find a way to send the selected value to the "setup" method, which is actually in the "method" whic is a part of the standard library "HardwareSerial".
Last edited on
What happens if you change L46 to

 
const HardwareSerial & serial, 


and L52 to

 
const HardwareSerial & serial, 


Unfortunately it didn't help.
Topic archived. No new replies allowed.