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

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

ファイルを追加、更新。

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