atmel-samd: Rename auto-reset to auto-reload to reduce confusion with physical reset buttons.

crypto-aes
Scott Shawcroft 6 years ago
parent e0f931afd3
commit 7672bf7736

@ -180,7 +180,7 @@ SRC_ASF = $(addprefix asf/sam0/,\
SRC_C = \
access_vfs.c \
autoreset.c \
autoreload.c \
builtin_open.c \
fatfs_port.c \
main.c \

@ -27,7 +27,7 @@
#include <string.h>
#include "access_vfs.h"
#include "autoreset.h"
#include "autoreload.h"
#include "asf/common/services/usb/class/msc/device/udi_msc.h"
#include "extmod/fsusermount.h"
@ -184,6 +184,6 @@ Ctrl_status vfs_usb_write_10(uint32_t addr, volatile uint16_t nb_sector)
}
}
}
autoreset_start();
autoreload_start();
return CTRL_GOOD;
}

@ -24,44 +24,44 @@
* THE SOFTWARE.
*/
#include "autoreset.h"
#include "autoreload.h"
#include "asf/sam0/drivers/tc/tc_interrupt.h"
#include "lib/utils/interrupt_char.h"
#include "py/mphal.h"
volatile uint32_t autoreset_delay_ms = 0;
bool autoreset_enabled = false;
volatile bool reset_next_character = false;
volatile uint32_t autoreload_delay_ms = 0;
bool autoreload_enabled = false;
volatile bool reload_next_character = false;
inline void autoreset_tick() {
if (autoreset_delay_ms == 0) {
inline void autoreload_tick() {
if (autoreload_delay_ms == 0) {
return;
}
if (autoreset_delay_ms == 1 && autoreset_enabled && !reset_next_character) {
if (autoreload_delay_ms == 1 && autoreload_enabled && !reload_next_character) {
mp_keyboard_interrupt();
reset_next_character = true;
reload_next_character = true;
}
autoreset_delay_ms--;
autoreload_delay_ms--;
}
void autoreset_enable() {
autoreset_enabled = true;
reset_next_character = false;
void autoreload_enable() {
autoreload_enabled = true;
reload_next_character = false;
}
void autoreset_disable() {
autoreset_enabled = false;
void autoreload_disable() {
autoreload_enabled = false;
}
inline bool autoreset_is_enabled() {
return autoreset_enabled;
inline bool autoreload_is_enabled() {
return autoreload_enabled;
}
void autoreset_start() {
autoreset_delay_ms = AUTORESET_DELAY_MS;
void autoreload_start() {
autoreload_delay_ms = CIRCUITPY_AUTORELOAD_DELAY_MS;
}
void autoreset_stop() {
autoreset_delay_ms = 0;
void autoreload_stop() {
autoreload_delay_ms = 0;
}

@ -24,19 +24,19 @@
* THE SOFTWARE.
*/
#ifndef __MICROPY_INCLUDED_ATMEL_SAMD_AUTORESET_H__
#define __MICROPY_INCLUDED_ATMEL_SAMD_AUTORESET_H__
#ifndef __MICROPY_INCLUDED_ATMEL_SAMD_AUTORELOAD_H__
#define __MICROPY_INCLUDED_ATMEL_SAMD_AUTORELOAD_H__
#include <stdbool.h>
extern volatile bool reset_next_character;
extern volatile bool reload_next_character;
void autoreset_tick(void);
void autoreload_tick(void);
void autoreset_start(void);
void autoreset_stop(void);
void autoreset_enable(void);
void autoreset_disable(void);
bool autoreset_is_enabled(void);
void autoreload_start(void);
void autoreload_stop(void);
void autoreload_enable(void);
void autoreload_disable(void);
bool autoreload_is_enabled(void);
#endif // __MICROPY_INCLUDED_ATMEL_SAMD_AUTORESET_H__
#endif // __MICROPY_INCLUDED_ATMEL_SAMD_AUTORELOAD_H__

@ -25,7 +25,7 @@
*/
#include "py/obj.h"
#include "py/runtime.h"
#include "autoreset.h"
#include "autoreload.h"
//| :mod:`samd` --- SAMD implementation settings
//| =================================================
@ -35,31 +35,31 @@
//| :platform: SAMD21
//|
//| .. method:: enable_autoreset()
//| .. method:: enable_autoreload()
//|
//| Enable autoreset based on USB file write activity.
//| Enable autoreload based on USB file write activity.
//|
STATIC mp_obj_t samd_enable_autoreset(void) {
autoreset_enable();
STATIC mp_obj_t samd_enable_autoreload(void) {
autoreload_enable();
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_0(samd_enable_autoreset_obj, samd_enable_autoreset);
MP_DEFINE_CONST_FUN_OBJ_0(samd_enable_autoreload_obj, samd_enable_autoreload);
//| .. method:: disable_autoreset()
//| .. method:: disable_autoreload()
//|
//| Disable autoreset based on USB file write activity until the next reset
//| or until `enable_autoreset` is called.
//| Disable autoreload based on USB file write activity until the next reload
//| or until `enable_autoreload` is called.
//|
STATIC mp_obj_t samd_disable_autoreset(void) {
autoreset_disable();
STATIC mp_obj_t samd_disable_autoreload(void) {
autoreload_disable();
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_0(samd_disable_autoreset_obj, samd_disable_autoreset);
MP_DEFINE_CONST_FUN_OBJ_0(samd_disable_autoreload_obj, samd_disable_autoreload);
STATIC const mp_rom_map_elem_t samd_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_samd) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_enable_autoreset), MP_ROM_PTR(&samd_enable_autoreset_obj)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_disable_autoreset), MP_ROM_PTR(&samd_disable_autoreset_obj)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_enable_autoreload), MP_ROM_PTR(&samd_enable_autoreload_obj)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_disable_autoreload), MP_ROM_PTR(&samd_disable_autoreload_obj)},
};
STATIC MP_DEFINE_CONST_DICT(samd_module_globals, samd_module_globals_table);

@ -10,8 +10,6 @@
#define MICROPY_PORT_A (PORT_PA24 | PORT_PA25 | PORT_PA27)
#define MICROPY_PORT_B (PORT_PB03)
#define AUTORESET_DELAY_MS 500
#include "internal_flash.h"
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)

@ -32,8 +32,6 @@
#define SPEAKER_ENABLE_PIN (&pin_PA30)
#define AUTORESET_DELAY_MS 500
#include "spi_flash.h"
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000)

@ -6,8 +6,6 @@
#define MICROPY_HW_BOARD_NAME "Adafruit Feather M0 Adalogger"
#define MICROPY_HW_MCU_NAME "samd21g18"
#define AUTORESET_DELAY_MS 500
#define MICROPY_PORT_A (PORT_PA24 | PORT_PA25)
#define MICROPY_PORT_B (0)

@ -6,8 +6,6 @@
#define MICROPY_HW_BOARD_NAME "Adafruit Feather M0 Basic"
#define MICROPY_HW_MCU_NAME "samd21g18"
#define AUTORESET_DELAY_MS 500
#define MICROPY_PORT_A (PORT_PA24 | PORT_PA25)
#define MICROPY_PORT_B (0)

@ -21,8 +21,6 @@
#define MICROPY_PORT_A (PORT_PA06 | PORT_PA08 | PORT_PA09 | PORT_PA14 | PORT_PA13 | PORT_PA14 | PORT_PA24 | PORT_PA25)
#define MICROPY_PORT_B ( 0 )
#define AUTORESET_DELAY_MS 500
#include "spi_flash.h"
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000)

@ -11,8 +11,6 @@
#define MICROPY_PORT_A (PORT_PA04 | PORT_PA05 | PORT_PA24 | PORT_PA25)
#define MICROPY_PORT_B (0)
#define AUTORESET_DELAY_MS 500
#include "internal_flash.h"
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)

@ -23,8 +23,6 @@
#define MICROPY_PORT_A (PORT_PA13 |PORT_PA24 | PORT_PA25 | PORT_PA27 | PORT_PA30 | PORT_PA31)
#define MICROPY_PORT_B (PORT_PB03 | PORT_PB22 | PORT_PB23)
#define AUTORESET_DELAY_MS 500
#include "spi_flash.h"
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000)

@ -10,8 +10,6 @@
#define MICROPY_PORT_A (PORT_PA04 | PORT_PA05 | PORT_PA24 | PORT_PA25)
#define MICROPY_PORT_B (0)
#define AUTORESET_DELAY_MS 500
#include "internal_flash.h"
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)

@ -38,7 +38,7 @@
#define INTERNAL_CIRCUITPY_CONFIG_START_ADDR (0x00040000 - 0x010000 - 0x100)
#endif
#include "autoreset.h"
#include "autoreload.h"
#include "flash_api.h"
#include "mpconfigboard.h"
#include "rgb_led_status.h"
@ -84,7 +84,7 @@ void init_flash_fs(void) {
FRESULT res = f_mount(&vfs->fatfs, vfs->str, 1);
if (res == FR_NO_FILESYSTEM) {
// no filesystem, or asked to reset it, so create a fresh one
// no filesystem so create a fresh one
// We are before USB initializes so temporarily undo the USB_WRITEABLE
// requirement.
@ -120,8 +120,8 @@ static char heap[16384];
void reset_mp(void) {
reset_status_led();
new_status_color(0x8f008f);
autoreset_stop();
autoreset_enable();
autoreload_stop();
autoreload_enable();
// Sync the file systems in case any used RAM from the GC to cache. As soon
// as we re-init the GC all bets are off on the cache.
@ -245,10 +245,10 @@ bool maybe_run(const char* filename, pyexec_result_t* exec_result) {
bool start_mp(void) {
bool cdc_enabled_at_start = mp_cdc_enabled;
#ifdef AUTORESET_DELAY_MS
#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS
if (cdc_enabled_at_start) {
mp_hal_stdout_tx_str("\r\n");
mp_hal_stdout_tx_str("Auto-soft reset is on. Simply save files over USB to run them or enter REPL to disable.\r\n");
mp_hal_stdout_tx_str("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\r\n");
}
#endif
@ -269,7 +269,7 @@ bool start_mp(void) {
reset_status_led();
if (result.return_code & PYEXEC_FORCED_EXIT) {
return reset_next_character;
return reload_next_character;
}
// If not is USB mode then do not skip the repl.
@ -309,11 +309,11 @@ bool start_mp(void) {
#ifdef MICROPY_VM_HOOK_LOOP
MICROPY_VM_HOOK_LOOP
#endif
if (reset_next_character) {
if (reload_next_character) {
return true;
}
if (usb_rx_count > 0) {
// Skip REPL if reset was requested.
// Skip REPL if reload was requested.
return receive_usb() == CHAR_CTRL_D;
}
@ -322,12 +322,12 @@ bool start_mp(void) {
mp_hal_stdout_tx_str("\r\n\r\n");
}
if (!cdc_enabled_at_start && autoreset_is_enabled()) {
mp_hal_stdout_tx_str("Auto-soft reset is on. Simply save files over USB to run them or enter REPL to disable.\r\n");
if (!cdc_enabled_at_start && autoreload_is_enabled()) {
mp_hal_stdout_tx_str("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\r\n");
} else {
mp_hal_stdout_tx_str("Auto-soft reset is off.\r\n");
mp_hal_stdout_tx_str("Auto-reload is off.\r\n");
}
mp_hal_stdout_tx_str("Press any key to enter the REPL. Use CTRL-D to soft reset.\r\n");
mp_hal_stdout_tx_str("Press any key to enter the REPL. Use CTRL-D to reload.\r\n");
}
if (cdc_enabled_before && !mp_cdc_enabled) {
cdc_enabled_at_start = false;
@ -529,13 +529,13 @@ int main(void) {
// Main script is finished, so now go into REPL mode.
// The REPL mode can change, or it can request a soft reset.
// The REPL mode can change, or it can request a reload.
int exit_code = PYEXEC_FORCED_EXIT;
bool skip_repl = true;
bool first_run = true;
for (;;) {
if (!skip_repl) {
autoreset_disable();
autoreload_disable();
new_status_color(REPL_RUNNING);
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
exit_code = pyexec_raw_repl();

@ -203,4 +203,6 @@ bool udi_msc_process_trans(void);
#define MICROPY_VM_HOOK_LOOP udi_msc_process_trans();
#define MICROPY_VM_HOOK_RETURN udi_msc_process_trans();
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
#endif // __INCLUDED_MPCONFIGPORT_H

@ -1,6 +1,6 @@
#include <string.h>
#include "autoreset.h"
#include "autoreload.h"
#include "compiler.h"
#include "asf/common/services/sleepmgr/sleepmgr.h"
#include "asf/common/services/usb/class/cdc/device/udi_cdc.h"
@ -131,8 +131,8 @@ int receive_usb(void) {
return 0;
}
// Disable autoreset if someone is using the repl.
autoreset_disable();
// Disable autoreload if someone is using the repl.
autoreload_disable();
// Copy from head.
cpu_irq_disable();
@ -157,7 +157,7 @@ int mp_hal_stdin_rx_chr(void) {
MICROPY_VM_HOOK_LOOP
#endif
#ifdef USB_REPL
if (reset_next_character) {
if (reload_next_character) {
return CHAR_CTRL_D;
}
if (usb_rx_count > 0) {
@ -228,7 +228,7 @@ void mp_hal_delay_ms(mp_uint_t delay) {
#ifdef MICROPY_VM_HOOK_LOOP
MICROPY_VM_HOOK_LOOP
#endif
// Check to see if we've been CTRL-Ced by autoreset or the user.
// Check to see if we've been CTRL-Ced by autoreload or the user.
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))) {
break;
}

@ -1,4 +1,4 @@
#include "autoreset.h"
#include "autoreload.h"
#include "tick.h"
@ -14,8 +14,8 @@ static void ms_tick(struct tc_module *const module_inst) {
// (every millisecond).
ticks_ms += 1;
#ifdef AUTORESET_DELAY_MS
autoreset_tick();
#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS
autoreload_tick();
#endif
}

@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
* Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

Loading…
Cancel
Save