[Open_electroporator] culture shock build automation script

John Griessen john at cibolo.com
Sat May 5 15:59:57 UTC 2018


On 05/05/2018 12:17 AM, Nathan McCorkle wrote:
> Duplication of code is a cardinal sin of good software engineering :) I was a little upset that I saw all the duplication in the 
> low-level.py files in the pyflex code dir... it's really ugly and hard to navigate and debug or understand the parallel 
> (duplicate) code flows.

Sure, it's ugly.  As we have left it being ugly for many months, time for it must be hard to justify.
As we see some time, I can see how to make it much prettier with some generic register bit writing functions to call.

Most MCU registers are 16 bits and datasheets show them as rows of cells with definitions inside, similar to spreadsheets.
So dealing with them in binary or decimal seems helpful when it comes to finding them in datasheets.
Some part of writing those register bit ranges could use decimal, since the datasheets also number the cells in decimal 0 to 15.

I'd like to see some functions
that stuff a range of bits specified as 14:12 for bit 14,13,12 in a vector of three bits.

then you could have the generic range writer function use inputs like:

range_write(110, 14, 12, OC2M, TIMx_CCMR1, TIM5)

It would refer to other definition functions where:

TIMx_CCMR1  is equated to stm.TIM_CCMR1
and
TIM5 is equated with      stm.TIM5

And it would use one function that gets the current contents of a 16 bit register, [generically for any of them]

and it would call
stm.mem16[stm.TIM5 + stm.TIM_CCMR1] =  `[the previous content plus 0b110 stuffed in the right bit range.]`


More information about the open_electroporator mailing list