python-on-a-chip online compiler

Dependencies:   mbed TSI

Embed: (wiki syntax)

« Back to documentation index

sli.c File Reference

sli.c File Reference

Standard Library Interface. More...

Go to the source code of this file.

Functions

void * sli_memcpy (unsigned char *to, unsigned char const *from, unsigned int n)
 Copies a block of memory in RAM.
int sli_strlen (char const *s)
 Obtain string length.
int sli_strcmp (char const *s1, char const *s2)
 Compares two strings.
int sli_strncmp (char const *s1, char const *s2, unsigned int n)
 Compare strings for a specific length.
void sli_memset (unsigned char *dest, char const val, unsigned int n)
 Copy a value repeatedly into a block of memory.
void sli_puts (uint8_t *s)
 Prints a string to stdout (using plat_putByte)
PmReturn_t sli_ltoa10 (int32_t value, uint8_t *buf, uint8_t buflen)
 Formats a 32-bit signed int as a decimal value.
PmReturn_t sli_btoa16 (uint8_t value, uint8_t *buf, uint8_t buflen, uint8_t upperCase)
 Formats an 8-bit int as a hexadecimal value.
PmReturn_t sli_ltoa16 (int32_t value, uint8_t *buf, uint8_t buflen, uint8_t upperCase)
 Formats a 32-bit signed int as a hexadecimal value.
PmReturn_t sli_ptoa16 (intptr_t value, uint8_t *buf, uint8_t buflen, uint8_t upperCase)
 Formats a pointer as a hexadecimal value.
PmReturn_t sli_ftoa (float f, uint8_t *buf, uint8_t buflen)
 Formats a 32-bit (single-precision) float as an ascii string.

Detailed Description

Standard Library Interface.

PyMite requires a few functions from a few different standard C libraries (memory, string, etc).

Definition in file sli.c.


Function Documentation

PmReturn_t sli_btoa16 ( uint8_t  value,
uint8_t *  buf,
uint8_t  buflen,
uint8_t  upperCase 
)

Formats an 8-bit int as a hexadecimal value.

Parameters:
valuethe 8-bit value
bufa pointer to where the formatted string goes
buflenthe length of the given buffer in bytes
upperCasewhen zero, hex chars rendered lowercase, else uppercase
Returns:
Always PM_RET_OK

Definition at line 225 of file sli.c.

PmReturn_t sli_ftoa ( float  f,
uint8_t *  buf,
uint8_t  buflen 
)

Formats a 32-bit (single-precision) float as an ascii string.

Parameters:
fthe float value
bufa pointer to where the formatted string goes
buflenthe size of the buffer
Returns:
Status

Definition at line 299 of file sli.c.

PmReturn_t sli_ltoa10 ( int32_t  value,
uint8_t *  buf,
uint8_t  buflen 
)

Formats a 32-bit signed int as a decimal value.

Parameters:
valuethe 32-bit signed value
bufa pointer to where the formatted string goes
buflenthe length of the given buffer in bytes
Returns:
a pointer to the string.

Definition at line 164 of file sli.c.

PmReturn_t sli_ltoa16 ( int32_t  value,
uint8_t *  buf,
uint8_t  buflen,
uint8_t  upperCase 
)

Formats a 32-bit signed int as a hexadecimal value.

Parameters:
valuethe 32-bit signed value
bufa pointer to where the formatted string goes
buflenthe length of the given buffer in bytes
upperCasewhen zero, hex chars rendered lowercase, else uppercase
Returns:
Always PM_RET_OK

Definition at line 245 of file sli.c.

void* sli_memcpy ( unsigned char *  to,
unsigned char const *  from,
unsigned int  n 
)

Copies a block of memory in RAM.

Parameters:
toThe destination address.
fromThe source address.
nThe number of bytes to copy.
Returns:
The initial pointer value of the destination
See also:
mem_copy

Definition at line 32 of file sli.c.

void sli_memset ( unsigned char *  dest,
const char  val,
unsigned int  n 
)

Copy a value repeatedly into a block of memory.

Parameters:
destthe destination address.
valthe value.
nthe number of bytes to copy.
Returns:
Nothing
See also:
memset

Definition at line 135 of file sli.c.

PmReturn_t sli_ptoa16 ( intptr_t  value,
uint8_t *  buf,
uint8_t  buflen,
uint8_t  upperCase 
)

Formats a pointer as a hexadecimal value.

Parameters:
valuethe pointer
bufa pointer to where the formatted string goes
buflenthe length of the given buffer in bytes
upperCasewhen zero, hex chars rendered lowercase, else uppercase
Returns:
Always PM_RET_OK

Definition at line 272 of file sli.c.

void sli_puts ( uint8_t *  s )

Prints a string to stdout (using plat_putByte)

Parameters:
sPointer to the C string to print

Definition at line 147 of file sli.c.

int sli_strcmp ( char const *  s1,
char const *  s2 
)

Compares two strings.

Parameters:
s1Ptr to string 1.
s2Ptr to string 2.
Returns:
value that is less then, equal to or greater than 0 depending on whether s1's encoding is less than, equal to, or greater than s2's.

Definition at line 91 of file sli.c.

int sli_strlen ( char const *  s )

Obtain string length.

Parameters:
sptr to string.
Returns:
number of bytes in string.

Definition at line 77 of file sli.c.

int sli_strncmp ( char const *  s1,
char const *  s2,
unsigned int  n 
)

Compare strings for a specific length.

Parameters:
s1ptr to string 1.
s2ptr to string 2.
nnumber of chars to compare
Returns:
value that is less then, equal to or greater than 0 depending on whether s1's encoding is less than, equal to, or greater than s2's.

Definition at line 106 of file sli.c.