I'm aware that if you need microseconds timing precision, STM32L1 is not a good bet. For that matter, is better to use an 8bit/16bit micro and interface it with I2C or SPI. Onewire protocol is one example where you need good timing for the thing to work.
Still, I have a delay function in assembler that is good enough for such a case, it works well when I use it with HAL/LL driver no matter the level of optimization in the gcc compiler, but it needs some tweaking if I use it with SPL driver and it depends on the optimization level. If optimization is disabled, if I use SPL, I can't make it work. Worse, I do not posses an oscilloscope. As I understand, freepascal do not optimize for ARM yet...
Anyway, I need help to write this function in freepascal, can anyone know how to do it? Thank you, whatever the outcome!
static __INLINE void my_delay_us(uint32_t us)
{
us *= 24; // it was 32
us--;
asm volatile(" mov r0, %[us]\n\t"
"1: subs r0, #5\n\t"
" bhi 1b\n\t"
:
: [us] "r" (us)
: "r0");
}