mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-05 15:33:57 -04:00
AP_Common: Make the char_to_hex method a common method
This commit is contained in:
parent
8743ca226c
commit
1e91dfe9d6
@ -83,3 +83,19 @@ void strncpy_noterm(char *dest, const char *src, size_t n)
|
|||||||
}
|
}
|
||||||
memcpy(dest, src, len);
|
memcpy(dest, src, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return the numeric value of an ascii hex character
|
||||||
|
*
|
||||||
|
* @param[in] a Hexadecimal character
|
||||||
|
* @return Returns a binary value
|
||||||
|
*/
|
||||||
|
int16_t char_to_hex(char a)
|
||||||
|
{
|
||||||
|
if (a >= 'A' && a <= 'F')
|
||||||
|
return a - 'A' + 10;
|
||||||
|
else if (a >= 'a' && a <= 'f')
|
||||||
|
return a - 'a' + 10;
|
||||||
|
else
|
||||||
|
return a - '0';
|
||||||
|
}
|
||||||
|
@ -149,6 +149,9 @@ bool hex_to_uint8(uint8_t a, uint8_t &res); // return the uint8 value of an asc
|
|||||||
*/
|
*/
|
||||||
void strncpy_noterm(char *dest, const char *src, size_t n);
|
void strncpy_noterm(char *dest, const char *src, size_t n);
|
||||||
|
|
||||||
|
// return the numeric value of an ascii hex character
|
||||||
|
int16_t char_to_hex(char a);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Bit manipulation
|
Bit manipulation
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user