How can I plan my software to avoid overwriting and interdependencies

I am writing a motor controller that has a couple of interfaces (buttons, Bluetooth, tactile buttons), which is a task that is constantly growing to be bigger than I thought. I tried to just go to it, starting with low-level modules (for example, writing code for talking on the I2C bus), and then above (code for talking to a specific device on the I2C bus ...), but too often I have to dive back into my lower modules to handle quirks that I haven't adapted. It either takes a lot of time or I get really hacked code.

My goal is an 8-bit MCU, so from the bottom up it seems that I can make better use of the hardware. If I go from top to bottom, I have no structure to build or test / debug.

I tried to make some general diagrams and them for certain levels / drivers, but I'm not sure how to structure them, so I can be very systematic and avoid the odd signal that should go through 2-3 layers.

I think this is the reason for the degree of CS? I am an electrical engineer: P

+3
source share
7 answers

You seem to be on the right track. Sometimes, no planning prevents you from remaking or reorganizing parts of the system at a later date. Try the following tips:

  • , .
  • , .
  • . . . .
  • , .
  • , .
  • , .
  • . , . .
+3

, API , . .

:

  • , , , . , .. , .
  • " " , . , , - -, - , . , API, , .
  • , . , , -/ , , . . , "" API - . , .
  • . - . , , , . , //, , , . , " " . , . . , . ( , ) , .
+3

, . , , , , . - . , , , , , . , , .

, , . , , , , , . , .

, . . - ( . , ). , .

, , , , . , . UML . . , , - OOD.

+2

, , , , , , , , ( / / ) , .

, , , . , , , , , , , .

, , . , , , , , , .

" " , , , ( , ), - , .

UML . , , , , .

: " ": -)

+2

.

"":

  • O.

, :

GetKnobLevel()
GetNextKeyboardButton

-

syscall(DRIVERNUMBER, command)

/ .

, . , .

, :

---
Application
---
OS
---
Driver communicators
---
drivers
---
hardware

, ( ...). , .

MCU , x86, .

, , "overengineery" . , , , .

, , .

, , , . - .

, , .

- . , .

+1

, .

- - . , . , . - , .

0

, " -": " , ".

" . . ".

, , - , . . . , , , .

0

Source: https://habr.com/ru/post/1759425/


All Articles