cancel
Showing results for 
Search instead for 
Did you mean: 

Circular buffer

cyrildufoing
Associate II
Posted on December 20, 2015 at 20:58

Someone knows how to implement a circular buffer with HAL Drivers F1? 

5 REPLIES 5
carmine
Associate II
Posted on December 20, 2015 at 22:54

You can find several good implementations around on the web. Google knows about them.

There are no special requirements for using a ring buffer on a STM32 MCU. For example, you can consider

https://github.com/cnoviello/mastering-stm32/tree/master/nucleo-f103RB/Middlewares/RingBuffer

 even if I don't like it too much (it could be implemented in a faster way if it's ok to lose a bit of ''safeness''). Please, consider that this library works well only if you have just two ''threads'' operating on it. Otherwise, you have to add locking mechanisms. 

tm3341
Associate II
Posted on December 21, 2015 at 12:44

Check this ''thread'' safe implementation.

https://github.com/MaJerle/stm32fxxx_hal_libraries/blob/master/00-STM32_LIBRARIES/tm_stm32_buffer.h

If you don't use my libs, then just remove includes for libraries in this library:

//Remove these 2 lines:

#include ''stm32fxxx_hal.h''

#include ''defines.h''

And you are ready to go.

Lib supports memory allocation with malloc, or if you want, you specify it by yourself.

Ask here for more info, if needed.

Hi Carmine,

Thanks for your post.

One question for you and I would be very glad if you could answer. I am using STM32F407VG-DISC1 board.

I have checked the repo you ve provided. I wonder that, is that OK if I copy ringbuffer.c under core-->src and also ringbuffer.h under core -->inc.

Then, can I use ringbuffer functions with ease ?

demir_0-1709749501221.png

 

You're responding to a very old post, I think several forum transitions ago, the OP might not respond.

I'd imagine you can use C rule to determine how best to integrate this into your build. Ring / Circular buffers being a pretty basic concept.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thanks for the heads up.

I have already raised a question here, but no one responded yet, meanwhile I was looking for a solution then I noticed this thread.

As it is pretty basic, could you please check my issue in above link and also please point me to the right direction ?