Commit 50912e7f authored by Damien George's avatar Damien George
Browse files

py, unix, stmhal: Allow to compile with -Wshadow.

See issue #699.
parent 640e0b22
......@@ -84,7 +84,7 @@ void mp_arg_parse_all(mp_uint_t n_pos, const mp_obj_t *pos, mp_map_t *kws, mp_ui
pos_found++;
given_arg = pos[i];
} else {
mp_map_elem_t *kw = mp_map_lookup(kws, MP_OBJ_NEW_QSTR(allowed[i].qstr), MP_MAP_LOOKUP);
mp_map_elem_t *kw = mp_map_lookup(kws, MP_OBJ_NEW_QSTR(allowed[i].qst), MP_MAP_LOOKUP);
if (kw == NULL) {
if (allowed[i].flags & MP_ARG_REQUIRED) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
......@@ -92,7 +92,7 @@ void mp_arg_parse_all(mp_uint_t n_pos, const mp_obj_t *pos, mp_map_t *kws, mp_ui
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
"'%s' argument required",
qstr_str(allowed[i].qstr)));
qstr_str(allowed[i].qst)));
}
}
out_vals[i] = allowed[i].defval;
......
......@@ -1229,9 +1229,9 @@ STATIC void compile_decorated(compiler_t *comp, mp_parse_node_struct_t *pns) {
// compile the decorator function
compile_node(comp, name_nodes[0]);
for (int i = 1; i < name_len; i++) {
assert(MP_PARSE_NODE_IS_ID(name_nodes[i])); // should be
EMIT_ARG(load_attr, MP_PARSE_NODE_LEAF_ARG(name_nodes[i]));
for (int j = 1; j < name_len; j++) {
assert(MP_PARSE_NODE_IS_ID(name_nodes[j])); // should be
EMIT_ARG(load_attr, MP_PARSE_NODE_LEAF_ARG(name_nodes[j]));
}
// nodes[1] contains arguments to the decorator function, if any
......@@ -2778,9 +2778,9 @@ STATIC void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) {
// process rest of elements
for (int i = 0; i < n; i++) {
mp_parse_node_t pn = nodes[i];
bool is_key_value = MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_dictorsetmaker_item);
compile_node(comp, pn);
mp_parse_node_t pn_i = nodes[i];
bool is_key_value = MP_PARSE_NODE_IS_STRUCT_KIND(pn_i, PN_dictorsetmaker_item);
compile_node(comp, pn_i);
if (is_dict) {
if (!is_key_value) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting key:value for dictionary");
......@@ -3489,12 +3489,12 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
}
if (pass > MP_PASS_SCOPE) {
mp_int_t bytesize = MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[0]);
for (uint i = 1; i < n_args; i++) {
if (!MP_PARSE_NODE_IS_SMALL_INT(pn_arg[i])) {
for (uint j = 1; j < n_args; j++) {
if (!MP_PARSE_NODE_IS_SMALL_INT(pn_arg[j])) {
compile_syntax_error(comp, nodes[i], "inline assembler 'data' requires integer arguments");
return;
}
EMIT_INLINE_ASM_ARG(data, bytesize, MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[i]));
EMIT_INLINE_ASM_ARG(data, bytesize, MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[j]));
}
}
} else {
......
......@@ -215,6 +215,6 @@ mp_obj_t mp_module_get(qstr module_name) {
return el->value;
}
void mp_module_register(qstr qstr, mp_obj_t module) {
mp_map_lookup(&MP_STATE_VM(mp_loaded_modules_map), MP_OBJ_NEW_QSTR(qstr), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = module;
void mp_module_register(qstr qst, mp_obj_t module) {
mp_map_lookup(&MP_STATE_VM(mp_loaded_modules_map), MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = module;
}
......@@ -1243,15 +1243,15 @@ mp_obj_t mp_obj_str_format(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwa
break;
case 's': {
mp_uint_t len;
const char *s = mp_obj_str_get_data(arg, &len);
mp_uint_t slen;
const char *s = mp_obj_str_get_data(arg, &slen);
if (precision < 0) {
precision = len;
precision = slen;
}
if (len > (mp_uint_t)precision) {
len = precision;
if (slen > (mp_uint_t)precision) {
slen = precision;
}
pfenv_print_strn(&pfenv_vstr, s, len, flags, fill, width);
pfenv_print_strn(&pfenv_vstr, s, slen, flags, fill, width);
break;
}
......@@ -1379,9 +1379,9 @@ not_enough_args:
switch (*str) {
case 'c':
if (MP_OBJ_IS_STR(arg)) {
mp_uint_t len;
const char *s = mp_obj_str_get_data(arg, &len);
if (len != 1) {
mp_uint_t slen;
const char *s = mp_obj_str_get_data(arg, &slen);
if (slen != 1) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError,
"%%c requires int or char"));
}
......@@ -1425,14 +1425,14 @@ not_enough_args:
vstr_t *arg_vstr = vstr_new();
mp_obj_print_helper((void (*)(void*, const char*, ...))vstr_printf,
arg_vstr, arg, *str == 'r' ? PRINT_REPR : PRINT_STR);
uint len = vstr_len(arg_vstr);
uint vlen = vstr_len(arg_vstr);
if (prec < 0) {
prec = len;
prec = vlen;
}
if (len > (uint)prec) {
len = prec;
if (vlen > (uint)prec) {
vlen = prec;
}
pfenv_print_strn(&pfenv_vstr, vstr_str(arg_vstr), len, flags, ' ', width);
pfenv_print_strn(&pfenv_vstr, vstr_str(arg_vstr), vlen, flags, ' ', width);
vstr_free(arg_vstr);
break;
}
......
......@@ -273,12 +273,12 @@ STATIC void push_result_node(parser_t *parser, mp_parse_node_t pn) {
return;
}
if (parser->result_stack_top >= parser->result_stack_alloc) {
mp_parse_node_t *pn = m_renew_maybe(mp_parse_node_t, parser->result_stack, parser->result_stack_alloc, parser->result_stack_alloc + MICROPY_ALLOC_PARSE_RESULT_INC);
if (pn == NULL) {
mp_parse_node_t *stack = m_renew_maybe(mp_parse_node_t, parser->result_stack, parser->result_stack_alloc, parser->result_stack_alloc + MICROPY_ALLOC_PARSE_RESULT_INC);
if (stack == NULL) {
memory_error(parser);
return;
}
parser->result_stack = pn;
parser->result_stack = stack;
parser->result_stack_alloc += MICROPY_ALLOC_PARSE_RESULT_INC;
}
parser->result_stack[parser->result_stack_top++] = pn;
......
......@@ -104,67 +104,67 @@ void mp_deinit(void) {
#endif
}
mp_obj_t mp_load_const_int(qstr qstr) {
DEBUG_OP_printf("load '%s'\n", qstr_str(qstr));
mp_obj_t mp_load_const_int(qstr qst) {
DEBUG_OP_printf("load '%s'\n", qstr_str(qst));
mp_uint_t len;
const byte* data = qstr_data(qstr, &len);
const byte* data = qstr_data(qst, &len);
return mp_parse_num_integer((const char*)data, len, 0);
}
mp_obj_t mp_load_const_dec(qstr qstr) {
DEBUG_OP_printf("load '%s'\n", qstr_str(qstr));
mp_obj_t mp_load_const_dec(qstr qst) {
DEBUG_OP_printf("load '%s'\n", qstr_str(qst));
mp_uint_t len;
const byte* data = qstr_data(qstr, &len);
const byte* data = qstr_data(qst, &len);
return mp_parse_num_decimal((const char*)data, len, true, false);
}
mp_obj_t mp_load_const_str(qstr qstr) {
DEBUG_OP_printf("load '%s'\n", qstr_str(qstr));
return MP_OBJ_NEW_QSTR(qstr);
mp_obj_t mp_load_const_str(qstr qst) {
DEBUG_OP_printf("load '%s'\n", qstr_str(qst));
return MP_OBJ_NEW_QSTR(qst);
}
mp_obj_t mp_load_const_bytes(qstr qstr) {
DEBUG_OP_printf("load b'%s'\n", qstr_str(qstr));
mp_obj_t mp_load_const_bytes(qstr qst) {
DEBUG_OP_printf("load b'%s'\n", qstr_str(qst));
mp_uint_t len;
const byte *data = qstr_data(qstr, &len);
const byte *data = qstr_data(qst, &len);
return mp_obj_new_bytes(data, len);
}
mp_obj_t mp_load_name(qstr qstr) {
mp_obj_t mp_load_name(qstr qst) {
// logic: search locals, globals, builtins
DEBUG_OP_printf("load name %s\n", qstr_str(qstr));
DEBUG_OP_printf("load name %s\n", qstr_str(qst));
// If we're at the outer scope (locals == globals), dispatch to load_global right away
if (MP_STATE_CTX(dict_locals) != MP_STATE_CTX(dict_globals)) {
mp_map_elem_t *elem = mp_map_lookup(&MP_STATE_CTX(dict_locals)->map, MP_OBJ_NEW_QSTR(qstr), MP_MAP_LOOKUP);
mp_map_elem_t *elem = mp_map_lookup(&MP_STATE_CTX(dict_locals)->map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP);
if (elem != NULL) {
return elem->value;
}
}
return mp_load_global(qstr);
return mp_load_global(qst);
}
mp_obj_t mp_load_global(qstr qstr) {
mp_obj_t mp_load_global(qstr qst) {
// logic: search globals, builtins
DEBUG_OP_printf("load global %s\n", qstr_str(qstr));
mp_map_elem_t *elem = mp_map_lookup(&MP_STATE_CTX(dict_globals)->map, MP_OBJ_NEW_QSTR(qstr), MP_MAP_LOOKUP);
DEBUG_OP_printf("load global %s\n", qstr_str(qst));
mp_map_elem_t *elem = mp_map_lookup(&MP_STATE_CTX(dict_globals)->map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP);
if (elem == NULL) {
#if MICROPY_CAN_OVERRIDE_BUILTINS
if (MP_STATE_VM(mp_module_builtins_override_dict) != NULL) {
// lookup in additional dynamic table of builtins first
elem = mp_map_lookup(&MP_STATE_VM(mp_module_builtins_override_dict)->map, MP_OBJ_NEW_QSTR(qstr), MP_MAP_LOOKUP);
elem = mp_map_lookup(&MP_STATE_VM(mp_module_builtins_override_dict)->map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP);
if (elem != NULL) {
return elem->value;
}
}
#endif
elem = mp_map_lookup((mp_map_t*)&mp_module_builtins_globals.map, MP_OBJ_NEW_QSTR(qstr), MP_MAP_LOOKUP);
elem = mp_map_lookup((mp_map_t*)&mp_module_builtins_globals.map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP);
if (elem == NULL) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_NameError,
"name not defined"));
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_NameError,
"name '%s' is not defined", qstr_str(qstr)));
"name '%s' is not defined", qstr_str(qst)));
}
}
}
......@@ -185,26 +185,26 @@ mp_obj_t mp_load_build_class(void) {
return (mp_obj_t)&mp_builtin___build_class___obj;
}
void mp_store_name(qstr qstr, mp_obj_t obj) {
DEBUG_OP_printf("store name %s <- %p\n", qstr_str(qstr), obj);
mp_obj_dict_store(MP_STATE_CTX(dict_locals), MP_OBJ_NEW_QSTR(qstr), obj);
void mp_store_name(qstr qst, mp_obj_t obj) {
DEBUG_OP_printf("store name %s <- %p\n", qstr_str(qst), obj);
mp_obj_dict_store(MP_STATE_CTX(dict_locals), MP_OBJ_NEW_QSTR(qst), obj);
}
void mp_delete_name(qstr qstr) {
DEBUG_OP_printf("delete name %s\n", qstr_str(qstr));
// TODO convert KeyError to NameError if qstr not found
mp_obj_dict_delete(MP_STATE_CTX(dict_locals), MP_OBJ_NEW_QSTR(qstr));
void mp_delete_name(qstr qst) {
DEBUG_OP_printf("delete name %s\n", qstr_str(qst));
// TODO convert KeyError to NameError if qst not found
mp_obj_dict_delete(MP_STATE_CTX(dict_locals), MP_OBJ_NEW_QSTR(qst));
}
void mp_store_global(qstr qstr, mp_obj_t obj) {
DEBUG_OP_printf("store global %s <- %p\n", qstr_str(qstr), obj);
mp_obj_dict_store(MP_STATE_CTX(dict_globals), MP_OBJ_NEW_QSTR(qstr), obj);
void mp_store_global(qstr qst, mp_obj_t obj) {
DEBUG_OP_printf("store global %s <- %p\n", qstr_str(qst), obj);
mp_obj_dict_store(MP_STATE_CTX(dict_globals), MP_OBJ_NEW_QSTR(qst), obj);
}
void mp_delete_global(qstr qstr) {
DEBUG_OP_printf("delete global %s\n", qstr_str(qstr));
// TODO convert KeyError to NameError if qstr not found
mp_obj_dict_delete(MP_STATE_CTX(dict_globals), MP_OBJ_NEW_QSTR(qstr));
void mp_delete_global(qstr qst) {
DEBUG_OP_printf("delete global %s\n", qstr_str(qst));
// TODO convert KeyError to NameError if qst not found
mp_obj_dict_delete(MP_STATE_CTX(dict_globals), MP_OBJ_NEW_QSTR(qst));
}
mp_obj_t mp_unary_op(mp_uint_t op, mp_obj_t arg) {
......
......@@ -51,7 +51,7 @@ typedef union _mp_arg_val_t {
} mp_arg_val_t;
typedef struct _mp_arg_t {
qstr qstr;
qstr qst;
mp_uint_t flags;
mp_arg_val_t defval;
} mp_arg_t;
......@@ -70,21 +70,21 @@ static inline void mp_locals_set(mp_obj_dict_t *d) { MP_STATE_CTX(dict_locals) =
static inline mp_obj_dict_t *mp_globals_get(void) { return MP_STATE_CTX(dict_globals); }
static inline void mp_globals_set(mp_obj_dict_t *d) { MP_STATE_CTX(dict_globals) = d; }
mp_obj_t mp_load_name(qstr qstr);
mp_obj_t mp_load_global(qstr qstr);
mp_obj_t mp_load_name(qstr qst);
mp_obj_t mp_load_global(qstr qst);
mp_obj_t mp_load_build_class(void);
void mp_store_name(qstr qstr, mp_obj_t obj);
void mp_store_global(qstr qstr, mp_obj_t obj);
void mp_delete_name(qstr qstr);
void mp_delete_global(qstr qstr);
void mp_store_name(qstr qst, mp_obj_t obj);
void mp_store_global(qstr qst, mp_obj_t obj);
void mp_delete_name(qstr qst);
void mp_delete_global(qstr qst);
mp_obj_t mp_unary_op(mp_uint_t op, mp_obj_t arg);
mp_obj_t mp_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs);
mp_obj_t mp_load_const_int(qstr qstr);
mp_obj_t mp_load_const_dec(qstr qstr);
mp_obj_t mp_load_const_str(qstr qstr);
mp_obj_t mp_load_const_bytes(qstr qstr);
mp_obj_t mp_load_const_int(qstr qst);
mp_obj_t mp_load_const_dec(qstr qst);
mp_obj_t mp_load_const_str(qstr qst);
mp_obj_t mp_load_const_bytes(qstr qst);
mp_obj_t mp_call_function_0(mp_obj_t fun);
mp_obj_t mp_call_function_1(mp_obj_t fun, mp_obj_t arg);
......
......@@ -43,9 +43,9 @@ extern const qstr mp_binary_op_method_name[];
#define DECODE_ULABEL do { unum = (ip[0] | (ip[1] << 8)); ip += 2; } while (0)
#define DECODE_SLABEL do { unum = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; } while (0)
#define DECODE_QSTR { \
qstr = 0; \
qst = 0; \
do { \
qstr = (qstr << 7) + (*ip & 0x7f); \
qst = (qst << 7) + (*ip & 0x7f); \
} while ((*ip++ & 0x80) != 0); \
}
#define DECODE_PTR do { \
......@@ -131,7 +131,7 @@ void mp_bytecode_print(const void *descr, mp_uint_t n_total_args, const byte *ip
const byte *mp_bytecode_print_str(const byte *ip) {
mp_uint_t unum;
qstr qstr;
qstr qst;
switch (*ip++) {
case MP_BC_LOAD_CONST_FALSE:
......@@ -165,22 +165,22 @@ const byte *mp_bytecode_print_str(const byte *ip) {
case MP_BC_LOAD_CONST_INT:
DECODE_QSTR;
printf("LOAD_CONST_INT %s", qstr_str(qstr));
printf("LOAD_CONST_INT %s", qstr_str(qst));
break;
case MP_BC_LOAD_CONST_DEC:
DECODE_QSTR;
printf("LOAD_CONST_DEC %s", qstr_str(qstr));
printf("LOAD_CONST_DEC %s", qstr_str(qst));
break;
case MP_BC_LOAD_CONST_BYTES:
DECODE_QSTR;
printf("LOAD_CONST_BYTES %s", qstr_str(qstr));
printf("LOAD_CONST_BYTES %s", qstr_str(qst));
break;
case MP_BC_LOAD_CONST_STRING:
DECODE_QSTR;
printf("LOAD_CONST_STRING '%s'", qstr_str(qstr));
printf("LOAD_CONST_STRING '%s'", qstr_str(qst));
break;
case MP_BC_LOAD_CONST_OBJ:
......@@ -205,7 +205,7 @@ const byte *mp_bytecode_print_str(const byte *ip) {
case MP_BC_LOAD_NAME:
DECODE_QSTR;
printf("LOAD_NAME %s", qstr_str(qstr));
printf("LOAD_NAME %s", qstr_str(qst));
if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
printf(" (cache=%u)", *ip++);
}
......@@ -213,7 +213,7 @@ const byte *mp_bytecode_print_str(const byte *ip) {
case MP_BC_LOAD_GLOBAL:
DECODE_QSTR;
printf("LOAD_GLOBAL %s", qstr_str(qstr));
printf("LOAD_GLOBAL %s", qstr_str(qst));
if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
printf(" (cache=%u)", *ip++);
}
......@@ -221,7 +221,7 @@ const byte *mp_bytecode_print_str(const byte *ip) {
case MP_BC_LOAD_ATTR:
DECODE_QSTR;
printf("LOAD_ATTR %s", qstr_str(qstr));
printf("LOAD_ATTR %s", qstr_str(qst));
if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
printf(" (cache=%u)", *ip++);
}
......@@ -229,7 +229,7 @@ const byte *mp_bytecode_print_str(const byte *ip) {
case MP_BC_LOAD_METHOD:
DECODE_QSTR;
printf("LOAD_METHOD %s", qstr_str(qstr));
printf("LOAD_METHOD %s", qstr_str(qst));
break;
case MP_BC_LOAD_BUILD_CLASS:
......@@ -252,17 +252,17 @@ const byte *mp_bytecode_print_str(const byte *ip) {
case MP_BC_STORE_NAME:
DECODE_QSTR;
printf("STORE_NAME %s", qstr_str(qstr));
printf("STORE_NAME %s", qstr_str(qst));
break;
case MP_BC_STORE_GLOBAL:
DECODE_QSTR;
printf("STORE_GLOBAL %s", qstr_str(qstr));
printf("STORE_GLOBAL %s", qstr_str(qst));
break;
case MP_BC_STORE_ATTR:
DECODE_QSTR;
printf("STORE_ATTR %s", qstr_str(qstr));
printf("STORE_ATTR %s", qstr_str(qst));
if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
printf(" (cache=%u)", *ip++);
}
......@@ -284,7 +284,7 @@ const byte *mp_bytecode_print_str(const byte *ip) {
case MP_BC_DELETE_NAME:
DECODE_QSTR;
printf("DELETE_NAME %s", qstr_str(qstr));
printf("DELETE_NAME %s", qstr_str(qst));
break;
case MP_BC_DUP_TOP:
......@@ -502,12 +502,12 @@ const byte *mp_bytecode_print_str(const byte *ip) {
case MP_BC_IMPORT_NAME:
DECODE_QSTR;
printf("IMPORT_NAME '%s'", qstr_str(qstr));
printf("IMPORT_NAME '%s'", qstr_str(qst));
break;
case MP_BC_IMPORT_FROM:
DECODE_QSTR;
printf("IMPORT_FROM '%s'", qstr_str(qstr));
printf("IMPORT_FROM '%s'", qstr_str(qst));
break;
case MP_BC_IMPORT_STAR:
......
......@@ -240,7 +240,7 @@ STATIC mp_obj_t poll_poll(uint n_args, const mp_obj_t *args) {
if (n_ready > 0 || (timeout != -1 && HAL_GetTick() - start_tick >= timeout)) {
// one or more objects are ready, or we had a timeout
mp_obj_list_t *ret_list = mp_obj_new_list(n_ready, NULL);
mp_uint_t n_ready = 0;
n_ready = 0;
for (mp_uint_t i = 0; i < self->poll_map.alloc; ++i) {
if (!MP_MAP_SLOT_IS_FILLED(&self->poll_map, i)) {
continue;
......
......@@ -365,7 +365,7 @@ friendly_repl_reset:
while (mp_repl_continue_with_input(vstr_str(&line))) {
vstr_add_char(&line, '\n');
int ret = readline(&line, "... ");
ret = readline(&line, "... ");
if (ret == CHAR_CTRL_C) {
// cancel everything
stdout_tx_str("\r\n");
......@@ -380,7 +380,7 @@ friendly_repl_reset:
if (lex == NULL) {
printf("MemoryError\n");
} else {
int ret = parse_compile_execute(lex, MP_PARSE_SINGLE_INPUT, EXEC_FLAG_ALLOW_DEBUGGING | EXEC_FLAG_IS_REPL);
ret = parse_compile_execute(lex, MP_PARSE_SINGLE_INPUT, EXEC_FLAG_ALLOW_DEBUGGING | EXEC_FLAG_IS_REPL);
if (ret & PYEXEC_FORCED_EXIT) {
return ret;
}
......
......@@ -77,7 +77,7 @@
#include "storage.h"
extern void __fatal_error(const char*);
extern PCD_HandleTypeDef hpcd;
extern PCD_HandleTypeDef pcd_handle;
/******************************************************************************/
/* Cortex-M4 Processor Exceptions Handlers */
......@@ -205,7 +205,7 @@ void SysTick_Handler(void) {
#if defined(OTG_XX_IRQHandler)
void OTG_XX_IRQHandler(void) {
HAL_PCD_IRQHandler(&hpcd);
HAL_PCD_IRQHandler(&pcd_handle);
}
#endif
......@@ -217,7 +217,7 @@ void OTG_XX_IRQHandler(void) {
#if defined(OTG_XX_WKUP_IRQHandler)
void OTG_XX_WKUP_IRQHandler(void) {
if ((&hpcd)->Init.low_power_enable) {
if ((&pcd_handle)->Init.low_power_enable) {
/* Reset SLEEPDEEP bit of Cortex System Control Register */
SCB->SCR &= (uint32_t)~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
......@@ -244,7 +244,7 @@ void OTG_XX_WKUP_IRQHandler(void) {
{}
/* ungate PHY clock */
__HAL_PCD_UNGATE_PHYCLOCK((&hpcd));
__HAL_PCD_UNGATE_PHYCLOCK((&pcd_handle));
}
#ifdef USE_USB_FS
/* Clear EXTI pending Bit*/
......
......@@ -37,7 +37,7 @@
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
PCD_HandleTypeDef hpcd;
PCD_HandleTypeDef pcd_handle;
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
......@@ -331,62 +331,62 @@ USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev)
{
#ifdef USE_USB_FS
/*Set LL Driver parameters */
hpcd.Instance = USB_OTG_FS;
hpcd.Init.dev_endpoints = 4;
hpcd.Init.use_dedicated_ep1 = 0;
hpcd.Init.ep0_mps = 0x40;
hpcd.Init.dma_enable = 0;
hpcd.Init.low_power_enable = 0;
hpcd.Init.phy_itface = PCD_PHY_EMBEDDED;
hpcd.Init.Sof_enable = 0;
hpcd.Init.speed = PCD_SPEED_FULL;
pcd_handle.Instance = USB_OTG_FS;
pcd_handle.Init.dev_endpoints = 4;
pcd_handle.Init.use_dedicated_ep1 = 0;
pcd_handle.Init.ep0_mps = 0x40;
pcd_handle.Init.dma_enable = 0;
pcd_handle.Init.low_power_enable = 0;
pcd_handle.Init.phy_itface = PCD_PHY_EMBEDDED;
pcd_handle.Init.Sof_enable = 0;
pcd_handle.Init.speed = PCD_SPEED_FULL;
#if !defined(MICROPY_HW_USB_VBUS_DETECT_PIN)
hpcd.Init.vbus_sensing_enable = 0; // No VBUS Sensing on USB0
pcd_handle.Init.vbus_sensing_enable = 0; // No VBUS Sensing on USB0
#else
hpcd.Init.vbus_sensing_enable = 1;
pcd_handle.Init.vbus_sensing_enable = 1;
#endif
/* Link The driver to the stack */
hpcd.pData = pdev;
pdev->pData = &hpcd;
pcd_handle.pData = pdev;
pdev->pData = &pcd_handle;
/*Initialize LL Driver */
HAL_PCD_Init(&hpcd);
HAL_PCD_Init(&pcd_handle);
HAL_PCD_SetRxFiFo(&hpcd, 0x80);
HAL_PCD_SetTxFiFo(&hpcd, 0, 0x20);
HAL_PCD_SetTxFiFo(&hpcd, 1, 0x40);
HAL_PCD_SetTxFiFo(&hpcd, 2, 0x20);
HAL_PCD_SetTxFiFo(&hpcd, 3, 0x40);
HAL_PCD_SetRxFiFo(&pcd_handle, 0x80);
HAL_PCD_SetTxFiFo(&pcd_handle, 0, 0x20);
HAL_PCD_SetTxFiFo(&pcd_handle, 1, 0x40);
HAL_PCD_SetTxFiFo(&pcd_handle, 2, 0x20);
HAL_PCD_SetTxFiFo(&pcd_handle, 3, 0x40);
#endif
#ifdef USE_USB_HS
/*Set LL Driver parameters */
hpcd.Instance = USB_OTG_HS;
hpcd.Init.dev_endpoints = 6;
hpcd.Init.use_dedicated_ep1 = 0;
hpcd.Init.ep0_mps = 0x40;
pcd_handle.Instance = USB_OTG_HS;
pcd_handle.Init.dev_endpoints = 6;
pcd_handle.Init.use_dedicated_ep1 = 0;
pcd_handle.Init.ep0_mps = 0x40;
/* Be aware that enabling USB-DMA mode will result in data being sent only by
multiple of 4 packet sizes. This is due to the fact that USB-DMA does
not allow sending data from non word-aligned addresses.
For this specific application, it is advised to not enable this option
unless required. */
hpcd.Init.dma_enable = 0;
pcd_handle.Init.dma_enable = 0;
hpcd.Init.low_power_enable = 0;
hpcd.Init.phy_itface = PCD_PHY_ULPI;
hpcd.Init.Sof_enable = 0;
hpcd.Init.speed = PCD_SPEED_HIGH;
hpcd.Init.vbus_sensing_enable = 1;
pcd_handle.Init.low_power_enable = 0;
pcd_handle.Init.phy_itface = PCD_PHY_ULPI;
pcd_handle.Init.Sof_enable = 0;
pcd_handle.Init.speed = PCD_SPEED_HIGH;
pcd_handle.Init.vbus_sensing_enable = 1;
/* Link The driver to the stack */
hpcd.pData = pdev;
pdev->pData = &hpcd;
pcd_handle.pData = pdev;
pdev->pData = &pcd_handle;
/*Initialize LL Driver */
HAL_PCD_Init(&hpcd);
HAL_PCD_Init(&pcd_handle);
HAL_PCD_SetRxFiFo(&hpcd, 0x200);
HAL_PCD_SetTxFiFo(&hpcd, 0, 0x80);
HAL_PCD_SetTxFiFo(&hpcd, 1, 0x174);
HAL_PCD_SetRxFiFo(&pcd_handle, 0x200);
HAL_PCD_SetTxFiFo(&pcd_handle, 0, 0x80);
HAL_PCD_SetTxFiFo(&pcd_handle, 1, 0x174);
#endif
......
......@@ -354,6 +354,7 @@ int main(int argc, char **argv) {
mp_obj_t *path_items;