I decided that the code that interacts directly with the hardware registers can’t be rewritten to be much clearer to read. There should be a lot of commenting in the code explaining why the registers need to be set that way. That is a big project and since I didn’t write most of that code, I don’t understand a lot of it. I am choosing this week to just make sure this code is formatted in the Allman style and leave commenting for later.
I have now worked through all the .c and .h files in the project to made sure they are formatted in the Allman style. I decided to go back through all the names used for variables, functions, constants, and macros and format them all the same. Since Espressif named all the system calls in lowercase underscore separated, system calls will follow that format.
The rest of the naming I decided as follows:
Macro: All caps with underscore separation followed by ()
Constant: All caps with underscore separation
Variable: Lower camel case
Non System functions: lower camel case with ()
I used Eclipse’ refactor feature to make these changes to all the files at once.
I had a couple of .h files that didn’t refactor correctly, but once i got those fixed, the code compiled and ran just like before.
The firmware is getting easier to maintain and edit. I hope to move forward with the electronics design again soon. I bought and received a new mixed signal oscilloscope and received it this last week, I plan on doing a review of it next week. I have uploaded these changes to Github, click the link in the right hand column to get the firmware source.
Have you used Eclipse’ refactor function before? Did you have similar problems?