Added code to support getting interrupts from the PIC. Can now get some data from the keyboard, however, it's not quite working yet.
This commit is contained in:
@@ -119,3 +119,38 @@ int strlen(char* string)
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
//Code reference:
|
||||
//http://www.strudel.org.uk/itoa/
|
||||
char* int_to_string(unsigned int value, int base)
|
||||
{
|
||||
static char buf[32] = {0};
|
||||
//void* ptr = Malloc(32);
|
||||
//if(ptr == 0)
|
||||
//{
|
||||
//puts("Malloc failed to allocate!\n");
|
||||
//return "";
|
||||
//}
|
||||
|
||||
//char buf = (char*) ptr;
|
||||
|
||||
if(value == 0)
|
||||
{
|
||||
buf[0] = '0';
|
||||
//*buf++ = '0';
|
||||
//return buf;
|
||||
return &buf[0];
|
||||
}
|
||||
|
||||
int i = 30;
|
||||
|
||||
for(; value && i; --i, value /= base)
|
||||
{
|
||||
//*buf++ = "0123456789ABCDEF"[value % base];
|
||||
buf[i] = "0123456789ABCDEF"[value % base];
|
||||
}
|
||||
|
||||
//Free(ptr);
|
||||
//return buf;
|
||||
return &buf[i+1];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user