Code will work.
Code:
void CopyBuf(const U8* Pu8Src, U8* Pu8Dest, U16 u16Len)
{
if((NULL != Pu8Src)&&(NULL != Pu8Dest)&&(u16Len > NULL))
{
while(u16Len)
{
*Pu8Dest = *Pu8Src;
Pu8Dest++;
Pu8Src++;
u16Len--;
}
}
}
Can be written in shorter way:
Code:
void CopyBuf(const U8* Pu8Src, U8* Pu8Dest, U16 u16Len)
{
while(u16Len--)
*Pu8Dest++ = *Pu8Src++;
}
Or simpy use memcpy or strcpy function of stdio.h library.
But this have to be written in different way:
Code:
CopyBuf(Pu8Data, gstUart.stTx.u8Buf + gstUart.stTx.u8BufIndex, u8Len);
Code:
#include <stdio.h>
#include <string.h>
strcpy((char*)gstUart.stTx.u8Buf + gstUart.stTx.u8BufIndex, (char*)Pu8Data);
- - - Updated - - -
Sorry, I forgot one stupid PIC limitation. It has 8 bit address data bus wide. So, any pointer operations are limited to 256 lenght. You can't keep in memory array longer than 256 bytes. So, it is only your choice to suffer with this