Hi!
I recently successfully coded usb bluetooth demo for stm32f4-discovery, based on ST usb lib and the btstack project.
Now I'd like it to be integrated with ChibiOS, but to my understanding, ST usb lib code size is considerable and it is not feasible to rewrite it from scratch, so I'm thinking of sort of weak integration. For instance, may be it's possible to just wrap relevant usb ISR into OS with minimal effort for the time being.
What do you think?
stm32 bluetooth usb integration RFC
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: stm32 bluetooth usb integration RFC
Hi,
It is possible for sure, one user already integrated the ST USB library with ChibiOS in the past (see GNUK project). Just take care to rewrite (or wrap) interrupt handlers using ChibiOS macros if you plan invoking OS APIs from ISRs or callbacks.
Giovanni
It is possible for sure, one user already integrated the ST USB library with ChibiOS in the past (see GNUK project). Just take care to rewrite (or wrap) interrupt handlers using ChibiOS macros if you plan invoking OS APIs from ISRs or callbacks.
Giovanni
Re: stm32 bluetooth usb integration RFC
Thank you very much for your prompt responce and good starting point link, Giovanni.
Now I've faced another issue: contrary to ST usb device lib, used in GNUK, current OTG/host usb lib version frivolously uses long (I've found 200ms at least) delays from inside ISR. I tried to emulate them using gptPolledDelay() (yes, I've read ChibiOS docs, but it was just an experiment anyway) with very limited success: it hangs after few successful stages.
Have you any idea how to fix it in a least intrusive way? I'd implemented it using spinlocks or something similar, but I don't want to convert ISR into state machine.
Now I've faced another issue: contrary to ST usb device lib, used in GNUK, current OTG/host usb lib version frivolously uses long (I've found 200ms at least) delays from inside ISR. I tried to emulate them using gptPolledDelay() (yes, I've read ChibiOS docs, but it was just an experiment anyway) with very limited success: it hangs after few successful stages.
Have you any idea how to fix it in a least intrusive way? I'd implemented it using spinlocks or something similar, but I don't want to convert ISR into state machine.
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: stm32 bluetooth usb integration RFC
200mS loops inside an interrupt handler? LOL, great design there.
Anyway, yesterday I added a RT counter feature to the STM32 HAL driver, you may checkout the current trunk and use that for delays. In hal.h there are examples. Note, it is still untested but very simple code.
Giovanni
Anyway, yesterday I added a RT counter feature to the STM32 HAL driver, you may checkout the current trunk and use that for delays. In hal.h there are examples. Note, it is still untested but very simple code.
Giovanni
Re: stm32 bluetooth usb integration RFC
Apparently it was not so scary: huge delays were present in a single ISR branch (usb reset). So, I have managed to integrate my code with ChibiOS/RT as we discussed above, now it works (possibly not very stable yet, but anyway). Thank you for your support and great OS, it looks truly fantastic to me. Keep going good work.
BTW, in case anybody interested, my code (although in very early stage) is available at https://github.com/byly/uubt
BTW, in case anybody interested, my code (although in very early stage) is available at https://github.com/byly/uubt