enhance board management
This commit is contained in:
parent
44967695a4
commit
bcbd3fa089
38
Makefile
38
Makefile
@ -80,23 +80,16 @@ remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-ou
|
|||||||
#*********************************
|
#*********************************
|
||||||
# Select the board to build
|
# Select the board to build
|
||||||
#*********************************
|
#*********************************
|
||||||
BOARD_LIST = $(sort $(subst .h,,$(subst src/boards/,,$(wildcard src/boards/*.h))))
|
BOARD_LIST = $(sort $(subst .h,,$(subst src/boards/,,$(wildcard src/boards/*))))
|
||||||
|
|
||||||
NRF52832_BOARDLIST = feather_nrf52832
|
NRF52832_BOARDLIST = feather_nrf52832
|
||||||
IS_52832 = $(filter $(BOARD),$(NRF52832_BOARDLIST))
|
IS_52832 = $(filter $(BOARD),$(NRF52832_BOARDLIST))
|
||||||
|
|
||||||
ifeq ($(filter $(MAKECMDGOALS),all-board help),)
|
|
||||||
ifeq ($(BOARD),)
|
|
||||||
$(info You must provide a BOARD parameter with 'BOARD=')
|
|
||||||
$(info Supported boards are: $(BOARD_LIST))
|
|
||||||
$(info Run 'make help' for usage)
|
|
||||||
$(error BOARD not defined)
|
|
||||||
else
|
|
||||||
ifeq ($(filter $(BOARD),$(BOARD_LIST)),)
|
ifeq ($(filter $(BOARD),$(BOARD_LIST)),)
|
||||||
|
$(info You must provide a BOARD parameter with 'BOARD='. Supported boards are:)
|
||||||
|
$(info $(BOARD_LIST))
|
||||||
$(error Invalid BOARD specified)
|
$(error Invalid BOARD specified)
|
||||||
endif
|
endif
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
BUILD = _build-$(BOARD)
|
BUILD = _build-$(BOARD)
|
||||||
|
|
||||||
@ -267,7 +260,7 @@ CFLAGS += -DDFU_APP_DATA_RESERVED=7*4096
|
|||||||
|
|
||||||
CFLAGS += -DUF2_VERSION='"$(GIT_VERSION) $(GIT_SUBMODULE_VERSIONS) $(SD_NAME) $(SD_VERSION)"'
|
CFLAGS += -DUF2_VERSION='"$(GIT_VERSION) $(GIT_SUBMODULE_VERSIONS) $(SD_NAME) $(SD_VERSION)"'
|
||||||
CFLAGS += -DBOARD_$(shell echo $(BOARD) | tr '[:lower:]' '[:upper:]')
|
CFLAGS += -DBOARD_$(shell echo $(BOARD) | tr '[:lower:]' '[:upper:]')
|
||||||
CFLAGS += -DBOARD_HEADER_FILE='"$(BOARD).h"'
|
CFLAGS += -DBOARD_HEADER_FILE='"$(BOARD)/board.h"'
|
||||||
|
|
||||||
ifneq ($(IS_52832),)
|
ifneq ($(IS_52832),)
|
||||||
CFLAGS += -DNRF52
|
CFLAGS += -DNRF52
|
||||||
@ -348,29 +341,6 @@ endif
|
|||||||
# default target to build
|
# default target to build
|
||||||
all: $(BUILD)/$(OUTPUT_FILENAME)-nosd.out size
|
all: $(BUILD)/$(OUTPUT_FILENAME)-nosd.out size
|
||||||
|
|
||||||
# Rule using BOARD_LIST, nl is newline
|
|
||||||
define nl
|
|
||||||
|
|
||||||
|
|
||||||
endef
|
|
||||||
|
|
||||||
_make_board = $(MAKE) -s -f $(MAKEFILE_LIST) -e BOARD=$1 $2 $(nl)
|
|
||||||
_make_all_board = $(foreach b,$(BOARD_LIST), $(call _make_board,$b,$1))
|
|
||||||
|
|
||||||
# build all the boards
|
|
||||||
all-board:
|
|
||||||
$(call _make_all_board,clean all)
|
|
||||||
|
|
||||||
help:
|
|
||||||
@echo To compile and build the current code for a board
|
|
||||||
@echo $$ make BOARD=feather_nrf52840_express all
|
|
||||||
@echo
|
|
||||||
@echo To flash current code using Jlink
|
|
||||||
@echo $$ make BOARD=feather_nrf52840_express flash
|
|
||||||
@echo
|
|
||||||
@echo To flash current code using existing bootloader dfu
|
|
||||||
@echo $$ make BOARD=feather_nrf52840_express SERIAL=/dev/ttyACM0 dfu-flash
|
|
||||||
|
|
||||||
#******************* Flash target *******************
|
#******************* Flash target *******************
|
||||||
|
|
||||||
check_defined = \
|
check_defined = \
|
||||||
|
10
src/boards.c
10
src/boards.c
@ -38,6 +38,16 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//------------- IMPLEMENTATION -------------//
|
//------------- IMPLEMENTATION -------------//
|
||||||
|
void button_init(uint32_t pin)
|
||||||
|
{
|
||||||
|
nrf_gpio_cfg_sense_input(pin, BUTTON_PULL, NRF_GPIO_PIN_SENSE_LOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool button_pressed(uint32_t pin)
|
||||||
|
{
|
||||||
|
return (nrf_gpio_pin_read(pin) == 0) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
void board_init(void)
|
void board_init(void)
|
||||||
{
|
{
|
||||||
// stop LF clock just in case we jump from application without reset
|
// stop LF clock just in case we jump from application without reset
|
||||||
|
14
src/boards.h
14
src/boards.h
@ -30,6 +30,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "nrf_gpio.h"
|
#include "nrf_gpio.h"
|
||||||
|
|
||||||
|
|
||||||
#include BOARD_HEADER_FILE
|
#include BOARD_HEADER_FILE
|
||||||
|
|
||||||
#ifndef BUTTON_DFU
|
#ifndef BUTTON_DFU
|
||||||
@ -68,8 +69,6 @@ void board_teardown(void);
|
|||||||
// LED
|
// LED
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
#define bit(b) (1UL << (b))
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
STATE_BOOTLOADER_STARTED = 0,
|
STATE_BOOTLOADER_STARTED = 0,
|
||||||
STATE_USB_MOUNTED,
|
STATE_USB_MOUNTED,
|
||||||
@ -97,15 +96,8 @@ void led_tick(void);
|
|||||||
#error "At least two buttons required in the BSP (see 'BUTTONS_NUMBER')"
|
#error "At least two buttons required in the BSP (see 'BUTTONS_NUMBER')"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void button_init(uint32_t pin)
|
void button_init(uint32_t pin);
|
||||||
{
|
bool button_pressed(uint32_t pin);
|
||||||
nrf_gpio_cfg_sense_input(pin, BUTTON_PULL, NRF_GPIO_PIN_SENSE_LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool button_pressed(uint32_t pin)
|
|
||||||
{
|
|
||||||
return (nrf_gpio_pin_read(pin) == 0) ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_ota(void);
|
bool is_ota(void);
|
||||||
|
|
||||||
|
@ -1,38 +1,28 @@
|
|||||||
/**************************************************************************/
|
/*
|
||||||
/*!
|
* The MIT License (MIT)
|
||||||
@file elelctronutlabs_papyr.h
|
*
|
||||||
@author Tavish Naruka <tavish@electronut.in>
|
* @author Tavish Naruka <tavish@electronut.in>
|
||||||
|
*
|
||||||
@section LICENSE
|
* Copyright (c) 2018 Adafruit Industries
|
||||||
|
*
|
||||||
Software License Agreement (BSD License)
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
Copyright (c) 2017, Adafruit Industries (adafruit.com)
|
* in the Software without restriction, including without limitation the rights
|
||||||
All rights reserved.
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
Redistribution and use in source and binary forms, with or without
|
* furnished to do so, subject to the following conditions:
|
||||||
modification, are permitted provided that the following conditions are met:
|
*
|
||||||
1. Redistributions of source code must retain the above copyright
|
* The above copyright notice and this permission notice shall be included in
|
||||||
notice, this list of conditions and the following disclaimer.
|
* all copies or substantial portions of the Software.
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
*
|
||||||
notice, this list of conditions and the following disclaimer in the
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
documentation and/or other materials provided with the distribution.
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
3. Neither the name of the copyright holders nor the
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
names of its contributors may be used to endorse or promote products
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
derived from this software without specific prior written permission.
|
* 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
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
* THE SOFTWARE.
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
#ifndef PAPYR_H
|
#ifndef PAPYR_H
|
||||||
#define PAPYR_H
|
#define PAPYR_H
|
@ -22,8 +22,8 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _FEATHER52832_H
|
#ifndef _FEATHER_NRF52832_H
|
||||||
#define _FEATHER52832_H
|
#define _FEATHER_NRF52832_H
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* LED
|
/* LED
|
||||||
@ -56,4 +56,4 @@
|
|||||||
|
|
||||||
#define PRODUCT_NAME "Adafruit Bluefruit Feather nRF52832"
|
#define PRODUCT_NAME "Adafruit Bluefruit Feather nRF52832"
|
||||||
|
|
||||||
#endif // _FEATHER52832_H
|
#endif // _FEATHER_NRF52832_H
|
@ -22,8 +22,8 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _FEATHER52840_H
|
#ifndef _FEATHER_NRF52840_H
|
||||||
#define _FEATHER52840_H
|
#define _FEATHER_NRF52840_H
|
||||||
|
|
||||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||||
|
|
||||||
@ -61,4 +61,4 @@
|
|||||||
#define PRODUCT_NAME "Adafruit Feather nRF52840 Express"
|
#define PRODUCT_NAME "Adafruit Feather nRF52840 Express"
|
||||||
#define VOLUME_LABEL "FTHR840BOOT"
|
#define VOLUME_LABEL "FTHR840BOOT"
|
||||||
|
|
||||||
#endif // _FEATHER52840_H
|
#endif // _FEATHER_NRF52840_H
|
@ -22,8 +22,8 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _METRO_NRF52840_EXPRESS_H_
|
#ifndef _METRO_NRF52840_H_
|
||||||
#define _METRO_NRF52840_EXPRESS_H_
|
#define _METRO_NRF52840_H_
|
||||||
|
|
||||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||||
|
|
||||||
@ -62,4 +62,4 @@
|
|||||||
#define VOLUME_LABEL "METR840BOOT"
|
#define VOLUME_LABEL "METR840BOOT"
|
||||||
|
|
||||||
|
|
||||||
#endif /* _METRO_NRF52840_EXPRESS_H_ */
|
#endif /* _METRO_NRF52840_H_ */
|
@ -17,11 +17,7 @@ exit_status = 0
|
|||||||
|
|
||||||
all_boards = []
|
all_boards = []
|
||||||
for entry in os.scandir("src/boards"):
|
for entry in os.scandir("src/boards"):
|
||||||
if not entry.name.endswith(".h"):
|
all_boards.append(entry.name)
|
||||||
print("Misplaced file in src/boards: {}\n".format(entry.name))
|
|
||||||
exit_status = 1
|
|
||||||
continue
|
|
||||||
all_boards.append(entry.name[:-2])
|
|
||||||
|
|
||||||
#sha, version = build_info.get_version_info()
|
#sha, version = build_info.get_version_info()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user