Merge from trunk

This commit is contained in:
David Gálvez
2014-07-10 11:09:09 +00:00
parent 73f75895bc
commit 818cb2bcd7
54 changed files with 3647 additions and 1000 deletions

View File

@@ -55,14 +55,14 @@ void *memset(void *s, int c, size_t n)
}
int memcmp(const char *s1, const char *s2, size_t max)
int memcmp(const void *s1, const void *s2, size_t max)
{
int i;
int cmp;
for (i = 0; i < max; i++)
{
cmp = (*s1 - *s2);
cmp = (* (const char *) s1 - * (const char *) s2);
if (cmp != 0) return cmp;
}
return cmp;
@@ -75,7 +75,7 @@ int strcmp(const char *s1, const char *s2)
for (i = 0; *s1++ && *s2++; i++)
{
cmp * (*s1 - *s2);
cmp = (*s1 - *s2);
if (cmp != 0) return cmp;
}
return cmp;

View File

@@ -34,3 +34,5 @@ printf_helper:
lea __MBAR+0x860C,a0 // PSCSTB0 transmitter buffer register
move.b d0,(a0) // send byte
rts
// vim: set syntax=asm68k :

View File

@@ -27,5 +27,43 @@
#include <stdint.h>
#include <MCF5475.h>
#include <wait.h>
uint32_t get_timer(void)
{
return MCF_SLT_SCNT(0);
}
/*
* wait for the specified number of us on slice timer 0. Replaces the original routines that had
* the number of useconds to wait for hardcoded in their name.
*/
void wait(uint32_t us)
{
int32_t target = MCF_SLT_SCNT(0) - (us * (SYSCLK / 1000));
while (MCF_SLT_SCNT(0) - target > 0);
}
/*
* same as above, but with milliseconds wait time
*/
void wait_ms(uint32_t ms)
{
wait(ms * 1000);
}
/*
* the same as above, with a checker function which gets called while
* busy waiting and allows for an early return if it returns true
*/
bool waitfor(uint32_t us, checker_func condition)
{
int32_t target = MCF_SLT_SCNT(0) - (us * (SYSCLK / 1000));
bool res;
do
{
if ((res = (*condition)()))
return res;
} while (MCF_SLT_SCNT(0) - target > 0);
return false;
}