Fine-tuning "libs" API
This commit is contained in:
parent
ffec0e2b57
commit
e8cff640ac
18 changed files with 244 additions and 204 deletions
|
@ -12,12 +12,12 @@
|
|||
#define PACKAGE_DELAY_MS 0
|
||||
#define STATS_DELAY_MS 1000
|
||||
|
||||
// UART DMA RX TX
|
||||
// USART DMA RX TX
|
||||
// 1 2 2 7
|
||||
// 2 1 5 6
|
||||
// 3 1 1 3
|
||||
// 6 2 1 6
|
||||
// console UART
|
||||
// console USART
|
||||
// 4 1 2 4
|
||||
|
||||
void MainLoop()
|
||||
|
@ -53,7 +53,7 @@ void MainLoop()
|
|||
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);
|
||||
&g_crcStatus, idx + USARTCOUNT, idx, NULL, NULL);
|
||||
memcpy(GetTxBuffer(&g_uartStatuses[idx]), text2Send, sizeof(text2Send) -1);
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ void MainLoop()
|
|||
PrintStats((char*)g_statsBuf, statId, &g_uartStatuses[statId].stats, UART4, &g_ConsoleTxDmaInfo);
|
||||
lastStatsTick += STATS_DELAY_MS;
|
||||
++statId;
|
||||
if(statId >= UARTCOUNT)
|
||||
if(statId >= USARTCOUNT)
|
||||
statId = 0;
|
||||
}
|
||||
uint32_t ein = LL_GPIO_ReadInputPort(KEY1_GPIO_Port);
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
#include <inttypes.h>
|
||||
#include "main.h"
|
||||
#include <stats.h>
|
||||
|
||||
void MainLoop();
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#ifndef CONFIG_H_
|
||||
#define CONFIG_H_
|
||||
|
||||
#define UARTCOUNT 4
|
||||
#define CRCTASKCOUNT (UARTCOUNT * 2)
|
||||
#define USARTCOUNT 4
|
||||
#define CRCTASKCOUNT (USARTCOUNT * 2)
|
||||
#define USART1_OFFSET 0
|
||||
#define USART2_OFFSET 1
|
||||
#define USART3_OFFSET 2
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
#include "globals.h"
|
||||
|
||||
UARTSTATUS g_uartStatuses[UARTCOUNT];
|
||||
USARTSTATUS g_uartStatuses[USARTCOUNT];
|
||||
|
||||
struct crcstatus_t g_crcStatus;
|
||||
CRCSTATUS g_crcStatus;
|
||||
|
||||
DMAINFO g_ConsoleTxDmaInfo;
|
||||
uint8_t g_statsBuf[128];
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
#include "dma_helper.h"
|
||||
#include "crc_handler.h"
|
||||
|
||||
extern UARTSTATUS g_uartStatuses[UARTCOUNT];
|
||||
extern USARTSTATUS g_uartStatuses[USARTCOUNT];
|
||||
|
||||
extern struct crcstatus_t g_crcStatus;
|
||||
extern CRCSTATUS g_crcStatus;
|
||||
|
||||
extern DMAINFO g_ConsoleTxDmaInfo;
|
||||
extern uint8_t g_statsBuf[128];
|
||||
|
|
6
app/platform/crc_ll.h
Normal file
6
app/platform/crc_ll.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef __PLATFORM_CRC_LL_H_INCLUDED
|
||||
#define __PLATFORM_CRC_LL_H_INCLUDED
|
||||
|
||||
#include "crc.h"
|
||||
|
||||
#endif // __PLATFORM_CRC_LL_H_INCLUDED
|
6
app/platform/dma_ll.h
Normal file
6
app/platform/dma_ll.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef __PLATFORM_DMA_LL_H_INCLUDED
|
||||
#define __PLATFORM_DMA_LL_H_INCLUDED
|
||||
|
||||
#include "dma.h"
|
||||
|
||||
#endif // __PLATFORM_DMA_LL_H_INCLUDED
|
6
app/platform/usart_ll.h
Normal file
6
app/platform/usart_ll.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef __PLATFORM_USART_LL_H_INCLUDED
|
||||
#define __PLATFORM_USART_LL_H_INCLUDED
|
||||
|
||||
#include "usart.h"
|
||||
|
||||
#endif // __PLATFORM_USART_LL_H_INCLUDED
|
68
app/stats.h
68
app/stats.h
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
* stats.h
|
||||
*
|
||||
* Created on: Sep 16, 2019
|
||||
* Author: abody
|
||||
*/
|
||||
|
||||
#ifndef STATS_H_
|
||||
#define STATS_H_
|
||||
#include "diag.h"
|
||||
|
||||
#ifndef DIAG_ERROR_EVENT
|
||||
# define DIAG_ERROR_EVENT()
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint32_t overrun;
|
||||
uint32_t hdrError;
|
||||
uint32_t lastErrHdr;
|
||||
uint32_t payloadErrror;
|
||||
uint32_t pep1, pep2;
|
||||
uint32_t dmaError;
|
||||
uint32_t rcvd;
|
||||
uint32_t premature_hdr;
|
||||
uint32_t premature_payload;
|
||||
uint32_t sent;
|
||||
uint32_t skiped;
|
||||
} STATS;
|
||||
|
||||
#ifndef STATS_DISABLED
|
||||
static inline void StatsIncOverrun(STATS *s) {
|
||||
++s->overrun;
|
||||
}
|
||||
static inline void StatsIncHdrError(STATS *s, uint32_t hdr) {
|
||||
DIAG_ERROR_EVENT();
|
||||
++s->hdrError;
|
||||
}
|
||||
static inline void StatsIncPayloadError(STATS *s, uint32_t pep1, uint32_t pep2) {
|
||||
DIAG_ERROR_EVENT();
|
||||
++s->payloadErrror;
|
||||
s->pep1 = pep1;
|
||||
s->pep2 = pep2;
|
||||
}
|
||||
static inline void StatsIncDmaError(STATS *s) {
|
||||
DIAG_ERROR_EVENT();
|
||||
++s->dmaError;
|
||||
}
|
||||
static inline void StatsIncRcvd(STATS *s) {
|
||||
++s->rcvd;
|
||||
}
|
||||
static inline void StatsIncPremature_hdr(STATS *s) {
|
||||
++s->premature_hdr;
|
||||
}
|
||||
static inline void StatsIncPremature_payload(STATS *s) {
|
||||
++s->premature_payload;
|
||||
}
|
||||
static inline void StatsIncSent(STATS *s) {
|
||||
++s->sent;
|
||||
}
|
||||
static inline void StatsAddSkiped(STATS *s, uint8_t cnt) {
|
||||
s->skiped += s->rcvd > 2 ? cnt : 0;
|
||||
}
|
||||
|
||||
#else // STATS_DISABLED
|
||||
#define StatsIncSent(x)
|
||||
#endif // STATS_DISABLED
|
||||
|
||||
#endif /* STATS_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue