Added function to STM32F4 DMA stream driver returning its status (running or not).

pull/180/head
Silvano Seva 2023-04-15 09:56:15 +02:00
rodzic 2931a83303
commit 4d03d1535c
1 zmienionych plików z 15 dodań i 5 usunięć

Wyświetl plik

@ -154,7 +154,7 @@ public:
* The stream does not stop immediately but only when it reaches the half
* or the end of the transfer.
*/
void stop()
inline void stop()
{
stopTransfer = true;
}
@ -163,18 +163,28 @@ public:
* Forcefully stop an ongoing DMA stream.
* Calling this function causes the immediate stop of an ongoing stream.
*/
void halt()
inline void halt()
{
stopTransfer = true;
NVIC_SetPendingIRQ(IRQn);
}
/**
* Query che the current status of the stream.
*
* @return true if the stream is active, false otherwise.
*/
inline bool running()
{
return (stream->CR & DMA_SxCR_EN) ? true : false;
}
/**
* Register a function to be called on stream end.
*
* @param callback: std::function for the stream end callback.
*/
void setEndTransferCallback(std::function<void()>&& callback)
inline void setEndTransferCallback(std::function<void()>&& callback)
{
streamEndCallback = callback;
}
@ -267,7 +277,7 @@ public:
/**
* Low-level shutdown of a DMA stream.
*/
static void terminate()
static inline void terminate()
{
NVIC_DisableIRQ(IRQn());
getStream()->CR = 0;
@ -279,7 +289,7 @@ public:
*
* @param hdl: pointer to the StreamHandler class managing the stream.
*/
static void IRQhandleInterrupt(StreamHandler *hdl)
static inline void IRQhandleInterrupt(StreamHandler *hdl)
{
uint32_t flags = readIrqFlags();
hdl->IRQhandler(flags);