git subrepo pull components/f4ll_c

subrepo:
  subdir:   "components/f4ll_c"
  merged:   "5d26fdc"
upstream:
  origin:   "git@git.pcmuhely.hu:compi/f4ll_c.git"
  branch:   "master"
  commit:   "5d26fdc"
git-subrepo:
  version:  "0.4.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "5d6aba9"
This commit is contained in:
Attila Body 2019-12-06 14:32:53 +01:00
parent 357b30b344
commit b9114f049a
10 changed files with 243 additions and 189 deletions

View file

@ -7,10 +7,10 @@
#ifndef USART_HANDLER_H_
#define USART_HANDLER_H_
#include <f4ll_c/crcscheduler.h>
#include <inttypes.h>
#include <platform/usart_ll.h>
#include "f4ll_c/dmahelper.h"
#include <f4ll_c/crcscheduler.h>
#ifdef __cplusplus
extern "C" {
@ -18,25 +18,43 @@ extern "C" {
struct usart_buffer_t;
struct usartstatus_t;
struct usartpacket_t;
typedef void (*pku_packetreceivedcallback_t)(void *userParam, struct usart_buffer_t *buffer);
void Pku_Init(
void Pu_Init(
struct usartstatus_t *st, USART_TypeDef *usart, DMA_TypeDef *dma,
uint32_t stream_rx, uint32_t stream_tx,
struct crcstatus_t *crcStatus,
pku_packetreceivedcallback_t packetReceivedCallback, void * packetReceivedCallbackParam);
uint8_t* Pku_GetTxBuffer(struct usartstatus_t *status);
uint8_t* Pu_GetTxBuffer(struct usartstatus_t *status);
uint8_t Pku_Post(struct usartstatus_t *status, uint8_t const *payload, uint16_t length, struct crcstatus_t *crcStatus, uint8_t waitForCrcQueue);
void Pku_SetupReceive(struct usartstatus_t *status);
void Pku_SetupTransmit(USART_TypeDef *usart, DMA_TypeDef* dma, uint32_t stream, void *buffer, uint32_t length);
void Pku_ConsumePacket(struct usartstatus_t *status, uint8_t packetIndex);
uint8_t Pu_Post(struct usartstatus_t *status, uint8_t const *payload, uint8_t length, struct crcstatus_t *crcStatus, uint8_t waitForCrcQueue);
void Pu_SetupReceive(struct usartstatus_t *status);
void Pu_SetupTransmit(USART_TypeDef *usart, DMA_TypeDef* dma, uint32_t stream, void *buffer, uint32_t length);
void Pu_ConsumePacket(struct usartstatus_t *status, uint8_t packetIndex);
void Pku_HandleRxDmaIrq(struct usartstatus_t *status);
void Pku_HandleTxDmaIrq(struct usartstatus_t *status);
void Pku_HandleUsartIrq(struct usartstatus_t *status);
void Pu_HandleRxDmaIrq(struct usartstatus_t *status);
void Pu_HandleTxDmaIrq(struct usartstatus_t *status);
void Pu_HandleUsartIrq(struct usartstatus_t *status);
// !!!Private!!! exposed only to make unit testing possible
void Pu_RxCrcComputedCallback(void *callbackParm, uint32_t calculatedCrc, uint8_t success);
uint8_t Pu_CheckHeader(struct usartpacket_t *packet);
DECLARE_MOCK(Pu_Init);
DECLARE_MOCK(Pu_GetTxBuffer);
DECLARE_MOCK(Pu_Post);
DECLARE_MOCK(Pu_SetupReceive);
DECLARE_MOCK(Pu_SetupTransmit);
DECLARE_MOCK(Pu_ConsumePacket);
DECLARE_MOCK(Pu_ConsumePacket);
DECLARE_MOCK(Pu_HandleRxDmaIrq);
DECLARE_MOCK(Pu_HandleTxDmaIrq);
DECLARE_MOCK(Pu_HandleUsartIrq);
DECLARE_MOCK(Pu_RxCrcComputedCallback);
DECLARE_MOCK(Pu_CheckHeader);
/******************************************************************************************
*
@ -94,54 +112,11 @@ struct usartstatus_t {
struct usart_stats stats;
uint8_t activeRxBuf;
pku_packetreceivedcallback_t packetReceivedCallback;
void *packetReceivedCallbacParam;
void *packetReceivedCallbackParam;
struct usart_buffer_t txBuffer;
struct usart_buffer_t rxBuffers[2];
};
#ifndef USART_STATS_DISABLED
static inline void StatsIncOverrun(struct usart_stats *s) {
++s->overrun;
}
static inline void StatsIncHdrError(struct usart_stats *s, uint32_t hdr) {
++s->hdrError;
s->lastErrHdr = hdr;
}
static inline void StatsIncPayloadError(struct usart_stats *s, uint32_t pep1, uint32_t pep2) {
++s->payloadErrror;
s->pep1 = pep1;
s->pep2 = pep2;
}
static inline void StatsIncDmaError(struct usart_stats *s) {
++s->dmaError;
}
static inline void StatsIncRcvd(struct usart_stats *s) {
++s->rcvd;
}
static inline void StatsIncPremature_hdr(struct usart_stats *s) {
++s->premature_hdr;
}
static inline void StatsIncPremature_payload(struct usart_stats *s) {
++s->premature_payload;
}
static inline void StatsIncSent(struct usart_stats *s) {
++s->sent;
}
static inline void StatsAddSkiped(struct usart_stats *s, uint8_t cnt) {
s->skiped += s->rcvd > 2 ? cnt : 0;
}
#else // USART_STATS_DISABLED
#define StatsIncOverrun(x)
#define StatsIncHdrError(x,y)
#define StatsIncPayloadError(x,y,z)
#define StatsIncDmaError(x)
#define StatsIncRcvd(x)
#define StatsIncPremature_hdr(x)
#define StatsIncPremature_payload(x)
#define StatsIncSent(x)
#define StatsAddSkiped(x)
#endif // USART_STATS_DISABLED
#ifdef __cplusplus
}