source: EcnlProtoTool/trunk/prototool/src/arduino.h@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 3.1 KB
Line 
1/*
2 *
3 */
4#ifndef _ARDUINO_H_
5#define _ARDUINO_H_
6
7#include <stdint.h>
8#include <stdio.h>
9#include <stdlib.h>
10#include <string.h>
11#include <time.h>
12#include <mbed_api.h>
13
14#ifndef bool
15#define bool int
16#endif
17#ifndef true
18#define true 1
19#endif
20#ifndef false
21#define false 0
22#endif
23
24typedef unsigned char byte;
25
26void arduino_init(void);
27
28typedef enum pintype_e {
29 pintype_none,
30 pintype_gpio,
31 pintype_dac,
32 pintype_pwmout,
33 pintype_analogin,
34} PinType;
35
36struct pin_node {
37 struct pin_node *next;
38 PinName pin;
39 PinType type;
40 union {
41 gpio_t gpio;
42#if DEVICE_ANALOGOUT
43 dac_t dac;
44#endif
45 pwmout_t pwmout;
46 analogin_t analogin;
47 };
48 uint32_t period;
49 uint32_t pulsewidth;
50 int min;
51 int max;
52};
53
54struct pin_node *get_pin(PinType type, PinName pinno);
55PinType get_pin_type(PinName pin);
56
57#define DEFAULT 0
58#define INTERNAL 1
59#define EXTERNAL 2
60#define RAW12BIT 3
61
62void analogReference(int type);
63void setPinModeDac(int pin);
64void tone(int pin, int frequency, int duration);
65void noTone(int pin);
66void randomSeed(long seed);
67long arduino_random(long min, long max);
68
69typedef enum sci_port {
70 SCI_USB0,
71 SCI_SCI0P2x,
72 SCI_SCI2B,
73 SCI_SCI6B,
74 SCI_SCI2A,
75} SCI_PORT;
76
77bool portToPins(SCI_PORT port, PinName *txpin, PinName *rxpin);
78
79extern serial_t *Serial;
80extern serial_t *Serial1; /*1:Serial1*/
81extern serial_t *Serial2; /*2:Serial3*/
82extern serial_t *Serial3; /*3:Serial2*/
83extern serial_t *Serial4; /*4:Serial6*/
84extern serial_t *Serial5; /*5:Serial7*/
85
86int serial_write(serial_t *serial, const unsigned char *c, int len);
87int serial_print(serial_t *serial, const char *c);
88int serial_println(serial_t *serial, const char *c);
89
90extern i2c_t Wire1;
91extern i2c_t Wire2;
92extern i2c_t Wire3;
93extern i2c_t Wire4;
94extern i2c_t Wire5;
95
96typedef struct File {
97 int fd;
98} File;
99
100#define FILE_READ 0x01
101#define FILE_WRITE 0x02
102
103int file_write(File *fd, unsigned char *str, int len);
104void file_close(File *fd);
105int file_size(File *fd);
106int file_position(File *fd);
107void file_flush(File *fd);
108bool file_seek(File *fd, int pos);
109int file_read(File *fd);
110
111bool SD_begin();
112bool SD_open(File *file, const char *path, int mode);
113bool SD_rmdir(const char *path);
114bool SD_rename(const char *path1, const char *path2);
115bool SD_remove(const char *path);
116bool SD_exists(const char *path);
117bool SD_mkdir(const char *path);
118
119typedef struct FILEEEP {
120 int fd;
121} FILEEEP;
122
123int EEP_fopen(FILEEEP *fp, const char *str, char mode);
124int EEP_fwrite(FILEEEP *fp, byte *data, int *len);
125int EEP_fread(FILEEEP *fp);
126void EEP_fclose(FILEEEP *fp);
127int EEP_fseek(FILEEEP *fp, int pos, int mode);
128int EEP_ffilesize(const char *str);
129bool EEP_fEof(FILEEEP *fp);
130int EEP_fexist(const char *path);
131int EEP_fcopy(const char *src, const char *dst);
132int EEP_fdelete(const char *path);
133
134#define EEP_SEEKTOP 1
135#define EEP_SEEKCUR 2
136#define EEP_SEEKEND 3
137
138#define EEP_READ 0x01
139#define EEP_WRITE 0x02
140#define EEP_APPEND 0x4
141
142uint8_t EEPROM_write(int addr, uint8_t data);
143uint8_t EEPROM_read(int addr);
144
145#define REBOOT_USERAPP 1
146void system_reboot(int mode);
147int fileloader(const char *progVer, const char *binVer);
148
149extern volatile char ProgVer[];
150extern char RubyFilename[64];
151extern char ExeFilename[64];
152
153#endif /* _ARDUINO_H_ */
Note: See TracBrowser for help on using the repository browser.