atmel-samd: Add user initiated safe mode and rework board.c for
board specific functionality. Fixes #155
This commit is contained in:
parent
c7efd2cae9
commit
3e23464b1e
@ -210,7 +210,7 @@ SRC_C = \
|
||||
asf/sam0/utils/cmsis/samd21/source/gcc/startup_samd21.c \
|
||||
asf/sam0/utils/cmsis/samd21/source/system_samd21.c \
|
||||
asf/sam0/utils/syscalls/gcc/syscalls.c \
|
||||
boards/$(BOARD)/init.c \
|
||||
boards/$(BOARD)/board.c \
|
||||
boards/$(BOARD)/pins.c \
|
||||
freetouch/adafruit_ptc.c \
|
||||
lib/fatfs/ff.c \
|
||||
|
46
atmel-samd/boards/arduino_zero/board.c
Normal file
46
atmel-samd/boards/arduino_zero/board.c
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* 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
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "boards/board.h"
|
||||
#include "asf/sam0/drivers/port/port.h"
|
||||
#include "mpconfigboard.h"
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
struct port_config pin_conf;
|
||||
port_get_config_defaults(&pin_conf);
|
||||
|
||||
pin_conf.direction = PORT_PIN_DIR_OUTPUT;
|
||||
port_pin_set_config(MICROPY_HW_LED_TX, &pin_conf);
|
||||
port_pin_set_output_level(MICROPY_HW_LED_TX, true);
|
||||
|
||||
port_pin_set_config(MICROPY_HW_LED_RX, &pin_conf);
|
||||
port_pin_set_output_level(MICROPY_HW_LED_RX, true);
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
return false;
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief User board initialization template
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "conf_board.h"
|
||||
#include "mpconfigboard.h"
|
||||
#include "asf/sam0/drivers/sercom/usart/usart.h"
|
||||
#include "asf/sam0/drivers/port/port.h"
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
/* This function is meant to contain board-specific initialization code
|
||||
* for, e.g., the I/O pins. The initialization can rely on application-
|
||||
* specific board configuration, found in conf_board.h.
|
||||
*/
|
||||
struct port_config pin_conf;
|
||||
port_get_config_defaults(&pin_conf);
|
||||
|
||||
pin_conf.direction = PORT_PIN_DIR_OUTPUT;
|
||||
port_pin_set_config(MICROPY_HW_LED_TX, &pin_conf);
|
||||
port_pin_set_output_level(MICROPY_HW_LED_TX, true);
|
||||
|
||||
port_pin_set_config(MICROPY_HW_LED_RX, &pin_conf);
|
||||
port_pin_set_output_level(MICROPY_HW_LED_RX, true);
|
||||
}
|
42
atmel-samd/boards/board.h
Normal file
42
atmel-samd/boards/board.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* 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
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// This file defines board specific functions.
|
||||
|
||||
#ifndef __MICROPY_INCLUDED_ATMEL_SAMD_BOARDS_BOARD_H__
|
||||
#define __MICROPY_INCLUDED_ATMEL_SAMD_BOARDS_BOARD_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
// Initializes board related state once on start up.
|
||||
void board_init(void);
|
||||
|
||||
// Returns true if the user initiates safe mode in a board specific way.
|
||||
// Also add BOARD_USER_SAFE_MODE in mpconfigboard.h to explain the board specific
|
||||
// way.
|
||||
bool board_requests_safe_mode(void);
|
||||
|
||||
#endif // __MICROPY_INCLUDED_ATMEL_SAMD_BOARDS_BOARD_H__
|
49
atmel-samd/boards/circuitplayground_express/board.c
Normal file
49
atmel-samd/boards/circuitplayground_express/board.c
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* 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
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "boards/board.h"
|
||||
#include "asf/sam0/drivers/port/port.h"
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
// Check the status of the two buttons on CircuitPlayground Express. If both are
|
||||
// pressed, then boot into user safe mode.
|
||||
bool board_requests_safe_mode(void) {
|
||||
struct port_config pin_conf;
|
||||
port_get_config_defaults(&pin_conf);
|
||||
pin_conf.direction = PORT_PIN_DIR_INPUT;
|
||||
pin_conf.input_pull = PORT_PIN_PULL_DOWN;
|
||||
port_pin_set_config(PIN_PA14, &pin_conf);
|
||||
port_pin_set_config(PIN_PA28, &pin_conf);
|
||||
bool safe_mode = port_pin_get_input_level(PIN_PA14) &&
|
||||
port_pin_get_input_level(PIN_PA28);
|
||||
reset_pin(PIN_PA14);
|
||||
reset_pin(PIN_PA28);
|
||||
return safe_mode;
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief User board initialization template
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "conf_board.h"
|
||||
#include "mpconfigboard.h"
|
||||
#include "asf/sam0/drivers/port/port.h"
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
}
|
@ -39,3 +39,6 @@
|
||||
#include "flash_S25FL216K.h"
|
||||
|
||||
#define CALIBRATE_CRYSTALLESS 1
|
||||
|
||||
// Explanation of how a user got into safe mode.
|
||||
#define BOARD_USER_SAFE_MODE "pressing both buttons at start up"
|
||||
|
35
atmel-samd/boards/feather_m0_adalogger/board.c
Normal file
35
atmel-samd/boards/feather_m0_adalogger/board.c
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* 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
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "boards/board.h"
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
return false;
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief User board initialization template
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "conf_board.h"
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
/* This function is meant to contain board-specific initialization code
|
||||
* for, e.g., the I/O pins. The initialization can rely on application-
|
||||
* specific board configuration, found in conf_board.h.
|
||||
*/
|
||||
}
|
35
atmel-samd/boards/feather_m0_basic/board.c
Normal file
35
atmel-samd/boards/feather_m0_basic/board.c
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* 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
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "boards/board.h"
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
return false;
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief User board initialization template
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "conf_board.h"
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
/* This function is meant to contain board-specific initialization code
|
||||
* for, e.g., the I/O pins. The initialization can rely on application-
|
||||
* specific board configuration, found in conf_board.h.
|
||||
*/
|
||||
}
|
35
atmel-samd/boards/feather_m0_express/board.c
Normal file
35
atmel-samd/boards/feather_m0_express/board.c
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* 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
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "boards/board.h"
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
return false;
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief User board initialization template
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "conf_board.h"
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
/* This function is meant to contain board-specific initialization code
|
||||
* for, e.g., the I/O pins. The initialization can rely on application-
|
||||
* specific board configuration, found in conf_board.h.
|
||||
*/
|
||||
}
|
35
atmel-samd/boards/gemma_m0/board.c
Normal file
35
atmel-samd/boards/gemma_m0/board.c
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* 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
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "boards/board.h"
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
return false;
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief User board initialization template
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "conf_board.h"
|
||||
#include "mpconfigboard.h"
|
||||
#include "asf/sam0/drivers/port/port.h"
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
}
|
46
atmel-samd/boards/metro_m0_express/board.c
Normal file
46
atmel-samd/boards/metro_m0_express/board.c
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* 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
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "boards/board.h"
|
||||
#include "asf/sam0/drivers/port/port.h"
|
||||
#include "mpconfigboard.h"
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
struct port_config pin_conf;
|
||||
port_get_config_defaults(&pin_conf);
|
||||
|
||||
pin_conf.direction = PORT_PIN_DIR_OUTPUT;
|
||||
port_pin_set_config(MICROPY_HW_LED_TX, &pin_conf);
|
||||
port_pin_set_output_level(MICROPY_HW_LED_TX, true);
|
||||
|
||||
port_pin_set_config(MICROPY_HW_LED_RX, &pin_conf);
|
||||
port_pin_set_output_level(MICROPY_HW_LED_RX, true);
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
return false;
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief User board initialization template
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "conf_board.h"
|
||||
#include "mpconfigboard.h"
|
||||
#include "asf/sam0/drivers/port/port.h"
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
/* This function is meant to contain board-specific initialization code
|
||||
* for, e.g., the I/O pins. The initialization can rely on application-
|
||||
* specific board configuration, found in conf_board.h.
|
||||
*/
|
||||
struct port_config pin_conf;
|
||||
port_get_config_defaults(&pin_conf);
|
||||
|
||||
pin_conf.direction = PORT_PIN_DIR_OUTPUT;
|
||||
port_pin_set_config(MICROPY_HW_LED_TX, &pin_conf);
|
||||
port_pin_set_output_level(MICROPY_HW_LED_TX, true);
|
||||
|
||||
port_pin_set_config(MICROPY_HW_LED_RX, &pin_conf);
|
||||
port_pin_set_output_level(MICROPY_HW_LED_RX, true);
|
||||
}
|
35
atmel-samd/boards/trinket_m0/board.c
Normal file
35
atmel-samd/boards/trinket_m0/board.c
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* 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
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "boards/board.h"
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
return false;
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief User board initialization template
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "conf_board.h"
|
||||
#include "mpconfigboard.h"
|
||||
#include "asf/sam0/drivers/port/port.h"
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
}
|
@ -24,6 +24,8 @@
|
||||
#include "asf/sam0/drivers/system/system.h"
|
||||
#include <board.h>
|
||||
|
||||
#include "boards/board.h"
|
||||
|
||||
#include "common-hal/analogio/AnalogIn.h"
|
||||
#include "common-hal/audioio/AudioOut.h"
|
||||
#include "common-hal/pulseio/PulseIn.h"
|
||||
@ -51,6 +53,7 @@ typedef enum {
|
||||
NO_SAFE_MODE = 0,
|
||||
BROWNOUT,
|
||||
HARD_CRASH,
|
||||
USER_SAFE_MODE,
|
||||
} safe_mode_t;
|
||||
|
||||
void do_str(const char *src, mp_parse_input_kind_t input_kind) {
|
||||
@ -331,6 +334,16 @@ bool start_mp(safe_mode_t safe_mode) {
|
||||
mp_hal_stdout_tx_str("Auto-reload is off.\r\n");
|
||||
}
|
||||
}
|
||||
// Output a user safe mode string if its set.
|
||||
#ifdef BOARD_USER_SAFE_MODE
|
||||
if (safe_mode == USER_SAFE_MODE) {
|
||||
mp_hal_stdout_tx_str("\r\nYou requested starting safe mode by ");
|
||||
mp_hal_stdout_tx_str(BOARD_USER_SAFE_MODE);
|
||||
mp_hal_stdout_tx_str(".\r\nTo exit, please reset the board without ");
|
||||
mp_hal_stdout_tx_str(BOARD_USER_SAFE_MODE);
|
||||
mp_hal_stdout_tx_str(".\r\n");
|
||||
} else
|
||||
#endif
|
||||
if (safe_mode != NO_SAFE_MODE) {
|
||||
mp_hal_stdout_tx_str("\r\nYou are running in safe mode which means something really bad happened.\r\n");
|
||||
if (safe_mode == HARD_CRASH) {
|
||||
@ -555,6 +568,10 @@ safe_mode_t samd21_init(void) {
|
||||
return BROWNOUT;
|
||||
}
|
||||
|
||||
if (board_requests_safe_mode()) {
|
||||
return USER_SAFE_MODE;
|
||||
}
|
||||
|
||||
return NO_SAFE_MODE;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user