Kinda works
This commit is contained in:
parent
f3d345e2e3
commit
662a7a9b12
40 changed files with 2851 additions and 26 deletions
39
components/f4ll_cpp/memcpydma.cpp
Normal file
39
components/f4ll_cpp/memcpydma.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* memcpy_dma.c
|
||||
*
|
||||
* Created on: Oct 1, 2019
|
||||
* Author: abody
|
||||
*/
|
||||
#include <f4ll_cpp/dmahelper.h>
|
||||
#include <f4ll_cpp/memcpydma.h>
|
||||
|
||||
namespace f4ll_cpp {
|
||||
|
||||
MemcpyDma::MemcpyDma(DMA_TypeDef *dma, uint32_t stream) :
|
||||
DmaHelper(dma, stream),
|
||||
m_busy(false)
|
||||
{
|
||||
LL_DMA_EnableIT_TC(dma, stream);
|
||||
}
|
||||
|
||||
void* MemcpyDma::Copy(void *dst, void const *src, size_t length)
|
||||
{
|
||||
while(m_busy);
|
||||
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 = true;
|
||||
LL_DMA_EnableStream(GetDma(), GetStream());
|
||||
return dst;
|
||||
}
|
||||
|
||||
void MemcpyDma::HandleDmaIrq(void)
|
||||
{
|
||||
if(*GetIsReg() & GetTcMask()) { // DMA transfer complete
|
||||
*GetIfcReg() = GetTcMask();
|
||||
LL_DMA_DisableStream(GetDma(), GetStream());
|
||||
m_busy = false;
|
||||
}
|
||||
}
|
||||
|
||||
} // f4ll_cpp
|
Loading…
Add table
Add a link
Reference in a new issue