// TODO
arduino.h
/*
#ifndef true
#define true 1
#endif
*/
#ifndef __ARDUINO_H__
#define __ARDUINO_H__
#define HIGH 1
#define LOW 0
#define INPUT 0
#define INPUT_PULLUP 1
#define OUTPUT 2
#define LED_BUILTIN 13
typedef unsigned char byte;
typedef unsigned short word;
#define byte(x) (byte)(x)
#define char(x) (char)(x)
#define float(x) (float)(x)
// #define int(x) (int)(x)
#define long(x) (long)(x)
#define word(x) (word)(x)
#define word(h, l) (word)((h) << 16 + (l))
void setup();
void loop();
#endif // __ARDUINO_H__
arduino_app.c
#include "arduino.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
void setup()
{
}
void loop()
{
printf("Hello, arduino world!\n");
int x = 23;
byte y = (byte) x;
byte z = byte(x);
printf("x = %d, y = %d, z = %d \n", x, y, z);
bool b = true;
b = !b;
if( b == false) {
printf("b == false.\n");
}
else {
printf("b == true.\n");
}
exit(0);
}
arduino_main.c
#include "arduino.h"
#define port_ThreadSleep(x)
void main_thread(void *);
int main(int argc, char *argv[])
{
void *x = 0;
main_thread(x);
return 0;
}
void main_thread(void *x)
{
(void) x;
setup();
while(1) {
loop();
port_ThreadSleep(1);
}
}
引用: RCSN 发表于 2023-12-23 07:30 移植好了?
还没有。。。。