OLD | NEW |
1 // Copyright (c) 2016, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dartino project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
11 | 11 |
12 #include <app.h> | 12 #include <app.h> |
13 #include <err.h> | 13 #include <err.h> |
14 #include <compiler.h> | 14 #include <compiler.h> |
15 #include <endian.h> | 15 #include <endian.h> |
16 #include <platform.h> | 16 #include <platform.h> |
17 #include <dev/display.h> | 17 #include <dev/display.h> |
| 18 #include <dev/gpio.h> |
18 | 19 |
19 #include <kernel/port.h> | 20 #include <kernel/port.h> |
20 | 21 |
21 #include <lib/font.h> | 22 #include <lib/font.h> |
22 #include <lib/gfx.h> | 23 #include <lib/gfx.h> |
23 | 24 |
24 #include <include/static_ffi.h> | 25 #include <include/static_ffi.h> |
25 | 26 |
26 #include "loader.h" | 27 #include "loader.h" |
27 | 28 |
28 #if defined(WITH_LIB_CONSOLE) | 29 #if defined(WITH_LIB_CONSOLE) |
29 #include <lib/console.h> | 30 #include <lib/console.h> |
30 #else | 31 #else |
31 #error "dartino app needs a console" | 32 #error "dartino app needs a console" |
32 #endif | 33 #endif |
33 | 34 |
34 void SensorsInit(void); | 35 void SensorsInit(void); |
35 | 36 |
| 37 int led_get_gpio(int); |
| 38 |
36 enum { | 39 enum { |
37 MODE_RUN, | 40 MODE_RUN, |
38 MODE_BURN | 41 MODE_BURN |
39 } dartino_mode; | 42 } dartino_mode; |
40 | 43 |
41 | 44 |
42 //////////////// Dart FFI setup /////////////////////////////////////////////// | 45 //////////////// Dart FFI setup /////////////////////////////////////////////// |
43 | 46 |
44 __WEAK status_t display_get_info(struct display_info *info) { | 47 __WEAK status_t display_get_info(struct display_info *info) { |
45 return ERR_NOT_FOUND; | 48 return ERR_NOT_FOUND; |
(...skipping 25 matching lines...) Expand all Loading... |
71 DARTINO_EXPORT_TABLE_ENTRY("gfx_width", GetWidth) | 74 DARTINO_EXPORT_TABLE_ENTRY("gfx_width", GetWidth) |
72 DARTINO_EXPORT_TABLE_ENTRY("gfx_height", GetHeight) | 75 DARTINO_EXPORT_TABLE_ENTRY("gfx_height", GetHeight) |
73 DARTINO_EXPORT_TABLE_ENTRY("gfx_destroy", gfx_surface_destroy) | 76 DARTINO_EXPORT_TABLE_ENTRY("gfx_destroy", gfx_surface_destroy) |
74 DARTINO_EXPORT_TABLE_ENTRY("gfx_pixel", gfx_putpixel) | 77 DARTINO_EXPORT_TABLE_ENTRY("gfx_pixel", gfx_putpixel) |
75 DARTINO_EXPORT_TABLE_ENTRY("gfx_line", gfx_line) | 78 DARTINO_EXPORT_TABLE_ENTRY("gfx_line", gfx_line) |
76 DARTINO_EXPORT_TABLE_ENTRY("gfx_clear", gfx_clear) | 79 DARTINO_EXPORT_TABLE_ENTRY("gfx_clear", gfx_clear) |
77 DARTINO_EXPORT_TABLE_ENTRY("gfx_flush", gfx_flush) | 80 DARTINO_EXPORT_TABLE_ENTRY("gfx_flush", gfx_flush) |
78 DARTINO_EXPORT_TABLE_ENTRY("port_open", port_open) | 81 DARTINO_EXPORT_TABLE_ENTRY("port_open", port_open) |
79 DARTINO_EXPORT_TABLE_ENTRY("port_close", port_open) | 82 DARTINO_EXPORT_TABLE_ENTRY("port_close", port_open) |
80 DARTINO_EXPORT_TABLE_ENTRY("port_read", port_read) | 83 DARTINO_EXPORT_TABLE_ENTRY("port_read", port_read) |
| 84 #if defined(TARGET_DARTUINOP0) |
| 85 DARTINO_EXPORT_TABLE_ENTRY("led_get_gpio", led_get_gpio) |
| 86 DARTINO_EXPORT_TABLE_ENTRY("gpio_set", gpio_set) |
| 87 DARTINO_EXPORT_TABLE_ENTRY("gpio_get", gpio_get) |
| 88 #endif |
81 DARTINO_EXPORT_TABLE_END | 89 DARTINO_EXPORT_TABLE_END |
82 | 90 |
83 //////////////// Port debug /////////////////////////////////////////////////// | 91 //////////////// Port debug /////////////////////////////////////////////////// |
84 | 92 |
85 static void DumpPacket(const port_result_t* result) { | 93 static void DumpPacket(const port_result_t* result) { |
86 const port_packet_t* p = &result->packet; | 94 const port_packet_t* p = &result->packet; |
87 printf("[%02x %02x %02x %02x %02x %02x %02x %02x]\n", | 95 printf("[%02x %02x %02x %02x %02x %02x %02x %02x]\n", |
88 p->value[0], p->value[1], p->value[2], p->value[3], | 96 p->value[0], p->value[1], p->value[2], p->value[3], |
89 p->value[4], p->value[5], p->value[6], p->value[7]); | 97 p->value[4], p->value[5], p->value[6], p->value[7]); |
90 } | 98 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 .init = ServicesInit, | 183 .init = ServicesInit, |
176 .entry = NULL, | 184 .entry = NULL, |
177 .flags = 0, | 185 .flags = 0, |
178 APP_END | 186 APP_END |
179 | 187 |
180 STATIC_COMMAND_START | 188 STATIC_COMMAND_START |
181 STATIC_COMMAND("dartino", "dartino vm via tftp", &DartinoRunner) | 189 STATIC_COMMAND("dartino", "dartino vm via tftp", &DartinoRunner) |
182 STATIC_COMMAND_END(dartinorunner); | 190 STATIC_COMMAND_END(dartinorunner); |
183 | 191 |
184 // vim: set expandtab ts=2 sw=2: | 192 // vim: set expandtab ts=2 sw=2: |
OLD | NEW |