1 | /*
|
---|
2 | * TOPPERS ECHONET Lite Communication Middleware
|
---|
3 | *
|
---|
4 | * Copyright (C) 2017 Cores Co., Ltd. Japan
|
---|
5 | *
|
---|
6 | * ä¸è¨èä½æ¨©è
|
---|
7 | ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
|
---|
8 | * ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹
|
---|
9 | * å¤ã»åé
|
---|
10 | å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
11 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
12 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
13 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
14 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
15 | * ç¨ã§ããå½¢ã§åé
|
---|
16 | å¸ããå ´åã«ã¯ï¼åé
|
---|
17 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
18 | * è
|
---|
19 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
20 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
21 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
22 | * ç¨ã§ããªãå½¢ã§åé
|
---|
23 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
24 | * ã¨ï¼
|
---|
25 | * (a) åé
|
---|
26 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
27 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
28 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
29 | * (b) åé
|
---|
30 | å¸ã®å½¢æ
|
---|
31 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
32 | * å ±åãããã¨ï¼
|
---|
33 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
34 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
35 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
36 | 責ãããã¨ï¼
|
---|
37 | * ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
|
---|
38 | * ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
|
---|
39 | ããã³TOPPERSããã¸ã§ã¯ãã
|
---|
40 | * å
|
---|
41 | 責ãããã¨ï¼
|
---|
42 | *
|
---|
43 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
44 | ã
|
---|
45 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
|
---|
46 | * ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
|
---|
47 | * ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã
|
---|
48 | * ã®è²¬ä»»ãè² ããªãï¼
|
---|
49 | *
|
---|
50 | * @(#) $Id$
|
---|
51 | */
|
---|
52 | #include "mbedcall.h"
|
---|
53 | #include "mbed_api.h"
|
---|
54 |
|
---|
55 | #define __asm_mbedcall(...) do { \
|
---|
56 | __asm__ __volatile__ ( "push { lr }" ); \
|
---|
57 | __asm__ __volatile__ ( "svc 1" \
|
---|
58 | : "=r"(r0) : __VA_ARGS__ : "memory"); \
|
---|
59 | __asm__ __volatile__ ( "pop { lr }" ); \
|
---|
60 | return r0; \
|
---|
61 | } while (0)
|
---|
62 |
|
---|
63 | static inline long __mbedcall0(long n)
|
---|
64 | {
|
---|
65 | register long r7 __asm__("r7") = n;
|
---|
66 | register long r0 __asm__("r0");
|
---|
67 | __asm_mbedcall("r"(r7));
|
---|
68 | }
|
---|
69 |
|
---|
70 | static inline long __mbedcall1(long n, long a)
|
---|
71 | {
|
---|
72 | register long r7 __asm__("r7") = n;
|
---|
73 | register long r0 __asm__("r0") = a;
|
---|
74 | __asm_mbedcall("r"(r7), "0"(r0));
|
---|
75 | }
|
---|
76 |
|
---|
77 | static inline long __mbedcall2(long n, long a, long b)
|
---|
78 | {
|
---|
79 | register long r7 __asm__("r7") = n;
|
---|
80 | register long r0 __asm__("r0") = a;
|
---|
81 | register long r1 __asm__("r1") = b;
|
---|
82 | __asm_mbedcall("r"(r7), "0"(r0), "r"(r1));
|
---|
83 | }
|
---|
84 |
|
---|
85 | static inline long __mbedcall3(long n, long a, long b, long c)
|
---|
86 | {
|
---|
87 | register long r7 __asm__("r7") = n;
|
---|
88 | register long r0 __asm__("r0") = a;
|
---|
89 | register long r1 __asm__("r1") = b;
|
---|
90 | register long r2 __asm__("r2") = c;
|
---|
91 | __asm_mbedcall("r"(r7), "0"(r0), "r"(r1), "r"(r2));
|
---|
92 | }
|
---|
93 |
|
---|
94 | static inline long __mbedcall4(long n, long a, long b, long c, long d)
|
---|
95 | {
|
---|
96 | register long r7 __asm__("r7") = n;
|
---|
97 | register long r0 __asm__("r0") = a;
|
---|
98 | register long r1 __asm__("r1") = b;
|
---|
99 | register long r2 __asm__("r2") = c;
|
---|
100 | register long r3 __asm__("r3") = d;
|
---|
101 | __asm_mbedcall("r"(r7), "0"(r0), "r"(r1), "r"(r2), "r"(r3));
|
---|
102 | }
|
---|
103 |
|
---|
104 | static inline long __mbedcall5(long n, long a, long b, long c, long d, long e)
|
---|
105 | {
|
---|
106 | register long r7 __asm__("r7") = n;
|
---|
107 | register long r0 __asm__("r0") = a;
|
---|
108 | register long r1 __asm__("r1") = b;
|
---|
109 | register long r2 __asm__("r2") = c;
|
---|
110 | register long r3 __asm__("r3") = d;
|
---|
111 | register long r4 __asm__("r4") = e;
|
---|
112 | __asm_mbedcall("r"(r7), "0"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4));
|
---|
113 | }
|
---|
114 |
|
---|
115 | static inline long __mbedcall6(long n, long a, long b, long c, long d, long e, long f)
|
---|
116 | {
|
---|
117 | register long r7 __asm__("r7") = n;
|
---|
118 | register long r0 __asm__("r0") = a;
|
---|
119 | register long r1 __asm__("r1") = b;
|
---|
120 | register long r2 __asm__("r2") = c;
|
---|
121 | register long r3 __asm__("r3") = d;
|
---|
122 | register long r4 __asm__("r4") = e;
|
---|
123 | register long r5 __asm__("r5") = f;
|
---|
124 | __asm_mbedcall("r"(r7), "0"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4), "r"(r5));
|
---|
125 | }
|
---|
126 |
|
---|
127 | void analogin_init(analogin_t *obj, PinName pin)
|
---|
128 | {
|
---|
129 | __mbedcall2(MBED_analogin_init, (long)obj, (long)pin);
|
---|
130 | }
|
---|
131 |
|
---|
132 | uint16_t analogin_read_u16(analogin_t *obj)
|
---|
133 | {
|
---|
134 | return __mbedcall1(MBED_analogin_read_u16, (long)obj);
|
---|
135 | }
|
---|
136 |
|
---|
137 | void gpio_init(gpio_t *obj, PinName pin)
|
---|
138 | {
|
---|
139 | __mbedcall2(MBED_gpio_init, (long)obj, (long)pin);
|
---|
140 | }
|
---|
141 |
|
---|
142 | void gpio_mode(gpio_t *obj, PinMode mode)
|
---|
143 | {
|
---|
144 | __mbedcall2(MBED_gpio_mode, (long)obj, (long)mode);
|
---|
145 | }
|
---|
146 |
|
---|
147 | void gpio_dir(gpio_t *obj, PinDirection direction)
|
---|
148 | {
|
---|
149 | __mbedcall2(MBED_gpio_dir, (long)obj, (long)direction);
|
---|
150 | }
|
---|
151 |
|
---|
152 | void gpio_write(gpio_t *obj, int value)
|
---|
153 | {
|
---|
154 | __mbedcall2(MBED_gpio_write, (long)obj, (long)value);
|
---|
155 | }
|
---|
156 |
|
---|
157 | int gpio_read(gpio_t *obj)
|
---|
158 | {
|
---|
159 | return __mbedcall1(MBED_gpio_read, (long)obj);
|
---|
160 | }
|
---|
161 |
|
---|
162 | int i2c_start(i2c_t *obj)
|
---|
163 | {
|
---|
164 | return __mbedcall1(MBED_i2c_start, (long)obj);
|
---|
165 | }
|
---|
166 |
|
---|
167 | int i2c_stop(i2c_t *obj)
|
---|
168 | {
|
---|
169 | return __mbedcall1(MBED_i2c_stop, (long)obj);
|
---|
170 | }
|
---|
171 |
|
---|
172 | void i2c_init(i2c_t *obj, PinName sda, PinName scl)
|
---|
173 | {
|
---|
174 | __mbedcall3(MBED_i2c_init, (long)obj, (long)sda, (long)scl);
|
---|
175 | }
|
---|
176 |
|
---|
177 | int i2c_read(i2c_t *obj, int address, char *data, int length, int stop)
|
---|
178 | {
|
---|
179 | return __mbedcall5(MBED_i2c_read, (long)obj, (long)address, (long)data, (long)length, (long)stop);
|
---|
180 | }
|
---|
181 |
|
---|
182 | int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop)
|
---|
183 | {
|
---|
184 | return __mbedcall5(MBED_i2c_write, (long)obj, (long)address, (long)data, (long)length, (long)stop);
|
---|
185 | }
|
---|
186 |
|
---|
187 | int i2c_byte_read(i2c_t *obj, int last)
|
---|
188 | {
|
---|
189 | return __mbedcall2(MBED_i2c_byte_read, (long)obj, (long)last);
|
---|
190 | }
|
---|
191 |
|
---|
192 | int i2c_byte_write(i2c_t *obj, int data)
|
---|
193 | {
|
---|
194 | return __mbedcall2(MBED_i2c_byte_write, (long)obj, (long)data);
|
---|
195 | }
|
---|
196 |
|
---|
197 | void pin_function(PinName pin, int function)
|
---|
198 | {
|
---|
199 | __mbedcall2(MBED_pin_function, (long)pin, (long)function);
|
---|
200 | }
|
---|
201 |
|
---|
202 | void pin_mode(PinName pin, PinMode mode)
|
---|
203 | {
|
---|
204 | __mbedcall2(MBED_pin_mode, (long)pin, (long)mode);
|
---|
205 | }
|
---|
206 |
|
---|
207 | void pwmout_free(pwmout_t* obj)
|
---|
208 | {
|
---|
209 | __mbedcall1(MBED_pwmout_free, (long)obj);
|
---|
210 | }
|
---|
211 |
|
---|
212 | void pwmout_init(pwmout_t* obj, PinName pin)
|
---|
213 | {
|
---|
214 | __mbedcall2(MBED_pwmout_init, (long)obj, (long)pin);
|
---|
215 | }
|
---|
216 |
|
---|
217 | void pwmout_pulsewidth_us(pwmout_t* obj, int us)
|
---|
218 | {
|
---|
219 | __mbedcall2(MBED_pwmout_pulsewidth_us, (long)obj, (long)us);
|
---|
220 | }
|
---|
221 |
|
---|
222 | void rtc_init(void)
|
---|
223 | {
|
---|
224 | __mbedcall0(MBED_rtc_init);
|
---|
225 | }
|
---|
226 |
|
---|
227 | void rtc_free(void)
|
---|
228 | {
|
---|
229 | __mbedcall0(MBED_rtc_free);
|
---|
230 | }
|
---|
231 |
|
---|
232 | int rtc_isenabled(void)
|
---|
233 | {
|
---|
234 | return __mbedcall0(MBED_rtc_isenabled);
|
---|
235 | }
|
---|
236 |
|
---|
237 | time_t rtc_read(void)
|
---|
238 | {
|
---|
239 | return __mbedcall0(MBED_rtc_read);
|
---|
240 | }
|
---|
241 |
|
---|
242 | void rtc_write(time_t t)
|
---|
243 | {
|
---|
244 | __mbedcall1(MBED_rtc_write, (long)t);
|
---|
245 | }
|
---|
246 |
|
---|
247 | void serial_baud(serial_t *obj, int baudrate)
|
---|
248 | {
|
---|
249 | __mbedcall2(MBED_serial_baud, (long)obj, (long)baudrate);
|
---|
250 | }
|
---|
251 |
|
---|
252 | void serial_init(serial_t *obj, PinName tx, PinName rx)
|
---|
253 | {
|
---|
254 | __mbedcall3(MBED_serial_init, (long)obj, (long)tx, (long)rx);
|
---|
255 | }
|
---|
256 |
|
---|
257 | int serial_readable(serial_t *obj)
|
---|
258 | {
|
---|
259 | return __mbedcall1(MBED_serial_readable, (long)obj);
|
---|
260 | }
|
---|
261 |
|
---|
262 | int serial_getc(serial_t *obj)
|
---|
263 | {
|
---|
264 | return __mbedcall1(MBED_serial_getc, (long)obj);
|
---|
265 | }
|
---|
266 |
|
---|
267 | void serial_putc(serial_t *obj, int c)
|
---|
268 | {
|
---|
269 | __mbedcall2(MBED_serial_putc, (long)obj, (long)c);
|
---|
270 | }
|
---|
271 |
|
---|
272 | void us_ticker_init(void)
|
---|
273 | {
|
---|
274 | __mbedcall0(MBED_us_ticker_init);
|
---|
275 | }
|
---|
276 |
|
---|
277 | uint32_t us_ticker_read(void)
|
---|
278 | {
|
---|
279 | return __mbedcall0(MBED_us_ticker_read);
|
---|
280 | }
|
---|
281 |
|
---|
282 | void us_ticker_set_interrupt(timestamp_t timestamp)
|
---|
283 | {
|
---|
284 | __mbedcall1(MBED_us_ticker_set_interrupt, (long)timestamp);
|
---|
285 | }
|
---|
286 |
|
---|
287 | void us_ticker_disable_interrupt(void)
|
---|
288 | {
|
---|
289 | __mbedcall0(MBED_us_ticker_disable_interrupt);
|
---|
290 | }
|
---|
291 |
|
---|
292 | void us_ticker_clear_interrupt(void)
|
---|
293 | {
|
---|
294 | __mbedcall0(MBED_us_ticker_clear_interrupt);
|
---|
295 | }
|
---|
296 |
|
---|
297 | int SD_begin()
|
---|
298 | {
|
---|
299 | return __mbedcall0(MBED_SD_begin);
|
---|
300 | }
|
---|
301 |
|
---|
302 | void __disable_irq()
|
---|
303 | {
|
---|
304 | __mbedcall0(MBED___disable_irq);
|
---|
305 | }
|
---|
306 |
|
---|
307 | void __enable_irq()
|
---|
308 | {
|
---|
309 | __mbedcall0(MBED___enable_irq);
|
---|
310 | }
|
---|
311 |
|
---|
312 | void hal_critical_section_enter(void)
|
---|
313 | {
|
---|
314 | }
|
---|
315 |
|
---|
316 | void hal_critical_section_exit(void)
|
---|
317 | {
|
---|
318 | }
|
---|
319 |
|
---|
320 | void us_ticker_fire_interrupt(void)
|
---|
321 | {
|
---|
322 | }
|
---|
323 |
|
---|
324 | void us_ticker_free(void)
|
---|
325 | {
|
---|
326 | }
|
---|
327 |
|
---|
328 | //#include <pinmap.h>
|
---|
329 | #define LED1 109
|
---|
330 | #include "mbed_assert.c"
|
---|
331 | #include "mbed_board.c"
|
---|
332 | #include "mbed_critical.c"
|
---|
333 | #include "mbed_error.c"
|
---|
334 | #include "mbed_gpio.c"
|
---|
335 | #include "mbed_lp_ticker_api.c"
|
---|
336 | #include "mbed_interface.c"
|
---|
337 | #include "mbed_pinmap_common.c"
|
---|
338 | //#include "mbed_rtc_time.c"
|
---|
339 | #include "mbed_semihost_api.c"
|
---|
340 | #include "mbed_ticker_api.c"
|
---|
341 | #include "mbed_us_ticker_api.c"
|
---|
342 | #include "mbed_wait_api_no_rtos.c"
|
---|
343 |
|
---|
344 | const ticker_info_t *us_ticker_get_info(void)
|
---|
345 | {
|
---|
346 | return NULL;
|
---|
347 | }
|
---|