python-on-a-chip online compiler
Dependencies:
mbed
TSI
« Back to documentation index
sli.h 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_strcmp (char const *s1, char const *s2)
Compares two strings.
int sli_strlen (char const *s)
Obtain string length.
int sli_strncmp (char const *s1, char const *s2, unsigned int n)
Compare strings for a specific length.
void sli_memset (unsigned char *dest, const char 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). If your microcontroller has these libraries, set the constant to 1 for each library available. This will cause a macro to be defined which wraps the function for use by PyMite. Otherwise, leave the constant as 0, and PyMite will use the function defined in sli.c Some of the functions in sli.c will need to be ported to the target system.
Definition in file sli.h .
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:
value the 8-bit value
buf a pointer to where the formatted string goes
buflen the length of the given buffer in bytes
upperCase when 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:
f the float value
buf a pointer to where the formatted string goes
buflen the 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:
value the 32-bit signed value
buf a pointer to where the formatted string goes
buflen the 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:
value the 32-bit signed value
buf a pointer to where the formatted string goes
buflen the length of the given buffer in bytes
upperCase when 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:
to The destination address.
from The source address.
n The 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:
dest the destination address.
val the value.
n the 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:
value the pointer
buf a pointer to where the formatted string goes
buflen the length of the given buffer in bytes
upperCase when 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:
s Pointer 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:
s1 Ptr to string 1.
s2 Ptr 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:
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:
s1 ptr to string 1.
s2 ptr to string 2.
n number 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 .