74 lines
1.6 KiB
C
74 lines
1.6 KiB
C
/*!
|
|
* \file OnBoard.c
|
|
*
|
|
* \brief Target xc6xxx hal spi implementation
|
|
*
|
|
* \copyright Revised BSD License, see section \ref LICENSE.
|
|
*
|
|
* \code
|
|
*
|
|
* _ __ _ ________ _
|
|
* | |/ /(_)___ / ____/ /_ (_)___
|
|
* | // / __ \/ / / __ \/ / __ \
|
|
* / |/ / / / / /___/ / / / / /_/ /
|
|
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
|
* /_/
|
|
* (C) 2022-2025 XinChip
|
|
*
|
|
* \endcode
|
|
*
|
|
* \author ( XinChip ) Alex-J
|
|
*
|
|
* \author ( XinChip )
|
|
*/
|
|
|
|
#include "OnBoard.h"
|
|
|
|
/*********************************************************************
|
|
* @fn _itoa
|
|
*
|
|
* @brief convert a 16bit number to ASCII
|
|
*
|
|
* @param num -
|
|
* buf -
|
|
* radix -
|
|
*
|
|
* @return void
|
|
*
|
|
*********************************************************************/
|
|
void _itoa(uint16 num, uint8 *buf, uint8 radix)
|
|
{
|
|
char c,i;
|
|
uint8 *p, rst[5];
|
|
|
|
p = rst;
|
|
for ( i=0; i<5; i++,p++ )
|
|
{
|
|
c = num % radix; // Isolate a digit
|
|
*p = c + (( c < 10 ) ? '0' : '7'); // Convert to Ascii
|
|
num /= radix;
|
|
if ( !num )
|
|
break;
|
|
}
|
|
|
|
for ( c=0 ; c<=i; c++ )
|
|
*buf++ = *p--; // Reverse character order
|
|
|
|
*buf = '\0';
|
|
}
|
|
|
|
/*********************************************************************
|
|
* @fn Onboard_rand
|
|
*
|
|
* @brief Random number generator
|
|
*
|
|
* @param none
|
|
*
|
|
* @return uint16 - new random number
|
|
*
|
|
*********************************************************************/
|
|
uint16 Onboard_rand( void )
|
|
{
|
|
return ( rand() );
|
|
}
|