fixed led processing and wait
This commit is contained in:
+18
-6
@@ -15,9 +15,21 @@
|
|||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
static const char* generated_source = ""
|
static const char* generated_source = ""
|
||||||
"LEDToggle (12);\n"
|
"var tmp, a, b = 1, c = 2, d, e = 3, g = 4;\n"
|
||||||
"LEDToggle (13);\n"
|
"var count = 10000*10000;\n"
|
||||||
"LEDToggle (14);\n"
|
"for (var i = 0; i < count; i += 1)\n"
|
||||||
"LEDToggle (15);\n"
|
"{\n"
|
||||||
;
|
" tmp = b * c;\n"
|
||||||
|
" a = tmp + g;\n"
|
||||||
|
" d = tmp * e;\n"
|
||||||
|
"\n"
|
||||||
|
" if (i % 1000 == 0) \n"
|
||||||
|
" { \n"
|
||||||
|
" LEDToggle (12);\n"
|
||||||
|
" LEDToggle (13);\n"
|
||||||
|
" LEDToggle (14);\n"
|
||||||
|
" LEDToggle (15);\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
;
|
||||||
|
|||||||
@@ -410,6 +410,39 @@ opfunc_call_1 (OPCODE opdata __unused, struct __int_data *int_data)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!__strcmp ((const char*)str_value.str_p, "LEDToggle"))
|
if (!__strcmp ((const char*)str_value.str_p, "LEDToggle"))
|
||||||
|
{
|
||||||
|
ECMA_TRY_CATCH (cond_value, get_variable_value (int_data, opdata.data.call_1.arg1_lit_idx, false), ret_value);
|
||||||
|
JERRY_ASSERT(cond_value.value.value_type == ECMA_TYPE_NUMBER );
|
||||||
|
ecma_number_t * num_p = (ecma_number_t*)ecma_get_pointer(cond_value.value.value);
|
||||||
|
uint32_t int_num = (uint32_t)*num_p;
|
||||||
|
led_toggle (int_num);
|
||||||
|
ret_value = ecma_make_empty_completion_value ();
|
||||||
|
ECMA_FINALIZE (cond_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!__strcmp ((const char*)str_value.str_p, "LEDOn"))
|
||||||
|
{
|
||||||
|
ECMA_TRY_CATCH (cond_value, get_variable_value (int_data, opdata.data.call_1.arg1_lit_idx, false), ret_value);
|
||||||
|
JERRY_ASSERT(cond_value.value.value_type == ECMA_TYPE_NUMBER );
|
||||||
|
ecma_number_t * num_p = (ecma_number_t*)ecma_get_pointer(cond_value.value.value);
|
||||||
|
uint32_t int_num = (uint32_t)*num_p;
|
||||||
|
led_on (int_num);
|
||||||
|
ret_value = ecma_make_empty_completion_value ();
|
||||||
|
ECMA_FINALIZE (cond_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!__strcmp ((const char*)str_value.str_p, "LEDOff"))
|
||||||
|
{
|
||||||
|
ECMA_TRY_CATCH (cond_value, get_variable_value (int_data, opdata.data.call_1.arg1_lit_idx, false), ret_value);
|
||||||
|
JERRY_ASSERT(cond_value.value.value_type == ECMA_TYPE_NUMBER );
|
||||||
|
ecma_number_t * num_p = (ecma_number_t*)ecma_get_pointer(cond_value.value.value);
|
||||||
|
uint32_t int_num = (uint32_t)*num_p;
|
||||||
|
led_off (int_num);
|
||||||
|
ret_value = ecma_make_empty_completion_value ();
|
||||||
|
ECMA_FINALIZE (cond_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!__strcmp ((const char*)str_value.str_p, "LEDOnce"))
|
||||||
{
|
{
|
||||||
ECMA_TRY_CATCH (cond_value, get_variable_value (int_data, opdata.data.call_1.arg1_lit_idx, false), ret_value);
|
ECMA_TRY_CATCH (cond_value, get_variable_value (int_data, opdata.data.call_1.arg1_lit_idx, false), ret_value);
|
||||||
JERRY_ASSERT(cond_value.value.value_type == ECMA_TYPE_NUMBER );
|
JERRY_ASSERT(cond_value.value.value_type == ECMA_TYPE_NUMBER );
|
||||||
@@ -420,6 +453,17 @@ opfunc_call_1 (OPCODE opdata __unused, struct __int_data *int_data)
|
|||||||
ECMA_FINALIZE (cond_value);
|
ECMA_FINALIZE (cond_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!__strcmp ((const char*)str_value.str_p, "wait"))
|
||||||
|
{
|
||||||
|
ECMA_TRY_CATCH (cond_value, get_variable_value (int_data, opdata.data.call_1.arg1_lit_idx, false), ret_value);
|
||||||
|
JERRY_ASSERT(cond_value.value.value_type == ECMA_TYPE_NUMBER );
|
||||||
|
ecma_number_t * num_p = (ecma_number_t*)ecma_get_pointer(cond_value.value.value);
|
||||||
|
uint32_t int_num = (uint32_t)*num_p;
|
||||||
|
wait_ms (int_num);
|
||||||
|
ret_value = ecma_make_empty_completion_value ();
|
||||||
|
ECMA_FINALIZE (cond_value);
|
||||||
|
}
|
||||||
|
|
||||||
free_string_literal_copy (&str_value);
|
free_string_literal_copy (&str_value);
|
||||||
|
|
||||||
return ret_value;
|
return ret_value;
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ led_toggle (uint32_t led_id)
|
|||||||
|
|
||||||
|
|
||||||
#ifdef __TARGET_MCU
|
#ifdef __TARGET_MCU
|
||||||
init_led (led_id);
|
init_led (led_id);
|
||||||
|
|
||||||
GPIOD->ODR ^= (uint16_t) (1 << led_id);
|
GPIOD->ODR ^= (uint16_t) (1 << led_id);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,6 +54,7 @@ led_on (uint32_t led_id)
|
|||||||
init_led (led_id);
|
init_led (led_id);
|
||||||
|
|
||||||
GPIOD->BSRRH = (uint16_t) (1 << led_id);
|
GPIOD->BSRRH = (uint16_t) (1 << led_id);
|
||||||
|
GPIOD->BSRRL = (uint16_t) (1 << led_id);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,6 +68,7 @@ led_off (uint32_t led_id)
|
|||||||
#ifdef __TARGET_MCU
|
#ifdef __TARGET_MCU
|
||||||
init_led (led_id);
|
init_led (led_id);
|
||||||
|
|
||||||
|
GPIOD->BSRRL = (uint16_t) (1 << led_id);
|
||||||
GPIOD->BSRRH = (uint16_t) (1 << led_id);
|
GPIOD->BSRRH = (uint16_t) (1 << led_id);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -81,13 +83,11 @@ led_blink_once (uint32_t led_id)
|
|||||||
#ifdef __TARGET_MCU
|
#ifdef __TARGET_MCU
|
||||||
init_led (led_id);
|
init_led (led_id);
|
||||||
|
|
||||||
uint32_t dot = 600000 * 3;
|
uint32_t dot = 300000;
|
||||||
|
|
||||||
GPIOD->BSRRL = (uint16_t) (1 << led_id);
|
GPIOD->BSRRL = (uint16_t) (1 << led_id);
|
||||||
wait_ms (dot);
|
wait_ms (dot);
|
||||||
|
|
||||||
GPIOD->BSRRH = (uint16_t) (1 << led_id);
|
GPIOD->BSRRH = (uint16_t) (1 << led_id);
|
||||||
wait_ms (dot);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user