39 #define __FILE_ID__ "yfifo" 43 #if defined(MICROCHIP_API) 52 const char* fileid,
int line,
54 yFifoBuf *buf, u8 *buffer, u16 bufflen)
58 buf->buffsize = bufflen;
59 buf->head = buf->tail = buffer;
64 #ifdef YFIFO_USE_MUTEX 72 #ifdef YFIFO_USE_MUTEX 79 #ifdef YFIFO_USE_MUTEX 98 #ifdef YFIFO_USE_MUTEX 112 if (datalen > freespace) {
121 memcpy(buf->
tail, data, datalen);
122 buf->
tail += datalen;
127 memcpy(buf->
tail, data, cplen);
128 memcpy(buf->
buff, data + cplen, datalen - cplen);
129 buf->
tail = buf->
buff + (datalen - cplen);
136 buf->totalPushed += datalen;
141 #ifdef YFIFO_USE_MUTEX 161 memcpy(data, buf->
head, firstpart);
162 memcpy(data + firstpart, buf->
buff, datalen - firstpart);
165 buf->
head = buf->
buff + (datalen - firstpart);
168 memcpy(data, buf->
head, datalen);
170 buf->
head += datalen;
179 buf->totalPopded += datalen;
185 #ifdef YFIFO_USE_MUTEX 207 if (datalen > freespace) {
218 #ifndef MICROCHIP_API 225 #ifndef MICROCHIP_API 239 if (datalen + startofs > buf->
datasize)
242 ptr=buf->
head+startofs;
246 if (ptr + datalen >
YFIFOEND(buf)) {
248 u16 firstpart = (u16)(
YFIFOEND(buf) - ptr);
250 memcpy(data, ptr, firstpart);
251 memcpy(data + firstpart, buf->
buff, datalen - firstpart);
255 memcpy(data, ptr, datalen);
261 #ifdef YFIFO_USE_MUTEX 282 lptr = buf->
head + startofs;
291 u16 toend = (u16)(
YFIFOEND(buf) - lptr);
295 return (toend < buf->datasize ? toend : buf->
datasize);
301 #ifdef YFIFO_USE_MUTEX 314 u16
ySeekFifoEx(
yFifoBuf *buf,
const u8* pattern, u16 patlen, u16 startofs, u16 searchlen, u8 bTextCompare)
318 u16 firstmatch = 0xffff;
321 if (startofs + patlen > buf->
datasize) {
326 if (searchlen == 0 || searchlen > buf->
datasize - startofs)
327 searchlen = buf->
datasize - startofs;
328 ptr = buf->
head + startofs;
333 while (searchlen > 0 && patidx < patlen) {
335 u16 pletter = pattern[patidx];
337 if (bTextCompare && pletter >=
'A' && bletter >=
'A' && pletter <=
'z' && bletter <=
'z') {
341 if (pletter == bletter) {
343 firstmatch = startofs;
346 }
else if(patidx > 0) {
358 if (patidx == patlen) {
365 #ifdef YFIFO_USE_MUTEX 367 u16
ySeekFifo(
yFifoBuf *buf,
const u8* pattern, u16 patlen, u16 startofs, u16 searchlen, u8 bTextCompare)
372 res =
ySeekFifoEx(buf,pattern,patlen,startofs,searchlen,bTextCompare);
383 #ifdef YFIFO_USE_MUTEX 400 #ifdef YFIFO_USE_MUTEX 412 #ifndef REDUCE_COMMON_CODE 413 void yxtoa(u32 x,
char *buf, u16 len)
417 unsigned b = x & 0xf;
418 buf[--len] = (b>9u) ? b+
'a'-10 : b+
'0';
424 #if defined(USE_TYPED_NOTIFICATIONS) || !defined(MICROCHIP_API) 431 const unsigned char *p = (
const unsigned char *)funcval;
443 switch(funcValType) {
454 for(i = 0; i < funcValType; i++) {
457 buffer[2*i] = (b>9u) ? b+
'a'-10 : b+
'0';
459 buffer[2*i+1] = (b>9u) ? b+
'a'-10 : b+
'0';
467 numVal += (s32)*p++ << 8;
468 numVal += (s32)*p++ << 16;
469 numVal += (s32)*p++ << 24;
472 s32toa(numVal, buffer);
482 endp = buffer + strlen(buffer);
483 while(endp > buffer && endp[-1] ==
'0') {
486 if(endp > buffer && endp[-1] ==
'.') {
494 memcpy(&floatVal, p,
sizeof(floatVal));
499 char largeBuffer[64];
501 YSPRINTF(largeBuffer, 64,
"%.6f", floatVal);
502 endp = largeBuffer + strlen(largeBuffer);
503 while(endp > largeBuffer && endp[-1] ==
'0') {
506 if(endp > largeBuffer && endp[-1] ==
'.') {
521 for(i = 0; i < 6; i++,p++) {
void yFifoEnterCS(yFifoBuf *buf)
u16 yFifoGetUsedEx(yFifoBuf *buf)
u16 yPeekContinuousFifo(yFifoBuf *buf, u8 **ptr, u16 startofs)
u16 yPushFifoEx(yFifoBuf *buf, const u8 *data, u16 datalen)
void yInitializeCriticalSection(yCRITICAL_SECTION *cs)
void yFifoCleanup(yFifoBuf *buf)
#define NOTIFY_V2_TYPEDDATA
u16 yPushFifo(yFifoBuf *buf, const u8 *data, u16 datalen)
u16 yPeekFifo(yFifoBuf *buf, u8 *data, u16 datalen, u16 startofs)
void yFifoEmptyEx(yFifoBuf *buf)
u16 yFifoGetUsed(yFifoBuf *buf)
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
u16 yPeekContinuousFifoEx(yFifoBuf *buf, u8 **ptr, u16 startofs)
void yFifoInitEx(yFifoBuf *buf, u8 *buffer, u16 bufflen)
void yFifoLeaveCS(yFifoBuf *buf)
u16 yFifoGetFreeEx(yFifoBuf *buf)
#define PUBVAL_YOCTO_FLOAT_E3
#define YFIFOEND(fifobuf)
void decodePubVal(Notification_funydx funInfo, const char *funcval, char *buffer)
struct Notification_funydx::@10 v2
#define YSTRCPY(dst, dstsize, src)
static u16 yForceFifoEx(yFifoBuf *buf, const u8 *data, u16 datalen)
u16 yPopFifoEx(yFifoBuf *buf, u8 *data, u16 datalen)
u16 yPeekFifoEx(yFifoBuf *buf, u8 *data, u16 datalen, u16 startofs)
#define NOTIFY_V2_6RAWBYTES
u16 yForceFifo(yFifoBuf *buf, const u8 *data, u16 datalen, u32 *absCounter)
void yFifoEmpty(yFifoBuf *buf)
u16 yFifoGetFree(yFifoBuf *buf)
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
u16 ySeekFifoEx(yFifoBuf *buf, const u8 *pattern, u16 patlen, u16 startofs, u16 searchlen, u8 bTextCompare)
void yDeleteCriticalSection(yCRITICAL_SECTION *cs)
void yxtoa(u32 x, char *buf, u16 len)
u16 ySeekFifo(yFifoBuf *buf, const u8 *pattern, u16 patlen, u16 startofs, u16 searchlen, u8 bTextCompare)
u16 yPopFifo(yFifoBuf *buf, u8 *data, u16 datalen)