Skip to content

Commit 37ed824

Browse files
janjongboomLaszloLango
authored andcommitted
target: mbedos5: Update to mbed OS 5.4.5 (jerryscript-project#1853)
Also ignore the default jerry-port - see also jerryscript-project#1847. Re-implement the `print()` function, as it's no longer part of core Jerry, but our programs still depend on it. JerryScript-DCO-1.0-Signed-off-by: Jan Jongboom [email protected]
1 parent a8a25e7 commit 37ed824

File tree

7 files changed

+67
-4
lines changed

7 files changed

+67
-4
lines changed

targets/mbedos5/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
BOARD=$(subst [mbed] ,,$(shell mbed target))
2020
HEAPSIZE=16
2121

22-
DEBUG=0
23-
NO_JS=0
24-
MBED_VERBOSE=0
22+
DEBUG?=0
23+
NO_JS?=0
24+
MBED_VERBOSE?=0
2525

2626
MBED_CLI_FLAGS=-j0 --source . --source ../../
2727

targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/lib_drivers.h

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "jerryscript-mbed-drivers/DigitalOut-js.h"
2020
#include "jerryscript-mbed-drivers/setInterval-js.h"
2121
#include "jerryscript-mbed-drivers/setTimeout-js.h"
22+
#include "jerryscript-mbed-drivers/print-js.h"
2223
#include "jerryscript-mbed-drivers/assert-js.h"
2324
#include "jerryscript-mbed-drivers/I2C-js.h"
2425
#include "jerryscript-mbed-drivers/gc-js.h"
@@ -32,6 +33,7 @@ DECLARE_JS_WRAPPER_REGISTRATION (base) {
3233
REGISTER_GLOBAL_FUNCTION(setTimeout);
3334
REGISTER_GLOBAL_FUNCTION(clearInterval);
3435
REGISTER_GLOBAL_FUNCTION(clearTimeout);
36+
REGISTER_GLOBAL_FUNCTION(print);
3537
REGISTER_CLASS_CONSTRUCTOR(DigitalOut);
3638
REGISTER_CLASS_CONSTRUCTOR(I2C);
3739
REGISTER_CLASS_CONSTRUCTOR(InterruptIn);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* Copyright JS Foundation and other contributors, http://js.foundation
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
#ifndef _JERRYSCRIPT_MBED_DRIVERS_PRINT_H
16+
#define _JERRYSCRIPT_MBED_DRIVERS_PRINT_H
17+
18+
#include "jerryscript-mbed-library-registry/wrap_tools.h"
19+
20+
DECLARE_GLOBAL_FUNCTION(print);
21+
22+
#endif // _JERRYSCRIPT_MBED_DRIVERS_PRINT_H
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* Copyright JS Foundation and other contributors, http://js.foundation
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
#include "mbed.h"
16+
#include "jerryscript-mbed-drivers/print-js.h"
17+
18+
/**
19+
* print (native JavaScript function)
20+
*
21+
* Print a string over serial (baud rate 115,200)
22+
*
23+
* @param string String to print
24+
*/
25+
DECLARE_GLOBAL_FUNCTION(print) {
26+
CHECK_ARGUMENT_COUNT(global, print, (args_count == 1));
27+
CHECK_ARGUMENT_TYPE_ALWAYS(global, print, 0, string);
28+
29+
jerry_size_t szArg0 = jerry_get_string_size(args[0]);
30+
jerry_char_t *sArg0 = (jerry_char_t*) calloc(szArg0 + 1, sizeof(jerry_char_t));
31+
jerry_string_to_char_buffer(args[0], sArg0, szArg0);
32+
33+
printf("%s\n", (const char*)sArg0);
34+
35+
return jerry_create_undefined();
36+
}

targets/mbedos5/jerryscript-mbed/jerryscript-mbed-util/logging.h

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#ifndef _JERRYSCRIPT_MBED_UTIL_LOGGING_H
1616
#define _JERRYSCRIPT_MBED_UTIL_LOGGING_H
1717

18+
#include "mbed.h"
19+
1820
#ifdef DEBUG_WRAPPER
1921
#define LOG_PRINT(...) printf(__VA_ARGS__)
2022
#else

targets/mbedos5/mbed-os.lib

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://github.com/ARMmbed/mbed-os/#d5de476f74dd4de27012eb74ede078f6330dfc3f
1+
https://github.com/ARMmbed/mbed-os/#8d21974ba35e04c4854e5090c0f8283171664175

targets/mbedos5/template-mbedignore.txt

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ targets/*
99
tests/*
1010
third-party/*
1111
tools/*
12+
jerry-port/default/*

0 commit comments

Comments
 (0)