Support of STM32F3 board.

This commit is contained in:
Ruben Ayrapetyan
2014-10-17 21:48:09 +04:00
parent 9c1428de29
commit 8e1156bd9e
12 changed files with 1788 additions and 489 deletions
+12 -8
View File
@@ -41,25 +41,29 @@
# dwarf4=1 - use DWARF v4 format for debug information
#
export TARGET_MODES = debug debug_release release
export TARGET_DEBUG_MODES = debug debug_release
export TARGET_RELEASE_MODES = release
export TARGET_PC_SYSTEMS = linux
export TARGET_MCU_SYSTEMS = $(addprefix stm32f,4) # now only stm32f4 is supported, to add, for example, to stm32f3, change to $(addprefix stm32f,3 4)
export TARGET_MCU_SYSTEMS = $(addprefix stm32f,3 4)
export TARGET_PC_MODS = musl sanitize valgrind \
musl-valgrind
export TARGET_MCU_MODS =
export TARGET_SYSTEMS = $(TARGET_PC_SYSTEMS) \
$(TARGET_MCU_SYSTEMS) \
$(foreach __MOD,$(TARGET_PC_MODS),$(foreach __SYSTEM,$(TARGET_PC_SYSTEMS),$(__SYSTEM)-$(__MOD))) \
$(foreach __MOD,$(TARGET_MCU_MODS),$(foreach __SYSTEM,$(TARGET_MCU_SYSTEMS),$(__SYSTEM)-$(__MOD)))
export TARGET_PC_SYSTEMS_MODS = $(TARGET_PC_SYSTEMS) \
$(foreach __MOD,$(TARGET_PC_MODS),$(foreach __SYSTEM,$(TARGET_PC_SYSTEMS),$(__SYSTEM)-$(__MOD)))
export TARGET_MCU_SYSTEMS_MODS = $(TARGET_MCU_SYSTEMS) \
$(foreach __MOD,$(TARGET_MCU_MODS),$(foreach __SYSTEM,$(TARGET_MCU_SYSTEMS),$(__SYSTEM)-$(__MOD)))
# Target list
export JERRY_TARGETS = $(foreach __MODE,$(TARGET_MODES),$(foreach __SYSTEM,$(TARGET_SYSTEMS),$(__MODE).$(__SYSTEM)))
export JERRY_TARGETS = $(foreach __MODE,$(TARGET_DEBUG_MODES),$(foreach __SYSTEM,$(TARGET_PC_SYSTEMS_MODS),$(__MODE).$(__SYSTEM))) \
$(foreach __MODE,$(TARGET_RELEASE_MODES),$(foreach __SYSTEM,$(TARGET_PC_SYSTEMS_MODS),$(__MODE).$(__SYSTEM))) \
$(foreach __MODE,$(TARGET_RELEASE_MODES),$(foreach __SYSTEM,$(TARGET_MCU_SYSTEMS_MODS),$(__MODE).$(__SYSTEM)))
export TESTS_TARGET = unittests
export CHECK_TARGETS = $(foreach __TARGET,$(JERRY_TARGETS),$(__TARGET).check)
export FLASH_TARGETS = $(foreach __TARGET,$(foreach __MODE,$(TARGET_MODES),$(foreach __SYSTEM,$(TARGET_MCU_SYSTEMS),$(__MODE).$(__SYSTEM))),$(__TARGET).flash)
export FLASH_TARGETS = $(foreach __TARGET,$(foreach __MODE,$(TARGET_RELEASE_MODES),$(foreach __SYSTEM,$(TARGET_MCU_SYSTEMS_MODS),$(__MODE).$(__SYSTEM))),$(__TARGET).flash)
export OUT_DIR = ./out
export UNITTESTS_SRC_DIR = ./tests/unit
+20 -7
View File
@@ -16,6 +16,7 @@ STRIP = strip
MAIN_MODULE_SRC = ./src/main.c
LNK_SCRIPT_STM32F3 = ./third-party/stm32f3.ld
LNK_SCRIPT_STM32F4 = ./third-party/stm32f4.ld
# Parsing target
@@ -234,11 +235,6 @@ ifeq ($(TARGET_CPU),cortexm4)
CFLAGS_COMMON += $(CFLAGS_CORTEXM4)
endif
# System-specific common
ifeq ($(TARGET_SYSTEM),stm32f4)
LDFLAGS += -nostartfiles -T$(LNK_SCRIPT_STM32F4)
endif
ifeq ($(OPTION_MCU),enable)
CC := $(CROSS_COMPILE)$(CC)
LD := $(CROSS_COMPILE)$(LD)
@@ -345,6 +341,7 @@ ifeq ($(OPTION_MCU),disable)
else
CFLAGS_COMMON += -ffunction-sections -fdata-sections -nostdlib
DEFINES_JERRY += -D__TARGET_MCU
LDFLAGS += -Wl,--gc-sections
endif
ifeq ($(OPTION_COLOR),enable)
@@ -377,6 +374,8 @@ INCLUDES_THIRDPARTY = -I third-party/valgrind/
CFLAGS_THIRDPARTY =
ifeq ($(TARGET_SYSTEM),stm32f4)
DEFINES_JERRY += -D__TARGET_MCU_STM32F4
LDFLAGS += -nostartfiles -T$(LNK_SCRIPT_STM32F4)
SOURCES_THIRDPARTY += \
./third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c \
./third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f4xx.s \
@@ -389,9 +388,23 @@ ifeq ($(TARGET_SYSTEM),stm32f4)
-I third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/STM32F4xx_StdPeriph_Driver/inc \
-I third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/Include \
-I third-party/STM32F4-Discovery_FW_V1.1.0/
else
ifeq ($(TARGET_SYSTEM),stm32f3)
DEFINES_JERRY += -D__TARGET_MCU_STM32F3
LDFLAGS += -nostartfiles -T$(LNK_SCRIPT_STM32F3)
SOURCES_THIRDPARTY += \
./third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Source/Templates/system_stm32f30x.c \
./third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Source/Templates/gcc_ride7/startup_stm32f30x.s \
./third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_tim.c \
./third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_gpio.c \
./third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_rcc.c
#-I third-party/STM32F4-Discovery_FW_V1.1.0/Project/Demonstration \
INCLUDES_THIRDPARTY += \
-I ./third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Include/ \
-I ./third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/STM32F30x_StdPeriph_Driver/inc \
-I ./third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Include/ \
-I ./third-party/STM32F3-Discovery_FW_V1.1.0
endif
endif
# Unit tests
+67 -48
View File
@@ -12,6 +12,25 @@
// See the License for the specific language governing permissions and
// limitations under the License.
var led_green = 0;
var led_orange = 1;
var led_red = 2;
var led_blue = 3;
function LEDSet(led_group, on)
{
if (on)
{
LEDOn (led_group);
LEDOn (led_group + 4);
}
else
{
LEDOff (led_group);
LEDOff (led_group + 4);
}
}
var tmp, a, b = 1, c = 2, d, e = 3, g = 4;
var count = 1000;
@@ -27,99 +46,99 @@ while (1)
{
for (var j = 0; j < numOfIterations; j += 1)
{
LEDOn(12);
LEDOn(13);
LEDOn(14);
LEDOn(15);
LEDSet(led_green, true);
LEDSet(led_orange, true);
LEDSet(led_red, true);
LEDSet(led_blue, true);
wait(waitTime * 2);
LEDOff(12);
LEDOff(13);
LEDOff(14);
LEDOff(15);
LEDSet(led_green, false);
LEDSet(led_orange, false);
LEDSet(led_red, false);
LEDSet(led_blue, false);
wait(waitTime * 2);
}
for (var j = 0; j < numOfIterations; j += 1)
{
LEDOn(12);
LEDSet(led_green, true);
wait(waitTime);
LEDOff(12);
LEDSet(led_green, false);
wait(waitTime);
LEDOn(13);
LEDSet(led_orange, true);
wait(waitTime);
LEDOff(13);
LEDSet(led_orange, false);
wait(waitTime);
LEDOn(14);
LEDSet(led_red, true);
wait(waitTime);
LEDOff(14);
LEDSet(led_red, false);
wait(waitTime);
LEDOn(15);
LEDSet(led_blue, true);
wait(waitTime);
LEDOff(15);
LEDSet(led_blue, false);
wait(waitTime);
}
for (var j = 0; j < numOfIterations; j += 1)
{
LEDOn(12);
LEDSet(led_green, true);
wait(waitTime);
LEDOff(12);
LEDOn(13);
LEDSet(led_green, false);
LEDSet(led_orange, true);
wait(waitTime);
LEDOff(13);
LEDOn(14);
LEDSet(led_orange, false);
LEDSet(led_red, true);
wait(waitTime);
LEDOff(14);
LEDOn(15);
LEDSet(led_red, false);
LEDSet(led_blue, true);
wait(waitTime);
LEDOff(15);
LEDSet(led_blue, false);
}
for (var j = 0; j < numOfIterations; j += 1)
{
LEDOn(12);
LEDSet(led_green, true);
wait(waitTime / 2);
LEDOff(12);
LEDOn(13);
LEDSet(led_green, false);
LEDSet(led_orange, true);
wait(waitTime / 2);
LEDOff(13);
LEDOn(14);
LEDSet(led_orange, false);
LEDSet(led_red, true);
wait(waitTime / 2);
LEDOff(14);
LEDOn(15);
LEDSet(led_red, false);
LEDSet(led_blue, true);
wait(waitTime / 2);
LEDOff(15);
LEDSet(led_blue, false);
}
for (var j = 0; j < numOfIterations; j += 1)
{
LEDOn(12);
LEDSet(led_green, true);
wait(waitTime / 3);
LEDOff(12);
LEDOn(13);
LEDSet(led_green, false);
LEDSet(led_orange, true);
wait(waitTime / 3);
LEDOff(13);
LEDOn(14);
LEDSet(led_orange, false);
LEDSet(led_red, true);
wait(waitTime / 3);
LEDOff(14);
LEDOn(15);
LEDSet(led_red, false);
LEDSet(led_blue, true);
wait(waitTime / 3);
LEDOff(15);
LEDSet(led_blue, false);
}
for (var j = 0; j < numOfIterations; j += 1)
{
LEDOn(12);
LEDSet(led_green, true);
wait(waitTime / 6);
LEDOff(12);
LEDOn(13);
LEDSet(led_green, false);
LEDSet(led_orange, true);
wait(waitTime / 6);
LEDOff(13);
LEDOn(14);
LEDSet(led_orange, false);
LEDSet(led_red, true);
wait(waitTime / 6);
LEDOff(14);
LEDOn(15);
LEDSet(led_red, false);
LEDSet(led_blue, true);
wait(waitTime / 6);
LEDOff(15);
LEDSet(led_blue, false);
}
}
+7 -1
View File
@@ -55,7 +55,13 @@
/**
* Size of heap
*/
#define CONFIG_MEM_HEAP_AREA_SIZE (64 * 1024)
#ifdef __TARGET_HOST
# define CONFIG_MEM_HEAP_AREA_SIZE (64 * 1024)
#elif defined (__TARGET_MCU)
# define CONFIG_MEM_HEAP_AREA_SIZE (8 * 1024)
#else /* !__TARGET_HOST && !__TARGET_MCU */
# error "!__TARGET_HOST && !__TARGET_MCU"
#endif /* !__TARGET_HOST && !__TARGET_MCU */
/**
* Log2 of maximum possible offset in the heap
+1177 -300
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -116,7 +116,7 @@ extern void __noreturn jerry_unimplemented (const char *comment, const char *fil
* Mark for unreachable points and unimplemented cases
*/
extern void jerry_ref_unused_variables (int unused_variables_follow, ...);
#ifndef JERRY_NDEBUG
#if !defined (JERRY_NDEBUG) && defined (__TARGET_HOST)
#define JERRY_UNREACHABLE() \
do \
{ \
@@ -138,7 +138,7 @@ extern void jerry_ref_unused_variables (int unused_variables_follow, ...);
jerry_ref_unused_variables (0, __VA_ARGS__); \
} \
} while (0)
#else /* !JERRY_NDEBUG */
#else /* !JERRY_NDEBUG && __TARGET_HOST */
#define JERRY_UNREACHABLE() \
do \
{ \
@@ -160,7 +160,7 @@ extern void jerry_ref_unused_variables (int unused_variables_follow, ...);
jerry_ref_unused_variables (0, __VA_ARGS__); \
} \
} while (0)
#endif /* JERRY_NDEBUG */
#endif /* JERRY_NDEBUG || !TARGET_HOST */
/**
* Conditions' likeliness, unlikeliness.
*/
+187 -57
View File
@@ -13,88 +13,218 @@
* limitations under the License.
*/
#ifdef __TARGET_MCU
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#include "stm32f4xx_conf.h"
#include "stm32f4xx.h"
#pragma GCC diagnostic pop
#endif
#include "actuators.h"
#include "common-io.h"
#include "jerry-libc.h"
void
led_toggle (uint32_t led_id)
{
#ifdef __TARGET_HOST
/**
* Host stub for LEDToggle operation
*/
void
led_toggle (uint32_t led_id) /**< index of LED */
{
__printf ("led_toggle: %d\n", led_id);
#endif
#ifdef __TARGET_MCU
GPIOD->ODR ^= (uint16_t) (1 << led_id);
#endif
}
/**
* Host stub for LEDOn operation
*/
void
led_on (uint32_t led_id)
led_on (uint32_t led_id) /**< index of LED */
{
#ifdef __TARGET_HOST
__printf ("led_on: %d\n", led_id);
#endif
#ifdef __TARGET_MCU
GPIO_WriteBit (GPIOD, (uint16_t) (1 << led_id), Bit_SET);
#endif
}
/**
* Host stub for LEDOff operation
*/
void
led_off (uint32_t led_id)
led_off (uint32_t led_id) /**< index of LED */
{
#ifdef __TARGET_HOST
__printf ("led_off: %d\n", led_id);
#endif
#ifdef __TARGET_MCU
GPIO_WriteBit (GPIOD, (uint16_t) (1 << led_id), Bit_RESET);
#endif
}
/**
* Host stub for LEDOnce operation
*/
void
led_blink_once (uint32_t led_id)
led_blink_once (uint32_t led_id) /**< index of LED */
{
#ifdef __TARGET_HOST
__printf ("led_blink_once: %d\n", led_id);
#endif
#ifdef __TARGET_MCU
uint32_t dot = 300000;
GPIOD->BSRRL = (uint16_t) (1 << led_id);
wait_ms (dot);
GPIOD->BSRRH = (uint16_t) (1 << led_id);
#endif
}
#else /* !__TARGET_HOST */
#ifndef __TARGET_MCU
# error "!__TARGET_HOST && !__TARGET_MCU"
#endif /* !__TARGET_MCU */
#ifdef __TARGET_MCU
#include "mcu-headers.h"
void
initialize_leds ()
#ifdef __TARGET_MCU_STM32F4
/**
* Number of LEDs on the board
*/
#define LED_NUMBER 4
/**
* LEDs' GPIO pins
*/
static const uint16_t led_pins [LED_NUMBER] =
{
GPIO_Pin_12, /* LD4: Green */
GPIO_Pin_13, /* LD3: Orange */
GPIO_Pin_14, /* LD5: Red */
GPIO_Pin_15 /* LD6: Blue */
};
/**
* LEDs' GPIO ports
*/
static GPIO_TypeDef* leds_port = GPIOD;
/**
* Initialize LEDs on the board
*/
void
initialize_leds (void)
{
GPIO_InitTypeDef gpio_init_structure;
RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOD, ENABLE);
GPIO_InitTypeDef gpioStructure;
gpioStructure.GPIO_Pin = GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;
gpioStructure.GPIO_Mode = GPIO_Mode_OUT;
gpioStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_Init (GPIOD, &gpioStructure);
uint16_t led_pins_mask = 0;
for (uint32_t led_index = 0;
led_index < LED_NUMBER;
led_index++)
{
led_pins_mask |= led_pins[led_index];
}
GPIO_WriteBit (GPIOD,
GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15,
Bit_RESET);
}
#endif
gpio_init_structure.GPIO_Pin = led_pins_mask;
gpio_init_structure.GPIO_Mode = GPIO_Mode_OUT;
gpio_init_structure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_Init (leds_port, &gpio_init_structure);
for (uint32_t led_index = 0;
led_index < LED_NUMBER;
led_index++)
{
led_off (led_index);
}
} /* initialize_leds */
#else /* !__TARGET_MCU_STM32F4 */
# ifndef __TARGET_MCU_STM32F3
# error "!__TARGET_MCU_STM32F4 && !__TARGET_MCU_STM32F3"
# endif /* !__TARGET_MCU_STM32F3 */
/**
* Number of LEDs on the board
*/
#define LED_NUMBER 8
/**
* LEDs' GPIO pins
*/
static const uint16_t led_pins [LED_NUMBER] =
{
GPIO_Pin_15, /* LD6 - Green */
GPIO_Pin_14, /* LD8 - Orange */
GPIO_Pin_13, /* LD10 - Red */
GPIO_Pin_12, /* LD9 - Blue */
GPIO_Pin_11, /* LD7 - Green */
GPIO_Pin_10, /* LD5 - Orange */
GPIO_Pin_9, /* LD3 - Red */
GPIO_Pin_8 /* LD4 - Blue */
};
/**
* LEDs' GPIO ports
*/
static GPIO_TypeDef* leds_port = GPIOE;
/**
* Initialize LEDs on the board
*/
void
initialize_leds (void)
{
GPIO_InitTypeDef gpio_init_structure;
RCC_AHBPeriphClockCmd (RCC_AHBPeriph_GPIOE, ENABLE);
uint16_t led_pins_mask = 0;
for (uint32_t led_index = 0;
led_index < LED_NUMBER;
led_index++)
{
led_pins_mask |= led_pins[led_index];
}
gpio_init_structure.GPIO_Pin = led_pins_mask;
gpio_init_structure.GPIO_Mode = GPIO_Mode_OUT;
gpio_init_structure.GPIO_OType = GPIO_OType_PP;
gpio_init_structure.GPIO_PuPd = GPIO_PuPd_UP;
gpio_init_structure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init (leds_port, &gpio_init_structure);
for (uint32_t led_index = 0;
led_index < LED_NUMBER;
led_index++)
{
led_off (led_index);
}
} /* initialize_leds */
#endif /* !__TARGET_MCU_STM32F4 && __TARGET_MCU_STM32F3 */
/**
* Toggle specified LED
*/
void
led_toggle (uint32_t led_id) /**< index of LED */
{
if (led_id < LED_NUMBER)
{
leds_port->ODR ^= led_pins [led_id];
}
} /* led_toggle */
/**
* Turn specified LED on
*/
void
led_on (uint32_t led_id) /**< index of LED */
{
if (led_id < LED_NUMBER)
{
GPIO_WriteBit (leds_port, led_pins[led_id], Bit_SET);
}
} /* led_on */
/**
* Turn specified LED off
*/
void
led_off (uint32_t led_id) /**< index of LED */
{
if (led_id < LED_NUMBER)
{
GPIO_WriteBit (leds_port, led_pins[led_id], Bit_RESET);
}
} /* led_off */
/**
* Blink once with specified LED
*/
void
led_blink_once (uint32_t led_id) /**< index of LED */
{
uint32_t dot = 300;
led_on (led_id);
wait_ms (dot);
led_off (led_id);
} /* led_blink_once */
#endif /* !__TARGET_HOST && __TARGET_MCU */
+53 -65
View File
@@ -13,23 +13,11 @@
* limitations under the License.
*/
#include "actuators.h"
#include "common-io.h"
#include "jerry-libc.h"
#ifdef __TARGET_MCU
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#include "stm32f4xx_conf.h"
#include "stm32f4xx.h"
#pragma GCC diagnostic pop
// STM32 F4
#define LED_GREEN 12
#define LED_ORANGE 13
#define LED_RED 14
#define LED_BLUE 15
#endif
#include "mcu-headers.h"
int
digital_read (uint32_t arg1 __unused, uint32_t arg2 __unused)
@@ -55,62 +43,17 @@ analog_write (uint32_t arg1 __unused, uint32_t arg2 __unused)
JERRY_UNIMPLEMENTED ();
}
#ifdef __TARGET_HOST
void
wait_ms (uint32_t time_ms)
{
#ifdef __TARGET_HOST
// 1 millisecond = 1,000,000 Nanoseconds
#define NANO_SECOND_MULTIPLIER 1000000
__printf ("wait_ms: %d\n", time_ms);
#endif
#ifdef __TARGET_MCU
while (time_ms --)
{
wait_1ms ();
}
#endif
}
#else /* !__TARGET_HOST */
#ifdef __TARGET_MCU
void
initialize_timer ()
{
RCC_APB1PeriphClockCmd (RCC_APB1Periph_TIM2, ENABLE);
TIM_TimeBaseInitTypeDef timerInitStructure;
timerInitStructure.TIM_Prescaler = 40000;
timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
timerInitStructure.TIM_Period = 500;
timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
timerInitStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit (TIM2, &timerInitStructure);
TIM_Cmd (TIM2, ENABLE);
}
void
fake_exit (void)
{
uint32_t pin = LED_ORANGE;
volatile GPIO_TypeDef* gpio = GPIOD;
volatile int index;
int dot = 600000;
int dash = dot * 3;
while (1)
{
gpio->BSRRL = (uint16_t) (1 << pin);
for ( index = 0; index < dot; index ++)
{
};
gpio->BSRRH = (uint16_t) (1 << pin);
for (index = 0; index < dash; index ++)
{
};
}
}
#ifndef __TARGET_MCU
# error "!__TARGET_HOST && !__TARGET_MCU"
#endif /* !__TARGET_MCU */
static __IO uint32_t sys_tick_counter;
@@ -163,4 +106,49 @@ wait_1ms (void)
{
}
}
#endif
void
wait_ms (uint32_t time_ms)
{
while (time_ms --)
{
wait_1ms ();
}
}
void
fake_exit (void)
{
uint32_t pin = LED_ORANGE;
volatile int index;
int dot = 600000;
int dash = dot * 3;
while (1)
{
led_on (pin);
for ( index = 0; index < dot; index ++)
{
};
led_off (pin);
for (index = 0; index < dash; index ++)
{
};
}
}
void
initialize_timer ()
{
RCC_APB1PeriphClockCmd (RCC_APB1Periph_TIM2, ENABLE);
TIM_TimeBaseInitTypeDef timerInitStructure;
timerInitStructure.TIM_Prescaler = 40000;
timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
timerInitStructure.TIM_Period = 500;
timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
timerInitStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit (TIM2, &timerInitStructure);
TIM_Cmd (TIM2, ENABLE);
}
#endif /* !__TARGET_HOST && __TARGET_MCU */
+45
View File
@@ -0,0 +1,45 @@
/* Copyright 2014 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.
*/
#ifndef MCU_HEADERS_H
#define MCU_HEADERS_H
#ifdef __TARGET_MCU
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#pragma GCC diagnostic ignored "-Wsign-conversion"
# ifdef __TARGET_MCU_STM32F4
# include "stm32f4xx_conf.h"
# include "stm32f4xx.h"
# define LED_GREEN 0
# define LED_ORANGE 1
# define LED_RED 2
# define LED_BLUE 3
# elif defined (__TARGET_MCU_STM32F3)
# include "stm32f30x_conf.h"
# include "stm32f30x.h"
# define LED_GREEN 0
# define LED_ORANGE 1
# define LED_RED 2
# define LED_BLUE 3
# else /* !__TARGET_MCU_STM32F4 && !__TARGET_MCU_STM32F3 */
# error "!__TARGET_MCU_STM32F4 && !__TARGET_MCU_STM32F3"
# endif /* !__TARGET_MCU_STM32F4 && !__TARGET_MCU_STM32F3 */
#pragma GCC diagnostic pop
#endif /* __TARGET_MCU */
#endif /* !MCU_HEADERS_H */
+103
View File
@@ -0,0 +1,103 @@
/**
* Runtime ABI for ARM architecture
*/
/**
* long long __aeabi_llsl(long long {r1, r0}, int {r2})
*/
.thumb_func
.global __aeabi_llsl
__aeabi_llsl:
// if (r2 >= 64) goto 2f;
cmp r2, #64
bhs 2f
// if (r2 < 32) goto 1f;
cmp r2, #32
blo 1f
// r1 = (r0 << (r2 - 32));
// r0 = 0;
sub r2, #32
mov r1, r0
lsl r1, r2
mov r0, #0
bx lr
1:
// r1 <<= r2;
lsl r1, r2
// r2 = 32 - r2;
rsb r2, r2, #32
// r1 |= (r0 >> r2);
mov r3, r0
lsr r3, r2
orr r1, r3
// r2 = 32 - r2;
rsb r2, r2, #32
// r0 <<= r2;
lsl r0, r2
bx lr
2:
// r1 = 0;
// r0 = 0;
mov r1, #0
mov r0, #0
bx lr
/**
* long long __aeabi_llsr(long long {r1, r0}, int {r2})
*/
.thumb_func
.global __aeabi_llsr
__aeabi_llsr:
// if (r2 >= 64) goto 2f;
cmp r2, #64
bhs 2f
// if (r2 < 32) goto 1f;
cmp r2, #32
blo 1f
// r0 = (r1 >> (r2 - 32));
// r1 = 0
sub r2, #32
mov r0, r1
lsr r0, r2
mov r1, #0
bx lr
1:
// r0 >>= r2
lsr r0, r2
// r0 |= r1 << (32 - r2)
mov r3, r1
rsb r2, r2, #32
lsl r3, r3, r2
orr r0, r3
rsb r2, r2, #32
// r1 >>= r2
lsr r1, r2
bx lr
2:
// r1 = 0;
// r0 = 0;
mov r1, #0
mov r0, #0
bx lr
@@ -0,0 +1,55 @@
/* Copyright 2014 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 "globals.h"
#include "jerry-libc.h"
/**
* Handle failed assertion
*/
void __noreturn
jerry_assert_fail (const char *assertion __unused, /**< assertion condition string */
const char *file __unused, /**< file name */
const char *function __unused, /**< function name */
const uint32_t line __unused) /** line */
{
__exit (-ERR_FAILED_INTERNAL_ASSERTION);
} /* jerry_assert_fail */
/**
* Handle execution of control path that should be unreachable
*/
void __noreturn
jerry_unreachable (const char *comment __unused, /**< comment to unreachable mark if exists,
NULL - otherwise */
const char *file __unused, /**< file name */
const char *function __unused, /**< function name */
const uint32_t line __unused) /**< line */
{
__exit (-ERR_FAILED_INTERNAL_ASSERTION);
} /* jerry_unreachable */
/**
* Handle unimplemented case execution
*/
void __noreturn
jerry_unimplemented (const char *comment __unused, /**< comment to unimplemented mark if exists,
NULL - otherwise */
const char *file __unused, /**< file name */
const char *function __unused, /**< function name */
const uint32_t line __unused) /**< line */
{
__exit (-ERR_UNIMPLEMENTED_CASE);
} /* jerry_unimplemented */
@@ -0,0 +1,59 @@
/* Copyright 2014 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.
*/
/**
* Jerry libc platform-specific functions stm32f4 implementation
*/
#include "jerry-libc.h"
#include <stdarg.h>
extern void __noreturn exit (int status);
/** Output of character. Writes the character c, cast to an unsigned char, to stdout. */
int
__putchar (int c)
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(c);
} /* __putchar */
/** exit - cause normal process termination */
void __noreturn
__exit (int status __unused)
{
/**
* TODO: Blink LEDs? status -> binary -> LEDs?
*/
while (true)
{
}
} /* __exit */
/**
* 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 */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(ptr, size, nmemb, stream);
} /* __fwrite */