init
This commit is contained in:
parent
d84d296fe8
commit
7db5a0bc33
23
MikuDuino.c
Executable file
23
MikuDuino.c
Executable file
@ -0,0 +1,23 @@
|
||||
#include "MikuDuino.h"
|
||||
|
||||
void sayhello()
|
||||
{
|
||||
printf("Hello MikuDuino!\n");
|
||||
}
|
||||
|
||||
void delay (unsigned int howLong)
|
||||
{
|
||||
struct timespec sleeper, dummy ;
|
||||
|
||||
sleeper.tv_sec = (time_t)(howLong / 1000) ;
|
||||
sleeper.tv_nsec = (long)(howLong % 1000) * 1000000 ;
|
||||
|
||||
nanosleep (&sleeper, &dummy) ;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
setup();
|
||||
while(1)
|
||||
loop();
|
||||
}
|
||||
12
MikuDuino.h
Executable file
12
MikuDuino.h
Executable file
@ -0,0 +1,12 @@
|
||||
#ifndef _MIKUDUINO_H_
|
||||
#define _MIKUDUINO_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
void sayhello();
|
||||
void delay (unsigned int howLong);
|
||||
void setup();
|
||||
void loop();
|
||||
|
||||
#endif
|
||||
7
MikuPi.c
Executable file
7
MikuPi.c
Executable file
@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include "MikuPi.h"
|
||||
|
||||
void sayhello()
|
||||
{
|
||||
printf("Hello MikuQ.com!\n");
|
||||
}
|
||||
6
MikuPi.h
Executable file
6
MikuPi.h
Executable file
@ -0,0 +1,6 @@
|
||||
#ifndef _MIKUPI_H_
|
||||
#define _MIKUPI_H_
|
||||
|
||||
void sayhello();
|
||||
|
||||
#endif
|
||||
6
test/hello.c
Executable file
6
test/hello.c
Executable file
@ -0,0 +1,6 @@
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
printf("Hello MikuQ.com!\n");
|
||||
return 0;
|
||||
}
|
||||
BIN
test/hello.exe
Executable file
BIN
test/hello.exe
Executable file
Binary file not shown.
7
test/hello2.c
Executable file
7
test/hello2.c
Executable file
@ -0,0 +1,7 @@
|
||||
#include "MikuPi.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
sayhello();
|
||||
return 0;
|
||||
}
|
||||
BIN
test/hello2.exe
Executable file
BIN
test/hello2.exe
Executable file
Binary file not shown.
15
test/hello3.c
Executable file
15
test/hello3.c
Executable file
@ -0,0 +1,15 @@
|
||||
#include "MikuDuino.h"
|
||||
|
||||
int i=0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
sayhello();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
delay(5000);
|
||||
printf("%d\n",++i);
|
||||
}
|
||||
|
||||
BIN
test/hello3.exe
Executable file
BIN
test/hello3.exe
Executable file
Binary file not shown.
65
test/hello4.c
Executable file
65
test/hello4.c
Executable file
@ -0,0 +1,65 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE (1==1)
|
||||
#define FALSE (1==2)
|
||||
#endif
|
||||
|
||||
int wiringPiDebug = TRUE;
|
||||
|
||||
static void piBoardRevOops (const char *why)
|
||||
{
|
||||
fprintf (stderr, "piBoardRev: Unable to determine board revision from /proc/cpuinfo\n") ;
|
||||
fprintf (stderr, " -> %s\n", why) ;
|
||||
fprintf (stderr, " -> You may want to check:\n") ;
|
||||
fprintf (stderr, " -> http://MikuQ.com\n") ;
|
||||
exit (EXIT_FAILURE) ;
|
||||
}
|
||||
|
||||
int isH3(void)
|
||||
{
|
||||
FILE *cpuFd ;
|
||||
char line [120] ;
|
||||
char *d;
|
||||
if ((cpuFd = fopen ("/proc/cpuinfo", "r")) == NULL)
|
||||
piBoardRevOops ("Unable to open /proc/cpuinfo") ;
|
||||
while (fgets (line, 120, cpuFd) != NULL)
|
||||
{
|
||||
if (strncmp (line, "Hardware", 8) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
fclose (cpuFd) ;
|
||||
if (strncmp (line, "Hardware", 8) != 0)
|
||||
piBoardRevOops ("No \"Hardware\" line") ;
|
||||
|
||||
for (d = &line [strlen (line) - 1] ; (*d == '\n') || (*d == '\r') ; --d)
|
||||
*d = 0 ;
|
||||
if (wiringPiDebug)
|
||||
printf ("piboardRev: Hardware string: %s\n", line) ;
|
||||
|
||||
if (strstr(line,"sun8i") != NULL)
|
||||
{
|
||||
if (wiringPiDebug)
|
||||
printf ("Hardware:%s\n",line) ;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wiringPiDebug)
|
||||
printf ("Hardware:%s\n",line) ;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Hello MikuQ.com!\n");
|
||||
if (isH3())
|
||||
printf("is H3!\n");
|
||||
else
|
||||
printf("is not H3!\n");
|
||||
return 0;
|
||||
}
|
||||
BIN
test/hello4.exe
Executable file
BIN
test/hello4.exe
Executable file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user