/* Function for reading the index previously written to the "index data base" in NV memory. */
static uint8_t gzp_index_db_read(void)
/* Function for reading the index previously written to the "index data base" in NV memory. */
static uint8_t gzp_index_db_read(void)
{
    uint8_t retval;
    int16_t i;
    for(i = (GZP_INDEX_DB_SIZE - 1); i >= 0; i--)
    {
        retval = *(uint8_t*)(GZP_INDEX_DB_ADR + i);
        if(retval != 0xff)
        {
          break;
        }
    }
    if(retval == 0xff)
    {
        retval = GZP_PARAMS_DB_MAX_ENTRIES;
    }
    else if((retval & 0xf0) != 0xf0)
    {
        retval >>= 4;
    }
    else
    {
        retval &= 0x0f;
    }
    return retval;
}