mirror of
https://github.com/google/pebble.git
synced 2025-05-22 11:24:52 +00:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
43
third_party/jerryscript/targets/esp8266/user/Makefile
vendored
Normal file
43
third_party/jerryscript/targets/esp8266/user/Makefile
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
|
||||
#############################################################
|
||||
# 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 -I../../../
|
||||
sinclude $(PDIR)Makefile
|
||||
|
94
third_party/jerryscript/targets/esp8266/user/jerry_port.c
vendored
Normal file
94
third_party/jerryscript/targets/esp8266/user/jerry_port.c
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
/* Copyright 2014-2016 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>
|
||||
|
||||
#include "jerry-core/jerry-port.h"
|
||||
|
||||
/**
|
||||
* Provide console message implementation for the engine.
|
||||
*/
|
||||
void
|
||||
jerry_port_console (const char *format, /**< format string */
|
||||
...) /**< parameters */
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, format);
|
||||
/* TODO, uncomment when vprint link is ok */
|
||||
/* vfprintf (stdout, format, args); */
|
||||
va_end (args);
|
||||
} /* jerry_port_console */
|
||||
|
||||
/**
|
||||
* Provide log message implementation for the engine.
|
||||
*/
|
||||
void
|
||||
jerry_port_log (jerry_log_level_t level, /**< log level */
|
||||
const char *format, /**< format string */
|
||||
...) /**< parameters */
|
||||
{
|
||||
(void) level; /* ignore log level */
|
||||
|
||||
va_list args;
|
||||
va_start (args, format);
|
||||
/* TODO, uncomment when vprint link is ok */
|
||||
/* vprintf (stderr, format, args); */
|
||||
va_end (args);
|
||||
} /* jerry_port_log */
|
||||
|
||||
|
||||
/** exit - cause normal process termination */
|
||||
void exit (int status)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
}
|
||||
} /* exit */
|
||||
|
||||
/** abort - cause abnormal process termination */
|
||||
void abort (void)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
}
|
||||
} /* abort */
|
||||
|
||||
/**
|
||||
* fwrite
|
||||
*
|
||||
* @return number of bytes written
|
||||
*/
|
||||
size_t
|
||||
fwrite (const void *ptr, /**< data to write */
|
||||
size_t size, /**< size of elements to write */
|
||||
size_t nmemb, /**< number of elements */
|
||||
FILE *stream) /**< stream pointer */
|
||||
{
|
||||
return size * nmemb;
|
||||
} /* fwrite */
|
||||
|
||||
/**
|
||||
* This function can get the time as well as a timezone.
|
||||
*
|
||||
* @return 0 if success, -1 otherwise
|
||||
*/
|
||||
int
|
||||
gettimeofday (void *tp, /**< struct timeval */
|
||||
void *tzp) /**< struct timezone */
|
||||
{
|
||||
return -1;
|
||||
} /* gettimeofday */
|
50
third_party/jerryscript/targets/esp8266/user/native_esp8266.c
vendored
Normal file
50
third_party/jerryscript/targets/esp8266/user/native_esp8266.c
vendored
Normal file
|
@ -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);
|
||||
}
|
39
third_party/jerryscript/targets/esp8266/user/user_gpio.c
vendored
Normal file
39
third_party/jerryscript/targets/esp8266/user/user_gpio.c
vendored
Normal file
|
@ -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);
|
||||
}
|
111
third_party/jerryscript/targets/esp8266/user/user_main.c
vendored
Normal file
111
third_party/jerryscript/targets/esp8266/user/user_main.c
vendored
Normal file
|
@ -0,0 +1,111 @@
|
|||
/* 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)
|
||||
{
|
||||
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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue