Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mphalport.c@7:379d46fd02c2, 2016-04-26 (annotated)
- Committer:
- Colin Hogben
- Date:
- Tue Apr 26 22:50:06 2016 +0100
- Revision:
- 7:379d46fd02c2
- Parent:
- 0:5868e8752d44
Add help, DigitalIn etc.
Who changed what in which revision?
| User | Revision | Line number | New 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 |
| Colin Hogben |
7:379d46fd02c2 | 38 | mp_import_stat_t mp_import_stat(const char *path) { |
| Colin Hogben |
7:379d46fd02c2 | 39 | (void)path; |
| Colin Hogben |
7:379d46fd02c2 | 40 | return MP_IMPORT_STAT_NO_EXIST; |
| pythontech | 0:5868e8752d44 | 41 | } |
| pythontech | 0:5868e8752d44 | 42 | |
| Colin Hogben |
7:379d46fd02c2 | 43 | mp_lexer_t *mp_lexer_new_from_file(const char *filename) { |
| Colin Hogben |
7:379d46fd02c2 | 44 | (void)filename; |
| Colin Hogben |
7:379d46fd02c2 | 45 | return NULL; |
| pythontech | 0:5868e8752d44 | 46 | } |
| pythontech | 0:5868e8752d44 | 47 | |
| pythontech | 0:5868e8752d44 | 48 | mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { |
| Colin Hogben |
7:379d46fd02c2 | 49 | (void)n_args; |
| Colin Hogben |
7:379d46fd02c2 | 50 | (void)args; |
| Colin Hogben |
7:379d46fd02c2 | 51 | (void)kwargs; |
| Colin Hogben |
7:379d46fd02c2 | 52 | return mp_const_none; |
| pythontech | 0:5868e8752d44 | 53 | } |
| pythontech | 0:5868e8752d44 | 54 | MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open); |
| pythontech | 0:5868e8752d44 | 55 | |
| pythontech | 0:5868e8752d44 | 56 | void mp_hal_stdout_tx_chr(char c); |
| pythontech | 0:5868e8752d44 | 57 | |
| pythontech | 0:5868e8752d44 | 58 | // Text output |
| pythontech | 0:5868e8752d44 | 59 | void mp_hal_stdout_tx_strn(const char *str, size_t len) { |
| Colin Hogben |
7:379d46fd02c2 | 60 | while (len--) { |
| Colin Hogben |
7:379d46fd02c2 | 61 | mp_hal_stdout_tx_chr(*str++); |
| Colin Hogben |
7:379d46fd02c2 | 62 | } |
| pythontech | 0:5868e8752d44 | 63 | } |
| pythontech | 0:5868e8752d44 | 64 | |
| pythontech | 0:5868e8752d44 | 65 | void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) { |
| Colin Hogben |
7:379d46fd02c2 | 66 | while (len--) { |
| Colin Hogben |
7:379d46fd02c2 | 67 | char c = *str++; |
| Colin Hogben |
7:379d46fd02c2 | 68 | if (c == '\n') { |
| Colin Hogben |
7:379d46fd02c2 | 69 | mp_hal_stdout_tx_chr('\r'); |
| Colin Hogben |
7:379d46fd02c2 | 70 | } |
| Colin Hogben |
7:379d46fd02c2 | 71 | mp_hal_stdout_tx_chr(c); |
| pythontech | 0:5868e8752d44 | 72 | } |
| pythontech | 0:5868e8752d44 | 73 | } |
| pythontech | 0:5868e8752d44 | 74 | |
| pythontech | 0:5868e8752d44 | 75 | void mp_hal_stdout_tx_str(const char *str) { |
| pythontech | 0:5868e8752d44 | 76 | mp_hal_stdout_tx_strn(str, strlen(str)); |
| pythontech | 0:5868e8752d44 | 77 | } |
| pythontech | 0:5868e8752d44 | 78 | |
| Colin Hogben |
7:379d46fd02c2 | 79 | void mp_hal_set_interrupt_char(int c) { |
| Colin Hogben |
7:379d46fd02c2 | 80 | (void)c; |
| pythontech | 0:5868e8752d44 | 81 | } |
| pythontech | 0:5868e8752d44 | 82 | |
| pythontech | 0:5868e8752d44 | 83 | mp_uint_t mp_hal_ticks_ms(void) { |
| pythontech | 0:5868e8752d44 | 84 | return 0; |
| pythontech | 0:5868e8752d44 | 85 | } |
| pythontech | 0:5868e8752d44 | 86 | |
| pythontech | 0:5868e8752d44 | 87 | void mp_hal_delay_ms(mp_uint_t ms) { |
| Colin Hogben |
7:379d46fd02c2 | 88 | (void)ms; |
| pythontech | 0:5868e8752d44 | 89 | } |
| pythontech | 0:5868e8752d44 | 90 | |
| pythontech | 0:5868e8752d44 | 91 | void gc_collect(void) {} |
| pythontech | 0:5868e8752d44 | 92 | #if ! MICROPY_ENABLE_GC |
| pythontech | 0:5868e8752d44 | 93 | void gc_dump_info(void) {} |
| pythontech | 0:5868e8752d44 | 94 | #endif |