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
|
||||
#*********************************
|
||||
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
|
||||
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)),)
|
||||
$(info You must provide a BOARD parameter with 'BOARD='. Supported boards are:)
|
||||
$(info $(BOARD_LIST))
|
||||
$(error Invalid BOARD specified)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
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 += -DBOARD_$(shell echo $(BOARD) | tr '[:lower:]' '[:upper:]')
|
||||
CFLAGS += -DBOARD_HEADER_FILE='"$(BOARD).h"'
|
||||
CFLAGS += -DBOARD_HEADER_FILE='"$(BOARD)/board.h"'
|
||||
|
||||
ifneq ($(IS_52832),)
|
||||
CFLAGS += -DNRF52
|
||||
@ -348,29 +341,6 @@ endif
|
||||
# default target to build
|
||||
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 *******************
|
||||
|
||||
check_defined = \
|
||||
|
10
src/boards.c
10
src/boards.c
@ -38,6 +38,16 @@
|
||||
#endif
|
||||
|
||||
//------------- 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)
|
||||
{
|
||||
// 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 "nrf_gpio.h"
|
||||
|
||||
|
||||
#include BOARD_HEADER_FILE
|
||||
|
||||
#ifndef BUTTON_DFU
|
||||
@ -68,8 +69,6 @@ void board_teardown(void);
|
||||
// LED
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
#define bit(b) (1UL << (b))
|
||||
|
||||
enum {
|
||||
STATE_BOOTLOADER_STARTED = 0,
|
||||
STATE_USB_MOUNTED,
|
||||
@ -97,15 +96,8 @@ void led_tick(void);
|
||||
#error "At least two buttons required in the BSP (see 'BUTTONS_NUMBER')"
|
||||
#endif
|
||||
|
||||
static inline void button_init(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;
|
||||
}
|
||||
void button_init(uint32_t pin);
|
||||
bool button_pressed(uint32_t pin);
|
||||
|
||||
bool is_ota(void);
|
||||
|
||||
|
@ -1,38 +1,28 @@
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@file elelctronutlabs_papyr.h
|
||||
@author Tavish Naruka <tavish@electronut.in>
|
||||
|
||||
@section LICENSE
|
||||
|
||||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2017, Adafruit Industries (adafruit.com)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holders nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
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.
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* @author Tavish Naruka <tavish@electronut.in>
|
||||
*
|
||||
* Copyright (c) 2018 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.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef PAPYR_H
|
||||
#define PAPYR_H
|
@ -22,8 +22,8 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _FEATHER52832_H
|
||||
#define _FEATHER52832_H
|
||||
#ifndef _FEATHER_NRF52832_H
|
||||
#define _FEATHER_NRF52832_H
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
@ -56,4 +56,4 @@
|
||||
|
||||
#define PRODUCT_NAME "Adafruit Bluefruit Feather nRF52832"
|
||||
|
||||
#endif // _FEATHER52832_H
|
||||
#endif // _FEATHER_NRF52832_H
|
@ -22,8 +22,8 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _FEATHER52840_H
|
||||
#define _FEATHER52840_H
|
||||
#ifndef _FEATHER_NRF52840_H
|
||||
#define _FEATHER_NRF52840_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
@ -61,4 +61,4 @@
|
||||
#define PRODUCT_NAME "Adafruit Feather nRF52840 Express"
|
||||
#define VOLUME_LABEL "FTHR840BOOT"
|
||||
|
||||
#endif // _FEATHER52840_H
|
||||
#endif // _FEATHER_NRF52840_H
|
@ -22,8 +22,8 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _METRO_NRF52840_EXPRESS_H_
|
||||
#define _METRO_NRF52840_EXPRESS_H_
|
||||
#ifndef _METRO_NRF52840_H_
|
||||
#define _METRO_NRF52840_H_
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
@ -62,4 +62,4 @@
|
||||
#define VOLUME_LABEL "METR840BOOT"
|
||||
|
||||
|
||||
#endif /* _METRO_NRF52840_EXPRESS_H_ */
|
||||
#endif /* _METRO_NRF52840_H_ */
|
@ -17,11 +17,7 @@ exit_status = 0
|
||||
|
||||
all_boards = []
|
||||
for entry in os.scandir("src/boards"):
|
||||
if not entry.name.endswith(".h"):
|
||||
print("Misplaced file in src/boards: {}\n".format(entry.name))
|
||||
exit_status = 1
|
||||
continue
|
||||
all_boards.append(entry.name[:-2])
|
||||
all_boards.append(entry.name)
|
||||
|
||||
#sha, version = build_info.get_version_info()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user