source: EcnlProtoTool/trunk/mrbgems/gr_peach/src/arduino.h@ 270

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

mruby版ECNLプロトタイピング・ツールを追加

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