User manual
LPCXpresso Experiment Kit - User’s Guide
Page 119
Copyright 2013 © Embedded Artists AB
/*****************************************************************************
** Function name: hasPattern
**
** Descriptions: Tests if pBuf starts with pPattern.
**
** parameters: Buffer to search and pattern to match
** Returned value: 1 if pBuf starts with pPattern, 0 otherwise
**
*****************************************************************************/
static uint8_t hasPattern(uint8_t *pBuf, uint8_t *pPattern)
{
while(*pBuf != END_OF_MESSAGE && *pPattern != END_OF_MESSAGE){
if(*pBuf != *pPattern){
return 0;
}
pPattern++;
pBuf++;
}
return 1;
}
/*****************************************************************************
** Function name: pointToNextValue
**
** Descriptions: Moves past the next divider
**
** parameters: Pointer to the string to search
** Returned value: None
**
*****************************************************************************/
static void pointToNextValue(uint8_t **ppBuf)
{
while(**ppBuf != END_OF_MESSAGE) {
if (**ppBuf == DIVIDER) {
(*ppBuf)++; // point to the start of next value
break;
}
(*ppBuf)++;
}
}
/*****************************************************************************
** Function name: convertCordinateToDegree
**
** Descriptions: Converts the pBuf string which is in the
** "ddmm.mmmm" format into an integer representation
**
** parameters: The buffer, the resulting integer and the
** length of the buffer
** Returned value: None
**
*****************************************************************************/
static void convertCordinateToDegree(uint8_t *pBuf, int* pDegree, int len)
{
int index = 0;
int sum = 0;
int deg = 0;
int min = 0;
int div = 0;
int pow = 1;
for (index = len; index >=0; index--) {
if (pBuf[index] == '.') {
div = 1;
continue;
}
sum += pow * (pBuf[index] & 0x0F);
if (index > 0) {
pow *= 10;
div *= 10;
}
}