WIP
This commit is contained in:
parent
ee09dcef00
commit
83f510bb59
13 changed files with 213 additions and 64 deletions
|
@ -28,6 +28,7 @@ uint32_t GetDmeMask(uint32_t stream);
|
|||
uint32_t GetTeMask(uint32_t stream);
|
||||
uint32_t GetHtMask(uint32_t stream);
|
||||
uint32_t GetTcMask(uint32_t stream);
|
||||
uint32_t GetFeMask(uint32_t stream);
|
||||
|
||||
void InitDmaInfo(DMAINFO *info, DMA_TypeDef *dma, uint32_t stream);
|
||||
|
||||
|
|
|
@ -36,6 +36,11 @@ void InitUartStatus(
|
|||
struct crcstatus_t *crcStatus,
|
||||
PACKETRECEIVEDCALLBACK packetReceivedCallback, void * packetReceivedCallbackParam)
|
||||
{
|
||||
uint32_t status = usart->SR;
|
||||
volatile uint32_t tmpreg = usart->DR; // clearing some of the error/status bits in the USART
|
||||
(void) tmpreg;
|
||||
(void) status;
|
||||
|
||||
st->usart = usart;
|
||||
InitDmaInfo(&st->rxDmaInfo, dma, stream_rx);
|
||||
InitDmaInfo(&st->txDmaInfo, dma, stream_tx);
|
||||
|
@ -60,6 +65,13 @@ void InitUartStatus(
|
|||
AttachCrcTask(crcStatus, &st->crcSlot, st->crcTasks, 2);
|
||||
memset(&st->stats, 0, sizeof(st->stats));
|
||||
|
||||
*GetIfcReg(dma, stream_rx) =
|
||||
GetTcMask(stream_rx) | GetHtMask(stream_rx) |
|
||||
GetTeMask(stream_rx) | GetFeMask(stream_rx) | GetDmeMask(stream_rx);
|
||||
*GetIfcReg(dma, stream_tx) =
|
||||
GetTcMask(stream_tx) | GetHtMask(stream_tx) |
|
||||
GetTeMask(stream_tx) | GetFeMask(stream_tx) | GetDmeMask(stream_tx);
|
||||
|
||||
LL_DMA_EnableIT_TC(dma, stream_rx);
|
||||
LL_DMA_EnableIT_TE(dma, stream_rx);
|
||||
LL_DMA_EnableIT_TC(dma, stream_tx);
|
||||
|
@ -98,16 +110,8 @@ uint8_t PostPacket(USARTSTATUS *status, uint8_t const *payload, uint16_t length,
|
|||
|
||||
BuildHeader(&status->txBuffer, status->txSerial++, length);
|
||||
uint16_t payloadLength = RoundUpTo4(length);
|
||||
if(payload) {
|
||||
#ifdef USART_USE_MEMCPY_DMA
|
||||
if((uint32_t)payload & 3)
|
||||
memcpy(status->txBuffer.packet.payload, payload, length);
|
||||
else
|
||||
MemcpyDma(status->txBuffer.packet.payload, payload, length);
|
||||
#else
|
||||
if(payload)
|
||||
memcpy(status->txBuffer.packet.payload, payload, length);
|
||||
#endif
|
||||
}
|
||||
status->txBuffer.requestedLength = sizeof(USARTPACKETHEADER) + payloadLength + sizeof(uint32_t); // +4 for the hash
|
||||
status->txBuffer.busy = 1;
|
||||
status->txBuffer.error = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue