StdPJ/Core/Src/APP/BSP/ug96/ug96.c
/**
  * @brief  Parses and returns number from string.
  * @param  ptr: pointer to string
  * @param  cnt: pointer to the number of parsed digit
  * @retval integer value.
  */
@brief  Parses and returns number from string.
@param  ptr: pointer to string
@param  cnt: pointer to the number of parsed digit
@retval integer value.
@brief Parses and returns number from string . @param ptr : pointer to string @param cnt : pointer to the number of parsed digit @retval integer value .
static int32_t  ParseNumber(char* ptr, uint8_t* cnt)
{
    uint8_t minus = 0, i = 0;
    int32_t sum = 0;
    if (*ptr == '-') {                            
        minus = 1;
        ptr++;
        i++;
    }
    while (CHARISNUM(*ptr)) {                     
        sum = 10 * sum + CHAR2NUM(*ptr);
        ptr++;
        i++;
    }
    if (cnt != NULL) {                            
        *cnt = i;
    }
    if (minus) {                                  
        return 0 - sum;
    }
    return sum;                                   
}
static int32_t ParseNumber ( char * ptr , uint8_t * cnt ) { uint8_t minus = 0 , i = 0 ; int32_t sum = 0 ; if ( * ptr == ' ' ) { minus = 1 ; ptr ++ ; i ++ ; } while ( CHARISNUM ( * ptr ) ) { sum = 10 * sum + CHAR2NUM ( * ptr ) ; ptr ++ ; i ++ ; } if ( cnt != NULL ) { * cnt = i ; } if ( minus ) { return 0 - sum ; } return sum ; }
@brief  Parses and returns number from string.
@brief Parses and returns number from string .
/* Check for minus character */ /* Parse number */ /* Save number of characters used for number */ /* Minus detected */ /* Return number */