Code compiles
This commit is contained in:
parent
7a74273ca7
commit
2aa08f20a0
118 changed files with 119250 additions and 34 deletions
83
app/application.c
Normal file
83
app/application.c
Normal file
|
@ -0,0 +1,83 @@
|
|||
#include <string.h>
|
||||
#include "application.h"
|
||||
#include "globals.h"
|
||||
#include "strutil.h"
|
||||
#include "diag.h"
|
||||
#include "usart_handler.h"
|
||||
#include "crc_handler.h"
|
||||
#include "console_handler.h"
|
||||
|
||||
#define PACKAGE_DELAY_MS 0
|
||||
#define STATS_DELAY_MS 1000
|
||||
|
||||
// UART DMA RX TX
|
||||
// 1 2 2 7
|
||||
// 2 1 5 6
|
||||
// 3 1 1 3
|
||||
// 5 1 0 7
|
||||
// 6 2 1 6
|
||||
// console UART
|
||||
// 4 1 2 4
|
||||
|
||||
void MainLoop()
|
||||
{
|
||||
static uint8_t const text2Send[] = "------------------------------------------------\r\n| Megszentsegtelenithetetlensegeskedeseitekert |\r\n------------------------------------------------\r\n";
|
||||
|
||||
struct initdata_t {
|
||||
USART_TypeDef* uart;
|
||||
DMA_TypeDef* dma;
|
||||
uint32_t stream_rx;
|
||||
uint32_t stream_tx;
|
||||
} static const initdata[] = {
|
||||
{ USART1, DMA2, LL_DMA_STREAM_2, LL_DMA_STREAM_7 },
|
||||
{ USART2, DMA1, LL_DMA_STREAM_5, LL_DMA_STREAM_6 },
|
||||
{ USART3, DMA1, LL_DMA_STREAM_1, LL_DMA_STREAM_3 },
|
||||
{ UART5, DMA1, LL_DMA_STREAM_0, LL_DMA_STREAM_7 },
|
||||
{ USART6, DMA2, LL_DMA_STREAM_1, LL_DMA_STREAM_6 },
|
||||
};
|
||||
|
||||
uint32_t lastStatsTick = 0;
|
||||
uint32_t prevSentTick = 0;
|
||||
uint8_t statId = 0;
|
||||
|
||||
for(uint16_t idx = 0; idx < sizeof(g_uartStatuses) / sizeof(g_uartStatuses[0]); ++idx) {
|
||||
struct initdata_t const *id = &initdata[idx];
|
||||
InitUartStatus(&g_uartStatuses[idx], id->uart, id->dma, id->stream_rx, id->stream_tx,
|
||||
&g_crcStatus, idx + UARTCOUNT, idx);
|
||||
memcpy(GetTxBuffer(&g_uartStatuses[idx]), text2Send, sizeof(text2Send) -1);
|
||||
}
|
||||
|
||||
InitCrcStatus(&g_crcStatus, DMA2, LL_DMA_STREAM_4);
|
||||
|
||||
InitDmaInfo(&g_ConsoleTxDmaInfo, DMA1, LL_DMA_STREAM_3);
|
||||
LL_DMA_EnableIT_TC(g_ConsoleTxDmaInfo.dma, g_ConsoleTxDmaInfo.stream);
|
||||
LL_DMA_EnableIT_TE(g_ConsoleTxDmaInfo.dma, g_ConsoleTxDmaInfo.stream);
|
||||
|
||||
LL_SYSTICK_EnableIT();
|
||||
|
||||
for(uint16_t idx = 0; idx < sizeof(g_uartStatuses) / sizeof(g_uartStatuses[0]); ++idx)
|
||||
SetupReceive(&g_uartStatuses[idx]);
|
||||
|
||||
for(;;) {
|
||||
uint8_t send = PACKAGE_DELAY_MS ? (g_tickCount - prevSentTick > PACKAGE_DELAY_MS) : 1;
|
||||
if(send)
|
||||
prevSentTick += PACKAGE_DELAY_MS;
|
||||
|
||||
for(uint16_t idx = 0; idx < sizeof(g_uartStatuses) / sizeof(g_uartStatuses[0]); ++idx) {
|
||||
if(!g_uartStatuses[idx].txBuffer.busy && send) {
|
||||
PostPacket(&g_uartStatuses[idx], NULL, sizeof(text2Send) -1, &g_crcStatus);
|
||||
}
|
||||
for(uint16_t rIdx = 0; rIdx < 2; ++rIdx)
|
||||
if(g_uartStatuses[idx].rxBuffers[rIdx].busy || g_uartStatuses[idx].rxBuffers[rIdx].error)
|
||||
ConsumePacket(&g_uartStatuses[idx], rIdx, &g_crcStatus);
|
||||
|
||||
}
|
||||
if(g_tickCount - lastStatsTick > STATS_DELAY_MS) {
|
||||
PrintStats((char*)g_statsBuf, statId, &g_uartStatuses[statId].stats, USART3, &g_ConsoleTxDmaInfo);
|
||||
lastStatsTick += STATS_DELAY_MS;
|
||||
++statId;
|
||||
if(statId >= UARTCOUNT)
|
||||
statId = 0;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue