enhance board management
This commit is contained in:
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_ */
|
Reference in New Issue
Block a user