Colin Hogben / micropython

Dependents:   micropython-repl

Committer:
pythontech
Date:
Sat Apr 16 17:11:56 2016 +0000
Revision:
0:5868e8752d44
Child:
7:379d46fd02c2
Split off library from repl

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pythontech 0:5868e8752d44 1 /*
pythontech 0:5868e8752d44 2 * The MIT License (MIT)
pythontech 0:5868e8752d44 3 *
pythontech 0:5868e8752d44 4 * Copyright (c) 2016 Colin Hogben
pythontech 0:5868e8752d44 5 *
pythontech 0:5868e8752d44 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
pythontech 0:5868e8752d44 7 * of this software and associated documentation files (the "Software"), to deal
pythontech 0:5868e8752d44 8 * in the Software without restriction, including without limitation the rights
pythontech 0:5868e8752d44 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
pythontech 0:5868e8752d44 10 * copies of the Software, and to permit persons to whom the Software is
pythontech 0:5868e8752d44 11 * furnished to do so, subject to the following conditions:
pythontech 0:5868e8752d44 12 *
pythontech 0:5868e8752d44 13 * The above copyright notice and this permission notice shall be included in
pythontech 0:5868e8752d44 14 * all copies or substantial portions of the Software.
pythontech 0:5868e8752d44 15 *
pythontech 0:5868e8752d44 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
pythontech 0:5868e8752d44 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
pythontech 0:5868e8752d44 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
pythontech 0:5868e8752d44 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
pythontech 0:5868e8752d44 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
pythontech 0:5868e8752d44 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
pythontech 0:5868e8752d44 22 * THE SOFTWARE.
pythontech 0:5868e8752d44 23 */
pythontech 0:5868e8752d44 24
pythontech 0:5868e8752d44 25 /**
pythontech 0:5868e8752d44 26 * Hardware Abstraction Layer.
pythontech 0:5868e8752d44 27 *
pythontech 0:5868e8752d44 28 * Implementations or stubs for functions provided by the specific port.
pythontech 0:5868e8752d44 29 * Note that two functions are delegated to the user of the library:
pythontech 0:5868e8752d44 30 * - mp_hal_stdout_tx_chr
pythontech 0:5868e8752d44 31 * - mp_hal_stdin_rx_chr
pythontech 0:5868e8752d44 32 */
pythontech 0:5868e8752d44 33 #include <string.h>
pythontech 0:5868e8752d44 34 #include "py/mpstate.h"
pythontech 0:5868e8752d44 35 #include "py/lexer.h"
pythontech 0:5868e8752d44 36
pythontech 0:5868e8752d44 37 // Since we have no filesystem, no file exists
pythontech 0:5868e8752d44 38 mp_import_stat_t mp_import_stat(const char *path)
pythontech 0:5868e8752d44 39 {
pythontech 0:5868e8752d44 40 (void)path;
pythontech 0:5868e8752d44 41 return MP_IMPORT_STAT_NO_EXIST;
pythontech 0:5868e8752d44 42 }
pythontech 0:5868e8752d44 43
pythontech 0:5868e8752d44 44 mp_lexer_t *mp_lexer_new_from_file(const char *filename)
pythontech 0:5868e8752d44 45 {
pythontech 0:5868e8752d44 46 (void)filename;
pythontech 0:5868e8752d44 47 return NULL;
pythontech 0:5868e8752d44 48 }
pythontech 0:5868e8752d44 49
pythontech 0:5868e8752d44 50 mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
pythontech 0:5868e8752d44 51 return mp_const_none;
pythontech 0:5868e8752d44 52 }
pythontech 0:5868e8752d44 53 MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open);
pythontech 0:5868e8752d44 54
pythontech 0:5868e8752d44 55 void mp_hal_stdout_tx_chr(char c);
pythontech 0:5868e8752d44 56
pythontech 0:5868e8752d44 57 // Text output
pythontech 0:5868e8752d44 58 void mp_hal_stdout_tx_strn(const char *str, size_t len) {
pythontech 0:5868e8752d44 59 while (len--) {
pythontech 0:5868e8752d44 60 mp_hal_stdout_tx_chr(*str++);
pythontech 0:5868e8752d44 61 }
pythontech 0:5868e8752d44 62 }
pythontech 0:5868e8752d44 63
pythontech 0:5868e8752d44 64 void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {
pythontech 0:5868e8752d44 65 while (len--) {
pythontech 0:5868e8752d44 66 char c = *str++;
pythontech 0:5868e8752d44 67 if (c == '\n') {
pythontech 0:5868e8752d44 68 mp_hal_stdout_tx_chr('\r');
pythontech 0:5868e8752d44 69 }
pythontech 0:5868e8752d44 70 mp_hal_stdout_tx_chr(c);
pythontech 0:5868e8752d44 71 }
pythontech 0:5868e8752d44 72 }
pythontech 0:5868e8752d44 73
pythontech 0:5868e8752d44 74 void mp_hal_stdout_tx_str(const char *str) {
pythontech 0:5868e8752d44 75 mp_hal_stdout_tx_strn(str, strlen(str));
pythontech 0:5868e8752d44 76 }
pythontech 0:5868e8752d44 77
pythontech 0:5868e8752d44 78 void mp_hal_set_interrupt_char(int c)
pythontech 0:5868e8752d44 79 {
pythontech 0:5868e8752d44 80 }
pythontech 0:5868e8752d44 81
pythontech 0:5868e8752d44 82 mp_uint_t mp_hal_ticks_ms(void) {
pythontech 0:5868e8752d44 83 return 0;
pythontech 0:5868e8752d44 84 }
pythontech 0:5868e8752d44 85
pythontech 0:5868e8752d44 86 void mp_hal_delay_ms(mp_uint_t ms) {
pythontech 0:5868e8752d44 87 }
pythontech 0:5868e8752d44 88
pythontech 0:5868e8752d44 89 void gc_collect(void) {}
pythontech 0:5868e8752d44 90 #if ! MICROPY_ENABLE_GC
pythontech 0:5868e8752d44 91 void gc_dump_info(void) {}
pythontech 0:5868e8752d44 92 #endif