/**
* @brief BCD to hexadecimal number.
* @param ConverData: Conversion data
* @retval ConverResult: Conversion result
*/
uint8_t TypeConver_BCDHEX(uint8_t ConverData)
{
uint8_t ConverResult;
ConverResult = 0;
ConverResult = ((ConverData >> 4) * 10 + (ConverData & 0x0F));
return ConverResult;
}
/**
* @brief Long to Chacter.
* @param ConverData: Conversion data
* @param Char:
* @retval None
*/
void TypeConver_LongCharacter(uint32_t ConverData, uint8_t *Char)
{
uint8_t i;
uint8_t a[5];
a[0] = ConverData / 10000 ;
ConverData = ConverData - a[0]*10000;
a[1] = ConverData / 1000;
ConverData = ConverData - a[1]*1000;
a[2] = ConverData / 100;
ConverData = ConverData - a[2]*100;
a[3] = ConverData / 10;
a[4] = ConverData % 10;
for(i = 0;i < 5;i++)
{
Char[i] = '0' + a[i];
}
}
/**
* @brief Long to Chacter.
* @param ConverData: Conversion data
* @param Char:
* @retval None
*/
void TypeConver_IntChacter(uint16_t ConverData, uint8_t *Char)
{
uint8_t i;
uint8_t a[4];
a[0] = ConverData / 1000 ;
ConverData = ConverData - a[0]*1000;
a[1] = ConverData / 100;
ConverData = ConverData - a[1]*100;
a[2] = ConverData / 10;
a[3] = ConverData % 10;
for(i = 0;i < 4;i++)
{
Char[i] = '0' + a[i];
}
}
/**
* @brief Byte to Chacter.
* @param ConverData: Conversion data
* @param Char:
* @retval None
*/
void TypeConver_ByteChacter(uint8_t ConverData, uint8_t *Char)
{
uint8_t i;
uint8_t a[3];
a[0] = ConverData / 100;
ConverData = ConverData - a[0]*100;
a[1] = ConverData / 10;
a[2] = ConverData % 10;
for(i = 0;i < 3;i++)
{
Char[i] = '0' + a[i];
}
}
C语音数据类型转换
最新推荐文章于 2024-03-27 14:14:03 发布