Return Types of Functions #51
Replies: 3 comments 10 replies
-
You need some kind of error checking inside this function. I2C communication could fail for some reason and this needs to be returned to the calling function somehow. Thats why volume is returned by reference through the parameter. esp_err_t is in fact an int I belive. I was always focused on IDF and they use this type. |
Beta Was this translation helpful? Give feedback.
-
Hello again, thank you for the explanation. I will try that. At some point I got lost...Now I can move on. I never used that way of returning a value. For me it was easier to use an explicit type (Boolean, String or whatever). If I have finished all functions how should I test the code. Do you have an recommended way? |
Beta Was this translation helpful? Give feedback.
-
Hi @CarlosDerSeher .. It's harder than I thought. I never used that IDF in such a low level. So it might be good if you could briefly explain for what these declarations are used:
Can I left them as they are? (I copied them from another driver..) EDIT2: **EDIT: ** I got the Project building with my additions to the driver. I didn't hook my board up (until now). Can I ignore these warnings?
If yes I can do the next steps (adding it to the Menu etc..) |
Beta Was this translation helpful? Give feedback.
-
Hi @CarlosDerSeher ,
I am wondering how the code is structured. As you know I am working on a new DAC-Type (TAS5805M). I got some information how to use the dac and luckily the implementation is almost finished.
For me it's not clear how you use the functions. For example here:
esp_err_t adau1961_get_volume(int *vol)
Why you use the return type esp_err_t and not an int instead?
Did I miss something? - Is the esp_err_t the preferred method to use in this case?
Thank you in advance!
Beta Was this translation helpful? Give feedback.
All reactions