rfLPC
A low level library for using NXP's LPC17xx SoC. Config is given for MBED prototyping board
LIBC tiny subset

The rflpc library implement a very small subset of the libc. More...

Functions

int printf (const char *format,...)
 Formated output function. More...
 
void rflpc_printf_set_putchar (int(*putchar_func)(int c))
 Sets the internal function pointer that is used by printf to output a character. More...
 
void * memcpy (void *dest, const void *src, size_t n)
 Copies memory from one buffer to another. More...
 
void * memset (void *dest, int c, size_t n)
 Fills the first n bytes of the memory area pointed to by dest with the constant byte c. More...
 
void srand (unsigned int seed)
 Sets the seed used by rand() to generate the pseudo-random sequence. More...
 
int rand (void)
 Returns a pseudo-random integer in the range of 0 to RAND_MAX. More...
 
int rand_r (unsigned int *seed)
 Returns a pseudo-random integer in the range of 0 to RAND_MAX. More...
 
#define RAND_MAX   2147483647
 The maximum value of a random number. More...
 

Detailed Description

The rflpc library implement a very small subset of the libc.

Macro Definition Documentation

#define RAND_MAX   2147483647

The maximum value of a random number.

The rand function generate number in [0, RAND_MAX] range.

Definition at line 41 of file rand.h.

Function Documentation

void* memcpy ( void *  dest,
const void *  src,
size_t  n 
)

Copies memory from one buffer to another.

Note
if the src and dest are aligned on 4 bytes, copy is done by 4 bytes block, so it should be faster if the given pointers are aligned on a 4 byte boundary
Warning
dest and src should not overlap.
Parameters
[out]destdestination buffer
[in]srcsource buffer
[in]nnumber of bytes to copy
Returns
void* memset ( void *  dest,
int  c,
size_t  n 
)

Fills the first n bytes of the memory area pointed to by dest with the constant byte c.

Note
if the src and dest are aligned on 4 bytes, memset is done by 4 bytes block, so it should be faster if the given pointers are aligned on a 4 byte boundary
Parameters
[out]destdestination buffer
[in]cvalue to set
[in]nnumber of bytes to copy
Returns
int printf ( const char *  format,
  ... 
)

Formated output function.

This function is similar to stdio's printf. However, it only handles:

  • %d
  • %x/X (%0?X can also be used, where ? is a digit [1-9])
  • %p
  • %c
  • %s
Note
If another format char is used, int is assumed to skip argument, but nothing is printed unless RFLPC_VERBOSE_PRINTF is defined when compiling lib. If RFLPC_CONFIG_ENABLE_ATOMIC_PRINTF is defined, interrupts are disabled when entering printf and enabled before exiting
Warning
This function uses a function pointer to output each character. By default, it uses a function which eventually call rflpc_uart_putchar with RFLPC_UART0. If you want to use your own putchar function, you have to call rflpc_printf_set_putchar to set the function pointer.
Parameters
[in]formatThe format string. Prefer to use constant string instead of user supplied string to be sure that some escape characters are not put for wrong purpose.
int rand ( void  )

Returns a pseudo-random integer in the range of 0 to RAND_MAX.

Warning
this function is not reentrant!
int rand_r ( unsigned int *  seed)

Returns a pseudo-random integer in the range of 0 to RAND_MAX.

Note
This function is reentrant as it uses a user defined pointer for its seed.
Parameters
seedpointer to the current value of the seed.
void rflpc_printf_set_putchar ( int(*)(int c)  putchar_func)

Sets the internal function pointer that is used by printf to output a character.

By default, it uses a function that call rflpc_uart_putchar with RFLPC_UART0.

Parameters
[in]putchar_funca pointer to a function that takes a character to put and returns it.
void srand ( unsigned int  seed)

Sets the seed used by rand() to generate the pseudo-random sequence.

Parameters
seedthe seed to use.