Add target build for ESP8266 board.
JerryScript-DCO-1.0-Signed-off-by: SaeHie Park saehie.park@samsung.com
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
|
||||
#############################################################
|
||||
# Required variables for each makefile
|
||||
# Discard this section from all parent makefiles
|
||||
# Expected variables (with automatic defaults):
|
||||
# CSRCS (all "C" files in the dir)
|
||||
# SUBDIRS (all subdirs with a Makefile)
|
||||
# GEN_LIBS - list of libs to be generated ()
|
||||
# GEN_IMAGES - list of images to be generated ()
|
||||
# COMPONENTS_xxx - a list of libs/objs in the form
|
||||
# subdir/lib to be extracted and rolled up into
|
||||
# a generated lib/image xxx.a ()
|
||||
#
|
||||
ifndef PDIR
|
||||
GEN_LIBS = libuser.a
|
||||
endif
|
||||
|
||||
|
||||
#############################################################
|
||||
# Configuration i.e. compile options etc.
|
||||
# Target specific stuff (defines etc.) goes in here!
|
||||
# Generally values applying to a tree are captured in the
|
||||
# makefile at its root level - these are then overridden
|
||||
# for a subtree within the makefile rooted therein
|
||||
#
|
||||
#DEFINES +=
|
||||
|
||||
#############################################################
|
||||
# Recursion Magic - Don't touch this!!
|
||||
#
|
||||
# Each subtree potentially has an include directory
|
||||
# corresponding to the common APIs applicable to modules
|
||||
# rooted at that subtree. Accordingly, the INCLUDE PATH
|
||||
# of a module can only contain the include directories up
|
||||
# its parent path, and not its siblings
|
||||
#
|
||||
# Required for each makefile to inherit from the parent
|
||||
#
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include
|
||||
INCLUDES += -I ./ -I ../include
|
||||
PDIR := ../$(PDIR)
|
||||
sinclude $(PDIR)Makefile
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "esp_common.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
/**
|
||||
* Provide log message to filestream implementation for the engine.
|
||||
*/
|
||||
int jerry_port_logmsg (FILE* stream, const char* format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int count = 0;
|
||||
va_start (args, format);
|
||||
// TODO, uncomment when vfprint link is ok
|
||||
//count = vfprintf (stream, format, args);
|
||||
va_end (args);
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide error message to console implementation for the engine.
|
||||
*/
|
||||
int jerry_port_errormsg (const char* format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int count = 0;
|
||||
va_start (args, format);
|
||||
// TODO, uncomment when vprint link is ok
|
||||
//count = vprintf (format, args);
|
||||
va_end (args);
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide output character to console implementation for the engine.
|
||||
*/
|
||||
int jerry_port_putchar (int c)
|
||||
{
|
||||
printf ("%c", (char)c);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
void exit (int status)
|
||||
{
|
||||
printf ("!!!! EXIT: %d\n", status);
|
||||
while (true)
|
||||
{
|
||||
;
|
||||
}
|
||||
} /* exit */
|
||||
@@ -0,0 +1,50 @@
|
||||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright 2013-2014 Espressif Systems (Wuxi)
|
||||
*
|
||||
* FileName: user_main.c
|
||||
*
|
||||
* Description: entry file of user application
|
||||
*
|
||||
* Modification history:
|
||||
* 2014/12/1, v1.0 create this file.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "esp_common.h"
|
||||
|
||||
#include "user_config.h"
|
||||
#include "esp8266_gpio.h"
|
||||
|
||||
|
||||
void native_gpio_dir(int port, int value) {
|
||||
if (value) {
|
||||
GPIO_AS_OUTPUT(1 << port);
|
||||
}
|
||||
else {
|
||||
GPIO_AS_INPUT(1 << port);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void native_gpio_set(int port, int value) {
|
||||
GPIO_OUTPUT_SET(port, value);
|
||||
}
|
||||
|
||||
|
||||
int native_gpio_get(int port) {
|
||||
return GPIO_INPUT_GET(port);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 -2016 Espressif System
|
||||
*
|
||||
*/
|
||||
|
||||
#include "esp_common.h"
|
||||
|
||||
#include "esp8266_gpio.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void gpio_output_conf(uint32 set_mask, uint32 clear_mask, uint32 enable_mask,
|
||||
uint32 disable_mask) {
|
||||
GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, set_mask);
|
||||
GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, clear_mask);
|
||||
GPIO_REG_WRITE(GPIO_ENABLE_W1TS_ADDRESS, enable_mask);
|
||||
GPIO_REG_WRITE(GPIO_ENABLE_W1TC_ADDRESS, disable_mask);
|
||||
}
|
||||
|
||||
|
||||
uint32 gpio_input_get(void) {
|
||||
return GPIO_REG_READ(GPIO_IN_ADDRESS);
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright 2013-2014 Espressif Systems (Wuxi)
|
||||
*
|
||||
* FileName: user_main.c
|
||||
*
|
||||
* Description: entry file of user application
|
||||
*
|
||||
* Modification history:
|
||||
* 2014/12/1, v1.0 create this file.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "esp_common.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
#include "user_config.h"
|
||||
#include "esp8266_uart.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void show_free_mem(int idx) {
|
||||
size_t res = xPortGetFreeHeapSize();
|
||||
printf("dbg free memory(%d): %d\r\n", idx, res);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "jerry_targetjs.h"
|
||||
|
||||
|
||||
static int jerry_task_init(void) {
|
||||
int retcode;
|
||||
int src;
|
||||
|
||||
DECLARE_JS_CODES;
|
||||
|
||||
/* run main.js */
|
||||
show_free_mem(2);
|
||||
retcode = js_entry(js_codes[0].source, js_codes[0].length);
|
||||
if (retcode != 0) {
|
||||
printf("js_entry failed code(%d) [%s]\r\n", retcode, js_codes[0].name);
|
||||
return -1;
|
||||
}
|
||||
/* run rest of the js files */
|
||||
show_free_mem(3);
|
||||
for (src=1; js_codes[src].source; src++) {
|
||||
retcode = js_eval(js_codes[src].source, js_codes[src].length);
|
||||
if (retcode != 0) {
|
||||
printf("js_eval failed code(%d) [%s]\r\n", retcode, js_codes[src].name);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
show_free_mem(4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void jerry_task(void *pvParameters) {
|
||||
const portTickType xDelay = 100 / portTICK_RATE_MS;
|
||||
uint32_t ticknow = 0;
|
||||
|
||||
if (jerry_task_init() == 0) {
|
||||
for (;;) {
|
||||
vTaskDelay(xDelay);
|
||||
js_loop(ticknow);
|
||||
if (!ticknow) {
|
||||
show_free_mem(5);
|
||||
}
|
||||
ticknow++;
|
||||
}
|
||||
}
|
||||
js_exit();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* This is entry point for user code
|
||||
*/
|
||||
void ICACHE_FLASH_ATTR user_init(void)
|
||||
{
|
||||
const portTickType onesec = 1000 / portTICK_RATE_MS;
|
||||
uart_div_modify(UART0, UART_CLK_FREQ / (BIT_RATE_115200));
|
||||
|
||||
show_free_mem(0);
|
||||
wifi_softap_dhcps_stop();
|
||||
show_free_mem(1);
|
||||
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0); // GPIO 0
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2); // GPIO 2
|
||||
|
||||
xTaskCreate(jerry_task, "jerry", JERRY_STACK_SIZE, NULL, 2, NULL);
|
||||
}
|
||||
Reference in New Issue
Block a user