LL_MemcpyDma
This commit is contained in:
parent
4de62c7f74
commit
bdc796a8ce
8 changed files with 45 additions and 19 deletions
|
@ -15,4 +15,23 @@ LL_MemcpyDma::LL_MemcpyDma(DMA_TypeDef *dma, uint32_t stream)
|
|||
LL_DMA_EnableIT_TC(dma, stream);
|
||||
}
|
||||
|
||||
void* LL_MemcpyDma::Copy(void *dst, void const *src, uint16_t length)
|
||||
{
|
||||
LL_DMA_SetM2MSrcAddress(GetDma(), GetStream(), (uint32_t)src);
|
||||
LL_DMA_SetM2MDstAddress(GetDma(), GetStream(), (uint32_t)dst);
|
||||
LL_DMA_SetDataLength(GetDma(), GetStream(), (length+3)/4 );
|
||||
m_busy = 1;
|
||||
LL_DMA_EnableStream(GetDma(), GetStream());
|
||||
while(m_busy);
|
||||
return dst;
|
||||
}
|
||||
|
||||
void LL_MemcpyDma::DmaTransferCompleted()
|
||||
{
|
||||
if(*GetIsReg() & GetTcMask()) { // DMA transfer complete
|
||||
*GetIcfReg() = GetTcMask();
|
||||
LL_DMA_DisableStream(GetDma(), GetStream());
|
||||
m_busy = 0;
|
||||
}
|
||||
}
|
||||
} /* namespace f4ll */
|
||||
|
|
|
@ -8,15 +8,19 @@
|
|||
#ifndef LL_MEMCPY_DMA_H_
|
||||
#define LL_MEMCPY_DMA_H_
|
||||
#include "ll_dmahelper.h"
|
||||
#include "singleton.h"
|
||||
|
||||
namespace f4ll {
|
||||
|
||||
class LL_MemcpyDma : private LL_DmaHelper
|
||||
class LL_MemcpyDma : public Singleton<LL_MemcpyDma>, private LL_DmaHelper
|
||||
{
|
||||
friend class Singleton<LL_MemcpyDma>;
|
||||
public:
|
||||
void* Copy(void *dst, void const *src, uint16_t length);
|
||||
void DmaTransferCompleted();
|
||||
private:
|
||||
LL_MemcpyDma(DMA_TypeDef *dma, uint32_t stream);
|
||||
void Copy(void *dst, void const *src, uint16_t length);
|
||||
|
||||
bool volatile m_busy = false;
|
||||
};
|
||||
|
||||
} /* namespace f4ll */
|
||||
|
|
|
@ -10,8 +10,7 @@ public:
|
|||
static T &Init(Args &&... args)
|
||||
{
|
||||
static T instance{ std::forward<Args>(args)... };
|
||||
if(!m_instance)
|
||||
m_instance = &instance;
|
||||
m_instance = &instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue