Initial public release.
This commit is contained in:
parent
7b169e8116
commit
dac4af8d25
255 changed files with 68595 additions and 2 deletions
48
2020TPCApp1.cydsn/COMM/COMM_Util.c
Normal file
48
2020TPCApp1.cydsn/COMM/COMM_Util.c
Normal file
|
@ -0,0 +1,48 @@
|
|||
/** \file
|
||||
* \brief This file implements utility functions used by the communications package.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \ingroup CONSOLE
|
||||
*/
|
||||
|
||||
/* Include Files */
|
||||
#include "KTag.h"
|
||||
|
||||
/* Local Definitions and Constants */
|
||||
|
||||
/* Public Variables */
|
||||
|
||||
/* Private Variables */
|
||||
static char8 uint64_buffer[20+1];
|
||||
|
||||
/* Private Function Prototypes */
|
||||
|
||||
/* Public Functions */
|
||||
|
||||
//! Converts a UInt64 to a NULL-terminated string.
|
||||
/*!
|
||||
* This function is necessary because newlib-nano does not support "%llu" / #PRIu64.
|
||||
* \see https://answers.launchpad.net/gcc-arm-embedded/+question/257014
|
||||
*
|
||||
* \note This function is not reentrant!
|
||||
*
|
||||
* \param value pointer to the digital input object.
|
||||
* \return pointer to a NULL-terminated string containing the base-10 textual representation of #value.
|
||||
*/
|
||||
char8 * COMM_UInt64ToDecimal(uint64_t value)
|
||||
{
|
||||
char8 * p = uint64_buffer + sizeof(uint64_buffer);
|
||||
*(--p) = 0x00;
|
||||
|
||||
for (bool first_time = true; value || first_time; first_time = false)
|
||||
{
|
||||
const uint32_t digit = value % 10;
|
||||
const char c = '0' + digit;
|
||||
*(--p) = c;
|
||||
value = value / 10;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Private Functions */
|
Loading…
Add table
Add a link
Reference in a new issue