tmp 1
This commit is contained in:
parent
bc01b1f0e8
commit
5d5fd4bc83
256 changed files with 163824 additions and 189151 deletions
109
components/app/application.cpp
Normal file
109
components/app/application.cpp
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* ll_testbed.cpp
|
||||
*
|
||||
* Created on: Oct 28, 2019
|
||||
* Author: abody
|
||||
*/
|
||||
#ifdef USE_CPLUSPLUS
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "f4ll/packetusart.h"
|
||||
#include "f4ll/crchandler.h"
|
||||
#include "f4ll/memcpydma.h"
|
||||
#include "f4ll/consolehandler.h"
|
||||
#include "f4ll/irqlock.h"
|
||||
#include "f4ll/strutil.h"
|
||||
|
||||
extern "C" {
|
||||
#include "main.h"
|
||||
#include "globals.h"
|
||||
#include "config.h"
|
||||
}
|
||||
#include "globals_cpp.h"
|
||||
|
||||
#define PACKAGE_DELAY_MS 0
|
||||
#define STATS_DELAY_MS 1000
|
||||
|
||||
|
||||
#define ADDINFO(b,s,u) \
|
||||
b += strcpy_ex(b,s); \
|
||||
b += uitodec(b,u);
|
||||
|
||||
extern "C" void MainLoop()
|
||||
{
|
||||
uint8_t const text2Send[] __attribute__((aligned(16))) =
|
||||
"Megszentsegtelenithetetlensegeskedeseitekert\r\n"
|
||||
"--------------------------------------------\r\n\0\0\0";
|
||||
|
||||
|
||||
f4ll::MemcpyDma::Init(MEMCPY_DMA_ENGINE, MEMCPY_DMA_STREAM);
|
||||
f4ll::CrcHandler::Init(DMA2, LL_DMA_STREAM_4);
|
||||
f4ll::ConsoleHandler::Init(UART4, CONSOLE_DMA_ENGINE, 0u, CONSOLE_TX_DMA_STREAM);
|
||||
|
||||
f4ll::PacketUsart u1{ USART1, DMA2, LL_DMA_STREAM_2, LL_DMA_STREAM_7 };
|
||||
f4ll::PacketUsart u2{ USART2, DMA1, LL_DMA_STREAM_5, LL_DMA_STREAM_6 };
|
||||
f4ll::PacketUsart u3{ USART3, DMA1, LL_DMA_STREAM_1, LL_DMA_STREAM_3 };
|
||||
f4ll::PacketUsart u6{ USART6, DMA2, LL_DMA_STREAM_1, LL_DMA_STREAM_6 };
|
||||
|
||||
f4ll::PacketUsart * usarts[] = { &u1, &u2, &u3, &u6 };
|
||||
f4ll::PacketUsart **dst = g_usarts;
|
||||
for(auto usart: usarts)
|
||||
*dst++ = usart;
|
||||
|
||||
uint32_t lastStatsTick = 0;
|
||||
uint32_t prevSentTick = 0;
|
||||
uint8_t statId = 0;
|
||||
|
||||
uint32_t tmp = sizeof(text2Send) - 1;
|
||||
uint32_t randmask = 0x80000000;
|
||||
|
||||
do {
|
||||
if(randmask & tmp)
|
||||
break;
|
||||
} while((randmask = randmask >> 1));
|
||||
--randmask;
|
||||
|
||||
lastStatsTick = HAL_GetTick();
|
||||
|
||||
for(auto u : g_usarts)
|
||||
u->SetupReceive();
|
||||
|
||||
for(;;) {
|
||||
uint32_t tick = HAL_GetTick();
|
||||
bool send = PACKAGE_DELAY_MS ? (tick - prevSentTick > PACKAGE_DELAY_MS) : 1;
|
||||
|
||||
if(send)
|
||||
prevSentTick += PACKAGE_DELAY_MS;
|
||||
|
||||
for(auto u : g_usarts) {
|
||||
if(!u->IsTxBusy() && send) {
|
||||
//DIAG_ENTER_BUSY();
|
||||
auto len = sizeof(text2Send) - 1 - (rand() & randmask);
|
||||
f4ll::MemcpyDma::Instance().Copy(u->GetTxPacketBuffer(), text2Send, len);
|
||||
u->PostPacket(nullptr, len);
|
||||
//DIAG_EXIT_BUSY();
|
||||
}
|
||||
for(uint16_t rIdx = 0; rIdx < 2; ++rIdx)
|
||||
if(u->IsRxBusy((bool)rIdx) || u->IsRxFailed(rIdx)) {
|
||||
u->GetRxPacketBuffer(rIdx);
|
||||
// ...
|
||||
u->RxProcessed((bool)rIdx);
|
||||
}
|
||||
}
|
||||
if(tick - lastStatsTick > STATS_DELAY_MS) {
|
||||
f4ll::ConsoleHandler::Instance().PrintStats(statId, *g_usarts[statId]);
|
||||
lastStatsTick += STATS_DELAY_MS;
|
||||
++statId;
|
||||
if(statId >= sizeof(g_usarts) / sizeof(g_usarts[0]))
|
||||
statId = 0;
|
||||
}
|
||||
// uint32_t ein = LL_GPIO_ReadInputPort(KEY1_GPIO_Port);
|
||||
// if(!(ein & KEY1_Pin)) {
|
||||
// void (*fptr)(void) = (void (*)(void))(void*)0xa0000000;
|
||||
// fptr();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
#endif // USE_CPLUSPLUS
|
Loading…
Add table
Add a link
Reference in a new issue