mirror of https://github.com/ARMmbed/mbed-os.git
Remove unused NRF52 SDK and MCU files
Superseded by new SDK 14.2 in https://github.com/ARMmbed/mbed-os/pull/6547pull/6711/head
parent
0f51ea031e
commit
1360920e77
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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 MBED_PERIPHERALNAMES_H
|
||||
#define MBED_PERIPHERALNAMES_H
|
||||
|
||||
#include "cmsis.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef STDIO_UART_TX
|
||||
#define STDIO_UART_TX TX_PIN_NUMBER
|
||||
#endif
|
||||
|
||||
#ifndef STDIO_UART_RX
|
||||
#define STDIO_UART_RX RX_PIN_NUMBER
|
||||
#endif
|
||||
|
||||
#define STDIO_UART UART_0
|
||||
|
||||
typedef enum {
|
||||
UART_0 = (int)NRF_UART0_BASE
|
||||
} UARTName;
|
||||
|
||||
|
||||
typedef enum {
|
||||
SPI_0 = (int)NRF_SPI0_BASE,
|
||||
SPI_1 = (int)NRF_SPI1_BASE,
|
||||
SPIS = (int)NRF_SPIS1_BASE
|
||||
} SPIName;
|
||||
|
||||
typedef enum {
|
||||
PWM_1 = 0,
|
||||
PWM_2
|
||||
} PWMName;
|
||||
|
||||
typedef enum {
|
||||
I2C_0 = (int)NRF_TWI0_BASE,
|
||||
I2C_1 = (int)NRF_TWI1_BASE
|
||||
} I2CName;
|
||||
|
||||
typedef enum {
|
||||
ADC0_0 = (int)0
|
||||
} ADCName;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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 MBED_PORTNAMES_H
|
||||
#define MBED_PORTNAMES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
Port0 = 0 //GPIO pins 0-31
|
||||
} PortName;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1,202 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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 MBED_PINNAMES_H
|
||||
#define MBED_PINNAMES_H
|
||||
|
||||
#include "cmsis.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PIN_INPUT,
|
||||
PIN_OUTPUT
|
||||
} PinDirection;
|
||||
|
||||
#define PORT_SHIFT 3
|
||||
|
||||
typedef enum {
|
||||
p0 = 0,
|
||||
p1 = 1,
|
||||
p2 = 2,
|
||||
p3 = 3,
|
||||
p4 = 4,
|
||||
p5 = 5,
|
||||
p6 = 6,
|
||||
p7 = 7,
|
||||
p8 = 8,
|
||||
p9 = 9,
|
||||
p10 = 10,
|
||||
p11 = 11,
|
||||
p12 = 12,
|
||||
p13 = 13,
|
||||
p14 = 14,
|
||||
p15 = 15,
|
||||
p16 = 16,
|
||||
p17 = 17,
|
||||
p18 = 18,
|
||||
p19 = 19,
|
||||
p20 = 20,
|
||||
p21 = 21,
|
||||
p22 = 22,
|
||||
p23 = 23,
|
||||
p24 = 24,
|
||||
p25 = 25,
|
||||
p26 = 26,
|
||||
p27 = 27,
|
||||
p28 = 28,
|
||||
p29 = 29,
|
||||
p30 = 30,
|
||||
p31 = 31,
|
||||
|
||||
P0_0 = p0,
|
||||
P0_1 = p1,
|
||||
P0_2 = p2,
|
||||
P0_3 = p3,
|
||||
P0_4 = p4,
|
||||
P0_5 = p5,
|
||||
P0_6 = p6,
|
||||
P0_7 = p7,
|
||||
|
||||
P0_8 = p8,
|
||||
P0_9 = p9,
|
||||
P0_10 = p10,
|
||||
P0_11 = p11,
|
||||
P0_12 = p12,
|
||||
P0_13 = p13,
|
||||
P0_14 = p14,
|
||||
P0_15 = p15,
|
||||
|
||||
P0_16 = p16,
|
||||
P0_17 = p17,
|
||||
P0_18 = p18,
|
||||
P0_19 = p19,
|
||||
P0_20 = p20,
|
||||
P0_21 = p21,
|
||||
P0_22 = p22,
|
||||
P0_23 = p23,
|
||||
|
||||
P0_24 = p24,
|
||||
P0_25 = p25,
|
||||
P0_26 = p26,
|
||||
P0_27 = p27,
|
||||
P0_28 = p28,
|
||||
P0_29 = p29,
|
||||
P0_30 = p30,
|
||||
|
||||
LED1 = p17,
|
||||
LED2 = p18,
|
||||
LED3 = p19,
|
||||
LED4 = p20,
|
||||
|
||||
BUTTON1 = p13,
|
||||
BUTTON2 = p14,
|
||||
BUTTON3 = p15,
|
||||
BUTTON4 = p16,
|
||||
|
||||
RX_PIN_NUMBER = p11,
|
||||
TX_PIN_NUMBER = p12,
|
||||
CTS_PIN_NUMBER = p13,
|
||||
RTS_PIN_NUMBER = p14,
|
||||
|
||||
// mBed interface Pins
|
||||
USBTX = TX_PIN_NUMBER,
|
||||
USBRX = RX_PIN_NUMBER,
|
||||
|
||||
SPI_PSELMOSI0 = p23,
|
||||
SPI_PSELMISO0 = p24,
|
||||
SPI_PSELSS0 = p22,
|
||||
SPI_PSELSCK0 = p25,
|
||||
|
||||
SPI_PSELMOSI1 = p12,
|
||||
SPI_PSELMISO1 = p13,
|
||||
SPI_PSELSS1 = p11,
|
||||
SPI_PSELSCK1 = p14,
|
||||
|
||||
SPIS_PSELMOSI = p12,
|
||||
SPIS_PSELMISO = p13,
|
||||
SPIS_PSELSS = p11,
|
||||
SPIS_PSELSCK = p14,
|
||||
|
||||
I2C_SDA0 = p26,
|
||||
I2C_SCL0 = p27,
|
||||
|
||||
D0 = p11,
|
||||
D1 = p12,
|
||||
D2 = p13,
|
||||
D3 = p14,
|
||||
D4 = p15,
|
||||
D5 = p16,
|
||||
D6 = p17,
|
||||
D7 = p18,
|
||||
|
||||
D8 = p19,
|
||||
D9 = p20,
|
||||
D10 = p22,
|
||||
D11 = p23,
|
||||
D12 = p24,
|
||||
D13 = p25,
|
||||
|
||||
D14 = p26,
|
||||
D15 = p27,
|
||||
|
||||
A0 = p3,
|
||||
A1 = p4,
|
||||
A2 = p28,
|
||||
A3 = p29,
|
||||
A4 = p30,
|
||||
A5 = p31,
|
||||
|
||||
// Not connected
|
||||
NC = (int)0xFFFFFFFF
|
||||
} PinName;
|
||||
|
||||
typedef enum {
|
||||
PullNone = 0,
|
||||
PullDown = 1,
|
||||
PullUp = 3,
|
||||
PullDefault = PullUp
|
||||
} PinMode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
// The 'features' section in 'target.json' is now used to create the device's hardware preprocessor switches.
|
||||
// Check the 'features' section of the target description in 'targets.json' for more details.
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_DEVICE_H
|
||||
#define MBED_DEVICE_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "objects.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2016 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
void mbed_sdk_init()
|
||||
{
|
||||
char* debug_date = __DATE__;
|
||||
char* debug_time = __TIME__;
|
||||
|
||||
}
|
||||
|
|
@ -1,243 +0,0 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2013 Nordic Semiconductor
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_PINNAMES_H
|
||||
#define MBED_PINNAMES_H
|
||||
|
||||
#include "cmsis.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PIN_INPUT,
|
||||
PIN_OUTPUT
|
||||
} PinDirection;
|
||||
|
||||
#define PORT_SHIFT 3
|
||||
|
||||
typedef enum {
|
||||
p0 = 0,
|
||||
p1 = 1,
|
||||
p2 = 2,
|
||||
p3 = 3,
|
||||
p4 = 4,
|
||||
p5 = 5,
|
||||
p6 = 6,
|
||||
p7 = 7,
|
||||
p8 = 8,
|
||||
p9 = 9,
|
||||
p10 = 10,
|
||||
p11 = 11,
|
||||
p12 = 12,
|
||||
p13 = 13,
|
||||
p14 = 14,
|
||||
p15 = 15,
|
||||
p16 = 16,
|
||||
p17 = 17,
|
||||
p18 = 18,
|
||||
p19 = 19,
|
||||
p20 = 20,
|
||||
p21 = 21,
|
||||
p22 = 22,
|
||||
p23 = 23,
|
||||
p24 = 24,
|
||||
p25 = 25,
|
||||
p26 = 26,
|
||||
p27 = 27,
|
||||
p28 = 28,
|
||||
p29 = 29,
|
||||
p30 = 30,
|
||||
p31 = 31,
|
||||
|
||||
|
||||
P0_0 = p0,
|
||||
P0_1 = p1,
|
||||
P0_2 = p2,
|
||||
P0_3 = p3,
|
||||
P0_4 = p4,
|
||||
P0_5 = p5,
|
||||
P0_6 = p6,
|
||||
P0_7 = p7,
|
||||
|
||||
P0_8 = p8,
|
||||
P0_9 = p9,
|
||||
P0_10 = p10,
|
||||
P0_11 = p11,
|
||||
P0_12 = p12,
|
||||
P0_13 = p13,
|
||||
P0_14 = p14,
|
||||
P0_15 = p15,
|
||||
|
||||
P0_16 = p16,
|
||||
P0_17 = p17,
|
||||
P0_18 = p18,
|
||||
P0_19 = p19,
|
||||
P0_20 = p20,
|
||||
P0_21 = p21,
|
||||
P0_22 = p22,
|
||||
P0_23 = p23,
|
||||
|
||||
P0_24 = p24,
|
||||
P0_25 = p25,
|
||||
P0_26 = p26,
|
||||
P0_27 = p27,
|
||||
P0_28 = p28,
|
||||
P0_29 = p29,
|
||||
P0_30 = p30,
|
||||
P0_31 = p31,
|
||||
|
||||
// Module pins. Refer datasheet for pin numbers.
|
||||
SIO_1 = P0_1,
|
||||
SIO_2 = P0_2,
|
||||
SIO_3 = P0_3,
|
||||
SIO_4 = P0_4,
|
||||
SIO_5 = P0_5,
|
||||
SIO_6 = P0_6,
|
||||
SIO_7 = P0_7,
|
||||
SIO_8 = P0_8,
|
||||
SIO_9 = P0_9, //NFC1
|
||||
SIO_10 = P0_10, //NFC2
|
||||
SIO_11 = P0_11,
|
||||
SIO_12 = P0_12,
|
||||
SIO_13 = P0_13,
|
||||
SIO_14 = P0_14,
|
||||
SIO_15 = P0_15,
|
||||
SIO_16 = P0_16,
|
||||
SIO_17 = P0_17,
|
||||
SIO_18 = P0_18,
|
||||
SIO_19 = P0_19,
|
||||
SIO_20 = P0_20,
|
||||
|
||||
SIO_22 = P0_22,
|
||||
SIO_23 = P0_23,
|
||||
SIO_24 = P0_24,
|
||||
SIO_25 = P0_25,
|
||||
SIO_26 = P0_26,
|
||||
SIO_27 = P0_27,
|
||||
SIO_28 = P0_28,
|
||||
SIO_29 = P0_29,
|
||||
SIO_30 = P0_30,
|
||||
SIO_31 = P0_31,
|
||||
SIO_0 = P0_0,
|
||||
|
||||
// Not connected
|
||||
NC = (int)0xFFFFFFFF,
|
||||
|
||||
//Mbed MTB pin defines.
|
||||
P_1 = NC,
|
||||
P_2 = SIO_24, //MISO
|
||||
P_3 = SIO_23, //MOSI
|
||||
P_4 = SIO_22,
|
||||
// P_5 = SWDIO,
|
||||
// P_6 = SWDCLK,
|
||||
// P_7 = NRST,
|
||||
P_8 = SIO_20,
|
||||
P_9 = SIO_18,
|
||||
P_10 = SIO_16,
|
||||
P_11 = SIO_14,
|
||||
P_12 = SIO_12,
|
||||
P_13 = SIO_11,
|
||||
P_14 = SIO_10,
|
||||
P_15 = SIO_9,
|
||||
P_16 = NC,
|
||||
P_17 = SIO_8,
|
||||
P_18 = SIO_7,
|
||||
P_19 = SIO_6,
|
||||
P_20 = SIO_5,
|
||||
P_21 = SIO_4,
|
||||
P_22 = SIO_3,
|
||||
P_23 = SIO_2,
|
||||
P_24 = SIO_1,
|
||||
P_25 = SIO_0,
|
||||
P_26 = NC,
|
||||
P_27 = NC,
|
||||
P_28 = SIO_13,
|
||||
P_29 = SIO_15,
|
||||
P_30 = SIO_17,
|
||||
P_31 = SIO_19,
|
||||
P_32 = SIO_31,
|
||||
P_33 = SIO_30,
|
||||
P_34 = SIO_29,
|
||||
P_35 = SIO_28,
|
||||
P_36 = SIO_27,
|
||||
P_37 = SIO_26,
|
||||
P_38 = SIO_25,
|
||||
P_39 = NC,
|
||||
|
||||
//LEDs
|
||||
LED1 = SIO_28,
|
||||
LED2 = SIO_29,
|
||||
LED3 = SIO_30,
|
||||
LED_RED = LED1,
|
||||
LED_GREEN = LED2,
|
||||
LED_BLUE = LED3,
|
||||
|
||||
GP0 = SIO_11,
|
||||
//Standardized button name
|
||||
BUTTON1 = GP0,
|
||||
|
||||
//Nordic SDK pin names
|
||||
RX_PIN_NUMBER = SIO_8,
|
||||
TX_PIN_NUMBER = SIO_6,
|
||||
CTS_PIN_NUMBER = SIO_7,
|
||||
RTS_PIN_NUMBER = SIO_5,
|
||||
|
||||
// mBed interface Pins
|
||||
USBTX = TX_PIN_NUMBER,
|
||||
USBRX = RX_PIN_NUMBER,
|
||||
|
||||
SPI_MOSI = SIO_23,
|
||||
SPI_MISO = SIO_24,
|
||||
SPI_SS0 = SIO_17, //CS for LCD on MTB
|
||||
SPI_SS1 = SIO_10, //CS for SD card on MTB
|
||||
SPI_SCK1 = SIO_25,
|
||||
SPI_SCK2 = SIO_31,
|
||||
|
||||
//Default SPI
|
||||
SPI_SCK = SPI_SCK1,
|
||||
SPI_CS = SPI_SS1,
|
||||
|
||||
I2C_SDA = SIO_26,
|
||||
I2C_SCL = SIO_27,
|
||||
|
||||
//MTB aliases
|
||||
GP1 = SIO_13,
|
||||
AIN0 = SIO_2,
|
||||
AIN1 = SIO_3,
|
||||
AIN2 = SIO_4,
|
||||
GP2 = SIO_10,
|
||||
GP3 = SIO_9,
|
||||
GP4 = SIO_22,
|
||||
GP5 = SIO_19, //A0 for LCD on MTB
|
||||
GP6 = SIO_18, //RESET for LCD on MTB
|
||||
GP7 = SIO_17,
|
||||
GP8 = SIO_15,
|
||||
|
||||
} PinName;
|
||||
|
||||
typedef enum {
|
||||
PullNone = 0,
|
||||
PullDown = 1,
|
||||
PullUp = 3,
|
||||
PullDefault = PullUp
|
||||
} PinMode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
// The 'features' section in 'target.json' is now used to create the device's hardware preprocessor switches.
|
||||
// Check the 'features' section of the target description in 'targets.json' for more details.
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_DEVICE_H
|
||||
#define MBED_DEVICE_H
|
||||
|
||||
#include "objects.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2016 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef MBED_PINNAMES_H
|
||||
#define MBED_PINNAMES_H
|
||||
|
||||
#include "cmsis.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PIN_INPUT,
|
||||
PIN_OUTPUT
|
||||
} PinDirection;
|
||||
|
||||
#define PORT_SHIFT 3
|
||||
|
||||
typedef enum {
|
||||
// nRF52 pin names
|
||||
p0 = 0,
|
||||
p1 = 1,
|
||||
p2 = 2,
|
||||
p3 = 3,
|
||||
p4 = 4,
|
||||
p5 = 5,
|
||||
p6 = 6,
|
||||
p7 = 7,
|
||||
p8 = 8,
|
||||
p9 = 9,
|
||||
p10 = 10,
|
||||
p11 = 11,
|
||||
p12 = 12,
|
||||
p13 = 13,
|
||||
p14 = 14,
|
||||
p15 = 15,
|
||||
p16 = 16,
|
||||
p17 = 17,
|
||||
p18 = 18,
|
||||
p19 = 19,
|
||||
p20 = 20,
|
||||
p21 = 21,
|
||||
p22 = 22,
|
||||
p23 = 23,
|
||||
p24 = 24,
|
||||
p25 = 25,
|
||||
p26 = 26,
|
||||
p27 = 27,
|
||||
p28 = 28,
|
||||
p29 = 29,
|
||||
p30 = 30,
|
||||
p31 = 31,
|
||||
NC = (int)0xFFFFFFFF, // Not connected
|
||||
|
||||
//NINA-B112 module pin names
|
||||
P_1 = p8,
|
||||
P_2 = p11,
|
||||
P_3 = p12,
|
||||
P_4 = p13,
|
||||
P_5 = p14,
|
||||
P_6 = NC,
|
||||
P_7 = p16,
|
||||
P_8 = p18,
|
||||
P_9 = NC,
|
||||
P_10 = NC,
|
||||
P_11 = NC,
|
||||
P_12 = NC,
|
||||
P_13 = NC,
|
||||
P_14 = NC,
|
||||
P_15 = NC,
|
||||
P_16 = p28,
|
||||
P_17 = p29,
|
||||
P_18 = p30,
|
||||
P_19 = p21,
|
||||
P_20 = p31,
|
||||
P_21 = p7,
|
||||
P_22 = p6,
|
||||
P_23 = p5,
|
||||
P_24 = p2,
|
||||
P_25 = p3,
|
||||
P_26 = NC,
|
||||
P_27 = p4,
|
||||
P_28 = p9,
|
||||
P_29 = p10,
|
||||
P_30 = NC,
|
||||
|
||||
// MTB aliases
|
||||
GPIO18 = p30,
|
||||
|
||||
LED1 = p4, // Red LED
|
||||
LED2 = p10, // Green LED
|
||||
GPIO27 = LED1,
|
||||
// GPIO29 = LED2,
|
||||
|
||||
GPIO7 = p16, //A0 for LCD
|
||||
GPIO16 = p28, //RESET for LCD
|
||||
|
||||
SW1 = p29,
|
||||
GPIO17 = SW1,
|
||||
//Standardized button names
|
||||
BUTTON1 = SW1,
|
||||
|
||||
// Nordic SDK pin names
|
||||
RX_PIN_NUMBER = p5,
|
||||
TX_PIN_NUMBER = p6,
|
||||
CTS_PIN_NUMBER = p7,
|
||||
RTS_PIN_NUMBER = p31,
|
||||
|
||||
I2C_SDA = p2,
|
||||
I2C_SCL = p3,
|
||||
|
||||
SPI0_MOSI = p13,
|
||||
SPI0_MISO = p12,
|
||||
SPI0_SCK = p14,
|
||||
SPI0_CS = p11,
|
||||
SPI1_CS = p8,
|
||||
|
||||
SPI_MOSI = SPI0_MOSI,
|
||||
SPI_MISO = SPI0_MISO,
|
||||
SPI_SCK = SPI0_SCK,
|
||||
SPI_CS = SPI0_CS,
|
||||
|
||||
// DAPLink
|
||||
USBRX = RX_PIN_NUMBER,
|
||||
USBTX = TX_PIN_NUMBER,
|
||||
NTRST = p21,
|
||||
SWO = p18,
|
||||
|
||||
} PinName;
|
||||
|
||||
typedef enum {
|
||||
PullNone = 0,
|
||||
PullDown = 1,
|
||||
PullUp = 3,
|
||||
PullDefault = PullUp
|
||||
} PinMode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_DEVICE_H
|
||||
#define MBED_DEVICE_H
|
||||
|
||||
#include "objects.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,203 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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 MBED_PINNAMES_H
|
||||
#define MBED_PINNAMES_H
|
||||
|
||||
#include "cmsis.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PIN_INPUT,
|
||||
PIN_OUTPUT
|
||||
} PinDirection;
|
||||
|
||||
#define PORT_SHIFT 3
|
||||
|
||||
typedef enum {
|
||||
p0 = 0,
|
||||
p1 = 1,
|
||||
p2 = 2,
|
||||
p3 = 3,
|
||||
p4 = 4,
|
||||
p5 = 5,
|
||||
p6 = 6,
|
||||
p7 = 7,
|
||||
p8 = 8,
|
||||
p9 = 9,
|
||||
p10 = 10,
|
||||
p11 = 11,
|
||||
p12 = 12,
|
||||
p13 = 13,
|
||||
p14 = 14,
|
||||
p15 = 15,
|
||||
p16 = 16,
|
||||
p17 = 17,
|
||||
p18 = 18,
|
||||
p19 = 19,
|
||||
p20 = 20,
|
||||
p21 = 21,
|
||||
p22 = 22,
|
||||
p23 = 23,
|
||||
p24 = 24,
|
||||
p25 = 25,
|
||||
p26 = 26,
|
||||
p27 = 27,
|
||||
p28 = 28,
|
||||
p29 = 29,
|
||||
p30 = 30,
|
||||
p31 = 31,
|
||||
|
||||
P0_0 = p0,
|
||||
P0_1 = p1,
|
||||
P0_2 = p2,
|
||||
P0_3 = p3,
|
||||
P0_4 = p4,
|
||||
P0_5 = p5,
|
||||
P0_6 = p6,
|
||||
P0_7 = p7,
|
||||
|
||||
P0_8 = p8,
|
||||
P0_9 = p9,
|
||||
P0_10 = p10,
|
||||
P0_11 = p11,
|
||||
P0_12 = p12,
|
||||
P0_13 = p13,
|
||||
P0_14 = p14,
|
||||
P0_15 = p15,
|
||||
|
||||
P0_16 = p16,
|
||||
P0_17 = p17,
|
||||
P0_18 = p18,
|
||||
P0_19 = p19,
|
||||
P0_20 = p20,
|
||||
P0_21 = p21,
|
||||
P0_22 = p22,
|
||||
P0_23 = p23,
|
||||
|
||||
P0_24 = p24,
|
||||
P0_25 = p25,
|
||||
P0_26 = p26,
|
||||
P0_27 = p27,
|
||||
P0_28 = p28,
|
||||
P0_29 = p29,
|
||||
P0_30 = p30,
|
||||
P0_31 = p31,
|
||||
|
||||
LED1 = p17,
|
||||
LED2 = p18,
|
||||
LED3 = p19,
|
||||
LED4 = p20,
|
||||
|
||||
BUTTON1 = p13,
|
||||
BUTTON2 = p14,
|
||||
BUTTON3 = p15,
|
||||
BUTTON4 = p16,
|
||||
|
||||
RX_PIN_NUMBER = p8,
|
||||
TX_PIN_NUMBER = p6,
|
||||
CTS_PIN_NUMBER = p7,
|
||||
RTS_PIN_NUMBER = p5,
|
||||
|
||||
// mBed interface Pins
|
||||
USBTX = TX_PIN_NUMBER,
|
||||
USBRX = RX_PIN_NUMBER,
|
||||
|
||||
SPI_PSELMOSI0 = p23,
|
||||
SPI_PSELMISO0 = p24,
|
||||
SPI_PSELSS0 = p22,
|
||||
SPI_PSELSCK0 = p25,
|
||||
|
||||
SPI_PSELMOSI1 = p12,
|
||||
SPI_PSELMISO1 = p13,
|
||||
SPI_PSELSS1 = p11,
|
||||
SPI_PSELSCK1 = p14,
|
||||
|
||||
SPIS_PSELMOSI = p12,
|
||||
SPIS_PSELMISO = p13,
|
||||
SPIS_PSELSS = p11,
|
||||
SPIS_PSELSCK = p14,
|
||||
|
||||
I2C_SDA0 = p26,
|
||||
I2C_SCL0 = p27,
|
||||
|
||||
D0 = p11,
|
||||
D1 = p12,
|
||||
D2 = p13,
|
||||
D3 = p14,
|
||||
D4 = p15,
|
||||
D5 = p16,
|
||||
D6 = p17,
|
||||
D7 = p18,
|
||||
|
||||
D8 = p19,
|
||||
D9 = p20,
|
||||
D10 = p22,
|
||||
D11 = p23,
|
||||
D12 = p24,
|
||||
D13 = p25,
|
||||
|
||||
D14 = p26,
|
||||
D15 = p27,
|
||||
|
||||
A0 = p3,
|
||||
A1 = p4,
|
||||
A2 = p28,
|
||||
A3 = p29,
|
||||
A4 = p30,
|
||||
A5 = p31,
|
||||
|
||||
// Not connected
|
||||
NC = (int)0xFFFFFFFF
|
||||
} PinName;
|
||||
|
||||
typedef enum {
|
||||
PullNone = 0,
|
||||
PullDown = 1,
|
||||
PullUp = 3,
|
||||
PullDefault = PullUp
|
||||
} PinMode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
// The 'features' section in 'target.json' is now used to create the device's hardware preprocessor switches.
|
||||
// Check the 'features' section of the target description in 'targets.json' for more details.
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_DEVICE_H
|
||||
#define MBED_DEVICE_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "objects.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,194 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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 MBED_PINNAMES_H
|
||||
#define MBED_PINNAMES_H
|
||||
|
||||
#include "cmsis.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PIN_INPUT,
|
||||
PIN_OUTPUT
|
||||
} PinDirection;
|
||||
|
||||
#define PORT_SHIFT 3
|
||||
|
||||
typedef enum {
|
||||
p0 = 0,
|
||||
p1 = 1,
|
||||
p2 = 2,
|
||||
p3 = 3,
|
||||
p4 = 4,
|
||||
p5 = 5,
|
||||
p6 = 6,
|
||||
p7 = 7,
|
||||
p8 = 8,
|
||||
p9 = 9,
|
||||
p10 = 10,
|
||||
p11 = 11,
|
||||
p12 = 12,
|
||||
p13 = 13,
|
||||
p14 = 14,
|
||||
p15 = 15,
|
||||
p16 = 16,
|
||||
p17 = 17,
|
||||
p18 = 18,
|
||||
p19 = 19,
|
||||
p20 = 20,
|
||||
p21 = 21,
|
||||
p22 = 22,
|
||||
p23 = 23,
|
||||
p24 = 24,
|
||||
p25 = 25,
|
||||
p26 = 26,
|
||||
p27 = 27,
|
||||
p28 = 28,
|
||||
p29 = 29,
|
||||
p30 = 30,
|
||||
p31 = 31,
|
||||
|
||||
P0_0 = p0,
|
||||
P0_1 = p1,
|
||||
P0_2 = p2,
|
||||
P0_3 = p3,
|
||||
P0_4 = p4,
|
||||
P0_5 = p5,
|
||||
P0_6 = p6,
|
||||
P0_7 = p7,
|
||||
|
||||
P0_8 = p8,
|
||||
P0_9 = p9,
|
||||
P0_10 = p10,
|
||||
P0_11 = p11,
|
||||
P0_12 = p12,
|
||||
P0_13 = p13,
|
||||
P0_14 = p14,
|
||||
P0_15 = p15,
|
||||
|
||||
P0_16 = p16,
|
||||
P0_17 = p17,
|
||||
P0_18 = p18,
|
||||
P0_19 = p19,
|
||||
P0_20 = p20,
|
||||
P0_21 = p21,
|
||||
P0_22 = p22,
|
||||
P0_23 = p23,
|
||||
|
||||
P0_24 = p24,
|
||||
P0_25 = p25,
|
||||
P0_26 = p26,
|
||||
P0_27 = p27,
|
||||
P0_28 = p28,
|
||||
P0_29 = p29,
|
||||
P0_30 = p30,
|
||||
|
||||
LED1 = p11,
|
||||
LED2 = p11,
|
||||
LED3 = p11,
|
||||
LED4 = p11,
|
||||
|
||||
RX_PIN_NUMBER = p30,
|
||||
TX_PIN_NUMBER = p29,
|
||||
CTS_PIN_NUMBER = p28,
|
||||
RTS_PIN_NUMBER = p2,
|
||||
|
||||
// mBed interface Pins
|
||||
USBTX = TX_PIN_NUMBER,
|
||||
USBRX = RX_PIN_NUMBER,
|
||||
|
||||
SPI_PSELMOSI0 = p6,
|
||||
SPI_PSELMISO0 = p7,
|
||||
SPI_PSELSS0 = p3,
|
||||
SPI_PSELSCK0 = p8,
|
||||
|
||||
SPI_PSELMOSI1 = p29,
|
||||
SPI_PSELMISO1 = p30,
|
||||
SPI_PSELSS1 = p28,
|
||||
SPI_PSELSCK1 = p2,
|
||||
|
||||
SPIS_PSELMOSI = p29,
|
||||
SPIS_PSELMISO = p30,
|
||||
SPIS_PSELSS = p28,
|
||||
SPIS_PSELSCK = p2,
|
||||
|
||||
I2C_SDA0 = p28,
|
||||
I2C_SCL0 = p2,
|
||||
|
||||
D0 = p30,
|
||||
D1 = p29,
|
||||
D2 = p28,
|
||||
D3 = p2,
|
||||
|
||||
D4 = p3,
|
||||
D5 = p6,
|
||||
D6 = p7,
|
||||
D7 = p8,
|
||||
D8 = p21,
|
||||
|
||||
D9 = p4,
|
||||
D10 = p5,
|
||||
|
||||
D13 = p11,
|
||||
|
||||
A0 = p28,
|
||||
A1 = p29,
|
||||
A2 = p30,
|
||||
A3 = p2,
|
||||
A4 = p4,
|
||||
A5 = p5,
|
||||
|
||||
// Not connected
|
||||
NC = (int)0xFFFFFFFF
|
||||
} PinName;
|
||||
|
||||
typedef enum {
|
||||
PullNone = 0,
|
||||
PullDown = 1,
|
||||
PullUp = 3,
|
||||
PullDefault = PullUp
|
||||
} PinMode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
// The 'features' section in 'target.json' is now used to create the device's hardware preprocessor switches.
|
||||
// Check the 'features' section of the target description in 'targets.json' for more details.
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_DEVICE_H
|
||||
#define MBED_DEVICE_H
|
||||
|
||||
#include "objects.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
#ifndef MBED_PINNAMES_H
|
||||
#define MBED_PINNAMES_H
|
||||
|
||||
#include "cmsis.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PIN_INPUT,
|
||||
PIN_OUTPUT
|
||||
} PinDirection;
|
||||
|
||||
#define PORT_SHIFT 3
|
||||
|
||||
typedef enum {
|
||||
// nRF52 pin names
|
||||
p0 = 0,
|
||||
p1 = 1,
|
||||
p2 = 2,
|
||||
p3 = 3,
|
||||
p4 = 4,
|
||||
p5 = 5,
|
||||
p6 = 6,
|
||||
p7 = 7,
|
||||
p8 = 8,
|
||||
p9 = 9,
|
||||
p10 = 10,
|
||||
p11 = 11,
|
||||
p12 = 12,
|
||||
p13 = 13,
|
||||
p14 = 14,
|
||||
p15 = 15,
|
||||
p16 = 16,
|
||||
p17 = 17,
|
||||
p18 = 18,
|
||||
p19 = 19,
|
||||
p20 = 20,
|
||||
p21 = 21,
|
||||
p22 = 22,
|
||||
p23 = 23,
|
||||
p24 = 24,
|
||||
p25 = 25,
|
||||
p26 = 26,
|
||||
p27 = 27,
|
||||
p28 = 28,
|
||||
p29 = 29,
|
||||
p30 = 30,
|
||||
p31 = 31,
|
||||
NC = (int)0xFFFFFFFF, // Not connected
|
||||
|
||||
//NINA-B1 module pin names
|
||||
NINA_B1_GPIO_1 = p8,
|
||||
NINA_B1_GPIO_2 = p11,
|
||||
NINA_B1_GPIO_3 = p12,
|
||||
NINA_B1_GPIO_4 = p13,
|
||||
NINA_B1_GPIO_5 = p14,
|
||||
NINA_B1_GPIO_7 = p16,
|
||||
NINA_B1_GPIO_8 = p18,
|
||||
|
||||
NINA_B1_GPIO_16 = p28,
|
||||
NINA_B1_GPIO_17 = p29,
|
||||
NINA_B1_GPIO_18 = p30,
|
||||
|
||||
NINA_B1_GPIO_20 = p31,
|
||||
NINA_B1_GPIO_21 = p7,
|
||||
NINA_B1_GPIO_22 = p6,
|
||||
NINA_B1_GPIO_23 = p5,
|
||||
NINA_B1_GPIO_24 = p2,
|
||||
NINA_B1_GPIO_25 = p3,
|
||||
NINA_B1_GPIO_27 = p4,
|
||||
NINA_B1_GPIO_28 = p9,
|
||||
NINA_B1_GPIO_29 = p10,
|
||||
|
||||
// Board pins
|
||||
LED1 = NINA_B1_GPIO_7, // ORANGE
|
||||
LED2 = NC,
|
||||
LED3 = NC,
|
||||
LED4 = NC,
|
||||
|
||||
// Nordic SDK pin names
|
||||
RX_PIN_NUMBER = p5,
|
||||
TX_PIN_NUMBER = p6,
|
||||
CTS_PIN_NUMBER = p7,
|
||||
RTS_PIN_NUMBER = p31,
|
||||
I2C_SDA0 = p2,
|
||||
I2C_SCL0 = p3,
|
||||
|
||||
// mBed interface pins
|
||||
USBTX = TX_PIN_NUMBER,
|
||||
USBRX = RX_PIN_NUMBER
|
||||
} PinName;
|
||||
|
||||
typedef enum {
|
||||
PullNone = 0,
|
||||
PullDown = 1,
|
||||
PullUp = 3,
|
||||
PullDefault = PullUp
|
||||
} PinMode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
// The 'features' section in 'target.json' is now used to create the device's hardware preprocessor switches.
|
||||
// Check the 'features' section of the target description in 'targets.json' for more details.
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_DEVICE_H
|
||||
#define MBED_DEVICE_H
|
||||
|
||||
#include "objects.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
#ifndef MBED_PINNAMES_H
|
||||
#define MBED_PINNAMES_H
|
||||
|
||||
#include "cmsis.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PIN_INPUT,
|
||||
PIN_OUTPUT
|
||||
} PinDirection;
|
||||
|
||||
#define PORT_SHIFT 3
|
||||
|
||||
typedef enum {
|
||||
// nRF52 pin names
|
||||
p0 = 0,
|
||||
p1 = 1,
|
||||
p2 = 2,
|
||||
p3 = 3,
|
||||
p4 = 4,
|
||||
p5 = 5,
|
||||
p6 = 6,
|
||||
p7 = 7,
|
||||
p8 = 8,
|
||||
p9 = 9,
|
||||
p10 = 10,
|
||||
p11 = 11,
|
||||
p12 = 12,
|
||||
p13 = 13,
|
||||
p14 = 14,
|
||||
p15 = 15,
|
||||
p16 = 16,
|
||||
p17 = 17,
|
||||
p18 = 18,
|
||||
p19 = 19,
|
||||
p20 = 20,
|
||||
p21 = 21,
|
||||
p22 = 22,
|
||||
p23 = 23,
|
||||
p24 = 24,
|
||||
p25 = 25,
|
||||
p26 = 26,
|
||||
p27 = 27,
|
||||
p28 = 28,
|
||||
p29 = 29,
|
||||
p30 = 30,
|
||||
p31 = 31,
|
||||
NC = (int)0xFFFFFFFF, // Not connected
|
||||
|
||||
//NINA-B1 module pin names
|
||||
NINA_B1_GPIO_1 = p8,
|
||||
NINA_B1_GPIO_2 = p11,
|
||||
NINA_B1_GPIO_3 = p12,
|
||||
NINA_B1_GPIO_4 = p13,
|
||||
NINA_B1_GPIO_5 = p14,
|
||||
NINA_B1_GPIO_7 = p16,
|
||||
NINA_B1_GPIO_8 = p18,
|
||||
|
||||
NINA_B1_GPIO_16 = p28,
|
||||
NINA_B1_GPIO_17 = p29,
|
||||
NINA_B1_GPIO_18 = p30,
|
||||
|
||||
NINA_B1_GPIO_20 = p31,
|
||||
NINA_B1_GPIO_21 = p7,
|
||||
NINA_B1_GPIO_22 = p6,
|
||||
NINA_B1_GPIO_23 = p5,
|
||||
NINA_B1_GPIO_24 = p2,
|
||||
NINA_B1_GPIO_25 = p3,
|
||||
NINA_B1_GPIO_27 = p4,
|
||||
NINA_B1_GPIO_28 = p9,
|
||||
NINA_B1_GPIO_29 = p10,
|
||||
|
||||
// EVK-NINA-B1 board
|
||||
LED1 = NINA_B1_GPIO_1, // Red
|
||||
LED2 = NINA_B1_GPIO_7, // Green/SW1
|
||||
LED3 = NINA_B1_GPIO_8, // Blue
|
||||
LED4 = NINA_B1_GPIO_8,
|
||||
SW1 = NINA_B1_GPIO_7,
|
||||
SW2 = NINA_B1_GPIO_18,
|
||||
D0 = NINA_B1_GPIO_23,
|
||||
D1 = NINA_B1_GPIO_22,
|
||||
D2 = NINA_B1_GPIO_21,
|
||||
D3 = NINA_B1_GPIO_20,
|
||||
D4 = NINA_B1_GPIO_8,
|
||||
D5 = NC, // SWDIO
|
||||
D6 = NINA_B1_GPIO_28,
|
||||
D7 = NINA_B1_GPIO_29,
|
||||
D8 = NC, // SWDCLK
|
||||
D9 = NINA_B1_GPIO_1,
|
||||
D10 = NINA_B1_GPIO_2,
|
||||
D11 = NINA_B1_GPIO_4,
|
||||
D12 = NINA_B1_GPIO_3,
|
||||
D13 = NINA_B1_GPIO_5,
|
||||
D14 = NINA_B1_GPIO_24,
|
||||
D15 = NINA_B1_GPIO_25,
|
||||
A0 = NINA_B1_GPIO_25,
|
||||
A1 = NINA_B1_GPIO_24,
|
||||
A2 = NINA_B1_GPIO_27,
|
||||
A3 = NINA_B1_GPIO_18,
|
||||
A4 = NINA_B1_GPIO_17,
|
||||
A5 = NINA_B1_GPIO_16,
|
||||
// Nordic SDK pin names
|
||||
RX_PIN_NUMBER = p5,
|
||||
TX_PIN_NUMBER = p6,
|
||||
CTS_PIN_NUMBER = p7,
|
||||
RTS_PIN_NUMBER = p31,
|
||||
I2C_SDA0 = p2,
|
||||
I2C_SCL0 = p3,
|
||||
// mBed interface pins
|
||||
USBTX = TX_PIN_NUMBER,
|
||||
USBRX = RX_PIN_NUMBER
|
||||
} PinName;
|
||||
|
||||
typedef enum {
|
||||
PullNone = 0,
|
||||
PullDown = 1,
|
||||
PullUp = 3,
|
||||
PullDefault = PullUp
|
||||
} PinMode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#ifndef MBED_DEVICE_H
|
||||
#define MBED_DEVICE_H
|
||||
|
||||
#include "objects.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,253 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2017 VNG IoT Lab, Vietnam
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* PinNames for the VBLUno52 board
|
||||
*/
|
||||
#ifndef MBED_PINNAMES_H
|
||||
#define MBED_PINNAMES_H
|
||||
|
||||
#include "cmsis.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PIN_INPUT,
|
||||
PIN_OUTPUT
|
||||
} PinDirection;
|
||||
|
||||
#define PORT_SHIFT 3
|
||||
|
||||
typedef enum {
|
||||
p0 = 0,
|
||||
p1 = 1,
|
||||
p2 = 2,
|
||||
p3 = 3,
|
||||
p4 = 4,
|
||||
p5 = 5,
|
||||
p6 = 6,
|
||||
p7 = 7,
|
||||
p8 = 8,
|
||||
p9 = 9,
|
||||
p10 = 10,
|
||||
p11 = 11,
|
||||
p12 = 12,
|
||||
p13 = 13,
|
||||
p14 = 14,
|
||||
p15 = 15,
|
||||
p16 = 16,
|
||||
p17 = 17,
|
||||
p18 = 18,
|
||||
p19 = 19,
|
||||
p20 = 20,
|
||||
p21 = 21,
|
||||
p22 = 22,
|
||||
p23 = 23,
|
||||
p24 = 24,
|
||||
p25 = 25,
|
||||
p26 = 26,
|
||||
p27 = 27,
|
||||
p28 = 28,
|
||||
p29 = 29,
|
||||
p30 = 30,
|
||||
p31 = 31,
|
||||
|
||||
P0_0 = p0,
|
||||
P0_1 = p1,
|
||||
P0_2 = p2,
|
||||
P0_3 = p3,
|
||||
P0_4 = p4,
|
||||
P0_5 = p5,
|
||||
P0_6 = p6,
|
||||
P0_7 = p7,
|
||||
|
||||
P0_8 = p8,
|
||||
P0_9 = p9,
|
||||
P0_10 = p10,
|
||||
P0_11 = p11,
|
||||
P0_12 = p12,
|
||||
P0_13 = p13,
|
||||
P0_14 = p14,
|
||||
P0_15 = p15,
|
||||
|
||||
P0_16 = p16,
|
||||
P0_17 = p17,
|
||||
P0_18 = p18,
|
||||
P0_19 = p19,
|
||||
P0_20 = p20,
|
||||
P0_21 = p21,
|
||||
P0_22 = p22,
|
||||
P0_23 = p23,
|
||||
|
||||
P0_24 = p24,
|
||||
P0_25 = p25,
|
||||
P0_26 = p26,
|
||||
P0_27 = p27,
|
||||
P0_28 = p28,
|
||||
P0_29 = p29,
|
||||
P0_30 = p30,
|
||||
P0_31 = p31,
|
||||
|
||||
//only for mbed test suite
|
||||
LED1 = p12,
|
||||
LED2 = p18,
|
||||
LED3 = p19,
|
||||
LED4 = p20,
|
||||
|
||||
//only for mbed test suite
|
||||
BUTTON1 = p17,
|
||||
BUTTON2 = p3,
|
||||
BUTTON3 = p4,
|
||||
BUTTON4 = p28,
|
||||
|
||||
RX_PIN_NUMBER = p8,
|
||||
TX_PIN_NUMBER = p6,
|
||||
CTS_PIN_NUMBER = p7, //not on Header
|
||||
RTS_PIN_NUMBER = p5, //not on Header
|
||||
|
||||
// mBed interface Pins
|
||||
USBTX = TX_PIN_NUMBER,
|
||||
USBRX = RX_PIN_NUMBER,
|
||||
|
||||
SPI_PSELMOSI0 = p13,
|
||||
SPI_PSELMISO0 = p14,
|
||||
SPI_PSELSS0 = p11,
|
||||
SPI_PSELSCK0 = p15,
|
||||
|
||||
SPI_PSELMOSI1 = p13,
|
||||
SPI_PSELMISO1 = p14,
|
||||
SPI_PSELSS1 = p11,
|
||||
SPI_PSELSCK1 = p15,
|
||||
|
||||
SPIS_PSELMOSI = p13,
|
||||
SPIS_PSELMISO = p14,
|
||||
SPIS_PSELSS = p11,
|
||||
SPIS_PSELSCK = p15,
|
||||
|
||||
I2C_SDA = p26,
|
||||
I2C_SCL = p27,
|
||||
|
||||
I2C_SDA0 = p26,
|
||||
I2C_SCL0 = p27,
|
||||
|
||||
I2C_SDA1 = p30,
|
||||
I2C_SCL1 = p31,
|
||||
|
||||
RESET = p21,
|
||||
|
||||
NFC1 = p9,
|
||||
NFC2 = p10,
|
||||
|
||||
//Adruino interface pins
|
||||
D0 = p8,
|
||||
D1 = p6,
|
||||
D2 = p24,
|
||||
D3 = p23,
|
||||
D4 = p22,
|
||||
D5 = p18,
|
||||
D6 = p19,
|
||||
D7 = p20,
|
||||
|
||||
D8 = p9,
|
||||
D9 = p10,
|
||||
D10 = p11,
|
||||
D11 = p13,
|
||||
D12 = p14,
|
||||
D13 = p15,
|
||||
|
||||
D14 = p3,
|
||||
D15 = p4,
|
||||
D16 = p28,
|
||||
D17 = p29,
|
||||
D18 = p30,
|
||||
D19 = p31,
|
||||
|
||||
D20 = p26,
|
||||
D21 = p27,
|
||||
|
||||
D22 = p12,
|
||||
D23 = p17,
|
||||
|
||||
D24 = p5,
|
||||
D25 = p7,
|
||||
|
||||
A0 = D14,
|
||||
A1 = D15,
|
||||
A2 = D16,
|
||||
A3 = D17,
|
||||
A4 = D18,
|
||||
A5 = D19,
|
||||
|
||||
SS = D10,
|
||||
MOSI = D11,
|
||||
MISO = D12,
|
||||
SCK = D13,
|
||||
|
||||
SDA0 = D20,
|
||||
SCL0 = D21,
|
||||
SDA1 = D18,
|
||||
SCL1 = D19,
|
||||
SDA = SDA0,
|
||||
SCL = SCL0,
|
||||
|
||||
RX = D0,
|
||||
TX = D1,
|
||||
RTS = D24, //not on Header
|
||||
CTS = D25, //not on Header
|
||||
|
||||
LED = D22, //not on Header
|
||||
BUT = D23, //not on Header
|
||||
|
||||
// Not connected
|
||||
NC = (int)0xFFFFFFFF
|
||||
} PinName;
|
||||
|
||||
typedef enum {
|
||||
PullNone = 0,
|
||||
PullDown = 1,
|
||||
PullUp = 3,
|
||||
PullDefault = PullUp
|
||||
} PinMode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
// The 'features' section in 'target.json' is now used to create the device's hardware preprocessor switches.
|
||||
// Check the 'features' section of the target description in 'targets.json' for more details.
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_DEVICE_H
|
||||
#define MBED_DEVICE_H
|
||||
|
||||
#include "objects.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
;WITHOUT SOFTDEVICE:
|
||||
;LR_IROM1 0x00000000 0x00040000 {
|
||||
; ER_IROM1 0x00000000 0x00040000 {
|
||||
; *.o (RESET, +First)
|
||||
; *(InRoot$$Sections)
|
||||
; .ANY (+RO)
|
||||
; }
|
||||
; RW_IRAM1 0x20000000 0x00004000 {
|
||||
; .ANY (+RW +ZI)
|
||||
; }
|
||||
;}
|
||||
;
|
||||
;WITH SOFTDEVICE:
|
||||
|
||||
LR_IROM1 0x1C000 0x0064000 {
|
||||
ER_IROM1 0x1C000 0x0064000 {
|
||||
*.o (RESET, +First)
|
||||
*(InRoot$$Sections)
|
||||
.ANY (+RO)
|
||||
}
|
||||
RW_IRAM0 0x20002EF8 UNINIT 0x000000D8 { ;no init section
|
||||
*(*noinit)
|
||||
}
|
||||
RW_IRAM1 0x20002FD0 0x0000D030 {
|
||||
.ANY (+RW +ZI)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,245 +0,0 @@
|
|||
;/* Copyright (c) 2012 ARM LIMITED
|
||||
;
|
||||
; All rights reserved.
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions are met:
|
||||
; - Redistributions of source code must retain the above copyright
|
||||
; notice, this list of conditions and the following disclaimer.
|
||||
; - 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.
|
||||
; - Neither the name of ARM 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 AND CONTRIBUTORS "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 COPYRIGHT HOLDERS AND CONTRIBUTORS 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.
|
||||
; ---------------------------------------------------------------------------*/
|
||||
|
||||
__initial_sp EQU 0x20010000
|
||||
|
||||
PRESERVE8
|
||||
THUMB
|
||||
|
||||
; Vector Table Mapped to Address 0 at Reset
|
||||
|
||||
AREA RESET, DATA, READONLY
|
||||
EXPORT __Vectors
|
||||
EXPORT __Vectors_End
|
||||
EXPORT __Vectors_Size
|
||||
|
||||
__Vectors DCD __initial_sp ; Top of Stack
|
||||
DCD Reset_Handler
|
||||
DCD NMI_Handler
|
||||
DCD HardFault_Handler
|
||||
DCD MemoryManagement_Handler
|
||||
DCD BusFault_Handler
|
||||
DCD UsageFault_Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler
|
||||
DCD DebugMonitor_Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler
|
||||
DCD SysTick_Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD POWER_CLOCK_IRQHandler
|
||||
DCD RADIO_IRQHandler
|
||||
DCD UARTE0_UART0_IRQHandler_v
|
||||
DCD SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler_v
|
||||
DCD SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler_v
|
||||
DCD NFCT_IRQHandler_v
|
||||
DCD GPIOTE_IRQHandler_v
|
||||
DCD SAADC_IRQHandler_v
|
||||
DCD TIMER0_IRQHandler_v
|
||||
DCD TIMER1_IRQHandler_v
|
||||
DCD TIMER2_IRQHandler_v
|
||||
DCD RTC0_IRQHandler
|
||||
DCD TEMP_IRQHandler_v
|
||||
DCD RNG_IRQHandler
|
||||
DCD ECB_IRQHandler
|
||||
DCD CCM_AAR_IRQHandler
|
||||
DCD WDT_IRQHandler_v
|
||||
DCD RTC1_IRQHandler_v
|
||||
DCD QDEC_IRQHandler_v
|
||||
DCD COMP_LPCOMP_IRQHandler_v
|
||||
DCD SWI0_EGU0_IRQHandler_v
|
||||
DCD SWI1_EGU1_IRQHandler_v
|
||||
DCD SWI2_EGU2_IRQHandler_v
|
||||
DCD SWI3_EGU3_IRQHandler_v
|
||||
DCD SWI4_EGU4_IRQHandler
|
||||
DCD SWI5_EGU5_IRQHandler
|
||||
DCD TIMER3_IRQHandler_v
|
||||
DCD TIMER4_IRQHandler_v
|
||||
DCD PWM0_IRQHandler_v
|
||||
DCD PDM_IRQHandler_v
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD MWU_IRQHandler
|
||||
DCD PWM1_IRQHandler_v
|
||||
DCD PWM2_IRQHandler_v
|
||||
DCD SPIM2_SPIS2_SPI2_IRQHandler_v
|
||||
DCD RTC2_IRQHandler_v
|
||||
DCD I2S_IRQHandler_v
|
||||
DCD FPU_IRQHandler_v
|
||||
|
||||
__Vectors_End
|
||||
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
|
||||
; Reset Handler
|
||||
|
||||
|
||||
Reset_Handler PROC
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
IMPORT SystemInit
|
||||
IMPORT __main
|
||||
IMPORT nrf_reloc_vector_table
|
||||
|
||||
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =nrf_reloc_vector_table
|
||||
BLX R0
|
||||
LDR R0, =__main
|
||||
BX R0
|
||||
ENDP
|
||||
|
||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
||||
|
||||
NMI_Handler PROC
|
||||
EXPORT NMI_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
HardFault_Handler\
|
||||
PROC
|
||||
EXPORT HardFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
MemoryManagement_Handler\
|
||||
PROC
|
||||
EXPORT MemoryManagement_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
BusFault_Handler\
|
||||
PROC
|
||||
EXPORT BusFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
UsageFault_Handler\
|
||||
PROC
|
||||
EXPORT UsageFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SVC_Handler PROC
|
||||
EXPORT SVC_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
DebugMonitor_Handler\
|
||||
PROC
|
||||
EXPORT DebugMonitor_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
PendSV_Handler PROC
|
||||
EXPORT PendSV_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SysTick_Handler PROC
|
||||
EXPORT SysTick_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
|
||||
Default_Handler PROC
|
||||
|
||||
EXPORT POWER_CLOCK_IRQHandler [WEAK]
|
||||
EXPORT RADIO_IRQHandler [WEAK]
|
||||
EXPORT UARTE0_UART0_IRQHandler_v [WEAK]
|
||||
EXPORT SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler_v [WEAK]
|
||||
EXPORT SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler_v [WEAK]
|
||||
EXPORT NFCT_IRQHandler_v [WEAK]
|
||||
EXPORT GPIOTE_IRQHandler_v [WEAK]
|
||||
EXPORT SAADC_IRQHandler_v [WEAK]
|
||||
EXPORT TIMER0_IRQHandler_v [WEAK]
|
||||
EXPORT TIMER1_IRQHandler_v [WEAK]
|
||||
EXPORT TIMER2_IRQHandler_v [WEAK]
|
||||
EXPORT RTC0_IRQHandler [WEAK]
|
||||
EXPORT TEMP_IRQHandler_v [WEAK]
|
||||
EXPORT RNG_IRQHandler [WEAK]
|
||||
EXPORT ECB_IRQHandler [WEAK]
|
||||
EXPORT CCM_AAR_IRQHandler [WEAK]
|
||||
EXPORT WDT_IRQHandler_v [WEAK]
|
||||
EXPORT RTC1_IRQHandler_v [WEAK]
|
||||
EXPORT QDEC_IRQHandler_v [WEAK]
|
||||
EXPORT COMP_LPCOMP_IRQHandler_v [WEAK]
|
||||
EXPORT SWI0_EGU0_IRQHandler_v [WEAK]
|
||||
EXPORT SWI1_EGU1_IRQHandler_v [WEAK]
|
||||
EXPORT SWI2_EGU2_IRQHandler_v [WEAK]
|
||||
EXPORT SWI3_EGU3_IRQHandler_v [WEAK]
|
||||
EXPORT SWI4_EGU4_IRQHandler [WEAK]
|
||||
EXPORT SWI5_EGU5_IRQHandler [WEAK]
|
||||
EXPORT TIMER3_IRQHandler_v [WEAK]
|
||||
EXPORT TIMER4_IRQHandler_v [WEAK]
|
||||
EXPORT PWM0_IRQHandler_v [WEAK]
|
||||
EXPORT PDM_IRQHandler_v [WEAK]
|
||||
EXPORT MWU_IRQHandler [WEAK]
|
||||
EXPORT PWM1_IRQHandler_v [WEAK]
|
||||
EXPORT PWM2_IRQHandler_v [WEAK]
|
||||
EXPORT SPIM2_SPIS2_SPI2_IRQHandler_v [WEAK]
|
||||
EXPORT RTC2_IRQHandler_v [WEAK]
|
||||
EXPORT I2S_IRQHandler_v [WEAK]
|
||||
EXPORT FPU_IRQHandler_v [WEAK]
|
||||
POWER_CLOCK_IRQHandler
|
||||
RADIO_IRQHandler
|
||||
UARTE0_UART0_IRQHandler_v
|
||||
SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler_v
|
||||
SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler_v
|
||||
NFCT_IRQHandler_v
|
||||
GPIOTE_IRQHandler_v
|
||||
SAADC_IRQHandler_v
|
||||
TIMER0_IRQHandler_v
|
||||
TIMER1_IRQHandler_v
|
||||
TIMER2_IRQHandler_v
|
||||
RTC0_IRQHandler
|
||||
TEMP_IRQHandler_v
|
||||
RNG_IRQHandler
|
||||
ECB_IRQHandler
|
||||
CCM_AAR_IRQHandler
|
||||
WDT_IRQHandler_v
|
||||
RTC1_IRQHandler_v
|
||||
QDEC_IRQHandler_v
|
||||
COMP_LPCOMP_IRQHandler_v
|
||||
SWI0_EGU0_IRQHandler_v
|
||||
SWI1_EGU1_IRQHandler_v
|
||||
SWI2_EGU2_IRQHandler_v
|
||||
SWI3_EGU3_IRQHandler_v
|
||||
SWI4_EGU4_IRQHandler
|
||||
SWI5_EGU5_IRQHandler
|
||||
TIMER3_IRQHandler_v
|
||||
TIMER4_IRQHandler_v
|
||||
PWM0_IRQHandler_v
|
||||
PDM_IRQHandler_v
|
||||
MWU_IRQHandler
|
||||
PWM1_IRQHandler_v
|
||||
PWM2_IRQHandler_v
|
||||
SPIM2_SPIS2_SPI2_IRQHandler_v
|
||||
RTC2_IRQHandler_v
|
||||
I2S_IRQHandler_v
|
||||
FPU_IRQHandler_v
|
||||
B .
|
||||
ENDP
|
||||
ALIGN
|
||||
END
|
||||
|
|
@ -1,190 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* Linker script to configure memory regions. */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x1C000, LENGTH = 0x64000
|
||||
RAM (rwx) : ORIGIN = 0x20002ef8, LENGTH = 0xd108
|
||||
}
|
||||
|
||||
|
||||
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||
|
||||
/* Linker script to place sections and symbol values. Should be used together
|
||||
* with the other linker script that defines memory regions FLASH and RAM.
|
||||
* It references the following symbols that must be defined in code:
|
||||
* Reset_Handler : Entry of reset handler
|
||||
*
|
||||
* It defines the following symbols that the code can use without definition:
|
||||
* __exidx_start
|
||||
* __exidx_end
|
||||
* __etext
|
||||
* __data_start__
|
||||
* __preinit_array_start
|
||||
* __preinit_array_end
|
||||
* __init_array_start
|
||||
* __init_array_end
|
||||
* __fini_array_start
|
||||
* __fini_array_end
|
||||
* __data_end__
|
||||
* __bss_start__
|
||||
* __bss_end__
|
||||
* __end__
|
||||
* end
|
||||
* __HeapLimit
|
||||
* __StackLimit
|
||||
* __StackTop
|
||||
* __stack
|
||||
*/
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
KEEP(*(.Vectors))
|
||||
*(.text*)
|
||||
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.fini))
|
||||
|
||||
/* .ctors */
|
||||
*crtbegin.o(.ctors)
|
||||
*crtbegin?.o(.ctors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||
*(SORT(.ctors.*))
|
||||
*(.ctors)
|
||||
|
||||
/* .dtors */
|
||||
*crtbegin.o(.dtors)
|
||||
*crtbegin?.o(.dtors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||
*(SORT(.dtors.*))
|
||||
*(.dtors)
|
||||
|
||||
*(.rodata*)
|
||||
|
||||
KEEP(*(.eh_frame*))
|
||||
} > FLASH
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
. = ALIGN(4);
|
||||
} > FLASH
|
||||
|
||||
__exidx_start = .;
|
||||
.ARM.exidx :
|
||||
{
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
. = ALIGN(4);
|
||||
} > FLASH
|
||||
__exidx_end = .;
|
||||
|
||||
__etext = .;
|
||||
|
||||
.data : AT (__etext)
|
||||
{
|
||||
__data_start__ = .;
|
||||
*(vtable)
|
||||
*(.data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
/* preinit data */
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* init data */
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
|
||||
|
||||
. = ALIGN(4);
|
||||
/* finit data */
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
PROVIDE(__start_fs_data = .);
|
||||
KEEP(*(.fs_data))
|
||||
PROVIDE(__stop_fs_data = .);
|
||||
|
||||
*(.jcr)
|
||||
. = ALIGN(4);
|
||||
/* All data end */
|
||||
__data_end__ = .;
|
||||
|
||||
} > RAM
|
||||
|
||||
__edata = .;
|
||||
|
||||
.noinit :
|
||||
{
|
||||
PROVIDE(__start_noinit = .);
|
||||
KEEP(*(.noinit))
|
||||
PROVIDE(__stop_noinit = .);
|
||||
} > RAM
|
||||
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start__ = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
} > RAM
|
||||
|
||||
.heap (NOLOAD):
|
||||
{
|
||||
__end__ = .;
|
||||
end = __end__;
|
||||
*(.heap*);
|
||||
|
||||
/* Expand the heap to reach the stack boundary. */
|
||||
ASSERT(. <= (ORIGIN(RAM) + LENGTH(RAM) - 0x800), "heap region overflowed into stack");
|
||||
. += (ORIGIN(RAM) + LENGTH(RAM) - 0x800) - .;
|
||||
} > RAM
|
||||
PROVIDE(__heap_start = ADDR(.heap));
|
||||
PROVIDE(__heap_size = SIZEOF(.heap));
|
||||
PROVIDE(__mbed_sbrk_start = ADDR(.heap));
|
||||
PROVIDE(__mbed_krbs_start = ADDR(.heap) + SIZEOF(.heap));
|
||||
|
||||
/* .stack_dummy section does not contain any symbols. It is only
|
||||
* used for the linker script to calculate the size of stack sections
|
||||
* and assign values to stack symbols later. */
|
||||
.stack (NOLOAD):
|
||||
{
|
||||
__StackLimit = .;
|
||||
*(.stack*)
|
||||
. += (ORIGIN(RAM) + LENGTH(RAM) - .);
|
||||
} > RAM
|
||||
|
||||
/* Set the stack top to the end of RAM and move down the stack limit by
|
||||
* the size of the stack_dummy section. */
|
||||
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
|
||||
__StackLimit = __StackTop - SIZEOF(.stack);
|
||||
PROVIDE(__stack = __StackTop);
|
||||
}
|
||||
|
|
@ -1,270 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
NOTE: Template files (including this one) are application specific and therefore
|
||||
expected to be copied into the application project folder prior to its use!
|
||||
*/
|
||||
|
||||
.syntax unified
|
||||
.arch armv7e-m
|
||||
|
||||
.section .Vectors
|
||||
.align 2
|
||||
.globl __Vectors
|
||||
__Vectors:
|
||||
.long __StackTop /* Top of Stack */
|
||||
.long Reset_Handler
|
||||
.long NMI_Handler
|
||||
.long HardFault_Handler
|
||||
.long MemoryManagement_Handler
|
||||
.long BusFault_Handler
|
||||
.long UsageFault_Handler
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long SVC_Handler
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long PendSV_Handler
|
||||
.long SysTick_Handler
|
||||
|
||||
/* External Interrupts */
|
||||
.long POWER_CLOCK_IRQHandler
|
||||
.long RADIO_IRQHandler
|
||||
.long UARTE0_UART0_IRQHandler_v
|
||||
.long SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler_v
|
||||
.long SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler_v
|
||||
.long NFCT_IRQHandler_v
|
||||
.long GPIOTE_IRQHandler_v
|
||||
.long SAADC_IRQHandler_v
|
||||
.long TIMER0_IRQHandler_v
|
||||
.long TIMER1_IRQHandler_v
|
||||
.long TIMER2_IRQHandler_v
|
||||
.long RTC0_IRQHandler
|
||||
.long TEMP_IRQHandler_v
|
||||
.long RNG_IRQHandler
|
||||
.long ECB_IRQHandler
|
||||
.long CCM_AAR_IRQHandler
|
||||
.long WDT_IRQHandler_v
|
||||
.long RTC1_IRQHandler_v
|
||||
.long QDEC_IRQHandler_v
|
||||
.long COMP_LPCOMP_IRQHandler_v
|
||||
.long SWI0_EGU0_IRQHandler_v
|
||||
.long SWI1_EGU1_IRQHandler_v
|
||||
.long SWI2_EGU2_IRQHandler_v
|
||||
.long SWI3_EGU3_IRQHandler_v
|
||||
.long SWI4_EGU4_IRQHandler
|
||||
.long SWI5_EGU5_IRQHandler
|
||||
.long TIMER3_IRQHandler_v
|
||||
.long TIMER4_IRQHandler_v
|
||||
.long PWM0_IRQHandler_v
|
||||
.long PDM_IRQHandler_v
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long MWU_IRQHandler
|
||||
.long PWM1_IRQHandler_v
|
||||
.long PWM2_IRQHandler_v
|
||||
.long SPIM2_SPIS2_SPI2_IRQHandler_v
|
||||
.long RTC2_IRQHandler_v
|
||||
.long I2S_IRQHandler_v
|
||||
.long FPU_IRQHandler_v
|
||||
|
||||
|
||||
.size __Vectors, . - __Vectors
|
||||
|
||||
/* Reset Handler */
|
||||
|
||||
.text
|
||||
.thumb
|
||||
.thumb_func
|
||||
.align 1
|
||||
.globl Reset_Handler
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.fnstart
|
||||
|
||||
|
||||
/* Loop to copy data from read only memory to RAM. The ranges
|
||||
* of copy from/to are specified by following symbols evaluated in
|
||||
* linker script.
|
||||
* __etext: End of code section, i.e., begin of data sections to copy from.
|
||||
* __data_start__/__data_end__: RAM address range that data should be
|
||||
* copied to. Both must be aligned to 4 bytes boundary. */
|
||||
|
||||
ldr r1, =__etext
|
||||
ldr r2, =__data_start__
|
||||
ldr r3, =__data_end__
|
||||
|
||||
subs r3, r2
|
||||
ble .LC0
|
||||
|
||||
.LC1:
|
||||
subs r3, 4
|
||||
ldr r0, [r1,r3]
|
||||
str r0, [r2,r3]
|
||||
bgt .LC1
|
||||
.LC0:
|
||||
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =nrf_reloc_vector_table
|
||||
BLX R0
|
||||
LDR R0, =_start
|
||||
BX R0
|
||||
|
||||
.pool
|
||||
.cantunwind
|
||||
.fnend
|
||||
.size Reset_Handler,.-Reset_Handler
|
||||
|
||||
.section ".text"
|
||||
|
||||
|
||||
/* Dummy Exception Handlers (infinite loops which can be modified) */
|
||||
|
||||
.weak NMI_Handler
|
||||
.type NMI_Handler, %function
|
||||
NMI_Handler:
|
||||
B .
|
||||
.size NMI_Handler, . - NMI_Handler
|
||||
|
||||
|
||||
.weak HardFault_Handler
|
||||
.type HardFault_Handler, %function
|
||||
HardFault_Handler:
|
||||
B .
|
||||
.size HardFault_Handler, . - HardFault_Handler
|
||||
|
||||
|
||||
.weak MemoryManagement_Handler
|
||||
.type MemoryManagement_Handler, %function
|
||||
MemoryManagement_Handler:
|
||||
B .
|
||||
.size MemoryManagement_Handler, . - MemoryManagement_Handler
|
||||
|
||||
|
||||
.weak BusFault_Handler
|
||||
.type BusFault_Handler, %function
|
||||
BusFault_Handler:
|
||||
B .
|
||||
.size BusFault_Handler, . - BusFault_Handler
|
||||
|
||||
|
||||
.weak UsageFault_Handler
|
||||
.type UsageFault_Handler, %function
|
||||
UsageFault_Handler:
|
||||
B .
|
||||
.size UsageFault_Handler, . - UsageFault_Handler
|
||||
|
||||
|
||||
.weak SVC_Handler
|
||||
.type SVC_Handler, %function
|
||||
SVC_Handler:
|
||||
B .
|
||||
.size SVC_Handler, . - SVC_Handler
|
||||
|
||||
|
||||
.weak PendSV_Handler
|
||||
.type PendSV_Handler, %function
|
||||
PendSV_Handler:
|
||||
B .
|
||||
.size PendSV_Handler, . - PendSV_Handler
|
||||
|
||||
|
||||
.weak SysTick_Handler
|
||||
.type SysTick_Handler, %function
|
||||
SysTick_Handler:
|
||||
B .
|
||||
.size SysTick_Handler, . - SysTick_Handler
|
||||
|
||||
|
||||
/* IRQ Handlers */
|
||||
|
||||
.globl Default_Handler
|
||||
.type Default_Handler, %function
|
||||
Default_Handler:
|
||||
B .
|
||||
.size Default_Handler, . - Default_Handler
|
||||
|
||||
.macro IRQ handler
|
||||
.weak \handler
|
||||
.set \handler, Default_Handler
|
||||
.endm
|
||||
|
||||
IRQ POWER_CLOCK_IRQHandler /* restricted */
|
||||
IRQ RADIO_IRQHandler /* blocked */
|
||||
IRQ UARTE0_UART0_IRQHandler_v
|
||||
IRQ SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler_v
|
||||
IRQ SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler_v
|
||||
IRQ NFCT_IRQHandler_v
|
||||
IRQ GPIOTE_IRQHandler_v
|
||||
IRQ SAADC_IRQHandler_v
|
||||
IRQ TIMER0_IRQHandler_v
|
||||
IRQ TIMER1_IRQHandler_v
|
||||
IRQ TIMER2_IRQHandler_v
|
||||
IRQ RTC0_IRQHandler /* blocked */
|
||||
IRQ TEMP_IRQHandler_v
|
||||
IRQ RNG_IRQHandler /* restricted */
|
||||
IRQ ECB_IRQHandler /* restricted */
|
||||
IRQ CCM_AAR_IRQHandler /* blocked */
|
||||
IRQ WDT_IRQHandler_v
|
||||
IRQ RTC1_IRQHandler_v
|
||||
IRQ QDEC_IRQHandler_v
|
||||
IRQ COMP_LPCOMP_IRQHandler_v
|
||||
IRQ SWI0_EGU0_IRQHandler_v
|
||||
IRQ SWI1_EGU1_IRQHandler_v /* restricted for Radio Notification */
|
||||
IRQ SWI2_EGU2_IRQHandler_v /* blocked for SoftDevice Event */
|
||||
IRQ SWI3_EGU3_IRQHandler_v
|
||||
IRQ SWI4_EGU4_IRQHandler /* blocked */
|
||||
IRQ SWI5_EGU5_IRQHandler /* blocked */
|
||||
IRQ TIMER3_IRQHandler_v
|
||||
IRQ TIMER4_IRQHandler_v
|
||||
IRQ PWM0_IRQHandler_v
|
||||
IRQ PDM_IRQHandler_v
|
||||
IRQ MWU_IRQHandler /* restricted */
|
||||
IRQ PWM1_IRQHandler_v
|
||||
IRQ PWM2_IRQHandler_v
|
||||
IRQ SPIM2_SPIS2_SPI2_IRQHandler_v
|
||||
IRQ RTC2_IRQHandler_v
|
||||
IRQ I2S_IRQHandler_v
|
||||
IRQ FPU_IRQHandler_v
|
||||
|
||||
.end
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
||||
/*-Specials-*/
|
||||
define symbol __ICFEDIT_intvec_start__ = 0x1c000;
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_ROM_start__ = 0x1c000;
|
||||
define symbol __ICFEDIT_region_ROM_end__ = 0x7ffff;
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20002ef8;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x2000ffff;
|
||||
export symbol __ICFEDIT_region_RAM_start__;
|
||||
export symbol __ICFEDIT_region_RAM_end__;
|
||||
/*-Sizes-*/
|
||||
/*Heap 1/4 of ram and stack 1/8*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x800;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x1800;
|
||||
/**** End of ICF editor section. ###ICF###*/
|
||||
|
||||
define symbol __code_start_soft_device__ = 0x0;
|
||||
|
||||
define memory mem with size = 4G;
|
||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
||||
|
||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
initialize by copy { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
keep { section .intvec };
|
||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
||||
place in ROM_region { readonly };
|
||||
place in RAM_region { readwrite,
|
||||
block HEAP,
|
||||
block CSTACK };
|
||||
|
||||
/*This is used for mbed applications build inside the Embedded workbench
|
||||
Applications build with the python scritps use a hex merge so need to merge it
|
||||
inside the linker. The linker can only use binary files so the hex merge is not possible
|
||||
through the linker. That is why a binary is used instead of a hex image for the embedded project.
|
||||
*/
|
||||
if(isdefinedsymbol(SOFT_DEVICE_BIN))
|
||||
{
|
||||
place at address mem:__code_start_soft_device__ { section .noinit_softdevice };
|
||||
}
|
||||
|
|
@ -1,381 +0,0 @@
|
|||
;/* Copyright (c) 2012 ARM LIMITED
|
||||
;
|
||||
; All rights reserved.
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions are met:
|
||||
; - Redistributions of source code must retain the above copyright
|
||||
; notice, this list of conditions and the following disclaimer.
|
||||
; - 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.
|
||||
; - Neither the name of ARM 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 AND CONTRIBUTORS "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 COPYRIGHT HOLDERS AND CONTRIBUTORS 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 modules in this file are included in the libraries, and may be replaced
|
||||
; by any user-defined modules that define the PUBLIC symbol _program_start or
|
||||
; a user defined start symbol.
|
||||
; To override the cstartup defined in the library, simply add your modified
|
||||
; version to the workbench project.
|
||||
;
|
||||
; The vector table is normally located at address 0.
|
||||
; When debugging in RAM, it can be located in RAM, aligned to at least 2^6.
|
||||
; The name "__vector_table" has special meaning for C-SPY:
|
||||
; it is where the SP start value is found, and the NVIC vector
|
||||
; table register (VTOR) is initialized to this address if != 0.
|
||||
|
||||
|
||||
|
||||
MODULE ?cstartup
|
||||
|
||||
;; Stack size default : Defined in *.icf (linker file). Can be modified inside EW.
|
||||
;; Heap size default : Defined in *.icf (linker file). Can be modified inside EW.
|
||||
|
||||
;; Forward declaration of sections.
|
||||
SECTION CSTACK:DATA:NOROOT(3)
|
||||
|
||||
SECTION .intvec:CODE:NOROOT(2)
|
||||
|
||||
EXTERN __iar_program_start
|
||||
EXTERN SystemInit
|
||||
EXTERN nrf_reloc_vector_table
|
||||
PUBLIC __vector_table
|
||||
PUBLIC __Vectors
|
||||
PUBLIC __Vectors_End
|
||||
PUBLIC __Vectors_Size
|
||||
|
||||
DATA
|
||||
|
||||
__vector_table
|
||||
DCD sfe(CSTACK)
|
||||
DCD Reset_Handler
|
||||
DCD NMI_Handler
|
||||
DCD HardFault_Handler
|
||||
DCD MemoryManagement_Handler
|
||||
DCD BusFault_Handler
|
||||
DCD UsageFault_Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler
|
||||
DCD DebugMonitor_Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler
|
||||
DCD SysTick_Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD POWER_CLOCK_IRQHandler
|
||||
DCD RADIO_IRQHandler
|
||||
DCD UARTE0_UART0_IRQHandler_v
|
||||
DCD SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler_v
|
||||
DCD SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler_v
|
||||
DCD NFCT_IRQHandler_v
|
||||
DCD GPIOTE_IRQHandler_v
|
||||
DCD SAADC_IRQHandler_v
|
||||
DCD TIMER0_IRQHandler_v
|
||||
DCD TIMER1_IRQHandler_v
|
||||
DCD TIMER2_IRQHandler_v
|
||||
DCD RTC0_IRQHandler
|
||||
DCD TEMP_IRQHandler_v
|
||||
DCD RNG_IRQHandler
|
||||
DCD ECB_IRQHandler
|
||||
DCD CCM_AAR_IRQHandler
|
||||
DCD WDT_IRQHandler_v
|
||||
DCD RTC1_IRQHandler_v
|
||||
DCD QDEC_IRQHandler_v
|
||||
DCD COMP_LPCOMP_IRQHandler_v
|
||||
DCD SWI0_EGU0_IRQHandler_v
|
||||
DCD SWI1_EGU1_IRQHandler_v
|
||||
DCD SWI2_EGU2_IRQHandler_v
|
||||
DCD SWI3_EGU3_IRQHandler_v
|
||||
DCD SWI4_EGU4_IRQHandler
|
||||
DCD SWI5_EGU5_IRQHandler
|
||||
DCD TIMER3_IRQHandler_v
|
||||
DCD TIMER4_IRQHandler_v
|
||||
DCD PWM0_IRQHandler_v
|
||||
DCD PDM_IRQHandler_v
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD MWU_IRQHandler
|
||||
DCD PWM1_IRQHandler_v
|
||||
DCD PWM2_IRQHandler_v
|
||||
DCD SPIM2_SPIS2_SPI2_IRQHandler_v
|
||||
DCD RTC2_IRQHandler_v
|
||||
DCD I2S_IRQHandler_v
|
||||
DCD FPU_IRQHandler_v
|
||||
|
||||
|
||||
__Vectors_End
|
||||
__Vectors EQU __vector_table
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
|
||||
; Default handlers.
|
||||
THUMB
|
||||
|
||||
PUBWEAK Reset_Handler
|
||||
SECTION .text:CODE:NOROOT(2)
|
||||
Reset_Handler
|
||||
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =nrf_reloc_vector_table
|
||||
BLX R0
|
||||
LDR R0, =__iar_program_start
|
||||
BX R0
|
||||
|
||||
; Dummy exception handlers
|
||||
|
||||
|
||||
PUBWEAK NMI_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
NMI_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK HardFault_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
HardFault_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK MemoryManagement_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
MemoryManagement_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK BusFault_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
BusFault_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK UsageFault_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
UsageFault_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK SVC_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SVC_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK DebugMonitor_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
DebugMonitor_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK PendSV_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
PendSV_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK SysTick_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SysTick_Handler
|
||||
B .
|
||||
|
||||
|
||||
; Dummy interrupt handlers
|
||||
|
||||
PUBWEAK POWER_CLOCK_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
POWER_CLOCK_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK RADIO_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
RADIO_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK UARTE0_UART0_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
UARTE0_UART0_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK NFCT_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
NFCT_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK GPIOTE_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
GPIOTE_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SAADC_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SAADC_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK TIMER0_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
TIMER0_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK TIMER1_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
TIMER1_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK TIMER2_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
TIMER2_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK RTC0_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
RTC0_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK TEMP_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
TEMP_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK RNG_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
RNG_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK ECB_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
ECB_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK CCM_AAR_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
CCM_AAR_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK WDT_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
WDT_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK RTC1_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
RTC1_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK QDEC_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
QDEC_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK COMP_LPCOMP_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
COMP_LPCOMP_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SWI0_EGU0_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SWI0_EGU0_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SWI1_EGU1_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SWI1_EGU1_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SWI2_EGU2_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SWI2_EGU2_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SWI3_EGU3_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SWI3_EGU3_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SWI4_EGU4_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SWI4_EGU4_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK SWI5_EGU5_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SWI5_EGU5_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK TIMER3_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
TIMER3_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK TIMER4_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
TIMER4_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK PWM0_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
PWM0_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK PDM_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
PDM_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK MWU_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
MWU_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK PWM1_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
PWM1_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK PWM2_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
PWM2_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SPIM2_SPIS2_SPI2_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SPIM2_SPIS2_SPI2_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK RTC2_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
RTC2_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK I2S_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
I2S_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK FPU_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
FPU_IRQHandler_v
|
||||
B .
|
||||
|
||||
|
||||
END
|
||||
|
||||
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* PackageLicenseDeclared: Apache-2.0
|
||||
* Copyright (c) 2016 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef MBED_CMSIS_H
|
||||
#define MBED_CMSIS_H
|
||||
|
||||
#include "nrf.h"
|
||||
#include "cmsis_nvic.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/* mbed Microcontroller Library
|
||||
* CMSIS-style functionality to support dynamic vectors
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2016 ARM Limited. All rights reserved.
|
||||
* 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 ARM Limited 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 AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "cmsis_nvic.h"
|
||||
|
||||
extern uint32_t nrf_dispatch_vector[NVIC_NUM_VECTORS];
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector)
|
||||
{
|
||||
nrf_dispatch_vector[IRQn + NVIC_USER_IRQ_OFFSET] = vector;
|
||||
}
|
||||
|
||||
uint32_t NVIC_GetVector(IRQn_Type IRQn)
|
||||
{
|
||||
return nrf_dispatch_vector[IRQn + NVIC_USER_IRQ_OFFSET];
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2016 ARM Limited. All rights reserved.
|
||||
* 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 ARM Limited 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 AND CONTRIBUTORS "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 OR CONTRIBUTORS 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 MBED_CMSIS_NVIC_H
|
||||
#define MBED_CMSIS_NVIC_H
|
||||
|
||||
#define NVIC_NUM_VECTORS (16 + 38) // CORE + MCU Peripherals
|
||||
#define NVIC_USER_IRQ_OFFSET 16
|
||||
|
||||
#include "nrf52.h"
|
||||
#include "cmsis.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector);
|
||||
uint32_t NVIC_GetVector(IRQn_Type IRQn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,321 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "nrf.h"
|
||||
#include "system_nrf52.h"
|
||||
#include "nrf5x_lf_clk_helper.h"
|
||||
|
||||
/*lint ++flb "Enter library region" */
|
||||
|
||||
#define __SYSTEM_CLOCK_64M (64000000UL)
|
||||
|
||||
static bool errata_16(void);
|
||||
static bool errata_31(void);
|
||||
static bool errata_32(void);
|
||||
static bool errata_36(void);
|
||||
static bool errata_37(void);
|
||||
static bool errata_57(void);
|
||||
static bool errata_66(void);
|
||||
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK_64M;
|
||||
#elif defined ( __ICCARM__ )
|
||||
__root uint32_t SystemCoreClock = __SYSTEM_CLOCK_64M;
|
||||
#elif defined ( __GNUC__ )
|
||||
uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK_64M;
|
||||
#endif
|
||||
|
||||
void SystemCoreClockUpdate(void)
|
||||
{
|
||||
SystemCoreClock = __SYSTEM_CLOCK_64M;
|
||||
}
|
||||
|
||||
void SystemInit(void)
|
||||
{
|
||||
/* Workaround for Errata 16 "System: RAM may be corrupt on wakeup from CPU IDLE" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_16()){
|
||||
*(volatile uint32_t *)0x4007C074 = 3131961357ul;
|
||||
}
|
||||
|
||||
/* Workaround for Errata 31 "CLOCK: Calibration values are not correctly loaded from FICR at reset" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_31()){
|
||||
*(volatile uint32_t *)0x4000053C = ((*(volatile uint32_t *)0x10000244) & 0x0000E000) >> 13;
|
||||
}
|
||||
|
||||
/* Workaround for Errata 32 "DIF: Debug session automatically enables TracePort pins" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_32()){
|
||||
CoreDebug->DEMCR &= ~CoreDebug_DEMCR_TRCENA_Msk;
|
||||
}
|
||||
|
||||
/* Workaround for Errata 36 "CLOCK: Some registers are not reset when expected" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_36()){
|
||||
NRF_CLOCK->EVENTS_DONE = 0;
|
||||
NRF_CLOCK->EVENTS_CTTO = 0;
|
||||
NRF_CLOCK->CTIV = 0;
|
||||
}
|
||||
|
||||
/* Workaround for Errata 37 "RADIO: Encryption engine is slow by default" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_37()){
|
||||
*(volatile uint32_t *)0x400005A0 = 0x3;
|
||||
}
|
||||
|
||||
/* Workaround for Errata 57 "NFCT: NFC Modulation amplitude" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_57()){
|
||||
*(volatile uint32_t *)0x40005610 = 0x00000005;
|
||||
*(volatile uint32_t *)0x40005688 = 0x00000001;
|
||||
*(volatile uint32_t *)0x40005618 = 0x00000000;
|
||||
*(volatile uint32_t *)0x40005614 = 0x0000003F;
|
||||
}
|
||||
|
||||
/* Workaround for Errata 66 "TEMP: Linearity specification not met with default settings" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_66()){
|
||||
NRF_TEMP->A0 = NRF_FICR->TEMP.A0;
|
||||
NRF_TEMP->A1 = NRF_FICR->TEMP.A1;
|
||||
NRF_TEMP->A2 = NRF_FICR->TEMP.A2;
|
||||
NRF_TEMP->A3 = NRF_FICR->TEMP.A3;
|
||||
NRF_TEMP->A4 = NRF_FICR->TEMP.A4;
|
||||
NRF_TEMP->A5 = NRF_FICR->TEMP.A5;
|
||||
NRF_TEMP->B0 = NRF_FICR->TEMP.B0;
|
||||
NRF_TEMP->B1 = NRF_FICR->TEMP.B1;
|
||||
NRF_TEMP->B2 = NRF_FICR->TEMP.B2;
|
||||
NRF_TEMP->B3 = NRF_FICR->TEMP.B3;
|
||||
NRF_TEMP->B4 = NRF_FICR->TEMP.B4;
|
||||
NRF_TEMP->B5 = NRF_FICR->TEMP.B5;
|
||||
NRF_TEMP->T0 = NRF_FICR->TEMP.T0;
|
||||
NRF_TEMP->T1 = NRF_FICR->TEMP.T1;
|
||||
NRF_TEMP->T2 = NRF_FICR->TEMP.T2;
|
||||
NRF_TEMP->T3 = NRF_FICR->TEMP.T3;
|
||||
NRF_TEMP->T4 = NRF_FICR->TEMP.T4;
|
||||
}
|
||||
|
||||
/* Enable the FPU if the compiler used floating point unit instructions. __FPU_USED is a MACRO defined by the
|
||||
* compiler. Since the FPU consumes energy, remember to disable FPU use in the compiler if floating point unit
|
||||
* operations are not used in your code. */
|
||||
#if (__FPU_USED == 1)
|
||||
SCB->CPACR |= (3UL << 20) | (3UL << 22);
|
||||
__DSB();
|
||||
__ISB();
|
||||
#endif
|
||||
|
||||
/* Configure NFCT pins as GPIOs if NFCT is not to be used in your code. If CONFIG_NFCT_PINS_AS_GPIOS is not defined,
|
||||
two GPIOs (see Product Specification to see which ones) will be reserved for NFC and will not be available as
|
||||
normal GPIOs. */
|
||||
#if defined (CONFIG_NFCT_PINS_AS_GPIOS)
|
||||
if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk) == (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)){
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NRF_UICR->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Configure GPIO pads as pPin Reset pin if Pin Reset capabilities desired. If CONFIG_GPIO_AS_PINRESET is not
|
||||
defined, pin reset will not be available. One GPIO (see Product Specification to see which one) will then be
|
||||
reserved for PinReset and not available as normal GPIO. */
|
||||
#if defined (CONFIG_GPIO_AS_PINRESET)
|
||||
if (((NRF_UICR->PSELRESET[0] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos)) ||
|
||||
((NRF_UICR->PSELRESET[1] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos))){
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NRF_UICR->PSELRESET[0] = 21;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NRF_UICR->PSELRESET[1] = 21;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Enable SWO trace functionality. If ENABLE_SWO is not defined, SWO pin will be used as GPIO (see Product
|
||||
Specification to see which one). */
|
||||
#if defined (ENABLE_SWO)
|
||||
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
||||
NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Serial << CLOCK_TRACECONFIG_TRACEMUX_Pos;
|
||||
NRF_P0->PIN_CNF[18] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||
#endif
|
||||
|
||||
/* Enable Trace functionality. If ENABLE_TRACE is not defined, TRACE pins will be used as GPIOs (see Product
|
||||
Specification to see which ones). */
|
||||
#if defined (ENABLE_TRACE)
|
||||
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
||||
NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Parallel << CLOCK_TRACECONFIG_TRACEMUX_Pos;
|
||||
NRF_P0->PIN_CNF[14] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||
NRF_P0->PIN_CNF[15] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||
NRF_P0->PIN_CNF[16] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||
NRF_P0->PIN_CNF[18] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||
NRF_P0->PIN_CNF[20] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||
#endif
|
||||
|
||||
SystemCoreClockUpdate();
|
||||
|
||||
// Start the LF oscilator according to the mbed configuration (over the nrf5x_lf_clk_helper.h file)
|
||||
NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_TO_USE << CLOCK_LFCLKSRC_SRC_Pos);
|
||||
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
|
||||
NRF_CLOCK->TASKS_LFCLKSTART = 1;
|
||||
|
||||
// Wait for the external oscillator to start up.
|
||||
while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) {
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static bool errata_16(void)
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
|
||||
{
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool errata_31(void)
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
|
||||
{
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool errata_32(void)
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
|
||||
{
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool errata_36(void)
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
|
||||
{
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool errata_37(void)
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
|
||||
{
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool errata_57(void)
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
|
||||
{
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool errata_66(void)
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
|
||||
{
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*lint --flb "Leave library region" */
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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 SYSTEM_NRF52_H
|
||||
#define SYSTEM_NRF52_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
|
||||
|
||||
/**
|
||||
* Initialize the system
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Setup the microcontroller system.
|
||||
* Initialize the System and update the SystemCoreClock variable.
|
||||
*/
|
||||
extern void SystemInit (void);
|
||||
|
||||
/**
|
||||
* Update SystemCoreClock variable
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Updates the SystemCoreClock with current core Clock
|
||||
* retrieved from cpu registers.
|
||||
*/
|
||||
extern void SystemCoreClockUpdate (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SYSTEM_NRF52_H */
|
||||
|
|
@ -1,350 +0,0 @@
|
|||
/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is property of Nordic Semiconductor ASA.
|
||||
* Terms and conditions of usage are described in detail in NORDIC
|
||||
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* Licensees are granted free, non-transferable use of the information. NO
|
||||
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
|
||||
* the file.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "nrf_drv_pwm.h"
|
||||
#include "nrf_drv_common.h"
|
||||
#include "nrf_gpio.h"
|
||||
#include "app_util_platform.h"
|
||||
|
||||
#if (PWM_COUNT == 0)
|
||||
#error "No PWM instances enabled in the driver configuration file."
|
||||
#endif
|
||||
|
||||
|
||||
// Control block - driver instance local data.
|
||||
typedef struct
|
||||
{
|
||||
nrf_drv_pwm_handler_t handler;
|
||||
nrf_drv_state_t volatile state;
|
||||
} pwm_control_block_t;
|
||||
static pwm_control_block_t m_cb[PWM_COUNT];
|
||||
|
||||
static nrf_drv_pwm_config_t const m_default_config[PWM_COUNT] = {
|
||||
#if PWM0_ENABLED
|
||||
NRF_DRV_PWM_DEFAULT_CONFIG(0),
|
||||
#endif
|
||||
#if PWM1_ENABLED
|
||||
NRF_DRV_PWM_DEFAULT_CONFIG(1),
|
||||
#endif
|
||||
#if PWM2_ENABLED
|
||||
NRF_DRV_PWM_DEFAULT_CONFIG(2),
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
static void configure_pins(nrf_drv_pwm_t const * const p_instance,
|
||||
nrf_drv_pwm_config_t const * p_config)
|
||||
{
|
||||
uint32_t out_pins[NRF_PWM_CHANNEL_COUNT];
|
||||
uint8_t i;
|
||||
|
||||
for (i = 0; i < NRF_PWM_CHANNEL_COUNT; ++i)
|
||||
{
|
||||
uint8_t output_pin = p_config->output_pins[i];
|
||||
if (output_pin != NRF_DRV_PWM_PIN_NOT_USED)
|
||||
{
|
||||
bool inverted = output_pin & NRF_DRV_PWM_PIN_INVERTED;
|
||||
out_pins[i] = output_pin & ~NRF_DRV_PWM_PIN_INVERTED;
|
||||
|
||||
if (inverted)
|
||||
{
|
||||
nrf_gpio_pin_set(out_pins[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
nrf_gpio_pin_clear(out_pins[i]);
|
||||
}
|
||||
|
||||
nrf_gpio_cfg_output(out_pins[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
out_pins[i] = NRF_PWM_PIN_NOT_CONNECTED;
|
||||
}
|
||||
}
|
||||
|
||||
nrf_pwm_pins_set(p_instance->p_registers, out_pins);
|
||||
}
|
||||
|
||||
|
||||
ret_code_t nrf_drv_pwm_init(nrf_drv_pwm_t const * const p_instance,
|
||||
nrf_drv_pwm_config_t const * p_config,
|
||||
nrf_drv_pwm_handler_t handler)
|
||||
{
|
||||
pwm_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
|
||||
|
||||
if (p_cb->state != NRF_DRV_STATE_UNINITIALIZED)
|
||||
{
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (p_config == NULL)
|
||||
{
|
||||
p_config = &m_default_config[p_instance->drv_inst_idx];
|
||||
}
|
||||
|
||||
p_cb->handler = handler;
|
||||
|
||||
configure_pins(p_instance, p_config);
|
||||
|
||||
nrf_pwm_enable(p_instance->p_registers);
|
||||
nrf_pwm_configure(p_instance->p_registers,
|
||||
p_config->base_clock, p_config->count_mode, p_config->top_value);
|
||||
nrf_pwm_decoder_set(p_instance->p_registers,
|
||||
p_config->load_mode, p_config->step_mode);
|
||||
|
||||
nrf_pwm_shorts_set(p_instance->p_registers, 0);
|
||||
nrf_pwm_int_set(p_instance->p_registers, 0);
|
||||
nrf_pwm_event_clear(p_instance->p_registers, NRF_PWM_EVENT_LOOPSDONE);
|
||||
nrf_pwm_event_clear(p_instance->p_registers, NRF_PWM_EVENT_SEQEND0);
|
||||
nrf_pwm_event_clear(p_instance->p_registers, NRF_PWM_EVENT_SEQEND1);
|
||||
nrf_pwm_event_clear(p_instance->p_registers, NRF_PWM_EVENT_STOPPED);
|
||||
|
||||
if (p_cb->handler)
|
||||
{
|
||||
nrf_drv_common_irq_enable(nrf_drv_get_IRQn(p_instance->p_registers),
|
||||
p_config->irq_priority);
|
||||
}
|
||||
|
||||
p_cb->state = NRF_DRV_STATE_INITIALIZED;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void nrf_drv_pwm_uninit(nrf_drv_pwm_t const * const p_instance)
|
||||
{
|
||||
pwm_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
|
||||
ASSERT(p_cb->state != NRF_DRV_STATE_UNINITIALIZED);
|
||||
|
||||
nrf_drv_common_irq_disable(nrf_drv_get_IRQn(p_instance->p_registers));
|
||||
|
||||
nrf_pwm_disable(p_instance->p_registers);
|
||||
|
||||
p_cb->state = NRF_DRV_STATE_UNINITIALIZED;
|
||||
}
|
||||
|
||||
|
||||
static void start_playback(nrf_drv_pwm_t const * const p_instance,
|
||||
pwm_control_block_t * p_cb,
|
||||
uint8_t flags,
|
||||
nrf_pwm_task_t starting_task)
|
||||
{
|
||||
p_cb->state = NRF_DRV_STATE_POWERED_ON;
|
||||
|
||||
if (p_cb->handler)
|
||||
{
|
||||
// The notification about finished playback is by default enabled, but
|
||||
// this can be suppressed. The notification that the peripheral has been
|
||||
// stopped is always enable.
|
||||
uint32_t int_mask = NRF_PWM_INT_LOOPSDONE_MASK |
|
||||
NRF_PWM_INT_STOPPED_MASK;
|
||||
|
||||
if (flags & NRF_DRV_PWM_FLAG_SIGNAL_END_SEQ0)
|
||||
{
|
||||
int_mask |= NRF_PWM_INT_SEQEND0_MASK;
|
||||
}
|
||||
if (flags & NRF_DRV_PWM_FLAG_SIGNAL_END_SEQ1)
|
||||
{
|
||||
int_mask |= NRF_PWM_INT_SEQEND1_MASK;
|
||||
}
|
||||
if (flags & NRF_DRV_PWM_FLAG_NO_EVT_FINISHED)
|
||||
{
|
||||
int_mask &= ~NRF_PWM_INT_LOOPSDONE_MASK;
|
||||
}
|
||||
|
||||
nrf_pwm_int_set(p_instance->p_registers, int_mask);
|
||||
}
|
||||
|
||||
nrf_pwm_event_clear(p_instance->p_registers, NRF_PWM_EVENT_STOPPED);
|
||||
|
||||
nrf_pwm_task_trigger(p_instance->p_registers, starting_task);
|
||||
}
|
||||
|
||||
|
||||
void nrf_drv_pwm_simple_playback(nrf_drv_pwm_t const * const p_instance,
|
||||
nrf_pwm_sequence_t const * p_sequence,
|
||||
uint16_t playback_count,
|
||||
uint32_t flags)
|
||||
{
|
||||
pwm_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
|
||||
ASSERT(p_cb->state != NRF_DRV_STATE_UNINITIALIZED);
|
||||
ASSERT(playback_count > 0);
|
||||
ASSERT(nrf_drv_is_in_RAM(p_sequence->values.p_raw));
|
||||
|
||||
// To take advantage of the looping mechanism, we need to use both sequences
|
||||
// (single sequence can be played back only once).
|
||||
nrf_pwm_sequence_set(p_instance->p_registers, 0, p_sequence);
|
||||
nrf_pwm_sequence_set(p_instance->p_registers, 1, p_sequence);
|
||||
bool odd = (playback_count & 1);
|
||||
nrf_pwm_loop_set(p_instance->p_registers, playback_count/2 + (odd ? 1 : 0));
|
||||
|
||||
uint32_t shorts_mask;
|
||||
if (flags & NRF_DRV_PWM_FLAG_STOP)
|
||||
{
|
||||
shorts_mask = NRF_PWM_SHORT_LOOPSDONE_STOP_MASK;
|
||||
}
|
||||
else if (flags & NRF_DRV_PWM_FLAG_LOOP)
|
||||
{
|
||||
shorts_mask = odd ? NRF_PWM_SHORT_LOOPSDONE_SEQSTART1_MASK
|
||||
: NRF_PWM_SHORT_LOOPSDONE_SEQSTART0_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
shorts_mask = 0;
|
||||
}
|
||||
nrf_pwm_shorts_set(p_instance->p_registers, shorts_mask);
|
||||
|
||||
start_playback(p_instance, p_cb, flags, odd ? NRF_PWM_TASK_SEQSTART1
|
||||
: NRF_PWM_TASK_SEQSTART0);
|
||||
}
|
||||
|
||||
|
||||
void nrf_drv_pwm_complex_playback(nrf_drv_pwm_t const * const p_instance,
|
||||
nrf_pwm_sequence_t const * p_sequence_0,
|
||||
nrf_pwm_sequence_t const * p_sequence_1,
|
||||
uint16_t playback_count,
|
||||
uint32_t flags)
|
||||
{
|
||||
pwm_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
|
||||
ASSERT(p_cb->state != NRF_DRV_STATE_UNINITIALIZED);
|
||||
ASSERT(playback_count > 0);
|
||||
ASSERT(nrf_drv_is_in_RAM(p_sequence_0->values.p_raw));
|
||||
ASSERT(nrf_drv_is_in_RAM(p_sequence_1->values.p_raw));
|
||||
|
||||
nrf_pwm_sequence_set(p_instance->p_registers, 0, p_sequence_0);
|
||||
nrf_pwm_sequence_set(p_instance->p_registers, 1, p_sequence_1);
|
||||
nrf_pwm_loop_set(p_instance->p_registers, playback_count);
|
||||
|
||||
uint32_t shorts_mask;
|
||||
if (flags & NRF_DRV_PWM_FLAG_STOP)
|
||||
{
|
||||
shorts_mask = NRF_PWM_SHORT_LOOPSDONE_STOP_MASK;
|
||||
}
|
||||
else if (flags & NRF_DRV_PWM_FLAG_LOOP)
|
||||
{
|
||||
shorts_mask = NRF_PWM_SHORT_LOOPSDONE_SEQSTART0_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
shorts_mask = 0;
|
||||
}
|
||||
nrf_pwm_shorts_set(p_instance->p_registers, shorts_mask);
|
||||
|
||||
start_playback(p_instance, p_cb, flags, NRF_PWM_TASK_SEQSTART0);
|
||||
}
|
||||
|
||||
|
||||
bool nrf_drv_pwm_stop(nrf_drv_pwm_t const * const p_instance,
|
||||
bool wait_until_stopped)
|
||||
{
|
||||
ASSERT(m_cb[p_instance->drv_inst_idx].state != NRF_DRV_STATE_UNINITIALIZED);
|
||||
|
||||
if (nrf_drv_pwm_is_stopped(p_instance))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
nrf_pwm_task_trigger(p_instance->p_registers, NRF_PWM_TASK_STOP);
|
||||
|
||||
do {
|
||||
if (nrf_drv_pwm_is_stopped(p_instance))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
} while (wait_until_stopped);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool nrf_drv_pwm_is_stopped(nrf_drv_pwm_t const * const p_instance)
|
||||
{
|
||||
pwm_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
|
||||
ASSERT(p_cb->state != NRF_DRV_STATE_UNINITIALIZED);
|
||||
|
||||
// If the event handler is used (interrupts are enabled), the state will
|
||||
// be changed in interrupt handler when the STOPPED event occurs.
|
||||
if (p_cb->state != NRF_DRV_STATE_POWERED_ON)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// If interrupts are disabled, we must check the STOPPED event here.
|
||||
if (nrf_pwm_event_check(p_instance->p_registers, NRF_PWM_EVENT_STOPPED))
|
||||
{
|
||||
p_cb->state = NRF_DRV_STATE_INITIALIZED;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static void irq_handler(NRF_PWM_Type * p_pwm, pwm_control_block_t * p_cb)
|
||||
{
|
||||
ASSERT(p_cb->handler);
|
||||
|
||||
// The SEQEND0 and SEQEND1 events are only handled when the user asked for
|
||||
// it (by setting proper flags when starting the playback).
|
||||
if (nrf_pwm_int_enable_check(p_pwm, NRF_PWM_INT_SEQEND0_MASK) &&
|
||||
nrf_pwm_event_check(p_pwm, NRF_PWM_EVENT_SEQEND0))
|
||||
{
|
||||
nrf_pwm_event_clear(p_pwm, NRF_PWM_EVENT_SEQEND0);
|
||||
p_cb->handler(NRF_DRV_PWM_EVT_END_SEQ0);
|
||||
}
|
||||
if (nrf_pwm_int_enable_check(p_pwm, NRF_PWM_INT_SEQEND1_MASK) &&
|
||||
nrf_pwm_event_check(p_pwm, NRF_PWM_EVENT_SEQEND1))
|
||||
{
|
||||
nrf_pwm_event_clear(p_pwm, NRF_PWM_EVENT_SEQEND1);
|
||||
p_cb->handler(NRF_DRV_PWM_EVT_END_SEQ1);
|
||||
}
|
||||
|
||||
// The LOOPSDONE event is handled by default, but this can be disabled.
|
||||
if (nrf_pwm_int_enable_check(p_pwm, NRF_PWM_INT_LOOPSDONE_MASK) &&
|
||||
nrf_pwm_event_check(p_pwm, NRF_PWM_EVENT_LOOPSDONE))
|
||||
{
|
||||
nrf_pwm_event_clear(p_pwm, NRF_PWM_EVENT_LOOPSDONE);
|
||||
p_cb->handler(NRF_DRV_PWM_EVT_FINISHED);
|
||||
}
|
||||
|
||||
if (nrf_pwm_event_check(p_pwm, NRF_PWM_EVENT_STOPPED))
|
||||
{
|
||||
nrf_pwm_event_clear(p_pwm, NRF_PWM_EVENT_STOPPED);
|
||||
|
||||
p_cb->state = NRF_DRV_STATE_INITIALIZED;
|
||||
|
||||
p_cb->handler(NRF_DRV_PWM_EVT_STOPPED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if PWM0_ENABLED
|
||||
void PWM0_IRQHandler(void)
|
||||
{
|
||||
irq_handler(NRF_PWM0, &m_cb[PWM0_INSTANCE_INDEX]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if PWM1_ENABLED
|
||||
void PWM1_IRQHandler(void)
|
||||
{
|
||||
irq_handler(NRF_PWM1, &m_cb[PWM1_INSTANCE_INDEX]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if PWM2_ENABLED
|
||||
void PWM2_IRQHandler(void)
|
||||
{
|
||||
irq_handler(NRF_PWM2, &m_cb[PWM2_INSTANCE_INDEX]);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1,426 +0,0 @@
|
|||
/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is property of Nordic Semiconductor ASA.
|
||||
* Terms and conditions of usage are described in detail in NORDIC
|
||||
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* Licensees are granted free, non-transferable use of the information. NO
|
||||
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
|
||||
* the file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file
|
||||
* @addtogroup nrf_pwm PWM HAL and driver
|
||||
* @ingroup nrf_drivers
|
||||
* @brief @tagAPI52 Pulse Width Modulation (PWM) module APIs.
|
||||
*
|
||||
* @defgroup nrf_drv_pwm PWM driver
|
||||
* @{
|
||||
* @ingroup nrf_pwm
|
||||
* @brief @tagAPI52 Pulse Width Modulation (PWM) module driver.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NRF_DRV_PWM_H__
|
||||
#define NRF_DRV_PWM_H__
|
||||
|
||||
#include "nordic_common.h"
|
||||
#include "nrf_drv_config.h"
|
||||
#include "nrf_pwm.h"
|
||||
#include "sdk_errors.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief PWM driver instance data structure.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
NRF_PWM_Type * p_registers; ///< Pointer to the structure with PWM peripheral instance registers.
|
||||
uint8_t drv_inst_idx; ///< Driver instance index.
|
||||
} nrf_drv_pwm_t;
|
||||
|
||||
/**
|
||||
* @brief Macro for creating a PWM driver instance.
|
||||
*/
|
||||
#define NRF_DRV_PWM_INSTANCE(id) \
|
||||
{ \
|
||||
.p_registers = CONCAT_2(NRF_PWM, id), \
|
||||
.drv_inst_idx = CONCAT_3(PWM, id, _INSTANCE_INDEX), \
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief This value can be provided instead of a pin number for any channel
|
||||
* to specify that its output is not used and therefore does not need
|
||||
* to be connected to a pin.
|
||||
*/
|
||||
#define NRF_DRV_PWM_PIN_NOT_USED 0xFF
|
||||
|
||||
/**
|
||||
* @brief This value can be added to a pin number to inverse its polarity
|
||||
* (set idle state = 1).
|
||||
*/
|
||||
#define NRF_DRV_PWM_PIN_INVERTED 0x80
|
||||
|
||||
/**
|
||||
* @brief PWM driver configuration structure.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t output_pins[NRF_PWM_CHANNEL_COUNT]; ///< Pin numbers for individual output channels (optional).
|
||||
/**< Use @ref NRF_DRV_PWM_PIN_NOT_USED
|
||||
* if a given output channel is not needed. */
|
||||
uint8_t irq_priority; ///< Interrupt priority.
|
||||
nrf_pwm_clk_t base_clock; ///< Base clock frequency.
|
||||
nrf_pwm_mode_t count_mode; ///< Operating mode of the pulse generator counter.
|
||||
uint16_t top_value; ///< Value up to which the pulse generator counter counts.
|
||||
nrf_pwm_dec_load_t load_mode; ///< Mode of loading sequence data from RAM.
|
||||
nrf_pwm_dec_step_t step_mode; ///< Mode of advancing the active sequence.
|
||||
} nrf_drv_pwm_config_t;
|
||||
|
||||
/**
|
||||
* @brief PWM driver default configuration.
|
||||
*/
|
||||
#define NRF_DRV_PWM_DEFAULT_CONFIG(id) \
|
||||
{ \
|
||||
.output_pins = { CONCAT_3(PWM, id, _CONFIG_OUT0_PIN), \
|
||||
CONCAT_3(PWM, id, _CONFIG_OUT1_PIN), \
|
||||
CONCAT_3(PWM, id, _CONFIG_OUT2_PIN), \
|
||||
CONCAT_3(PWM, id, _CONFIG_OUT3_PIN) }, \
|
||||
.irq_priority = CONCAT_3(PWM, id, _CONFIG_IRQ_PRIORITY), \
|
||||
.base_clock = CONCAT_3(PWM, id, _CONFIG_BASE_CLOCK), \
|
||||
.count_mode = CONCAT_3(PWM, id, _CONFIG_COUNT_MODE), \
|
||||
.top_value = CONCAT_3(PWM, id, _CONFIG_TOP_VALUE), \
|
||||
.load_mode = CONCAT_3(PWM, id, _CONFIG_LOAD_MODE), \
|
||||
.step_mode = CONCAT_3(PWM, id, _CONFIG_STEP_MODE), \
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief PWM flags providing additional playback options.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NRF_DRV_PWM_FLAG_STOP = 0x01, /**< When the requested playback is finished,
|
||||
the peripheral should be stopped.
|
||||
@note The STOP task is triggered when
|
||||
the last value of the final sequence is
|
||||
loaded from RAM, and the peripheral stops
|
||||
at the end of the current PWM period.
|
||||
For sequences with configured repeating
|
||||
of duty cycle values, this might result in
|
||||
less than the requested number of repeats
|
||||
of the last value. */
|
||||
NRF_DRV_PWM_FLAG_LOOP = 0x02, /**< When the requested playback is finished,
|
||||
it should be started from the beginning.
|
||||
This flag is ignored if used together
|
||||
with @ref NRF_DRV_PWM_FLAG_STOP. */
|
||||
NRF_DRV_PWM_FLAG_SIGNAL_END_SEQ0 = 0x04, /**< The event handler should be
|
||||
called when the last value
|
||||
from sequence 0 is loaded. */
|
||||
NRF_DRV_PWM_FLAG_SIGNAL_END_SEQ1 = 0x08, /**< The event handler should be
|
||||
called when the last value
|
||||
from sequence 1 is loaded. */
|
||||
NRF_DRV_PWM_FLAG_NO_EVT_FINISHED = 0x10, /**< The playback finished event
|
||||
(enabled by default) should be
|
||||
suppressed. */
|
||||
} nrf_drv_pwm_flag_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief PWM driver event type.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NRF_DRV_PWM_EVT_FINISHED, ///< Sequence playback finished.
|
||||
NRF_DRV_PWM_EVT_END_SEQ0, /**< End of sequence 0 reached. Its data can be
|
||||
safely modified now. */
|
||||
NRF_DRV_PWM_EVT_END_SEQ1, /**< End of sequence 1 reached. Its data can be
|
||||
safely modified now. */
|
||||
NRF_DRV_PWM_EVT_STOPPED, ///< The PWM peripheral has been stopped.
|
||||
} nrf_drv_pwm_evt_type_t;
|
||||
|
||||
/**
|
||||
* @brief PWM driver event handler type.
|
||||
*/
|
||||
typedef void (* nrf_drv_pwm_handler_t)(nrf_drv_pwm_evt_type_t event_type);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the PWM driver.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] p_config Pointer to the structure with initial configuration.
|
||||
* If NULL, the default configuration is used.
|
||||
* @param[in] handler Event handler provided by the user. If NULL is passed
|
||||
* instead, event notifications are not done and PWM
|
||||
* interrupts are disabled.
|
||||
*
|
||||
* @retval NRF_SUCCESS If initialization was successful.
|
||||
* @retval NRF_ERROR_INVALID_STATE If the driver was already initialized.
|
||||
*/
|
||||
ret_code_t nrf_drv_pwm_init(nrf_drv_pwm_t const * const p_instance,
|
||||
nrf_drv_pwm_config_t const * p_config,
|
||||
nrf_drv_pwm_handler_t handler);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing the PWM driver.
|
||||
*
|
||||
* If any sequence playback is in progress, it is stopped immediately.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
void nrf_drv_pwm_uninit(nrf_drv_pwm_t const * const p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for starting a single sequence playback.
|
||||
*
|
||||
* To take advantage of the looping mechanism in the PWM peripheral, both
|
||||
* sequences must be used (single sequence can be played back only once by
|
||||
* the peripheral). Therefore, the provided sequence is internally set and
|
||||
* played back as both sequence 0 and sequence 1. Consequently, if end of
|
||||
* sequence notifications are required, events for both sequences should be
|
||||
* used (that means that both the @ref NRF_DRV_PWM_FLAG_SIGNAL_END_SEQ0 flag
|
||||
* and the @ref NRF_DRV_PWM_FLAG_SIGNAL_END_SEQ1 flag should be specified and
|
||||
* the @ref NRF_DRV_PWM_EVT_END_SEQ0 event and the @ref NRF_DRV_PWM_EVT_END_SEQ1
|
||||
* event should be handled in the same way).
|
||||
*
|
||||
* @note The array containing the duty cycle values for the specified sequence
|
||||
* must be in RAM and cannot be allocated on stack.
|
||||
* For detailed information, see @ref nrf_pwm_sequence_t.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] p_sequence Sequence to be played back.
|
||||
* @param[in] playback_count Number of playbacks to be performed (must not be 0).
|
||||
* @param[in] flags Additional options. Pass any combination of
|
||||
* @ref nrf_drv_pwm_flag_t "playback flags", or 0
|
||||
* for default settings.
|
||||
*/
|
||||
void nrf_drv_pwm_simple_playback(nrf_drv_pwm_t const * const p_instance,
|
||||
nrf_pwm_sequence_t const * p_sequence,
|
||||
uint16_t playback_count,
|
||||
uint32_t flags);
|
||||
|
||||
/**
|
||||
* @brief Function for starting a two-sequence playback.
|
||||
*
|
||||
* @note The array containing the duty cycle values for the specified sequence
|
||||
* must be in RAM and cannot be allocated on stack.
|
||||
* For detailed information, see @ref nrf_pwm_sequence_t.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] p_sequence_0 First sequence to be played back.
|
||||
* @param[in] p_sequence_1 Second sequence to be played back.
|
||||
* @param[in] playback_count Number of playbacks to be performed (must not be 0).
|
||||
* @param[in] flags Additional options. Pass any combination of
|
||||
* @ref nrf_drv_pwm_flag_t "playback flags", or 0
|
||||
* for default settings.
|
||||
*/
|
||||
void nrf_drv_pwm_complex_playback(nrf_drv_pwm_t const * const p_instance,
|
||||
nrf_pwm_sequence_t const * p_sequence_0,
|
||||
nrf_pwm_sequence_t const * p_sequence_1,
|
||||
uint16_t playback_count,
|
||||
uint32_t flags);
|
||||
|
||||
/**
|
||||
* @brief Function for advancing the active sequence.
|
||||
*
|
||||
* This function only applies to @ref NRF_PWM_STEP_TRIGGERED mode.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_drv_pwm_step(nrf_drv_pwm_t const * const p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for stopping the sequence playback.
|
||||
*
|
||||
* The playback is stopped at the end of the current PWM period.
|
||||
* This means that if the active sequence is configured to repeat each duty
|
||||
* cycle value for a certain number of PWM periods, the last played value
|
||||
* might appear on the output less times than requested.
|
||||
*
|
||||
* @note This function can be instructed to wait until the playback is stopped
|
||||
* (by setting @p wait_until_stopped to true). Note that, depending on
|
||||
* the length of the PMW period, this might take a significant amount of
|
||||
* time. Alternatively, the @ref nrf_drv_pwm_is_stopped function can be
|
||||
* used to poll the status, or the @ref NRF_DRV_PWM_EVT_STOPPED event can
|
||||
* be used to get the notification when the playback is stopped, provided
|
||||
* the event handler is defined.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] wait_until_stopped If true, the function will not return until
|
||||
* the playback is stopped.
|
||||
*
|
||||
* @retval true If the PWM peripheral is stopped.
|
||||
* @retval false If the PWM peripheral is not stopped.
|
||||
*/
|
||||
bool nrf_drv_pwm_stop(nrf_drv_pwm_t const * const p_instance,
|
||||
bool wait_until_stopped);
|
||||
|
||||
/**
|
||||
* @brief Function for checking the status of the PWM peripheral.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
*
|
||||
* @retval true If the PWM peripheral is stopped.
|
||||
* @retval false If the PWM peripheral is not stopped.
|
||||
*/
|
||||
bool nrf_drv_pwm_is_stopped(nrf_drv_pwm_t const * const p_instance);
|
||||
|
||||
/**
|
||||
* @brief Function for updating the sequence data during playback.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] seq_id Identifier of the sequence (0 or 1).
|
||||
* @param[in] p_sequence Pointer to the new sequence definition.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_drv_pwm_sequence_update(
|
||||
nrf_drv_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
nrf_pwm_sequence_t const * p_sequence);
|
||||
|
||||
/**
|
||||
* @brief Function for updating the pointer to the duty cycle values
|
||||
* in the specified sequence during playback.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] seq_id Identifier of the sequence (0 or 1).
|
||||
* @param[in] values New pointer to the duty cycle values.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_drv_pwm_sequence_values_update(
|
||||
nrf_drv_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
nrf_pwm_values_t values);
|
||||
|
||||
/**
|
||||
* @brief Function for updating the number of duty cycle values
|
||||
* in the specified sequence during playback.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] seq_id Identifier of the sequence (0 or 1).
|
||||
* @param[in] length New number of the duty cycle values.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_drv_pwm_sequence_length_update(
|
||||
nrf_drv_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
uint16_t length);
|
||||
|
||||
/**
|
||||
* @brief Function for updating the number of repeats for duty cycle values
|
||||
* in specified sequence during playback.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] seq_id Identifier of the sequence (0 or 1).
|
||||
* @param[in] repeats New number of repeats.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_drv_pwm_sequence_repeats_update(
|
||||
nrf_drv_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
uint32_t repeats);
|
||||
|
||||
/**
|
||||
* @brief Function for updating the additional delay after the specified
|
||||
* sequence during playback.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] seq_id Identifier of the sequence (0 or 1).
|
||||
* @param[in] end_delay New end delay value (in PWM periods).
|
||||
*/
|
||||
__STATIC_INLINE void nrf_drv_pwm_sequence_end_delay_update(
|
||||
nrf_drv_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
uint32_t end_delay);
|
||||
|
||||
/**
|
||||
* @brief Function for returning the address of a specified PWM task that can
|
||||
* be used in PPI module.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] task Requested task.
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_drv_pwm_task_address_get(
|
||||
nrf_drv_pwm_t const * const p_instance,
|
||||
nrf_pwm_task_t task);
|
||||
|
||||
/**@brief Function for returning the address of a specified PWM event that can
|
||||
* be used in PPI module.
|
||||
*
|
||||
* @param[in] p_instance Pointer to the driver instance structure.
|
||||
* @param[in] event Requested event.
|
||||
*
|
||||
* @return Event address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_drv_pwm_event_address_get(
|
||||
nrf_drv_pwm_t const * const p_instance,
|
||||
nrf_pwm_event_t event);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
__STATIC_INLINE void nrf_drv_pwm_step(nrf_drv_pwm_t const * const p_instance)
|
||||
{
|
||||
nrf_pwm_task_trigger(p_instance->p_registers, NRF_PWM_TASK_NEXTSTEP);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_drv_pwm_sequence_update(
|
||||
nrf_drv_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
nrf_pwm_sequence_t const * p_sequence)
|
||||
{
|
||||
nrf_pwm_sequence_set(p_instance->p_registers, seq_id, p_sequence);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_drv_pwm_sequence_values_update(
|
||||
nrf_drv_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
nrf_pwm_values_t values)
|
||||
{
|
||||
nrf_pwm_seq_ptr_set(p_instance->p_registers, seq_id, values.p_raw);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_drv_pwm_sequence_length_update(
|
||||
nrf_drv_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
uint16_t length)
|
||||
{
|
||||
nrf_pwm_seq_cnt_set(p_instance->p_registers, seq_id, length);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_drv_pwm_sequence_repeats_update(
|
||||
nrf_drv_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
uint32_t repeats)
|
||||
{
|
||||
nrf_pwm_seq_refresh_set(p_instance->p_registers, seq_id, repeats);
|
||||
}
|
||||
|
||||
__STATIC_INLINE void nrf_drv_pwm_sequence_end_delay_update(
|
||||
nrf_drv_pwm_t const * const p_instance,
|
||||
uint8_t seq_id,
|
||||
uint32_t end_delay)
|
||||
{
|
||||
nrf_pwm_seq_end_delay_set(p_instance->p_registers, seq_id, end_delay);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_drv_pwm_task_address_get(
|
||||
nrf_drv_pwm_t const * const p_instance,
|
||||
nrf_pwm_task_t task)
|
||||
{
|
||||
return nrf_pwm_task_address_get(p_instance->p_registers, task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_drv_pwm_event_address_get(
|
||||
nrf_drv_pwm_t const * const p_instance,
|
||||
nrf_pwm_event_t event)
|
||||
{
|
||||
return nrf_pwm_event_address_get(p_instance->p_registers, event);
|
||||
}
|
||||
|
||||
#endif // SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
#endif // NRF_DRV_PWM_H__
|
||||
|
||||
/** @} */
|
||||
|
|
@ -1,536 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "nrf_drv_saadc.h"
|
||||
#include "nrf_assert.h"
|
||||
#include "nordic_common.h"
|
||||
#include "nrf_drv_common.h"
|
||||
#include "app_util_platform.h"
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NRF_SAADC_STATE_IDLE = 0,
|
||||
NRF_SAADC_STATE_BUSY = 1
|
||||
} nrf_saadc_state_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
nrf_saadc_input_t pselp;
|
||||
nrf_saadc_input_t pseln;
|
||||
} nrf_saadc_psel_buffer;
|
||||
|
||||
static const nrf_drv_saadc_config_t m_default_config = NRF_DRV_SAADC_DEFAULT_CONFIG;
|
||||
|
||||
/** @brief SAADC control block.*/
|
||||
typedef struct
|
||||
{
|
||||
nrf_drv_saadc_event_handler_t event_handler; ///< Event handler function pointer.
|
||||
volatile nrf_saadc_value_t * p_buffer; ///< Sample buffer.
|
||||
volatile uint16_t buffer_size; ///< Size of the sample buffer.
|
||||
#ifdef NRF52_PAN_28
|
||||
volatile uint16_t buffer_pos; ///< Current sample buffer position.
|
||||
#endif
|
||||
volatile nrf_saadc_value_t * p_secondary_buffer; ///< Secondary sample buffer.
|
||||
uint32_t limits_enabled_flags; ///< Enabled limits flags.
|
||||
uint16_t secondary_buffer_size; ///< Size of the secondary buffer.
|
||||
nrf_saadc_psel_buffer psel[NRF_SAADC_CHANNEL_COUNT]; ///< Pin configurations of SAADC channels.
|
||||
nrf_drv_state_t state; ///< Driver initialization state.
|
||||
nrf_saadc_state_t adc_state; ///< State of the SAADC.
|
||||
#ifdef NRF52_PAN_28
|
||||
uint8_t scan_pos; ///< Current channel scanning position.
|
||||
#endif
|
||||
uint8_t active_channels; ///< Number of enabled SAADC channels.
|
||||
} nrf_drv_saadc_cb_t;
|
||||
|
||||
static nrf_drv_saadc_cb_t m_cb;
|
||||
|
||||
#define LOW_LIMIT_TO_FLAG(channel) ((2*channel+1))
|
||||
#define HIGH_LIMIT_TO_FLAG(channel) ((2*channel))
|
||||
#define FLAG_IDX_TO_EVENT(idx) ((nrf_saadc_event_t)((uint32_t)NRF_SAADC_EVENT_CH0_LIMITH+4*idx))
|
||||
#define LIMIT_EVENT_TO_CHANNEL(event)(uint8_t)(((uint32_t)event-(uint32_t)NRF_SAADC_EVENT_CH0_LIMITH)/8)
|
||||
#define LIMIT_EVENT_TO_LIMIT_TYPE(event)((((uint32_t)event-(uint32_t)NRF_SAADC_EVENT_CH0_LIMITH) & 4) ? \
|
||||
NRF_SAADC_LIMIT_LOW : NRF_SAADC_LIMIT_HIGH)
|
||||
#define HW_TIMEOUT 10000
|
||||
|
||||
|
||||
void SAADC_IRQHandler(void)
|
||||
{
|
||||
if (nrf_saadc_event_check(NRF_SAADC_EVENT_END))
|
||||
{
|
||||
nrf_saadc_event_clear(NRF_SAADC_EVENT_END);
|
||||
#ifdef NRF52_PAN_28
|
||||
if (m_cb.active_channels == 1)
|
||||
{
|
||||
#endif
|
||||
nrf_drv_saadc_evt_t evt;
|
||||
evt.type = NRF_DRV_SAADC_EVT_DONE;
|
||||
evt.data.done.p_buffer = (nrf_saadc_value_t *)m_cb.p_buffer;
|
||||
evt.data.done.size = nrf_saadc_amount_get();
|
||||
|
||||
if (m_cb.p_secondary_buffer == NULL)
|
||||
{
|
||||
m_cb.adc_state = NRF_SAADC_STATE_IDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cb.p_buffer = m_cb.p_secondary_buffer;
|
||||
m_cb.buffer_size = m_cb.secondary_buffer_size;
|
||||
m_cb.p_secondary_buffer = NULL;
|
||||
nrf_saadc_task_trigger(NRF_SAADC_TASK_START);
|
||||
}
|
||||
|
||||
m_cb.event_handler(&evt);
|
||||
#ifdef NRF52_PAN_28
|
||||
}
|
||||
else
|
||||
{
|
||||
//PAN-28: scan mode is not working correctly, emulated by interrupts
|
||||
++(m_cb.buffer_pos);
|
||||
uint16_t buffer_pos = m_cb.buffer_pos;
|
||||
if (buffer_pos == m_cb.buffer_size)
|
||||
{
|
||||
nrf_drv_saadc_evt_t evt;
|
||||
evt.type = NRF_DRV_SAADC_EVT_DONE;
|
||||
evt.data.done.p_buffer = (nrf_saadc_value_t *)(m_cb.p_buffer);
|
||||
evt.data.done.size = m_cb.buffer_size;
|
||||
|
||||
m_cb.adc_state = NRF_SAADC_STATE_IDLE;
|
||||
if (m_cb.p_secondary_buffer == NULL)
|
||||
{
|
||||
m_cb.adc_state = NRF_SAADC_STATE_IDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)nrf_drv_saadc_buffer_convert((nrf_saadc_value_t *)m_cb.p_secondary_buffer, (uint16_t)m_cb.secondary_buffer_size);
|
||||
}
|
||||
m_cb.event_handler(&evt);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t current_scan_pos = m_cb.scan_pos;
|
||||
|
||||
nrf_saadc_channel_input_set(current_scan_pos,
|
||||
NRF_SAADC_INPUT_DISABLED, NRF_SAADC_INPUT_DISABLED);
|
||||
|
||||
nrf_saadc_buffer_init((nrf_saadc_value_t *)(m_cb.p_buffer + m_cb.buffer_pos), 1);
|
||||
// Find the next enabled channel.
|
||||
for (++m_cb.scan_pos; m_cb.scan_pos < NRF_SAADC_CHANNEL_COUNT; ++m_cb.scan_pos)
|
||||
{
|
||||
if (m_cb.psel[m_cb.scan_pos].pselp)
|
||||
{
|
||||
nrf_saadc_channel_input_set(m_cb.scan_pos,
|
||||
m_cb.psel[m_cb.scan_pos].pselp, m_cb.psel[m_cb.scan_pos].pseln);
|
||||
nrf_saadc_task_trigger(NRF_SAADC_TASK_START);
|
||||
nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//if scanning is done prepare for next round.
|
||||
for (uint8_t i = 0; i < NRF_SAADC_CHANNEL_COUNT; ++i)
|
||||
{
|
||||
if (m_cb.psel[i].pselp)
|
||||
{
|
||||
m_cb.scan_pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nrf_saadc_channel_input_set(m_cb.scan_pos,
|
||||
m_cb.psel[m_cb.scan_pos].pselp, m_cb.psel[m_cb.scan_pos].pseln);
|
||||
nrf_saadc_task_trigger(NRF_SAADC_TASK_START);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED))
|
||||
{
|
||||
nrf_saadc_event_clear(NRF_SAADC_EVENT_STOPPED);
|
||||
m_cb.adc_state = NRF_SAADC_STATE_IDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t limit_flags = m_cb.limits_enabled_flags;
|
||||
uint32_t flag_idx;
|
||||
nrf_saadc_event_t event;
|
||||
while (limit_flags)
|
||||
{
|
||||
flag_idx = __CLZ(limit_flags);
|
||||
limit_flags &= ~((1UL<<31) >> flag_idx);
|
||||
event = FLAG_IDX_TO_EVENT(flag_idx);
|
||||
if (nrf_saadc_event_check(event))
|
||||
{
|
||||
nrf_saadc_event_clear(event);
|
||||
nrf_drv_saadc_evt_t evt;
|
||||
evt.type = NRF_DRV_SAADC_EVT_LIMIT;
|
||||
evt.data.limit.channel = LIMIT_EVENT_TO_CHANNEL(event);
|
||||
evt.data.limit.limit_type = LIMIT_EVENT_TO_LIMIT_TYPE(event);
|
||||
m_cb.event_handler(&evt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ret_code_t nrf_drv_saadc_init(nrf_drv_saadc_config_t const * p_config,
|
||||
nrf_drv_saadc_event_handler_t event_handler)
|
||||
{
|
||||
if (m_cb.state != NRF_DRV_STATE_UNINITIALIZED)
|
||||
{
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
if (event_handler == NULL)
|
||||
{
|
||||
return NRF_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (p_config == NULL)
|
||||
{
|
||||
p_config = &m_default_config;
|
||||
}
|
||||
|
||||
m_cb.event_handler = event_handler;
|
||||
nrf_saadc_resolution_set(p_config->resolution);
|
||||
nrf_saadc_oversample_set(p_config->oversample);
|
||||
m_cb.state = NRF_DRV_STATE_INITIALIZED;
|
||||
m_cb.adc_state = NRF_SAADC_STATE_IDLE;
|
||||
m_cb.active_channels = 0;
|
||||
m_cb.limits_enabled_flags = 0;
|
||||
#ifdef NRF52_PAN_28
|
||||
m_cb.buffer_pos = 0;
|
||||
#endif
|
||||
|
||||
nrf_saadc_int_disable(NRF_SAADC_INT_ALL);
|
||||
nrf_saadc_event_clear(NRF_SAADC_EVENT_END);
|
||||
nrf_drv_common_irq_enable(SAADC_IRQn, p_config->interrupt_priority);
|
||||
nrf_saadc_int_enable(NRF_SAADC_INT_END);
|
||||
|
||||
nrf_saadc_enable();
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void nrf_drv_saadc_uninit(void)
|
||||
{
|
||||
ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED);
|
||||
nrf_drv_common_irq_disable(SAADC_IRQn);
|
||||
nrf_saadc_task_trigger(NRF_SAADC_TASK_STOP);
|
||||
|
||||
// Wait for ADC being stopped.
|
||||
uint32_t timeout = HW_TIMEOUT;
|
||||
while (nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED) == 0 && timeout > 0)
|
||||
{
|
||||
--timeout;
|
||||
}
|
||||
ASSERT(timeout > 0);
|
||||
|
||||
nrf_saadc_disable();
|
||||
nrf_saadc_int_disable(NRF_SAADC_INT_ALL);
|
||||
|
||||
m_cb.adc_state = NRF_SAADC_STATE_IDLE;
|
||||
|
||||
for (uint8_t channel = 0; channel < NRF_SAADC_CHANNEL_COUNT; ++channel)
|
||||
{
|
||||
if (m_cb.psel[channel].pselp != NRF_SAADC_INPUT_DISABLED)
|
||||
{
|
||||
(void)nrf_drv_saadc_channel_uninit(channel);
|
||||
}
|
||||
}
|
||||
|
||||
m_cb.state = NRF_DRV_STATE_UNINITIALIZED;
|
||||
}
|
||||
|
||||
|
||||
ret_code_t nrf_drv_saadc_channel_init(uint8_t channel,
|
||||
nrf_saadc_channel_config_t const * const p_config)
|
||||
{
|
||||
ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED);
|
||||
ASSERT(channel < NRF_SAADC_CHANNEL_COUNT);
|
||||
//Oversampling can be used only with one channel.
|
||||
ASSERT((nrf_saadc_oversample_get()==NRF_SAADC_OVERSAMPLE_DISABLED) || (m_cb.active_channels == 0));
|
||||
ASSERT((p_config->pin_p <= NRF_SAADC_INPUT_VDD) && (p_config->pin_p > NRF_SAADC_INPUT_DISABLED));
|
||||
ASSERT(p_config->pin_n <= NRF_SAADC_INPUT_VDD);
|
||||
|
||||
// A channel can only be initialized if the driver is in the idle state.
|
||||
if (m_cb.adc_state == NRF_SAADC_STATE_BUSY)
|
||||
{
|
||||
return NRF_ERROR_BUSY;
|
||||
}
|
||||
|
||||
if (!m_cb.psel[channel].pselp)
|
||||
{
|
||||
++m_cb.active_channels;
|
||||
}
|
||||
m_cb.psel[channel].pselp = p_config->pin_p;
|
||||
m_cb.psel[channel].pseln = p_config->pin_n;
|
||||
nrf_saadc_channel_init(channel, p_config);
|
||||
|
||||
#ifdef NRF52_PAN_28
|
||||
nrf_saadc_channel_input_set(channel, NRF_SAADC_INPUT_DISABLED, NRF_SAADC_INPUT_DISABLED);
|
||||
#else
|
||||
nrf_saadc_channel_input_set(channel, p_config->pin_p, p_config->pin_n);
|
||||
#endif
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ret_code_t nrf_drv_saadc_channel_uninit(uint8_t channel)
|
||||
{
|
||||
ASSERT(channel <= NRF_SAADC_CHANNEL_COUNT)
|
||||
ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED);
|
||||
|
||||
// A channel can only be uninitialized if the driver is in the idle state.
|
||||
if (m_cb.adc_state == NRF_SAADC_STATE_BUSY)
|
||||
{
|
||||
return NRF_ERROR_BUSY;
|
||||
}
|
||||
|
||||
if (m_cb.psel[channel].pselp)
|
||||
{
|
||||
--m_cb.active_channels;
|
||||
}
|
||||
m_cb.psel[channel].pselp = NRF_SAADC_INPUT_DISABLED;
|
||||
m_cb.psel[channel].pseln = NRF_SAADC_INPUT_DISABLED;
|
||||
nrf_saadc_channel_input_set(channel, NRF_SAADC_INPUT_DISABLED, NRF_SAADC_INPUT_DISABLED);
|
||||
nrf_drv_saadc_limits_set(channel, NRF_DRV_SAADC_LIMITL_DISABLED, NRF_DRV_SAADC_LIMITH_DISABLED);
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
ret_code_t nrf_drv_saadc_sample_convert(uint8_t channel, nrf_saadc_value_t * p_value)
|
||||
{
|
||||
if (m_cb.adc_state != NRF_SAADC_STATE_IDLE)
|
||||
{
|
||||
return NRF_ERROR_BUSY;
|
||||
}
|
||||
m_cb.adc_state = NRF_SAADC_STATE_BUSY;
|
||||
nrf_saadc_int_disable(NRF_SAADC_INT_END);
|
||||
nrf_saadc_buffer_init(p_value, 1);
|
||||
#ifndef NRF52_PAN_28
|
||||
if (m_cb.active_channels > 1)
|
||||
{
|
||||
for (uint8_t i = 0; i < NRF_SAADC_CHANNEL_COUNT; ++i)
|
||||
{
|
||||
nrf_saadc_channel_input_set(i, NRF_SAADC_INPUT_DISABLED, NRF_SAADC_INPUT_DISABLED);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
nrf_saadc_channel_input_set(channel,
|
||||
m_cb.psel[channel].pselp, m_cb.psel[channel].pseln);
|
||||
nrf_saadc_task_trigger(NRF_SAADC_TASK_START);
|
||||
nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE);
|
||||
|
||||
uint32_t timeout = HW_TIMEOUT;
|
||||
while (0 == nrf_saadc_event_check(NRF_SAADC_EVENT_END) && timeout > 0)
|
||||
{
|
||||
timeout--;
|
||||
}
|
||||
nrf_saadc_event_clear(NRF_SAADC_EVENT_END);
|
||||
|
||||
#ifdef NRF52_PAN_28
|
||||
nrf_saadc_channel_input_set(channel, NRF_SAADC_INPUT_DISABLED, NRF_SAADC_INPUT_DISABLED);
|
||||
#else
|
||||
if (m_cb.active_channels > 1)
|
||||
{
|
||||
for (uint8_t i = 0; i < NRF_SAADC_CHANNEL_COUNT; ++i)
|
||||
{
|
||||
nrf_saadc_channel_input_set(i, m_cb.psel[i].pselp, m_cb.psel[i].pseln);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
nrf_saadc_int_enable(NRF_SAADC_INT_END);
|
||||
m_cb.adc_state = NRF_SAADC_STATE_IDLE;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
ret_code_t nrf_drv_saadc_buffer_convert(nrf_saadc_value_t * p_buffer, uint16_t size)
|
||||
{
|
||||
ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED);
|
||||
|
||||
nrf_saadc_int_disable(NRF_SAADC_INT_END);
|
||||
if (m_cb.adc_state == NRF_SAADC_STATE_BUSY)
|
||||
{
|
||||
if ( m_cb.p_secondary_buffer)
|
||||
{
|
||||
nrf_saadc_int_enable(NRF_SAADC_INT_END);
|
||||
return NRF_ERROR_BUSY;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cb.p_secondary_buffer = p_buffer;
|
||||
m_cb.secondary_buffer_size = size;
|
||||
#ifdef NRF52_PAN_28
|
||||
if (m_cb.active_channels == 1)
|
||||
#endif
|
||||
{
|
||||
while (nrf_saadc_event_check(NRF_SAADC_EVENT_STARTED) == 0);
|
||||
nrf_saadc_event_clear(NRF_SAADC_EVENT_STARTED);
|
||||
nrf_saadc_buffer_init(p_buffer, size);
|
||||
}
|
||||
nrf_saadc_int_enable(NRF_SAADC_INT_END);
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
}
|
||||
nrf_saadc_int_enable(NRF_SAADC_INT_END);
|
||||
m_cb.adc_state = NRF_SAADC_STATE_BUSY;
|
||||
|
||||
#ifdef NRF52_PAN_28
|
||||
m_cb.scan_pos = NRF_SAADC_CHANNEL_COUNT;
|
||||
for (uint8_t i = 0; i < NRF_SAADC_CHANNEL_COUNT; ++i)
|
||||
{
|
||||
if (m_cb.psel[i].pselp)
|
||||
{
|
||||
m_cb.scan_pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Find the first enabled channel.
|
||||
if (m_cb.scan_pos >= NRF_SAADC_CHANNEL_COUNT)
|
||||
{
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
m_cb.buffer_pos = 0;
|
||||
#endif
|
||||
m_cb.p_buffer = p_buffer;
|
||||
m_cb.buffer_size = size;
|
||||
m_cb.p_secondary_buffer = NULL;
|
||||
|
||||
#ifdef NRF52_PAN_28
|
||||
nrf_saadc_channel_input_set(m_cb.scan_pos,
|
||||
m_cb.psel[m_cb.scan_pos].pselp, m_cb.psel[m_cb.scan_pos].pseln);
|
||||
|
||||
if (m_cb.active_channels == 1)
|
||||
{
|
||||
nrf_saadc_buffer_init(p_buffer, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
nrf_saadc_buffer_init(p_buffer, 1);
|
||||
}
|
||||
#else
|
||||
nrf_saadc_buffer_init(p_buffer, size);
|
||||
#endif
|
||||
|
||||
nrf_saadc_event_clear(NRF_SAADC_EVENT_STARTED);
|
||||
nrf_saadc_task_trigger(NRF_SAADC_TASK_START);
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
ret_code_t nrf_drv_saadc_sample()
|
||||
{
|
||||
ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED);
|
||||
|
||||
ret_code_t err_code = NRF_SUCCESS;
|
||||
if (m_cb.adc_state == NRF_SAADC_STATE_IDLE)
|
||||
{
|
||||
err_code = NRF_ERROR_BUSY;
|
||||
}
|
||||
else
|
||||
{
|
||||
nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE);
|
||||
}
|
||||
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
bool nrf_drv_saadc_is_busy(void)
|
||||
{
|
||||
return (m_cb.adc_state == NRF_SAADC_STATE_BUSY);
|
||||
}
|
||||
|
||||
void nrf_drv_saadc_abort(void)
|
||||
{
|
||||
if (nrf_drv_saadc_is_busy())
|
||||
{
|
||||
nrf_saadc_event_clear(NRF_SAADC_EVENT_STOPPED);
|
||||
nrf_saadc_task_trigger(NRF_SAADC_TASK_STOP);
|
||||
|
||||
// Wait for ADC being stopped.
|
||||
uint32_t timeout = HW_TIMEOUT;
|
||||
while ((m_cb.adc_state != NRF_SAADC_STATE_IDLE) && (timeout > 0))
|
||||
{
|
||||
--timeout;
|
||||
}
|
||||
ASSERT(timeout > 0);
|
||||
|
||||
m_cb.p_buffer = 0;
|
||||
m_cb.p_secondary_buffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void nrf_drv_saadc_limits_set(uint8_t channel, int16_t limit_low, int16_t limit_high)
|
||||
{
|
||||
ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED);
|
||||
ASSERT(m_cb.event_handler); // only non blocking mode supported
|
||||
ASSERT(limit_low>=NRF_DRV_SAADC_LIMITL_DISABLED);
|
||||
ASSERT(limit_high<=NRF_DRV_SAADC_LIMITH_DISABLED);
|
||||
ASSERT(limit_low<limit_high);
|
||||
nrf_saadc_channel_limits_set(channel, limit_low, limit_high);
|
||||
|
||||
uint32_t int_mask = nrf_saadc_limit_int_get(channel, NRF_SAADC_LIMIT_LOW);
|
||||
if (limit_low == NRF_DRV_SAADC_LIMITL_DISABLED)
|
||||
{
|
||||
m_cb.limits_enabled_flags &= ~(0x80000000 >> LOW_LIMIT_TO_FLAG(channel));
|
||||
nrf_saadc_int_disable(int_mask);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cb.limits_enabled_flags |= (0x80000000 >> LOW_LIMIT_TO_FLAG(channel));
|
||||
nrf_saadc_int_enable(int_mask);
|
||||
}
|
||||
|
||||
int_mask = nrf_saadc_limit_int_get(channel, NRF_SAADC_LIMIT_HIGH);
|
||||
if (limit_high == NRF_DRV_SAADC_LIMITH_DISABLED)
|
||||
{
|
||||
m_cb.limits_enabled_flags &= ~(0x80000000 >> HIGH_LIMIT_TO_FLAG(channel));
|
||||
nrf_saadc_int_disable(int_mask);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cb.limits_enabled_flags |= (0x80000000 >> HIGH_LIMIT_TO_FLAG(channel));
|
||||
nrf_saadc_int_enable(int_mask);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,330 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @addtogroup nrf_saadc SAADC HAL and driver
|
||||
* @ingroup nrf_drivers
|
||||
* @brief @tagAPI52 Successive Approximation Analog-to-Digital Converter (SAADC) APIs.
|
||||
* @details The SAADC HAL provides basic APIs for accessing the registers of the SAADC peripheral.
|
||||
* The SAADC driver provides APIs on a higher level.
|
||||
*
|
||||
* @defgroup nrf_drv_saadc SAADC driver
|
||||
* @{
|
||||
* @ingroup nrf_saadc
|
||||
*
|
||||
* @brief @tagAPI52 Successive Approximation Analog-to-Digital Converter (SAADC) driver.
|
||||
*/
|
||||
|
||||
#ifndef NRF_DRV_SAADC_H__
|
||||
#define NRF_DRV_SAADC_H__
|
||||
|
||||
#include "nrf_drv_config.h"
|
||||
#include "nrf_saadc.h"
|
||||
#include "sdk_errors.h"
|
||||
|
||||
/**
|
||||
* @brief Value that should be set as high limit to disable limit detection.
|
||||
*/
|
||||
#define NRF_DRV_SAADC_LIMITH_DISABLED (2047)
|
||||
/**
|
||||
* @brief Value that should be set as low limit to disable limit detection.
|
||||
*/
|
||||
#define NRF_DRV_SAADC_LIMITL_DISABLED (-2048)
|
||||
|
||||
/**
|
||||
* @brief Macro for setting @ref nrf_drv_saadc_config_t to default settings.
|
||||
*/
|
||||
#define NRF_DRV_SAADC_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.resolution = SAADC_CONFIG_RESOLUTION, \
|
||||
.oversample = SAADC_CONFIG_OVERSAMPLE, \
|
||||
.interrupt_priority = SAADC_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Macro for setting @ref nrf_saadc_channel_config_t to default settings
|
||||
* in single ended mode.
|
||||
*
|
||||
* @param PIN_P Analog input.
|
||||
*/
|
||||
#define NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(PIN_P) \
|
||||
{ \
|
||||
.resistor_p = NRF_SAADC_RESISTOR_DISABLED, \
|
||||
.resistor_n = NRF_SAADC_RESISTOR_DISABLED, \
|
||||
.gain = NRF_SAADC_GAIN1_6, \
|
||||
.reference = NRF_SAADC_REFERENCE_INTERNAL, \
|
||||
.acq_time = NRF_SAADC_ACQTIME_10US, \
|
||||
.mode = NRF_SAADC_MODE_SINGLE_ENDED, \
|
||||
.pin_p = (nrf_saadc_input_t)(PIN_P), \
|
||||
.pin_n = NRF_SAADC_INPUT_DISABLED \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Macro for setting @ref nrf_saadc_channel_config_t to default settings
|
||||
* in differential mode.
|
||||
*
|
||||
* @param PIN_P Positive analog input.
|
||||
* @param PIN_N Negative analog input.
|
||||
*/
|
||||
#define NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL(PIN_P, PIN_N) \
|
||||
{ \
|
||||
.resistor_p = NRF_SAADC_RESISTOR_DISABLED, \
|
||||
.resistor_n = NRF_SAADC_RESISTOR_DISABLED, \
|
||||
.gain = NRF_SAADC_GAIN1_6, \
|
||||
.reference = NRF_SAADC_REFERENCE_INTERNAL, \
|
||||
.acq_time = NRF_SAADC_ACQTIME_10US, \
|
||||
.mode = NRF_SAADC_MODE_DIFFERENTIAL, \
|
||||
.pin_p = (nrf_saadc_input_t)(PIN_P), \
|
||||
.pin_n = (nrf_saadc_input_t)(PIN_N) \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Analog-to-digital converter driver configuration structure.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
nrf_saadc_resolution_t resolution; ///< Resolution configuration.
|
||||
nrf_saadc_oversample_t oversample; ///< Oversampling configuration.
|
||||
uint8_t interrupt_priority; ///< Interrupt priority.
|
||||
} nrf_drv_saadc_config_t;
|
||||
|
||||
/**
|
||||
* @brief Driver event types.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NRF_DRV_SAADC_EVT_DONE, ///< Event generated when the buffer is filled with samples.
|
||||
NRF_DRV_SAADC_EVT_LIMIT, ///< Event generated after one of the limits is reached.
|
||||
} nrf_drv_saadc_evt_type_t;
|
||||
|
||||
/**
|
||||
* @brief Analog-to-digital converter driver done event data.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
nrf_saadc_value_t * p_buffer; ///< Pointer to buffer with converted samples.
|
||||
uint16_t size; ///< Number of samples in the buffer.
|
||||
} nrf_drv_saadc_done_evt_t;
|
||||
|
||||
/**
|
||||
* @brief Analog-to-digital converter driver limit event data.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t channel; ///< Channel on which the limit was detected.
|
||||
nrf_saadc_limit_t limit_type; ///< Type of limit detected.
|
||||
} nrf_drv_saadc_limit_evt_t;
|
||||
|
||||
/**
|
||||
* @brief Analog-to-digital converter driver event structure.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
nrf_drv_saadc_evt_type_t type; ///< Event type.
|
||||
union
|
||||
{
|
||||
nrf_drv_saadc_done_evt_t done; ///< Data for @ref NRF_DRV_SAADC_EVT_DONE event.
|
||||
nrf_drv_saadc_limit_evt_t limit;///< Data for @ref NRF_DRV_SAADC_EVT_LIMIT event.
|
||||
} data;
|
||||
} nrf_drv_saadc_evt_t;
|
||||
|
||||
/**
|
||||
* @brief ADC event handler.
|
||||
*
|
||||
* @param[in] p_event Pointer to an ADC event. The event structure is allocated on
|
||||
* the stack, so it is valid only within the context of
|
||||
* the event handler.
|
||||
*/
|
||||
typedef void (*nrf_drv_saadc_event_handler_t)(nrf_drv_saadc_evt_t const * p_event);
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the SAADC.
|
||||
*
|
||||
* @param[in] p_config Pointer to a configuration structure. If NULL, the default one is used.
|
||||
* @param[in] event_handler Event handler provided by the user.
|
||||
*
|
||||
* @retval NRF_SUCCESS If initialization was successful.
|
||||
* @retval NRF_ERROR_INVALID_STATE If the driver is already initialized.
|
||||
* @retval NRF_ERROR_INVALID_PARAM If event_handler is NULL.
|
||||
*/
|
||||
ret_code_t nrf_drv_saadc_init(nrf_drv_saadc_config_t const * p_config,
|
||||
nrf_drv_saadc_event_handler_t event_handler);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing the SAADC.
|
||||
*
|
||||
* This function stops all ongoing conversions and disables all channels.
|
||||
*/
|
||||
void nrf_drv_saadc_uninit(void);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a SAMPLE SAADC task.
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_drv_saadc_sample_task_get(void)
|
||||
{
|
||||
return nrf_saadc_task_address_get(NRF_SAADC_TASK_SAMPLE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for initializing an SAADC channel.
|
||||
*
|
||||
* This function configures and enables the channel.
|
||||
*
|
||||
* @retval NRF_SUCCESS If initialization was successful.
|
||||
* @retval NRF_ERROR_INVALID_STATE If the ADC was not initialized.
|
||||
* @retval NRF_ERROR_NO_MEM If the specified channel was already allocated.
|
||||
*/
|
||||
ret_code_t nrf_drv_saadc_channel_init(uint8_t channel,
|
||||
nrf_saadc_channel_config_t const * const p_config);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing an SAADC channel.
|
||||
*
|
||||
* @retval NRF_SUCCESS If uninitialization was successful.
|
||||
* @retval NRF_ERROR_BUSY If the ADC is busy.
|
||||
*/
|
||||
ret_code_t nrf_drv_saadc_channel_uninit(uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Function for starting SAADC sampling.
|
||||
*
|
||||
* @retval NRF_SUCCESS If ADC sampling was triggered.
|
||||
* @retval NRF_ERROR_BUSY If ADC is in idle state.
|
||||
*/
|
||||
ret_code_t nrf_drv_saadc_sample(void);
|
||||
|
||||
/**
|
||||
* @brief Blocking function for executing a single ADC conversion.
|
||||
*
|
||||
* This function selects the desired input, starts a single conversion,
|
||||
* waits for it to finish, and returns the result.
|
||||
*
|
||||
* The function will fail if ADC is busy.
|
||||
*
|
||||
* @param[in] channel Channel.
|
||||
* @param[out] p_value Pointer to the location where the result should be placed.
|
||||
*
|
||||
* @retval NRF_SUCCESS If conversion was successful.
|
||||
* @retval NRF_ERROR_BUSY If the ADC driver is busy.
|
||||
*/
|
||||
ret_code_t nrf_drv_saadc_sample_convert(uint8_t channel, nrf_saadc_value_t * p_value);
|
||||
|
||||
/**
|
||||
* @brief Function for issuing conversion of data to the buffer.
|
||||
*
|
||||
* This function is non-blocking. The application is notified about filling the buffer by the event handler.
|
||||
* Conversion will be done on all enabled channels. If the ADC is in idle state, the function will set up Easy
|
||||
* DMA for the conversion. The ADC will be ready for sampling and wait for the SAMPLE task. It can be
|
||||
* triggered manually by the @ref nrf_drv_saadc_sample function or by PPI using the @ref NRF_SAADC_TASK_SAMPLE
|
||||
* task. If one buffer is already set and the conversion is ongoing, calling this function will
|
||||
* result in queuing the given buffer. The driver will start filling the issued buffer when the first one is
|
||||
* completed. If the function is called again before the first buffer is filled, it will return with error.
|
||||
*
|
||||
* @param[in] buffer Result buffer.
|
||||
* @param[in] size Buffer size in words.
|
||||
*
|
||||
* @retval NRF_SUCCESS If conversion was successful.
|
||||
* @retval NRF_ERROR_BUSY If the driver already has two buffers set.
|
||||
*/
|
||||
ret_code_t nrf_drv_saadc_buffer_convert(nrf_saadc_value_t * buffer, uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the SAADC state.
|
||||
*
|
||||
* @retval true If the ADC is busy.
|
||||
* @retval false If the ADC is ready.
|
||||
*/
|
||||
bool nrf_drv_saadc_is_busy(void);
|
||||
|
||||
/**
|
||||
* @brief Function for aborting ongoing and buffered conversions.
|
||||
* @note @ref NRF_DRV_SAADC_EVT_DONE event will be generated if there is a conversion in progress.
|
||||
* Event will contain number of words in the sample buffer.
|
||||
*/
|
||||
void nrf_drv_saadc_abort(void);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the SAADC channel limits.
|
||||
* When limits are enabled and the result exceeds the defined bounds, the limit handler function is called.
|
||||
*
|
||||
* @param[in] channel SAADC channel number.
|
||||
* @param[in] limit_low Lower limit (valid values from @ref NRF_DRV_SAADC_LIMITL_DISABLED to
|
||||
* @ref NRF_DRV_SAADC_LIMITH_DISABLED). Conversion results below this value will trigger
|
||||
* the handler function. Set to @ref NRF_DRV_SAADC_LIMITL_DISABLED to disable this limit.
|
||||
* @param[in] limit_high Upper limit (valid values from @ref NRF_DRV_SAADC_LIMITL_DISABLED to
|
||||
* @ref NRF_DRV_SAADC_LIMITH_DISABLED). Conversion results above this value will trigger
|
||||
* the handler function. Set to @ref NRF_DRV_SAADC_LIMITH_DISABLED to disable this limit.
|
||||
*/
|
||||
void nrf_drv_saadc_limits_set(uint8_t channel, int16_t limit_low, int16_t limit_high);
|
||||
|
||||
/**
|
||||
* @brief Function for converting a GPIO pin number to an analog input pin number used in the channel
|
||||
* configuration.
|
||||
*
|
||||
* @param[in] pin GPIO pin.
|
||||
*
|
||||
* @return Value representing an analog input pin. The function returns @ref NRF_SAADC_INPUT_DISABLED
|
||||
* if the specified pin is not an analog input.
|
||||
*/
|
||||
__STATIC_INLINE nrf_saadc_input_t nrf_drv_saadc_gpio_to_ain(uint32_t pin)
|
||||
{
|
||||
// AIN0 - AIN3
|
||||
if (pin >= 2 && pin <= 5)
|
||||
{
|
||||
//0 means "not connected", hence this "+ 1"
|
||||
return (nrf_saadc_input_t)(pin - 2 + 1);
|
||||
}
|
||||
// AIN4 - AIN7
|
||||
else if (pin >= 28 && pin <= 31)
|
||||
{
|
||||
return (nrf_saadc_input_t)(pin - 24 + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NRF_SAADC_INPUT_DISABLED;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // NRF_DRV_SAADC_H__
|
||||
|
||||
/** @} */
|
||||
|
|
@ -1,495 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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 NRF_DRV_CONFIG_H
|
||||
#define NRF_DRV_CONFIG_H
|
||||
|
||||
/**
|
||||
* Provide a non-zero value here in applications that need to use several
|
||||
* peripherals with the same ID that are sharing certain resources
|
||||
* (for example, SPI0 and TWI0). Obviously, such peripherals cannot be used
|
||||
* simultaneously. Therefore, this definition allows to initialize the driver
|
||||
* for another peripheral from a given group only after the previously used one
|
||||
* is uninitialized. Normally, this is not possible, because interrupt handlers
|
||||
* are implemented in individual drivers.
|
||||
* This functionality requires a more complicated interrupt handling and driver
|
||||
* initialization, hence it is not always desirable to use it.
|
||||
*/
|
||||
#define PERIPHERAL_RESOURCE_SHARING_ENABLED 1
|
||||
|
||||
/* CLOCK */
|
||||
#define CLOCK_ENABLED 1
|
||||
|
||||
#if (CLOCK_ENABLED == 1)
|
||||
#define CLOCK_CONFIG_XTAL_FREQ NRF_CLOCK_XTALFREQ_Default
|
||||
#define CLOCK_CONFIG_LF_SRC NRF_CLOCK_LFCLK_Xtal
|
||||
#define CLOCK_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
#endif
|
||||
|
||||
/* GPIOTE */
|
||||
#define GPIOTE_ENABLED 1
|
||||
|
||||
#if (GPIOTE_ENABLED == 1)
|
||||
#define GPIOTE_CONFIG_USE_SWI_EGU false
|
||||
#define GPIOTE_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
#define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 8
|
||||
#endif
|
||||
|
||||
/* TIMER */
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
#define TIMER0_ENABLED 0
|
||||
#else
|
||||
#define TIMER0_ENABLED 1
|
||||
#endif
|
||||
|
||||
#if (TIMER0_ENABLED == 1)
|
||||
#define TIMER0_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
|
||||
#define TIMER0_CONFIG_MODE TIMER_MODE_MODE_Timer
|
||||
#define TIMER0_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_32Bit
|
||||
#define TIMER0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
|
||||
#define TIMER0_INSTANCE_INDEX 0
|
||||
#endif
|
||||
|
||||
#define TIMER1_ENABLED 1
|
||||
|
||||
#if (TIMER1_ENABLED == 1)
|
||||
#define TIMER1_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
|
||||
#define TIMER1_CONFIG_MODE TIMER_MODE_MODE_Timer
|
||||
#define TIMER1_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit
|
||||
#define TIMER1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
|
||||
#define TIMER1_INSTANCE_INDEX (TIMER0_ENABLED)
|
||||
#endif
|
||||
|
||||
#define TIMER2_ENABLED 1
|
||||
|
||||
#if (TIMER2_ENABLED == 1)
|
||||
#define TIMER2_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
|
||||
#define TIMER2_CONFIG_MODE TIMER_MODE_MODE_Timer
|
||||
#define TIMER2_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit
|
||||
#define TIMER2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
|
||||
#define TIMER2_INSTANCE_INDEX (TIMER1_ENABLED+TIMER0_ENABLED)
|
||||
#endif
|
||||
|
||||
#define TIMER3_ENABLED 0
|
||||
|
||||
#if (TIMER3_ENABLED == 1)
|
||||
#define TIMER3_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
|
||||
#define TIMER3_CONFIG_MODE TIMER_MODE_MODE_Timer
|
||||
#define TIMER3_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit
|
||||
#define TIMER3_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
|
||||
#define TIMER3_INSTANCE_INDEX (TIMER2_ENABLED+TIMER1_ENABLED+TIMER0_ENABLED)
|
||||
#endif
|
||||
|
||||
#define TIMER4_ENABLED 0
|
||||
|
||||
#if (TIMER4_ENABLED == 1)
|
||||
#define TIMER4_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
|
||||
#define TIMER4_CONFIG_MODE TIMER_MODE_MODE_Timer
|
||||
#define TIMER4_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit
|
||||
#define TIMER4_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
|
||||
#define TIMER4_INSTANCE_INDEX (TIMER3_ENABLED+TIMER2_ENABLED+TIMER1_ENABLED+TIMER0_ENABLED)
|
||||
#endif
|
||||
|
||||
|
||||
#define TIMER_COUNT (TIMER0_ENABLED + TIMER1_ENABLED + TIMER2_ENABLED + TIMER3_ENABLED + TIMER4_ENABLED)
|
||||
|
||||
/* RTC */
|
||||
#define RTC0_ENABLED 0
|
||||
|
||||
#if (RTC0_ENABLED == 1)
|
||||
#define RTC0_CONFIG_FREQUENCY 32678
|
||||
#define RTC0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
#define RTC0_CONFIG_RELIABLE false
|
||||
|
||||
#define RTC0_INSTANCE_INDEX 0
|
||||
#endif
|
||||
|
||||
#define RTC1_ENABLED 0
|
||||
|
||||
#if (RTC1_ENABLED == 1)
|
||||
#define RTC1_CONFIG_FREQUENCY 32768
|
||||
#define RTC1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
#define RTC1_CONFIG_RELIABLE false
|
||||
|
||||
#define RTC1_INSTANCE_INDEX (RTC0_ENABLED)
|
||||
#endif
|
||||
|
||||
#define RTC2_ENABLED 0
|
||||
|
||||
#if (RTC2_ENABLED == 1)
|
||||
#define RTC2_CONFIG_FREQUENCY 32768
|
||||
#define RTC2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
#define RTC2_CONFIG_RELIABLE false
|
||||
|
||||
#define RTC2_INSTANCE_INDEX (RTC0_ENABLED+RTC1_ENABLED)
|
||||
#endif
|
||||
|
||||
|
||||
#define RTC_COUNT (RTC0_ENABLED+RTC1_ENABLED+RTC2_ENABLED)
|
||||
|
||||
#define NRF_MAXIMUM_LATENCY_US 2000
|
||||
|
||||
/* RNG */
|
||||
#define RNG_ENABLED 1
|
||||
|
||||
#if (RNG_ENABLED == 1)
|
||||
#define RNG_CONFIG_ERROR_CORRECTION true
|
||||
#define RNG_CONFIG_POOL_SIZE 8
|
||||
#define RNG_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
#endif
|
||||
|
||||
/* PWM */
|
||||
|
||||
#define PWM0_ENABLED 1
|
||||
|
||||
#if (PWM0_ENABLED == 1)
|
||||
#define PWM0_CONFIG_OUT0_PIN 2
|
||||
#define PWM0_CONFIG_OUT1_PIN 3
|
||||
#define PWM0_CONFIG_OUT2_PIN 4
|
||||
#define PWM0_CONFIG_OUT3_PIN 5
|
||||
#define PWM0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
#define PWM0_CONFIG_BASE_CLOCK NRF_PWM_CLK_1MHz
|
||||
#define PWM0_CONFIG_COUNT_MODE NRF_PWM_MODE_UP
|
||||
#define PWM0_CONFIG_TOP_VALUE 1000
|
||||
#define PWM0_CONFIG_LOAD_MODE NRF_PWM_LOAD_COMMON
|
||||
#define PWM0_CONFIG_STEP_MODE NRF_PWM_STEP_AUTO
|
||||
|
||||
#define PWM0_INSTANCE_INDEX 0
|
||||
#endif
|
||||
|
||||
#define PWM1_ENABLED 1
|
||||
|
||||
#if (PWM1_ENABLED == 1)
|
||||
#define PWM1_CONFIG_OUT0_PIN 2
|
||||
#define PWM1_CONFIG_OUT1_PIN 3
|
||||
#define PWM1_CONFIG_OUT2_PIN 4
|
||||
#define PWM1_CONFIG_OUT3_PIN 5
|
||||
#define PWM1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
#define PWM1_CONFIG_BASE_CLOCK NRF_PWM_CLK_1MHz
|
||||
#define PWM1_CONFIG_COUNT_MODE NRF_PWM_MODE_UP
|
||||
#define PWM1_CONFIG_TOP_VALUE 1000
|
||||
#define PWM1_CONFIG_LOAD_MODE NRF_PWM_LOAD_COMMON
|
||||
#define PWM1_CONFIG_STEP_MODE NRF_PWM_STEP_AUTO
|
||||
|
||||
#define PWM1_INSTANCE_INDEX (PWM0_ENABLED)
|
||||
#endif
|
||||
|
||||
#define PWM2_ENABLED 1
|
||||
|
||||
#if (PWM2_ENABLED == 1)
|
||||
#define PWM2_CONFIG_OUT0_PIN 2
|
||||
#define PWM2_CONFIG_OUT1_PIN 3
|
||||
#define PWM2_CONFIG_OUT2_PIN 4
|
||||
#define PWM2_CONFIG_OUT3_PIN 5
|
||||
#define PWM2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
#define PWM2_CONFIG_BASE_CLOCK NRF_PWM_CLK_1MHz
|
||||
#define PWM2_CONFIG_COUNT_MODE NRF_PWM_MODE_UP
|
||||
#define PWM2_CONFIG_TOP_VALUE 1000
|
||||
#define PWM2_CONFIG_LOAD_MODE NRF_PWM_LOAD_COMMON
|
||||
#define PWM2_CONFIG_STEP_MODE NRF_PWM_STEP_AUTO
|
||||
|
||||
#define PWM2_INSTANCE_INDEX (PWM0_ENABLED + PWM1_ENABLED)
|
||||
#endif
|
||||
|
||||
#define PWM_COUNT (PWM0_ENABLED + PWM1_ENABLED + PWM2_ENABLED)
|
||||
|
||||
/* SPI */
|
||||
#define SPI0_ENABLED 1
|
||||
|
||||
#if (SPI0_ENABLED == 1)
|
||||
#define SPI0_USE_EASY_DMA 0
|
||||
|
||||
#define SPI0_CONFIG_SCK_PIN 2
|
||||
#define SPI0_CONFIG_MOSI_PIN 3
|
||||
#define SPI0_CONFIG_MISO_PIN 4
|
||||
#define SPI0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
|
||||
#define SPI0_INSTANCE_INDEX 0
|
||||
#endif
|
||||
|
||||
#define SPI1_ENABLED 1
|
||||
|
||||
#if (SPI1_ENABLED == 1)
|
||||
#define SPI1_USE_EASY_DMA 0
|
||||
|
||||
#define SPI1_CONFIG_SCK_PIN 2
|
||||
#define SPI1_CONFIG_MOSI_PIN 3
|
||||
#define SPI1_CONFIG_MISO_PIN 4
|
||||
#define SPI1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
|
||||
#define SPI1_INSTANCE_INDEX (SPI0_ENABLED)
|
||||
#endif
|
||||
|
||||
#define SPI2_ENABLED 1
|
||||
|
||||
#if (SPI2_ENABLED == 1)
|
||||
#define SPI2_USE_EASY_DMA 0
|
||||
|
||||
#define SPI2_CONFIG_SCK_PIN 2
|
||||
#define SPI2_CONFIG_MOSI_PIN 3
|
||||
#define SPI2_CONFIG_MISO_PIN 4
|
||||
#define SPI2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
|
||||
#define SPI2_INSTANCE_INDEX (SPI0_ENABLED + SPI1_ENABLED)
|
||||
#endif
|
||||
|
||||
#define SPI_COUNT (SPI0_ENABLED + SPI1_ENABLED + SPI2_ENABLED)
|
||||
|
||||
/* SPIS */
|
||||
#define SPIS0_ENABLED 1
|
||||
|
||||
#if (SPIS0_ENABLED == 1)
|
||||
#define SPIS0_CONFIG_SCK_PIN 2
|
||||
#define SPIS0_CONFIG_MOSI_PIN 3
|
||||
#define SPIS0_CONFIG_MISO_PIN 4
|
||||
#define SPIS0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
|
||||
#define SPIS0_INSTANCE_INDEX 0
|
||||
#endif
|
||||
|
||||
#define SPIS1_ENABLED 1
|
||||
|
||||
#if (SPIS1_ENABLED == 1)
|
||||
#define SPIS1_CONFIG_SCK_PIN 2
|
||||
#define SPIS1_CONFIG_MOSI_PIN 3
|
||||
#define SPIS1_CONFIG_MISO_PIN 4
|
||||
#define SPIS1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
|
||||
#define SPIS1_INSTANCE_INDEX SPIS0_ENABLED
|
||||
#endif
|
||||
|
||||
#define SPIS2_ENABLED 1
|
||||
|
||||
#if (SPIS2_ENABLED == 1)
|
||||
#define SPIS2_CONFIG_SCK_PIN 2
|
||||
#define SPIS2_CONFIG_MOSI_PIN 3
|
||||
#define SPIS2_CONFIG_MISO_PIN 4
|
||||
#define SPIS2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
|
||||
#define SPIS2_INSTANCE_INDEX (SPIS0_ENABLED + SPIS1_ENABLED)
|
||||
#endif
|
||||
|
||||
#define SPIS_COUNT (SPIS0_ENABLED + SPIS1_ENABLED + SPIS2_ENABLED)
|
||||
|
||||
/* UART */
|
||||
#define UART0_ENABLED 1
|
||||
|
||||
#if (UART0_ENABLED == 1)
|
||||
#define UART0_CONFIG_HWFC NRF_UART_HWFC_ENABLED
|
||||
#define UART0_CONFIG_PARITY NRF_UART_PARITY_EXCLUDED
|
||||
#define UART0_CONFIG_BAUDRATE NRF_UART_BAUDRATE_9600
|
||||
#define UART0_CONFIG_PSEL_TXD 6
|
||||
#define UART0_CONFIG_PSEL_RXD 8
|
||||
#define UART0_CONFIG_PSEL_CTS 7
|
||||
#define UART0_CONFIG_PSEL_RTS 5
|
||||
#define UART0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_HIGH
|
||||
#ifdef NRF52
|
||||
#define UART0_CONFIG_USE_EASY_DMA false
|
||||
//Compile time flag
|
||||
#define UART_EASY_DMA_SUPPORT 1
|
||||
#define UART_LEGACY_SUPPORT 1
|
||||
#endif //NRF52
|
||||
#endif
|
||||
|
||||
#define TWI0_ENABLED 1
|
||||
|
||||
#if (TWI0_ENABLED == 1)
|
||||
#define TWI0_USE_EASY_DMA 0
|
||||
|
||||
#define TWI0_CONFIG_FREQUENCY NRF_TWI_FREQ_100K
|
||||
#define TWI0_CONFIG_SCL 0
|
||||
#define TWI0_CONFIG_SDA 1
|
||||
#define TWI0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
|
||||
#define TWI0_INSTANCE_INDEX 0
|
||||
#endif
|
||||
|
||||
#define TWI1_ENABLED 1
|
||||
|
||||
#if (TWI1_ENABLED == 1)
|
||||
#define TWI1_USE_EASY_DMA 0
|
||||
|
||||
#define TWI1_CONFIG_FREQUENCY NRF_TWI_FREQ_100K
|
||||
#define TWI1_CONFIG_SCL 0
|
||||
#define TWI1_CONFIG_SDA 1
|
||||
#define TWI1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
|
||||
#define TWI1_INSTANCE_INDEX (TWI0_ENABLED)
|
||||
#endif
|
||||
|
||||
#define TWI_COUNT (TWI0_ENABLED + TWI1_ENABLED)
|
||||
|
||||
/* TWIS */
|
||||
#define TWIS0_ENABLED 0
|
||||
|
||||
#if (TWIS0_ENABLED == 1)
|
||||
#define TWIS0_CONFIG_ADDR0 0
|
||||
#define TWIS0_CONFIG_ADDR1 0 /* 0: Disabled */
|
||||
#define TWIS0_CONFIG_SCL 0
|
||||
#define TWIS0_CONFIG_SDA 1
|
||||
#define TWIS0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
|
||||
#define TWIS0_INSTANCE_INDEX 0
|
||||
#endif
|
||||
|
||||
#define TWIS1_ENABLED 0
|
||||
|
||||
#if (TWIS1_ENABLED == 1)
|
||||
#define TWIS1_CONFIG_ADDR0 0
|
||||
#define TWIS1_CONFIG_ADDR1 0 /* 0: Disabled */
|
||||
#define TWIS1_CONFIG_SCL 0
|
||||
#define TWIS1_CONFIG_SDA 1
|
||||
#define TWIS1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
|
||||
#define TWIS1_INSTANCE_INDEX (TWIS0_ENABLED)
|
||||
#endif
|
||||
|
||||
#define TWIS_COUNT (TWIS0_ENABLED + TWIS1_ENABLED)
|
||||
/* For more documentation see nrf_drv_twis.h file */
|
||||
#define TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0
|
||||
/* For more documentation see nrf_drv_twis.h file */
|
||||
#define TWIS_NO_SYNC_MODE 0
|
||||
|
||||
/* QDEC */
|
||||
#define QDEC_ENABLED 0
|
||||
|
||||
#if (QDEC_ENABLED == 1)
|
||||
#define QDEC_CONFIG_REPORTPER NRF_QDEC_REPORTPER_10
|
||||
#define QDEC_CONFIG_SAMPLEPER NRF_QDEC_SAMPLEPER_16384us
|
||||
#define QDEC_CONFIG_PIO_A 1
|
||||
#define QDEC_CONFIG_PIO_B 2
|
||||
#define QDEC_CONFIG_PIO_LED 3
|
||||
#define QDEC_CONFIG_LEDPRE 511
|
||||
#define QDEC_CONFIG_LEDPOL NRF_QDEC_LEPOL_ACTIVE_HIGH
|
||||
#define QDEC_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
#define QDEC_CONFIG_DBFEN false
|
||||
#define QDEC_CONFIG_SAMPLE_INTEN false
|
||||
#endif
|
||||
|
||||
/* ADC */
|
||||
#define ADC_ENABLED 0
|
||||
|
||||
#if (ADC_ENABLED == 1)
|
||||
#define ADC_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
#endif
|
||||
|
||||
|
||||
/* SAADC */
|
||||
#define SAADC_ENABLED 1
|
||||
|
||||
#if (SAADC_ENABLED == 1)
|
||||
#define SAADC_CONFIG_RESOLUTION NRF_SAADC_RESOLUTION_10BIT
|
||||
#define SAADC_CONFIG_OVERSAMPLE NRF_SAADC_OVERSAMPLE_DISABLED
|
||||
#define SAADC_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
#endif
|
||||
|
||||
/* PDM */
|
||||
#define PDM_ENABLED 0
|
||||
|
||||
#if (PDM_ENABLED == 1)
|
||||
#define PDM_CONFIG_MODE NRF_PDM_MODE_MONO
|
||||
#define PDM_CONFIG_EDGE NRF_PDM_EDGE_LEFTFALLING
|
||||
#define PDM_CONFIG_CLOCK_FREQ NRF_PDM_FREQ_1032K
|
||||
#define PDM_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
#endif
|
||||
|
||||
/* COMP */
|
||||
#define COMP_ENABLED 0
|
||||
|
||||
#if (COMP_ENABLED == 1)
|
||||
#define COMP_CONFIG_REF NRF_COMP_REF_Int1V8
|
||||
#define COMP_CONFIG_MAIN_MODE NRF_COMP_MAIN_MODE_SE
|
||||
#define COMP_CONFIG_SPEED_MODE NRF_COMP_SP_MODE_High
|
||||
#define COMP_CONFIG_HYST NRF_COMP_HYST_NoHyst
|
||||
#define COMP_CONFIG_ISOURCE NRF_COMP_ISOURCE_Off
|
||||
#define COMP_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
#define COMP_CONFIG_INPUT NRF_COMP_INPUT_0
|
||||
#endif
|
||||
|
||||
/* LPCOMP */
|
||||
#define LPCOMP_ENABLED 0
|
||||
|
||||
#if (LPCOMP_ENABLED == 1)
|
||||
#define LPCOMP_CONFIG_REFERENCE NRF_LPCOMP_REF_SUPPLY_4_8
|
||||
#define LPCOMP_CONFIG_DETECTION NRF_LPCOMP_DETECT_DOWN
|
||||
#define LPCOMP_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOWEST
|
||||
#define LPCOMP_CONFIG_INPUT NRF_LPCOMP_INPUT_0
|
||||
#endif
|
||||
|
||||
/* WDT */
|
||||
#define WDT_ENABLED 0
|
||||
|
||||
#if (WDT_ENABLED == 1)
|
||||
#define WDT_CONFIG_BEHAVIOUR NRF_WDT_BEHAVIOUR_RUN_SLEEP
|
||||
#define WDT_CONFIG_RELOAD_VALUE 2000
|
||||
#define WDT_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_HIGH
|
||||
#endif
|
||||
|
||||
/* SWI EGU */
|
||||
#ifdef NRF52
|
||||
#define EGU_ENABLED 0
|
||||
#endif
|
||||
|
||||
/* I2S */
|
||||
#define I2S_ENABLED 0
|
||||
|
||||
#if (I2S_ENABLED == 1)
|
||||
#define I2S_CONFIG_SCK_PIN 22
|
||||
#define I2S_CONFIG_LRCK_PIN 23
|
||||
#define I2S_CONFIG_MCK_PIN NRF_DRV_I2S_PIN_NOT_USED
|
||||
#define I2S_CONFIG_SDOUT_PIN 24
|
||||
#define I2S_CONFIG_SDIN_PIN 25
|
||||
#define I2S_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_HIGH
|
||||
#define I2S_CONFIG_MASTER NRF_I2S_MODE_MASTER
|
||||
#define I2S_CONFIG_FORMAT NRF_I2S_FORMAT_I2S
|
||||
#define I2S_CONFIG_ALIGN NRF_I2S_ALIGN_LEFT
|
||||
#define I2S_CONFIG_SWIDTH NRF_I2S_SWIDTH_16BIT
|
||||
#define I2S_CONFIG_CHANNELS NRF_I2S_CHANNELS_STEREO
|
||||
#define I2S_CONFIG_MCK_SETUP NRF_I2S_MCK_32MDIV8
|
||||
#define I2S_CONFIG_RATIO NRF_I2S_RATIO_256X
|
||||
#endif
|
||||
|
||||
#include "nrf_drv_config_validation.h"
|
||||
|
||||
#endif // NRF_DRV_CONFIG_H
|
||||
|
|
@ -1,220 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup nrf_mbr_api Master Boot Record API
|
||||
@{
|
||||
|
||||
@brief APIs for updating SoftDevice and BootLoader
|
||||
|
||||
*/
|
||||
|
||||
/* Header guard */
|
||||
#ifndef NRF_MBR_H__
|
||||
#define NRF_MBR_H__
|
||||
|
||||
#include "nrf_svc.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef NRF52
|
||||
#error "This header file shall only be included for nRF52 projects"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup NRF_MBR_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@brief MBR SVC Base number. */
|
||||
#define MBR_SVC_BASE (0x18)
|
||||
|
||||
/**@brief Page size in words. */
|
||||
#define MBR_PAGE_SIZE_IN_WORDS (1024)
|
||||
|
||||
/** @brief The size that must be reserved for the MBR when a softdevice is written to flash.
|
||||
This is the offset where the first byte of the softdevice hex file is written.*/
|
||||
#define MBR_SIZE (0x1000)
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_ENUMS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief nRF Master Boot Record API SVC numbers. */
|
||||
enum NRF_MBR_SVCS
|
||||
{
|
||||
SD_MBR_COMMAND = MBR_SVC_BASE, /**< ::sd_mbr_command */
|
||||
};
|
||||
|
||||
/**@brief Possible values for ::sd_mbr_command_t.command */
|
||||
enum NRF_MBR_COMMANDS
|
||||
{
|
||||
SD_MBR_COMMAND_COPY_BL, /**< Copy a new BootLoader. @see sd_mbr_command_copy_bl_t */
|
||||
SD_MBR_COMMAND_COPY_SD, /**< Copy a new SoftDevice. @see ::sd_mbr_command_copy_sd_t*/
|
||||
SD_MBR_COMMAND_INIT_SD, /**< Init forwarding interrupts to SD, and run reset function in SD*/
|
||||
SD_MBR_COMMAND_COMPARE, /**< This command works like memcmp. @see ::sd_mbr_command_compare_t*/
|
||||
SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET, /**< Start forwarding all exception to this address @see ::sd_mbr_command_vector_table_base_set_t*/
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_TYPES Types
|
||||
* @{ */
|
||||
|
||||
/**@brief This command copies part of a new SoftDevice
|
||||
* The destination area is erased before copying.
|
||||
* If dst is in the middle of a flash page, that whole flash page will be erased.
|
||||
* If (dst+len) is in the middle of a flash page, that whole flash page will be erased.
|
||||
*
|
||||
* The user of this function is responsible for setting the BPROT registers.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS indicates that the contents of the memory blocks where copied correctly.
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates that the contents of the memory blocks where not verified correctly after copying.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *src; /**< Pointer to the source of data to be copied.*/
|
||||
uint32_t *dst; /**< Pointer to the destination where the content is to be copied.*/
|
||||
uint32_t len; /**< Number of 32 bit words to copy. Must be a multiple of @ref MBR_PAGE_SIZE_IN_WORDS words.*/
|
||||
} sd_mbr_command_copy_sd_t;
|
||||
|
||||
|
||||
/**@brief This command works like memcmp, but takes the length in words.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS indicates that the contents of both memory blocks are equal.
|
||||
* @retval ::NRF_ERROR_NULL indicates that the contents of the memory blocks are not equal.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *ptr1; /**< Pointer to block of memory. */
|
||||
uint32_t *ptr2; /**< Pointer to block of memory. */
|
||||
uint32_t len; /**< Number of 32 bit words to compare.*/
|
||||
} sd_mbr_command_compare_t;
|
||||
|
||||
|
||||
/**@brief This command copies a new BootLoader.
|
||||
* With this command, destination of BootLoader is always the address written in NRF_UICR->BOOTADDR.
|
||||
*
|
||||
* Destination is erased by this function.
|
||||
* If (destination+bl_len) is in the middle of a flash page, that whole flash page will be erased.
|
||||
*
|
||||
* This function will use PROTENSET to protect the flash that is not intended to be written.
|
||||
*
|
||||
* On Success, this function will not return. It will start the new BootLoader from reset-vector as normal.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN if NRF_UICR->BOOTADDR is not set.
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH if parameters attempts to read or write outside flash area.
|
||||
* @retval ::NRF_ERROR_NO_MEM if no parameter page is provided (see sds for more info)
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *bl_src; /**< Pointer to the source of the Bootloader to be be copied.*/
|
||||
uint32_t bl_len; /**< Number of 32 bit words to copy for BootLoader. */
|
||||
} sd_mbr_command_copy_bl_t;
|
||||
|
||||
/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the MBR
|
||||
*
|
||||
* Once this function has been called, this address is where the MBR will start to forward interrupts to after a reset.
|
||||
*
|
||||
* To restore default forwarding this function should be called with @param address set to 0.
|
||||
* The MBR will then start forwarding to interrupts to the address in NFR_UICR->BOOTADDR or to the SoftDevice if the BOOTADDR is not set.
|
||||
*
|
||||
* On Success, this function will not return. It will reset the device.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR if parameter address is outside of the flash size.
|
||||
* @retval ::NRF_ERROR_NO_MEM if no parameter page is provided (see sds for more info)
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/
|
||||
} sd_mbr_command_vector_table_base_set_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t command; /**< type of command to be issued see @ref NRF_MBR_COMMANDS. */
|
||||
union
|
||||
{
|
||||
sd_mbr_command_copy_sd_t copy_sd; /**< Parameters for copy SoftDevice.*/
|
||||
sd_mbr_command_compare_t compare; /**< Parameters for verify.*/
|
||||
sd_mbr_command_copy_bl_t copy_bl; /**< Parameters for copy BootLoader. Requires parameter page. */
|
||||
sd_mbr_command_vector_table_base_set_t base_set; /**< Parameters for vector table base set. Requires parameter page.*/
|
||||
} params;
|
||||
} sd_mbr_command_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Issue Master Boot Record commands
|
||||
*
|
||||
* Commands used when updating a SoftDevice and bootloader.
|
||||
*
|
||||
* The SD_MBR_COMMAND_COPY_BL and SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET requires parameters to be
|
||||
* retained by the MBR when resetting the IC. This is done in a separate flash page
|
||||
* provided by the application. The uicr register UICR.NRFFW[1] must be set
|
||||
* to an address corresponding to a page in the application flash space. This page will be cleared
|
||||
* by the MBR and used to store the command before reset. When the UICR.NRFFW[1] field is set
|
||||
* the page it refers to must not be used by the application. If the UICR.NRFFW[1] is set to
|
||||
* 0xFFFFFFFF (the default) MBR commands which use flash will be unavailable and return
|
||||
* NRF_ERROR_NO_MEM.
|
||||
*
|
||||
* @param[in] param Pointer to a struct describing the command.
|
||||
*
|
||||
* @note for retvals see ::sd_mbr_command_copy_sd_t ::sd_mbr_command_copy_bl_t ::sd_mbr_command_compare_t ::sd_mbr_command_vector_table_base_set_t
|
||||
*
|
||||
* @retval NRF_ERROR_NO_MEM if UICR.NRFFW[1] is not set (i.e. is 0xFFFFFFFF).
|
||||
* @retval NRF_ERROR_INVALID_PARAM if an invalid command is given.
|
||||
*/
|
||||
SVCALL(SD_MBR_COMMAND, uint32_t, sd_mbr_command(sd_mbr_command_t* param));
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_MBR_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,635 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
@addtogroup BLE_COMMON BLE SoftDevice Common
|
||||
@{
|
||||
@defgroup ble_api Events, type definitions and API calls
|
||||
@{
|
||||
|
||||
@brief Module independent events, type definitions and API calls for the BLE SoftDevice.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef NRF_BLE_H__
|
||||
#define NRF_BLE_H__
|
||||
|
||||
#include "nrf_ble_ranges.h"
|
||||
#include "nrf_ble_types.h"
|
||||
#include "nrf_ble_gap.h"
|
||||
#include "nrf_ble_l2cap.h"
|
||||
#include "nrf_ble_gatt.h"
|
||||
#include "nrf_ble_gattc.h"
|
||||
#include "nrf_ble_gatts.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup BLE_COMMON_ENUMERATIONS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**
|
||||
* @brief Common API SVC numbers.
|
||||
*/
|
||||
enum BLE_COMMON_SVCS
|
||||
{
|
||||
SD_BLE_ENABLE = BLE_SVC_BASE, /**< Enable and initialize the BLE stack */
|
||||
SD_BLE_EVT_GET, /**< Get an event from the pending events queue. */
|
||||
SD_BLE_TX_PACKET_COUNT_GET, /**< Get the total number of available application transmission packets for a particular connection. */
|
||||
SD_BLE_UUID_VS_ADD, /**< Add a Vendor Specific UUID. */
|
||||
SD_BLE_UUID_DECODE, /**< Decode UUID bytes. */
|
||||
SD_BLE_UUID_ENCODE, /**< Encode UUID bytes. */
|
||||
SD_BLE_VERSION_GET, /**< Get the local version information (company id, Link Layer Version, Link Layer Subversion). */
|
||||
SD_BLE_USER_MEM_REPLY, /**< User Memory Reply. */
|
||||
SD_BLE_OPT_SET, /**< Set a BLE option. */
|
||||
SD_BLE_OPT_GET, /**< Get a BLE option. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief BLE Module Independent Event IDs.
|
||||
*/
|
||||
enum BLE_COMMON_EVTS
|
||||
{
|
||||
BLE_EVT_TX_COMPLETE = BLE_EVT_BASE, /**< Transmission Complete. @ref ble_evt_tx_complete_t */
|
||||
BLE_EVT_USER_MEM_REQUEST, /**< User Memory request. @ref ble_evt_user_mem_request_t */
|
||||
BLE_EVT_USER_MEM_RELEASE /**< User Memory release. @ref ble_evt_user_mem_release_t */
|
||||
};
|
||||
|
||||
/**@brief BLE connection bandwidth types.
|
||||
* Bandwidth types supported by the SoftDevice in packets per connection interval.
|
||||
*/
|
||||
enum BLE_CONN_BWS
|
||||
{
|
||||
BLE_CONN_BW_NONE = 0,
|
||||
BLE_CONN_BW_LOW,
|
||||
BLE_CONN_BW_MID,
|
||||
BLE_CONN_BW_HIGH
|
||||
};
|
||||
|
||||
/**@brief Common Option IDs.
|
||||
* IDs that uniquely identify a common option.
|
||||
*/
|
||||
enum BLE_COMMON_OPTS
|
||||
{
|
||||
BLE_COMMON_OPT_CONN_BW = BLE_OPT_BASE, /**< Bandwidth configuration @ref ble_common_opt_conn_bw_t */
|
||||
BLE_COMMON_OPT_PA_LNA /**< PA and LNA options */
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_COMMON_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/** @brief Required pointer alignment for BLE Events.
|
||||
*/
|
||||
#define BLE_EVTS_PTR_ALIGNMENT 4
|
||||
|
||||
/** @defgroup BLE_USER_MEM_TYPES User Memory Types
|
||||
* @{ */
|
||||
#define BLE_USER_MEM_TYPE_INVALID 0x00 /**< Invalid User Memory Types. */
|
||||
#define BLE_USER_MEM_TYPE_GATTS_QUEUED_WRITES 0x01 /**< User Memory for GATTS queued writes. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_UUID_VS_COUNTS Vendor Specific UUID counts
|
||||
* @{
|
||||
*/
|
||||
#define BLE_UUID_VS_COUNT_MIN 1 /**< Minimum VS UUID count. */
|
||||
#define BLE_UUID_VS_COUNT_DEFAULT 0 /**< Use the default VS UUID count (10 for this version of the SoftDevice). */
|
||||
/** @} */
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_COMMON_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**@brief User Memory Block. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *p_mem; /**< Pointer to the start of the user memory block. */
|
||||
uint16_t len; /**< Length in bytes of the user memory block. */
|
||||
} ble_user_mem_block_t;
|
||||
|
||||
/**
|
||||
* @brief Event structure for @ref BLE_EVT_TX_COMPLETE.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t count; /**< Number of packets transmitted. */
|
||||
} ble_evt_tx_complete_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_EVT_USER_MEM_REQUEST. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */
|
||||
} ble_evt_user_mem_request_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_EVT_USER_MEM_RELEASE. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */
|
||||
ble_user_mem_block_t mem_block; /**< User memory block */
|
||||
} ble_evt_user_mem_release_t;
|
||||
|
||||
|
||||
/**@brief Event structure for events not associated with a specific function module. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t conn_handle; /**< Connection Handle on which this event occurred. */
|
||||
union
|
||||
{
|
||||
ble_evt_tx_complete_t tx_complete; /**< Transmission Complete. */
|
||||
ble_evt_user_mem_request_t user_mem_request; /**< User Memory Request Event Parameters. */
|
||||
ble_evt_user_mem_release_t user_mem_release; /**< User Memory Release Event Parameters. */
|
||||
} params;
|
||||
} ble_common_evt_t;
|
||||
|
||||
/**@brief BLE Event header. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t evt_id; /**< Value from a BLE_<module>_EVT series. */
|
||||
uint16_t evt_len; /**< Length in octets including this header. */
|
||||
} ble_evt_hdr_t;
|
||||
|
||||
/**@brief Common BLE Event type, wrapping the module specific event reports. */
|
||||
typedef struct
|
||||
{
|
||||
ble_evt_hdr_t header; /**< Event header. */
|
||||
union
|
||||
{
|
||||
ble_common_evt_t common_evt; /**< Common Event, evt_id in BLE_EVT_* series. */
|
||||
ble_gap_evt_t gap_evt; /**< GAP originated event, evt_id in BLE_GAP_EVT_* series. */
|
||||
ble_l2cap_evt_t l2cap_evt; /**< L2CAP originated event, evt_id in BLE_L2CAP_EVT* series. */
|
||||
ble_gattc_evt_t gattc_evt; /**< GATT client originated event, evt_id in BLE_GATTC_EVT* series. */
|
||||
ble_gatts_evt_t gatts_evt; /**< GATT server originated event, evt_id in BLE_GATTS_EVT* series. */
|
||||
} evt;
|
||||
} ble_evt_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Version Information.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t version_number; /**< Link Layer Version number for BT 4.1 spec is 7 (https://www.bluetooth.org/en-us/specification/assigned-numbers/link-layer). */
|
||||
uint16_t company_id; /**< Company ID, Nordic Semiconductor's company ID is 89 (0x0059) (https://www.bluetooth.org/apps/content/Default.aspx?doc_id=49708). */
|
||||
uint16_t subversion_number; /**< Link Layer Sub Version number, corresponds to the SoftDevice Config ID or Firmware ID (FWID). */
|
||||
} ble_version_t;
|
||||
|
||||
/* @brief: Configuration parameters for the PA and LNA. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t enable :1; /**< Enable toggling for this amplifier */
|
||||
uint8_t active_high :1; /**< Set the pin to be active high */
|
||||
uint8_t gpio_pin :6; /**< The GPIO pin to toggle for this amplifier */
|
||||
} ble_pa_lna_cfg_t;
|
||||
|
||||
/*
|
||||
* @brief PA & LNA GPIO toggle configuration
|
||||
*
|
||||
* This option configures the SoftDevice to toggle pins when the radio is active for use with a power amplifier and/or
|
||||
* a low noise amplifier.
|
||||
*
|
||||
* Toggling the pins is achieved by using two PPI channels and a GPIOTE channel. The hardware channel IDs are provided
|
||||
* by the application and should be regarded as reserved as long as any PA/LNA toggling is enabled.
|
||||
*
|
||||
* @note @ref sd_ble_opt_get is not supported for this option.
|
||||
* @note This feature is only supported for nRF52, on nRF51 @ref NRF_ERROR_NOT_SUPPORTED will always be returned.
|
||||
* @note Setting this option while the radio is in use (i.e. any of the roles are active) may have undefined consequences
|
||||
* and must be avoided by the application.
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ble_pa_lna_cfg_t pa_cfg; /**< Power Amplifier configuration */
|
||||
ble_pa_lna_cfg_t lna_cfg; /**< Low Noise Amplifier configuration */
|
||||
|
||||
uint8_t ppi_ch_id_set; /**< PPI channel used for radio pin setting */
|
||||
uint8_t ppi_ch_id_clr; /**< PPI channel used for radio pin clearing */
|
||||
uint8_t gpiote_ch_id; /**< GPIOTE channel used for radio pin toggling */
|
||||
} ble_common_opt_pa_lna_t;
|
||||
|
||||
/**
|
||||
* @brief BLE connection bandwidth configuration parameters
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t conn_bw_tx; /**< Connection bandwidth configuration for transmission, see @ref BLE_CONN_BWS.*/
|
||||
uint8_t conn_bw_rx; /**< Connection bandwidth configuration for reception, see @ref BLE_CONN_BWS.*/
|
||||
} ble_conn_bw_t;
|
||||
|
||||
/**@brief BLE connection specific bandwidth configuration parameters.
|
||||
*
|
||||
* This can be used with @ref sd_ble_opt_set to set the bandwidth configuration to be used when creating connections.
|
||||
*
|
||||
* Call @ref sd_ble_opt_set with this option prior to calling @ref sd_ble_gap_adv_start or @ref sd_ble_gap_connect.
|
||||
*
|
||||
* The bandwidth configurations set via @ref sd_ble_opt_set are maintained separately for central and peripheral
|
||||
* connections. The given configurations are used for all future connections of the role indicated in this structure
|
||||
* unless they are changed by subsequent @ref sd_ble_opt_set calls.
|
||||
*
|
||||
* @note When this option is not used, the SoftDevice will use the default options:
|
||||
* - @ref BLE_CONN_BW_HIGH for @ref BLE_GAP_ROLE_PERIPH connections (both transmission and reception).
|
||||
* - @ref BLE_CONN_BW_MID for @ref BLE_GAP_ROLE_CENTRAL connections (both transmisison and reception).
|
||||
* This option allows the application to selectively override these defaults for each role.
|
||||
*
|
||||
* @note The global memory pool configuration can be set with the @ref ble_conn_bw_counts_t configuration parameter, which
|
||||
* is provided to @ref sd_ble_enable.
|
||||
*
|
||||
* @note Please refer to SoftDevice Specification for more information on bandwidth configuration.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_COMMON_CONF_BW}
|
||||
* @endmscs
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Set successfully.
|
||||
* @retval ::BLE_ERROR_INVALID_ROLE The role is invalid.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid bandwidth configuration parameters.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED If the combination of role and bandwidth configuration is not supported.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t role; /**< BLE role of the connection, see @ref BLE_GAP_ROLES. */
|
||||
ble_conn_bw_t conn_bw; /**< Bandwidth configuration parameters. */
|
||||
} ble_common_opt_conn_bw_t;
|
||||
|
||||
/**@brief Option structure for common options. */
|
||||
typedef union
|
||||
{
|
||||
ble_common_opt_conn_bw_t conn_bw; /**< Parameters for the connection bandwidth option. */
|
||||
ble_common_opt_pa_lna_t pa_lna; /**< Parameters for controlling PA and LNA pin toggling. */
|
||||
} ble_common_opt_t;
|
||||
|
||||
/**@brief Common BLE Option type, wrapping the module specific options. */
|
||||
typedef union
|
||||
{
|
||||
ble_common_opt_t common_opt; /**< COMMON options, opt_id in @ref BLE_COMMON_OPTS series. */
|
||||
ble_gap_opt_t gap_opt; /**< GAP option, opt_id in @ref BLE_GAP_OPTS series. */
|
||||
} ble_opt_t;
|
||||
|
||||
/**
|
||||
* @brief BLE bandwidth count parameters
|
||||
*
|
||||
* These parameters are used to configure the memory pools allocated within the SoftDevice for application packets
|
||||
* (both transmission and reception) for all connections.
|
||||
*
|
||||
* @note The sum of all three counts must add up to the sum of @ref ble_gap_enable_params_t::central_conn_count and
|
||||
* @ref ble_gap_enable_params_t::periph_conn_count in @ref ble_gap_enable_params_t.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t high_count; /**< Total number of high bandwidth TX or RX memory pools available to the application at runtime for all active connections. */
|
||||
uint8_t mid_count; /**< Total number of medium bandwidth TX or RX memory pools available to the application at runtime for all active connections. */
|
||||
uint8_t low_count; /**< Total number of low bandwidth TX or RX memory pools available to the application at runtime for all active connections. */
|
||||
} ble_conn_bw_count_t;
|
||||
|
||||
/**
|
||||
* @brief BLE bandwidth global memory pool configuration parameters
|
||||
*
|
||||
* These configuration parameters are used to set the amount of memory dedicated to application packets for
|
||||
* all connections. The application should specify the most demanding configuration for the intended use.
|
||||
*
|
||||
* Please refer to the SoftDevice Specification for more information on bandwidth configuration.
|
||||
*
|
||||
* @note Each connection created at runtime requires both a TX and an RX memory pool. By the use of these configuration
|
||||
* parameters, the application can decide the size and total number of the global memory pools that will be later
|
||||
* available for connection creation.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_COMMON_CONF_BW}
|
||||
* @endmscs
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
ble_conn_bw_count_t tx_counts; /**< Global memory pool configuration for transmission.*/
|
||||
ble_conn_bw_count_t rx_counts; /**< Global memory pool configuration for reception.*/
|
||||
} ble_conn_bw_counts_t;
|
||||
|
||||
/**
|
||||
* @brief BLE Common Initialization parameters.
|
||||
*
|
||||
* @note If @ref p_conn_bw_counts is NULL the SoftDevice will assume default bandwidth configuration for all connections.
|
||||
* To fit a custom bandwidth configuration requirement, the application developer may have to specify a custom memory
|
||||
* pool configuration here. See @ref ble_common_opt_conn_bw_t for bandwidth configuration of individual connections.
|
||||
* Please refer to the SoftDevice Specification for more information on bandwidth configuration.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t vs_uuid_count; /**< Maximum number of 128-bit, Vendor Specific UUID bases to allocate. */
|
||||
ble_conn_bw_counts_t *p_conn_bw_counts; /**< Bandwidth configuration parameters or NULL for defaults. */
|
||||
} ble_common_enable_params_t;
|
||||
|
||||
/**
|
||||
* @brief BLE Initialization parameters.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ble_common_enable_params_t common_enable_params; /**< Common init parameters @ref ble_common_enable_params_t. */
|
||||
ble_gap_enable_params_t gap_enable_params; /**< GAP init parameters @ref ble_gap_enable_params_t. */
|
||||
ble_gatts_enable_params_t gatts_enable_params; /**< GATTS init parameters @ref ble_gatts_enable_params_t. */
|
||||
} ble_enable_params_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_COMMON_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Enable the BLE stack
|
||||
*
|
||||
* @param[in, out] p_ble_enable_params Pointer to ble_enable_params_t
|
||||
* @param[in, out] p_app_ram_base Pointer to a variable containing the start address of the application RAM region
|
||||
* (APP_RAM_BASE). On return, this will contain the minimum start address of the application RAM region required by the
|
||||
* SoftDevice for this configuration. Calling @ref sd_ble_enable() with *p_app_ram_base set to 0 can be used during
|
||||
* development to find out how much memory a specific configuration will need.
|
||||
*
|
||||
* @note The memory requirement for a specific configuration will not increase between SoftDevices with the same major
|
||||
* version number.
|
||||
*
|
||||
* @note At runtime the IC's RAM is split into 2 regions: The SoftDevice RAM region is located between 0x20000000 and
|
||||
* APP_RAM_BASE-1 and the application's RAM region is located between APP_RAM_BASE and the start of the call stack.
|
||||
*
|
||||
* @details This call initializes the BLE stack, no other BLE related function can be called before this one.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_COMMON_ENABLE}
|
||||
* @endmscs
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The BLE stack has been initialized successfully.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE The BLE stack had already been initialized and cannot be reinitialized.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH The specified Attribute Table size is either too small or not a multiple of 4.
|
||||
* The minimum acceptable size is defined by @ref BLE_GATTS_ATTR_TAB_SIZE_MIN.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Incorrectly configured VS UUID count or connection count parameters.
|
||||
* @retval ::NRF_ERROR_NO_MEM The amount of memory assigned to the SoftDevice by *p_app_ram_base is not
|
||||
* large enough to fit this configuration's memory requirement. Check *p_app_ram_base
|
||||
* and set the start address of the application RAM region accordingly.
|
||||
* @retval ::NRF_ERROR_CONN_COUNT The requested number of connections exceeds the maximum supported by the SoftDevice.
|
||||
* Please refer to the SoftDevice Specification for more information on role configuration.
|
||||
*/
|
||||
SVCALL(SD_BLE_ENABLE, uint32_t, sd_ble_enable(ble_enable_params_t * p_ble_enable_params, uint32_t * p_app_ram_base));
|
||||
|
||||
/**@brief Get an event from the pending events queue.
|
||||
*
|
||||
* @param[out] p_dest Pointer to buffer to be filled in with an event, or NULL to retrieve the event length.
|
||||
* This buffer <b>must be 4-byte aligned in memory</b>.
|
||||
* @param[in, out] p_len Pointer the length of the buffer, on return it is filled with the event length.
|
||||
*
|
||||
* @details This call allows the application to pull a BLE event from the BLE stack. The application is signaled that
|
||||
* an event is available from the BLE stack by the triggering of the SD_EVT_IRQn interrupt.
|
||||
* The application is free to choose whether to call this function from thread mode (main context) or directly from the
|
||||
* Interrupt Service Routine that maps to SD_EVT_IRQn. In any case however, and because the BLE stack runs at a higher
|
||||
* priority than the application, this function should be called in a loop (until @ref NRF_ERROR_NOT_FOUND is returned)
|
||||
* every time SD_EVT_IRQn is raised to ensure that all available events are pulled from the BLE stack. Failure to do so
|
||||
* could potentially leave events in the internal queue without the application being aware of this fact. Sizing the
|
||||
* p_dest buffer is equally important, since the application needs to provide all the memory necessary for the event to
|
||||
* be copied into application memory. If the buffer provided is not large enough to fit the entire contents of the event,
|
||||
* @ref NRF_ERROR_DATA_SIZE will be returned and the application can then call again with a larger buffer size.
|
||||
* Please note that because of the variable length nature of some events, sizeof(ble_evt_t) will not always be large
|
||||
* enough to fit certain events, and so it is the application's responsibility to provide an amount of memory large
|
||||
* enough so that the relevant event is copied in full. The application may "peek" the event length by providing p_dest
|
||||
* as a NULL pointer and inspecting the value of *p_len upon return:
|
||||
*
|
||||
* \code
|
||||
* uint16_t len;
|
||||
* errcode = sd_ble_evt_get(NULL, &len);
|
||||
* \endcode
|
||||
*
|
||||
* @note The pointer supplied must be aligned to the extend defined by @ref BLE_EVTS_PTR_ALIGNMENT
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_COMMON_IRQ_EVT_MSC}
|
||||
* @mmsc{@ref BLE_COMMON_THREAD_EVT_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Event pulled and stored into the supplied buffer.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND No events ready to be pulled.
|
||||
* @retval ::NRF_ERROR_DATA_SIZE Event ready but could not fit into the supplied buffer.
|
||||
*/
|
||||
SVCALL(SD_BLE_EVT_GET, uint32_t, sd_ble_evt_get(uint8_t *p_dest, uint16_t *p_len));
|
||||
|
||||
|
||||
/**@brief Get the total number of available guaranteed application transmission packets for a particular connection.
|
||||
*
|
||||
* @details This call allows the application to obtain the total number of guaranteed application transmission packets
|
||||
* available for a connection. Please note that this does not return the number of free packets, but rather the total
|
||||
* amount of them for that particular connection. The application has two options to handle transmitting application packets:
|
||||
* - Use a simple arithmetic calculation: after connection creation time the application should use this function to
|
||||
* find out the total amount of guaranteed packets available to it and store it in a variable.
|
||||
* Every time a packet is successfully queued for a transmission on this connection using any of the exposed functions in
|
||||
* this BLE API, the application should decrement that variable. Conversely, whenever a @ref BLE_EVT_TX_COMPLETE event
|
||||
* with the conn_handle matching the particular connection is received by the application, it should retrieve the count
|
||||
* field in such event and add that number to the same variable storing the number of available guaranteed packets. This
|
||||
* mechanism allows the application to be aware at any time of the number of guaranteed application packets available for
|
||||
* each of the active connections, and therefore it can know with certainty whether it is possible to send more data or
|
||||
* it has to wait for a @ref BLE_EVT_TX_COMPLETE event before it proceeds.
|
||||
* The application can still pursue transmissions when the number of guaranteed application packets available is smaller
|
||||
* than or equal to zero, but successful queuing of the tranmsission is not guaranteed.
|
||||
* - Choose to simply not keep track of available packets at all, and instead handle the @ref BLE_ERROR_NO_TX_PACKETS error
|
||||
* by queueing the packet to be transmitted and try again as soon as a @ref BLE_EVT_TX_COMPLETE event arrives.
|
||||
*
|
||||
* The API functions that <b>may</b> consume an application packet depending on the parameters supplied to them can be found below:
|
||||
* - @ref sd_ble_gattc_write (write without response only)
|
||||
* - @ref sd_ble_gatts_hvx (notifications only)
|
||||
* - @ref sd_ble_l2cap_tx (all packets)
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[out] p_count Pointer to a uint8_t which will contain the number of application transmission packets upon
|
||||
* successful return.
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_COMMON_APP_BUFF_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Number of application transmission packets retrieved successfully.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
*/
|
||||
SVCALL(SD_BLE_TX_PACKET_COUNT_GET, uint32_t, sd_ble_tx_packet_count_get(uint16_t conn_handle, uint8_t *p_count));
|
||||
|
||||
|
||||
/**@brief Add a Vendor Specific UUID.
|
||||
*
|
||||
* @details This call enables the application to add a vendor specific UUID to the BLE stack's table, for later use
|
||||
* all other modules and APIs. This then allows the application to use the shorter, 24-bit @ref ble_uuid_t format
|
||||
* when dealing with both 16-bit and 128-bit UUIDs without having to check for lengths and having split code paths.
|
||||
* The way that this is accomplished is by extending the grouping mechanism that the Bluetooth SIG standard base
|
||||
* UUID uses for all other 128-bit UUIDs. The type field in the @ref ble_uuid_t structure is an index (relative to
|
||||
* @ref BLE_UUID_TYPE_VENDOR_BEGIN) to the table populated by multiple calls to this function, and the uuid field
|
||||
* in the same structure contains the 2 bytes at indices 12 and 13. The number of possible 128-bit UUIDs available to
|
||||
* the application is therefore the number of Vendor Specific UUIDs added with the help of this function times 65536,
|
||||
* although restricted to modifying bytes 12 and 13 for each of the entries in the supplied array.
|
||||
*
|
||||
* @note Bytes 12 and 13 of the provided UUID will not be used internally, since those are always replaced by
|
||||
* the 16-bit uuid field in @ref ble_uuid_t.
|
||||
*
|
||||
* @note If a UUID is already present in the BLE stack's internal table, the corresponding index will be returned in
|
||||
* p_uuid_type along with an NRF_SUCCESS error code.
|
||||
*
|
||||
* @param[in] p_vs_uuid Pointer to a 16-octet (128-bit) little endian Vendor Specific UUID disregarding
|
||||
* bytes 12 and 13.
|
||||
* @param[out] p_uuid_type Pointer to a uint8_t where the type field in @ref ble_uuid_t corresponding to this UUID will be stored.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully added the Vendor Specific UUID.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR If p_vs_uuid or p_uuid_type is NULL or invalid.
|
||||
* @retval ::NRF_ERROR_NO_MEM If there are no more free slots for VS UUIDs.
|
||||
*/
|
||||
SVCALL(SD_BLE_UUID_VS_ADD, uint32_t, sd_ble_uuid_vs_add(ble_uuid128_t const *p_vs_uuid, uint8_t *p_uuid_type));
|
||||
|
||||
|
||||
/** @brief Decode little endian raw UUID bytes (16-bit or 128-bit) into a 24 bit @ref ble_uuid_t structure.
|
||||
*
|
||||
* @details The raw UUID bytes excluding bytes 12 and 13 (i.e. bytes 0-11 and 14-15) of p_uuid_le are compared
|
||||
* to the corresponding ones in each entry of the table of vendor specific UUIDs populated with @ref sd_ble_uuid_vs_add
|
||||
* to look for a match. If there is such a match, bytes 12 and 13 are returned as p_uuid->uuid and the index
|
||||
* relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN as p_uuid->type.
|
||||
*
|
||||
* @note If the UUID length supplied is 2, then the type set by this call will always be @ref BLE_UUID_TYPE_BLE.
|
||||
*
|
||||
* @param[in] uuid_le_len Length in bytes of the buffer pointed to by p_uuid_le (must be 2 or 16 bytes).
|
||||
* @param[in] p_uuid_le Pointer pointing to little endian raw UUID bytes.
|
||||
* @param[out] p_uuid Pointer to a @ref ble_uuid_t structure to be filled in.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully decoded into the @ref ble_uuid_t structure.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH Invalid UUID length.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND For a 128-bit UUID, no match in the populated table of UUIDs.
|
||||
*/
|
||||
SVCALL(SD_BLE_UUID_DECODE, uint32_t, sd_ble_uuid_decode(uint8_t uuid_le_len, uint8_t const *p_uuid_le, ble_uuid_t *p_uuid));
|
||||
|
||||
|
||||
/** @brief Encode a @ref ble_uuid_t structure into little endian raw UUID bytes (16-bit or 128-bit).
|
||||
*
|
||||
* @note The pointer to the destination buffer p_uuid_le may be NULL, in which case only the validity and size of p_uuid is computed.
|
||||
*
|
||||
* @param[in] p_uuid Pointer to a @ref ble_uuid_t structure that will be encoded into bytes.
|
||||
* @param[out] p_uuid_le_len Pointer to a uint8_t that will be filled with the encoded length (2 or 16 bytes).
|
||||
* @param[out] p_uuid_le Pointer to a buffer where the little endian raw UUID bytes (2 or 16) will be stored.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully encoded into the buffer.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid UUID type.
|
||||
*/
|
||||
SVCALL(SD_BLE_UUID_ENCODE, uint32_t, sd_ble_uuid_encode(ble_uuid_t const *p_uuid, uint8_t *p_uuid_le_len, uint8_t *p_uuid_le));
|
||||
|
||||
|
||||
/**@brief Get Version Information.
|
||||
*
|
||||
* @details This call allows the application to get the BLE stack version information.
|
||||
*
|
||||
* @param[out] p_version Pointer to a ble_version_t structure to be filled in.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Version information stored successfully.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_BUSY The BLE stack is busy (typically doing a locally-initiated disconnection procedure).
|
||||
*/
|
||||
SVCALL(SD_BLE_VERSION_GET, uint32_t, sd_ble_version_get(ble_version_t *p_version));
|
||||
|
||||
|
||||
/**@brief Provide a user memory block.
|
||||
*
|
||||
* @note This call can only be used as a response to a @ref BLE_EVT_USER_MEM_REQUEST event issued to the application.
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in,out] p_block Pointer to a user memory block structure.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_PEER_CANCEL_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_AUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_AUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_NOAUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully queued a response to the peer.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection state or no execute write request pending.
|
||||
* @retval ::NRF_ERROR_BUSY The BLE stack is busy. Retry at later time.
|
||||
*/
|
||||
SVCALL(SD_BLE_USER_MEM_REPLY, uint32_t, sd_ble_user_mem_reply(uint16_t conn_handle, ble_user_mem_block_t const *p_block));
|
||||
|
||||
/**@brief Set a BLE option.
|
||||
*
|
||||
* @details This call allows the application to set the value of an option.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GAP_PERIPH_BONDING_STATIC_PK_MSC}
|
||||
* @mmsc{@ref BLE_COMMON_CONF_BW}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] opt_id Option ID, see @ref BLE_COMMON_OPTS and @ref BLE_GAP_OPTS.
|
||||
* @param[in] p_opt Pointer to a ble_opt_t structure containing the option value.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Option set successfully.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Unable to set the parameter at this time.
|
||||
* @retval ::NRF_ERROR_BUSY The BLE stack is busy or the previous procedure has not completed.
|
||||
*/
|
||||
SVCALL(SD_BLE_OPT_SET, uint32_t, sd_ble_opt_set(uint32_t opt_id, ble_opt_t const *p_opt));
|
||||
|
||||
|
||||
/**@brief Get a BLE option.
|
||||
*
|
||||
* @details This call allows the application to retrieve the value of an option.
|
||||
*
|
||||
* @param[in] opt_id Option ID, see @ref BLE_COMMON_OPTS and @ref BLE_GAP_OPTS.
|
||||
* @param[out] p_opt Pointer to a ble_opt_t structure to be filled in.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Option retrieved successfully.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Unable to retrieve the parameter at this time.
|
||||
* @retval ::NRF_ERROR_BUSY The BLE stack is busy or the previous procedure has not completed.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED This option is not supported.
|
||||
*
|
||||
*/
|
||||
SVCALL(SD_BLE_OPT_GET, uint32_t, sd_ble_opt_get(uint32_t opt_id, ble_opt_t *p_opt));
|
||||
|
||||
/** @} */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* NRF_BLE_H__ */
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
@addtogroup BLE_COMMON
|
||||
@{
|
||||
@addtogroup nrf_error
|
||||
@{
|
||||
@ingroup BLE_COMMON
|
||||
@}
|
||||
|
||||
@defgroup ble_err General error codes
|
||||
@{
|
||||
|
||||
@brief General error code definitions for the BLE API.
|
||||
|
||||
@ingroup BLE_COMMON
|
||||
*/
|
||||
#ifndef NRF_BLE_ERR_H__
|
||||
#define NRF_BLE_ERR_H__
|
||||
|
||||
#include "nrf_error.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* @defgroup BLE_ERRORS Error Codes
|
||||
* @{ */
|
||||
#define BLE_ERROR_NOT_ENABLED (NRF_ERROR_STK_BASE_NUM+0x001) /**< @ref sd_ble_enable has not been called. */
|
||||
#define BLE_ERROR_INVALID_CONN_HANDLE (NRF_ERROR_STK_BASE_NUM+0x002) /**< Invalid connection handle. */
|
||||
#define BLE_ERROR_INVALID_ATTR_HANDLE (NRF_ERROR_STK_BASE_NUM+0x003) /**< Invalid attribute handle. */
|
||||
#define BLE_ERROR_NO_TX_PACKETS (NRF_ERROR_STK_BASE_NUM+0x004) /**< Not enough application packets available on this connection. */
|
||||
#define BLE_ERROR_INVALID_ROLE (NRF_ERROR_STK_BASE_NUM+0x005) /**< Invalid role. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_ERROR_SUBRANGES Module specific error code subranges
|
||||
* @brief Assignment of subranges for module specific error codes.
|
||||
* @note For specific error codes, see ble_<module>.h or ble_error_<module>.h.
|
||||
* @{ */
|
||||
#define NRF_L2CAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x100) /**< L2CAP specific errors. */
|
||||
#define NRF_GAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x200) /**< GAP specific errors. */
|
||||
#define NRF_GATTC_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x300) /**< GATT client specific errors. */
|
||||
#define NRF_GATTS_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x400) /**< GATT server specific errors. */
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,215 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
@addtogroup BLE_GATT Generic Attribute Profile (GATT) Common
|
||||
@{
|
||||
@brief Common definitions and prototypes for the GATT interfaces.
|
||||
*/
|
||||
|
||||
#ifndef NRF_BLE_GATT_H__
|
||||
#define NRF_BLE_GATT_H__
|
||||
|
||||
#include "nrf_ble_types.h"
|
||||
#include "nrf_ble_ranges.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup BLE_GATT_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/** @brief Default MTU size. */
|
||||
#define GATT_MTU_SIZE_DEFAULT 23
|
||||
|
||||
/** @brief Only the default MTU size of 23 is currently supported. */
|
||||
#define GATT_RX_MTU 23
|
||||
|
||||
|
||||
/**@brief Invalid Attribute Handle. */
|
||||
#define BLE_GATT_HANDLE_INVALID 0x0000
|
||||
|
||||
/**@brief First Attribute Handle. */
|
||||
#define BLE_GATT_HANDLE_START 0x0001
|
||||
|
||||
/**@brief Last Attribute Handle. */
|
||||
#define BLE_GATT_HANDLE_END 0xFFFF
|
||||
|
||||
/** @defgroup BLE_GATT_TIMEOUT_SOURCES GATT Timeout sources
|
||||
* @{ */
|
||||
#define BLE_GATT_TIMEOUT_SRC_PROTOCOL 0x00 /**< ATT Protocol timeout. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_WRITE_OPS GATT Write operations
|
||||
* @{ */
|
||||
#define BLE_GATT_OP_INVALID 0x00 /**< Invalid Operation. */
|
||||
#define BLE_GATT_OP_WRITE_REQ 0x01 /**< Write Request. */
|
||||
#define BLE_GATT_OP_WRITE_CMD 0x02 /**< Write Command. */
|
||||
#define BLE_GATT_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */
|
||||
#define BLE_GATT_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */
|
||||
#define BLE_GATT_OP_EXEC_WRITE_REQ 0x05 /**< Execute Write Request. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_EXEC_WRITE_FLAGS GATT Execute Write flags
|
||||
* @{ */
|
||||
#define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL 0x00
|
||||
#define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE 0x01
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_HVX_TYPES GATT Handle Value operations
|
||||
* @{ */
|
||||
#define BLE_GATT_HVX_INVALID 0x00 /**< Invalid Operation. */
|
||||
#define BLE_GATT_HVX_NOTIFICATION 0x01 /**< Handle Value Notification. */
|
||||
#define BLE_GATT_HVX_INDICATION 0x02 /**< Handle Value Indication. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_STATUS_CODES GATT Status Codes
|
||||
* @{ */
|
||||
#define BLE_GATT_STATUS_SUCCESS 0x0000 /**< Success. */
|
||||
#define BLE_GATT_STATUS_UNKNOWN 0x0001 /**< Unknown or not applicable status. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID 0x0100 /**< ATT Error: Invalid Error Code. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID_HANDLE 0x0101 /**< ATT Error: Invalid Attribute Handle. */
|
||||
#define BLE_GATT_STATUS_ATTERR_READ_NOT_PERMITTED 0x0102 /**< ATT Error: Read not permitted. */
|
||||
#define BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED 0x0103 /**< ATT Error: Write not permitted. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID_PDU 0x0104 /**< ATT Error: Used in ATT as Invalid PDU. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION 0x0105 /**< ATT Error: Authenticated link required. */
|
||||
#define BLE_GATT_STATUS_ATTERR_REQUEST_NOT_SUPPORTED 0x0106 /**< ATT Error: Used in ATT as Request Not Supported. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID_OFFSET 0x0107 /**< ATT Error: Offset specified was past the end of the attribute. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_AUTHORIZATION 0x0108 /**< ATT Error: Used in ATT as Insufficient Authorisation. */
|
||||
#define BLE_GATT_STATUS_ATTERR_PREPARE_QUEUE_FULL 0x0109 /**< ATT Error: Used in ATT as Prepare Queue Full. */
|
||||
#define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND 0x010A /**< ATT Error: Used in ATT as Attribute not found. */
|
||||
#define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_LONG 0x010B /**< ATT Error: Attribute cannot be read or written using read/write blob requests. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_ENC_KEY_SIZE 0x010C /**< ATT Error: Encryption key size used is insufficient. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID_ATT_VAL_LENGTH 0x010D /**< ATT Error: Invalid value size. */
|
||||
#define BLE_GATT_STATUS_ATTERR_UNLIKELY_ERROR 0x010E /**< ATT Error: Very unlikely error. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION 0x010F /**< ATT Error: Encrypted link required. */
|
||||
#define BLE_GATT_STATUS_ATTERR_UNSUPPORTED_GROUP_TYPE 0x0110 /**< ATT Error: Attribute type is not a supported grouping attribute. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_RESOURCES 0x0111 /**< ATT Error: Encrypted link required. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_BEGIN 0x0112 /**< ATT Error: Reserved for Future Use range #1 begin. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_END 0x017F /**< ATT Error: Reserved for Future Use range #1 end. */
|
||||
#define BLE_GATT_STATUS_ATTERR_APP_BEGIN 0x0180 /**< ATT Error: Application range begin. */
|
||||
#define BLE_GATT_STATUS_ATTERR_APP_END 0x019F /**< ATT Error: Application range end. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_BEGIN 0x01A0 /**< ATT Error: Reserved for Future Use range #2 begin. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_END 0x01DF /**< ATT Error: Reserved for Future Use range #2 end. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_BEGIN 0x01E0 /**< ATT Error: Reserved for Future Use range #3 begin. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_END 0x01FC /**< ATT Error: Reserved for Future Use range #3 end. */
|
||||
#define BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR 0x01FD /**< ATT Common Profile and Service Error: Client Characteristic Configuration Descriptor improperly configured. */
|
||||
#define BLE_GATT_STATUS_ATTERR_CPS_PROC_ALR_IN_PROG 0x01FE /**< ATT Common Profile and Service Error: Procedure Already in Progress. */
|
||||
#define BLE_GATT_STATUS_ATTERR_CPS_OUT_OF_RANGE 0x01FF /**< ATT Common Profile and Service Error: Out Of Range. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_GATT_CPF_FORMATS Characteristic Presentation Formats
|
||||
* @note Found at http://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml
|
||||
* @{ */
|
||||
#define BLE_GATT_CPF_FORMAT_RFU 0x00 /**< Reserved For Future Use. */
|
||||
#define BLE_GATT_CPF_FORMAT_BOOLEAN 0x01 /**< Boolean. */
|
||||
#define BLE_GATT_CPF_FORMAT_2BIT 0x02 /**< Unsigned 2-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_NIBBLE 0x03 /**< Unsigned 4-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT8 0x04 /**< Unsigned 8-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT12 0x05 /**< Unsigned 12-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT16 0x06 /**< Unsigned 16-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT24 0x07 /**< Unsigned 24-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT32 0x08 /**< Unsigned 32-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT48 0x09 /**< Unsigned 48-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT64 0x0A /**< Unsigned 64-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT128 0x0B /**< Unsigned 128-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT8 0x0C /**< Signed 2-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT12 0x0D /**< Signed 12-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT16 0x0E /**< Signed 16-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT24 0x0F /**< Signed 24-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT32 0x10 /**< Signed 32-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT48 0x11 /**< Signed 48-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT64 0x12 /**< Signed 64-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT128 0x13 /**< Signed 128-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_FLOAT32 0x14 /**< IEEE-754 32-bit floating point. */
|
||||
#define BLE_GATT_CPF_FORMAT_FLOAT64 0x15 /**< IEEE-754 64-bit floating point. */
|
||||
#define BLE_GATT_CPF_FORMAT_SFLOAT 0x16 /**< IEEE-11073 16-bit SFLOAT. */
|
||||
#define BLE_GATT_CPF_FORMAT_FLOAT 0x17 /**< IEEE-11073 32-bit FLOAT. */
|
||||
#define BLE_GATT_CPF_FORMAT_DUINT16 0x18 /**< IEEE-20601 format. */
|
||||
#define BLE_GATT_CPF_FORMAT_UTF8S 0x19 /**< UTF-8 string. */
|
||||
#define BLE_GATT_CPF_FORMAT_UTF16S 0x1A /**< UTF-16 string. */
|
||||
#define BLE_GATT_CPF_FORMAT_STRUCT 0x1B /**< Opaque Structure. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_CPF_NAMESPACES GATT Bluetooth Namespaces
|
||||
* @{
|
||||
*/
|
||||
#define BLE_GATT_CPF_NAMESPACE_BTSIG 0x01 /**< Bluetooth SIG defined Namespace. */
|
||||
#define BLE_GATT_CPF_NAMESPACE_DESCRIPTION_UNKNOWN 0x0000 /**< Namespace Description Unknown. */
|
||||
/** @} */
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATT_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**@brief GATT Characteristic Properties. */
|
||||
typedef struct
|
||||
{
|
||||
/* Standard properties */
|
||||
uint8_t broadcast :1; /**< Broadcasting of the value permitted. */
|
||||
uint8_t read :1; /**< Reading the value permitted. */
|
||||
uint8_t write_wo_resp :1; /**< Writing the value with Write Command permitted. */
|
||||
uint8_t write :1; /**< Writing the value with Write Request permitted. */
|
||||
uint8_t notify :1; /**< Notications of the value permitted. */
|
||||
uint8_t indicate :1; /**< Indications of the value permitted. */
|
||||
uint8_t auth_signed_wr :1; /**< Writing the value with Signed Write Command permitted. */
|
||||
} ble_gatt_char_props_t;
|
||||
|
||||
/**@brief GATT Characteristic Extended Properties. */
|
||||
typedef struct
|
||||
{
|
||||
/* Extended properties */
|
||||
uint8_t reliable_wr :1; /**< Writing the value with Queued Write operations permitted. */
|
||||
uint8_t wr_aux :1; /**< Writing the Characteristic User Description descriptor permitted. */
|
||||
} ble_gatt_char_ext_props_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_BLE_GATT_H__
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,572 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
@addtogroup BLE_GATTC Generic Attribute Profile (GATT) Client
|
||||
@{
|
||||
@brief Definitions and prototypes for the GATT Client interface.
|
||||
*/
|
||||
|
||||
#ifndef NRF_BLE_GATTC_H__
|
||||
#define NRF_BLE_GATTC_H__
|
||||
|
||||
#include "nrf_ble_gatt.h"
|
||||
#include "nrf_ble_types.h"
|
||||
#include "nrf_ble_ranges.h"
|
||||
#include "nrf_svc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup BLE_GATTC_ENUMERATIONS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief GATTC API SVC numbers. */
|
||||
enum BLE_GATTC_SVCS
|
||||
{
|
||||
SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER = BLE_GATTC_SVC_BASE, /**< Primary Service Discovery. */
|
||||
SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, /**< Relationship Discovery. */
|
||||
SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, /**< Characteristic Discovery. */
|
||||
SD_BLE_GATTC_DESCRIPTORS_DISCOVER, /**< Characteristic Descriptor Discovery. */
|
||||
SD_BLE_GATTC_ATTR_INFO_DISCOVER, /**< Attribute Information Discovery. */
|
||||
SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, /**< Read Characteristic Value by UUID. */
|
||||
SD_BLE_GATTC_READ, /**< Generic read. */
|
||||
SD_BLE_GATTC_CHAR_VALUES_READ, /**< Read multiple Characteristic Values. */
|
||||
SD_BLE_GATTC_WRITE, /**< Generic write. */
|
||||
SD_BLE_GATTC_HV_CONFIRM, /**< Handle Value Confirmation. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief GATT Client Event IDs.
|
||||
*/
|
||||
enum BLE_GATTC_EVTS
|
||||
{
|
||||
BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP = BLE_GATTC_EVT_BASE, /**< Primary Service Discovery Response event. \n See @ref ble_gattc_evt_prim_srvc_disc_rsp_t. */
|
||||
BLE_GATTC_EVT_REL_DISC_RSP, /**< Relationship Discovery Response event. \n See @ref ble_gattc_evt_rel_disc_rsp_t. */
|
||||
BLE_GATTC_EVT_CHAR_DISC_RSP, /**< Characteristic Discovery Response event. \n See @ref ble_gattc_evt_char_disc_rsp_t. */
|
||||
BLE_GATTC_EVT_DESC_DISC_RSP, /**< Descriptor Discovery Response event. \n See @ref ble_gattc_evt_desc_disc_rsp_t. */
|
||||
BLE_GATTC_EVT_ATTR_INFO_DISC_RSP, /**< Attribute Information Response event. \n See @ref ble_gattc_evt_attr_info_disc_rsp_t. */
|
||||
BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP, /**< Read By UUID Response event. \n See @ref ble_gattc_evt_char_val_by_uuid_read_rsp_t. */
|
||||
BLE_GATTC_EVT_READ_RSP, /**< Read Response event. \n See @ref ble_gattc_evt_read_rsp_t. */
|
||||
BLE_GATTC_EVT_CHAR_VALS_READ_RSP, /**< Read multiple Response event. \n See @ref ble_gattc_evt_char_vals_read_rsp_t. */
|
||||
BLE_GATTC_EVT_WRITE_RSP, /**< Write Response event. \n See @ref ble_gattc_evt_write_rsp_t. */
|
||||
BLE_GATTC_EVT_HVX, /**< Handle Value Notification or Indication event. \n Confirm indication with @ref sd_ble_gattc_hv_confirm. \n See @ref ble_gattc_evt_hvx_t. */
|
||||
BLE_GATTC_EVT_TIMEOUT /**< Timeout event. \n See @ref ble_gattc_evt_timeout_t. */
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTC_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/** @defgroup BLE_ERRORS_GATTC SVC return values specific to GATTC
|
||||
* @{ */
|
||||
#define BLE_ERROR_GATTC_PROC_NOT_PERMITTED (NRF_GATTC_ERR_BASE + 0x000) /**< Procedure not Permitted. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATTC_ATTR_INFO_FORMAT Attribute Information Formats
|
||||
* @{ */
|
||||
#define BLE_GATTC_ATTR_INFO_FORMAT_16BIT 1 /**< 16-bit Attribute Information Format. */
|
||||
#define BLE_GATTC_ATTR_INFO_FORMAT_128BIT 2 /**< 128-bit Attribute Information Format. */
|
||||
/** @} */
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTC_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**@brief Operation Handle Range. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t start_handle; /**< Start Handle. */
|
||||
uint16_t end_handle; /**< End Handle. */
|
||||
} ble_gattc_handle_range_t;
|
||||
|
||||
|
||||
/**@brief GATT service. */
|
||||
typedef struct
|
||||
{
|
||||
ble_uuid_t uuid; /**< Service UUID. */
|
||||
ble_gattc_handle_range_t handle_range; /**< Service Handle Range. */
|
||||
} ble_gattc_service_t;
|
||||
|
||||
|
||||
/**@brief GATT include. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Include Handle. */
|
||||
ble_gattc_service_t included_srvc; /**< Handle of the included service. */
|
||||
} ble_gattc_include_t;
|
||||
|
||||
|
||||
/**@brief GATT characteristic. */
|
||||
typedef struct
|
||||
{
|
||||
ble_uuid_t uuid; /**< Characteristic UUID. */
|
||||
ble_gatt_char_props_t char_props; /**< Characteristic Properties. */
|
||||
uint8_t char_ext_props : 1; /**< Extended properties present. */
|
||||
uint16_t handle_decl; /**< Handle of the Characteristic Declaration. */
|
||||
uint16_t handle_value; /**< Handle of the Characteristic Value. */
|
||||
} ble_gattc_char_t;
|
||||
|
||||
|
||||
/**@brief GATT descriptor. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Descriptor Handle. */
|
||||
ble_uuid_t uuid; /**< Descriptor UUID. */
|
||||
} ble_gattc_desc_t;
|
||||
|
||||
|
||||
/**@brief Write Parameters. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t write_op; /**< Write Operation to be performed, see @ref BLE_GATT_WRITE_OPS. */
|
||||
uint8_t flags; /**< Flags, see @ref BLE_GATT_EXEC_WRITE_FLAGS. */
|
||||
uint16_t handle; /**< Handle to the attribute to be written. */
|
||||
uint16_t offset; /**< Offset in bytes. @note For WRITE_CMD and WRITE_REQ, offset must be 0. */
|
||||
uint16_t len; /**< Length of data in bytes. */
|
||||
uint8_t *p_value; /**< Pointer to the value data. */
|
||||
} ble_gattc_write_params_t;
|
||||
|
||||
/**@brief Attribute Information. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute handle. */
|
||||
union {
|
||||
ble_uuid_t uuid16; /**< 16-bit Attribute UUID. */
|
||||
ble_uuid128_t uuid128; /**< 128-bit Attribute UUID. */
|
||||
} info;
|
||||
} ble_gattc_attr_info_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t count; /**< Service count. */
|
||||
ble_gattc_service_t services[1]; /**< Service data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_prim_srvc_disc_rsp_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_REL_DISC_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t count; /**< Include count. */
|
||||
ble_gattc_include_t includes[1]; /**< Include data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_rel_disc_rsp_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_DISC_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t count; /**< Characteristic count. */
|
||||
ble_gattc_char_t chars[1]; /**< Characteristic data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_char_disc_rsp_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_DESC_DISC_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t count; /**< Descriptor count. */
|
||||
ble_gattc_desc_t descs[1]; /**< Descriptor data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_desc_disc_rsp_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_ATTR_INFO_DISC_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t count; /**< Attribute count. */
|
||||
uint8_t format; /**< Attribute information format, see @ref BLE_GATTC_ATTR_INFO_FORMAT. */
|
||||
ble_gattc_attr_info_t attr_info[1]; /**< Attribute information. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_attr_info_disc_rsp_t;
|
||||
|
||||
/**@brief GATT read by UUID handle value pair. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute Handle. */
|
||||
uint8_t *p_value; /**< Pointer to value, variable length (length available as value_len in @ref ble_gattc_evt_char_val_by_uuid_read_rsp_t).
|
||||
Please note that this pointer is absolute to the memory provided by the user when retrieving the event,
|
||||
so it will effectively point to a location inside the handle_value array. */
|
||||
} ble_gattc_handle_value_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t count; /**< Handle-Value Pair Count. */
|
||||
uint16_t value_len; /**< Length of the value in Handle-Value(s) list. */
|
||||
ble_gattc_handle_value_t handle_value[1]; /**< Handle-Value(s) list. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_char_val_by_uuid_read_rsp_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_READ_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute Handle. */
|
||||
uint16_t offset; /**< Offset of the attribute data. */
|
||||
uint16_t len; /**< Attribute data length. */
|
||||
uint8_t data[1]; /**< Attribute data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_read_rsp_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_VALS_READ_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t len; /**< Concatenated Attribute values length. */
|
||||
uint8_t values[1]; /**< Attribute values. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_char_vals_read_rsp_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_WRITE_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute Handle. */
|
||||
uint8_t write_op; /**< Type of write operation, see @ref BLE_GATT_WRITE_OPS. */
|
||||
uint16_t offset; /**< Data offset. */
|
||||
uint16_t len; /**< Data length. */
|
||||
uint8_t data[1]; /**< Data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_write_rsp_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_HVX. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Handle to which the HVx operation applies. */
|
||||
uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */
|
||||
uint16_t len; /**< Attribute data length. */
|
||||
uint8_t data[1]; /**< Attribute data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_hvx_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_TIMEOUT. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */
|
||||
} ble_gattc_evt_timeout_t;
|
||||
|
||||
/**@brief GATTC event structure. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t conn_handle; /**< Connection Handle on which event occured. */
|
||||
uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */
|
||||
uint16_t error_handle; /**< In case of error: The handle causing the error. In all other cases @ref BLE_GATT_HANDLE_INVALID. */
|
||||
union
|
||||
{
|
||||
ble_gattc_evt_prim_srvc_disc_rsp_t prim_srvc_disc_rsp; /**< Primary Service Discovery Response Event Parameters. */
|
||||
ble_gattc_evt_rel_disc_rsp_t rel_disc_rsp; /**< Relationship Discovery Response Event Parameters. */
|
||||
ble_gattc_evt_char_disc_rsp_t char_disc_rsp; /**< Characteristic Discovery Response Event Parameters. */
|
||||
ble_gattc_evt_desc_disc_rsp_t desc_disc_rsp; /**< Descriptor Discovery Response Event Parameters. */
|
||||
ble_gattc_evt_char_val_by_uuid_read_rsp_t char_val_by_uuid_read_rsp; /**< Characteristic Value Read by UUID Response Event Parameters. */
|
||||
ble_gattc_evt_read_rsp_t read_rsp; /**< Read Response Event Parameters. */
|
||||
ble_gattc_evt_char_vals_read_rsp_t char_vals_read_rsp; /**< Characteristic Values Read Response Event Parameters. */
|
||||
ble_gattc_evt_write_rsp_t write_rsp; /**< Write Response Event Parameters. */
|
||||
ble_gattc_evt_hvx_t hvx; /**< Handle Value Notification/Indication Event Parameters. */
|
||||
ble_gattc_evt_timeout_t timeout; /**< Timeout Event Parameters. */
|
||||
ble_gattc_evt_attr_info_disc_rsp_t attr_info_disc_rsp; /**< Attribute Information Discovery Event Parameters. */
|
||||
} params; /**< Event Parameters. @note Only valid if @ref gatt_status == @ref BLE_GATT_STATUS_SUCCESS. */
|
||||
} ble_gattc_evt_t;
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTC_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Initiate or continue a GATT Primary Service Discovery procedure.
|
||||
*
|
||||
* @details This function initiates or resumes a Primary Service discovery procedure, starting from the supplied handle.
|
||||
* If the last service has not been reached, this function must be called again with an updated start handle value to continue the search.
|
||||
*
|
||||
* @note If any of the discovered services have 128-bit UUIDs which are not present in the table provided to ble_vs_uuids_assign, a UUID structure with
|
||||
* type @ref BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_PRIM_SRVC_DISC_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] start_handle Handle to start searching from.
|
||||
* @param[in] p_srvc_uuid Pointer to the service UUID to be found. If it is NULL, all primary services will be returned.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully started or resumed the Primary Service Discovery procedure.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER, uint32_t, sd_ble_gattc_primary_services_discover(uint16_t conn_handle, uint16_t start_handle, ble_uuid_t const *p_srvc_uuid));
|
||||
|
||||
|
||||
/**@brief Initiate or continue a GATT Relationship Discovery procedure.
|
||||
*
|
||||
* @details This function initiates or resumes the Find Included Services sub-procedure. If the last included service has not been reached,
|
||||
* this must be called again with an updated handle range to continue the search.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_REL_DISC_RSP}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_REL_DISC_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully started or resumed the Relationship Discovery procedure.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, uint32_t, sd_ble_gattc_relationships_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range));
|
||||
|
||||
|
||||
/**@brief Initiate or continue a GATT Characteristic Discovery procedure.
|
||||
*
|
||||
* @details This function initiates or resumes a Characteristic discovery procedure. If the last Characteristic has not been reached,
|
||||
* this must be called again with an updated handle range to continue the discovery.
|
||||
*
|
||||
* @note If any of the discovered characteristics have 128-bit UUIDs which are not present in the table provided to ble_vs_uuids_assign, a UUID structure with
|
||||
* type @ref BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_CHAR_DISC_RSP}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_CHAR_DISC_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully started or resumed the Characteristic Discovery procedure.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, uint32_t, sd_ble_gattc_characteristics_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range));
|
||||
|
||||
|
||||
/**@brief Initiate or continue a GATT Characteristic Descriptor Discovery procedure.
|
||||
*
|
||||
* @details This function initiates or resumes a Characteristic Descriptor discovery procedure. If the last Descriptor has not been reached,
|
||||
* this must be called again with an updated handle range to continue the discovery.
|
||||
*
|
||||
* @events
|
||||
* @event{BLE_GATTC_EVT_DESC_DISC_RSP}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_DESC_DISC_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_handle_range A pointer to the range of handles of the Characteristic to perform this procedure on.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully started or resumed the Descriptor Discovery procedure.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_DESCRIPTORS_DISCOVER, uint32_t, sd_ble_gattc_descriptors_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range));
|
||||
|
||||
|
||||
/**@brief Initiate or continue a GATT Read using Characteristic UUID procedure.
|
||||
*
|
||||
* @details This function initiates or resumes a Read using Characteristic UUID procedure. If the last Characteristic has not been reached,
|
||||
* this must be called again with an updated handle range to continue the discovery.
|
||||
*
|
||||
* @events
|
||||
* @event{BLE_GATTC_EVT_DESC_DISC_RSP}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_READ_UUID_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_uuid Pointer to a Characteristic value UUID to read.
|
||||
* @param[in] p_handle_range A pointer to the range of handles to perform this procedure on.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully started or resumed the Read using Characteristic UUID procedure.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, uint32_t, sd_ble_gattc_char_value_by_uuid_read(uint16_t conn_handle, ble_uuid_t const *p_uuid, ble_gattc_handle_range_t const *p_handle_range));
|
||||
|
||||
|
||||
/**@brief Initiate or continue a GATT Read (Long) Characteristic or Descriptor procedure.
|
||||
*
|
||||
* @details This function initiates or resumes a GATT Read (Long) Characteristic or Descriptor procedure. If the Characteristic or Descriptor
|
||||
* to be read is longer than ATT_MTU - 1, this function must be called multiple times with appropriate offset to read the
|
||||
* complete value.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_VALUE_READ_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] handle The handle of the attribute to be read.
|
||||
* @param[in] offset Offset into the attribute value to be read.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully started or resumed the Read (Long) procedure.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
|
||||
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_READ, uint32_t, sd_ble_gattc_read(uint16_t conn_handle, uint16_t handle, uint16_t offset));
|
||||
|
||||
|
||||
/**@brief Initiate a GATT Read Multiple Characteristic Values procedure.
|
||||
*
|
||||
* @details This function initiates a GATT Read Multiple Characteristic Values procedure.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_CHAR_VALS_READ_RSP}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_READ_MULT_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_handles A pointer to the handle(s) of the attribute(s) to be read.
|
||||
* @param[in] handle_count The number of handles in p_handles.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully started the Read Multiple Characteristic Values procedure.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_CHAR_VALUES_READ, uint32_t, sd_ble_gattc_char_values_read(uint16_t conn_handle, uint16_t const *p_handles, uint16_t handle_count));
|
||||
|
||||
|
||||
/**@brief Perform a Write (Characteristic Value or Descriptor, with or without response, signed or not, long or reliable) procedure.
|
||||
*
|
||||
* @details This function can perform all write procedures described in GATT.
|
||||
*
|
||||
* @note It is important to note that a write without response will <b>consume an application buffer</b>, and will therefore
|
||||
* generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted. A write (with response) on the other hand will use the
|
||||
* standard client internal buffer and thus will only generate a @ref BLE_GATTC_EVT_WRITE_RSP event as soon as the write response
|
||||
* has been received from the peer. Please see the documentation of @ref sd_ble_tx_packet_count_get for more details.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_WRITE_RSP, Generated when using write request or queued writes.}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_VALUE_WRITE_MSC}
|
||||
* @mmsc{@ref BLE_GATTC_VALUE_LONG_WRITE_MSC}
|
||||
* @mmsc{@ref BLE_GATTC_VALUE_RELIABLE_WRITE_MSC}
|
||||
* @mmsc{@ref BLE_COMMON_APP_BUFF_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_write_params A pointer to a write parameters structure.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully started the Write procedure.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Procedure already in progress.
|
||||
* @retval ::BLE_ERROR_NO_TX_PACKETS No available application packets for this connection.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_WRITE, uint32_t, sd_ble_gattc_write(uint16_t conn_handle, ble_gattc_write_params_t const *p_write_params));
|
||||
|
||||
|
||||
/**@brief Send a Handle Value Confirmation to the GATT Server.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_HVI_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] handle The handle of the attribute in the indication.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully queued the Handle Value Confirmation for transmission.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no Indication pending to be confirmed.
|
||||
* @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_HV_CONFIRM, uint32_t, sd_ble_gattc_hv_confirm(uint16_t conn_handle, uint16_t handle));
|
||||
|
||||
/**@brief Discovers information about a range of attributes on a GATT server.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_ATTR_INFO_DISC_RSP, Generated when information about a range of attributes has been received.}
|
||||
* @endevents
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_handle_range The range of handles to request information about.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully started an attribute information discovery procedure.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid connection state
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_ATTR_INFO_DISCOVER, uint32_t, sd_ble_gattc_attr_info_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * p_handle_range));
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* NRF_BLE_GATTC_H__ */
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,725 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
@addtogroup BLE_GATTS Generic Attribute Profile (GATT) Server
|
||||
@{
|
||||
@brief Definitions and prototypes for the GATTS interface.
|
||||
*/
|
||||
|
||||
#ifndef NRF_BLE_GATTS_H__
|
||||
#define NRF_BLE_GATTS_H__
|
||||
|
||||
#include "nrf_ble_types.h"
|
||||
#include "nrf_ble_ranges.h"
|
||||
#include "nrf_ble_l2cap.h"
|
||||
#include "nrf_ble_gap.h"
|
||||
#include "nrf_ble_gatt.h"
|
||||
#include "nrf_svc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup BLE_GATTS_ENUMERATIONS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**
|
||||
* @brief GATTS API SVC numbers.
|
||||
*/
|
||||
enum BLE_GATTS_SVCS
|
||||
{
|
||||
SD_BLE_GATTS_SERVICE_ADD = BLE_GATTS_SVC_BASE, /**< Add a service. */
|
||||
SD_BLE_GATTS_INCLUDE_ADD, /**< Add an included service. */
|
||||
SD_BLE_GATTS_CHARACTERISTIC_ADD, /**< Add a characteristic. */
|
||||
SD_BLE_GATTS_DESCRIPTOR_ADD, /**< Add a generic attribute. */
|
||||
SD_BLE_GATTS_VALUE_SET, /**< Set an attribute value. */
|
||||
SD_BLE_GATTS_VALUE_GET, /**< Get an attribute value. */
|
||||
SD_BLE_GATTS_HVX, /**< Handle Value Notification or Indication. */
|
||||
SD_BLE_GATTS_SERVICE_CHANGED, /**< Perform a Service Changed Indication to one or more peers. */
|
||||
SD_BLE_GATTS_RW_AUTHORIZE_REPLY, /**< Reply to an authorization request for a read or write operation on one or more attributes. */
|
||||
SD_BLE_GATTS_SYS_ATTR_SET, /**< Set the persistent system attributes for a connection. */
|
||||
SD_BLE_GATTS_SYS_ATTR_GET, /**< Retrieve the persistent system attributes. */
|
||||
SD_BLE_GATTS_INITIAL_USER_HANDLE_GET, /**< Retrieve the first valid user handle. */
|
||||
SD_BLE_GATTS_ATTR_GET /**< Retrieve the UUID and/or metadata of an attribute. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief GATT Server Event IDs.
|
||||
*/
|
||||
enum BLE_GATTS_EVTS
|
||||
{
|
||||
BLE_GATTS_EVT_WRITE = BLE_GATTS_EVT_BASE, /**< Write operation performed. \n See @ref ble_gatts_evt_write_t. */
|
||||
BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST, /**< Read/Write Authorization request. \n Reply with @ref sd_ble_gatts_rw_authorize_reply. \n See @ref ble_gatts_evt_rw_authorize_request_t. */
|
||||
BLE_GATTS_EVT_SYS_ATTR_MISSING, /**< A persistent system attribute access is pending. \n Respond with @ref sd_ble_gatts_sys_attr_set. \n See @ref ble_gatts_evt_sys_attr_missing_t. */
|
||||
BLE_GATTS_EVT_HVC, /**< Handle Value Confirmation. \n See @ref ble_gatts_evt_hvc_t. */
|
||||
BLE_GATTS_EVT_SC_CONFIRM, /**< Service Changed Confirmation. No additional event structure applies. */
|
||||
BLE_GATTS_EVT_TIMEOUT /**< Peer failed to resonpond to an ATT request in time. \n See @ref ble_gatts_evt_timeout_t. */
|
||||
};
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTS_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/** @defgroup BLE_ERRORS_GATTS SVC return values specific to GATTS
|
||||
* @{ */
|
||||
#define BLE_ERROR_GATTS_INVALID_ATTR_TYPE (NRF_GATTS_ERR_BASE + 0x000) /**< Invalid attribute type. */
|
||||
#define BLE_ERROR_GATTS_SYS_ATTR_MISSING (NRF_GATTS_ERR_BASE + 0x001) /**< System Attributes missing. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATTS_ATTR_LENS_MAX Maximum attribute lengths
|
||||
* @{ */
|
||||
#define BLE_GATTS_FIX_ATTR_LEN_MAX (510) /**< Maximum length for fixed length Attribute Values. */
|
||||
#define BLE_GATTS_VAR_ATTR_LEN_MAX (512) /**< Maximum length for variable length Attribute Values. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATTS_SRVC_TYPES GATT Server Service Types
|
||||
* @{ */
|
||||
#define BLE_GATTS_SRVC_TYPE_INVALID 0x00 /**< Invalid Service Type. */
|
||||
#define BLE_GATTS_SRVC_TYPE_PRIMARY 0x01 /**< Primary Service. */
|
||||
#define BLE_GATTS_SRVC_TYPE_SECONDARY 0x02 /**< Secondary Type. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_GATTS_ATTR_TYPES GATT Server Attribute Types
|
||||
* @{ */
|
||||
#define BLE_GATTS_ATTR_TYPE_INVALID 0x00 /**< Invalid Attribute Type. */
|
||||
#define BLE_GATTS_ATTR_TYPE_PRIM_SRVC_DECL 0x01 /**< Primary Service Declaration. */
|
||||
#define BLE_GATTS_ATTR_TYPE_SEC_SRVC_DECL 0x02 /**< Secondary Service Declaration. */
|
||||
#define BLE_GATTS_ATTR_TYPE_INC_DECL 0x03 /**< Include Declaration. */
|
||||
#define BLE_GATTS_ATTR_TYPE_CHAR_DECL 0x04 /**< Characteristic Declaration. */
|
||||
#define BLE_GATTS_ATTR_TYPE_CHAR_VAL 0x05 /**< Characteristic Value. */
|
||||
#define BLE_GATTS_ATTR_TYPE_DESC 0x06 /**< Descriptor. */
|
||||
#define BLE_GATTS_ATTR_TYPE_OTHER 0x07 /**< Other, non-GATT specific type. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_GATTS_OPS GATT Server Operations
|
||||
* @{ */
|
||||
#define BLE_GATTS_OP_INVALID 0x00 /**< Invalid Operation. */
|
||||
#define BLE_GATTS_OP_WRITE_REQ 0x01 /**< Write Request. */
|
||||
#define BLE_GATTS_OP_WRITE_CMD 0x02 /**< Write Command. */
|
||||
#define BLE_GATTS_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */
|
||||
#define BLE_GATTS_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */
|
||||
#define BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL 0x05 /**< Execute Write Request: Cancel all prepared writes. */
|
||||
#define BLE_GATTS_OP_EXEC_WRITE_REQ_NOW 0x06 /**< Execute Write Request: Immediately execute all prepared writes. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATTS_VLOCS GATT Value Locations
|
||||
* @{ */
|
||||
#define BLE_GATTS_VLOC_INVALID 0x00 /**< Invalid Location. */
|
||||
#define BLE_GATTS_VLOC_STACK 0x01 /**< Attribute Value is located in stack memory, no user memory is required. */
|
||||
#define BLE_GATTS_VLOC_USER 0x02 /**< Attribute Value is located in user memory. This requires the user to maintain a valid buffer through the lifetime of the attribute, since the stack
|
||||
will read and write directly to the memory using the pointer provided in the APIs. There are no alignment requirements for the buffer. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATTS_AUTHORIZE_TYPES GATT Server Authorization Types
|
||||
* @{ */
|
||||
#define BLE_GATTS_AUTHORIZE_TYPE_INVALID 0x00 /**< Invalid Type. */
|
||||
#define BLE_GATTS_AUTHORIZE_TYPE_READ 0x01 /**< Authorize a Read Operation. */
|
||||
#define BLE_GATTS_AUTHORIZE_TYPE_WRITE 0x02 /**< Authorize a Write Request Operation. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATTS_SYS_ATTR_FLAGS System Attribute Flags
|
||||
* @{ */
|
||||
#define BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS (1 << 0) /**< Restrict system attributes to system services only. */
|
||||
#define BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS (1 << 1) /**< Restrict system attributes to user services only. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATTS_ATTR_TAB_SIZE Attribute Table size
|
||||
* @{
|
||||
*/
|
||||
#define BLE_GATTS_ATTR_TAB_SIZE_MIN 216 /**< Minimum Attribute Table size */
|
||||
#define BLE_GATTS_ATTR_TAB_SIZE_DEFAULT 0x0000 /**< Default Attribute Table size (0x580 bytes for this version of the SoftDevice). */
|
||||
/** @} */
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTS_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**
|
||||
* @brief BLE GATTS initialization parameters.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t service_changed:1; /**< Include the Service Changed characteristic in the Attribute Table. */
|
||||
uint32_t attr_tab_size; /**< Attribute Table size in bytes. The size must be a multiple of 4. @ref BLE_GATTS_ATTR_TAB_SIZE_DEFAULT is used to set the default size. */
|
||||
} ble_gatts_enable_params_t;
|
||||
|
||||
/**@brief Attribute metadata. */
|
||||
typedef struct
|
||||
{
|
||||
ble_gap_conn_sec_mode_t read_perm; /**< Read permissions. */
|
||||
ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */
|
||||
uint8_t vlen :1; /**< Variable length attribute. */
|
||||
uint8_t vloc :2; /**< Value location, see @ref BLE_GATTS_VLOCS.*/
|
||||
uint8_t rd_auth :1; /**< Read authorization and value will be requested from the application on every read operation. */
|
||||
uint8_t wr_auth :1; /**< Write authorization will be requested from the application on every Write Request operation (but not Write Command). */
|
||||
} ble_gatts_attr_md_t;
|
||||
|
||||
|
||||
/**@brief GATT Attribute. */
|
||||
typedef struct
|
||||
{
|
||||
ble_uuid_t *p_uuid; /**< Pointer to the attribute UUID. */
|
||||
ble_gatts_attr_md_t *p_attr_md; /**< Pointer to the attribute metadata structure. */
|
||||
uint16_t init_len; /**< Initial attribute value length in bytes. */
|
||||
uint16_t init_offs; /**< Initial attribute value offset in bytes. If different from zero, the first init_offs bytes of the attribute value will be left uninitialized. */
|
||||
uint16_t max_len; /**< Maximum attribute value length in bytes, see @ref BLE_GATTS_ATTR_LENS_MAX for maximum values. */
|
||||
uint8_t* p_value; /**< Pointer to the attribute data. Please note that if the @ref BLE_GATTS_VLOC_USER value location is selected in the attribute metadata, this will have to point to a buffer
|
||||
that remains valid through the lifetime of the attribute. This excludes usage of automatic variables that may go out of scope or any other temporary location.
|
||||
The stack may access that memory directly without the application's knowledge. For writable characteristics, this value must not be a location in flash memory.*/
|
||||
} ble_gatts_attr_t;
|
||||
|
||||
/**@brief GATT Attribute Value. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t len; /**< Length in bytes to be written or read. Length in bytes written or read after successful return.*/
|
||||
uint16_t offset; /**< Attribute value offset. */
|
||||
uint8_t *p_value; /**< Pointer to where value is stored or will be stored.
|
||||
If value is stored in user memory, only the attribute length is updated when p_value == NULL.
|
||||
Set to NULL when reading to obtain the complete length of the attribute value */
|
||||
} ble_gatts_value_t;
|
||||
|
||||
|
||||
/**@brief GATT Characteristic Presentation Format. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t format; /**< Format of the value, see @ref BLE_GATT_CPF_FORMATS. */
|
||||
int8_t exponent; /**< Exponent for integer data types. */
|
||||
uint16_t unit; /**< Unit from Bluetooth Assigned Numbers. */
|
||||
uint8_t name_space; /**< Namespace from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */
|
||||
uint16_t desc; /**< Namespace description from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */
|
||||
} ble_gatts_char_pf_t;
|
||||
|
||||
|
||||
/**@brief GATT Characteristic metadata. */
|
||||
typedef struct
|
||||
{
|
||||
ble_gatt_char_props_t char_props; /**< Characteristic Properties. */
|
||||
ble_gatt_char_ext_props_t char_ext_props; /**< Characteristic Extended Properties. */
|
||||
uint8_t *p_char_user_desc; /**< Pointer to a UTF-8 encoded string (non-NULL terminated), NULL if the descriptor is not required. */
|
||||
uint16_t char_user_desc_max_size; /**< The maximum size in bytes of the user description descriptor. */
|
||||
uint16_t char_user_desc_size; /**< The size of the user description, must be smaller or equal to char_user_desc_max_size. */
|
||||
ble_gatts_char_pf_t* p_char_pf; /**< Pointer to a presentation format structure or NULL if the CPF descriptor is not required. */
|
||||
ble_gatts_attr_md_t* p_user_desc_md; /**< Attribute metadata for the User Description descriptor, or NULL for default values. */
|
||||
ble_gatts_attr_md_t* p_cccd_md; /**< Attribute metadata for the Client Characteristic Configuration Descriptor, or NULL for default values. */
|
||||
ble_gatts_attr_md_t* p_sccd_md; /**< Attribute metadata for the Server Characteristic Configuration Descriptor, or NULL for default values. */
|
||||
} ble_gatts_char_md_t;
|
||||
|
||||
|
||||
/**@brief GATT Characteristic Definition Handles. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t value_handle; /**< Handle to the characteristic value. */
|
||||
uint16_t user_desc_handle; /**< Handle to the User Description descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */
|
||||
uint16_t cccd_handle; /**< Handle to the Client Characteristic Configuration Descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */
|
||||
uint16_t sccd_handle; /**< Handle to the Server Characteristic Configuration Descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */
|
||||
} ble_gatts_char_handles_t;
|
||||
|
||||
|
||||
/**@brief GATT HVx parameters. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Characteristic Value Handle. */
|
||||
uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */
|
||||
uint16_t offset; /**< Offset within the attribute value. */
|
||||
uint16_t *p_len; /**< Length in bytes to be written, length in bytes written after successful return. */
|
||||
uint8_t *p_data; /**< Actual data content, use NULL to use the current attribute value. */
|
||||
} ble_gatts_hvx_params_t;
|
||||
|
||||
/**@brief GATT Authorization parameters. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */
|
||||
uint8_t update : 1; /**< If set, data supplied in p_data will be used to update the attribute value.
|
||||
Please note that for @ref BLE_GATTS_OP_WRITE_REQ operations this bit must always be set,
|
||||
as the data to be written needs to be stored and later provided by the application. */
|
||||
uint16_t offset; /**< Offset of the attribute value being updated. */
|
||||
uint16_t len; /**< Length in bytes of the value in p_data pointer, see @ref BLE_GATTS_ATTR_LENS_MAX. */
|
||||
const uint8_t *p_data; /**< Pointer to new value used to update the attribute value. */
|
||||
} ble_gatts_authorize_params_t;
|
||||
|
||||
/**@brief GATT Read or Write Authorize Reply parameters. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */
|
||||
union {
|
||||
ble_gatts_authorize_params_t read; /**< Read authorization parameters. */
|
||||
ble_gatts_authorize_params_t write; /**< Write authorization parameters. */
|
||||
} params; /**< Reply Parameters. */
|
||||
} ble_gatts_rw_authorize_reply_params_t;
|
||||
|
||||
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTS_EVT_WRITE. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute Handle. */
|
||||
ble_uuid_t uuid; /**< Attribute UUID. */
|
||||
uint8_t op; /**< Type of write operation, see @ref BLE_GATTS_OPS. */
|
||||
uint8_t auth_required; /**< Writing operation deferred due to authorization requirement. Application may use @ref sd_ble_gatts_value_set to finalise the writing operation. */
|
||||
uint16_t offset; /**< Offset for the write operation. */
|
||||
uint16_t len; /**< Length of the received data. */
|
||||
uint8_t data[1]; /**< Received data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gatts_evt_write_t;
|
||||
|
||||
/**@brief Event substructure for authorized read requests, see @ref ble_gatts_evt_rw_authorize_request_t. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute Handle. */
|
||||
ble_uuid_t uuid; /**< Attribute UUID. */
|
||||
uint16_t offset; /**< Offset for the read operation. */
|
||||
} ble_gatts_evt_read_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */
|
||||
union {
|
||||
ble_gatts_evt_read_t read; /**< Attribute Read Parameters. */
|
||||
ble_gatts_evt_write_t write; /**< Attribute Write Parameters. */
|
||||
} request; /**< Request Parameters. */
|
||||
} ble_gatts_evt_rw_authorize_request_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTS_EVT_SYS_ATTR_MISSING. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t hint; /**< Hint (currently unused). */
|
||||
} ble_gatts_evt_sys_attr_missing_t;
|
||||
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTS_EVT_HVC. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute Handle. */
|
||||
} ble_gatts_evt_hvc_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTS_EVT_TIMEOUT. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */
|
||||
} ble_gatts_evt_timeout_t;
|
||||
|
||||
|
||||
/**@brief GATT Server event callback event structure. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t conn_handle; /**< Connection Handle on which the event occurred. */
|
||||
union
|
||||
{
|
||||
ble_gatts_evt_write_t write; /**< Write Event Parameters. */
|
||||
ble_gatts_evt_rw_authorize_request_t authorize_request; /**< Read or Write Authorize Request Parameters. */
|
||||
ble_gatts_evt_sys_attr_missing_t sys_attr_missing; /**< System attributes missing. */
|
||||
ble_gatts_evt_hvc_t hvc; /**< Handle Value Confirmation Event Parameters. */
|
||||
ble_gatts_evt_timeout_t timeout; /**< Timeout Event. */
|
||||
} params; /**< Event Parameters. */
|
||||
} ble_gatts_evt_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTS_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Add a service declaration to the Attribute Table.
|
||||
*
|
||||
* @note Secondary Services are only relevant in the context of the entity that references them, it is therefore forbidden to
|
||||
* add a secondary service declaration that is not referenced by another service later in the Attribute Table.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] type Toggles between primary and secondary services, see @ref BLE_GATTS_SRVC_TYPES.
|
||||
* @param[in] p_uuid Pointer to service UUID.
|
||||
* @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully added a service declaration.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, Vendor Specific UUIDs need to be present in the table.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack.
|
||||
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_SERVICE_ADD, uint32_t, sd_ble_gatts_service_add(uint8_t type, ble_uuid_t const *p_uuid, uint16_t *p_handle));
|
||||
|
||||
|
||||
/**@brief Add an include declaration to the Attribute Table.
|
||||
*
|
||||
* @note It is currently only possible to add an include declaration to the last added service (i.e. only sequential population is supported at this time).
|
||||
*
|
||||
* @note The included service must already be present in the Attribute Table prior to this call.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] service_handle Handle of the service where the included service is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
|
||||
* @param[in] inc_srvc_handle Handle of the included service.
|
||||
* @param[out] p_include_handle Pointer to a 16-bit word where the assigned handle will be stored.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully added an include declaration.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, handle values need to match previously added services.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, self inclusions are not allowed.
|
||||
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND Attribute not found.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_INCLUDE_ADD, uint32_t, sd_ble_gatts_include_add(uint16_t service_handle, uint16_t inc_srvc_handle, uint16_t *p_include_handle));
|
||||
|
||||
|
||||
/**@brief Add a characteristic declaration, a characteristic value declaration and optional characteristic descriptor declarations to the Attribute Table.
|
||||
*
|
||||
* @note It is currently only possible to add a characteristic to the last added service (i.e. only sequential population is supported at this time).
|
||||
*
|
||||
* @note Several restrictions apply to the parameters, such as matching permissions between the user description descriptor and the writeable auxiliaries bits,
|
||||
* readable (no security) and writeable (selectable) CCCDs and SCCDs and valid presentation format values.
|
||||
*
|
||||
* @note If no metadata is provided for the optional descriptors, their permissions will be derived from the characteristic permissions.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] service_handle Handle of the service where the characteristic is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
|
||||
* @param[in] p_char_md Characteristic metadata.
|
||||
* @param[in] p_attr_char_value Pointer to the attribute structure corresponding to the characteristic value.
|
||||
* @param[out] p_handles Pointer to the structure where the assigned handles will be stored.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully added a characteristic.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, service handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation, a service context is required.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack.
|
||||
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
* @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_CHARACTERISTIC_ADD, uint32_t, sd_ble_gatts_characteristic_add(uint16_t service_handle, ble_gatts_char_md_t const *p_char_md, ble_gatts_attr_t const *p_attr_char_value, ble_gatts_char_handles_t *p_handles));
|
||||
|
||||
|
||||
/**@brief Add a descriptor to the Attribute Table.
|
||||
*
|
||||
* @note It is currently only possible to add a descriptor to the last added characteristic (i.e. only sequential population is supported at this time).
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] char_handle Handle of the characteristic where the descriptor is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
|
||||
* @param[in] p_attr Pointer to the attribute structure.
|
||||
* @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully added a descriptor.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, characteristic handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation, a characteristic context is required.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack.
|
||||
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
* @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_DESCRIPTOR_ADD, uint32_t, sd_ble_gatts_descriptor_add(uint16_t char_handle, ble_gatts_attr_t const *p_attr, uint16_t *p_handle));
|
||||
|
||||
/**@brief Set the value of a given attribute.
|
||||
*
|
||||
* @note Values other than system attributes can be set at any time, regardless of wheter any active connections exist.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle Connection handle. If the value does not belong to a system attribute then @ref BLE_CONN_HANDLE_INVALID can be used.
|
||||
* @param[in] handle Attribute handle.
|
||||
* @param[in,out] p_value Attribute value information.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully set the value of the attribute.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND Attribute not found.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Forbidden handle supplied, certain attributes are not modifiable by the application.
|
||||
* @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
|
||||
* @retval ::BLE_ERROR_GATTS_INVALID_ATTR_TYPE @ref BLE_CONN_HANDLE_INVALID supplied on a system attribute.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_VALUE_SET, uint32_t, sd_ble_gatts_value_set(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value));
|
||||
|
||||
/**@brief Get the value of a given attribute.
|
||||
*
|
||||
* @note If the attribute value is longer than the size of the supplied buffer,
|
||||
* p_len will return the total attribute value length (excluding offset),
|
||||
* and not the number of bytes actually returned in p_data.
|
||||
* The application may use this information to allocate a suitable buffer size.
|
||||
*
|
||||
* @note When retrieving system attribute values with this function, the connection handle
|
||||
* may refer to an already disconnected connection. Refer to the documentation of
|
||||
* @ref sd_ble_gatts_sys_attr_get for further information.
|
||||
*
|
||||
* @param[in] conn_handle Connection handle. If the value does not belong to a system attribute then @ref BLE_CONN_HANDLE_INVALID can be used.
|
||||
* @param[in] handle Attribute handle.
|
||||
* @param[in,out] p_value Attribute value information.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully retrieved the value of the attribute.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND Attribute not found.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid attribute offset supplied.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
|
||||
* @retval ::BLE_ERROR_GATTS_INVALID_ATTR_TYPE @ref BLE_CONN_HANDLE_INVALID supplied on a system attribute.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_VALUE_GET, uint32_t, sd_ble_gatts_value_get(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value));
|
||||
|
||||
/**@brief Notify or Indicate an attribute value.
|
||||
*
|
||||
* @details This function checks for the relevant Client Characteristic Configuration descriptor value to verify that the relevant operation
|
||||
* (notification or indication) has been enabled by the client. It is also able to update the attribute value before issuing the PDU, so that
|
||||
* the application can atomically perform a value update and a server initiated transaction with a single API call.
|
||||
* If the application chooses to indicate an attribute value, a @ref BLE_GATTS_EVT_HVC event will be issued as soon as the confirmation arrives from
|
||||
* the peer.
|
||||
*
|
||||
* @note The local attribute value may be updated even if an outgoing packet is not sent to the peer due to an error during execution.
|
||||
* When receiveing the error codes @ref NRF_ERROR_INVALID_STATE, @ref NRF_ERROR_BUSY, @ref BLE_ERROR_GATTS_SYS_ATTR_MISSING and
|
||||
* @ref BLE_ERROR_NO_TX_PACKETS the Attribute Table has been updated.
|
||||
* The caller can check whether the value has been updated by looking at the contents of *(p_hvx_params->p_len).
|
||||
*
|
||||
* @note It is important to note that a notification will <b>consume an application buffer</b>, and will therefore
|
||||
* generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted. An indication on the other hand will use the
|
||||
* standard server internal buffer and thus will only generate a @ref BLE_GATTS_EVT_HVC event as soon as the confirmation
|
||||
* has been received from the peer. Please see the documentation of @ref sd_ble_tx_packet_count_get for more details.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_EVT_TX_COMPLETE, Transmission complete.}
|
||||
* @event{@ref BLE_GATTS_EVT_HVC, Confirmation received from peer.}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_HVX_SYS_ATTRS_MISSING_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_HVN_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_HVI_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_HVX_DISABLED_MSC}
|
||||
* @mmsc{@ref BLE_COMMON_APP_BUFF_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in] p_hvx_params Pointer to an HVx parameters structure. If the p_data member contains a non-NULL pointer the attribute value will be updated with
|
||||
* the contents pointed by it before sending the notification or indication.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully queued a notification or indication for transmission, and optionally updated the attribute value.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or notifications and/or indications not enabled in the CCCD.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied. Only attributes added directly by the application are available to notify and indicate.
|
||||
* @retval ::BLE_ERROR_GATTS_INVALID_ATTR_TYPE Invalid attribute type(s) supplied, only characteristic values may be notified and indicated.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND Attribute not found.
|
||||
* @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Procedure already in progress.
|
||||
* @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value.
|
||||
* @retval ::BLE_ERROR_NO_TX_PACKETS No available application packets for this connection, applies only to notifications.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_HVX, uint32_t, sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const *p_hvx_params));
|
||||
|
||||
/**@brief Indicate the Service Changed attribute value.
|
||||
*
|
||||
* @details This call will send a Handle Value Indication to one or more peers connected to inform them that the Attribute
|
||||
* Table layout has changed. As soon as the peer has confirmed the indication, a @ref BLE_GATTS_EVT_SC_CONFIRM event will
|
||||
* be issued.
|
||||
*
|
||||
* @note Some of the restrictions and limitations that apply to @ref sd_ble_gatts_hvx also apply here.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTS_EVT_SC_CONFIRM, Confirmation of attribute table change received from peer.}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_SC_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in] start_handle Start of affected attribute handle range.
|
||||
* @param[in] end_handle End of affected attribute handle range.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully queued the Service Changed indication for transmission.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED Service Changed not enabled at initialization. See @ref sd_ble_enable and @ref ble_gatts_enable_params_t.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or notifications and/or indications not enabled in the CCCD.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied, handles must be in the range populated by the application.
|
||||
* @retval ::NRF_ERROR_BUSY Procedure already in progress.
|
||||
* @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_SERVICE_CHANGED, uint32_t, sd_ble_gatts_service_changed(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle));
|
||||
|
||||
/**@brief Respond to a Read/Write authorization request.
|
||||
*
|
||||
* @note This call should only be used as a response to a @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event issued to the application.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_AUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_AUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_READ_REQ_AUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_WRITE_REQ_AUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_PEER_CANCEL_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in] p_rw_authorize_reply_params Pointer to a structure with the attribute provided by the application.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully queued a response to the peer, and in the case of a write operation, Attribute Table updated.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no authorization request pending.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Authorization op invalid,
|
||||
* handle supplied does not match requested handle,
|
||||
* or invalid data to be written provided by the application.
|
||||
* @retval ::NRF_ERROR_BUSY The stack is busy. Retry at later time.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_RW_AUTHORIZE_REPLY, uint32_t, sd_ble_gatts_rw_authorize_reply(uint16_t conn_handle, ble_gatts_rw_authorize_reply_params_t const *p_rw_authorize_reply_params));
|
||||
|
||||
|
||||
/**@brief Update persistent system attribute information.
|
||||
*
|
||||
* @details Supply information about persistent system attributes to the stack,
|
||||
* previously obtained using @ref sd_ble_gatts_sys_attr_get.
|
||||
* This call is only allowed for active connections, and is usually
|
||||
* made immediately after a connection is established with an known bonded device,
|
||||
* often as a response to a @ref BLE_GATTS_EVT_SYS_ATTR_MISSING.
|
||||
*
|
||||
* p_sysattrs may point directly to the application's stored copy of the system attributes
|
||||
* obtained using @ref sd_ble_gatts_sys_attr_get.
|
||||
* If the pointer is NULL, the system attribute info is initialized, assuming that
|
||||
* the application does not have any previously saved system attribute data for this device.
|
||||
*
|
||||
* @note The state of persistent system attributes is reset upon connection establishment and then remembered for its duration.
|
||||
*
|
||||
* @note If this call returns with an error code different from @ref NRF_SUCCESS, the storage of persistent system attributes may have been completed only partially.
|
||||
* This means that the state of the attribute table is undefined, and the application should either provide a new set of attributes using this same call or
|
||||
* reset the SoftDevice to return to a known state.
|
||||
*
|
||||
* @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS is used with this function, only the system attributes included in system services will be modified.
|
||||
* @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS is used with this function, only the system attributes included in user services will be modified.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_HVX_SYS_ATTRS_MISSING_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_SYS_ATTRS_UNK_PEER_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_SYS_ATTRS_BONDED_PEER_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in] p_sys_attr_data Pointer to a saved copy of system attributes supplied to the stack, or NULL.
|
||||
* @param[in] len Size of data pointed by p_sys_attr_data, in octets.
|
||||
* @param[in] flags Optional additional flags, see @ref BLE_GATTS_SYS_ATTR_FLAGS
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully set the system attribute information.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
|
||||
* @retval ::NRF_ERROR_INVALID_DATA Invalid data supplied, the data should be exactly the same as retrieved with @ref sd_ble_gatts_sys_attr_get.
|
||||
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
* @retval ::NRF_ERROR_BUSY The stack is busy. Retry at later time.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_SYS_ATTR_SET, uint32_t, sd_ble_gatts_sys_attr_set(uint16_t conn_handle, uint8_t const *p_sys_attr_data, uint16_t len, uint32_t flags));
|
||||
|
||||
|
||||
/**@brief Retrieve persistent system attribute information from the stack.
|
||||
*
|
||||
* @details This call is used to retrieve information about values to be stored perisistently by the application
|
||||
* during the lifetime of a connection or after it has been terminated. When a new connection is established with the same bonded device,
|
||||
* the system attribute information retrieved with this function should be restored using using @ref sd_ble_gatts_sys_attr_set.
|
||||
* If retrieved after disconnection, the data should be read before a new connection established. The connection handle for
|
||||
* the previous, now disconnected, connection will remain valid until a new one is created to allow this API call to refer to it.
|
||||
* Connection handles belonging to active connections can be used as well, but care should be taken since the system attributes
|
||||
* may be written to at any time by the peer during a connection's lifetime.
|
||||
*
|
||||
* @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS is used with this function, only the system attributes included in system services will be returned.
|
||||
* @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS is used with this function, only the system attributes included in user services will be returned.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_SYS_ATTRS_BONDED_PEER_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle Connection handle of the recently terminated connection.
|
||||
* @param[out] p_sys_attr_data Pointer to a buffer where updated information about system attributes will be filled in. The format of the data is described
|
||||
* in @ref BLE_GATTS_SYS_ATTRS_FORMAT. NULL can be provided to obtain the length of the data.
|
||||
* @param[in,out] p_len Size of application buffer if p_sys_attr_data is not NULL. Unconditially updated to actual length of system attribute data.
|
||||
* @param[in] flags Optional additional flags, see @ref BLE_GATTS_SYS_ATTR_FLAGS
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully retrieved the system attribute information.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_DATA_SIZE The system attribute information did not fit into the provided buffer.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND No system attributes found.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_SYS_ATTR_GET, uint32_t, sd_ble_gatts_sys_attr_get(uint16_t conn_handle, uint8_t *p_sys_attr_data, uint16_t *p_len, uint32_t flags));
|
||||
|
||||
|
||||
/**@brief Retrieve the first valid user attribute handle.
|
||||
*
|
||||
* @param[out] p_handle Pointer to an integer where the handle will be stored.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully retrieved the handle.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_INITIAL_USER_HANDLE_GET, uint32_t, sd_ble_gatts_initial_user_handle_get(uint16_t *p_handle));
|
||||
|
||||
/**@brief Retrieve the attribute UUID and/or metadata.
|
||||
*
|
||||
* @param[in] handle Attribute handle
|
||||
* @param[out] p_uuid UUID of the attribute. Use NULL to omit this field.
|
||||
* @param[out] p_md Metadata of the attribute. Use NULL to omit this field.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully retrieved the attribute metadata,
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameters supplied. Returned when both @c p_uuid and @c p_md are NULL.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND Attribute was not found.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_ATTR_GET, uint32_t, sd_ble_gatts_attr_get(uint16_t handle, ble_uuid_t * p_uuid, ble_gatts_attr_md_t * p_md));
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_BLE_GATTS_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,134 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
@addtogroup BLE_COMMON
|
||||
@{
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NRF_BLE_HCI_H__
|
||||
#define NRF_BLE_HCI_H__
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @defgroup BLE_HCI_STATUS_CODES Bluetooth status codes
|
||||
* @{ */
|
||||
|
||||
#define BLE_HCI_STATUS_CODE_SUCCESS 0x00 /**< Success. */
|
||||
#define BLE_HCI_STATUS_CODE_UNKNOWN_BTLE_COMMAND 0x01 /**< Unknown BLE Command. */
|
||||
#define BLE_HCI_STATUS_CODE_UNKNOWN_CONNECTION_IDENTIFIER 0x02 /**< Unknown Connection Identifier. */
|
||||
/*0x03 Hardware Failure
|
||||
0x04 Page Timeout
|
||||
*/
|
||||
#define BLE_HCI_AUTHENTICATION_FAILURE 0x05 /**< Authentication Failure. */
|
||||
#define BLE_HCI_STATUS_CODE_PIN_OR_KEY_MISSING 0x06 /**< Pin or Key missing. */
|
||||
#define BLE_HCI_MEMORY_CAPACITY_EXCEEDED 0x07 /**< Memory Capacity Exceeded. */
|
||||
#define BLE_HCI_CONNECTION_TIMEOUT 0x08 /**< Connection Timeout. */
|
||||
/*0x09 Connection Limit Exceeded
|
||||
0x0A Synchronous Connection Limit To A Device Exceeded
|
||||
0x0B ACL Connection Already Exists*/
|
||||
#define BLE_HCI_STATUS_CODE_COMMAND_DISALLOWED 0x0C /**< Command Disallowed. */
|
||||
/*0x0D Connection Rejected due to Limited Resources
|
||||
0x0E Connection Rejected Due To Security Reasons
|
||||
0x0F Connection Rejected due to Unacceptable BD_ADDR
|
||||
0x10 Connection Accept Timeout Exceeded
|
||||
0x11 Unsupported Feature or Parameter Value*/
|
||||
#define BLE_HCI_STATUS_CODE_INVALID_BTLE_COMMAND_PARAMETERS 0x12 /**< Invalid BLE Command Parameters. */
|
||||
#define BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION 0x13 /**< Remote User Terminated Connection. */
|
||||
#define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES 0x14 /**< Remote Device Terminated Connection due to low resources.*/
|
||||
#define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF 0x15 /**< Remote Device Terminated Connection due to power off. */
|
||||
#define BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION 0x16 /**< Local Host Terminated Connection. */
|
||||
/*
|
||||
0x17 Repeated Attempts
|
||||
0x18 Pairing Not Allowed
|
||||
0x19 Unknown LMP PDU
|
||||
*/
|
||||
#define BLE_HCI_UNSUPPORTED_REMOTE_FEATURE 0x1A /**< Unsupported Remote Feature. */
|
||||
/*
|
||||
0x1B SCO Offset Rejected
|
||||
0x1C SCO Interval Rejected
|
||||
0x1D SCO Air Mode Rejected*/
|
||||
#define BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS 0x1E /**< Invalid LMP Parameters. */
|
||||
#define BLE_HCI_STATUS_CODE_UNSPECIFIED_ERROR 0x1F /**< Unspecified Error. */
|
||||
/*0x20 Unsupported LMP Parameter Value
|
||||
0x21 Role Change Not Allowed
|
||||
*/
|
||||
#define BLE_HCI_STATUS_CODE_LMP_RESPONSE_TIMEOUT 0x22 /**< LMP Response Timeout. */
|
||||
/*0x23 LMP Error Transaction Collision*/
|
||||
#define BLE_HCI_STATUS_CODE_LMP_PDU_NOT_ALLOWED 0x24 /**< LMP PDU Not Allowed. */
|
||||
/*0x25 Encryption Mode Not Acceptable
|
||||
0x26 Link Key Can Not be Changed
|
||||
0x27 Requested QoS Not Supported
|
||||
*/
|
||||
#define BLE_HCI_INSTANT_PASSED 0x28 /**< Instant Passed. */
|
||||
#define BLE_HCI_PAIRING_WITH_UNIT_KEY_UNSUPPORTED 0x29 /**< Pairing with Unit Key Unsupported. */
|
||||
#define BLE_HCI_DIFFERENT_TRANSACTION_COLLISION 0x2A /**< Different Transaction Collision. */
|
||||
/*
|
||||
0x2B Reserved
|
||||
0x2C QoS Unacceptable Parameter
|
||||
0x2D QoS Rejected
|
||||
0x2E Channel Classification Not Supported
|
||||
0x2F Insufficient Security
|
||||
0x30 Parameter Out Of Mandatory Range
|
||||
0x31 Reserved
|
||||
0x32 Role Switch Pending
|
||||
0x33 Reserved
|
||||
0x34 Reserved Slot Violation
|
||||
0x35 Role Switch Failed
|
||||
0x36 Extended Inquiry Response Too Large
|
||||
0x37 Secure Simple Pairing Not Supported By Host.
|
||||
0x38 Host Busy - Pairing
|
||||
0x39 Connection Rejected due to No Suitable Channel Found*/
|
||||
#define BLE_HCI_CONTROLLER_BUSY 0x3A /**< Controller Busy. */
|
||||
#define BLE_HCI_CONN_INTERVAL_UNACCEPTABLE 0x3B /**< Connection Interval Unacceptable. */
|
||||
#define BLE_HCI_DIRECTED_ADVERTISER_TIMEOUT 0x3C /**< Directed Adverisement Timeout. */
|
||||
#define BLE_HCI_CONN_TERMINATED_DUE_TO_MIC_FAILURE 0x3D /**< Connection Terminated due to MIC Failure. */
|
||||
#define BLE_HCI_CONN_FAILED_TO_BE_ESTABLISHED 0x3E /**< Connection Failed to be Established. */
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_BLE_HCI_H__
|
||||
|
||||
/** @} */
|
||||
|
|
@ -1,205 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
@addtogroup BLE_L2CAP Logical Link Control and Adaptation Protocol (L2CAP)
|
||||
@{
|
||||
@brief Definitions and prototypes for the L2CAP interface.
|
||||
*/
|
||||
|
||||
#ifndef NRF_BLE_L2CAP_H__
|
||||
#define NRF_BLE_L2CAP_H__
|
||||
|
||||
#include "nrf_ble_types.h"
|
||||
#include "nrf_ble_ranges.h"
|
||||
#include "nrf_ble_err.h"
|
||||
#include "nrf_svc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**@addtogroup BLE_L2CAP_ENUMERATIONS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief L2CAP API SVC numbers. */
|
||||
enum BLE_L2CAP_SVCS
|
||||
{
|
||||
SD_BLE_L2CAP_CID_REGISTER = BLE_L2CAP_SVC_BASE, /**< Register a CID. */
|
||||
SD_BLE_L2CAP_CID_UNREGISTER, /**< Unregister a CID. */
|
||||
SD_BLE_L2CAP_TX /**< Transmit a packet. */
|
||||
};
|
||||
|
||||
/**@brief L2CAP Event IDs. */
|
||||
enum BLE_L2CAP_EVTS
|
||||
{
|
||||
BLE_L2CAP_EVT_RX = BLE_L2CAP_EVT_BASE /**< L2CAP packet received. */
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/**@addtogroup BLE_L2CAP_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@defgroup BLE_ERRORS_L2CAP SVC return values specific to L2CAP
|
||||
* @{ */
|
||||
#define BLE_ERROR_L2CAP_CID_IN_USE (NRF_L2CAP_ERR_BASE + 0x000) /**< CID already in use. */
|
||||
/** @} */
|
||||
|
||||
/**@brief Default L2CAP MTU. */
|
||||
#define BLE_L2CAP_MTU_DEF (23)
|
||||
|
||||
/**@brief Invalid Channel Identifier. */
|
||||
#define BLE_L2CAP_CID_INVALID (0x0000)
|
||||
|
||||
/**@brief Dynamic Channel Identifier base. */
|
||||
#define BLE_L2CAP_CID_DYN_BASE (0x0040)
|
||||
|
||||
/**@brief Maximum amount of dynamic CIDs. */
|
||||
#define BLE_L2CAP_CID_DYN_MAX (8)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**@addtogroup BLE_L2CAP_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**@brief Packet header format for L2CAP transmission. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t len; /**< Length of valid info in data member. */
|
||||
uint16_t cid; /**< Channel ID on which packet is transmitted. */
|
||||
} ble_l2cap_header_t;
|
||||
|
||||
|
||||
/**@brief L2CAP Received packet event report. */
|
||||
typedef struct
|
||||
{
|
||||
ble_l2cap_header_t header; /**< L2CAP packet header. */
|
||||
uint8_t data[1]; /**< Packet data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_l2cap_evt_rx_t;
|
||||
|
||||
|
||||
/**@brief L2CAP event callback event structure. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t conn_handle; /**< Connection Handle on which event occured. */
|
||||
union
|
||||
{
|
||||
ble_l2cap_evt_rx_t rx; /**< RX Event parameters. */
|
||||
} params; /**< Event Parameters. */
|
||||
} ble_l2cap_evt_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/**@addtogroup BLE_L2CAP_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Register a CID with L2CAP.
|
||||
*
|
||||
* @details This registers a higher protocol layer with the L2CAP multiplexer, and is requried prior to all operations on the CID.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_L2CAP_API_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] cid L2CAP CID.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully registered a CID with the L2CAP layer.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, CID must be above @ref BLE_L2CAP_CID_DYN_BASE.
|
||||
* @retval ::BLE_ERROR_L2CAP_CID_IN_USE L2CAP CID already in use.
|
||||
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
*/
|
||||
SVCALL(SD_BLE_L2CAP_CID_REGISTER, uint32_t, sd_ble_l2cap_cid_register(uint16_t cid));
|
||||
|
||||
/**@brief Unregister a CID with L2CAP.
|
||||
*
|
||||
* @details This unregisters a previously registerd higher protocol layer with the L2CAP multiplexer.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_L2CAP_API_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] cid L2CAP CID.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully unregistered the CID.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND CID not previously registered.
|
||||
*/
|
||||
SVCALL(SD_BLE_L2CAP_CID_UNREGISTER, uint32_t, sd_ble_l2cap_cid_unregister(uint16_t cid));
|
||||
|
||||
/**@brief Transmit an L2CAP packet.
|
||||
*
|
||||
* @note It is important to note that a call to this function will <b>consume an application packet</b>, and will therefore
|
||||
* generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted.
|
||||
* Please see the documentation of @ref sd_ble_tx_packet_count_get for more details.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_EVT_TX_COMPLETE}
|
||||
* @event{@ref BLE_L2CAP_EVT_RX}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_L2CAP_API_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle Connection Handle.
|
||||
* @param[in] p_header Pointer to a packet header containing length and CID.
|
||||
* @param[in] p_data Pointer to the data to be transmitted.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully queued an L2CAP packet for transmission.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, CIDs must be registered beforehand with @ref sd_ble_l2cap_cid_register.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND CID not found.
|
||||
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
* @retval ::BLE_ERROR_NO_TX_PACKETS Not enough application packets available.
|
||||
* @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, see @ref BLE_L2CAP_MTU_DEF.
|
||||
*/
|
||||
SVCALL(SD_BLE_L2CAP_TX, uint32_t, sd_ble_l2cap_tx(uint16_t conn_handle, ble_l2cap_header_t const *p_header, uint8_t const *p_data));
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_BLE_L2CAP_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,129 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
@addtogroup BLE_COMMON
|
||||
@{
|
||||
@defgroup ble_ranges Module specific SVC, event and option number subranges
|
||||
@{
|
||||
|
||||
@brief Definition of SVC, event and option number subranges for each API module.
|
||||
|
||||
@note
|
||||
SVCs, event and option numbers are split into subranges for each API module.
|
||||
Each module receives its entire allocated range of SVC calls, whether implemented or not,
|
||||
but return BLE_ERROR_NOT_SUPPORTED for unimplemented or undefined calls in its range.
|
||||
|
||||
Note that the symbols BLE_<module>_SVC_LAST is the end of the allocated SVC range,
|
||||
rather than the last SVC function call actually defined and implemented.
|
||||
|
||||
Specific SVC, event and option values are defined in each module's ble_<module>.h file,
|
||||
which defines names of each individual SVC code based on the range start value.
|
||||
*/
|
||||
|
||||
#ifndef NRF_BLE_RANGES_H__
|
||||
#define NRF_BLE_RANGES_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BLE_SVC_BASE 0x60 /**< Common BLE SVC base. */
|
||||
#define BLE_SVC_LAST 0x6B /**< Total: 12. */
|
||||
|
||||
#define BLE_RESERVED_SVC_BASE 0x6C /**< Reserved BLE SVC base. */
|
||||
#define BLE_RESERVED_SVC_LAST 0x6F /**< Total: 4. */
|
||||
|
||||
#define BLE_GAP_SVC_BASE 0x70 /**< GAP BLE SVC base. */
|
||||
#define BLE_GAP_SVC_LAST 0x8F /**< Total: 32. */
|
||||
|
||||
#define BLE_GATTC_SVC_BASE 0x90 /**< GATTC BLE SVC base. */
|
||||
#define BLE_GATTC_SVC_LAST 0x9F /**< Total: 32. */
|
||||
|
||||
#define BLE_GATTS_SVC_BASE 0xA0 /**< GATTS BLE SVC base. */
|
||||
#define BLE_GATTS_SVC_LAST 0xAF /**< Total: 16. */
|
||||
|
||||
#define BLE_L2CAP_SVC_BASE 0xB0 /**< L2CAP BLE SVC base. */
|
||||
#define BLE_L2CAP_SVC_LAST 0xBF /**< Total: 16. */
|
||||
|
||||
|
||||
#define BLE_EVT_INVALID 0x00 /**< Invalid BLE Event. */
|
||||
|
||||
#define BLE_EVT_BASE 0x01 /**< Common BLE Event base. */
|
||||
#define BLE_EVT_LAST 0x0F /**< Total: 15. */
|
||||
|
||||
#define BLE_GAP_EVT_BASE 0x10 /**< GAP BLE Event base. */
|
||||
#define BLE_GAP_EVT_LAST 0x2F /**< Total: 32. */
|
||||
|
||||
#define BLE_GATTC_EVT_BASE 0x30 /**< GATTC BLE Event base. */
|
||||
#define BLE_GATTC_EVT_LAST 0x4F /**< Total: 32. */
|
||||
|
||||
#define BLE_GATTS_EVT_BASE 0x50 /**< GATTS BLE Event base. */
|
||||
#define BLE_GATTS_EVT_LAST 0x6F /**< Total: 32. */
|
||||
|
||||
#define BLE_L2CAP_EVT_BASE 0x70 /**< L2CAP BLE Event base. */
|
||||
#define BLE_L2CAP_EVT_LAST 0x8F /**< Total: 32. */
|
||||
|
||||
|
||||
#define BLE_OPT_INVALID 0x00 /**< Invalid BLE Option. */
|
||||
|
||||
#define BLE_OPT_BASE 0x01 /**< Common BLE Option base. */
|
||||
#define BLE_OPT_LAST 0x1F /**< Total: 31. */
|
||||
|
||||
#define BLE_GAP_OPT_BASE 0x20 /**< GAP BLE Option base. */
|
||||
#define BLE_GAP_OPT_LAST 0x3F /**< Total: 32. */
|
||||
|
||||
#define BLE_GATTC_OPT_BASE 0x40 /**< GATTC BLE Option base. */
|
||||
#define BLE_GATTC_OPT_LAST 0x5F /**< Total: 32. */
|
||||
|
||||
#define BLE_GATTS_OPT_BASE 0x60 /**< GATTS BLE Option base. */
|
||||
#define BLE_GATTS_OPT_LAST 0x7F /**< Total: 32. */
|
||||
|
||||
#define BLE_L2CAP_OPT_BASE 0x80 /**< L2CAP BLE Option base. */
|
||||
#define BLE_L2CAP_OPT_LAST 0x9F /**< Total: 32. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* NRF_BLE_RANGES_H__ */
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,208 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
@addtogroup BLE_COMMON
|
||||
@{
|
||||
@defgroup ble_types Common types and macro definitions
|
||||
@{
|
||||
|
||||
@brief Common types and macro definitions for the BLE SoftDevice.
|
||||
*/
|
||||
|
||||
#ifndef NRF_BLE_TYPES_H__
|
||||
#define NRF_BLE_TYPES_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup BLE_TYPES_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/** @defgroup BLE_CONN_HANDLES BLE Connection Handles
|
||||
* @{ */
|
||||
#define BLE_CONN_HANDLE_INVALID 0xFFFF /**< Invalid Connection Handle. */
|
||||
#define BLE_CONN_HANDLE_ALL 0xFFFE /**< Applies to all Connection Handles. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_UUID_VALUES Assigned Values for BLE UUIDs
|
||||
* @{ */
|
||||
/* Generic UUIDs, applicable to all services */
|
||||
#define BLE_UUID_UNKNOWN 0x0000 /**< Reserved UUID. */
|
||||
#define BLE_UUID_SERVICE_PRIMARY 0x2800 /**< Primary Service. */
|
||||
#define BLE_UUID_SERVICE_SECONDARY 0x2801 /**< Secondary Service. */
|
||||
#define BLE_UUID_SERVICE_INCLUDE 0x2802 /**< Include. */
|
||||
#define BLE_UUID_CHARACTERISTIC 0x2803 /**< Characteristic. */
|
||||
#define BLE_UUID_DESCRIPTOR_CHAR_EXT_PROP 0x2900 /**< Characteristic Extended Properties Descriptor. */
|
||||
#define BLE_UUID_DESCRIPTOR_CHAR_USER_DESC 0x2901 /**< Characteristic User Description Descriptor. */
|
||||
#define BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG 0x2902 /**< Client Characteristic Configuration Descriptor. */
|
||||
#define BLE_UUID_DESCRIPTOR_SERVER_CHAR_CONFIG 0x2903 /**< Server Characteristic Configuration Descriptor. */
|
||||
#define BLE_UUID_DESCRIPTOR_CHAR_PRESENTATION_FORMAT 0x2904 /**< Characteristic Presentation Format Descriptor. */
|
||||
#define BLE_UUID_DESCRIPTOR_CHAR_AGGREGATE_FORMAT 0x2905 /**< Characteristic Aggregate Format Descriptor. */
|
||||
/* GATT specific UUIDs */
|
||||
#define BLE_UUID_GATT 0x1801 /**< Generic Attribute Profile. */
|
||||
#define BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED 0x2A05 /**< Service Changed Characteristic. */
|
||||
/* GAP specific UUIDs */
|
||||
#define BLE_UUID_GAP 0x1800 /**< Generic Access Profile. */
|
||||
#define BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME 0x2A00 /**< Device Name Characteristic. */
|
||||
#define BLE_UUID_GAP_CHARACTERISTIC_APPEARANCE 0x2A01 /**< Appearance Characteristic. */
|
||||
#define BLE_UUID_GAP_CHARACTERISTIC_PPF 0x2A02 /**< Peripheral Privacy Flag Characteristic. */
|
||||
#define BLE_UUID_GAP_CHARACTERISTIC_RECONN_ADDR 0x2A03 /**< Reconnection Address Characteristic. */
|
||||
#define BLE_UUID_GAP_CHARACTERISTIC_PPCP 0x2A04 /**< Peripheral Preferred Connection Parameters Characteristic. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_UUID_TYPES Types of UUID
|
||||
* @{ */
|
||||
#define BLE_UUID_TYPE_UNKNOWN 0x00 /**< Invalid UUID type. */
|
||||
#define BLE_UUID_TYPE_BLE 0x01 /**< Bluetooth SIG UUID (16-bit). */
|
||||
#define BLE_UUID_TYPE_VENDOR_BEGIN 0x02 /**< Vendor UUID types start at this index (128-bit). */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_APPEARANCES Bluetooth Appearance values
|
||||
* @note Retrieved from http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml
|
||||
* @{ */
|
||||
#define BLE_APPEARANCE_UNKNOWN 0 /**< Unknown. */
|
||||
#define BLE_APPEARANCE_GENERIC_PHONE 64 /**< Generic Phone. */
|
||||
#define BLE_APPEARANCE_GENERIC_COMPUTER 128 /**< Generic Computer. */
|
||||
#define BLE_APPEARANCE_GENERIC_WATCH 192 /**< Generic Watch. */
|
||||
#define BLE_APPEARANCE_WATCH_SPORTS_WATCH 193 /**< Watch: Sports Watch. */
|
||||
#define BLE_APPEARANCE_GENERIC_CLOCK 256 /**< Generic Clock. */
|
||||
#define BLE_APPEARANCE_GENERIC_DISPLAY 320 /**< Generic Display. */
|
||||
#define BLE_APPEARANCE_GENERIC_REMOTE_CONTROL 384 /**< Generic Remote Control. */
|
||||
#define BLE_APPEARANCE_GENERIC_EYE_GLASSES 448 /**< Generic Eye-glasses. */
|
||||
#define BLE_APPEARANCE_GENERIC_TAG 512 /**< Generic Tag. */
|
||||
#define BLE_APPEARANCE_GENERIC_KEYRING 576 /**< Generic Keyring. */
|
||||
#define BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 640 /**< Generic Media Player. */
|
||||
#define BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 704 /**< Generic Barcode Scanner. */
|
||||
#define BLE_APPEARANCE_GENERIC_THERMOMETER 768 /**< Generic Thermometer. */
|
||||
#define BLE_APPEARANCE_THERMOMETER_EAR 769 /**< Thermometer: Ear. */
|
||||
#define BLE_APPEARANCE_GENERIC_HEART_RATE_SENSOR 832 /**< Generic Heart rate Sensor. */
|
||||
#define BLE_APPEARANCE_HEART_RATE_SENSOR_HEART_RATE_BELT 833 /**< Heart Rate Sensor: Heart Rate Belt. */
|
||||
#define BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 896 /**< Generic Blood Pressure. */
|
||||
#define BLE_APPEARANCE_BLOOD_PRESSURE_ARM 897 /**< Blood Pressure: Arm. */
|
||||
#define BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 898 /**< Blood Pressure: Wrist. */
|
||||
#define BLE_APPEARANCE_GENERIC_HID 960 /**< Human Interface Device (HID). */
|
||||
#define BLE_APPEARANCE_HID_KEYBOARD 961 /**< Keyboard (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_MOUSE 962 /**< Mouse (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_JOYSTICK 963 /**< Joystiq (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_GAMEPAD 964 /**< Gamepad (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_DIGITIZERSUBTYPE 965 /**< Digitizer Tablet (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_CARD_READER 966 /**< Card Reader (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_DIGITAL_PEN 967 /**< Digital Pen (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_BARCODE 968 /**< Barcode Scanner (HID Subtype). */
|
||||
#define BLE_APPEARANCE_GENERIC_GLUCOSE_METER 1024 /**< Generic Glucose Meter. */
|
||||
#define BLE_APPEARANCE_GENERIC_RUNNING_WALKING_SENSOR 1088 /**< Generic Running Walking Sensor. */
|
||||
#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_IN_SHOE 1089 /**< Running Walking Sensor: In-Shoe. */
|
||||
#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_SHOE 1090 /**< Running Walking Sensor: On-Shoe. */
|
||||
#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_HIP 1091 /**< Running Walking Sensor: On-Hip. */
|
||||
#define BLE_APPEARANCE_GENERIC_CYCLING 1152 /**< Generic Cycling. */
|
||||
#define BLE_APPEARANCE_CYCLING_CYCLING_COMPUTER 1153 /**< Cycling: Cycling Computer. */
|
||||
#define BLE_APPEARANCE_CYCLING_SPEED_SENSOR 1154 /**< Cycling: Speed Sensor. */
|
||||
#define BLE_APPEARANCE_CYCLING_CADENCE_SENSOR 1155 /**< Cycling: Cadence Sensor. */
|
||||
#define BLE_APPEARANCE_CYCLING_POWER_SENSOR 1156 /**< Cycling: Power Sensor. */
|
||||
#define BLE_APPEARANCE_CYCLING_SPEED_CADENCE_SENSOR 1157 /**< Cycling: Speed and Cadence Sensor. */
|
||||
#define BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 3136 /**< Generic Pulse Oximeter. */
|
||||
#define BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 3137 /**< Fingertip (Pulse Oximeter subtype). */
|
||||
#define BLE_APPEARANCE_PULSE_OXIMETER_WRIST_WORN 3138 /**< Wrist Worn(Pulse Oximeter subtype). */
|
||||
#define BLE_APPEARANCE_GENERIC_WEIGHT_SCALE 3200 /**< Generic Weight Scale. */
|
||||
#define BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS_ACT 5184 /**< Generic Outdoor Sports Activity. */
|
||||
#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_DISP 5185 /**< Location Display Device (Outdoor Sports Activity subtype). */
|
||||
#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_AND_NAV_DISP 5186 /**< Location and Navigation Display Device (Outdoor Sports Activity subtype). */
|
||||
#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_POD 5187 /**< Location Pod (Outdoor Sports Activity subtype). */
|
||||
#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_AND_NAV_POD 5188 /**< Location and Navigation Pod (Outdoor Sports Activity subtype). */
|
||||
/** @} */
|
||||
|
||||
/** @brief Set .type and .uuid fields of ble_uuid_struct to specified uuid value. */
|
||||
#define BLE_UUID_BLE_ASSIGN(instance, value) do {\
|
||||
instance.type = BLE_UUID_TYPE_BLE; \
|
||||
instance.uuid = value;} while(0)
|
||||
|
||||
/** @brief Copy type and uuid members from src to dst ble_uuid_t pointer. Both pointers must be valid/non-null. */
|
||||
#define BLE_UUID_COPY_PTR(dst, src) do {\
|
||||
(dst)->type = (src)->type; \
|
||||
(dst)->uuid = (src)->uuid;} while(0)
|
||||
|
||||
/** @brief Copy type and uuid members from src to dst ble_uuid_t struct. */
|
||||
#define BLE_UUID_COPY_INST(dst, src) do {\
|
||||
(dst).type = (src).type; \
|
||||
(dst).uuid = (src).uuid;} while(0)
|
||||
|
||||
/** @brief Compare for equality both type and uuid members of two (valid, non-null) ble_uuid_t pointers. */
|
||||
#define BLE_UUID_EQ(p_uuid1, p_uuid2) \
|
||||
(((p_uuid1)->type == (p_uuid2)->type) && ((p_uuid1)->uuid == (p_uuid2)->uuid))
|
||||
|
||||
/** @brief Compare for difference both type and uuid members of two (valid, non-null) ble_uuid_t pointers. */
|
||||
#define BLE_UUID_NEQ(p_uuid1, p_uuid2) \
|
||||
(((p_uuid1)->type != (p_uuid2)->type) || ((p_uuid1)->uuid != (p_uuid2)->uuid))
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_TYPES_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/** @brief 128 bit UUID values. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t uuid128[16]; /**< Little-Endian UUID bytes. */
|
||||
} ble_uuid128_t;
|
||||
|
||||
/** @brief Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t uuid; /**< 16-bit UUID value or octets 12-13 of 128-bit UUID. */
|
||||
uint8_t type; /**< UUID type, see @ref BLE_UUID_TYPES. If type is @ref BLE_UUID_TYPE_UNKNOWN, the value of uuid is undefined. */
|
||||
} ble_uuid_t;
|
||||
|
||||
/** @} */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NRF_BLE_TYPES_H__ */
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup nrf_error SoftDevice Global Error Codes
|
||||
@{
|
||||
|
||||
@brief Global Error definitions
|
||||
*/
|
||||
|
||||
/* Header guard */
|
||||
#ifndef NRF_ERROR_H__
|
||||
#define NRF_ERROR_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @defgroup NRF_ERRORS_BASE Error Codes Base number definitions
|
||||
* @{ */
|
||||
#define NRF_ERROR_BASE_NUM (0x0) ///< Global error base
|
||||
#define NRF_ERROR_SDM_BASE_NUM (0x1000) ///< SDM error base
|
||||
#define NRF_ERROR_SOC_BASE_NUM (0x2000) ///< SoC error base
|
||||
#define NRF_ERROR_STK_BASE_NUM (0x3000) ///< STK error base
|
||||
/** @} */
|
||||
|
||||
#define NRF_SUCCESS (NRF_ERROR_BASE_NUM + 0) ///< Successful command
|
||||
#define NRF_ERROR_SVC_HANDLER_MISSING (NRF_ERROR_BASE_NUM + 1) ///< SVC handler is missing
|
||||
#define NRF_ERROR_SOFTDEVICE_NOT_ENABLED (NRF_ERROR_BASE_NUM + 2) ///< SoftDevice has not been enabled
|
||||
#define NRF_ERROR_INTERNAL (NRF_ERROR_BASE_NUM + 3) ///< Internal Error
|
||||
#define NRF_ERROR_NO_MEM (NRF_ERROR_BASE_NUM + 4) ///< No Memory for operation
|
||||
#define NRF_ERROR_NOT_FOUND (NRF_ERROR_BASE_NUM + 5) ///< Not found
|
||||
#define NRF_ERROR_NOT_SUPPORTED (NRF_ERROR_BASE_NUM + 6) ///< Not supported
|
||||
#define NRF_ERROR_INVALID_PARAM (NRF_ERROR_BASE_NUM + 7) ///< Invalid Parameter
|
||||
#define NRF_ERROR_INVALID_STATE (NRF_ERROR_BASE_NUM + 8) ///< Invalid state, operation disallowed in this state
|
||||
#define NRF_ERROR_INVALID_LENGTH (NRF_ERROR_BASE_NUM + 9) ///< Invalid Length
|
||||
#define NRF_ERROR_INVALID_FLAGS (NRF_ERROR_BASE_NUM + 10) ///< Invalid Flags
|
||||
#define NRF_ERROR_INVALID_DATA (NRF_ERROR_BASE_NUM + 11) ///< Invalid Data
|
||||
#define NRF_ERROR_DATA_SIZE (NRF_ERROR_BASE_NUM + 12) ///< Invalid Data size
|
||||
#define NRF_ERROR_TIMEOUT (NRF_ERROR_BASE_NUM + 13) ///< Operation timed out
|
||||
#define NRF_ERROR_NULL (NRF_ERROR_BASE_NUM + 14) ///< Null Pointer
|
||||
#define NRF_ERROR_FORBIDDEN (NRF_ERROR_BASE_NUM + 15) ///< Forbidden Operation
|
||||
#define NRF_ERROR_INVALID_ADDR (NRF_ERROR_BASE_NUM + 16) ///< Bad Memory Address
|
||||
#define NRF_ERROR_BUSY (NRF_ERROR_BASE_NUM + 17) ///< Busy
|
||||
#define NRF_ERROR_CONN_COUNT (NRF_ERROR_BASE_NUM + 18) ///< Maximum connection count exceeded.
|
||||
#define NRF_ERROR_RESOURCES (NRF_ERROR_BASE_NUM + 19) ///< Not enough resources for operation
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_ERROR_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup nrf_sdm_api
|
||||
@{
|
||||
@defgroup nrf_sdm_error SoftDevice Manager Error Codes
|
||||
@{
|
||||
|
||||
@brief Error definitions for the SDM API
|
||||
*/
|
||||
|
||||
/* Header guard */
|
||||
#ifndef NRF_ERROR_SDM_H__
|
||||
#define NRF_ERROR_SDM_H__
|
||||
|
||||
#include "nrf_error.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN (NRF_ERROR_SDM_BASE_NUM + 0) ///< Unknown lfclk source.
|
||||
#define NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION (NRF_ERROR_SDM_BASE_NUM + 1) ///< Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts).
|
||||
#define NRF_ERROR_SDM_INCORRECT_CLENR0 (NRF_ERROR_SDM_BASE_NUM + 2) ///< Incorrect CLENR0 (can be caused by erronous SoftDevice flashing).
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_ERROR_SDM_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup nrf_soc_api
|
||||
@{
|
||||
@defgroup nrf_soc_error SoC Library Error Codes
|
||||
@{
|
||||
|
||||
@brief Error definitions for the SoC library
|
||||
|
||||
*/
|
||||
|
||||
/* Header guard */
|
||||
#ifndef NRF_ERROR_SOC_H__
|
||||
#define NRF_ERROR_SOC_H__
|
||||
|
||||
#include "nrf_error.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Mutex Errors */
|
||||
#define NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN (NRF_ERROR_SOC_BASE_NUM + 0) ///< Mutex already taken
|
||||
|
||||
/* NVIC errors */
|
||||
#define NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE (NRF_ERROR_SOC_BASE_NUM + 1) ///< NVIC interrupt not available
|
||||
#define NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED (NRF_ERROR_SOC_BASE_NUM + 2) ///< NVIC interrupt priority not allowed
|
||||
#define NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 3) ///< NVIC should not return
|
||||
|
||||
/* Power errors */
|
||||
#define NRF_ERROR_SOC_POWER_MODE_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 4) ///< Power mode unknown
|
||||
#define NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 5) ///< Power POF threshold unknown
|
||||
#define NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 6) ///< Power off should not return
|
||||
|
||||
/* Rand errors */
|
||||
#define NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES (NRF_ERROR_SOC_BASE_NUM + 7) ///< RAND not enough values
|
||||
|
||||
/* PPI errors */
|
||||
#define NRF_ERROR_SOC_PPI_INVALID_CHANNEL (NRF_ERROR_SOC_BASE_NUM + 8) ///< Invalid PPI Channel
|
||||
#define NRF_ERROR_SOC_PPI_INVALID_GROUP (NRF_ERROR_SOC_BASE_NUM + 9) ///< Invalid PPI Group
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_ERROR_SOC_H__
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,486 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup nrf_nvic_api SoftDevice NVIC API
|
||||
* @{
|
||||
*
|
||||
* @note In order to use this module, the following code has to be added to a .c file:
|
||||
* \code
|
||||
* nrf_nvic_state_t nrf_nvic_state;
|
||||
* \endcode
|
||||
*
|
||||
* @note Definitions and declarations starting with __ (double underscore) in this header file are
|
||||
* not intended for direct use by the application.
|
||||
*
|
||||
* @brief APIs for the accessing NVIC when using a SoftDevice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NRF_NVIC_H__
|
||||
#define NRF_NVIC_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "nrf.h"
|
||||
|
||||
#include "nrf_error_soc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**@addtogroup NRF_NVIC_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@defgroup NRF_NVIC_ISER_DEFINES SoftDevice NVIC internal definitions
|
||||
* @{ */
|
||||
|
||||
#define __NRF_NVIC_NVMC_IRQn (30) /**< The peripheral ID of the NVMC. IRQ numbers are used to identify peripherals, but the NVMC doesn't have an IRQ number in the MDK. */
|
||||
|
||||
#ifdef NRF51
|
||||
#define __NRF_NVIC_ISER_COUNT (1) /**< The number of ISER/ICER registers in the NVIC that are used. */
|
||||
|
||||
/**@brief Interrupts used by the SoftDevice. */
|
||||
#define __NRF_NVIC_SD_IRQS_0 ((uint32_t)( \
|
||||
(1U << POWER_CLOCK_IRQn) \
|
||||
| (1U << RADIO_IRQn) \
|
||||
| (1U << RTC0_IRQn) \
|
||||
| (1U << TIMER0_IRQn) \
|
||||
| (1U << RNG_IRQn) \
|
||||
| (1U << ECB_IRQn) \
|
||||
| (1U << CCM_AAR_IRQn) \
|
||||
| (1U << TEMP_IRQn) \
|
||||
| (1U << __NRF_NVIC_NVMC_IRQn) \
|
||||
| (1U << (uint32_t)SWI4_IRQn) \
|
||||
| (1U << (uint32_t)SWI5_IRQn) \
|
||||
))
|
||||
|
||||
/**@brief Interrupts available for to application. */
|
||||
#define __NRF_NVIC_APP_IRQS_0 (~__NRF_NVIC_SD_IRQS_0)
|
||||
#endif
|
||||
|
||||
#ifdef NRF52
|
||||
#define __NRF_NVIC_ISER_COUNT (2) /**< The number of ISER/ICER registers in the NVIC that are used. */
|
||||
|
||||
/**@brief Interrupts used by the SoftDevice. */
|
||||
#define __NRF_NVIC_SD_IRQS_0 ((uint32_t)( \
|
||||
(1U << POWER_CLOCK_IRQn) \
|
||||
| (1U << RADIO_IRQn) \
|
||||
| (1U << RTC0_IRQn) \
|
||||
| (1U << TIMER0_IRQn) \
|
||||
| (1U << RNG_IRQn) \
|
||||
| (1U << ECB_IRQn) \
|
||||
| (1U << CCM_AAR_IRQn) \
|
||||
| (1U << TEMP_IRQn) \
|
||||
| (1U << __NRF_NVIC_NVMC_IRQn) \
|
||||
| (1U << (uint32_t)SWI4_EGU4_IRQn) \
|
||||
| (1U << (uint32_t)SWI5_EGU5_IRQn) \
|
||||
))
|
||||
#define __NRF_NVIC_SD_IRQS_1 ((uint32_t)0)
|
||||
|
||||
/**@brief Interrupts available for to application. */
|
||||
#define __NRF_NVIC_APP_IRQS_0 (~__NRF_NVIC_SD_IRQS_0)
|
||||
#define __NRF_NVIC_APP_IRQS_1 (~__NRF_NVIC_SD_IRQS_1)
|
||||
#endif
|
||||
/**@} */
|
||||
|
||||
/**@} */
|
||||
|
||||
/**@addtogroup NRF_NVIC_VARIABLES Variables
|
||||
* @{ */
|
||||
|
||||
/**@brief Type representing the state struct for the SoftDevice NVIC module. */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t volatile __irq_masks[__NRF_NVIC_ISER_COUNT]; /**< IRQs enabled by the application in the NVIC. */
|
||||
uint32_t volatile __cr_flag; /**< Non-zero if already in a critical region */
|
||||
} nrf_nvic_state_t;
|
||||
|
||||
/**@brief Variable keeping the state for the SoftDevice NVIC module. This must be declared in an
|
||||
* application source file. */
|
||||
extern nrf_nvic_state_t nrf_nvic_state;
|
||||
|
||||
/**@} */
|
||||
|
||||
/**@addtogroup NRF_NVIC_INTERNAL_FUNCTIONS SoftDevice NVIC internal functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Disables IRQ interrupts globally, including the SoftDevice's interrupts.
|
||||
*
|
||||
* @retval The value of PRIMASK prior to disabling the interrupts.
|
||||
*/
|
||||
static inline int __sd_nvic_irq_disable(void)
|
||||
{
|
||||
int pm = __get_PRIMASK();
|
||||
__disable_irq();
|
||||
return pm;
|
||||
}
|
||||
|
||||
/**@brief Enables IRQ interrupts globally, including the SoftDevice's interrupts.
|
||||
*/
|
||||
static inline void __sd_nvic_irq_enable(void)
|
||||
{
|
||||
__enable_irq();
|
||||
}
|
||||
|
||||
/**@brief Checks if IRQn is available to application
|
||||
* @param[in] IRQn irq to check
|
||||
*
|
||||
* @retval 1 (true) if the irq to check is available to the application
|
||||
*/
|
||||
static inline uint32_t __sd_nvic_app_accessible_irq(IRQn_Type IRQn)
|
||||
{
|
||||
if (IRQn < 32)
|
||||
{
|
||||
return ((1UL<<IRQn) & __NRF_NVIC_APP_IRQS_0) != 0;
|
||||
}
|
||||
#ifdef NRF52
|
||||
else if (IRQn < 64)
|
||||
{
|
||||
return ((1UL<<(IRQn-32)) & __NRF_NVIC_APP_IRQS_1) != 0;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**@brief Checks if IRQn is available to application
|
||||
* @param[in] priority priority to check
|
||||
*
|
||||
* @retval 1 (true) if the priority to check is available to the application
|
||||
*/
|
||||
static inline uint32_t __sd_nvic_is_app_accessible_priority(uint32_t priority)
|
||||
{
|
||||
if(priority >= (1 << __NVIC_PRIO_BITS))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#ifdef NRF51
|
||||
if( priority == 0
|
||||
|| priority == 2
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#ifdef NRF52
|
||||
if( priority == 0
|
||||
|| priority == 1
|
||||
|| priority == 4
|
||||
|| priority == 5
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**@} */
|
||||
|
||||
/**@addtogroup NRF_NVIC_FUNCTIONS SoftDevice NVIC public functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Enable External Interrupt.
|
||||
* @note Corresponds to NVIC_EnableIRQ in CMSIS.
|
||||
*
|
||||
* @pre IRQn is valid and not reserved by the stack.
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_EnableIRQ documentation in CMSIS.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt was enabled.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE The interrupt is not available for the application.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED The interrupt has a priority not available for the application.
|
||||
*/
|
||||
static inline uint32_t sd_nvic_EnableIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
if (!__sd_nvic_app_accessible_irq(IRQn))
|
||||
{
|
||||
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
|
||||
}
|
||||
if (!__sd_nvic_is_app_accessible_priority(NVIC_GetPriority(IRQn)))
|
||||
{
|
||||
return NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED;
|
||||
}
|
||||
|
||||
if (nrf_nvic_state.__cr_flag)
|
||||
{
|
||||
nrf_nvic_state.__irq_masks[(uint32_t)((int32_t)IRQn) >> 5] |= (uint32_t)(1 << ((uint32_t)((int32_t)IRQn) & (uint32_t)0x1F));
|
||||
}
|
||||
else
|
||||
{
|
||||
NVIC_EnableIRQ(IRQn);
|
||||
}
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
/**@brief Disable External Interrupt.
|
||||
* @note Corresponds to NVIC_DisableIRQ in CMSIS.
|
||||
*
|
||||
* @pre IRQn is valid and not reserved by the stack.
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_DisableIRQ documentation in CMSIS.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt was disabled.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE The interrupt is not available for the application.
|
||||
*/
|
||||
static inline uint32_t sd_nvic_DisableIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
if (!__sd_nvic_app_accessible_irq(IRQn))
|
||||
{
|
||||
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
if (nrf_nvic_state.__cr_flag)
|
||||
{
|
||||
nrf_nvic_state.__irq_masks[(uint32_t)((int32_t)IRQn) >> 5] &= ~(1UL << ((uint32_t)(IRQn) & 0x1F));
|
||||
}
|
||||
else
|
||||
{
|
||||
NVIC_DisableIRQ(IRQn);
|
||||
}
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
/**@brief Get Pending Interrupt.
|
||||
* @note Corresponds to NVIC_GetPendingIRQ in CMSIS.
|
||||
*
|
||||
* @pre IRQn is valid and not reserved by the stack.
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_GetPendingIRQ documentation in CMSIS.
|
||||
* @param[out] p_pending_irq Return value from NVIC_GetPendingIRQ.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt is available for the application.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
|
||||
*/
|
||||
static inline uint32_t sd_nvic_GetPendingIRQ(IRQn_Type IRQn, uint32_t * p_pending_irq)
|
||||
{
|
||||
if (__sd_nvic_app_accessible_irq(IRQn))
|
||||
{
|
||||
*p_pending_irq = NVIC_GetPendingIRQ(IRQn);
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
/**@brief Set Pending Interrupt.
|
||||
* @note Corresponds to NVIC_SetPendingIRQ in CMSIS.
|
||||
*
|
||||
* @pre IRQn is valid and not reserved by the stack.
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_SetPendingIRQ documentation in CMSIS.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt is set pending.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
|
||||
*/
|
||||
static inline uint32_t sd_nvic_SetPendingIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
if (__sd_nvic_app_accessible_irq(IRQn))
|
||||
{
|
||||
NVIC_SetPendingIRQ(IRQn);
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
/**@brief Clear Pending Interrupt.
|
||||
* @note Corresponds to NVIC_ClearPendingIRQ in CMSIS.
|
||||
*
|
||||
* @pre IRQn is valid and not reserved by the stack.
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_ClearPendingIRQ documentation in CMSIS.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt pending flag is cleared.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
|
||||
*/
|
||||
static inline uint32_t sd_nvic_ClearPendingIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
if (__sd_nvic_app_accessible_irq(IRQn))
|
||||
{
|
||||
NVIC_ClearPendingIRQ(IRQn);
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
/**@brief Set Interrupt Priority.
|
||||
* @note Corresponds to NVIC_SetPriority in CMSIS.
|
||||
*
|
||||
* @pre IRQn is valid and not reserved by the stack.
|
||||
* @pre Priority is valid and not reserved by the stack.
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_SetPriority documentation in CMSIS.
|
||||
* @param[in] priority A valid IRQ priority for use by the application.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt and priority level is available for the application.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED The interrupt priority is not available for the application.
|
||||
*/
|
||||
static inline uint32_t sd_nvic_SetPriority(IRQn_Type IRQn, uint32_t priority)
|
||||
{
|
||||
if (!__sd_nvic_app_accessible_irq(IRQn))
|
||||
{
|
||||
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
if (!__sd_nvic_is_app_accessible_priority(priority))
|
||||
{
|
||||
return NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED;
|
||||
}
|
||||
|
||||
NVIC_SetPriority(IRQn, (uint32_t)priority);
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
/**@brief Get Interrupt Priority.
|
||||
* @note Corresponds to NVIC_GetPriority in CMSIS.
|
||||
*
|
||||
* @pre IRQn is valid and not reserved by the stack.
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_GetPriority documentation in CMSIS.
|
||||
* @param[out] p_priority Return value from NVIC_GetPriority.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt priority is returned in p_priority.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE - IRQn is not available for the application.
|
||||
*/
|
||||
static inline uint32_t sd_nvic_GetPriority(IRQn_Type IRQn, uint32_t * p_priority)
|
||||
{
|
||||
if (__sd_nvic_app_accessible_irq(IRQn))
|
||||
{
|
||||
*p_priority = (NVIC_GetPriority(IRQn) & 0xFF);
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
/**@brief System Reset.
|
||||
* @note Corresponds to NVIC_SystemReset in CMSIS.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN
|
||||
*/
|
||||
static inline uint32_t sd_nvic_SystemReset(void)
|
||||
{
|
||||
NVIC_SystemReset();
|
||||
return NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN;
|
||||
}
|
||||
|
||||
/**@brief Enters critical region.
|
||||
*
|
||||
* @post Application interrupts will be disabled.
|
||||
* @note sd_nvic_critical_region_enter() and ::sd_nvic_critical_region_exit() must be called in matching pairs inside each
|
||||
* execution context
|
||||
* @sa sd_nvic_critical_region_exit
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
static inline uint32_t sd_nvic_critical_region_enter(uint8_t * p_is_nested_critical_region)
|
||||
{
|
||||
int was_masked = __sd_nvic_irq_disable();
|
||||
if (!nrf_nvic_state.__cr_flag)
|
||||
{
|
||||
nrf_nvic_state.__cr_flag = 1;
|
||||
nrf_nvic_state.__irq_masks[0] = ( NVIC->ICER[0] & __NRF_NVIC_APP_IRQS_0 );
|
||||
NVIC->ICER[0] = __NRF_NVIC_APP_IRQS_0;
|
||||
#ifdef NRF52
|
||||
nrf_nvic_state.__irq_masks[1] = ( NVIC->ICER[1] & __NRF_NVIC_APP_IRQS_1 );
|
||||
NVIC->ICER[1] = __NRF_NVIC_APP_IRQS_1;
|
||||
#endif
|
||||
*p_is_nested_critical_region = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*p_is_nested_critical_region = 1;
|
||||
}
|
||||
if (!was_masked)
|
||||
{
|
||||
__sd_nvic_irq_enable();
|
||||
}
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
/**@brief Exit critical region.
|
||||
*
|
||||
* @pre Application has entered a critical region using ::sd_nvic_critical_region_enter.
|
||||
* @post If not in a nested critical region, the application interrupts will restored to the state before ::sd_nvic_critical_region_enter was called.
|
||||
*
|
||||
* @param[in] is_nested_critical_region If this is set to 1, the critical region won't be exited. @sa sd_nvic_critical_region_enter.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
static inline uint32_t sd_nvic_critical_region_exit(uint8_t is_nested_critical_region)
|
||||
{
|
||||
if (nrf_nvic_state.__cr_flag && (is_nested_critical_region == 0))
|
||||
{
|
||||
int was_masked = __sd_nvic_irq_disable();
|
||||
NVIC->ISER[0] = nrf_nvic_state.__irq_masks[0];
|
||||
#ifdef NRF52
|
||||
NVIC->ISER[1] = nrf_nvic_state.__irq_masks[1];
|
||||
#endif
|
||||
nrf_nvic_state.__cr_flag = 0;
|
||||
if (!was_masked)
|
||||
{
|
||||
__sd_nvic_irq_enable();
|
||||
}
|
||||
}
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
/**@} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_NVIC_H__
|
||||
|
||||
/**@} */
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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 NRF_SD_DEF_H__
|
||||
#define NRF_SD_DEF_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define SD_PPI_CHANNELS_USED 0xFFF0C000uL /**< PPI channels utilized by SotfDevice (not available to the application). */
|
||||
#define SD_PPI_GROUPS_USED 0x0000000CuL /**< PPI groups utilized by SoftDevice (not available to the application). */
|
||||
#define SD_TIMERS_USED 0x00000001uL /**< Timers used by SoftDevice. */
|
||||
#define SD_SWI_USED 0x0000003CuL /**< Software interrupts used by SoftDevice */
|
||||
|
||||
#endif /* NRF_SD_DEF_H__ */
|
||||
|
|
@ -1,274 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup nrf_sdm_api SoftDevice Manager API
|
||||
@{
|
||||
|
||||
@brief APIs for SoftDevice management.
|
||||
|
||||
*/
|
||||
|
||||
/* Header guard */
|
||||
#ifndef NRF_SDM_H__
|
||||
#define NRF_SDM_H__
|
||||
|
||||
#include "nrf_svc.h"
|
||||
#include "nrf.h"
|
||||
#include "nrf_soc.h"
|
||||
#include "nrf_error_sdm.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup NRF_SDM_DEFINES Defines
|
||||
* @{ */
|
||||
#ifdef NRFSOC_DOXYGEN
|
||||
//Stuff defined elsewere, to satisfy doxygen
|
||||
#define MBR_SIZE 0
|
||||
#warning test
|
||||
#endif
|
||||
|
||||
/** @brief SoftDevice Manager SVC Base number. */
|
||||
#define SDM_SVC_BASE 0x10
|
||||
|
||||
/** @brief Defines the SoftDevice Information Structure location (address) as an offset from
|
||||
the start of the softdevice (without MBR)*/
|
||||
#define SOFTDEVICE_INFO_STRUCT_OFFSET (0x2000)
|
||||
|
||||
/** @brief Defines the absolute Softdevice information structure location (address)*/
|
||||
#define SOFTDEVICE_INFO_STRUCT_ADDRESS (SOFTDEVICE_INFO_STRUCT_OFFSET + MBR_SIZE)
|
||||
|
||||
/** @brief Defines the offset for Softdevice size value relative to Softdevice base address*/
|
||||
#define SD_SIZE_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x08)
|
||||
|
||||
/** @brief Defines the offset for FWID value relative to Softdevice base address*/
|
||||
#define SD_FWID_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x0C)
|
||||
|
||||
/** @brief Defines a macro for retreiving the actual Softdevice size value from a given base address
|
||||
use @ref MBR_SIZE when Softdevice is installed just above the MBR (the usual case)*/
|
||||
#define SD_SIZE_GET(baseaddr) (*((uint32_t *) ((baseaddr) + SD_SIZE_OFFSET)))
|
||||
|
||||
/** @brief Defines a macro for retreiving the actual FWID value from a given base address
|
||||
use @ref MBR_SIZE when Softdevice is installed just above the MBR (the usual case)*/
|
||||
#define SD_FWID_GET(baseaddr) ((*((uint32_t *) ((baseaddr) + SD_FWID_OFFSET))) & 0xFFFF)
|
||||
|
||||
/**@defgroup NRF_FAULT_ID_RANGES Fault ID ranges
|
||||
* @{ */
|
||||
#define NRF_FAULT_ID_SD_RANGE_START 0x00000000 /**< SoftDevice ID range start. */
|
||||
#define NRF_FAULT_ID_APP_RANGE_START 0x00001000 /**< Application ID range start. */
|
||||
/**@} */
|
||||
|
||||
/**@defgroup NRF_FAULT_IDS Fault ID types
|
||||
* @{ */
|
||||
#define NRF_FAULT_ID_SD_ASSERT (NRF_FAULT_ID_SD_RANGE_START + 1) /**< SoftDevice assertion. The info parameter will be set to 0x00000000. */
|
||||
#define NRF_FAULT_ID_APP_MEMACC (NRF_FAULT_ID_APP_RANGE_START + 1) /**< Application invalid memory access. The info parameter will contain the address in memory that was accessed. */
|
||||
/**@} */
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_SDM_ENUMS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief nRF SoftDevice Manager API SVC numbers. */
|
||||
enum NRF_SD_SVCS
|
||||
{
|
||||
SD_SOFTDEVICE_ENABLE = SDM_SVC_BASE, /**< ::sd_softdevice_enable */
|
||||
SD_SOFTDEVICE_DISABLE, /**< ::sd_softdevice_disable */
|
||||
SD_SOFTDEVICE_IS_ENABLED, /**< ::sd_softdevice_is_enabled */
|
||||
SD_SOFTDEVICE_VECTOR_TABLE_BASE_SET, /**< ::sd_softdevice_vector_table_base_set */
|
||||
SVC_SDM_LAST /**< Placeholder for last SDM SVC */
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_SDM_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@defgroup NRF_CLOCK_LF_XTAL_ACCURACY Clock accuracy * @{ */
|
||||
|
||||
#define NRF_CLOCK_LF_XTAL_ACCURACY_250_PPM (0) /* Default */
|
||||
#define NRF_CLOCK_LF_XTAL_ACCURACY_500_PPM (1)
|
||||
#define NRF_CLOCK_LF_XTAL_ACCURACY_150_PPM (2)
|
||||
#define NRF_CLOCK_LF_XTAL_ACCURACY_100_PPM (3)
|
||||
#define NRF_CLOCK_LF_XTAL_ACCURACY_75_PPM (4)
|
||||
#define NRF_CLOCK_LF_XTAL_ACCURACY_50_PPM (5)
|
||||
#define NRF_CLOCK_LF_XTAL_ACCURACY_30_PPM (6)
|
||||
#define NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM (7)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**@defgroup NRF_CLOCK_LF_SRC Possible lfclk oscillator sources * @{ */
|
||||
|
||||
#define NRF_CLOCK_LF_SRC_RC (0) /**< LFCLK RC oscillator. */
|
||||
#define NRF_CLOCK_LF_SRC_XTAL (1) /**< LFCLK crystal oscillator. */
|
||||
#define NRF_CLOCK_LF_SRC_SYNTH (2) /**< LFCLK Synthesized from HFCLK. */
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_SDM_TYPES Types
|
||||
* @{ */
|
||||
|
||||
/**@brief Type representing lfclk oscillator source. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t source; /**< LF oscillator clock source, see @ref NRF_CLOCK_LF_SRC. */
|
||||
uint8_t rc_ctiv; /**< Only for NRF_CLOCK_LF_SRC_RC: Calibration timer interval in 1/4 second
|
||||
units (nRF51: 1-64, nRF52: 1-32).
|
||||
@note To avoid excessive clock drift, 0.5 degrees Celsius is the
|
||||
maximum temperature change allowed in one calibration timer
|
||||
interval. The interval should be selected to ensure this.
|
||||
|
||||
@note Must be 0 if source is not NRF_CLOCK_LF_SRC_RC. */
|
||||
uint8_t rc_temp_ctiv; /**< Only for NRF_CLOCK_LF_SRC_RC: How often (in number of calibration
|
||||
intervals) the RC oscillator shall be calibrated if the temperature
|
||||
hasn't changed.
|
||||
0: Always calibrate even if the temperature hasn't changed.
|
||||
1: Only calibrate if the temperature has changed (nRF51 only).
|
||||
2-33: Check the temperature and only calibrate if it has changed,
|
||||
however calibration will take place every rc_temp_ctiv
|
||||
intervals in any case.
|
||||
|
||||
@note Must be 0 if source is not NRF_CLOCK_LF_SRC_RC.
|
||||
|
||||
@note For nRF52, the application must ensure calibration at least once
|
||||
every 8 seconds to ensure +/-250ppm clock stability. The
|
||||
recommended configuration for NRF_CLOCK_LF_SRC_RC on nRF52 is
|
||||
rc_ctiv=16 and rc_temp_ctiv=2. This will ensure calibration at
|
||||
least once every 8 seconds and for temperature changes of 0.5
|
||||
degrees Celsius every 4 seconds. See the Product Specification
|
||||
for the nRF52 device being used for more information.*/
|
||||
uint8_t xtal_accuracy; /**< External crystal clock accuracy used in the LL to compute timing windows.
|
||||
|
||||
@note For the NRF_CLOCK_LF_SRC_RC clock source this parameter is ignored. */
|
||||
} nrf_clock_lf_cfg_t;
|
||||
|
||||
/**@brief Fault Handler type.
|
||||
*
|
||||
* When certain unrecoverable errors occur within the application or SoftDevice the fault handler will be called back.
|
||||
* The protocol stack will be in an undefined state when this happens and the only way to recover will be to
|
||||
* perform a reset, using e.g. CMSIS NVIC_SystemReset().
|
||||
*
|
||||
* @note This callback is executed in HardFault context, thus SVC functions cannot be called from the fault callback.
|
||||
*
|
||||
* @param[in] id Fault identifier. See @ref NRF_FAULT_IDS.
|
||||
* @param[in] pc The program counter of the instruction that triggered the fault.
|
||||
* @param[in] info Optional additional information regarding the fault. Refer to each Fault identifier for details.
|
||||
*/
|
||||
typedef void (*nrf_fault_handler_t)(uint32_t id, uint32_t pc, uint32_t info);
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_SDM_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Enables the SoftDevice and by extension the protocol stack.
|
||||
*
|
||||
* @note Some care must be taken if a low frequency clock source is already running when calling this function:
|
||||
* If the LF clock has a different source then the one currently running, it will be stopped. Then, the new
|
||||
* clock source will be started.
|
||||
*
|
||||
* @note This function has no effect when returning with an error.
|
||||
*
|
||||
* @post If return code is ::NRF_SUCCESS
|
||||
* - SoC library and protocol stack APIs are made available.
|
||||
* - A portion of RAM will be unavailable (see relevant SDS documentation).
|
||||
* - Some peripherals will be unavailable or available only through the SoC API (see relevant SDS documentation).
|
||||
* - Interrupts will not arrive from protected peripherals or interrupts.
|
||||
* - nrf_nvic_ functions must be used instead of CMSIS NVIC_ functions for reliable usage of the SoftDevice.
|
||||
* - Interrupt latency may be affected by the SoftDevice (see relevant SDS documentation).
|
||||
* - Chosen low frequency clock source will be running.
|
||||
*
|
||||
* @param p_clock_lf_cfg Low frequency clock source and accuracy.
|
||||
If NULL the clock will be configured as an rc source with rc_ctiv = 16 and .rc_temp_ctiv = 2
|
||||
In the case of XTAL source, the PPM accuracy of the chosen clock source must be greater than or equal to the actual characteristics of your XTAL clock.
|
||||
* @param fault_handler Callback to be invoked in case of fault.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
* @retval ::NRF_ERROR_INVALID_STATE SoftDevice is already enabled, and the clock source and fault handler cannot be updated.
|
||||
* @retval ::NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION SoftDevice interrupt is already enabled, or an enabled interrupt has an illegal priority level.
|
||||
* @retval ::NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN Unknown low frequency clock source selected.
|
||||
*/
|
||||
SVCALL(SD_SOFTDEVICE_ENABLE, uint32_t, sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg, nrf_fault_handler_t fault_handler));
|
||||
|
||||
|
||||
/**@brief Disables the SoftDevice and by extension the protocol stack.
|
||||
*
|
||||
* Idempotent function to disable the SoftDevice.
|
||||
*
|
||||
* @post SoC library and protocol stack APIs are made unavailable.
|
||||
* @post All interrupts that was protected by the SoftDevice will be disabled and initialized to priority 0 (highest).
|
||||
* @post All peripherals used by the SoftDevice will be reset to default values.
|
||||
* @post All of RAM become available.
|
||||
* @post All interrupts are forwarded to the application.
|
||||
* @post LFCLK source chosen in ::sd_softdevice_enable will be left running.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_SOFTDEVICE_DISABLE, uint32_t, sd_softdevice_disable(void));
|
||||
|
||||
/**@brief Check if the SoftDevice is enabled.
|
||||
*
|
||||
* @param[out] p_softdevice_enabled If the SoftDevice is enabled: 1 else 0.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_SOFTDEVICE_IS_ENABLED, uint32_t, sd_softdevice_is_enabled(uint8_t * p_softdevice_enabled));
|
||||
|
||||
/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the SoftDevice
|
||||
*
|
||||
* This function is only intended to be called when a bootloader is enabled.
|
||||
*
|
||||
* @param[in] address The base address of the interrupt vector table for forwarded interrupts.
|
||||
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_SOFTDEVICE_VECTOR_TABLE_BASE_SET, uint32_t, sd_softdevice_vector_table_base_set(uint32_t address));
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_SDM_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,911 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup nrf_soc_api SoC Library API
|
||||
* @{
|
||||
*
|
||||
* @brief APIs for the SoC library.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NRF_SOC_H__
|
||||
#define NRF_SOC_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "nrf_svc.h"
|
||||
#include "nrf.h"
|
||||
|
||||
#include "nrf_error_soc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**@addtogroup NRF_SOC_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@brief The number of the lowest SVC number reserved for the SoC library. */
|
||||
#define SOC_SVC_BASE (0x20)
|
||||
#define SOC_SVC_BASE_NOT_AVAILABLE (0x2B)
|
||||
|
||||
/**@brief Guranteed time for application to process radio inactive notification. */
|
||||
#define NRF_RADIO_NOTIFICATION_INACTIVE_GUARANTEED_TIME_US (62)
|
||||
|
||||
/**@brief The minimum allowed timeslot extension time. */
|
||||
#define NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US (200)
|
||||
|
||||
#define SOC_ECB_KEY_LENGTH (16) /**< ECB key length. */
|
||||
#define SOC_ECB_CLEARTEXT_LENGTH (16) /**< ECB cleartext length. */
|
||||
#define SOC_ECB_CIPHERTEXT_LENGTH (SOC_ECB_CLEARTEXT_LENGTH) /**< ECB ciphertext length. */
|
||||
|
||||
#ifdef NRF51
|
||||
#define SD_EVT_IRQn (SWI2_IRQn) /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */
|
||||
#define SD_EVT_IRQHandler (SWI2_IRQHandler) /**< SoftDevice Event IRQ handler. Used for both protocol events and SoC events. */
|
||||
#define RADIO_NOTIFICATION_IRQn (SWI1_IRQn) /**< The radio notification IRQ number. */
|
||||
#define RADIO_NOTIFICATION_IRQHandler (SWI1_IRQHandler) /**< The radio notification IRQ handler. */
|
||||
#endif
|
||||
#ifdef NRF52
|
||||
#define SD_EVT_IRQn (SWI2_EGU2_IRQn) /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */
|
||||
#define SD_EVT_IRQHandler (SWI2_EGU2_IRQHandler) /**< SoftDevice Event IRQ handler. Used for both protocol events and SoC events. */
|
||||
#define RADIO_NOTIFICATION_IRQn (SWI1_EGU1_IRQn) /**< The radio notification IRQ number. */
|
||||
#define RADIO_NOTIFICATION_IRQHandler (SWI1_EGU1_IRQHandler) /**< The radio notification IRQ handler. */
|
||||
#endif
|
||||
|
||||
#define NRF_RADIO_LENGTH_MIN_US (100) /**< The shortest allowed radio timeslot, in microseconds. */
|
||||
#define NRF_RADIO_LENGTH_MAX_US (100000) /**< The longest allowed radio timeslot, in microseconds. */
|
||||
|
||||
#define NRF_RADIO_DISTANCE_MAX_US (128000000UL - 1UL) /**< The longest timeslot distance, in microseconds, allowed for the distance parameter (see @ref nrf_radio_request_normal_t) in the request. */
|
||||
|
||||
#define NRF_RADIO_EARLIEST_TIMEOUT_MAX_US (128000000UL - 1UL) /**< The longest timeout, in microseconds, allowed when requesting the earliest possible timeslot. */
|
||||
|
||||
#define NRF_RADIO_START_JITTER_US (2) /**< The maximum jitter in @ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START relative to the requested start time. */
|
||||
|
||||
/**@} */
|
||||
|
||||
/**@addtogroup NRF_SOC_ENUMS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief The SVC numbers used by the SVC functions in the SoC library. */
|
||||
enum NRF_SOC_SVCS
|
||||
{
|
||||
SD_PPI_CHANNEL_ENABLE_GET = SOC_SVC_BASE,
|
||||
SD_PPI_CHANNEL_ENABLE_SET,
|
||||
SD_PPI_CHANNEL_ENABLE_CLR,
|
||||
SD_PPI_CHANNEL_ASSIGN,
|
||||
SD_PPI_GROUP_TASK_ENABLE,
|
||||
SD_PPI_GROUP_TASK_DISABLE,
|
||||
SD_PPI_GROUP_ASSIGN,
|
||||
SD_PPI_GROUP_GET,
|
||||
SD_FLASH_PAGE_ERASE,
|
||||
SD_FLASH_WRITE,
|
||||
SD_FLASH_PROTECT,
|
||||
SD_MUTEX_NEW = SOC_SVC_BASE_NOT_AVAILABLE,
|
||||
SD_MUTEX_ACQUIRE,
|
||||
SD_MUTEX_RELEASE,
|
||||
SD_RFU_1,
|
||||
SD_RFU_2,
|
||||
SD_RFU_3,
|
||||
SD_RFU_4,
|
||||
SD_RFU_5,
|
||||
SD_RFU_6,
|
||||
SD_RFU_7,
|
||||
SD_RFU_8,
|
||||
SD_RFU_9,
|
||||
SD_RFU_10,
|
||||
SD_RAND_APPLICATION_POOL_CAPACITY_GET,
|
||||
SD_RAND_APPLICATION_BYTES_AVAILABLE_GET,
|
||||
SD_RAND_APPLICATION_VECTOR_GET,
|
||||
SD_POWER_MODE_SET,
|
||||
SD_POWER_SYSTEM_OFF,
|
||||
SD_POWER_RESET_REASON_GET,
|
||||
SD_POWER_RESET_REASON_CLR,
|
||||
SD_POWER_POF_ENABLE,
|
||||
SD_POWER_POF_THRESHOLD_SET,
|
||||
SD_POWER_RAMON_SET,
|
||||
SD_POWER_RAMON_CLR,
|
||||
SD_POWER_RAMON_GET,
|
||||
SD_POWER_GPREGRET_SET,
|
||||
SD_POWER_GPREGRET_CLR,
|
||||
SD_POWER_GPREGRET_GET,
|
||||
SD_POWER_DCDC_MODE_SET,
|
||||
SD_APP_EVT_WAIT,
|
||||
SD_CLOCK_HFCLK_REQUEST,
|
||||
SD_CLOCK_HFCLK_RELEASE,
|
||||
SD_CLOCK_HFCLK_IS_RUNNING,
|
||||
SD_RADIO_NOTIFICATION_CFG_SET,
|
||||
SD_ECB_BLOCK_ENCRYPT,
|
||||
SD_ECB_BLOCKS_ENCRYPT,
|
||||
SD_RADIO_SESSION_OPEN,
|
||||
SD_RADIO_SESSION_CLOSE,
|
||||
SD_RADIO_REQUEST,
|
||||
SD_EVT_GET,
|
||||
SD_TEMP_GET,
|
||||
SVC_SOC_LAST
|
||||
};
|
||||
|
||||
/**@brief Possible values of a ::nrf_mutex_t. */
|
||||
enum NRF_MUTEX_VALUES
|
||||
{
|
||||
NRF_MUTEX_FREE,
|
||||
NRF_MUTEX_TAKEN
|
||||
};
|
||||
|
||||
/**@brief Power modes. */
|
||||
enum NRF_POWER_MODES
|
||||
{
|
||||
NRF_POWER_MODE_CONSTLAT, /**< Constant latency mode. See power management in the reference manual. */
|
||||
NRF_POWER_MODE_LOWPWR /**< Low power mode. See power management in the reference manual. */
|
||||
};
|
||||
|
||||
|
||||
/**@brief Power failure thresholds */
|
||||
enum NRF_POWER_THRESHOLDS
|
||||
{
|
||||
NRF_POWER_THRESHOLD_V21, /**< 2.1 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLD_V23, /**< 2.3 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLD_V25, /**< 2.5 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLD_V27 /**< 2.7 Volts power failure threshold. */
|
||||
};
|
||||
|
||||
|
||||
/**@brief DC/DC converter modes. */
|
||||
enum NRF_POWER_DCDC_MODES
|
||||
{
|
||||
NRF_POWER_DCDC_DISABLE, /**< The DCDC is disabled. */
|
||||
NRF_POWER_DCDC_ENABLE /**< The DCDC is enabled. */
|
||||
};
|
||||
|
||||
/**@brief Radio notification distances. */
|
||||
enum NRF_RADIO_NOTIFICATION_DISTANCES
|
||||
{
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_NONE = 0, /**< The event does not have a notification. */
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_800US, /**< The distance from the active notification to start of radio activity. */
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_1740US, /**< The distance from the active notification to start of radio activity. */
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_2680US, /**< The distance from the active notification to start of radio activity. */
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_3620US, /**< The distance from the active notification to start of radio activity. */
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_4560US, /**< The distance from the active notification to start of radio activity. */
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_5500US /**< The distance from the active notification to start of radio activity. */
|
||||
};
|
||||
|
||||
|
||||
/**@brief Radio notification types. */
|
||||
enum NRF_RADIO_NOTIFICATION_TYPES
|
||||
{
|
||||
NRF_RADIO_NOTIFICATION_TYPE_NONE = 0, /**< The event does not have a radio notification signal. */
|
||||
NRF_RADIO_NOTIFICATION_TYPE_INT_ON_ACTIVE, /**< Using interrupt for notification when the radio will be enabled. */
|
||||
NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE, /**< Using interrupt for notification when the radio has been disabled. */
|
||||
NRF_RADIO_NOTIFICATION_TYPE_INT_ON_BOTH, /**< Using interrupt for notification both when the radio will be enabled and disabled. */
|
||||
};
|
||||
|
||||
/**@brief The Radio signal callback types. */
|
||||
enum NRF_RADIO_CALLBACK_SIGNAL_TYPE
|
||||
{
|
||||
NRF_RADIO_CALLBACK_SIGNAL_TYPE_START, /**< This signal indicates the start of the radio timeslot. */
|
||||
NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0, /**< This signal indicates the NRF_TIMER0 interrupt. */
|
||||
NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO, /**< This signal indicates the NRF_RADIO interrupt. */
|
||||
NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_FAILED, /**< This signal indicates extend action failed. */
|
||||
NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_SUCCEEDED /**< This signal indicates extend action succeeded. */
|
||||
};
|
||||
|
||||
/**@brief The actions requested by the signal callback.
|
||||
*
|
||||
* This code gives the SOC instructions about what action to take when the signal callback has
|
||||
* returned.
|
||||
*/
|
||||
enum NRF_RADIO_SIGNAL_CALLBACK_ACTION
|
||||
{
|
||||
NRF_RADIO_SIGNAL_CALLBACK_ACTION_NONE, /**< Return without action. */
|
||||
NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND, /**< Request an extension of the current timeslot (maximum execution time for this action is when the extension succeeded). */
|
||||
NRF_RADIO_SIGNAL_CALLBACK_ACTION_END, /**< End the current radio timeslot. */
|
||||
NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END /**< Request a new radio timeslot and end the current timeslot. */
|
||||
};
|
||||
|
||||
/**@brief Radio timeslot high frequency clock source configuration. */
|
||||
enum NRF_RADIO_HFCLK_CFG
|
||||
{
|
||||
NRF_RADIO_HFCLK_CFG_XTAL_GUARANTEED, /**< The SoftDevice will guarantee that the high frequency clock source is the
|
||||
external crystal for the whole duration of the timeslot. This should be the
|
||||
preferred option for events that use the radio or require high timing accuracy. */
|
||||
NRF_RADIO_HFCLK_CFG_NO_GUARANTEE /**< This configuration allows for earlier and tighter scheduling of timeslots.
|
||||
The RC oscillator may be the clock source in part or for the whole duration of the timeslot.
|
||||
The RC oscillator's accuracy must therefore be taken into consideration.
|
||||
@note If the application will use the radio peripheral in timeslots with this configuration,
|
||||
it must make sure that the crystal is running and stable before starting the radio. */
|
||||
};
|
||||
|
||||
/**@brief Radio timeslot priorities. */
|
||||
enum NRF_RADIO_PRIORITY
|
||||
{
|
||||
NRF_RADIO_PRIORITY_HIGH, /**< High (equal priority as the normal connection priority of the SoftDevice stack(s)). */
|
||||
NRF_RADIO_PRIORITY_NORMAL, /**< Normal (equal priority as the priority of secondary activites of the SoftDevice stack(s)). */
|
||||
};
|
||||
|
||||
/**@brief Radio timeslot request type. */
|
||||
enum NRF_RADIO_REQUEST_TYPE
|
||||
{
|
||||
NRF_RADIO_REQ_TYPE_EARLIEST, /**< Request radio timeslot as early as possible. This should always be used for the first request in a session. */
|
||||
NRF_RADIO_REQ_TYPE_NORMAL /**< Normal radio timeslot request. */
|
||||
};
|
||||
|
||||
/**@brief SoC Events. */
|
||||
enum NRF_SOC_EVTS
|
||||
{
|
||||
NRF_EVT_HFCLKSTARTED, /**< Event indicating that the HFCLK has started. */
|
||||
NRF_EVT_POWER_FAILURE_WARNING, /**< Event indicating that a power failure warning has occurred. */
|
||||
NRF_EVT_FLASH_OPERATION_SUCCESS, /**< Event indicating that the ongoing flash operation has completed successfully. */
|
||||
NRF_EVT_FLASH_OPERATION_ERROR, /**< Event indicating that the ongoing flash operation has timed out with an error. */
|
||||
NRF_EVT_RADIO_BLOCKED, /**< Event indicating that a radio timeslot was blocked. */
|
||||
NRF_EVT_RADIO_CANCELED, /**< Event indicating that a radio timeslot was canceled by SoftDevice. */
|
||||
NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN, /**< Event indicating that a radio timeslot signal callback handler return was invalid. */
|
||||
NRF_EVT_RADIO_SESSION_IDLE, /**< Event indicating that a radio timeslot session is idle. */
|
||||
NRF_EVT_RADIO_SESSION_CLOSED, /**< Event indicating that a radio timeslot session is closed. */
|
||||
NRF_EVT_NUMBER_OF_EVTS
|
||||
};
|
||||
|
||||
/**@} */
|
||||
|
||||
|
||||
/**@addtogroup NRF_SOC_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**@brief Represents a mutex for use with the nrf_mutex functions.
|
||||
* @note Accessing the value directly is not safe, use the mutex functions!
|
||||
*/
|
||||
typedef volatile uint8_t nrf_mutex_t;
|
||||
|
||||
/**@brief Parameters for a request for a timeslot as early as possible. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t hfclk; /**< High frequency clock source, see @ref NRF_RADIO_HFCLK_CFG. */
|
||||
uint8_t priority; /**< The radio timeslot priority, see @ref NRF_RADIO_PRIORITY. */
|
||||
uint32_t length_us; /**< The radio timeslot length (in the range 100 to 100,000] microseconds). */
|
||||
uint32_t timeout_us; /**< Longest acceptable delay until the start of the requested timeslot (up to @ref NRF_RADIO_EARLIEST_TIMEOUT_MAX_US microseconds). */
|
||||
} nrf_radio_request_earliest_t;
|
||||
|
||||
/**@brief Parameters for a normal radio timeslot request. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t hfclk; /**< High frequency clock source, see @ref NRF_RADIO_HFCLK_CFG. */
|
||||
uint8_t priority; /**< The radio timeslot priority, see @ref NRF_RADIO_PRIORITY. */
|
||||
uint32_t distance_us; /**< Distance from the start of the previous radio timeslot (up to @ref NRF_RADIO_DISTANCE_MAX_US microseconds). */
|
||||
uint32_t length_us; /**< The radio timeslot length (in the range [100..100,000] microseconds). */
|
||||
} nrf_radio_request_normal_t;
|
||||
|
||||
/**@brief Radio timeslot request parameters. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t request_type; /**< Type of request, see @ref NRF_RADIO_REQUEST_TYPE. */
|
||||
union
|
||||
{
|
||||
nrf_radio_request_earliest_t earliest; /**< Parameters for requesting a radio timeslot as early as possible. */
|
||||
nrf_radio_request_normal_t normal; /**< Parameters for requesting a normal radio timeslot. */
|
||||
} params;
|
||||
} nrf_radio_request_t;
|
||||
|
||||
/**@brief Return parameters of the radio timeslot signal callback. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t callback_action; /**< The action requested by the application when returning from the signal callback, see @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION. */
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
nrf_radio_request_t * p_next; /**< The request parameters for the next radio timeslot. */
|
||||
} request; /**< Additional parameters for return_code @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END. */
|
||||
struct
|
||||
{
|
||||
uint32_t length_us; /**< Requested extension of the radio timeslot duration (microseconds) (for minimum time see @ref NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US). */
|
||||
} extend; /**< Additional parameters for return_code @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND. */
|
||||
} params;
|
||||
} nrf_radio_signal_callback_return_param_t;
|
||||
|
||||
/**@brief The radio timeslot signal callback type.
|
||||
*
|
||||
* @note In case of invalid return parameters, the radio timeslot will automatically end
|
||||
* immediately after returning from the signal callback and the
|
||||
* @ref NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN event will be sent.
|
||||
* @note The returned struct pointer must remain valid after the signal callback
|
||||
* function returns. For instance, this means that it must not point to a stack variable.
|
||||
*
|
||||
* @param[in] signal_type Type of signal, see @ref NRF_RADIO_CALLBACK_SIGNAL_TYPE.
|
||||
*
|
||||
* @return Pointer to structure containing action requested by the application.
|
||||
*/
|
||||
typedef nrf_radio_signal_callback_return_param_t * (*nrf_radio_signal_callback_t) (uint8_t signal_type);
|
||||
|
||||
/**@brief AES ECB parameter typedefs */
|
||||
typedef uint8_t soc_ecb_key_t[SOC_ECB_KEY_LENGTH];
|
||||
typedef uint8_t soc_ecb_cleartext_t[SOC_ECB_CLEARTEXT_LENGTH];
|
||||
typedef uint8_t soc_ecb_ciphertext_t[SOC_ECB_CIPHERTEXT_LENGTH];
|
||||
|
||||
/**@brief AES ECB data structure */
|
||||
typedef struct
|
||||
{
|
||||
soc_ecb_key_t key; /**< Encryption key. */
|
||||
soc_ecb_cleartext_t cleartext; /**< Cleartext data. */
|
||||
soc_ecb_ciphertext_t ciphertext; /**< Ciphertext data. */
|
||||
} nrf_ecb_hal_data_t;
|
||||
|
||||
/**@brief AES ECB block. Used to provide multiple blocks in a single call
|
||||
to @ref sd_ecb_blocks_encrypt.*/
|
||||
typedef struct
|
||||
{
|
||||
soc_ecb_key_t* p_key; /**< Pointer to the Encryption key. */
|
||||
soc_ecb_cleartext_t* p_cleartext; /**< Pointer to the Cleartext data. */
|
||||
soc_ecb_ciphertext_t* p_ciphertext; /**< Pointer to the Ciphertext data. */
|
||||
} nrf_ecb_hal_data_block_t;
|
||||
|
||||
/**@} */
|
||||
|
||||
/**@addtogroup NRF_SOC_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Initialize a mutex.
|
||||
*
|
||||
* @param[in] p_mutex Pointer to the mutex to initialize.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_MUTEX_NEW, uint32_t, sd_mutex_new(nrf_mutex_t * p_mutex));
|
||||
|
||||
/**@brief Attempt to acquire a mutex.
|
||||
*
|
||||
* @param[in] p_mutex Pointer to the mutex to acquire.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The mutex was successfully acquired.
|
||||
* @retval ::NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN The mutex could not be acquired.
|
||||
*/
|
||||
SVCALL(SD_MUTEX_ACQUIRE, uint32_t, sd_mutex_acquire(nrf_mutex_t * p_mutex));
|
||||
|
||||
/**@brief Release a mutex.
|
||||
*
|
||||
* @param[in] p_mutex Pointer to the mutex to release.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_MUTEX_RELEASE, uint32_t, sd_mutex_release(nrf_mutex_t * p_mutex));
|
||||
|
||||
/**@brief Query the capacity of the application random pool.
|
||||
*
|
||||
* @param[out] p_pool_capacity The capacity of the pool.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_RAND_APPLICATION_POOL_CAPACITY_GET, uint32_t, sd_rand_application_pool_capacity_get(uint8_t * p_pool_capacity));
|
||||
|
||||
/**@brief Get number of random bytes available to the application.
|
||||
*
|
||||
* @param[out] p_bytes_available The number of bytes currently available in the pool.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_RAND_APPLICATION_BYTES_AVAILABLE_GET, uint32_t, sd_rand_application_bytes_available_get(uint8_t * p_bytes_available));
|
||||
|
||||
/**@brief Get random bytes from the application pool.
|
||||
*
|
||||
* @param[out] p_buff Pointer to unit8_t buffer for storing the bytes.
|
||||
* @param[in] length Number of bytes to take from pool and place in p_buff.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The requested bytes were written to p_buff.
|
||||
* @retval ::NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES No bytes were written to the buffer, because there were not enough bytes available.
|
||||
*/
|
||||
SVCALL(SD_RAND_APPLICATION_VECTOR_GET, uint32_t, sd_rand_application_vector_get(uint8_t * p_buff, uint8_t length));
|
||||
|
||||
/**@brief Gets the reset reason register.
|
||||
*
|
||||
* @param[out] p_reset_reason Contents of the NRF_POWER->RESETREAS register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_RESET_REASON_GET, uint32_t, sd_power_reset_reason_get(uint32_t * p_reset_reason));
|
||||
|
||||
/**@brief Clears the bits of the reset reason register.
|
||||
*
|
||||
* @param[in] reset_reason_clr_msk Contains the bits to clear from the reset reason register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_RESET_REASON_CLR, uint32_t, sd_power_reset_reason_clr(uint32_t reset_reason_clr_msk));
|
||||
|
||||
/**@brief Sets the power mode when in CPU sleep.
|
||||
*
|
||||
* @param[in] power_mode The power mode to use when in CPU sleep, see @ref NRF_POWER_MODES. @sa sd_app_evt_wait
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The power mode was set.
|
||||
* @retval ::NRF_ERROR_SOC_POWER_MODE_UNKNOWN The power mode was unknown.
|
||||
*/
|
||||
SVCALL(SD_POWER_MODE_SET, uint32_t, sd_power_mode_set(uint8_t power_mode));
|
||||
|
||||
/**@brief Puts the chip in System OFF mode.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN
|
||||
*/
|
||||
SVCALL(SD_POWER_SYSTEM_OFF, uint32_t, sd_power_system_off(void));
|
||||
|
||||
/**@brief Enables or disables the power-fail comparator.
|
||||
*
|
||||
* Enabling this will give a softdevice event (NRF_EVT_POWER_FAILURE_WARNING) when the power failure warning occurs.
|
||||
* The event can be retrieved with sd_evt_get();
|
||||
*
|
||||
* @param[in] pof_enable True if the power-fail comparator should be enabled, false if it should be disabled.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_POF_ENABLE, uint32_t, sd_power_pof_enable(uint8_t pof_enable));
|
||||
|
||||
/**@brief Sets the power-fail threshold value.
|
||||
*
|
||||
* @param[in] threshold The power-fail threshold value to use, see @ref NRF_POWER_THRESHOLDS.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The power failure threshold was set.
|
||||
* @retval ::NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN The power failure threshold is unknown.
|
||||
*/
|
||||
SVCALL(SD_POWER_POF_THRESHOLD_SET, uint32_t, sd_power_pof_threshold_set(uint8_t threshold));
|
||||
|
||||
/**@brief Sets bits in the NRF_POWER->RAMON register.
|
||||
*
|
||||
* @param[in] ramon Contains the bits needed to be set in the NRF_POWER->RAMON register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_RAMON_SET, uint32_t, sd_power_ramon_set(uint32_t ramon));
|
||||
|
||||
/**@brief Clears bits in the NRF_POWER->RAMON register.
|
||||
*
|
||||
* @param ramon Contains the bits needed to be cleared in the NRF_POWER->RAMON register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_RAMON_CLR, uint32_t, sd_power_ramon_clr(uint32_t ramon));
|
||||
|
||||
/**@brief Get contents of NRF_POWER->RAMON register, indicates power status of ram blocks.
|
||||
*
|
||||
* @param[out] p_ramon Content of NRF_POWER->RAMON register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_RAMON_GET, uint32_t, sd_power_ramon_get(uint32_t * p_ramon));
|
||||
|
||||
/**@brief Set bits in the NRF_POWER->GPREGRET register.
|
||||
*
|
||||
* @param[in] gpregret_msk Bits to be set in the GPREGRET register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_GPREGRET_SET, uint32_t, sd_power_gpregret_set(uint32_t gpregret_msk));
|
||||
|
||||
/**@brief Clear bits in the NRF_POWER->GPREGRET register.
|
||||
*
|
||||
* @param[in] gpregret_msk Bits to be clear in the GPREGRET register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_GPREGRET_CLR, uint32_t, sd_power_gpregret_clr(uint32_t gpregret_msk));
|
||||
|
||||
/**@brief Get contents of the NRF_POWER->GPREGRET register.
|
||||
*
|
||||
* @param[out] p_gpregret Contents of the GPREGRET register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_GPREGRET_GET, uint32_t, sd_power_gpregret_get(uint32_t *p_gpregret));
|
||||
|
||||
/**@brief Sets the DCDC mode.
|
||||
*
|
||||
* Enable or disable the DCDC peripheral.
|
||||
*
|
||||
* @param[in] dcdc_mode The mode of the DCDC, see @ref NRF_POWER_DCDC_MODES.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM The DCDC mode is invalid.
|
||||
*/
|
||||
SVCALL(SD_POWER_DCDC_MODE_SET, uint32_t, sd_power_dcdc_mode_set(uint8_t dcdc_mode));
|
||||
|
||||
/**@brief Request the high frequency crystal oscillator.
|
||||
*
|
||||
* Will start the high frequency crystal oscillator, the startup time of the crystal varies
|
||||
* and the ::sd_clock_hfclk_is_running function can be polled to check if it has started.
|
||||
*
|
||||
* @see sd_clock_hfclk_is_running
|
||||
* @see sd_clock_hfclk_release
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_CLOCK_HFCLK_REQUEST, uint32_t, sd_clock_hfclk_request(void));
|
||||
|
||||
/**@brief Releases the high frequency crystal oscillator.
|
||||
*
|
||||
* Will stop the high frequency crystal oscillator, this happens immediately.
|
||||
*
|
||||
* @see sd_clock_hfclk_is_running
|
||||
* @see sd_clock_hfclk_request
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_CLOCK_HFCLK_RELEASE, uint32_t, sd_clock_hfclk_release(void));
|
||||
|
||||
/**@brief Checks if the high frequency crystal oscillator is running.
|
||||
*
|
||||
* @see sd_clock_hfclk_request
|
||||
* @see sd_clock_hfclk_release
|
||||
*
|
||||
* @param[out] p_is_running 1 if the external crystal oscillator is running, 0 if not.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_CLOCK_HFCLK_IS_RUNNING, uint32_t, sd_clock_hfclk_is_running(uint32_t * p_is_running));
|
||||
|
||||
/**@brief Waits for an application event.
|
||||
*
|
||||
* An application event is either an application interrupt or a pended interrupt when the
|
||||
* interrupt is disabled. When the interrupt is enabled it will be taken immediately since
|
||||
* this function will wait in thread mode, then the execution will return in the application's
|
||||
* main thread. When an interrupt is disabled and gets pended it will return to the application's
|
||||
* thread main. The application must ensure that the pended flag is cleared using
|
||||
* ::sd_nvic_ClearPendingIRQ in order to sleep using this function. This is only necessary for
|
||||
* disabled interrupts, as the interrupt handler will clear the pending flag automatically for
|
||||
* enabled interrupts.
|
||||
*
|
||||
* In order to wake up from disabled interrupts, the SEVONPEND flag has to be set in the Cortex-M0
|
||||
* System Control Register (SCR). @sa CMSIS_SCB
|
||||
*
|
||||
* @note If an application interrupt has happened since the last time sd_app_evt_wait was
|
||||
* called this function will return immediately and not go to sleep. This is to avoid race
|
||||
* conditions that can occur when a flag is updated in the interrupt handler and processed
|
||||
* in the main loop.
|
||||
*
|
||||
* @post An application interrupt has happened or a interrupt pending flag is set.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_APP_EVT_WAIT, uint32_t, sd_app_evt_wait(void));
|
||||
|
||||
/**@brief Get PPI channel enable register contents.
|
||||
*
|
||||
* @param[out] p_channel_enable The contents of the PPI CHEN register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_CHANNEL_ENABLE_GET, uint32_t, sd_ppi_channel_enable_get(uint32_t * p_channel_enable));
|
||||
|
||||
/**@brief Set PPI channel enable register.
|
||||
*
|
||||
* @param[in] channel_enable_set_msk Mask containing the bits to set in the PPI CHEN register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_CHANNEL_ENABLE_SET, uint32_t, sd_ppi_channel_enable_set(uint32_t channel_enable_set_msk));
|
||||
|
||||
/**@brief Clear PPI channel enable register.
|
||||
*
|
||||
* @param[in] channel_enable_clr_msk Mask containing the bits to clear in the PPI CHEN register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_CHANNEL_ENABLE_CLR, uint32_t, sd_ppi_channel_enable_clr(uint32_t channel_enable_clr_msk));
|
||||
|
||||
/**@brief Assign endpoints to a PPI channel.
|
||||
*
|
||||
* @param[in] channel_num Number of the PPI channel to assign.
|
||||
* @param[in] evt_endpoint Event endpoint of the PPI channel.
|
||||
* @param[in] task_endpoint Task endpoint of the PPI channel.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_PPI_INVALID_CHANNEL The channel number is invalid.
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_CHANNEL_ASSIGN, uint32_t, sd_ppi_channel_assign(uint8_t channel_num, const volatile void * evt_endpoint, const volatile void * task_endpoint));
|
||||
|
||||
/**@brief Task to enable a channel group.
|
||||
*
|
||||
* @param[in] group_num Number of the channel group.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_GROUP_TASK_ENABLE, uint32_t, sd_ppi_group_task_enable(uint8_t group_num));
|
||||
|
||||
/**@brief Task to disable a channel group.
|
||||
*
|
||||
* @param[in] group_num Number of the PPI group.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid.
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_GROUP_TASK_DISABLE, uint32_t, sd_ppi_group_task_disable(uint8_t group_num));
|
||||
|
||||
/**@brief Assign PPI channels to a channel group.
|
||||
*
|
||||
* @param[in] group_num Number of the channel group.
|
||||
* @param[in] channel_msk Mask of the channels to assign to the group.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid.
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_GROUP_ASSIGN, uint32_t, sd_ppi_group_assign(uint8_t group_num, uint32_t channel_msk));
|
||||
|
||||
/**@brief Gets the PPI channels of a channel group.
|
||||
*
|
||||
* @param[in] group_num Number of the channel group.
|
||||
* @param[out] p_channel_msk Mask of the channels assigned to the group.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid.
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_GROUP_GET, uint32_t, sd_ppi_group_get(uint8_t group_num, uint32_t * p_channel_msk));
|
||||
|
||||
/**@brief Configures the Radio Notification signal.
|
||||
*
|
||||
* @note
|
||||
* - The notification signal latency depends on the interrupt priority settings of SWI used
|
||||
* for notification signal.
|
||||
* - To ensure that the radio notification signal behaves in a consistent way, always
|
||||
* configure radio notifications when there is no protocol stack or other SoftDevice
|
||||
* activity in progress. It is recommended that the radio notification signal is
|
||||
* configured directly after the SoftDevice has been enabled.
|
||||
* - In the period between the ACTIVE signal and the start of the Radio Event, the SoftDevice
|
||||
* will interrupt the application to do Radio Event preparation.
|
||||
* - Using the Radio Notification feature may limit the bandwidth, as the SoftDevice may have
|
||||
* to shorten the connection events to have time for the Radio Notification signals.
|
||||
*
|
||||
* @param[in] type Type of notification signal, see @ref NRF_RADIO_NOTIFICATION_TYPES.
|
||||
* @ref NRF_RADIO_NOTIFICATION_TYPE_NONE shall be used to turn off radio
|
||||
* notification. Using @ref NRF_RADIO_NOTIFICATION_DISTANCE_NONE is
|
||||
* recommended (but not required) to be used with
|
||||
* @ref NRF_RADIO_NOTIFICATION_TYPE_NONE.
|
||||
*
|
||||
* @param[in] distance Distance between the notification signal and start of radio activity, see @ref NRF_RADIO_NOTIFICATION_DISTANCES.
|
||||
* This parameter is ignored when @ref NRF_RADIO_NOTIFICATION_TYPE_NONE or
|
||||
* @ref NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE is used.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM The group number is invalid.
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_RADIO_NOTIFICATION_CFG_SET, uint32_t, sd_radio_notification_cfg_set(uint8_t type, uint8_t distance));
|
||||
|
||||
/**@brief Encrypts a block according to the specified parameters.
|
||||
*
|
||||
* 128-bit AES encryption.
|
||||
*
|
||||
* @note:
|
||||
* - The application may set the SEVONPEND bit in the SCR to 1 to make the SoftDevice sleep while
|
||||
* the ECB is running. The SEVONPEND bit should only be cleared (set to 0) from application
|
||||
* main or low interrupt level.
|
||||
*
|
||||
* @param[in, out] p_ecb_data Pointer to the ECB parameters' struct (two input
|
||||
* parameters and one output parameter).
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_ECB_BLOCK_ENCRYPT, uint32_t, sd_ecb_block_encrypt(nrf_ecb_hal_data_t * p_ecb_data));
|
||||
|
||||
/**@brief Encrypts multiple data blocks provided as an array of data block structures.
|
||||
*
|
||||
* @details: Performs 128-bit AES encryption on multiple data blocks
|
||||
*
|
||||
* @note:
|
||||
* - The application may set the SEVONPEND bit in the SCR to 1 to make the SoftDevice sleep while
|
||||
* the ECB is running. The SEVONPEND bit should only be cleared (set to 0) from application
|
||||
* main or low interrupt level.
|
||||
*
|
||||
* @param[in] block_count Count of blocks in the p_data_blocks array.
|
||||
* @param[in,out] p_data_blocks Pointer to the first entry in a contiguous array of
|
||||
* @ref nrf_ecb_hal_data_block_t structures.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_ECB_BLOCKS_ENCRYPT, uint32_t, sd_ecb_blocks_encrypt(uint8_t block_count, nrf_ecb_hal_data_block_t * p_data_blocks));
|
||||
|
||||
/**@brief Gets any pending events generated by the SoC API.
|
||||
*
|
||||
* The application should keep calling this function to get events, until ::NRF_ERROR_NOT_FOUND is returned.
|
||||
*
|
||||
* @param[out] p_evt_id Set to one of the values in @ref NRF_SOC_EVTS, if any events are pending.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS An event was pending. The event id is written in the p_evt_id parameter.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND No pending events.
|
||||
*/
|
||||
SVCALL(SD_EVT_GET, uint32_t, sd_evt_get(uint32_t * p_evt_id));
|
||||
|
||||
/**@brief Get the temperature measured on the chip
|
||||
*
|
||||
* This function will block until the temperature measurement is done.
|
||||
* It takes around 50us from call to return.
|
||||
*
|
||||
* @param[out] p_temp Result of temperature measurement. Die temperature in 0.25 degrees celsius.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS A temperature measurement was done, and the temperature was written to temp
|
||||
*/
|
||||
SVCALL(SD_TEMP_GET, uint32_t, sd_temp_get(int32_t * p_temp));
|
||||
|
||||
/**@brief Flash Write
|
||||
*
|
||||
* Commands to write a buffer to flash
|
||||
*
|
||||
* If the SoftDevice is enabled:
|
||||
* This call initiates the flash access command, and its completion will be communicated to the
|
||||
* application with exactly one of the following events:
|
||||
* - @ref NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed.
|
||||
* - @ref NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started.
|
||||
*
|
||||
* If the SoftDevice is not enabled no event will be generated, and this call will return @ref NRF_SUCCESS when the
|
||||
* write has been completed
|
||||
*
|
||||
* @note
|
||||
* - This call takes control over the radio and the CPU during flash erase and write to make sure that
|
||||
* they will not interfere with the flash access. This means that all interrupts will be blocked
|
||||
* for a predictable time (depending on the NVMC specification in nRF51 Series Reference Manual
|
||||
* and the command parameters).
|
||||
*
|
||||
*
|
||||
* @param[in] p_dst Pointer to start of flash location to be written.
|
||||
* @param[in] p_src Pointer to buffer with data to be written.
|
||||
* @param[in] size Number of 32-bit words to write. Maximum size is 256 32-bit words for nRF51 and 1024 for nRF52.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Tried to write to a non existing flash address, or p_dst or p_src was unaligned.
|
||||
* @retval ::NRF_ERROR_BUSY The previous command has not yet completed.
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH Size was 0, or higher than the maximum allowed size.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Tried to write to or read from protected location.
|
||||
* @retval ::NRF_SUCCESS The command was accepted.
|
||||
*/
|
||||
SVCALL(SD_FLASH_WRITE, uint32_t, sd_flash_write(uint32_t * const p_dst, uint32_t const * const p_src, uint32_t size));
|
||||
|
||||
|
||||
/**@brief Flash Erase page
|
||||
*
|
||||
* Commands to erase a flash page
|
||||
* If the SoftDevice is enabled:
|
||||
* This call initiates the flash access command, and its completion will be communicated to the
|
||||
* application with exactly one of the following events:
|
||||
* - @ref NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed.
|
||||
* - @ref NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started.
|
||||
*
|
||||
* If the SoftDevice is not enabled no event will be generated, and this call will return @ref NRF_SUCCESS when the
|
||||
* erase has been completed
|
||||
*
|
||||
* @note
|
||||
* - This call takes control over the radio and the CPU during flash erase and write to make sure that
|
||||
* they will not interfere with the flash access. This means that all interrupts will be blocked
|
||||
* for a predictable time (depending on the NVMC specification in nRF51 Series Reference Manual
|
||||
* and the command parameters).
|
||||
*
|
||||
*
|
||||
* @param[in] page_number Pagenumber of the page to erase
|
||||
* @retval ::NRF_ERROR_INTERNAL If a new session could not be opened due to an internal error.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Tried to erase to a non existing flash page.
|
||||
* @retval ::NRF_ERROR_BUSY The previous command has not yet completed.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Tried to erase a protected page.
|
||||
* @retval ::NRF_SUCCESS The command was accepted.
|
||||
*/
|
||||
SVCALL(SD_FLASH_PAGE_ERASE, uint32_t, sd_flash_page_erase(uint32_t page_number));
|
||||
|
||||
|
||||
/**@brief Flash Protection set
|
||||
*
|
||||
* Commands to set the flash protection configuration registers.
|
||||
On nRF51 this sets the PROTENSETx registers of the MPU peripheral.
|
||||
On nRF52 this sets the CONFIGx registers of the BPROT peripheral.
|
||||
*
|
||||
* @note To read the values read them directly. They are only write-protected.
|
||||
*
|
||||
* @param[in] block_cfg0 Value to be written to the configuration register.
|
||||
* @param[in] block_cfg1 Value to be written to the configuration register.
|
||||
* @param[in] block_cfg2 Value to be written to the configuration register (ignored on nRF51).
|
||||
* @param[in] block_cfg3 Value to be written to the configuration register (ignored on nRF51).
|
||||
*
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Tried to protect the SoftDevice.
|
||||
* @retval ::NRF_SUCCESS Values successfully written to configuration registers.
|
||||
*/
|
||||
SVCALL(SD_FLASH_PROTECT, uint32_t, sd_flash_protect(uint32_t block_cfg0, uint32_t block_cfg1, uint32_t block_cfg2, uint32_t block_cfg3));
|
||||
|
||||
/**@brief Opens a session for radio timeslot requests.
|
||||
*
|
||||
* @note Only one session can be open at a time.
|
||||
* @note p_radio_signal_callback(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) will be called when the radio timeslot
|
||||
* starts. From this point the NRF_RADIO and NRF_TIMER0 peripherals can be freely accessed
|
||||
* by the application.
|
||||
* @note p_radio_signal_callback(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0) is called whenever the NRF_TIMER0
|
||||
* interrupt occurs.
|
||||
* @note p_radio_signal_callback(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO) is called whenever the NRF_RADIO
|
||||
* interrupt occurs.
|
||||
* @note p_radio_signal_callback() will be called at ARM interrupt priority level 0. This
|
||||
* implies that none of the sd_* API calls can be used from p_radio_signal_callback().
|
||||
*
|
||||
* @param[in] p_radio_signal_callback The signal callback.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR p_radio_signal_callback is an invalid function pointer.
|
||||
* @retval ::NRF_ERROR_BUSY If session cannot be opened.
|
||||
* @retval ::NRF_ERROR_INTERNAL If a new session could not be opened due to an internal error.
|
||||
* @retval ::NRF_SUCCESS Otherwise.
|
||||
*/
|
||||
SVCALL(SD_RADIO_SESSION_OPEN, uint32_t, sd_radio_session_open(nrf_radio_signal_callback_t p_radio_signal_callback));
|
||||
|
||||
/**@brief Closes a session for radio timeslot requests.
|
||||
*
|
||||
* @note Any current radio timeslot will be finished before the session is closed.
|
||||
* @note If a radio timeslot is scheduled when the session is closed, it will be canceled.
|
||||
* @note The application cannot consider the session closed until the @ref NRF_EVT_RADIO_SESSION_CLOSED
|
||||
* event is received.
|
||||
*
|
||||
* @retval ::NRF_ERROR_FORBIDDEN If session not opened.
|
||||
* @retval ::NRF_ERROR_BUSY If session is currently being closed.
|
||||
* @retval ::NRF_SUCCESS Otherwise.
|
||||
*/
|
||||
SVCALL(SD_RADIO_SESSION_CLOSE, uint32_t, sd_radio_session_close(void));
|
||||
|
||||
/**@brief Requests a radio timeslot.
|
||||
*
|
||||
* @note The request type is determined by p_request->request_type, and can be one of @ref NRF_RADIO_REQ_TYPE_EARLIEST
|
||||
* and @ref NRF_RADIO_REQ_TYPE_NORMAL. The first request in a session must always be of type @ref NRF_RADIO_REQ_TYPE_EARLIEST.
|
||||
* @note For a normal request (@ref NRF_RADIO_REQ_TYPE_NORMAL), the start time of a radio timeslot is specified by
|
||||
* p_request->distance_us and is given relative to the start of the previous timeslot.
|
||||
* @note A too small p_request->distance_us will lead to a @ref NRF_EVT_RADIO_BLOCKED event.
|
||||
* @note Timeslots scheduled too close will lead to a @ref NRF_EVT_RADIO_BLOCKED event.
|
||||
* @note See the SoftDevice Specification for more on radio timeslot scheduling, distances and lengths.
|
||||
* @note If an opportunity for the first radio timeslot is not found before 100ms after the call to this
|
||||
* function, it is not scheduled, and instead a @ref NRF_EVT_RADIO_BLOCKED event is sent.
|
||||
* The application may then try to schedule the first radio timeslot again.
|
||||
* @note Successful requests will result in nrf_radio_signal_callback_t(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START).
|
||||
* Unsuccessful requests will result in a @ref NRF_EVT_RADIO_BLOCKED event, see @ref NRF_SOC_EVTS.
|
||||
* @note The jitter in the start time of the radio timeslots is +/- @ref NRF_RADIO_START_JITTER_US us.
|
||||
* @note The nrf_radio_signal_callback_t(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) call has a latency relative to the
|
||||
* specified radio timeslot start, but this does not affect the actual start time of the timeslot.
|
||||
* @note NRF_TIMER0 is reset at the start of the radio timeslot, and is clocked at 1MHz from the high frequency
|
||||
* (16 MHz) clock source. If p_request->hfclk_force_xtal is true, the high frequency clock is
|
||||
* guaranteed to be clocked from the external crystal.
|
||||
* @note The SoftDevice will neither access the NRF_RADIO peripheral nor the NRF_TIMER0 peripheral
|
||||
* during the radio timeslot.
|
||||
*
|
||||
* @param[in] p_request Pointer to the request parameters.
|
||||
*
|
||||
* @retval ::NRF_ERROR_FORBIDDEN If session not opened or the session is not IDLE.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR If the p_request pointer is invalid.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM If the parameters of p_request are not valid.
|
||||
* @retval ::NRF_SUCCESS Otherwise.
|
||||
*/
|
||||
SVCALL(SD_RADIO_REQUEST, uint32_t, sd_radio_request(nrf_radio_request_t * p_request ));
|
||||
|
||||
/**@} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_SOC_H__
|
||||
|
||||
/**@} */
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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 NRF_SVC__
|
||||
#define NRF_SVC__
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef SVCALL_AS_NORMAL_FUNCTION
|
||||
#define SVCALL(number, return_type, signature) return_type signature
|
||||
#else
|
||||
|
||||
#ifndef SVCALL
|
||||
#if defined (__CC_ARM)
|
||||
#define SVCALL(number, return_type, signature) return_type __svc(number) signature
|
||||
#elif defined (__GNUC__)
|
||||
#ifdef __cplusplus
|
||||
#define GCC_CAST_CPP (uint16_t)
|
||||
#else
|
||||
#define GCC_CAST_CPP
|
||||
#endif
|
||||
#define SVCALL(number, return_type, signature) \
|
||||
_Pragma("GCC diagnostic push") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \
|
||||
__attribute__((naked)) \
|
||||
__attribute__((unused)) \
|
||||
static return_type signature \
|
||||
{ \
|
||||
__asm( \
|
||||
"svc %0\n" \
|
||||
"bx r14" : : "I" (GCC_CAST_CPP number) : "r0" \
|
||||
); \
|
||||
} \
|
||||
_Pragma("GCC diagnostic pop")
|
||||
|
||||
#elif defined (__ICCARM__)
|
||||
#define PRAGMA(x) _Pragma(#x)
|
||||
#define SVCALL(number, return_type, signature) \
|
||||
PRAGMA(swi_number = (number)) \
|
||||
__swi return_type signature;
|
||||
#else
|
||||
#define SVCALL(number, return_type, signature) return_type signature
|
||||
#endif
|
||||
#endif // SVCALL
|
||||
|
||||
#endif // SVCALL_AS_NORMAL_FUNCTION
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_SVC__
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,19 +0,0 @@
|
|||
#ifndef _SDK_CONFIG_H_
|
||||
#define _SDK_CONFIG_H_
|
||||
|
||||
#include "nrf_drv_config.h"
|
||||
|
||||
#define UART_DEFAULT_CONFIG_BAUDRATE UART0_CONFIG_BAUDRATE
|
||||
#define UART_DEFAULT_CONFIG_PARITY UART0_CONFIG_PARITY
|
||||
#define UART_DEFAULT_CONFIG_HWFC UART0_CONFIG_HWFC
|
||||
|
||||
#define SPIS_DEFAULT_ORC NRF_DRV_SPIS_DEFAULT_ORC
|
||||
#define SPIS_DEFAULT_CONFIG_IRQ_PRIORITY SPIS1_CONFIG_IRQ_PRIORITY;
|
||||
#define SPIS_DEFAULT_ORC NRF_DRV_SPIS_DEFAULT_ORC
|
||||
#define SPIS_DEFAULT_DEF NRF_DRV_SPIS_DEFAULT_DEF
|
||||
|
||||
#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY SPI1_CONFIG_IRQ_PRIORITY
|
||||
|
||||
#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY PWM0_CONFIG_IRQ_PRIORITY
|
||||
|
||||
#endif
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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 MBED_PERIPHERALNAMES_H
|
||||
#define MBED_PERIPHERALNAMES_H
|
||||
|
||||
#include "cmsis.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef STDIO_UART_TX
|
||||
#define STDIO_UART_TX TX_PIN_NUMBER
|
||||
#endif
|
||||
|
||||
#ifndef STDIO_UART_RX
|
||||
#define STDIO_UART_RX RX_PIN_NUMBER
|
||||
#endif
|
||||
|
||||
#define STDIO_UART UART_0
|
||||
|
||||
typedef enum
|
||||
{
|
||||
UART_0 = (int)NRF_UART0_BASE
|
||||
} UARTName;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SPI_0 = (int)NRF_SPI0_BASE,
|
||||
SPI_1 = (int)NRF_SPI1_BASE,
|
||||
SPIS = (int)NRF_SPIS1_BASE
|
||||
} SPIName;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PWM_1 = 0,
|
||||
PWM_2
|
||||
} PWMName;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
I2C_0 = (int)NRF_TWI0_BASE,
|
||||
I2C_1 = (int)NRF_TWI1_BASE
|
||||
} I2CName;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ADC0_0 = (int)0
|
||||
} ADCName;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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 MBED_PORTNAMES_H
|
||||
#define MBED_PORTNAMES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Port0 = 0, //GPIO pins 0-31 -> 0.0-0.31
|
||||
Port1 = 1 //GPIO pins 32-47 -> 1.0-1.15
|
||||
} PortName;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1,241 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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 MBED_PINNAMES_H
|
||||
#define MBED_PINNAMES_H
|
||||
|
||||
#include "cmsis.h"
|
||||
#include "nrf_gpio.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PIN_INPUT,
|
||||
PIN_OUTPUT
|
||||
} PinDirection;
|
||||
|
||||
#define PORT_SHIFT 3
|
||||
|
||||
///> define macro producing for example Px_y = NRF_GPIO_PIN_MAP(x, y)
|
||||
#define PinDef(port_num, pin_num) P##port_num##_##pin_num = NRF_GPIO_PIN_MAP(port_num, pin_num)
|
||||
|
||||
|
||||
typedef enum {
|
||||
PinDef(0 , 0), // P0_0 = 0...
|
||||
PinDef(0 , 1),
|
||||
PinDef(0 , 2),
|
||||
PinDef(0 , 3),
|
||||
PinDef(0 , 4),
|
||||
PinDef(0 , 5),
|
||||
PinDef(0 , 6),
|
||||
PinDef(0 , 7),
|
||||
PinDef(0 , 8),
|
||||
PinDef(0 , 9),
|
||||
PinDef(0 , 10),
|
||||
PinDef(0 , 11),
|
||||
PinDef(0 , 12),
|
||||
PinDef(0 , 13),
|
||||
PinDef(0 , 14),
|
||||
PinDef(0 , 15),
|
||||
PinDef(0 , 16),
|
||||
PinDef(0 , 17),
|
||||
PinDef(0 , 18),
|
||||
PinDef(0 , 19),
|
||||
PinDef(0 , 20),
|
||||
PinDef(0 , 21),
|
||||
PinDef(0 , 22),
|
||||
PinDef(0 , 23),
|
||||
PinDef(0 , 24),
|
||||
PinDef(0 , 25),
|
||||
PinDef(0 , 26),
|
||||
PinDef(0 , 27),
|
||||
PinDef(0 , 28),
|
||||
PinDef(0 , 29),
|
||||
PinDef(0 , 30),
|
||||
PinDef(0 , 31),
|
||||
|
||||
PinDef(1 , 0), //P1_1 = 32...
|
||||
PinDef(1 , 1),
|
||||
PinDef(1 , 2),
|
||||
PinDef(1 , 3),
|
||||
PinDef(1 , 4),
|
||||
PinDef(1 , 5),
|
||||
PinDef(1 , 6),
|
||||
PinDef(1 , 7),
|
||||
PinDef(1 , 8),
|
||||
PinDef(1 , 9),
|
||||
PinDef(1 , 10),
|
||||
PinDef(1 , 11),
|
||||
PinDef(1 , 12),
|
||||
PinDef(1 , 13),
|
||||
PinDef(1 , 14),
|
||||
PinDef(1 , 15),
|
||||
|
||||
// Port0
|
||||
p0 = P0_0,
|
||||
p1 = P0_1,
|
||||
p2 = P0_2,
|
||||
p3 = P0_3,
|
||||
p4 = P0_4,
|
||||
p5 = P0_5,
|
||||
p6 = P0_6,
|
||||
p7 = P0_7,
|
||||
p8 = P0_8,
|
||||
p9 = P0_9,
|
||||
p10 = P0_10,
|
||||
p11 = P0_11,
|
||||
p12 = P0_12,
|
||||
p13 = P0_13,
|
||||
p14 = P0_14,
|
||||
p15 = P0_15,
|
||||
p16 = P0_16,
|
||||
p17 = P0_17,
|
||||
p18 = P0_18,
|
||||
p19 = P0_19,
|
||||
p20 = P0_20,
|
||||
p21 = P0_21,
|
||||
p22 = P0_22,
|
||||
p23 = P0_23,
|
||||
p24 = P0_24,
|
||||
p25 = P0_25,
|
||||
p26 = P0_26,
|
||||
p27 = P0_27,
|
||||
p28 = P0_28,
|
||||
p29 = P0_29,
|
||||
p30 = P0_30,
|
||||
p31 = P0_31,
|
||||
|
||||
// Port1
|
||||
p32 = P1_0,
|
||||
p33 = P1_1,
|
||||
p34 = P1_2,
|
||||
p35 = P1_3,
|
||||
p36 = P1_4,
|
||||
p37 = P1_5,
|
||||
p38 = P1_6,
|
||||
p39 = P1_7,
|
||||
p40 = P1_8,
|
||||
p41 = P1_9,
|
||||
p42 = P1_10,
|
||||
p43 = P1_11,
|
||||
p44 = P1_12,
|
||||
p45 = P1_13,
|
||||
p46 = P1_14,
|
||||
p47 = P1_15,
|
||||
|
||||
LED1 = p13,
|
||||
LED2 = p14,
|
||||
LED3 = p15,
|
||||
LED4 = p16,
|
||||
|
||||
BUTTON1 = p11,
|
||||
BUTTON2 = p12,
|
||||
BUTTON3 = p24,
|
||||
BUTTON4 = p25,
|
||||
|
||||
RX_PIN_NUMBER = p8,
|
||||
TX_PIN_NUMBER = p6,
|
||||
CTS_PIN_NUMBER = p7,
|
||||
RTS_PIN_NUMBER = p5,
|
||||
|
||||
// mBed interface Pins
|
||||
USBTX = TX_PIN_NUMBER,
|
||||
USBRX = RX_PIN_NUMBER,
|
||||
|
||||
SPI_PSELMOSI0 = P1_13,
|
||||
SPI_PSELMISO0 = P1_14,
|
||||
SPI_PSELSS0 = P1_12,
|
||||
SPI_PSELSCK0 = P1_15,
|
||||
|
||||
SPI_PSELMOSI1 = P1_2,
|
||||
SPI_PSELMISO1 = P1_3,
|
||||
SPI_PSELSS1 = P1_1,
|
||||
SPI_PSELSCK1 = P1_4,
|
||||
|
||||
SPIS_PSELMOSI = P1_2,
|
||||
SPIS_PSELMISO = P1_3,
|
||||
SPIS_PSELSS = P1_1,
|
||||
SPIS_PSELSCK = P1_4,
|
||||
|
||||
I2C_SDA0 = p26,
|
||||
I2C_SCL0 = p27,
|
||||
|
||||
D0 = P1_1,
|
||||
D1 = P1_2,
|
||||
D2 = P1_3,
|
||||
D3 = P1_4,
|
||||
D4 = P1_5,
|
||||
D5 = P1_6,
|
||||
D6 = P1_7,
|
||||
D7 = P1_8,
|
||||
|
||||
D8 = P1_10,
|
||||
D9 = P1_11,
|
||||
D10 = P1_12,
|
||||
D11 = P1_13,
|
||||
D12 = P1_14,
|
||||
D13 = P1_15,
|
||||
|
||||
D14 = p26,
|
||||
D15 = p27,
|
||||
|
||||
A0 = p3,
|
||||
A1 = p4,
|
||||
A2 = p28,
|
||||
A3 = p29,
|
||||
A4 = p30,
|
||||
A5 = p31,
|
||||
|
||||
// Not connected
|
||||
NC = (int)0xFFFFFFFF
|
||||
} PinName;
|
||||
|
||||
typedef enum {
|
||||
PullNone = 0,
|
||||
PullDown = 1,
|
||||
PullUp = 3,
|
||||
PullDefault = PullUp
|
||||
} PinMode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
// The 'features' section in 'target.json' is now used to create the device's hardware preprocessor switches.
|
||||
// Check the 'features' section of the target description in 'targets.json' for more details.
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_DEVICE_H
|
||||
#define MBED_DEVICE_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "objects.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
#! armcc -E
|
||||
|
||||
#if !defined(MBED_APP_START)
|
||||
#define MBED_APP_START 0x21000
|
||||
#endif
|
||||
|
||||
#if !defined(MBED_APP_SIZE)
|
||||
#define MBED_APP_SIZE 0xDF000
|
||||
#endif
|
||||
|
||||
LR_IROM1 MBED_APP_START MBED_APP_SIZE {
|
||||
ER_IROM1 MBED_APP_START MBED_APP_SIZE {
|
||||
*.o (RESET, +First)
|
||||
*(InRoot$$Sections)
|
||||
.ANY (+RO)
|
||||
}
|
||||
RW_IRAM0 0x20003288 UNINIT 0x000000F8 { ;no init section
|
||||
*(*noinit)
|
||||
}
|
||||
RW_IRAM1 0x20003380 0x0003cc80 {
|
||||
.ANY (+RW +ZI)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,269 +0,0 @@
|
|||
;/* Copyright (c) 2012 ARM LIMITED
|
||||
;
|
||||
; All rights reserved.
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions are met:
|
||||
; - Redistributions of source code must retain the above copyright
|
||||
; notice, this list of conditions and the following disclaimer.
|
||||
; - 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.
|
||||
; - Neither the name of ARM 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 AND CONTRIBUTORS "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 COPYRIGHT HOLDERS AND CONTRIBUTORS 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.
|
||||
; ---------------------------------------------------------------------------*/
|
||||
|
||||
__initial_sp EQU 0x20040000
|
||||
|
||||
PRESERVE8
|
||||
THUMB
|
||||
|
||||
; Vector Table Mapped to Address 0 at Reset
|
||||
|
||||
AREA RESET, DATA, READONLY
|
||||
EXPORT __Vectors
|
||||
EXPORT __Vectors_End
|
||||
EXPORT __Vectors_Size
|
||||
|
||||
__Vectors DCD __initial_sp ; Top of Stack
|
||||
DCD Reset_Handler
|
||||
DCD NMI_Handler
|
||||
DCD HardFault_Handler
|
||||
DCD MemoryManagement_Handler
|
||||
DCD BusFault_Handler
|
||||
DCD UsageFault_Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler
|
||||
DCD DebugMonitor_Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler
|
||||
DCD SysTick_Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD POWER_CLOCK_IRQHandler
|
||||
DCD RADIO_IRQHandler
|
||||
DCD UARTE0_UART0_IRQHandler_v
|
||||
DCD SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler_v
|
||||
DCD SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler_v
|
||||
DCD NFCT_IRQHandler_v
|
||||
DCD GPIOTE_IRQHandler_v
|
||||
DCD SAADC_IRQHandler_v
|
||||
DCD TIMER0_IRQHandler_v
|
||||
DCD TIMER1_IRQHandler_v
|
||||
DCD TIMER2_IRQHandler_v
|
||||
DCD RTC0_IRQHandler
|
||||
DCD TEMP_IRQHandler_v
|
||||
DCD RNG_IRQHandler
|
||||
DCD ECB_IRQHandler
|
||||
DCD CCM_AAR_IRQHandler
|
||||
DCD WDT_IRQHandler_v
|
||||
DCD RTC1_IRQHandler_v
|
||||
DCD QDEC_IRQHandler_v
|
||||
DCD COMP_LPCOMP_IRQHandler_v
|
||||
DCD SWI0_EGU0_IRQHandler_v
|
||||
DCD SWI1_EGU1_IRQHandler_v
|
||||
DCD SWI2_EGU2_IRQHandler_v
|
||||
DCD SWI3_EGU3_IRQHandler_v
|
||||
DCD SWI4_EGU4_IRQHandler
|
||||
DCD SWI5_EGU5_IRQHandler
|
||||
DCD TIMER3_IRQHandler_v
|
||||
DCD TIMER4_IRQHandler_v
|
||||
DCD PWM0_IRQHandler_v
|
||||
DCD PDM_IRQHandler_v
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD MWU_IRQHandler
|
||||
DCD PWM1_IRQHandler_v
|
||||
DCD PWM2_IRQHandler_v
|
||||
DCD SPIM2_SPIS2_SPI2_IRQHandler_v
|
||||
DCD RTC2_IRQHandler_v
|
||||
DCD I2S_IRQHandler_v
|
||||
DCD FPU_IRQHandler_v
|
||||
DCD USBD_IRQHandler_v
|
||||
DCD UARTE1_IRQHandler_v
|
||||
DCD QSPI_IRQHandler_v
|
||||
DCD CRYPTOCELL_IRQHandler_v
|
||||
DCD SPIM3_IRQHandler_v
|
||||
DCD 0 ; Reserved
|
||||
DCD PWM3_IRQHandler_v
|
||||
|
||||
__Vectors_End
|
||||
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
|
||||
; Reset Handler
|
||||
|
||||
|
||||
Reset_Handler PROC
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
IMPORT SystemInit
|
||||
IMPORT __main
|
||||
IMPORT nrf_reloc_vector_table
|
||||
|
||||
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =nrf_reloc_vector_table
|
||||
BLX R0
|
||||
LDR R0, =__main
|
||||
BX R0
|
||||
ENDP
|
||||
|
||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
||||
|
||||
NMI_Handler PROC
|
||||
EXPORT NMI_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
HardFault_Handler\
|
||||
PROC
|
||||
EXPORT HardFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
MemoryManagement_Handler\
|
||||
PROC
|
||||
EXPORT MemoryManagement_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
BusFault_Handler\
|
||||
PROC
|
||||
EXPORT BusFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
UsageFault_Handler\
|
||||
PROC
|
||||
EXPORT UsageFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SVC_Handler PROC
|
||||
EXPORT SVC_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
DebugMonitor_Handler\
|
||||
PROC
|
||||
EXPORT DebugMonitor_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
PendSV_Handler PROC
|
||||
EXPORT PendSV_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SysTick_Handler PROC
|
||||
EXPORT SysTick_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
|
||||
Default_Handler PROC
|
||||
|
||||
EXPORT POWER_CLOCK_IRQHandler [WEAK]
|
||||
EXPORT RADIO_IRQHandler [WEAK]
|
||||
EXPORT UARTE0_UART0_IRQHandler_v [WEAK]
|
||||
EXPORT SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler_v [WEAK]
|
||||
EXPORT SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler_v [WEAK]
|
||||
EXPORT NFCT_IRQHandler_v [WEAK]
|
||||
EXPORT GPIOTE_IRQHandler_v [WEAK]
|
||||
EXPORT SAADC_IRQHandler_v [WEAK]
|
||||
EXPORT TIMER0_IRQHandler_v [WEAK]
|
||||
EXPORT TIMER1_IRQHandler_v [WEAK]
|
||||
EXPORT TIMER2_IRQHandler_v [WEAK]
|
||||
EXPORT RTC0_IRQHandler [WEAK]
|
||||
EXPORT TEMP_IRQHandler_v [WEAK]
|
||||
EXPORT RNG_IRQHandler [WEAK]
|
||||
EXPORT ECB_IRQHandler [WEAK]
|
||||
EXPORT CCM_AAR_IRQHandler [WEAK]
|
||||
EXPORT WDT_IRQHandler_v [WEAK]
|
||||
EXPORT RTC1_IRQHandler_v [WEAK]
|
||||
EXPORT QDEC_IRQHandler_v [WEAK]
|
||||
EXPORT COMP_LPCOMP_IRQHandler_v [WEAK]
|
||||
EXPORT SWI0_EGU0_IRQHandler_v [WEAK]
|
||||
EXPORT SWI1_EGU1_IRQHandler_v [WEAK]
|
||||
EXPORT SWI2_EGU2_IRQHandler_v [WEAK]
|
||||
EXPORT SWI3_EGU3_IRQHandler_v [WEAK]
|
||||
EXPORT SWI4_EGU4_IRQHandler [WEAK]
|
||||
EXPORT SWI5_EGU5_IRQHandler [WEAK]
|
||||
EXPORT TIMER3_IRQHandler_v [WEAK]
|
||||
EXPORT TIMER4_IRQHandler_v [WEAK]
|
||||
EXPORT PWM0_IRQHandler_v [WEAK]
|
||||
EXPORT PDM_IRQHandler_v [WEAK]
|
||||
EXPORT MWU_IRQHandler [WEAK]
|
||||
EXPORT PWM1_IRQHandler_v [WEAK]
|
||||
EXPORT PWM2_IRQHandler_v [WEAK]
|
||||
EXPORT SPIM2_SPIS2_SPI2_IRQHandler_v [WEAK]
|
||||
EXPORT RTC2_IRQHandler_v [WEAK]
|
||||
EXPORT I2S_IRQHandler_v [WEAK]
|
||||
EXPORT FPU_IRQHandler_v [WEAK]
|
||||
EXPORT USBD_IRQHandler_v [WEAK]
|
||||
EXPORT UARTE1_IRQHandler_v [WEAK]
|
||||
EXPORT QSPI_IRQHandler_v [WEAK]
|
||||
EXPORT CRYPTOCELL_IRQHandler_v [WEAK]
|
||||
EXPORT SPIM3_IRQHandler_v [WEAK]
|
||||
EXPORT PWM3_IRQHandler_v [WEAK]
|
||||
|
||||
|
||||
|
||||
|
||||
POWER_CLOCK_IRQHandler
|
||||
RADIO_IRQHandler
|
||||
UARTE0_UART0_IRQHandler_v
|
||||
SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler_v
|
||||
SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler_v
|
||||
NFCT_IRQHandler_v
|
||||
GPIOTE_IRQHandler_v
|
||||
SAADC_IRQHandler_v
|
||||
TIMER0_IRQHandler_v
|
||||
TIMER1_IRQHandler_v
|
||||
TIMER2_IRQHandler_v
|
||||
RTC0_IRQHandler
|
||||
TEMP_IRQHandler_v
|
||||
RNG_IRQHandler
|
||||
ECB_IRQHandler
|
||||
CCM_AAR_IRQHandler
|
||||
WDT_IRQHandler_v
|
||||
RTC1_IRQHandler_v
|
||||
QDEC_IRQHandler_v
|
||||
COMP_LPCOMP_IRQHandler_v
|
||||
SWI0_EGU0_IRQHandler_v
|
||||
SWI1_EGU1_IRQHandler_v
|
||||
SWI2_EGU2_IRQHandler_v
|
||||
SWI3_EGU3_IRQHandler_v
|
||||
SWI4_EGU4_IRQHandler
|
||||
SWI5_EGU5_IRQHandler
|
||||
TIMER3_IRQHandler_v
|
||||
TIMER4_IRQHandler_v
|
||||
PWM0_IRQHandler_v
|
||||
PDM_IRQHandler_v
|
||||
MWU_IRQHandler
|
||||
PWM1_IRQHandler_v
|
||||
PWM2_IRQHandler_v
|
||||
SPIM2_SPIS2_SPI2_IRQHandler_v
|
||||
RTC2_IRQHandler_v
|
||||
I2S_IRQHandler_v
|
||||
FPU_IRQHandler_v
|
||||
USBD_IRQHandler_v
|
||||
UARTE1_IRQHandler_v
|
||||
QSPI_IRQHandler_v
|
||||
CRYPTOCELL_IRQHandler_v
|
||||
SPIM3_IRQHandler_v
|
||||
PWM3_IRQHandler_v
|
||||
|
||||
B .
|
||||
ENDP
|
||||
ALIGN
|
||||
END
|
||||
|
|
@ -1,198 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* Linker script to configure memory regions. */
|
||||
|
||||
#if !defined(MBED_APP_START)
|
||||
#define MBED_APP_START 0x21000
|
||||
#endif
|
||||
|
||||
#if !defined(MBED_APP_SIZE)
|
||||
#define MBED_APP_SIZE 0xDF000
|
||||
#endif
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE
|
||||
RAM (rwx) : ORIGIN = 0x20003288, LENGTH = 0x3cd78
|
||||
}
|
||||
|
||||
|
||||
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||
|
||||
/* Linker script to place sections and symbol values. Should be used together
|
||||
* with the other linker script that defines memory regions FLASH and RAM.
|
||||
* It references the following symbols that must be defined in code:
|
||||
* Reset_Handler : Entry of reset handler
|
||||
*
|
||||
* It defines the following symbols that the code can use without definition:
|
||||
* __exidx_start
|
||||
* __exidx_end
|
||||
* __etext
|
||||
* __data_start__
|
||||
* __preinit_array_start
|
||||
* __preinit_array_end
|
||||
* __init_array_start
|
||||
* __init_array_end
|
||||
* __fini_array_start
|
||||
* __fini_array_end
|
||||
* __data_end__
|
||||
* __bss_start__
|
||||
* __bss_end__
|
||||
* __end__
|
||||
* end
|
||||
* __HeapLimit
|
||||
* __StackLimit
|
||||
* __StackTop
|
||||
* __stack
|
||||
*/
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
KEEP(*(.Vectors))
|
||||
*(.text*)
|
||||
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.fini))
|
||||
|
||||
/* .ctors */
|
||||
*crtbegin.o(.ctors)
|
||||
*crtbegin?.o(.ctors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||
*(SORT(.ctors.*))
|
||||
*(.ctors)
|
||||
|
||||
/* .dtors */
|
||||
*crtbegin.o(.dtors)
|
||||
*crtbegin?.o(.dtors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||
*(SORT(.dtors.*))
|
||||
*(.dtors)
|
||||
|
||||
*(.rodata*)
|
||||
|
||||
KEEP(*(.eh_frame*))
|
||||
} > FLASH
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
. = ALIGN(4);
|
||||
} > FLASH
|
||||
|
||||
__exidx_start = .;
|
||||
.ARM.exidx :
|
||||
{
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
. = ALIGN(4);
|
||||
} > FLASH
|
||||
__exidx_end = .;
|
||||
|
||||
__etext = .;
|
||||
|
||||
.data : AT (__etext)
|
||||
{
|
||||
__data_start__ = .;
|
||||
*(vtable)
|
||||
*(.data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
/* preinit data */
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* init data */
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
|
||||
|
||||
. = ALIGN(4);
|
||||
/* finit data */
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
PROVIDE(__start_fs_data = .);
|
||||
KEEP(*(.fs_data))
|
||||
PROVIDE(__stop_fs_data = .);
|
||||
|
||||
*(.jcr)
|
||||
. = ALIGN(4);
|
||||
/* All data end */
|
||||
__data_end__ = .;
|
||||
|
||||
} > RAM
|
||||
|
||||
__edata = .;
|
||||
|
||||
.noinit :
|
||||
{
|
||||
PROVIDE(__start_noinit = .);
|
||||
KEEP(*(.noinit))
|
||||
PROVIDE(__stop_noinit = .);
|
||||
} > RAM
|
||||
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start__ = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
} > RAM
|
||||
|
||||
.heap (NOLOAD):
|
||||
{
|
||||
__end__ = .;
|
||||
end = __end__;
|
||||
*(.heap*);
|
||||
|
||||
/* Expand the heap to reach the stack boundary. */
|
||||
ASSERT(. <= (ORIGIN(RAM) + LENGTH(RAM) - 0x800), "heap region overflowed into stack");
|
||||
. += (ORIGIN(RAM) + LENGTH(RAM) - 0x800) - .;
|
||||
} > RAM
|
||||
PROVIDE(__heap_start = ADDR(.heap));
|
||||
PROVIDE(__heap_size = SIZEOF(.heap));
|
||||
PROVIDE(__mbed_sbrk_start = ADDR(.heap));
|
||||
PROVIDE(__mbed_krbs_start = ADDR(.heap) + SIZEOF(.heap));
|
||||
|
||||
/* .stack_dummy section does not contain any symbols. It is only
|
||||
* used for the linker script to calculate the size of stack sections
|
||||
* and assign values to stack symbols later. */
|
||||
.stack (NOLOAD):
|
||||
{
|
||||
__StackLimit = .;
|
||||
*(.stack*)
|
||||
. += (ORIGIN(RAM) + LENGTH(RAM) - .);
|
||||
} > RAM
|
||||
|
||||
/* Set the stack top to the end of RAM and move down the stack limit by
|
||||
* the size of the stack_dummy section. */
|
||||
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
|
||||
__StackLimit = __StackTop - SIZEOF(.stack);
|
||||
PROVIDE(__stack = __StackTop);
|
||||
}
|
||||
|
|
@ -1,283 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
NOTE: Template files (including this one) are application specific and therefore
|
||||
expected to be copied into the application project folder prior to its use!
|
||||
*/
|
||||
|
||||
.syntax unified
|
||||
.arch armv7e-m
|
||||
|
||||
.section .Vectors
|
||||
.align 2
|
||||
.globl __Vectors
|
||||
__Vectors:
|
||||
.long __StackTop /* Top of Stack */
|
||||
.long Reset_Handler
|
||||
.long NMI_Handler
|
||||
.long HardFault_Handler
|
||||
.long MemoryManagement_Handler
|
||||
.long BusFault_Handler
|
||||
.long UsageFault_Handler
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long SVC_Handler
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long PendSV_Handler
|
||||
.long SysTick_Handler
|
||||
|
||||
/* External Interrupts */
|
||||
.long POWER_CLOCK_IRQHandler
|
||||
.long RADIO_IRQHandler
|
||||
.long UARTE0_UART0_IRQHandler_v
|
||||
.long SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler_v
|
||||
.long SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler_v
|
||||
.long NFCT_IRQHandler_v
|
||||
.long GPIOTE_IRQHandler_v
|
||||
.long SAADC_IRQHandler_v
|
||||
.long TIMER0_IRQHandler_v
|
||||
.long TIMER1_IRQHandler_v
|
||||
.long TIMER2_IRQHandler_v
|
||||
.long RTC0_IRQHandler
|
||||
.long TEMP_IRQHandler_v
|
||||
.long RNG_IRQHandler
|
||||
.long ECB_IRQHandler
|
||||
.long CCM_AAR_IRQHandler
|
||||
.long WDT_IRQHandler_v
|
||||
.long RTC1_IRQHandler_v
|
||||
.long QDEC_IRQHandler_v
|
||||
.long COMP_LPCOMP_IRQHandler_v
|
||||
.long SWI0_EGU0_IRQHandler_v
|
||||
.long SWI1_EGU1_IRQHandler_v
|
||||
.long SWI2_EGU2_IRQHandler_v
|
||||
.long SWI3_EGU3_IRQHandler_v
|
||||
.long SWI4_EGU4_IRQHandler
|
||||
.long SWI5_EGU5_IRQHandler
|
||||
.long TIMER3_IRQHandler_v
|
||||
.long TIMER4_IRQHandler_v
|
||||
.long PWM0_IRQHandler_v
|
||||
.long PDM_IRQHandler_v
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long MWU_IRQHandler
|
||||
.long PWM1_IRQHandler_v
|
||||
.long PWM2_IRQHandler_v
|
||||
.long SPIM2_SPIS2_SPI2_IRQHandler_v
|
||||
.long RTC2_IRQHandler_v
|
||||
.long I2S_IRQHandler_v
|
||||
.long FPU_IRQHandler_v
|
||||
.long USBD_IRQHandler_v
|
||||
.long UARTE1_IRQHandler_v
|
||||
.long QSPI_IRQHandler_v
|
||||
.long CRYPTOCELL_IRQHandler_v
|
||||
.long SPIM3_IRQHandler_v
|
||||
.long 0 /*Reserved */
|
||||
.long PWM3_IRQHandler_v
|
||||
|
||||
|
||||
.size __Vectors, . - __Vectors
|
||||
|
||||
/* Reset Handler */
|
||||
|
||||
.text
|
||||
.thumb
|
||||
.thumb_func
|
||||
.align 1
|
||||
.globl Reset_Handler
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.fnstart
|
||||
|
||||
|
||||
/* Loop to copy data from read only memory to RAM. The ranges
|
||||
* of copy from/to are specified by following symbols evaluated in
|
||||
* linker script.
|
||||
* __etext: End of code section, i.e., begin of data sections to copy from.
|
||||
* __data_start__/__data_end__: RAM address range that data should be
|
||||
* copied to. Both must be aligned to 4 bytes boundary. */
|
||||
|
||||
ldr r1, =__etext
|
||||
ldr r2, =__data_start__
|
||||
ldr r3, =__data_end__
|
||||
|
||||
subs r3, r2
|
||||
ble .LC0
|
||||
|
||||
.LC1:
|
||||
subs r3, 4
|
||||
ldr r0, [r1,r3]
|
||||
str r0, [r2,r3]
|
||||
bgt .LC1
|
||||
.LC0:
|
||||
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =nrf_reloc_vector_table
|
||||
BLX R0
|
||||
LDR R0, =_start
|
||||
BX R0
|
||||
|
||||
.pool
|
||||
.cantunwind
|
||||
.fnend
|
||||
.size Reset_Handler,.-Reset_Handler
|
||||
|
||||
.section ".text"
|
||||
|
||||
|
||||
/* Dummy Exception Handlers (infinite loops which can be modified) */
|
||||
|
||||
.weak NMI_Handler
|
||||
.type NMI_Handler, %function
|
||||
NMI_Handler:
|
||||
B .
|
||||
.size NMI_Handler, . - NMI_Handler
|
||||
|
||||
|
||||
.weak HardFault_Handler
|
||||
.type HardFault_Handler, %function
|
||||
HardFault_Handler:
|
||||
B .
|
||||
.size HardFault_Handler, . - HardFault_Handler
|
||||
|
||||
|
||||
.weak MemoryManagement_Handler
|
||||
.type MemoryManagement_Handler, %function
|
||||
MemoryManagement_Handler:
|
||||
B .
|
||||
.size MemoryManagement_Handler, . - MemoryManagement_Handler
|
||||
|
||||
|
||||
.weak BusFault_Handler
|
||||
.type BusFault_Handler, %function
|
||||
BusFault_Handler:
|
||||
B .
|
||||
.size BusFault_Handler, . - BusFault_Handler
|
||||
|
||||
|
||||
.weak UsageFault_Handler
|
||||
.type UsageFault_Handler, %function
|
||||
UsageFault_Handler:
|
||||
B .
|
||||
.size UsageFault_Handler, . - UsageFault_Handler
|
||||
|
||||
|
||||
.weak SVC_Handler
|
||||
.type SVC_Handler, %function
|
||||
SVC_Handler:
|
||||
B .
|
||||
.size SVC_Handler, . - SVC_Handler
|
||||
|
||||
|
||||
.weak PendSV_Handler
|
||||
.type PendSV_Handler, %function
|
||||
PendSV_Handler:
|
||||
B .
|
||||
.size PendSV_Handler, . - PendSV_Handler
|
||||
|
||||
|
||||
.weak SysTick_Handler
|
||||
.type SysTick_Handler, %function
|
||||
SysTick_Handler:
|
||||
B .
|
||||
.size SysTick_Handler, . - SysTick_Handler
|
||||
|
||||
|
||||
/* IRQ Handlers */
|
||||
|
||||
.globl Default_Handler
|
||||
.type Default_Handler, %function
|
||||
Default_Handler:
|
||||
B .
|
||||
.size Default_Handler, . - Default_Handler
|
||||
|
||||
.macro IRQ handler
|
||||
.weak \handler
|
||||
.set \handler, Default_Handler
|
||||
.endm
|
||||
|
||||
IRQ POWER_CLOCK_IRQHandler /* restricted */
|
||||
IRQ RADIO_IRQHandler /* blocked */
|
||||
IRQ UARTE0_UART0_IRQHandler_v
|
||||
IRQ SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler_v
|
||||
IRQ SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler_v
|
||||
IRQ NFCT_IRQHandler_v
|
||||
IRQ GPIOTE_IRQHandler_v
|
||||
IRQ SAADC_IRQHandler_v
|
||||
IRQ TIMER0_IRQHandler_v
|
||||
IRQ TIMER1_IRQHandler_v
|
||||
IRQ TIMER2_IRQHandler_v
|
||||
IRQ RTC0_IRQHandler /* blocked */
|
||||
IRQ TEMP_IRQHandler_v
|
||||
IRQ RNG_IRQHandler /* restricted */
|
||||
IRQ ECB_IRQHandler /* restricted */
|
||||
IRQ CCM_AAR_IRQHandler /* blocked */
|
||||
IRQ WDT_IRQHandler_v
|
||||
IRQ RTC1_IRQHandler_v
|
||||
IRQ QDEC_IRQHandler_v
|
||||
IRQ COMP_LPCOMP_IRQHandler_v
|
||||
IRQ SWI0_EGU0_IRQHandler_v
|
||||
IRQ SWI1_EGU1_IRQHandler_v /* restricted for Radio Notification */
|
||||
IRQ SWI2_EGU2_IRQHandler_v /* blocked for SoftDevice Event */
|
||||
IRQ SWI3_EGU3_IRQHandler_v
|
||||
IRQ SWI4_EGU4_IRQHandler /* blocked */
|
||||
IRQ SWI5_EGU5_IRQHandler /* blocked */
|
||||
IRQ TIMER3_IRQHandler_v
|
||||
IRQ TIMER4_IRQHandler_v
|
||||
IRQ PWM0_IRQHandler_v
|
||||
IRQ PDM_IRQHandler_v
|
||||
IRQ MWU_IRQHandler /* restricted */
|
||||
IRQ PWM1_IRQHandler_v
|
||||
IRQ PWM2_IRQHandler_v
|
||||
IRQ SPIM2_SPIS2_SPI2_IRQHandler_v
|
||||
IRQ RTC2_IRQHandler_v
|
||||
IRQ I2S_IRQHandler_v
|
||||
IRQ FPU_IRQHandler_v
|
||||
IRQ USBD_IRQHandler_v
|
||||
IRQ UARTE1_IRQHandler_v
|
||||
IRQ QSPI_IRQHandler_v
|
||||
IRQ CRYPTOCELL_IRQHandler_v
|
||||
IRQ SPIM3_IRQHandler_v
|
||||
IRQ PWM3_IRQHandler_v
|
||||
|
||||
.end
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
||||
|
||||
if (!isdefinedsymbol(MBED_APP_START)) {
|
||||
define symbol MBED_APP_START = 0x21000;
|
||||
}
|
||||
|
||||
if (!isdefinedsymbol(MBED_APP_SIZE)) {
|
||||
define symbol MBED_APP_SIZE = 0xDF000;
|
||||
}
|
||||
|
||||
/*-Specials-*/
|
||||
define symbol __ICFEDIT_intvec_start__ = MBED_APP_START;
|
||||
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_ROM_start__ = MBED_APP_START;
|
||||
define symbol __ICFEDIT_region_ROM_end__ = MBED_APP_START + MBED_APP_SIZE - 1;
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20003288;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x2003ffff;
|
||||
export symbol __ICFEDIT_region_RAM_start__;
|
||||
export symbol __ICFEDIT_region_RAM_end__;
|
||||
|
||||
/*-Sizes-*/
|
||||
/*Heap 1/4 of ram and stack 1/8*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x800;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x3000;
|
||||
/**** End of ICF editor section. ###ICF###*/
|
||||
|
||||
define symbol __code_start_soft_device__ = 0x0;
|
||||
|
||||
define memory mem with size = 4G;
|
||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
||||
|
||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
initialize by copy { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
keep { section .intvec };
|
||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
||||
place in ROM_region { readonly };
|
||||
place in RAM_region { readwrite,
|
||||
block HEAP,
|
||||
block CSTACK };
|
||||
|
||||
/*This is used for mbed applications build inside the Embedded workbench
|
||||
Applications build with the python scritps use a hex merge so need to merge it
|
||||
inside the linker. The linker can only use binary files so the hex merge is not possible
|
||||
through the linker. That is why a binary is used instead of a hex image for the embedded project.
|
||||
*/
|
||||
if(isdefinedsymbol(SOFT_DEVICE_BIN))
|
||||
{
|
||||
place at address mem:__code_start_soft_device__ { section .noinit_softdevice };
|
||||
}
|
||||
|
|
@ -1,417 +0,0 @@
|
|||
;/* Copyright (c) 2012 ARM LIMITED
|
||||
;
|
||||
; All rights reserved.
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions are met:
|
||||
; - Redistributions of source code must retain the above copyright
|
||||
; notice, this list of conditions and the following disclaimer.
|
||||
; - 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.
|
||||
; - Neither the name of ARM 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 AND CONTRIBUTORS "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 COPYRIGHT HOLDERS AND CONTRIBUTORS 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 modules in this file are included in the libraries, and may be replaced
|
||||
; by any user-defined modules that define the PUBLIC symbol _program_start or
|
||||
; a user defined start symbol.
|
||||
; To override the cstartup defined in the library, simply add your modified
|
||||
; version to the workbench project.
|
||||
;
|
||||
; The vector table is normally located at address 0.
|
||||
; When debugging in RAM, it can be located in RAM, aligned to at least 2^6.
|
||||
; The name "__vector_table" has special meaning for C-SPY:
|
||||
; it is where the SP start value is found, and the NVIC vector
|
||||
; table register (VTOR) is initialized to this address if != 0.
|
||||
|
||||
|
||||
|
||||
MODULE ?cstartup
|
||||
|
||||
;; Stack size default : Defined in *.icf (linker file). Can be modified inside EW.
|
||||
;; Heap size default : Defined in *.icf (linker file). Can be modified inside EW.
|
||||
|
||||
;; Forward declaration of sections.
|
||||
SECTION CSTACK:DATA:NOROOT(3)
|
||||
|
||||
SECTION .intvec:CODE:NOROOT(2)
|
||||
|
||||
EXTERN __iar_program_start
|
||||
EXTERN SystemInit
|
||||
EXTERN nrf_reloc_vector_table
|
||||
PUBLIC __vector_table
|
||||
PUBLIC __Vectors
|
||||
PUBLIC __Vectors_End
|
||||
PUBLIC __Vectors_Size
|
||||
|
||||
DATA
|
||||
|
||||
__vector_table
|
||||
DCD sfe(CSTACK)
|
||||
DCD Reset_Handler
|
||||
DCD NMI_Handler
|
||||
DCD HardFault_Handler
|
||||
DCD MemoryManagement_Handler
|
||||
DCD BusFault_Handler
|
||||
DCD UsageFault_Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler
|
||||
DCD DebugMonitor_Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler
|
||||
DCD SysTick_Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD POWER_CLOCK_IRQHandler
|
||||
DCD RADIO_IRQHandler
|
||||
DCD UARTE0_UART0_IRQHandler_v
|
||||
DCD SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler_v
|
||||
DCD SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler_v
|
||||
DCD NFCT_IRQHandler_v
|
||||
DCD GPIOTE_IRQHandler_v
|
||||
DCD SAADC_IRQHandler_v
|
||||
DCD TIMER0_IRQHandler_v
|
||||
DCD TIMER1_IRQHandler_v
|
||||
DCD TIMER2_IRQHandler_v
|
||||
DCD RTC0_IRQHandler
|
||||
DCD TEMP_IRQHandler_v
|
||||
DCD RNG_IRQHandler
|
||||
DCD ECB_IRQHandler
|
||||
DCD CCM_AAR_IRQHandler
|
||||
DCD WDT_IRQHandler_v
|
||||
DCD RTC1_IRQHandler_v
|
||||
DCD QDEC_IRQHandler_v
|
||||
DCD COMP_LPCOMP_IRQHandler_v
|
||||
DCD SWI0_EGU0_IRQHandler_v
|
||||
DCD SWI1_EGU1_IRQHandler_v
|
||||
DCD SWI2_EGU2_IRQHandler_v
|
||||
DCD SWI3_EGU3_IRQHandler_v
|
||||
DCD SWI4_EGU4_IRQHandler
|
||||
DCD SWI5_EGU5_IRQHandler
|
||||
DCD TIMER3_IRQHandler_v
|
||||
DCD TIMER4_IRQHandler_v
|
||||
DCD PWM0_IRQHandler_v
|
||||
DCD PDM_IRQHandler_v
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD MWU_IRQHandler
|
||||
DCD PWM1_IRQHandler_v
|
||||
DCD PWM2_IRQHandler_v
|
||||
DCD SPIM2_SPIS2_SPI2_IRQHandler_v
|
||||
DCD RTC2_IRQHandler_v
|
||||
DCD I2S_IRQHandler_v
|
||||
DCD FPU_IRQHandler_v
|
||||
DCD USBD_IRQHandler_v
|
||||
DCD UARTE1_IRQHandler_v
|
||||
DCD QSPI_IRQHandler_v
|
||||
DCD CRYPTOCELL_IRQHandler_v
|
||||
DCD SPIM3_IRQHandler_v
|
||||
DCD 0 /*Reserved */
|
||||
DCD PWM3_IRQHandler_v
|
||||
|
||||
__Vectors_End
|
||||
__Vectors EQU __vector_table
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
|
||||
; Default handlers.
|
||||
THUMB
|
||||
|
||||
PUBWEAK Reset_Handler
|
||||
SECTION .text:CODE:NOROOT(2)
|
||||
Reset_Handler
|
||||
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =nrf_reloc_vector_table
|
||||
BLX R0
|
||||
LDR R0, =__iar_program_start
|
||||
BX R0
|
||||
|
||||
; Dummy exception handlers
|
||||
|
||||
|
||||
PUBWEAK NMI_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
NMI_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK HardFault_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
HardFault_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK MemoryManagement_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
MemoryManagement_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK BusFault_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
BusFault_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK UsageFault_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
UsageFault_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK SVC_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SVC_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK DebugMonitor_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
DebugMonitor_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK PendSV_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
PendSV_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK SysTick_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SysTick_Handler
|
||||
B .
|
||||
|
||||
|
||||
; Dummy interrupt handlers
|
||||
|
||||
PUBWEAK POWER_CLOCK_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
POWER_CLOCK_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK RADIO_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
RADIO_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK UARTE0_UART0_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
UARTE0_UART0_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK NFCT_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
NFCT_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK GPIOTE_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
GPIOTE_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SAADC_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SAADC_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK TIMER0_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
TIMER0_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK TIMER1_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
TIMER1_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK TIMER2_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
TIMER2_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK RTC0_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
RTC0_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK TEMP_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
TEMP_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK RNG_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
RNG_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK ECB_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
ECB_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK CCM_AAR_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
CCM_AAR_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK WDT_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
WDT_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK RTC1_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
RTC1_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK QDEC_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
QDEC_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK COMP_LPCOMP_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
COMP_LPCOMP_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SWI0_EGU0_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SWI0_EGU0_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SWI1_EGU1_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SWI1_EGU1_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SWI2_EGU2_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SWI2_EGU2_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SWI3_EGU3_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SWI3_EGU3_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SWI4_EGU4_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SWI4_EGU4_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK SWI5_EGU5_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SWI5_EGU5_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK TIMER3_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
TIMER3_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK TIMER4_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
TIMER4_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK PWM0_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
PWM0_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK PDM_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
PDM_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK MWU_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
MWU_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK PWM1_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
PWM1_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK PWM2_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
PWM2_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SPIM2_SPIS2_SPI2_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SPIM2_SPIS2_SPI2_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK RTC2_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
RTC2_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK I2S_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
I2S_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK FPU_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
FPU_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK USBD_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
USBD_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK UARTE1_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
UARTE1_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK QSPI_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
QSPI_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK CRYPTOCELL_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
CRYPTOCELL_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK SPIM3_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SPIM3_IRQHandler_v
|
||||
B .
|
||||
|
||||
PUBWEAK PWM3_IRQHandler_v
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
PWM3_IRQHandler_v
|
||||
B .
|
||||
|
||||
|
||||
END
|
||||
|
||||
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* PackageLicenseDeclared: Apache-2.0
|
||||
* Copyright (c) 2016 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef MBED_CMSIS_H
|
||||
#define MBED_CMSIS_H
|
||||
|
||||
#include "nrf.h"
|
||||
#include "cmsis_nvic.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/* mbed Microcontroller Library
|
||||
* CMSIS-style functionality to support dynamic vectors
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2016 ARM Limited. All rights reserved.
|
||||
* 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 ARM Limited 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 AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "cmsis_nvic.h"
|
||||
|
||||
extern uint32_t nrf_dispatch_vector[NVIC_NUM_VECTORS];
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector)
|
||||
{
|
||||
nrf_dispatch_vector[IRQn + NVIC_USER_IRQ_OFFSET] = vector;
|
||||
}
|
||||
|
||||
uint32_t NVIC_GetVector(IRQn_Type IRQn)
|
||||
{
|
||||
return nrf_dispatch_vector[IRQn + NVIC_USER_IRQ_OFFSET];
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
/* mbed Microcontroller Library
|
||||
* CMSIS-style functionality to support dynamic vectors
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2016 ARM Limited. All rights reserved.
|
||||
* 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 ARM Limited 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 AND CONTRIBUTORS "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 OR CONTRIBUTORS 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 MBED_CMSIS_NVIC_H
|
||||
#define MBED_CMSIS_NVIC_H
|
||||
|
||||
#define NVIC_NUM_VECTORS (16 + 46) // CORE + MCU Peripherals
|
||||
#define NVIC_USER_IRQ_OFFSET 16
|
||||
|
||||
#include "nrf.h"
|
||||
#include "cmsis.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector);
|
||||
uint32_t NVIC_GetVector(IRQn_Type IRQn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,209 +0,0 @@
|
|||
/* Copyright (c) 2012 ARM LIMITED
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* * Neither the name of ARM 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 AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "nrf.h"
|
||||
#include "system_nrf52840.h"
|
||||
|
||||
/*lint ++flb "Enter library region" */
|
||||
|
||||
#define __SYSTEM_CLOCK_64M (64000000UL)
|
||||
|
||||
static bool errata_36(void);
|
||||
static bool errata_98(void);
|
||||
static bool errata_103(void);
|
||||
static bool errata_115(void);
|
||||
static bool errata_120(void);
|
||||
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK_64M;
|
||||
#elif defined ( __ICCARM__ )
|
||||
__root uint32_t SystemCoreClock = __SYSTEM_CLOCK_64M;
|
||||
#elif defined ( __GNUC__ )
|
||||
uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK_64M;
|
||||
#endif
|
||||
|
||||
void SystemCoreClockUpdate(void)
|
||||
{
|
||||
SystemCoreClock = __SYSTEM_CLOCK_64M;
|
||||
}
|
||||
|
||||
void SystemInit(void)
|
||||
{
|
||||
/* Workaround for Errata 36 "CLOCK: Some registers are not reset when expected" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_36()){
|
||||
NRF_CLOCK->EVENTS_DONE = 0;
|
||||
NRF_CLOCK->EVENTS_CTTO = 0;
|
||||
NRF_CLOCK->CTIV = 0;
|
||||
}
|
||||
|
||||
/* Workaround for Errata 98 "NFCT: Not able to communicate with the peer" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_98()){
|
||||
*(volatile uint32_t *)0x4000568Cul = 0x00038148ul;
|
||||
}
|
||||
|
||||
/* Workaround for Errata 103 "CCM: Wrong reset value of CCM MAXPACKETSIZE" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_103()){
|
||||
NRF_CCM->MAXPACKETSIZE = 0xFBul;
|
||||
}
|
||||
|
||||
/* Workaround for Errata 115 "RAM: RAM content cannot be trusted upon waking up from System ON Idle or System OFF mode" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_115()){
|
||||
*(volatile uint32_t *)0x40000EE4 = (*(volatile uint32_t *)0x40000EE4 & 0xFFFFFFF0) | (*(uint32_t *)0x10000258 & 0x0000000F);
|
||||
}
|
||||
|
||||
/* Workaround for Errata 120 "QSPI: Data read or written is corrupted" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_120()){
|
||||
*(volatile uint32_t *)0x40029640ul = 0x200ul;
|
||||
}
|
||||
|
||||
/* Enable the FPU if the compiler used floating point unit instructions. __FPU_USED is a MACRO defined by the
|
||||
* compiler. Since the FPU consumes energy, remember to disable FPU use in the compiler if floating point unit
|
||||
* operations are not used in your code. */
|
||||
#if (__FPU_USED == 1)
|
||||
SCB->CPACR |= (3UL << 20) | (3UL << 22);
|
||||
__DSB();
|
||||
__ISB();
|
||||
#endif
|
||||
|
||||
/* Configure NFCT pins as GPIOs if NFCT is not to be used in your code. If CONFIG_NFCT_PINS_AS_GPIOS is not defined,
|
||||
two GPIOs (see Product Specification to see which ones) will be reserved for NFC and will not be available as
|
||||
normal GPIOs. */
|
||||
#if defined (CONFIG_NFCT_PINS_AS_GPIOS)
|
||||
if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk) == (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)){
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NRF_UICR->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Configure GPIO pads as pPin Reset pin if Pin Reset capabilities desired. If CONFIG_GPIO_AS_PINRESET is not
|
||||
defined, pin reset will not be available. One GPIO (see Product Specification to see which one) will then be
|
||||
reserved for PinReset and not available as normal GPIO. */
|
||||
#if defined (CONFIG_GPIO_AS_PINRESET)
|
||||
if (((NRF_UICR->PSELRESET[0] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos)) ||
|
||||
((NRF_UICR->PSELRESET[1] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos))){
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NRF_UICR->PSELRESET[0] = 18;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NRF_UICR->PSELRESET[1] = 18;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Enable SWO trace functionality. If ENABLE_SWO is not defined, SWO pin will be used as GPIO (see Product
|
||||
Specification to see which one). */
|
||||
#if defined (ENABLE_SWO)
|
||||
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
||||
NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Serial << CLOCK_TRACECONFIG_TRACEMUX_Pos;
|
||||
NRF_P1->PIN_CNF[0] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||
#endif
|
||||
|
||||
/* Enable Trace functionality. If ENABLE_TRACE is not defined, TRACE pins will be used as GPIOs (see Product
|
||||
Specification to see which ones). */
|
||||
#if defined (ENABLE_TRACE)
|
||||
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
||||
NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Parallel << CLOCK_TRACECONFIG_TRACEMUX_Pos;
|
||||
NRF_P0->PIN_CNF[7] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||
NRF_P1->PIN_CNF[0] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||
NRF_P0->PIN_CNF[12] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||
NRF_P0->PIN_CNF[11] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||
NRF_P1->PIN_CNF[9] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||
#endif
|
||||
|
||||
SystemCoreClockUpdate();
|
||||
}
|
||||
|
||||
|
||||
static bool errata_36(void)
|
||||
{
|
||||
if ((*(uint32_t *)0x10000130ul == 0x8ul) && (*(uint32_t *)0x10000134ul == 0x0ul)){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static bool errata_98(void)
|
||||
{
|
||||
if ((*(uint32_t *)0x10000130ul == 0x8ul) && (*(uint32_t *)0x10000134ul == 0x0ul)){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static bool errata_103(void)
|
||||
{
|
||||
if ((*(uint32_t *)0x10000130ul == 0x8ul) && (*(uint32_t *)0x10000134ul == 0x0ul)){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static bool errata_115(void)
|
||||
{
|
||||
if ((*(uint32_t *)0x10000130ul == 0x8ul) && (*(uint32_t *)0x10000134ul == 0x0ul)){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static bool errata_120(void)
|
||||
{
|
||||
if ((*(uint32_t *)0x10000130ul == 0x8ul) && (*(uint32_t *)0x10000134ul == 0x0ul)){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*lint --flb "Leave library region" */
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
/* Copyright (c) 2012 ARM LIMITED
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* * Neither the name of ARM 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 AND CONTRIBUTORS "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 OR CONTRIBUTORS 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 SYSTEM_NRF52840_H
|
||||
#define SYSTEM_NRF52840_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
|
||||
|
||||
/**
|
||||
* Initialize the system
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Setup the microcontroller system.
|
||||
* Initialize the System and update the SystemCoreClock variable.
|
||||
*/
|
||||
extern void SystemInit (void);
|
||||
|
||||
/**
|
||||
* Update SystemCoreClock variable
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Updates the SystemCoreClock with current core Clock
|
||||
* retrieved from cpu registers.
|
||||
*/
|
||||
extern void SystemCoreClockUpdate (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SYSTEM_NRF52840_H */
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,219 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
@defgroup nrf_mbr_api Master Boot Record API
|
||||
@{
|
||||
|
||||
@brief APIs for updating SoftDevice and BootLoader
|
||||
|
||||
*/
|
||||
|
||||
/* Header guard */
|
||||
#ifndef NRF_MBR_H__
|
||||
#define NRF_MBR_H__
|
||||
|
||||
#include "nrf_svc.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef NRF52840_XXAA
|
||||
#error "This header file shall only be included for nRF52 projects"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup NRF_MBR_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@brief MBR SVC Base number. */
|
||||
#define MBR_SVC_BASE (0x18)
|
||||
|
||||
/**@brief Page size in words. */
|
||||
#define MBR_PAGE_SIZE_IN_WORDS (1024)
|
||||
|
||||
/** @brief The size that must be reserved for the MBR when a softdevice is written to flash.
|
||||
This is the offset where the first byte of the softdevice hex file is written.*/
|
||||
#define MBR_SIZE (0x1000)
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_ENUMS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief nRF Master Boot Record API SVC numbers. */
|
||||
enum NRF_MBR_SVCS
|
||||
{
|
||||
SD_MBR_COMMAND = MBR_SVC_BASE, /**< ::sd_mbr_command */
|
||||
};
|
||||
|
||||
/**@brief Possible values for ::sd_mbr_command_t.command */
|
||||
enum NRF_MBR_COMMANDS
|
||||
{
|
||||
SD_MBR_COMMAND_COPY_BL, /**< Copy a new BootLoader. @see sd_mbr_command_copy_bl_t */
|
||||
SD_MBR_COMMAND_COPY_SD, /**< Copy a new SoftDevice. @see ::sd_mbr_command_copy_sd_t*/
|
||||
SD_MBR_COMMAND_INIT_SD, /**< Init forwarding interrupts to SD, and run reset function in SD*/
|
||||
SD_MBR_COMMAND_COMPARE, /**< This command works like memcmp. @see ::sd_mbr_command_compare_t*/
|
||||
SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET, /**< Start forwarding all exception to this address @see ::sd_mbr_command_vector_table_base_set_t*/
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_TYPES Types
|
||||
* @{ */
|
||||
|
||||
/**@brief This command copies part of a new SoftDevice
|
||||
* The destination area is erased before copying.
|
||||
* If dst is in the middle of a flash page, that whole flash page will be erased.
|
||||
* If (dst+len) is in the middle of a flash page, that whole flash page will be erased.
|
||||
*
|
||||
* The user of this function is responsible for setting the BPROT registers.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS indicates that the contents of the memory blocks where copied correctly.
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates that the contents of the memory blocks where not verified correctly after copying.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *src; /**< Pointer to the source of data to be copied.*/
|
||||
uint32_t *dst; /**< Pointer to the destination where the content is to be copied.*/
|
||||
uint32_t len; /**< Number of 32 bit words to copy. Must be a multiple of @ref MBR_PAGE_SIZE_IN_WORDS words.*/
|
||||
} sd_mbr_command_copy_sd_t;
|
||||
|
||||
|
||||
/**@brief This command works like memcmp, but takes the length in words.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS indicates that the contents of both memory blocks are equal.
|
||||
* @retval ::NRF_ERROR_NULL indicates that the contents of the memory blocks are not equal.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *ptr1; /**< Pointer to block of memory. */
|
||||
uint32_t *ptr2; /**< Pointer to block of memory. */
|
||||
uint32_t len; /**< Number of 32 bit words to compare.*/
|
||||
} sd_mbr_command_compare_t;
|
||||
|
||||
|
||||
/**@brief This command copies a new BootLoader.
|
||||
* With this command, destination of BootLoader is always the address written in NRF_UICR->BOOTADDR.
|
||||
*
|
||||
* Destination is erased by this function.
|
||||
* If (destination+bl_len) is in the middle of a flash page, that whole flash page will be erased.
|
||||
*
|
||||
* This function will use PROTENSET to protect the flash that is not intended to be written.
|
||||
*
|
||||
* On Success, this function will not return. It will start the new BootLoader from reset-vector as normal.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN if NRF_UICR->BOOTADDR is not set.
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH if parameters attempts to read or write outside flash area.
|
||||
* @retval ::NRF_ERROR_NO_MEM if no parameter page is provided (see sds for more info)
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *bl_src; /**< Pointer to the source of the Bootloader to be be copied.*/
|
||||
uint32_t bl_len; /**< Number of 32 bit words to copy for BootLoader. */
|
||||
} sd_mbr_command_copy_bl_t;
|
||||
|
||||
/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the MBR
|
||||
*
|
||||
* Once this function has been called, this address is where the MBR will start to forward interrupts to after a reset.
|
||||
*
|
||||
* To restore default forwarding this function should be called with @param address set to 0.
|
||||
* The MBR will then start forwarding to interrupts to the address in NFR_UICR->BOOTADDR or to the SoftDevice if the BOOTADDR is not set.
|
||||
*
|
||||
* On Success, this function will not return. It will reset the device.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR if parameter address is outside of the flash size.
|
||||
* @retval ::NRF_ERROR_NO_MEM if no parameter page is provided (see sds for more info)
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/
|
||||
} sd_mbr_command_vector_table_base_set_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t command; /**< type of command to be issued see @ref NRF_MBR_COMMANDS. */
|
||||
union
|
||||
{
|
||||
sd_mbr_command_copy_sd_t copy_sd; /**< Parameters for copy SoftDevice.*/
|
||||
sd_mbr_command_compare_t compare; /**< Parameters for verify.*/
|
||||
sd_mbr_command_copy_bl_t copy_bl; /**< Parameters for copy BootLoader. Requires parameter page. */
|
||||
sd_mbr_command_vector_table_base_set_t base_set; /**< Parameters for vector table base set. Requires parameter page.*/
|
||||
} params;
|
||||
} sd_mbr_command_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Issue Master Boot Record commands
|
||||
*
|
||||
* Commands used when updating a SoftDevice and bootloader.
|
||||
*
|
||||
* The SD_MBR_COMMAND_COPY_BL and SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET requires parameters to be
|
||||
* retained by the MBR when resetting the IC. This is done in a separate flash page
|
||||
* provided by the application. The uicr register UICR.NRFFW[1] must be set
|
||||
* to an address corresponding to a page in the application flash space. This page will be cleared
|
||||
* by the MBR and used to store the command before reset. When the UICR.NRFFW[1] field is set
|
||||
* the page it refers to must not be used by the application. If the UICR.NRFFW[1] is set to
|
||||
* 0xFFFFFFFF (the default) MBR commands which use flash will be unavailable and return
|
||||
* NRF_ERROR_NO_MEM.
|
||||
*
|
||||
* @param[in] param Pointer to a struct describing the command.
|
||||
*
|
||||
* @note for retvals see ::sd_mbr_command_copy_sd_t ::sd_mbr_command_copy_bl_t ::sd_mbr_command_compare_t ::sd_mbr_command_vector_table_base_set_t
|
||||
*
|
||||
* @retval NRF_ERROR_NO_MEM if UICR.NRFFW[1] is not set (i.e. is 0xFFFFFFFF).
|
||||
* @retval NRF_ERROR_INVALID_PARAM if an invalid command is given.
|
||||
*/
|
||||
SVCALL(SD_MBR_COMMAND, uint32_t, sd_mbr_command(sd_mbr_command_t* param));
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_MBR_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,689 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup BLE_COMMON BLE SoftDevice Common
|
||||
@{
|
||||
@defgroup ble_api Events, type definitions and API calls
|
||||
@{
|
||||
|
||||
@brief Module independent events, type definitions and API calls for the BLE SoftDevice.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef BLE_H__
|
||||
#define BLE_H__
|
||||
|
||||
#include "nrf_ble_ranges.h"
|
||||
#include "nrf_ble_types.h"
|
||||
#include "nrf_ble_gap.h"
|
||||
#include "nrf_ble_l2cap.h"
|
||||
#include "nrf_ble_gatt.h"
|
||||
#include "nrf_ble_gattc.h"
|
||||
#include "nrf_ble_gatts.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup BLE_COMMON_ENUMERATIONS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**
|
||||
* @brief Common API SVC numbers.
|
||||
*/
|
||||
enum BLE_COMMON_SVCS
|
||||
{
|
||||
SD_BLE_ENABLE = BLE_SVC_BASE, /**< Enable and initialize the BLE stack */
|
||||
SD_BLE_EVT_GET, /**< Get an event from the pending events queue. */
|
||||
SD_BLE_TX_PACKET_COUNT_GET, /**< Get the total number of available application transmission packets for a particular connection. */
|
||||
SD_BLE_UUID_VS_ADD, /**< Add a Vendor Specific UUID. */
|
||||
SD_BLE_UUID_DECODE, /**< Decode UUID bytes. */
|
||||
SD_BLE_UUID_ENCODE, /**< Encode UUID bytes. */
|
||||
SD_BLE_VERSION_GET, /**< Get the local version information (company id, Link Layer Version, Link Layer Subversion). */
|
||||
SD_BLE_USER_MEM_REPLY, /**< User Memory Reply. */
|
||||
SD_BLE_OPT_SET, /**< Set a BLE option. */
|
||||
SD_BLE_OPT_GET, /**< Get a BLE option. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief BLE Module Independent Event IDs.
|
||||
*/
|
||||
enum BLE_COMMON_EVTS
|
||||
{
|
||||
BLE_EVT_TX_COMPLETE = BLE_EVT_BASE, /**< Transmission Complete. @ref ble_evt_tx_complete_t */
|
||||
BLE_EVT_USER_MEM_REQUEST, /**< User Memory request. @ref ble_evt_user_mem_request_t */
|
||||
BLE_EVT_USER_MEM_RELEASE, /**< User Memory release. @ref ble_evt_user_mem_release_t */
|
||||
BLE_EVT_DATA_LENGTH_CHANGED /**< Link layer PDU length changed. @ref ble_evt_data_length_changed_t. */
|
||||
};
|
||||
|
||||
/**@brief BLE connection bandwidth types.
|
||||
* Bandwidth types supported by the SoftDevice. The bandwidth type dictates the maximum number of full length packets per connection interval.
|
||||
*/
|
||||
enum BLE_CONN_BWS
|
||||
{
|
||||
BLE_CONN_BW_INVALID = 0, /**< Invalid connection bandwidth. */
|
||||
BLE_CONN_BW_LOW, /**< Low connection bandwidth. */
|
||||
BLE_CONN_BW_MID, /**< Medium connection bandwidth. */
|
||||
BLE_CONN_BW_HIGH /**< High connection bandwidth. */
|
||||
};
|
||||
|
||||
/**@brief Common Option IDs.
|
||||
* IDs that uniquely identify a common option.
|
||||
*/
|
||||
enum BLE_COMMON_OPTS
|
||||
{
|
||||
BLE_COMMON_OPT_CONN_BW = BLE_OPT_BASE, /**< Bandwidth configuration @ref ble_common_opt_conn_bw_t */
|
||||
BLE_COMMON_OPT_PA_LNA, /**< PA and LNA options */
|
||||
BLE_COMMON_OPT_CONN_EVT_EXT, /**< Extended connection events option */
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_COMMON_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/** @brief Required pointer alignment for BLE Events.
|
||||
*/
|
||||
#define BLE_EVT_PTR_ALIGNMENT 4
|
||||
|
||||
/** @brief Leaves the maximum of the two arguments.
|
||||
*/
|
||||
#define BLE_MAX(a, b) ((a) < (b) ? (b) : (a))
|
||||
|
||||
/** @brief Maximum possible length for BLE Events.
|
||||
* @note Value of @ref ble_gatt_enable_params_t::att_mtu shall be used as a parameter.
|
||||
* If that value is set to 0 then @ref BLE_GATT_MTU_SIZE_DEFAULT must be used instead.
|
||||
*/
|
||||
#define BLE_EVT_LEN_MAX(ATT_MTU) (BLE_MAX( \
|
||||
sizeof(ble_evt_t), \
|
||||
BLE_MAX( \
|
||||
offsetof(ble_evt_t, evt.gattc_evt.params.rel_disc_rsp.includes) + ((ATT_MTU) - 2) / 6 * sizeof(ble_gattc_include_t), \
|
||||
offsetof(ble_evt_t, evt.gattc_evt.params.attr_info_disc_rsp.info.attr_info16) + ((ATT_MTU) - 2) / 4 * sizeof(ble_gattc_attr_info16_t) \
|
||||
) \
|
||||
))
|
||||
|
||||
/** @defgroup BLE_USER_MEM_TYPES User Memory Types
|
||||
* @{ */
|
||||
#define BLE_USER_MEM_TYPE_INVALID 0x00 /**< Invalid User Memory Types. */
|
||||
#define BLE_USER_MEM_TYPE_GATTS_QUEUED_WRITES 0x01 /**< User Memory for GATTS queued writes. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_UUID_VS_COUNTS Vendor Specific UUID counts
|
||||
* @{
|
||||
*/
|
||||
#define BLE_UUID_VS_COUNT_MIN 1 /**< Minimum VS UUID count. */
|
||||
#define BLE_UUID_VS_COUNT_DEFAULT 0 /**< Use the default VS UUID count (10 for this version of the SoftDevice). */
|
||||
/** @} */
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_COMMON_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**@brief User Memory Block. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *p_mem; /**< Pointer to the start of the user memory block. */
|
||||
uint16_t len; /**< Length in bytes of the user memory block. */
|
||||
} ble_user_mem_block_t;
|
||||
|
||||
/**
|
||||
* @brief Event structure for @ref BLE_EVT_TX_COMPLETE.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t count; /**< Number of packets transmitted. */
|
||||
} ble_evt_tx_complete_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_EVT_USER_MEM_REQUEST. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */
|
||||
} ble_evt_user_mem_request_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_EVT_USER_MEM_RELEASE. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */
|
||||
ble_user_mem_block_t mem_block; /**< User memory block */
|
||||
} ble_evt_user_mem_release_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_EVT_DATA_LENGTH_CHANGED. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t max_tx_octets; /**< The maximum number of payload octets in a Link Layer Data Channel PDU that the local Controller will send. Range: 27-251 */
|
||||
uint16_t max_tx_time; /**< The maximum time (in microseconds) that the local Controller will take to send a Link Layer Data Channel PDU. Range: 328-2120 */
|
||||
uint16_t max_rx_octets; /**< The maximum number of payload octets in a Link Layer Data Channel PDU that the local controller expects to receive. Range: 27-251 */
|
||||
uint16_t max_rx_time; /**< The maximum time (in microseconds) that the local Controller expects to take to receive a Link Layer Data Channel PDU. Range: 328-2120 */
|
||||
} ble_evt_data_length_changed_t;
|
||||
|
||||
/**@brief Event structure for events not associated with a specific function module. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t conn_handle; /**< Connection Handle on which this event occurred. */
|
||||
union
|
||||
{
|
||||
ble_evt_tx_complete_t tx_complete; /**< Transmission Complete. */
|
||||
ble_evt_user_mem_request_t user_mem_request; /**< User Memory Request Event Parameters. */
|
||||
ble_evt_user_mem_release_t user_mem_release; /**< User Memory Release Event Parameters. */
|
||||
ble_evt_data_length_changed_t data_length_changed; /**< Data Length Changed Event Parameters. */
|
||||
} params; /**< Event parameter union. */
|
||||
} ble_common_evt_t;
|
||||
|
||||
/**@brief BLE Event header. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t evt_id; /**< Value from a BLE_<module>_EVT series. */
|
||||
uint16_t evt_len; /**< Length in octets including this header. */
|
||||
} ble_evt_hdr_t;
|
||||
|
||||
/**@brief Common BLE Event type, wrapping the module specific event reports. */
|
||||
typedef struct
|
||||
{
|
||||
ble_evt_hdr_t header; /**< Event header. */
|
||||
union
|
||||
{
|
||||
ble_common_evt_t common_evt; /**< Common Event, evt_id in BLE_EVT_* series. */
|
||||
ble_gap_evt_t gap_evt; /**< GAP originated event, evt_id in BLE_GAP_EVT_* series. */
|
||||
ble_l2cap_evt_t l2cap_evt; /**< L2CAP originated event, evt_id in BLE_L2CAP_EVT* series. */
|
||||
ble_gattc_evt_t gattc_evt; /**< GATT client originated event, evt_id in BLE_GATTC_EVT* series. */
|
||||
ble_gatts_evt_t gatts_evt; /**< GATT server originated event, evt_id in BLE_GATTS_EVT* series. */
|
||||
} evt; /**< Event union. */
|
||||
} ble_evt_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Version Information.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t version_number; /**< Link Layer Version number for BT 4.1 spec is 7 (https://www.bluetooth.org/en-us/specification/assigned-numbers/link-layer). */
|
||||
uint16_t company_id; /**< Company ID, Nordic Semiconductor's company ID is 89 (0x0059) (https://www.bluetooth.org/apps/content/Default.aspx?doc_id=49708). */
|
||||
uint16_t subversion_number; /**< Link Layer Sub Version number, corresponds to the SoftDevice Config ID or Firmware ID (FWID). */
|
||||
} ble_version_t;
|
||||
|
||||
/**
|
||||
* @brief Configuration parameters for the PA and LNA.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t enable :1; /**< Enable toggling for this amplifier */
|
||||
uint8_t active_high :1; /**< Set the pin to be active high */
|
||||
uint8_t gpio_pin :6; /**< The GPIO pin to toggle for this amplifier */
|
||||
} ble_pa_lna_cfg_t;
|
||||
|
||||
/**
|
||||
* @brief PA & LNA GPIO toggle configuration
|
||||
*
|
||||
* This option configures the SoftDevice to toggle pins when the radio is active for use with a power amplifier and/or
|
||||
* a low noise amplifier.
|
||||
*
|
||||
* Toggling the pins is achieved by using two PPI channels and a GPIOTE channel. The hardware channel IDs are provided
|
||||
* by the application and should be regarded as reserved as long as any PA/LNA toggling is enabled.
|
||||
*
|
||||
* @note @ref sd_ble_opt_get is not supported for this option.
|
||||
* @note This feature is only supported for nRF52, on nRF51 @ref NRF_ERROR_NOT_SUPPORTED will always be returned.
|
||||
* @note Setting this option while the radio is in use (i.e. any of the roles are active) may have undefined consequences
|
||||
* and must be avoided by the application.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ble_pa_lna_cfg_t pa_cfg; /**< Power Amplifier configuration */
|
||||
ble_pa_lna_cfg_t lna_cfg; /**< Low Noise Amplifier configuration */
|
||||
|
||||
uint8_t ppi_ch_id_set; /**< PPI channel used for radio pin setting */
|
||||
uint8_t ppi_ch_id_clr; /**< PPI channel used for radio pin clearing */
|
||||
uint8_t gpiote_ch_id; /**< GPIOTE channel used for radio pin toggling */
|
||||
} ble_common_opt_pa_lna_t;
|
||||
|
||||
/**
|
||||
* @brief BLE connection bandwidth configuration parameters
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t conn_bw_tx; /**< Connection bandwidth configuration for transmission, see @ref BLE_CONN_BWS.*/
|
||||
uint8_t conn_bw_rx; /**< Connection bandwidth configuration for reception, see @ref BLE_CONN_BWS.*/
|
||||
} ble_conn_bw_t;
|
||||
|
||||
/**@brief BLE connection specific bandwidth configuration parameters.
|
||||
*
|
||||
* This can be used with @ref sd_ble_opt_set to set the bandwidth configuration to be used when creating connections.
|
||||
*
|
||||
* Call @ref sd_ble_opt_set with this option prior to calling @ref sd_ble_gap_adv_start or @ref sd_ble_gap_connect.
|
||||
*
|
||||
* The bandwidth configurations set via @ref sd_ble_opt_set are maintained separately for central and peripheral
|
||||
* connections. The given configurations are used for all future connections of the role indicated in this structure
|
||||
* unless they are changed by subsequent @ref sd_ble_opt_set calls.
|
||||
*
|
||||
* @note When this option is not used, the SoftDevice will use the default options:
|
||||
* - @ref BLE_CONN_BW_HIGH for @ref BLE_GAP_ROLE_PERIPH connections (both transmission and reception).
|
||||
* - @ref BLE_CONN_BW_MID for @ref BLE_GAP_ROLE_CENTRAL connections (both transmisison and reception).
|
||||
* This option allows the application to selectively override these defaults for each role.
|
||||
*
|
||||
* @note The global memory pool configuration can be set with the @ref ble_conn_bw_counts_t configuration parameter, which
|
||||
* is provided to @ref sd_ble_enable.
|
||||
*
|
||||
* @note @ref sd_ble_opt_get is not supported for this option.
|
||||
* @note Please refer to SoftDevice Specification for more information on bandwidth configuration.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_COMMON_CONF_BW}
|
||||
* @endmscs
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Set successfully.
|
||||
* @retval ::BLE_ERROR_INVALID_ROLE The role is invalid.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid bandwidth configuration parameters.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED If the combination of role and bandwidth configuration is not supported.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t role; /**< BLE role of the connection, see @ref BLE_GAP_ROLES. */
|
||||
ble_conn_bw_t conn_bw; /**< Bandwidth configuration parameters. */
|
||||
} ble_common_opt_conn_bw_t;
|
||||
|
||||
/**
|
||||
* @brief Configuration of extended BLE connection events.
|
||||
*
|
||||
* When enabled the SoftDevice will dynamically extend the connection event when possible.
|
||||
*
|
||||
* The connection event length is controlled by the bandwidth configuration as set by @ref ble_common_opt_conn_bw_t.
|
||||
* The connection event can be extended if there is time to send another packet pair before the start of the next connection interval,
|
||||
* and if there are no conflicts with other BLE roles requesting radio time.
|
||||
*
|
||||
* @note @ref sd_ble_opt_get is not supported for this option.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t enable : 1; /**< Enable extended BLE connection events, disabled by default. */
|
||||
} ble_common_opt_conn_evt_ext_t;
|
||||
|
||||
/**@brief Option structure for common options. */
|
||||
typedef union
|
||||
{
|
||||
ble_common_opt_conn_bw_t conn_bw; /**< Parameters for the connection bandwidth option. */
|
||||
ble_common_opt_pa_lna_t pa_lna; /**< Parameters for controlling PA and LNA pin toggling. */
|
||||
ble_common_opt_conn_evt_ext_t conn_evt_ext; /**< Parameters for enabling extended connection events. */
|
||||
} ble_common_opt_t;
|
||||
|
||||
/**@brief Common BLE Option type, wrapping the module specific options. */
|
||||
typedef union
|
||||
{
|
||||
ble_common_opt_t common_opt; /**< COMMON options, opt_id in @ref BLE_COMMON_OPTS series. */
|
||||
ble_gap_opt_t gap_opt; /**< GAP option, opt_id in @ref BLE_GAP_OPTS series. */
|
||||
} ble_opt_t;
|
||||
|
||||
/**
|
||||
* @brief BLE bandwidth count parameters
|
||||
*
|
||||
* These parameters are used to configure the memory pools allocated within the SoftDevice for application packets
|
||||
* (both transmission and reception) for all connections.
|
||||
*
|
||||
* @note The sum of all three counts must add up to the sum of @ref ble_gap_enable_params_t::central_conn_count and
|
||||
* @ref ble_gap_enable_params_t::periph_conn_count in @ref ble_gap_enable_params_t.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t high_count; /**< Total number of high bandwidth TX or RX memory pools available to the application at runtime for all active connections. */
|
||||
uint8_t mid_count; /**< Total number of medium bandwidth TX or RX memory pools available to the application at runtime for all active connections. */
|
||||
uint8_t low_count; /**< Total number of low bandwidth TX or RX memory pools available to the application at runtime for all active connections. */
|
||||
} ble_conn_bw_count_t;
|
||||
|
||||
/**
|
||||
* @brief BLE bandwidth global memory pool configuration parameters
|
||||
*
|
||||
* These configuration parameters are used to set the amount of memory dedicated to application packets for
|
||||
* all connections. The application should specify the most demanding configuration for the intended use.
|
||||
*
|
||||
* Please refer to the SoftDevice Specification for more information on bandwidth configuration.
|
||||
*
|
||||
* @note Each connection created at runtime requires both a TX and an RX memory pool. By the use of these configuration
|
||||
* parameters, the application can decide the size and total number of the global memory pools that will be later
|
||||
* available for connection creation.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_COMMON_CONF_BW}
|
||||
* @endmscs
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
ble_conn_bw_count_t tx_counts; /**< Global memory pool configuration for transmission.*/
|
||||
ble_conn_bw_count_t rx_counts; /**< Global memory pool configuration for reception.*/
|
||||
} ble_conn_bw_counts_t;
|
||||
|
||||
/**
|
||||
* @brief BLE Common Initialization parameters.
|
||||
*
|
||||
* @note If @ref p_conn_bw_counts is NULL the SoftDevice will assume default bandwidth configuration for all connections.
|
||||
* To fit a custom bandwidth configuration requirement, the application developer may have to specify a custom memory
|
||||
* pool configuration here. See @ref ble_common_opt_conn_bw_t for bandwidth configuration of individual connections.
|
||||
* Please refer to the SoftDevice Specification for more information on bandwidth configuration.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t vs_uuid_count; /**< Maximum number of 128-bit, Vendor Specific UUID bases to allocate. */
|
||||
ble_conn_bw_counts_t *p_conn_bw_counts; /**< Bandwidth configuration parameters or NULL for defaults. */
|
||||
} ble_common_enable_params_t;
|
||||
|
||||
/**
|
||||
* @brief BLE Initialization parameters.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ble_common_enable_params_t common_enable_params; /**< Common init parameters @ref ble_common_enable_params_t. */
|
||||
ble_gap_enable_params_t gap_enable_params; /**< GAP init parameters @ref ble_gap_enable_params_t. */
|
||||
ble_gatt_enable_params_t gatt_enable_params; /**< GATT init parameters @ref ble_gatt_enable_params_t. */
|
||||
ble_gatts_enable_params_t gatts_enable_params; /**< GATTS init parameters @ref ble_gatts_enable_params_t. */
|
||||
} ble_enable_params_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_COMMON_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Enable the BLE stack
|
||||
*
|
||||
* @param[in, out] p_ble_enable_params Pointer to ble_enable_params_t
|
||||
* @param[in, out] p_app_ram_base Pointer to a variable containing the start address of the application RAM region
|
||||
* (APP_RAM_BASE). On return, this will contain the minimum start address of the application RAM region required by the
|
||||
* SoftDevice for this configuration. Calling @ref sd_ble_enable() with *p_app_ram_base set to 0 can be used during
|
||||
* development to find out how much memory a specific configuration will need.
|
||||
*
|
||||
* @note The memory requirement for a specific configuration will not increase between SoftDevices with the same major
|
||||
* version number.
|
||||
*
|
||||
* @note At runtime the IC's RAM is split into 2 regions: The SoftDevice RAM region is located between 0x20000000 and
|
||||
* APP_RAM_BASE-1 and the application's RAM region is located between APP_RAM_BASE and the start of the call stack.
|
||||
*
|
||||
* @details This call initializes the BLE stack, no other BLE related function can be called before this one.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_COMMON_ENABLE}
|
||||
* @endmscs
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The BLE stack has been initialized successfully.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE The BLE stack had already been initialized and cannot be reinitialized.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH One or more of the following is true:
|
||||
* - The specified Attribute Table size is too small.
|
||||
* The minimum acceptable size is defined by @ref BLE_GATTS_ATTR_TAB_SIZE_MIN.
|
||||
* - The specified Attribute Table size is not a multiple of 4.
|
||||
* - The device name length is invalid (must be between 0 and @ref BLE_GAP_DEVNAME_MAX_LEN).
|
||||
* - The device name length is too long for the given Attribute Table.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true:
|
||||
* - Incorrectly configured VS UUID count.
|
||||
* - Invalid connection count parameters.
|
||||
* - Invalid device name location (vloc).
|
||||
* - Invalid device name security mode.
|
||||
* - Invalid maximum ATT_MTU size, see @ref ble_gatt_enable_params_t::att_mtu.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED Device name security mode is not supported.
|
||||
* @retval ::NRF_ERROR_NO_MEM The amount of memory assigned to the SoftDevice by *p_app_ram_base is not
|
||||
* large enough to fit this configuration's memory requirement. Check *p_app_ram_base
|
||||
* and set the start address of the application RAM region accordingly.
|
||||
* @retval ::NRF_ERROR_CONN_COUNT The requested number of connections exceeds the maximum supported by the SoftDevice.
|
||||
* Please refer to the SoftDevice Specification for more information on role configuration.
|
||||
*/
|
||||
SVCALL(SD_BLE_ENABLE, uint32_t, sd_ble_enable(ble_enable_params_t * p_ble_enable_params, uint32_t * p_app_ram_base));
|
||||
|
||||
/**@brief Get an event from the pending events queue.
|
||||
*
|
||||
* @param[out] p_dest Pointer to buffer to be filled in with an event, or NULL to retrieve the event length.
|
||||
* This buffer <b>must be aligned to the extend defined by @ref BLE_EVT_PTR_ALIGNMENT</b>.
|
||||
* The buffer should be interpreted as a @ref ble_evt_t struct.
|
||||
* @param[in, out] p_len Pointer the length of the buffer, on return it is filled with the event length.
|
||||
*
|
||||
* @details This call allows the application to pull a BLE event from the BLE stack. The application is signaled that
|
||||
* an event is available from the BLE stack by the triggering of the SD_EVT_IRQn interrupt.
|
||||
* The application is free to choose whether to call this function from thread mode (main context) or directly from the
|
||||
* Interrupt Service Routine that maps to SD_EVT_IRQn. In any case however, and because the BLE stack runs at a higher
|
||||
* priority than the application, this function should be called in a loop (until @ref NRF_ERROR_NOT_FOUND is returned)
|
||||
* every time SD_EVT_IRQn is raised to ensure that all available events are pulled from the BLE stack. Failure to do so
|
||||
* could potentially leave events in the internal queue without the application being aware of this fact.
|
||||
*
|
||||
* Sizing the p_dest buffer is equally important, since the application needs to provide all the memory necessary for the event to
|
||||
* be copied into application memory. If the buffer provided is not large enough to fit the entire contents of the event,
|
||||
* @ref NRF_ERROR_DATA_SIZE will be returned and the application can then call again with a larger buffer size.
|
||||
* The maximum possible event length is defined by @ref BLE_EVT_LEN_MAX. The application may also "peek" the event length
|
||||
* by providing p_dest as a NULL pointer and inspecting the value of *p_len upon return:
|
||||
*
|
||||
* \code
|
||||
* uint16_t len;
|
||||
* errcode = sd_ble_evt_get(NULL, &len);
|
||||
* \endcode
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_COMMON_IRQ_EVT_MSC}
|
||||
* @mmsc{@ref BLE_COMMON_THREAD_EVT_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Event pulled and stored into the supplied buffer.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND No events ready to be pulled.
|
||||
* @retval ::NRF_ERROR_DATA_SIZE Event ready but could not fit into the supplied buffer.
|
||||
*/
|
||||
SVCALL(SD_BLE_EVT_GET, uint32_t, sd_ble_evt_get(uint8_t *p_dest, uint16_t *p_len));
|
||||
|
||||
|
||||
/**@brief Get the total number of available guaranteed application transmission packets for a particular connection.
|
||||
*
|
||||
* @details This call allows the application to obtain the total number of guaranteed application transmission packets
|
||||
* available for a connection. Please note that this does not return the number of free packets, but rather the total
|
||||
* amount of them for that particular connection. The application has two options to handle transmitting application packets:
|
||||
* - Use a simple arithmetic calculation: after connection creation time the application should use this function to
|
||||
* find out the total amount of guaranteed packets available to it and store it in a variable.
|
||||
* Every time a packet is successfully queued for a transmission on this connection using any of the exposed functions in
|
||||
* this BLE API, the application should decrement that variable. Conversely, whenever a @ref BLE_EVT_TX_COMPLETE event
|
||||
* with the conn_handle matching the particular connection is received by the application, it should retrieve the count
|
||||
* field in such event and add that number to the same variable storing the number of available guaranteed packets. This
|
||||
* mechanism allows the application to be aware at any time of the number of guaranteed application packets available for
|
||||
* each of the active connections, and therefore it can know with certainty whether it is possible to send more data or
|
||||
* it has to wait for a @ref BLE_EVT_TX_COMPLETE event before it proceeds.
|
||||
* The application can still pursue transmissions when the number of guaranteed application packets available is smaller
|
||||
* than or equal to zero, but successful queuing of the tranmsission is not guaranteed.
|
||||
* - Choose to simply not keep track of available packets at all, and instead handle the @ref BLE_ERROR_NO_TX_PACKETS error
|
||||
* by queueing the packet to be transmitted and try again as soon as a @ref BLE_EVT_TX_COMPLETE event arrives.
|
||||
*
|
||||
* The API functions that <b>may</b> consume an application packet depending on the parameters supplied to them can be found below:
|
||||
* - @ref sd_ble_gattc_write (write without response only)
|
||||
* - @ref sd_ble_gatts_hvx (notifications only)
|
||||
* - @ref sd_ble_l2cap_tx (all packets)
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[out] p_count Pointer to a uint8_t which will contain the number of application transmission packets upon
|
||||
* successful return.
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_COMMON_APP_BUFF_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Number of application transmission packets retrieved successfully.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
*/
|
||||
SVCALL(SD_BLE_TX_PACKET_COUNT_GET, uint32_t, sd_ble_tx_packet_count_get(uint16_t conn_handle, uint8_t *p_count));
|
||||
|
||||
|
||||
/**@brief Add a Vendor Specific base UUID.
|
||||
*
|
||||
* @details This call enables the application to add a vendor specific base UUID to the BLE stack's table, for later
|
||||
* use with all other modules and APIs. This then allows the application to use the shorter, 24-bit @ref ble_uuid_t
|
||||
* format when dealing with both 16-bit and 128-bit UUIDs without having to check for lengths and having split code
|
||||
* paths. This is accomplished by extending the grouping mechanism that the Bluetooth SIG standard base UUID uses
|
||||
* for all other 128-bit UUIDs. The type field in the @ref ble_uuid_t structure is an index (relative to
|
||||
* @ref BLE_UUID_TYPE_VENDOR_BEGIN) to the table populated by multiple calls to this function, and the uuid field
|
||||
* in the same structure contains the 2 bytes at indices 12 and 13. The number of possible 128-bit UUIDs available to
|
||||
* the application is therefore the number of Vendor Specific UUIDs added with the help of this function times 65536,
|
||||
* although restricted to modifying bytes 12 and 13 for each of the entries in the supplied array.
|
||||
*
|
||||
* @note Bytes 12 and 13 of the provided UUID will not be used internally, since those are always replaced by
|
||||
* the 16-bit uuid field in @ref ble_uuid_t.
|
||||
*
|
||||
* @note If a UUID is already present in the BLE stack's internal table, the corresponding index will be returned in
|
||||
* p_uuid_type along with an NRF_SUCCESS error code.
|
||||
*
|
||||
* @param[in] p_vs_uuid Pointer to a 16-octet (128-bit) little endian Vendor Specific UUID disregarding
|
||||
* bytes 12 and 13.
|
||||
* @param[out] p_uuid_type Pointer to a uint8_t where the type field in @ref ble_uuid_t corresponding to this UUID will be stored.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully added the Vendor Specific UUID.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR If p_vs_uuid or p_uuid_type is NULL or invalid.
|
||||
* @retval ::NRF_ERROR_NO_MEM If there are no more free slots for VS UUIDs.
|
||||
*/
|
||||
SVCALL(SD_BLE_UUID_VS_ADD, uint32_t, sd_ble_uuid_vs_add(ble_uuid128_t const *p_vs_uuid, uint8_t *p_uuid_type));
|
||||
|
||||
|
||||
/** @brief Decode little endian raw UUID bytes (16-bit or 128-bit) into a 24 bit @ref ble_uuid_t structure.
|
||||
*
|
||||
* @details The raw UUID bytes excluding bytes 12 and 13 (i.e. bytes 0-11 and 14-15) of p_uuid_le are compared
|
||||
* to the corresponding ones in each entry of the table of vendor specific UUIDs populated with @ref sd_ble_uuid_vs_add
|
||||
* to look for a match. If there is such a match, bytes 12 and 13 are returned as p_uuid->uuid and the index
|
||||
* relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN as p_uuid->type.
|
||||
*
|
||||
* @note If the UUID length supplied is 2, then the type set by this call will always be @ref BLE_UUID_TYPE_BLE.
|
||||
*
|
||||
* @param[in] uuid_le_len Length in bytes of the buffer pointed to by p_uuid_le (must be 2 or 16 bytes).
|
||||
* @param[in] p_uuid_le Pointer pointing to little endian raw UUID bytes.
|
||||
* @param[out] p_uuid Pointer to a @ref ble_uuid_t structure to be filled in.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully decoded into the @ref ble_uuid_t structure.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH Invalid UUID length.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND For a 128-bit UUID, no match in the populated table of UUIDs.
|
||||
*/
|
||||
SVCALL(SD_BLE_UUID_DECODE, uint32_t, sd_ble_uuid_decode(uint8_t uuid_le_len, uint8_t const *p_uuid_le, ble_uuid_t *p_uuid));
|
||||
|
||||
|
||||
/** @brief Encode a @ref ble_uuid_t structure into little endian raw UUID bytes (16-bit or 128-bit).
|
||||
*
|
||||
* @note The pointer to the destination buffer p_uuid_le may be NULL, in which case only the validity and size of p_uuid is computed.
|
||||
*
|
||||
* @param[in] p_uuid Pointer to a @ref ble_uuid_t structure that will be encoded into bytes.
|
||||
* @param[out] p_uuid_le_len Pointer to a uint8_t that will be filled with the encoded length (2 or 16 bytes).
|
||||
* @param[out] p_uuid_le Pointer to a buffer where the little endian raw UUID bytes (2 or 16) will be stored.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully encoded into the buffer.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid UUID type.
|
||||
*/
|
||||
SVCALL(SD_BLE_UUID_ENCODE, uint32_t, sd_ble_uuid_encode(ble_uuid_t const *p_uuid, uint8_t *p_uuid_le_len, uint8_t *p_uuid_le));
|
||||
|
||||
|
||||
/**@brief Get Version Information.
|
||||
*
|
||||
* @details This call allows the application to get the BLE stack version information.
|
||||
*
|
||||
* @param[out] p_version Pointer to a ble_version_t structure to be filled in.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Version information stored successfully.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_BUSY The BLE stack is busy (typically doing a locally-initiated disconnection procedure).
|
||||
*/
|
||||
SVCALL(SD_BLE_VERSION_GET, uint32_t, sd_ble_version_get(ble_version_t *p_version));
|
||||
|
||||
|
||||
/**@brief Provide a user memory block.
|
||||
*
|
||||
* @note This call can only be used as a response to a @ref BLE_EVT_USER_MEM_REQUEST event issued to the application.
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in,out] p_block Pointer to a user memory block structure.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_PEER_CANCEL_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_AUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_AUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_NOAUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully queued a response to the peer.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection state or no execute write request pending.
|
||||
* @retval ::NRF_ERROR_BUSY The BLE stack is busy. Retry at later time.
|
||||
*/
|
||||
SVCALL(SD_BLE_USER_MEM_REPLY, uint32_t, sd_ble_user_mem_reply(uint16_t conn_handle, ble_user_mem_block_t const *p_block));
|
||||
|
||||
/**@brief Set a BLE option.
|
||||
*
|
||||
* @details This call allows the application to set the value of an option.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GAP_PERIPH_BONDING_STATIC_PK_MSC}
|
||||
* @mmsc{@ref BLE_COMMON_CONF_BW}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] opt_id Option ID, see @ref BLE_COMMON_OPTS and @ref BLE_GAP_OPTS.
|
||||
* @param[in] p_opt Pointer to a ble_opt_t structure containing the option value.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Option set successfully.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Unable to set the parameter at this time.
|
||||
* @retval ::NRF_ERROR_BUSY The BLE stack is busy or the previous procedure has not completed.
|
||||
*/
|
||||
SVCALL(SD_BLE_OPT_SET, uint32_t, sd_ble_opt_set(uint32_t opt_id, ble_opt_t const *p_opt));
|
||||
|
||||
|
||||
/**@brief Get a BLE option.
|
||||
*
|
||||
* @details This call allows the application to retrieve the value of an option.
|
||||
*
|
||||
* @param[in] opt_id Option ID, see @ref BLE_COMMON_OPTS and @ref BLE_GAP_OPTS.
|
||||
* @param[out] p_opt Pointer to a ble_opt_t structure to be filled in.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Option retrieved successfully.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Unable to retrieve the parameter at this time.
|
||||
* @retval ::NRF_ERROR_BUSY The BLE stack is busy or the previous procedure has not completed.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED This option is not supported.
|
||||
*
|
||||
*/
|
||||
SVCALL(SD_BLE_OPT_GET, uint32_t, sd_ble_opt_get(uint32_t opt_id, ble_opt_t *p_opt));
|
||||
|
||||
/** @} */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* BLE_H__ */
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup BLE_COMMON
|
||||
@{
|
||||
@addtogroup nrf_error
|
||||
@{
|
||||
@ingroup BLE_COMMON
|
||||
@}
|
||||
|
||||
@defgroup ble_err General error codes
|
||||
@{
|
||||
|
||||
@brief General error code definitions for the BLE API.
|
||||
|
||||
@ingroup BLE_COMMON
|
||||
*/
|
||||
#ifndef NRF_BLE_ERR_H__
|
||||
#define NRF_BLE_ERR_H__
|
||||
|
||||
#include "nrf_error.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* @defgroup BLE_ERRORS Error Codes
|
||||
* @{ */
|
||||
#define BLE_ERROR_NOT_ENABLED (NRF_ERROR_STK_BASE_NUM+0x001) /**< @ref sd_ble_enable has not been called. */
|
||||
#define BLE_ERROR_INVALID_CONN_HANDLE (NRF_ERROR_STK_BASE_NUM+0x002) /**< Invalid connection handle. */
|
||||
#define BLE_ERROR_INVALID_ATTR_HANDLE (NRF_ERROR_STK_BASE_NUM+0x003) /**< Invalid attribute handle. */
|
||||
#define BLE_ERROR_NO_TX_PACKETS (NRF_ERROR_STK_BASE_NUM+0x004) /**< Not enough application packets available on this connection. */
|
||||
#define BLE_ERROR_INVALID_ROLE (NRF_ERROR_STK_BASE_NUM+0x005) /**< Invalid role. */
|
||||
#define BLE_ERROR_BLOCKED_BY_OTHER_LINKS (NRF_ERROR_STK_BASE_NUM+0x006) /**< The attempt to change link settings failed due to the scheduling of other links. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_ERROR_SUBRANGES Module specific error code subranges
|
||||
* @brief Assignment of subranges for module specific error codes.
|
||||
* @note For specific error codes, see ble_<module>.h or ble_error_<module>.h.
|
||||
* @{ */
|
||||
#define NRF_L2CAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x100) /**< L2CAP specific errors. */
|
||||
#define NRF_GAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x200) /**< GAP specific errors. */
|
||||
#define NRF_GATTC_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x300) /**< GATT client specific errors. */
|
||||
#define NRF_GATTS_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x400) /**< GATT server specific errors. */
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,222 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup BLE_GATT Generic Attribute Profile (GATT) Common
|
||||
@{
|
||||
@brief Common definitions and prototypes for the GATT interfaces.
|
||||
*/
|
||||
|
||||
#ifndef BLE_GATT_H__
|
||||
#define BLE_GATT_H__
|
||||
|
||||
#include "nrf_ble_types.h"
|
||||
#include "nrf_ble_ranges.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup BLE_GATT_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/** @brief Default MTU size, in bytes. */
|
||||
#define BLE_GATT_MTU_SIZE_DEFAULT 23
|
||||
|
||||
/**@brief Invalid Attribute Handle. */
|
||||
#define BLE_GATT_HANDLE_INVALID 0x0000
|
||||
|
||||
/**@brief First Attribute Handle. */
|
||||
#define BLE_GATT_HANDLE_START 0x0001
|
||||
|
||||
/**@brief Last Attribute Handle. */
|
||||
#define BLE_GATT_HANDLE_END 0xFFFF
|
||||
|
||||
/** @defgroup BLE_GATT_TIMEOUT_SOURCES GATT Timeout sources
|
||||
* @{ */
|
||||
#define BLE_GATT_TIMEOUT_SRC_PROTOCOL 0x00 /**< ATT Protocol timeout. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_WRITE_OPS GATT Write operations
|
||||
* @{ */
|
||||
#define BLE_GATT_OP_INVALID 0x00 /**< Invalid Operation. */
|
||||
#define BLE_GATT_OP_WRITE_REQ 0x01 /**< Write Request. */
|
||||
#define BLE_GATT_OP_WRITE_CMD 0x02 /**< Write Command. */
|
||||
#define BLE_GATT_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */
|
||||
#define BLE_GATT_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */
|
||||
#define BLE_GATT_OP_EXEC_WRITE_REQ 0x05 /**< Execute Write Request. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_EXEC_WRITE_FLAGS GATT Execute Write flags
|
||||
* @{ */
|
||||
#define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL 0x00 /**< Cancel prepared write. */
|
||||
#define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE 0x01 /**< Execute prepared write. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_HVX_TYPES GATT Handle Value operations
|
||||
* @{ */
|
||||
#define BLE_GATT_HVX_INVALID 0x00 /**< Invalid Operation. */
|
||||
#define BLE_GATT_HVX_NOTIFICATION 0x01 /**< Handle Value Notification. */
|
||||
#define BLE_GATT_HVX_INDICATION 0x02 /**< Handle Value Indication. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_STATUS_CODES GATT Status Codes
|
||||
* @{ */
|
||||
#define BLE_GATT_STATUS_SUCCESS 0x0000 /**< Success. */
|
||||
#define BLE_GATT_STATUS_UNKNOWN 0x0001 /**< Unknown or not applicable status. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID 0x0100 /**< ATT Error: Invalid Error Code. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID_HANDLE 0x0101 /**< ATT Error: Invalid Attribute Handle. */
|
||||
#define BLE_GATT_STATUS_ATTERR_READ_NOT_PERMITTED 0x0102 /**< ATT Error: Read not permitted. */
|
||||
#define BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED 0x0103 /**< ATT Error: Write not permitted. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID_PDU 0x0104 /**< ATT Error: Used in ATT as Invalid PDU. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION 0x0105 /**< ATT Error: Authenticated link required. */
|
||||
#define BLE_GATT_STATUS_ATTERR_REQUEST_NOT_SUPPORTED 0x0106 /**< ATT Error: Used in ATT as Request Not Supported. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID_OFFSET 0x0107 /**< ATT Error: Offset specified was past the end of the attribute. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_AUTHORIZATION 0x0108 /**< ATT Error: Used in ATT as Insufficient Authorisation. */
|
||||
#define BLE_GATT_STATUS_ATTERR_PREPARE_QUEUE_FULL 0x0109 /**< ATT Error: Used in ATT as Prepare Queue Full. */
|
||||
#define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND 0x010A /**< ATT Error: Used in ATT as Attribute not found. */
|
||||
#define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_LONG 0x010B /**< ATT Error: Attribute cannot be read or written using read/write blob requests. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_ENC_KEY_SIZE 0x010C /**< ATT Error: Encryption key size used is insufficient. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID_ATT_VAL_LENGTH 0x010D /**< ATT Error: Invalid value size. */
|
||||
#define BLE_GATT_STATUS_ATTERR_UNLIKELY_ERROR 0x010E /**< ATT Error: Very unlikely error. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION 0x010F /**< ATT Error: Encrypted link required. */
|
||||
#define BLE_GATT_STATUS_ATTERR_UNSUPPORTED_GROUP_TYPE 0x0110 /**< ATT Error: Attribute type is not a supported grouping attribute. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_RESOURCES 0x0111 /**< ATT Error: Encrypted link required. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_BEGIN 0x0112 /**< ATT Error: Reserved for Future Use range #1 begin. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_END 0x017F /**< ATT Error: Reserved for Future Use range #1 end. */
|
||||
#define BLE_GATT_STATUS_ATTERR_APP_BEGIN 0x0180 /**< ATT Error: Application range begin. */
|
||||
#define BLE_GATT_STATUS_ATTERR_APP_END 0x019F /**< ATT Error: Application range end. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_BEGIN 0x01A0 /**< ATT Error: Reserved for Future Use range #2 begin. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_END 0x01DF /**< ATT Error: Reserved for Future Use range #2 end. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_BEGIN 0x01E0 /**< ATT Error: Reserved for Future Use range #3 begin. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_END 0x01FC /**< ATT Error: Reserved for Future Use range #3 end. */
|
||||
#define BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR 0x01FD /**< ATT Common Profile and Service Error: Client Characteristic Configuration Descriptor improperly configured. */
|
||||
#define BLE_GATT_STATUS_ATTERR_CPS_PROC_ALR_IN_PROG 0x01FE /**< ATT Common Profile and Service Error: Procedure Already in Progress. */
|
||||
#define BLE_GATT_STATUS_ATTERR_CPS_OUT_OF_RANGE 0x01FF /**< ATT Common Profile and Service Error: Out Of Range. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_GATT_CPF_FORMATS Characteristic Presentation Formats
|
||||
* @note Found at http://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml
|
||||
* @{ */
|
||||
#define BLE_GATT_CPF_FORMAT_RFU 0x00 /**< Reserved For Future Use. */
|
||||
#define BLE_GATT_CPF_FORMAT_BOOLEAN 0x01 /**< Boolean. */
|
||||
#define BLE_GATT_CPF_FORMAT_2BIT 0x02 /**< Unsigned 2-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_NIBBLE 0x03 /**< Unsigned 4-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT8 0x04 /**< Unsigned 8-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT12 0x05 /**< Unsigned 12-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT16 0x06 /**< Unsigned 16-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT24 0x07 /**< Unsigned 24-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT32 0x08 /**< Unsigned 32-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT48 0x09 /**< Unsigned 48-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT64 0x0A /**< Unsigned 64-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT128 0x0B /**< Unsigned 128-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT8 0x0C /**< Signed 2-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT12 0x0D /**< Signed 12-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT16 0x0E /**< Signed 16-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT24 0x0F /**< Signed 24-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT32 0x10 /**< Signed 32-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT48 0x11 /**< Signed 48-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT64 0x12 /**< Signed 64-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT128 0x13 /**< Signed 128-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_FLOAT32 0x14 /**< IEEE-754 32-bit floating point. */
|
||||
#define BLE_GATT_CPF_FORMAT_FLOAT64 0x15 /**< IEEE-754 64-bit floating point. */
|
||||
#define BLE_GATT_CPF_FORMAT_SFLOAT 0x16 /**< IEEE-11073 16-bit SFLOAT. */
|
||||
#define BLE_GATT_CPF_FORMAT_FLOAT 0x17 /**< IEEE-11073 32-bit FLOAT. */
|
||||
#define BLE_GATT_CPF_FORMAT_DUINT16 0x18 /**< IEEE-20601 format. */
|
||||
#define BLE_GATT_CPF_FORMAT_UTF8S 0x19 /**< UTF-8 string. */
|
||||
#define BLE_GATT_CPF_FORMAT_UTF16S 0x1A /**< UTF-16 string. */
|
||||
#define BLE_GATT_CPF_FORMAT_STRUCT 0x1B /**< Opaque Structure. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_CPF_NAMESPACES GATT Bluetooth Namespaces
|
||||
* @{
|
||||
*/
|
||||
#define BLE_GATT_CPF_NAMESPACE_BTSIG 0x01 /**< Bluetooth SIG defined Namespace. */
|
||||
#define BLE_GATT_CPF_NAMESPACE_DESCRIPTION_UNKNOWN 0x0000 /**< Namespace Description Unknown. */
|
||||
/** @} */
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATT_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**
|
||||
* @brief BLE GATT initialization parameters.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t att_mtu; /**< Maximum size of ATT packet the SoftDevice can send or receive.
|
||||
If it is 0 then @ref BLE_GATT_MTU_SIZE_DEFAULT will be used.
|
||||
Otherwise @ref BLE_GATT_MTU_SIZE_DEFAULT is the minimum value.
|
||||
@mscs
|
||||
@mmsc{@ref BLE_GATTC_MTU_EXCHANGE}
|
||||
@mmsc{@ref BLE_GATTS_MTU_EXCHANGE}
|
||||
@endmscs
|
||||
*/
|
||||
} ble_gatt_enable_params_t;
|
||||
|
||||
/**@brief GATT Characteristic Properties. */
|
||||
typedef struct
|
||||
{
|
||||
/* Standard properties */
|
||||
uint8_t broadcast :1; /**< Broadcasting of the value permitted. */
|
||||
uint8_t read :1; /**< Reading the value permitted. */
|
||||
uint8_t write_wo_resp :1; /**< Writing the value with Write Command permitted. */
|
||||
uint8_t write :1; /**< Writing the value with Write Request permitted. */
|
||||
uint8_t notify :1; /**< Notications of the value permitted. */
|
||||
uint8_t indicate :1; /**< Indications of the value permitted. */
|
||||
uint8_t auth_signed_wr :1; /**< Writing the value with Signed Write Command permitted. */
|
||||
} ble_gatt_char_props_t;
|
||||
|
||||
/**@brief GATT Characteristic Extended Properties. */
|
||||
typedef struct
|
||||
{
|
||||
/* Extended properties */
|
||||
uint8_t reliable_wr :1; /**< Writing the value with Queued Write operations permitted. */
|
||||
uint8_t wr_aux :1; /**< Writing the Characteristic User Description descriptor permitted. */
|
||||
} ble_gatt_char_ext_props_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // BLE_GATT_H__
|
||||
|
||||
/** @} */
|
||||
|
|
@ -1,669 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup BLE_GATTC Generic Attribute Profile (GATT) Client
|
||||
@{
|
||||
@brief Definitions and prototypes for the GATT Client interface.
|
||||
*/
|
||||
|
||||
#ifndef BLE_GATTC_H__
|
||||
#define BLE_GATTC_H__
|
||||
|
||||
#include "nrf_ble_gatt.h"
|
||||
#include "nrf_ble_types.h"
|
||||
#include "nrf_ble_ranges.h"
|
||||
#include "nrf_svc.h"
|
||||
#include "nrf_error.h"
|
||||
#include "nrf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup BLE_GATTC_ENUMERATIONS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief GATTC API SVC numbers. */
|
||||
enum BLE_GATTC_SVCS
|
||||
{
|
||||
SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER = BLE_GATTC_SVC_BASE, /**< Primary Service Discovery. */
|
||||
SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, /**< Relationship Discovery. */
|
||||
SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, /**< Characteristic Discovery. */
|
||||
SD_BLE_GATTC_DESCRIPTORS_DISCOVER, /**< Characteristic Descriptor Discovery. */
|
||||
SD_BLE_GATTC_ATTR_INFO_DISCOVER, /**< Attribute Information Discovery. */
|
||||
SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, /**< Read Characteristic Value by UUID. */
|
||||
SD_BLE_GATTC_READ, /**< Generic read. */
|
||||
SD_BLE_GATTC_CHAR_VALUES_READ, /**< Read multiple Characteristic Values. */
|
||||
SD_BLE_GATTC_WRITE, /**< Generic write. */
|
||||
SD_BLE_GATTC_HV_CONFIRM, /**< Handle Value Confirmation. */
|
||||
SD_BLE_GATTC_EXCHANGE_MTU_REQUEST, /**< Exchange MTU Request. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief GATT Client Event IDs.
|
||||
*/
|
||||
enum BLE_GATTC_EVTS
|
||||
{
|
||||
BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP = BLE_GATTC_EVT_BASE, /**< Primary Service Discovery Response event. \n See @ref ble_gattc_evt_prim_srvc_disc_rsp_t. */
|
||||
BLE_GATTC_EVT_REL_DISC_RSP, /**< Relationship Discovery Response event. \n See @ref ble_gattc_evt_rel_disc_rsp_t. */
|
||||
BLE_GATTC_EVT_CHAR_DISC_RSP, /**< Characteristic Discovery Response event. \n See @ref ble_gattc_evt_char_disc_rsp_t. */
|
||||
BLE_GATTC_EVT_DESC_DISC_RSP, /**< Descriptor Discovery Response event. \n See @ref ble_gattc_evt_desc_disc_rsp_t. */
|
||||
BLE_GATTC_EVT_ATTR_INFO_DISC_RSP, /**< Attribute Information Response event. \n See @ref ble_gattc_evt_attr_info_disc_rsp_t. */
|
||||
BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP, /**< Read By UUID Response event. \n See @ref ble_gattc_evt_char_val_by_uuid_read_rsp_t. */
|
||||
BLE_GATTC_EVT_READ_RSP, /**< Read Response event. \n See @ref ble_gattc_evt_read_rsp_t. */
|
||||
BLE_GATTC_EVT_CHAR_VALS_READ_RSP, /**< Read multiple Response event. \n See @ref ble_gattc_evt_char_vals_read_rsp_t. */
|
||||
BLE_GATTC_EVT_WRITE_RSP, /**< Write Response event. \n See @ref ble_gattc_evt_write_rsp_t. */
|
||||
BLE_GATTC_EVT_HVX, /**< Handle Value Notification or Indication event. \n Confirm indication with @ref sd_ble_gattc_hv_confirm. \n See @ref ble_gattc_evt_hvx_t. */
|
||||
BLE_GATTC_EVT_EXCHANGE_MTU_RSP, /**< Exchange MTU Response event. \n See @ref ble_gattc_evt_exchange_mtu_rsp_t. */
|
||||
BLE_GATTC_EVT_TIMEOUT /**< Timeout event. \n See @ref ble_gattc_evt_timeout_t. */
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTC_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/** @defgroup BLE_ERRORS_GATTC SVC return values specific to GATTC
|
||||
* @{ */
|
||||
#define BLE_ERROR_GATTC_PROC_NOT_PERMITTED (NRF_GATTC_ERR_BASE + 0x000) /**< Procedure not Permitted. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATTC_ATTR_INFO_FORMAT Attribute Information Formats
|
||||
* @{ */
|
||||
#define BLE_GATTC_ATTR_INFO_FORMAT_16BIT 1 /**< 16-bit Attribute Information Format. */
|
||||
#define BLE_GATTC_ATTR_INFO_FORMAT_128BIT 2 /**< 128-bit Attribute Information Format. */
|
||||
/** @} */
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTC_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**@brief Operation Handle Range. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t start_handle; /**< Start Handle. */
|
||||
uint16_t end_handle; /**< End Handle. */
|
||||
} ble_gattc_handle_range_t;
|
||||
|
||||
|
||||
/**@brief GATT service. */
|
||||
typedef struct
|
||||
{
|
||||
ble_uuid_t uuid; /**< Service UUID. */
|
||||
ble_gattc_handle_range_t handle_range; /**< Service Handle Range. */
|
||||
} ble_gattc_service_t;
|
||||
|
||||
|
||||
/**@brief GATT include. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Include Handle. */
|
||||
ble_gattc_service_t included_srvc; /**< Handle of the included service. */
|
||||
} ble_gattc_include_t;
|
||||
|
||||
|
||||
/**@brief GATT characteristic. */
|
||||
typedef struct
|
||||
{
|
||||
ble_uuid_t uuid; /**< Characteristic UUID. */
|
||||
ble_gatt_char_props_t char_props; /**< Characteristic Properties. */
|
||||
uint8_t char_ext_props : 1; /**< Extended properties present. */
|
||||
uint16_t handle_decl; /**< Handle of the Characteristic Declaration. */
|
||||
uint16_t handle_value; /**< Handle of the Characteristic Value. */
|
||||
} ble_gattc_char_t;
|
||||
|
||||
|
||||
/**@brief GATT descriptor. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Descriptor Handle. */
|
||||
ble_uuid_t uuid; /**< Descriptor UUID. */
|
||||
} ble_gattc_desc_t;
|
||||
|
||||
|
||||
/**@brief Write Parameters. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t write_op; /**< Write Operation to be performed, see @ref BLE_GATT_WRITE_OPS. */
|
||||
uint8_t flags; /**< Flags, see @ref BLE_GATT_EXEC_WRITE_FLAGS. */
|
||||
uint16_t handle; /**< Handle to the attribute to be written. */
|
||||
uint16_t offset; /**< Offset in bytes. @note For WRITE_CMD and WRITE_REQ, offset must be 0. */
|
||||
uint16_t len; /**< Length of data in bytes. */
|
||||
uint8_t const *p_value; /**< Pointer to the value data. */
|
||||
} ble_gattc_write_params_t;
|
||||
|
||||
/**@brief Attribute Information for 16-bit Attribute UUID. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute handle. */
|
||||
ble_uuid_t uuid; /**< 16-bit Attribute UUID. */
|
||||
} ble_gattc_attr_info16_t;
|
||||
|
||||
/**@brief Attribute Information for 128-bit Attribute UUID. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute handle. */
|
||||
ble_uuid128_t uuid; /**< 128-bit Attribute UUID. */
|
||||
} ble_gattc_attr_info128_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t count; /**< Service count. */
|
||||
ble_gattc_service_t services[1]; /**< Service data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_prim_srvc_disc_rsp_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_REL_DISC_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t count; /**< Include count. */
|
||||
ble_gattc_include_t includes[1]; /**< Include data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_rel_disc_rsp_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_DISC_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t count; /**< Characteristic count. */
|
||||
ble_gattc_char_t chars[1]; /**< Characteristic data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_char_disc_rsp_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_DESC_DISC_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t count; /**< Descriptor count. */
|
||||
ble_gattc_desc_t descs[1]; /**< Descriptor data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_desc_disc_rsp_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_ATTR_INFO_DISC_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t count; /**< Attribute count. */
|
||||
uint8_t format; /**< Attribute information format, see @ref BLE_GATTC_ATTR_INFO_FORMAT. */
|
||||
union {
|
||||
ble_gattc_attr_info16_t attr_info16[1]; /**< Attribute information for 16-bit Attribute UUID.
|
||||
@note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
ble_gattc_attr_info128_t attr_info128[1]; /**< Attribute information for 128-bit Attribute UUID.
|
||||
@note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} info; /**< Attribute information union. */
|
||||
} ble_gattc_evt_attr_info_disc_rsp_t;
|
||||
|
||||
/**@brief GATT read by UUID handle value pair. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute Handle. */
|
||||
uint8_t *p_value; /**< Pointer to the Attribute Value, length is available in @ref ble_gattc_evt_char_val_by_uuid_read_rsp_t::value_len. */
|
||||
} ble_gattc_handle_value_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t count; /**< Handle-Value Pair Count. */
|
||||
uint16_t value_len; /**< Length of the value in Handle-Value(s) list. */
|
||||
uint8_t handle_value[1]; /**< Handle-Value(s) list. To iterate through the list use @ref sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter.
|
||||
@note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_char_val_by_uuid_read_rsp_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_READ_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute Handle. */
|
||||
uint16_t offset; /**< Offset of the attribute data. */
|
||||
uint16_t len; /**< Attribute data length. */
|
||||
uint8_t data[1]; /**< Attribute data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_read_rsp_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_VALS_READ_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t len; /**< Concatenated Attribute values length. */
|
||||
uint8_t values[1]; /**< Attribute values. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_char_vals_read_rsp_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_WRITE_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute Handle. */
|
||||
uint8_t write_op; /**< Type of write operation, see @ref BLE_GATT_WRITE_OPS. */
|
||||
uint16_t offset; /**< Data offset. */
|
||||
uint16_t len; /**< Data length. */
|
||||
uint8_t data[1]; /**< Data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_write_rsp_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_HVX. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Handle to which the HVx operation applies. */
|
||||
uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */
|
||||
uint16_t len; /**< Attribute data length. */
|
||||
uint8_t data[1]; /**< Attribute data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gattc_evt_hvx_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_EXCHANGE_MTU_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t server_rx_mtu; /**< Server RX MTU size. */
|
||||
} ble_gattc_evt_exchange_mtu_rsp_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTC_EVT_TIMEOUT. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */
|
||||
} ble_gattc_evt_timeout_t;
|
||||
|
||||
/**@brief GATTC event structure. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t conn_handle; /**< Connection Handle on which event occured. */
|
||||
uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */
|
||||
uint16_t error_handle; /**< In case of error: The handle causing the error. In all other cases @ref BLE_GATT_HANDLE_INVALID. */
|
||||
union
|
||||
{
|
||||
ble_gattc_evt_prim_srvc_disc_rsp_t prim_srvc_disc_rsp; /**< Primary Service Discovery Response Event Parameters. */
|
||||
ble_gattc_evt_rel_disc_rsp_t rel_disc_rsp; /**< Relationship Discovery Response Event Parameters. */
|
||||
ble_gattc_evt_char_disc_rsp_t char_disc_rsp; /**< Characteristic Discovery Response Event Parameters. */
|
||||
ble_gattc_evt_desc_disc_rsp_t desc_disc_rsp; /**< Descriptor Discovery Response Event Parameters. */
|
||||
ble_gattc_evt_char_val_by_uuid_read_rsp_t char_val_by_uuid_read_rsp; /**< Characteristic Value Read by UUID Response Event Parameters. */
|
||||
ble_gattc_evt_read_rsp_t read_rsp; /**< Read Response Event Parameters. */
|
||||
ble_gattc_evt_char_vals_read_rsp_t char_vals_read_rsp; /**< Characteristic Values Read Response Event Parameters. */
|
||||
ble_gattc_evt_write_rsp_t write_rsp; /**< Write Response Event Parameters. */
|
||||
ble_gattc_evt_hvx_t hvx; /**< Handle Value Notification/Indication Event Parameters. */
|
||||
ble_gattc_evt_exchange_mtu_rsp_t exchange_mtu_rsp; /**< Exchange MTU Response Event Parameters. */
|
||||
ble_gattc_evt_timeout_t timeout; /**< Timeout Event Parameters. */
|
||||
ble_gattc_evt_attr_info_disc_rsp_t attr_info_disc_rsp; /**< Attribute Information Discovery Event Parameters. */
|
||||
} params; /**< Event Parameters. @note Only valid if @ref gatt_status == @ref BLE_GATT_STATUS_SUCCESS. */
|
||||
} ble_gattc_evt_t;
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTC_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Initiate or continue a GATT Primary Service Discovery procedure.
|
||||
*
|
||||
* @details This function initiates or resumes a Primary Service discovery procedure, starting from the supplied handle.
|
||||
* If the last service has not been reached, this function must be called again with an updated start handle value to continue the search.
|
||||
*
|
||||
* @note If any of the discovered services have 128-bit UUIDs which are not present in the table provided to ble_vs_uuids_assign, a UUID structure with
|
||||
* type @ref BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_PRIM_SRVC_DISC_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] start_handle Handle to start searching from.
|
||||
* @param[in] p_srvc_uuid Pointer to the service UUID to be found. If it is NULL, all primary services will be returned.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully started or resumed the Primary Service Discovery procedure.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER, uint32_t, sd_ble_gattc_primary_services_discover(uint16_t conn_handle, uint16_t start_handle, ble_uuid_t const *p_srvc_uuid));
|
||||
|
||||
|
||||
/**@brief Initiate or continue a GATT Relationship Discovery procedure.
|
||||
*
|
||||
* @details This function initiates or resumes the Find Included Services sub-procedure. If the last included service has not been reached,
|
||||
* this must be called again with an updated handle range to continue the search.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_REL_DISC_RSP}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_REL_DISC_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully started or resumed the Relationship Discovery procedure.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, uint32_t, sd_ble_gattc_relationships_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range));
|
||||
|
||||
|
||||
/**@brief Initiate or continue a GATT Characteristic Discovery procedure.
|
||||
*
|
||||
* @details This function initiates or resumes a Characteristic discovery procedure. If the last Characteristic has not been reached,
|
||||
* this must be called again with an updated handle range to continue the discovery.
|
||||
*
|
||||
* @note If any of the discovered characteristics have 128-bit UUIDs which are not present in the table provided to ble_vs_uuids_assign, a UUID structure with
|
||||
* type @ref BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_CHAR_DISC_RSP}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_CHAR_DISC_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully started or resumed the Characteristic Discovery procedure.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, uint32_t, sd_ble_gattc_characteristics_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range));
|
||||
|
||||
|
||||
/**@brief Initiate or continue a GATT Characteristic Descriptor Discovery procedure.
|
||||
*
|
||||
* @details This function initiates or resumes a Characteristic Descriptor discovery procedure. If the last Descriptor has not been reached,
|
||||
* this must be called again with an updated handle range to continue the discovery.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_DESC_DISC_RSP}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_DESC_DISC_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_handle_range A pointer to the range of handles of the Characteristic to perform this procedure on.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully started or resumed the Descriptor Discovery procedure.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_DESCRIPTORS_DISCOVER, uint32_t, sd_ble_gattc_descriptors_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range));
|
||||
|
||||
|
||||
/**@brief Initiate or continue a GATT Read using Characteristic UUID procedure.
|
||||
*
|
||||
* @details This function initiates or resumes a Read using Characteristic UUID procedure. If the last Characteristic has not been reached,
|
||||
* this must be called again with an updated handle range to continue the discovery.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_READ_UUID_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_uuid Pointer to a Characteristic value UUID to read.
|
||||
* @param[in] p_handle_range A pointer to the range of handles to perform this procedure on.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully started or resumed the Read using Characteristic UUID procedure.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, uint32_t, sd_ble_gattc_char_value_by_uuid_read(uint16_t conn_handle, ble_uuid_t const *p_uuid, ble_gattc_handle_range_t const *p_handle_range));
|
||||
|
||||
|
||||
/**@brief Initiate or continue a GATT Read (Long) Characteristic or Descriptor procedure.
|
||||
*
|
||||
* @details This function initiates or resumes a GATT Read (Long) Characteristic or Descriptor procedure. If the Characteristic or Descriptor
|
||||
* to be read is longer than ATT_MTU - 1, this function must be called multiple times with appropriate offset to read the
|
||||
* complete value.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_READ_RSP}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_VALUE_READ_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] handle The handle of the attribute to be read.
|
||||
* @param[in] offset Offset into the attribute value to be read.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully started or resumed the Read (Long) procedure.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
|
||||
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_READ, uint32_t, sd_ble_gattc_read(uint16_t conn_handle, uint16_t handle, uint16_t offset));
|
||||
|
||||
|
||||
/**@brief Initiate a GATT Read Multiple Characteristic Values procedure.
|
||||
*
|
||||
* @details This function initiates a GATT Read Multiple Characteristic Values procedure.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_CHAR_VALS_READ_RSP}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_READ_MULT_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_handles A pointer to the handle(s) of the attribute(s) to be read.
|
||||
* @param[in] handle_count The number of handles in p_handles.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully started the Read Multiple Characteristic Values procedure.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_CHAR_VALUES_READ, uint32_t, sd_ble_gattc_char_values_read(uint16_t conn_handle, uint16_t const *p_handles, uint16_t handle_count));
|
||||
|
||||
|
||||
/**@brief Perform a Write (Characteristic Value or Descriptor, with or without response, signed or not, long or reliable) procedure.
|
||||
*
|
||||
* @details This function can perform all write procedures described in GATT.
|
||||
*
|
||||
* @note It is important to note that a write without response will <b>consume an application buffer</b>, and will therefore
|
||||
* generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted. A write (with response) on the other hand will use the
|
||||
* standard client internal buffer and thus will only generate a @ref BLE_GATTC_EVT_WRITE_RSP event as soon as the write response
|
||||
* has been received from the peer. Please see the documentation of @ref sd_ble_tx_packet_count_get for more details.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_WRITE_RSP, Generated when using write request or queued writes.}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_VALUE_WRITE_MSC}
|
||||
* @mmsc{@ref BLE_GATTC_VALUE_LONG_WRITE_MSC}
|
||||
* @mmsc{@ref BLE_GATTC_VALUE_RELIABLE_WRITE_MSC}
|
||||
* @mmsc{@ref BLE_COMMON_APP_BUFF_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_write_params A pointer to a write parameters structure.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully started the Write procedure.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Procedure already in progress.
|
||||
* @retval ::BLE_ERROR_NO_TX_PACKETS No available application packets for this connection.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_WRITE, uint32_t, sd_ble_gattc_write(uint16_t conn_handle, ble_gattc_write_params_t const *p_write_params));
|
||||
|
||||
|
||||
/**@brief Send a Handle Value Confirmation to the GATT Server.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_HVI_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] handle The handle of the attribute in the indication.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully queued the Handle Value Confirmation for transmission.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no Indication pending to be confirmed.
|
||||
* @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_HV_CONFIRM, uint32_t, sd_ble_gattc_hv_confirm(uint16_t conn_handle, uint16_t handle));
|
||||
|
||||
/**@brief Discovers information about a range of attributes on a GATT server.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_ATTR_INFO_DISC_RSP, Generated when information about a range of attributes has been received.}
|
||||
* @endevents
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_handle_range The range of handles to request information about.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully started an attribute information discovery procedure.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid connection state
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_ATTR_INFO_DISCOVER, uint32_t, sd_ble_gattc_attr_info_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * p_handle_range));
|
||||
|
||||
/**@brief Start an ATT_MTU exchange by sending an Exchange MTU Request to the server.
|
||||
*
|
||||
* @details The SoftDevice sets ATT_MTU to the minimum of:
|
||||
* - The Client RX MTU value, and
|
||||
* - The Server RX MTU value from @ref BLE_GATTC_EVT_EXCHANGE_MTU_RSP.
|
||||
*
|
||||
* However, the SoftDevice never sets ATT_MTU lower than @ref BLE_GATT_MTU_SIZE_DEFAULT.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_EXCHANGE_MTU_RSP}
|
||||
* @event{@ref BLE_EVT_DATA_LENGTH_CHANGED, Generated if a data length update procedure is performed after the ATT_MTU exchange.}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTC_MTU_EXCHANGE}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] client_rx_mtu Client RX MTU size.
|
||||
* - The minimum value is @ref BLE_GATT_MTU_SIZE_DEFAULT.
|
||||
* - The maximum value is @ref ble_gatt_enable_params_t::att_mtu.
|
||||
* - The value must be equal to Server RX MTU size given in @ref sd_ble_gatts_exchange_mtu_reply
|
||||
* if an ATT_MTU exchange has already been performed in the other direction.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully sent request to the server.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid connection state or an ATT_MTU exchange was already requested once.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid Client RX MTU size supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_EXCHANGE_MTU_REQUEST, uint32_t, sd_ble_gattc_exchange_mtu_request(uint16_t conn_handle, uint16_t client_rx_mtu));
|
||||
|
||||
/**@brief Iterate through Handle-Value(s) list in @ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP event.
|
||||
*
|
||||
* @param[in] p_gattc_evt Pointer to event buffer containing @ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP event.
|
||||
* @note If the buffer contains different event, behavior is undefined.
|
||||
* @param[in,out] p_iter Iterator, points to @ref ble_gattc_handle_value_t structure that will be filled in with
|
||||
* the next Handle-Value pair in each iteration. If the function returns other than
|
||||
* @ref NRF_SUCCESS, it will not be changed.
|
||||
* - To start iteration, initialize the structure to zero.
|
||||
* - To continue, pass the value from previous iteration.
|
||||
*
|
||||
* \code
|
||||
* ble_gattc_handle_value_t iter;
|
||||
* memset(&iter, 0, sizeof(ble_gattc_handle_value_t));
|
||||
* while (sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter(&ble_evt.evt.gattc_evt, &iter) == NRF_SUCCESS)
|
||||
* {
|
||||
* app_handle = iter.handle;
|
||||
* memcpy(app_value, iter.p_value, ble_evt.evt.gattc_evt.params.char_val_by_uuid_read_rsp.value_len);
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully retrieved the next Handle-Value pair.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND No more Handle-Value pairs available in the list.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter(ble_gattc_evt_t *p_gattc_evt, ble_gattc_handle_value_t *p_iter);
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
__STATIC_INLINE uint32_t sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter(ble_gattc_evt_t *p_gattc_evt, ble_gattc_handle_value_t *p_iter)
|
||||
{
|
||||
uint32_t value_len = p_gattc_evt->params.char_val_by_uuid_read_rsp.value_len;
|
||||
uint8_t *p_first = p_gattc_evt->params.char_val_by_uuid_read_rsp.handle_value;
|
||||
uint8_t *p_next = p_iter->p_value ? p_iter->p_value + value_len : p_first;
|
||||
|
||||
if ((p_next - p_first) / (sizeof(uint16_t) + value_len) < p_gattc_evt->params.char_val_by_uuid_read_rsp.count)
|
||||
{
|
||||
p_iter->handle = (uint16_t)p_next[1] << 8 | p_next[0];
|
||||
p_iter->p_value = p_next + sizeof(uint16_t);
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NRF_ERROR_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SUPPRESS_INLINE_IMPLEMENTATION */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* BLE_GATTC_H__ */
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,778 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup BLE_GATTS Generic Attribute Profile (GATT) Server
|
||||
@{
|
||||
@brief Definitions and prototypes for the GATTS interface.
|
||||
*/
|
||||
|
||||
#ifndef BLE_GATTS_H__
|
||||
#define BLE_GATTS_H__
|
||||
|
||||
#include "nrf_ble_types.h"
|
||||
#include "nrf_ble_ranges.h"
|
||||
#include "nrf_ble_l2cap.h"
|
||||
#include "nrf_ble_gap.h"
|
||||
#include "nrf_ble_gatt.h"
|
||||
#include "nrf_svc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup BLE_GATTS_ENUMERATIONS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**
|
||||
* @brief GATTS API SVC numbers.
|
||||
*/
|
||||
enum BLE_GATTS_SVCS
|
||||
{
|
||||
SD_BLE_GATTS_SERVICE_ADD = BLE_GATTS_SVC_BASE, /**< Add a service. */
|
||||
SD_BLE_GATTS_INCLUDE_ADD, /**< Add an included service. */
|
||||
SD_BLE_GATTS_CHARACTERISTIC_ADD, /**< Add a characteristic. */
|
||||
SD_BLE_GATTS_DESCRIPTOR_ADD, /**< Add a generic attribute. */
|
||||
SD_BLE_GATTS_VALUE_SET, /**< Set an attribute value. */
|
||||
SD_BLE_GATTS_VALUE_GET, /**< Get an attribute value. */
|
||||
SD_BLE_GATTS_HVX, /**< Handle Value Notification or Indication. */
|
||||
SD_BLE_GATTS_SERVICE_CHANGED, /**< Perform a Service Changed Indication to one or more peers. */
|
||||
SD_BLE_GATTS_RW_AUTHORIZE_REPLY, /**< Reply to an authorization request for a read or write operation on one or more attributes. */
|
||||
SD_BLE_GATTS_SYS_ATTR_SET, /**< Set the persistent system attributes for a connection. */
|
||||
SD_BLE_GATTS_SYS_ATTR_GET, /**< Retrieve the persistent system attributes. */
|
||||
SD_BLE_GATTS_INITIAL_USER_HANDLE_GET, /**< Retrieve the first valid user handle. */
|
||||
SD_BLE_GATTS_ATTR_GET, /**< Retrieve the UUID and/or metadata of an attribute. */
|
||||
SD_BLE_GATTS_EXCHANGE_MTU_REPLY /**< Reply to Exchange MTU Request. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief GATT Server Event IDs.
|
||||
*/
|
||||
enum BLE_GATTS_EVTS
|
||||
{
|
||||
BLE_GATTS_EVT_WRITE = BLE_GATTS_EVT_BASE, /**< Write operation performed. \n See @ref ble_gatts_evt_write_t. */
|
||||
BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST, /**< Read/Write Authorization request. \n Reply with @ref sd_ble_gatts_rw_authorize_reply. \n See @ref ble_gatts_evt_rw_authorize_request_t. */
|
||||
BLE_GATTS_EVT_SYS_ATTR_MISSING, /**< A persistent system attribute access is pending. \n Respond with @ref sd_ble_gatts_sys_attr_set. \n See @ref ble_gatts_evt_sys_attr_missing_t. */
|
||||
BLE_GATTS_EVT_HVC, /**< Handle Value Confirmation. \n See @ref ble_gatts_evt_hvc_t. */
|
||||
BLE_GATTS_EVT_SC_CONFIRM, /**< Service Changed Confirmation. No additional event structure applies. */
|
||||
BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST, /**< Exchange MTU Request. \n Reply with @ref sd_ble_gatts_exchange_mtu_reply. \n See @ref ble_gatts_evt_exchange_mtu_request_t. */
|
||||
BLE_GATTS_EVT_TIMEOUT /**< Peer failed to resonpond to an ATT request in time. \n See @ref ble_gatts_evt_timeout_t. */
|
||||
};
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTS_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/** @defgroup BLE_ERRORS_GATTS SVC return values specific to GATTS
|
||||
* @{ */
|
||||
#define BLE_ERROR_GATTS_INVALID_ATTR_TYPE (NRF_GATTS_ERR_BASE + 0x000) /**< Invalid attribute type. */
|
||||
#define BLE_ERROR_GATTS_SYS_ATTR_MISSING (NRF_GATTS_ERR_BASE + 0x001) /**< System Attributes missing. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATTS_ATTR_LENS_MAX Maximum attribute lengths
|
||||
* @{ */
|
||||
#define BLE_GATTS_FIX_ATTR_LEN_MAX (510) /**< Maximum length for fixed length Attribute Values. */
|
||||
#define BLE_GATTS_VAR_ATTR_LEN_MAX (512) /**< Maximum length for variable length Attribute Values. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATTS_SRVC_TYPES GATT Server Service Types
|
||||
* @{ */
|
||||
#define BLE_GATTS_SRVC_TYPE_INVALID 0x00 /**< Invalid Service Type. */
|
||||
#define BLE_GATTS_SRVC_TYPE_PRIMARY 0x01 /**< Primary Service. */
|
||||
#define BLE_GATTS_SRVC_TYPE_SECONDARY 0x02 /**< Secondary Type. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_GATTS_ATTR_TYPES GATT Server Attribute Types
|
||||
* @{ */
|
||||
#define BLE_GATTS_ATTR_TYPE_INVALID 0x00 /**< Invalid Attribute Type. */
|
||||
#define BLE_GATTS_ATTR_TYPE_PRIM_SRVC_DECL 0x01 /**< Primary Service Declaration. */
|
||||
#define BLE_GATTS_ATTR_TYPE_SEC_SRVC_DECL 0x02 /**< Secondary Service Declaration. */
|
||||
#define BLE_GATTS_ATTR_TYPE_INC_DECL 0x03 /**< Include Declaration. */
|
||||
#define BLE_GATTS_ATTR_TYPE_CHAR_DECL 0x04 /**< Characteristic Declaration. */
|
||||
#define BLE_GATTS_ATTR_TYPE_CHAR_VAL 0x05 /**< Characteristic Value. */
|
||||
#define BLE_GATTS_ATTR_TYPE_DESC 0x06 /**< Descriptor. */
|
||||
#define BLE_GATTS_ATTR_TYPE_OTHER 0x07 /**< Other, non-GATT specific type. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_GATTS_OPS GATT Server Operations
|
||||
* @{ */
|
||||
#define BLE_GATTS_OP_INVALID 0x00 /**< Invalid Operation. */
|
||||
#define BLE_GATTS_OP_WRITE_REQ 0x01 /**< Write Request. */
|
||||
#define BLE_GATTS_OP_WRITE_CMD 0x02 /**< Write Command. */
|
||||
#define BLE_GATTS_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */
|
||||
#define BLE_GATTS_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */
|
||||
#define BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL 0x05 /**< Execute Write Request: Cancel all prepared writes. */
|
||||
#define BLE_GATTS_OP_EXEC_WRITE_REQ_NOW 0x06 /**< Execute Write Request: Immediately execute all prepared writes. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATTS_VLOCS GATT Value Locations
|
||||
* @{ */
|
||||
#define BLE_GATTS_VLOC_INVALID 0x00 /**< Invalid Location. */
|
||||
#define BLE_GATTS_VLOC_STACK 0x01 /**< Attribute Value is located in stack memory, no user memory is required. */
|
||||
#define BLE_GATTS_VLOC_USER 0x02 /**< Attribute Value is located in user memory. This requires the user to maintain a valid buffer through the lifetime of the attribute, since the stack
|
||||
will read and write directly to the memory using the pointer provided in the APIs. There are no alignment requirements for the buffer. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATTS_AUTHORIZE_TYPES GATT Server Authorization Types
|
||||
* @{ */
|
||||
#define BLE_GATTS_AUTHORIZE_TYPE_INVALID 0x00 /**< Invalid Type. */
|
||||
#define BLE_GATTS_AUTHORIZE_TYPE_READ 0x01 /**< Authorize a Read Operation. */
|
||||
#define BLE_GATTS_AUTHORIZE_TYPE_WRITE 0x02 /**< Authorize a Write Request Operation. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATTS_SYS_ATTR_FLAGS System Attribute Flags
|
||||
* @{ */
|
||||
#define BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS (1 << 0) /**< Restrict system attributes to system services only. */
|
||||
#define BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS (1 << 1) /**< Restrict system attributes to user services only. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATTS_ATTR_TAB_SIZE Attribute Table size
|
||||
* @{
|
||||
*/
|
||||
#define BLE_GATTS_ATTR_TAB_SIZE_MIN 248 /**< Minimum Attribute Table size */
|
||||
#define BLE_GATTS_ATTR_TAB_SIZE_DEFAULT 0x0000 /**< Default Attribute Table size (0x580 bytes for this version of the SoftDevice). */
|
||||
/** @} */
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTS_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**
|
||||
* @brief BLE GATTS initialization parameters.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t service_changed:1; /**< Include the Service Changed characteristic in the Attribute Table. */
|
||||
uint32_t attr_tab_size; /**< Attribute Table size in bytes. The size must be a multiple of 4. @ref BLE_GATTS_ATTR_TAB_SIZE_DEFAULT is used to set the default size. */
|
||||
} ble_gatts_enable_params_t;
|
||||
|
||||
/**@brief Attribute metadata. */
|
||||
typedef struct
|
||||
{
|
||||
ble_gap_conn_sec_mode_t read_perm; /**< Read permissions. */
|
||||
ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */
|
||||
uint8_t vlen :1; /**< Variable length attribute. */
|
||||
uint8_t vloc :2; /**< Value location, see @ref BLE_GATTS_VLOCS.*/
|
||||
uint8_t rd_auth :1; /**< Read authorization and value will be requested from the application on every read operation. */
|
||||
uint8_t wr_auth :1; /**< Write authorization will be requested from the application on every Write Request operation (but not Write Command). */
|
||||
} ble_gatts_attr_md_t;
|
||||
|
||||
|
||||
/**@brief GATT Attribute. */
|
||||
typedef struct
|
||||
{
|
||||
ble_uuid_t *p_uuid; /**< Pointer to the attribute UUID. */
|
||||
ble_gatts_attr_md_t *p_attr_md; /**< Pointer to the attribute metadata structure. */
|
||||
uint16_t init_len; /**< Initial attribute value length in bytes. */
|
||||
uint16_t init_offs; /**< Initial attribute value offset in bytes. If different from zero, the first init_offs bytes of the attribute value will be left uninitialized. */
|
||||
uint16_t max_len; /**< Maximum attribute value length in bytes, see @ref BLE_GATTS_ATTR_LENS_MAX for maximum values. */
|
||||
uint8_t* p_value; /**< Pointer to the attribute data. Please note that if the @ref BLE_GATTS_VLOC_USER value location is selected in the attribute metadata, this will have to point to a buffer
|
||||
that remains valid through the lifetime of the attribute. This excludes usage of automatic variables that may go out of scope or any other temporary location.
|
||||
The stack may access that memory directly without the application's knowledge. For writable characteristics, this value must not be a location in flash memory.*/
|
||||
} ble_gatts_attr_t;
|
||||
|
||||
/**@brief GATT Attribute Value. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t len; /**< Length in bytes to be written or read. Length in bytes written or read after successful return.*/
|
||||
uint16_t offset; /**< Attribute value offset. */
|
||||
uint8_t *p_value; /**< Pointer to where value is stored or will be stored.
|
||||
If value is stored in user memory, only the attribute length is updated when p_value == NULL.
|
||||
Set to NULL when reading to obtain the complete length of the attribute value */
|
||||
} ble_gatts_value_t;
|
||||
|
||||
|
||||
/**@brief GATT Characteristic Presentation Format. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t format; /**< Format of the value, see @ref BLE_GATT_CPF_FORMATS. */
|
||||
int8_t exponent; /**< Exponent for integer data types. */
|
||||
uint16_t unit; /**< Unit from Bluetooth Assigned Numbers. */
|
||||
uint8_t name_space; /**< Namespace from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */
|
||||
uint16_t desc; /**< Namespace description from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */
|
||||
} ble_gatts_char_pf_t;
|
||||
|
||||
|
||||
/**@brief GATT Characteristic metadata. */
|
||||
typedef struct
|
||||
{
|
||||
ble_gatt_char_props_t char_props; /**< Characteristic Properties. */
|
||||
ble_gatt_char_ext_props_t char_ext_props; /**< Characteristic Extended Properties. */
|
||||
uint8_t *p_char_user_desc; /**< Pointer to a UTF-8 encoded string (non-NULL terminated), NULL if the descriptor is not required. */
|
||||
uint16_t char_user_desc_max_size; /**< The maximum size in bytes of the user description descriptor. */
|
||||
uint16_t char_user_desc_size; /**< The size of the user description, must be smaller or equal to char_user_desc_max_size. */
|
||||
ble_gatts_char_pf_t* p_char_pf; /**< Pointer to a presentation format structure or NULL if the CPF descriptor is not required. */
|
||||
ble_gatts_attr_md_t* p_user_desc_md; /**< Attribute metadata for the User Description descriptor, or NULL for default values. */
|
||||
ble_gatts_attr_md_t* p_cccd_md; /**< Attribute metadata for the Client Characteristic Configuration Descriptor, or NULL for default values. */
|
||||
ble_gatts_attr_md_t* p_sccd_md; /**< Attribute metadata for the Server Characteristic Configuration Descriptor, or NULL for default values. */
|
||||
} ble_gatts_char_md_t;
|
||||
|
||||
|
||||
/**@brief GATT Characteristic Definition Handles. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t value_handle; /**< Handle to the characteristic value. */
|
||||
uint16_t user_desc_handle; /**< Handle to the User Description descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */
|
||||
uint16_t cccd_handle; /**< Handle to the Client Characteristic Configuration Descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */
|
||||
uint16_t sccd_handle; /**< Handle to the Server Characteristic Configuration Descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */
|
||||
} ble_gatts_char_handles_t;
|
||||
|
||||
|
||||
/**@brief GATT HVx parameters. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Characteristic Value Handle. */
|
||||
uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */
|
||||
uint16_t offset; /**< Offset within the attribute value. */
|
||||
uint16_t *p_len; /**< Length in bytes to be written, length in bytes written after successful return. */
|
||||
uint8_t *p_data; /**< Actual data content, use NULL to use the current attribute value. */
|
||||
} ble_gatts_hvx_params_t;
|
||||
|
||||
/**@brief GATT Authorization parameters. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */
|
||||
uint8_t update : 1; /**< If set, data supplied in p_data will be used to update the attribute value.
|
||||
Please note that for @ref BLE_GATTS_AUTHORIZE_TYPE_WRITE operations this bit must always be set,
|
||||
as the data to be written needs to be stored and later provided by the application. */
|
||||
uint16_t offset; /**< Offset of the attribute value being updated. */
|
||||
uint16_t len; /**< Length in bytes of the value in p_data pointer, see @ref BLE_GATTS_ATTR_LENS_MAX. */
|
||||
const uint8_t *p_data; /**< Pointer to new value used to update the attribute value. */
|
||||
} ble_gatts_authorize_params_t;
|
||||
|
||||
/**@brief GATT Read or Write Authorize Reply parameters. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */
|
||||
union {
|
||||
ble_gatts_authorize_params_t read; /**< Read authorization parameters. */
|
||||
ble_gatts_authorize_params_t write; /**< Write authorization parameters. */
|
||||
} params; /**< Reply Parameters. */
|
||||
} ble_gatts_rw_authorize_reply_params_t;
|
||||
|
||||
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTS_EVT_WRITE. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute Handle. */
|
||||
ble_uuid_t uuid; /**< Attribute UUID. */
|
||||
uint8_t op; /**< Type of write operation, see @ref BLE_GATTS_OPS. */
|
||||
uint8_t auth_required; /**< Writing operation deferred due to authorization requirement. Application may use @ref sd_ble_gatts_value_set to finalise the writing operation. */
|
||||
uint16_t offset; /**< Offset for the write operation. */
|
||||
uint16_t len; /**< Length of the received data. */
|
||||
uint8_t data[1]; /**< Received data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_gatts_evt_write_t;
|
||||
|
||||
/**@brief Event substructure for authorized read requests, see @ref ble_gatts_evt_rw_authorize_request_t. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute Handle. */
|
||||
ble_uuid_t uuid; /**< Attribute UUID. */
|
||||
uint16_t offset; /**< Offset for the read operation. */
|
||||
} ble_gatts_evt_read_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */
|
||||
union {
|
||||
ble_gatts_evt_read_t read; /**< Attribute Read Parameters. */
|
||||
ble_gatts_evt_write_t write; /**< Attribute Write Parameters. */
|
||||
} request; /**< Request Parameters. */
|
||||
} ble_gatts_evt_rw_authorize_request_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTS_EVT_SYS_ATTR_MISSING. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t hint; /**< Hint (currently unused). */
|
||||
} ble_gatts_evt_sys_attr_missing_t;
|
||||
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTS_EVT_HVC. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute Handle. */
|
||||
} ble_gatts_evt_hvc_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t client_rx_mtu; /**< Client RX MTU size. */
|
||||
} ble_gatts_evt_exchange_mtu_request_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GATTS_EVT_TIMEOUT. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */
|
||||
} ble_gatts_evt_timeout_t;
|
||||
|
||||
|
||||
/**@brief GATTS event structure. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t conn_handle; /**< Connection Handle on which the event occurred. */
|
||||
union
|
||||
{
|
||||
ble_gatts_evt_write_t write; /**< Write Event Parameters. */
|
||||
ble_gatts_evt_rw_authorize_request_t authorize_request; /**< Read or Write Authorize Request Parameters. */
|
||||
ble_gatts_evt_sys_attr_missing_t sys_attr_missing; /**< System attributes missing. */
|
||||
ble_gatts_evt_hvc_t hvc; /**< Handle Value Confirmation Event Parameters. */
|
||||
ble_gatts_evt_exchange_mtu_request_t exchange_mtu_request; /**< Exchange MTU Request Event Parameters. */
|
||||
ble_gatts_evt_timeout_t timeout; /**< Timeout Event. */
|
||||
} params; /**< Event Parameters. */
|
||||
} ble_gatts_evt_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTS_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Add a service declaration to the Attribute Table.
|
||||
*
|
||||
* @note Secondary Services are only relevant in the context of the entity that references them, it is therefore forbidden to
|
||||
* add a secondary service declaration that is not referenced by another service later in the Attribute Table.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] type Toggles between primary and secondary services, see @ref BLE_GATTS_SRVC_TYPES.
|
||||
* @param[in] p_uuid Pointer to service UUID.
|
||||
* @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully added a service declaration.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, Vendor Specific UUIDs need to be present in the table.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack.
|
||||
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_SERVICE_ADD, uint32_t, sd_ble_gatts_service_add(uint8_t type, ble_uuid_t const *p_uuid, uint16_t *p_handle));
|
||||
|
||||
|
||||
/**@brief Add an include declaration to the Attribute Table.
|
||||
*
|
||||
* @note It is currently only possible to add an include declaration to the last added service (i.e. only sequential population is supported at this time).
|
||||
*
|
||||
* @note The included service must already be present in the Attribute Table prior to this call.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] service_handle Handle of the service where the included service is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
|
||||
* @param[in] inc_srvc_handle Handle of the included service.
|
||||
* @param[out] p_include_handle Pointer to a 16-bit word where the assigned handle will be stored.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully added an include declaration.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, handle values need to match previously added services.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED Feature is not supported, service_handle must be that of the last added service.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, self inclusions are not allowed.
|
||||
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND Attribute not found.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_INCLUDE_ADD, uint32_t, sd_ble_gatts_include_add(uint16_t service_handle, uint16_t inc_srvc_handle, uint16_t *p_include_handle));
|
||||
|
||||
|
||||
/**@brief Add a characteristic declaration, a characteristic value declaration and optional characteristic descriptor declarations to the Attribute Table.
|
||||
*
|
||||
* @note It is currently only possible to add a characteristic to the last added service (i.e. only sequential population is supported at this time).
|
||||
*
|
||||
* @note Several restrictions apply to the parameters, such as matching permissions between the user description descriptor and the writeable auxiliaries bits,
|
||||
* readable (no security) and writeable (selectable) CCCDs and SCCDs and valid presentation format values.
|
||||
*
|
||||
* @note If no metadata is provided for the optional descriptors, their permissions will be derived from the characteristic permissions.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] service_handle Handle of the service where the characteristic is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
|
||||
* @param[in] p_char_md Characteristic metadata.
|
||||
* @param[in] p_attr_char_value Pointer to the attribute structure corresponding to the characteristic value.
|
||||
* @param[out] p_handles Pointer to the structure where the assigned handles will be stored.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully added a characteristic.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, service handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation, a service context is required.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack.
|
||||
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
* @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_CHARACTERISTIC_ADD, uint32_t, sd_ble_gatts_characteristic_add(uint16_t service_handle, ble_gatts_char_md_t const *p_char_md, ble_gatts_attr_t const *p_attr_char_value, ble_gatts_char_handles_t *p_handles));
|
||||
|
||||
|
||||
/**@brief Add a descriptor to the Attribute Table.
|
||||
*
|
||||
* @note It is currently only possible to add a descriptor to the last added characteristic (i.e. only sequential population is supported at this time).
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] char_handle Handle of the characteristic where the descriptor is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
|
||||
* @param[in] p_attr Pointer to the attribute structure.
|
||||
* @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully added a descriptor.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, characteristic handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation, a characteristic context is required.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack.
|
||||
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
* @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_DESCRIPTOR_ADD, uint32_t, sd_ble_gatts_descriptor_add(uint16_t char_handle, ble_gatts_attr_t const *p_attr, uint16_t *p_handle));
|
||||
|
||||
/**@brief Set the value of a given attribute.
|
||||
*
|
||||
* @note Values other than system attributes can be set at any time, regardless of wheter any active connections exist.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle Connection handle. Ignored if the value does not belong to a system attribute.
|
||||
* @param[in] handle Attribute handle.
|
||||
* @param[in,out] p_value Attribute value information.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully set the value of the attribute.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND Attribute not found.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Forbidden handle supplied, certain attributes are not modifiable by the application.
|
||||
* @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied on a system attribute.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_VALUE_SET, uint32_t, sd_ble_gatts_value_set(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value));
|
||||
|
||||
/**@brief Get the value of a given attribute.
|
||||
*
|
||||
* @note If the attribute value is longer than the size of the supplied buffer,
|
||||
* p_len will return the total attribute value length (excluding offset),
|
||||
* and not the number of bytes actually returned in p_data.
|
||||
* The application may use this information to allocate a suitable buffer size.
|
||||
*
|
||||
* @note When retrieving system attribute values with this function, the connection handle
|
||||
* may refer to an already disconnected connection. Refer to the documentation of
|
||||
* @ref sd_ble_gatts_sys_attr_get for further information.
|
||||
*
|
||||
* @param[in] conn_handle Connection handle. Ignored if the value does not belong to a system attribute.
|
||||
* @param[in] handle Attribute handle.
|
||||
* @param[in,out] p_value Attribute value information.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully retrieved the value of the attribute.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND Attribute not found.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid attribute offset supplied.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied on a system attribute.
|
||||
* @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_VALUE_GET, uint32_t, sd_ble_gatts_value_get(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value));
|
||||
|
||||
/**@brief Notify or Indicate an attribute value.
|
||||
*
|
||||
* @details This function checks for the relevant Client Characteristic Configuration descriptor value to verify that the relevant operation
|
||||
* (notification or indication) has been enabled by the client. It is also able to update the attribute value before issuing the PDU, so that
|
||||
* the application can atomically perform a value update and a server initiated transaction with a single API call.
|
||||
* If the application chooses to indicate an attribute value, a @ref BLE_GATTS_EVT_HVC event will be issued as soon as the confirmation arrives from
|
||||
* the peer.
|
||||
*
|
||||
* @note The local attribute value may be updated even if an outgoing packet is not sent to the peer due to an error during execution.
|
||||
* The Attribute Table has been updated if one of the following error codes is returned: @ref NRF_ERROR_INVALID_STATE, @ref NRF_ERROR_BUSY,
|
||||
* @ref NRF_ERROR_FORBIDDEN, @ref BLE_ERROR_GATTS_SYS_ATTR_MISSING and @ref BLE_ERROR_NO_TX_PACKETS.
|
||||
* The caller can check whether the value has been updated by looking at the contents of *(p_hvx_params->p_len).
|
||||
*
|
||||
* @note It is important to note that a notification will <b>consume an application buffer</b>, and will therefore
|
||||
* generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted. An indication on the other hand will use the
|
||||
* standard server internal buffer and thus will only generate a @ref BLE_GATTS_EVT_HVC event as soon as the confirmation
|
||||
* has been received from the peer. Please see the documentation of @ref sd_ble_tx_packet_count_get for more details.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_EVT_TX_COMPLETE, Transmission complete.}
|
||||
* @event{@ref BLE_GATTS_EVT_HVC, Confirmation received from peer.}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_HVX_SYS_ATTRS_MISSING_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_HVN_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_HVI_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_HVX_DISABLED_MSC}
|
||||
* @mmsc{@ref BLE_COMMON_APP_BUFF_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in] p_hvx_params Pointer to an HVx parameters structure. If the p_data member contains a non-NULL pointer the attribute value will be updated with
|
||||
* the contents pointed by it before sending the notification or indication.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully queued a notification or indication for transmission, and optionally updated the attribute value.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE One or more of the following is true:
|
||||
* - Invalid Connection State
|
||||
* - Notifications and/or indications not enabled in the CCCD
|
||||
* - An ATT_MTU exchange is ongoing
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied. Only attributes added directly by the application are available to notify and indicate.
|
||||
* @retval ::BLE_ERROR_GATTS_INVALID_ATTR_TYPE Invalid attribute type(s) supplied, only characteristic values may be notified and indicated.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND Attribute not found.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN The connection's current security level is lower than the one required by the write permissions of the CCCD associated with this characteristic.
|
||||
* @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
|
||||
* @retval ::NRF_ERROR_BUSY Procedure already in progress.
|
||||
* @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value.
|
||||
* @retval ::BLE_ERROR_NO_TX_PACKETS No available application packets for this connection, applies only to notifications.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_HVX, uint32_t, sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const *p_hvx_params));
|
||||
|
||||
/**@brief Indicate the Service Changed attribute value.
|
||||
*
|
||||
* @details This call will send a Handle Value Indication to one or more peers connected to inform them that the Attribute
|
||||
* Table layout has changed. As soon as the peer has confirmed the indication, a @ref BLE_GATTS_EVT_SC_CONFIRM event will
|
||||
* be issued.
|
||||
*
|
||||
* @note Some of the restrictions and limitations that apply to @ref sd_ble_gatts_hvx also apply here.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTS_EVT_SC_CONFIRM, Confirmation of attribute table change received from peer.}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_SC_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in] start_handle Start of affected attribute handle range.
|
||||
* @param[in] end_handle End of affected attribute handle range.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully queued the Service Changed indication for transmission.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED Service Changed not enabled at initialization. See @ref sd_ble_enable and @ref ble_gatts_enable_params_t.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE One or more of the following is true:
|
||||
* - Invalid Connection State
|
||||
* - Notifications and/or indications not enabled in the CCCD
|
||||
* - An ATT_MTU exchange is ongoing
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied, handles must be in the range populated by the application.
|
||||
* @retval ::NRF_ERROR_BUSY Procedure already in progress.
|
||||
* @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_SERVICE_CHANGED, uint32_t, sd_ble_gatts_service_changed(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle));
|
||||
|
||||
/**@brief Respond to a Read/Write authorization request.
|
||||
*
|
||||
* @note This call should only be used as a response to a @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event issued to the application.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_AUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_AUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_READ_REQ_AUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_WRITE_REQ_AUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_PEER_CANCEL_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in] p_rw_authorize_reply_params Pointer to a structure with the attribute provided by the application.
|
||||
*
|
||||
* @note @ref ble_gatts_authorize_params_t::p_data is ignored when this function is used to respond
|
||||
* to a @ref BLE_GATTS_AUTHORIZE_TYPE_READ event if @ref ble_gatts_authorize_params_t::update
|
||||
* is set to 0.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully queued a response to the peer, and in the case of a write operation, Attribute Table updated.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no authorization request pending.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Authorization op invalid,
|
||||
* handle supplied does not match requested handle,
|
||||
* or invalid data to be written provided by the application.
|
||||
* @retval ::NRF_ERROR_BUSY The stack is busy. Retry at later time.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_RW_AUTHORIZE_REPLY, uint32_t, sd_ble_gatts_rw_authorize_reply(uint16_t conn_handle, ble_gatts_rw_authorize_reply_params_t const *p_rw_authorize_reply_params));
|
||||
|
||||
|
||||
/**@brief Update persistent system attribute information.
|
||||
*
|
||||
* @details Supply information about persistent system attributes to the stack,
|
||||
* previously obtained using @ref sd_ble_gatts_sys_attr_get.
|
||||
* This call is only allowed for active connections, and is usually
|
||||
* made immediately after a connection is established with an known bonded device,
|
||||
* often as a response to a @ref BLE_GATTS_EVT_SYS_ATTR_MISSING.
|
||||
*
|
||||
* p_sysattrs may point directly to the application's stored copy of the system attributes
|
||||
* obtained using @ref sd_ble_gatts_sys_attr_get.
|
||||
* If the pointer is NULL, the system attribute info is initialized, assuming that
|
||||
* the application does not have any previously saved system attribute data for this device.
|
||||
*
|
||||
* @note The state of persistent system attributes is reset upon connection establishment and then remembered for its duration.
|
||||
*
|
||||
* @note If this call returns with an error code different from @ref NRF_SUCCESS, the storage of persistent system attributes may have been completed only partially.
|
||||
* This means that the state of the attribute table is undefined, and the application should either provide a new set of attributes using this same call or
|
||||
* reset the SoftDevice to return to a known state.
|
||||
*
|
||||
* @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS is used with this function, only the system attributes included in system services will be modified.
|
||||
* @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS is used with this function, only the system attributes included in user services will be modified.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_HVX_SYS_ATTRS_MISSING_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_SYS_ATTRS_UNK_PEER_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_SYS_ATTRS_BONDED_PEER_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in] p_sys_attr_data Pointer to a saved copy of system attributes supplied to the stack, or NULL.
|
||||
* @param[in] len Size of data pointed by p_sys_attr_data, in octets.
|
||||
* @param[in] flags Optional additional flags, see @ref BLE_GATTS_SYS_ATTR_FLAGS
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully set the system attribute information.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid flags supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_DATA Invalid data supplied, the data should be exactly the same as retrieved with @ref sd_ble_gatts_sys_attr_get.
|
||||
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
* @retval ::NRF_ERROR_BUSY The stack is busy. Retry at later time.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_SYS_ATTR_SET, uint32_t, sd_ble_gatts_sys_attr_set(uint16_t conn_handle, uint8_t const *p_sys_attr_data, uint16_t len, uint32_t flags));
|
||||
|
||||
|
||||
/**@brief Retrieve persistent system attribute information from the stack.
|
||||
*
|
||||
* @details This call is used to retrieve information about values to be stored perisistently by the application
|
||||
* during the lifetime of a connection or after it has been terminated. When a new connection is established with the same bonded device,
|
||||
* the system attribute information retrieved with this function should be restored using using @ref sd_ble_gatts_sys_attr_set.
|
||||
* If retrieved after disconnection, the data should be read before a new connection established. The connection handle for
|
||||
* the previous, now disconnected, connection will remain valid until a new one is created to allow this API call to refer to it.
|
||||
* Connection handles belonging to active connections can be used as well, but care should be taken since the system attributes
|
||||
* may be written to at any time by the peer during a connection's lifetime.
|
||||
*
|
||||
* @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS is used with this function, only the system attributes included in system services will be returned.
|
||||
* @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS is used with this function, only the system attributes included in user services will be returned.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_SYS_ATTRS_BONDED_PEER_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle Connection handle of the recently terminated connection.
|
||||
* @param[out] p_sys_attr_data Pointer to a buffer where updated information about system attributes will be filled in. The format of the data is described
|
||||
* in @ref BLE_GATTS_SYS_ATTRS_FORMAT. NULL can be provided to obtain the length of the data.
|
||||
* @param[in,out] p_len Size of application buffer if p_sys_attr_data is not NULL. Unconditially updated to actual length of system attribute data.
|
||||
* @param[in] flags Optional additional flags, see @ref BLE_GATTS_SYS_ATTR_FLAGS
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully retrieved the system attribute information.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid flags supplied.
|
||||
* @retval ::NRF_ERROR_DATA_SIZE The system attribute information did not fit into the provided buffer.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND No system attributes found.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_SYS_ATTR_GET, uint32_t, sd_ble_gatts_sys_attr_get(uint16_t conn_handle, uint8_t *p_sys_attr_data, uint16_t *p_len, uint32_t flags));
|
||||
|
||||
|
||||
/**@brief Retrieve the first valid user attribute handle.
|
||||
*
|
||||
* @param[out] p_handle Pointer to an integer where the handle will be stored.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully retrieved the handle.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_INITIAL_USER_HANDLE_GET, uint32_t, sd_ble_gatts_initial_user_handle_get(uint16_t *p_handle));
|
||||
|
||||
/**@brief Retrieve the attribute UUID and/or metadata.
|
||||
*
|
||||
* @param[in] handle Attribute handle
|
||||
* @param[out] p_uuid UUID of the attribute. Use NULL to omit this field.
|
||||
* @param[out] p_md Metadata of the attribute. Use NULL to omit this field.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully retrieved the attribute metadata,
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameters supplied. Returned when both @c p_uuid and @c p_md are NULL.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND Attribute was not found.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_ATTR_GET, uint32_t, sd_ble_gatts_attr_get(uint16_t handle, ble_uuid_t * p_uuid, ble_gatts_attr_md_t * p_md));
|
||||
|
||||
/**@brief Reply to an ATT_MTU exchange request by sending an Exchange MTU Response to the client.
|
||||
*
|
||||
* @details This function is only used to reply to a @ref BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST event.
|
||||
*
|
||||
* @details The SoftDevice sets ATT_MTU to the minimum of:
|
||||
* - The Client RX MTU value from @ref BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST, and
|
||||
* - The Server RX MTU value.
|
||||
*
|
||||
* However, the SoftDevice never sets ATT_MTU lower than @ref BLE_GATT_MTU_SIZE_DEFAULT.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_EVT_DATA_LENGTH_CHANGED, Generated if a data length update procedure is performed after the ATT_MTU exchange.}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_MTU_EXCHANGE}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] server_rx_mtu Server RX MTU size.
|
||||
* - The minimum value is @ref BLE_GATT_MTU_SIZE_DEFAULT.
|
||||
* - The maximum value is @ref ble_gatt_enable_params_t::att_mtu.
|
||||
* - The value must be equal to Client RX MTU size given in @ref sd_ble_gattc_exchange_mtu_request
|
||||
* if an ATT_MTU exchange has already been performed in the other direction.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully sent response to the client.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no ATT_MTU exchange request pending.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid Server RX MTU size supplied.
|
||||
* @retval ::NRF_ERROR_BUSY The stack is busy. Retry at later time.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_EXCHANGE_MTU_REPLY, uint32_t, sd_ble_gatts_exchange_mtu_reply(uint16_t conn_handle, uint16_t server_rx_mtu));
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // BLE_GATTS_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup BLE_COMMON
|
||||
@{
|
||||
*/
|
||||
|
||||
|
||||
#ifndef BLE_HCI_H__
|
||||
#define BLE_HCI_H__
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @defgroup BLE_HCI_STATUS_CODES Bluetooth status codes
|
||||
* @{ */
|
||||
|
||||
#define BLE_HCI_STATUS_CODE_SUCCESS 0x00 /**< Success. */
|
||||
#define BLE_HCI_STATUS_CODE_UNKNOWN_BTLE_COMMAND 0x01 /**< Unknown BLE Command. */
|
||||
#define BLE_HCI_STATUS_CODE_UNKNOWN_CONNECTION_IDENTIFIER 0x02 /**< Unknown Connection Identifier. */
|
||||
/*0x03 Hardware Failure
|
||||
0x04 Page Timeout
|
||||
*/
|
||||
#define BLE_HCI_AUTHENTICATION_FAILURE 0x05 /**< Authentication Failure. */
|
||||
#define BLE_HCI_STATUS_CODE_PIN_OR_KEY_MISSING 0x06 /**< Pin or Key missing. */
|
||||
#define BLE_HCI_MEMORY_CAPACITY_EXCEEDED 0x07 /**< Memory Capacity Exceeded. */
|
||||
#define BLE_HCI_CONNECTION_TIMEOUT 0x08 /**< Connection Timeout. */
|
||||
/*0x09 Connection Limit Exceeded
|
||||
0x0A Synchronous Connection Limit To A Device Exceeded
|
||||
0x0B ACL Connection Already Exists*/
|
||||
#define BLE_HCI_STATUS_CODE_COMMAND_DISALLOWED 0x0C /**< Command Disallowed. */
|
||||
/*0x0D Connection Rejected due to Limited Resources
|
||||
0x0E Connection Rejected Due To Security Reasons
|
||||
0x0F Connection Rejected due to Unacceptable BD_ADDR
|
||||
0x10 Connection Accept Timeout Exceeded
|
||||
0x11 Unsupported Feature or Parameter Value*/
|
||||
#define BLE_HCI_STATUS_CODE_INVALID_BTLE_COMMAND_PARAMETERS 0x12 /**< Invalid BLE Command Parameters. */
|
||||
#define BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION 0x13 /**< Remote User Terminated Connection. */
|
||||
#define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES 0x14 /**< Remote Device Terminated Connection due to low resources.*/
|
||||
#define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF 0x15 /**< Remote Device Terminated Connection due to power off. */
|
||||
#define BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION 0x16 /**< Local Host Terminated Connection. */
|
||||
/*
|
||||
0x17 Repeated Attempts
|
||||
0x18 Pairing Not Allowed
|
||||
0x19 Unknown LMP PDU
|
||||
*/
|
||||
#define BLE_HCI_UNSUPPORTED_REMOTE_FEATURE 0x1A /**< Unsupported Remote Feature. */
|
||||
/*
|
||||
0x1B SCO Offset Rejected
|
||||
0x1C SCO Interval Rejected
|
||||
0x1D SCO Air Mode Rejected*/
|
||||
#define BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS 0x1E /**< Invalid LMP Parameters. */
|
||||
#define BLE_HCI_STATUS_CODE_UNSPECIFIED_ERROR 0x1F /**< Unspecified Error. */
|
||||
/*0x20 Unsupported LMP Parameter Value
|
||||
0x21 Role Change Not Allowed
|
||||
*/
|
||||
#define BLE_HCI_STATUS_CODE_LMP_RESPONSE_TIMEOUT 0x22 /**< LMP Response Timeout. */
|
||||
#define BLE_HCI_STATUS_CODE_LMP_ERROR_TRANSACTION_COLLISION 0x23 /**< LMP Error Transaction Collision/LL Procedure Collision. */
|
||||
#define BLE_HCI_STATUS_CODE_LMP_PDU_NOT_ALLOWED 0x24 /**< LMP PDU Not Allowed. */
|
||||
/*0x25 Encryption Mode Not Acceptable
|
||||
0x26 Link Key Can Not be Changed
|
||||
0x27 Requested QoS Not Supported
|
||||
*/
|
||||
#define BLE_HCI_INSTANT_PASSED 0x28 /**< Instant Passed. */
|
||||
#define BLE_HCI_PAIRING_WITH_UNIT_KEY_UNSUPPORTED 0x29 /**< Pairing with Unit Key Unsupported. */
|
||||
#define BLE_HCI_DIFFERENT_TRANSACTION_COLLISION 0x2A /**< Different Transaction Collision. */
|
||||
/*
|
||||
0x2B Reserved
|
||||
0x2C QoS Unacceptable Parameter
|
||||
0x2D QoS Rejected
|
||||
0x2E Channel Classification Not Supported
|
||||
0x2F Insufficient Security
|
||||
0x30 Parameter Out Of Mandatory Range
|
||||
0x31 Reserved
|
||||
0x32 Role Switch Pending
|
||||
0x33 Reserved
|
||||
0x34 Reserved Slot Violation
|
||||
0x35 Role Switch Failed
|
||||
0x36 Extended Inquiry Response Too Large
|
||||
0x37 Secure Simple Pairing Not Supported By Host.
|
||||
0x38 Host Busy - Pairing
|
||||
0x39 Connection Rejected due to No Suitable Channel Found*/
|
||||
#define BLE_HCI_CONTROLLER_BUSY 0x3A /**< Controller Busy. */
|
||||
#define BLE_HCI_CONN_INTERVAL_UNACCEPTABLE 0x3B /**< Connection Interval Unacceptable. */
|
||||
#define BLE_HCI_DIRECTED_ADVERTISER_TIMEOUT 0x3C /**< Directed Adverisement Timeout. */
|
||||
#define BLE_HCI_CONN_TERMINATED_DUE_TO_MIC_FAILURE 0x3D /**< Connection Terminated due to MIC Failure. */
|
||||
#define BLE_HCI_CONN_FAILED_TO_BE_ESTABLISHED 0x3E /**< Connection Failed to be Established. */
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // BLE_HCI_H__
|
||||
|
||||
/** @} */
|
||||
|
|
@ -1,204 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup BLE_L2CAP Logical Link Control and Adaptation Protocol (L2CAP)
|
||||
@{
|
||||
@brief Definitions and prototypes for the L2CAP interface.
|
||||
*/
|
||||
|
||||
#ifndef BLE_L2CAP_H__
|
||||
#define BLE_L2CAP_H__
|
||||
|
||||
#include "nrf_ble_types.h"
|
||||
#include "nrf_ble_ranges.h"
|
||||
#include "nrf_ble_err.h"
|
||||
#include "nrf_svc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**@addtogroup BLE_L2CAP_ENUMERATIONS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief L2CAP API SVC numbers. */
|
||||
enum BLE_L2CAP_SVCS
|
||||
{
|
||||
SD_BLE_L2CAP_CID_REGISTER = BLE_L2CAP_SVC_BASE, /**< Register a CID. */
|
||||
SD_BLE_L2CAP_CID_UNREGISTER, /**< Unregister a CID. */
|
||||
SD_BLE_L2CAP_TX /**< Transmit a packet. */
|
||||
};
|
||||
|
||||
/**@brief L2CAP Event IDs. */
|
||||
enum BLE_L2CAP_EVTS
|
||||
{
|
||||
BLE_L2CAP_EVT_RX = BLE_L2CAP_EVT_BASE /**< L2CAP packet received. */
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/**@addtogroup BLE_L2CAP_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@defgroup BLE_ERRORS_L2CAP SVC return values specific to L2CAP
|
||||
* @{ */
|
||||
#define BLE_ERROR_L2CAP_CID_IN_USE (NRF_L2CAP_ERR_BASE + 0x000) /**< CID already in use. */
|
||||
/** @} */
|
||||
|
||||
/**@brief Default L2CAP MTU. */
|
||||
#define BLE_L2CAP_MTU_DEF (23)
|
||||
|
||||
/**@brief Invalid Channel Identifier. */
|
||||
#define BLE_L2CAP_CID_INVALID (0x0000)
|
||||
|
||||
/**@brief Dynamic Channel Identifier base. */
|
||||
#define BLE_L2CAP_CID_DYN_BASE (0x0040)
|
||||
|
||||
/**@brief Maximum amount of dynamic CIDs. */
|
||||
#define BLE_L2CAP_CID_DYN_MAX (8)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**@addtogroup BLE_L2CAP_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**@brief Packet header format for L2CAP transmission. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t len; /**< Length of valid info in data member. */
|
||||
uint16_t cid; /**< Channel ID on which packet is transmitted. */
|
||||
} ble_l2cap_header_t;
|
||||
|
||||
|
||||
/**@brief L2CAP Received packet event report. */
|
||||
typedef struct
|
||||
{
|
||||
ble_l2cap_header_t header; /**< L2CAP packet header. */
|
||||
uint8_t data[1]; /**< Packet data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
|
||||
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
|
||||
} ble_l2cap_evt_rx_t;
|
||||
|
||||
|
||||
/**@brief L2CAP event callback event structure. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t conn_handle; /**< Connection Handle on which event occured. */
|
||||
union
|
||||
{
|
||||
ble_l2cap_evt_rx_t rx; /**< RX Event parameters. */
|
||||
} params; /**< Event Parameters. */
|
||||
} ble_l2cap_evt_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/**@addtogroup BLE_L2CAP_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Register a CID with L2CAP.
|
||||
*
|
||||
* @details This registers a higher protocol layer with the L2CAP multiplexer, and is requried prior to all operations on the CID.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_L2CAP_API_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] cid L2CAP CID.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully registered a CID with the L2CAP layer.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, CID must be above @ref BLE_L2CAP_CID_DYN_BASE.
|
||||
* @retval ::BLE_ERROR_L2CAP_CID_IN_USE L2CAP CID already in use.
|
||||
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
*/
|
||||
SVCALL(SD_BLE_L2CAP_CID_REGISTER, uint32_t, sd_ble_l2cap_cid_register(uint16_t cid));
|
||||
|
||||
/**@brief Unregister a CID with L2CAP.
|
||||
*
|
||||
* @details This unregisters a previously registerd higher protocol layer with the L2CAP multiplexer.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_L2CAP_API_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] cid L2CAP CID.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully unregistered the CID.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND CID not previously registered.
|
||||
*/
|
||||
SVCALL(SD_BLE_L2CAP_CID_UNREGISTER, uint32_t, sd_ble_l2cap_cid_unregister(uint16_t cid));
|
||||
|
||||
/**@brief Transmit an L2CAP packet.
|
||||
*
|
||||
* @note It is important to note that a call to this function will <b>consume an application packet</b>, and will therefore
|
||||
* generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted.
|
||||
* Please see the documentation of @ref sd_ble_tx_packet_count_get for more details.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_EVT_TX_COMPLETE}
|
||||
* @event{@ref BLE_L2CAP_EVT_RX}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_L2CAP_API_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] conn_handle Connection Handle.
|
||||
* @param[in] p_header Pointer to a packet header containing length and CID.
|
||||
* @param[in] p_data Pointer to the data to be transmitted.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully queued an L2CAP packet for transmission.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, CIDs must be registered beforehand with @ref sd_ble_l2cap_cid_register.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND CID not found.
|
||||
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
* @retval ::BLE_ERROR_NO_TX_PACKETS Not enough application packets available.
|
||||
* @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, see @ref BLE_L2CAP_MTU_DEF.
|
||||
*/
|
||||
SVCALL(SD_BLE_L2CAP_TX, uint32_t, sd_ble_l2cap_tx(uint16_t conn_handle, ble_l2cap_header_t const *p_header, uint8_t const *p_data));
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // BLE_L2CAP_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup BLE_COMMON
|
||||
@{
|
||||
@defgroup ble_ranges Module specific SVC, event and option number subranges
|
||||
@{
|
||||
|
||||
@brief Definition of SVC, event and option number subranges for each API module.
|
||||
|
||||
@note
|
||||
SVCs, event and option numbers are split into subranges for each API module.
|
||||
Each module receives its entire allocated range of SVC calls, whether implemented or not,
|
||||
but return BLE_ERROR_NOT_SUPPORTED for unimplemented or undefined calls in its range.
|
||||
|
||||
Note that the symbols BLE_<module>_SVC_LAST is the end of the allocated SVC range,
|
||||
rather than the last SVC function call actually defined and implemented.
|
||||
|
||||
Specific SVC, event and option values are defined in each module's ble_<module>.h file,
|
||||
which defines names of each individual SVC code based on the range start value.
|
||||
*/
|
||||
|
||||
#ifndef BLE_RANGES_H__
|
||||
#define BLE_RANGES_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BLE_SVC_BASE 0x60 /**< Common BLE SVC base. */
|
||||
#define BLE_SVC_LAST 0x6B /**< Common BLE SVC last. */
|
||||
|
||||
|
||||
#define BLE_GAP_SVC_BASE 0x6C /**< GAP BLE SVC base. */
|
||||
#define BLE_GAP_SVC_LAST 0x93 /**< GAP BLE SVC last. */
|
||||
|
||||
|
||||
#define BLE_GATTC_SVC_BASE 0x94 /**< GATTC BLE SVC base. */
|
||||
#define BLE_GATTC_SVC_LAST 0x9F /**< GATTC BLE SVC last. */
|
||||
|
||||
|
||||
#define BLE_GATTS_SVC_BASE 0xA0 /**< GATTS BLE SVC base. */
|
||||
#define BLE_GATTS_SVC_LAST 0xAF /**< GATTS BLE SVC last. */
|
||||
|
||||
|
||||
#define BLE_L2CAP_SVC_BASE 0xB0 /**< L2CAP BLE SVC base. */
|
||||
#define BLE_L2CAP_SVC_LAST 0xBF /**< L2CAP BLE SVC last. */
|
||||
|
||||
|
||||
#define BLE_EVT_INVALID 0x00 /**< Invalid BLE Event. */
|
||||
|
||||
|
||||
#define BLE_EVT_BASE 0x01 /**< Common BLE Event base. */
|
||||
#define BLE_EVT_LAST 0x0F /**< Common BLE Event last. */
|
||||
|
||||
|
||||
#define BLE_GAP_EVT_BASE 0x10 /**< GAP BLE Event base. */
|
||||
#define BLE_GAP_EVT_LAST 0x2F /**< GAP BLE Event last. */
|
||||
|
||||
|
||||
#define BLE_GATTC_EVT_BASE 0x30 /**< GATTC BLE Event base. */
|
||||
#define BLE_GATTC_EVT_LAST 0x4F /**< GATTC BLE Event last. */
|
||||
|
||||
|
||||
#define BLE_GATTS_EVT_BASE 0x50 /**< GATTS BLE Event base. */
|
||||
#define BLE_GATTS_EVT_LAST 0x6F /**< GATTS BLE Event last. */
|
||||
|
||||
|
||||
#define BLE_L2CAP_EVT_BASE 0x70 /**< L2CAP BLE Event base. */
|
||||
#define BLE_L2CAP_EVT_LAST 0x8F /**< L2CAP BLE Event last. */
|
||||
|
||||
|
||||
#define BLE_OPT_INVALID 0x00 /**< Invalid BLE Option. */
|
||||
|
||||
|
||||
#define BLE_OPT_BASE 0x01 /**< Common BLE Option base. */
|
||||
#define BLE_OPT_LAST 0x1F /**< Common BLE Option last. */
|
||||
|
||||
|
||||
#define BLE_GAP_OPT_BASE 0x20 /**< GAP BLE Option base. */
|
||||
#define BLE_GAP_OPT_LAST 0x3F /**< GAP BLE Option last. */
|
||||
|
||||
|
||||
#define BLE_GATTC_OPT_BASE 0x40 /**< GATTC BLE Option base. */
|
||||
#define BLE_GATTC_OPT_LAST 0x5F /**< GATTC BLE Option last. */
|
||||
|
||||
|
||||
#define BLE_GATTS_OPT_BASE 0x60 /**< GATTS BLE Option base. */
|
||||
#define BLE_GATTS_OPT_LAST 0x7F /**< GATTS BLE Option last. */
|
||||
|
||||
|
||||
#define BLE_L2CAP_OPT_BASE 0x80 /**< L2CAP BLE Option base. */
|
||||
#define BLE_L2CAP_OPT_LAST 0x9F /**< L2CAP BLE Option last. */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* BLE_RANGES_H__ */
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,207 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup BLE_COMMON
|
||||
@{
|
||||
@defgroup ble_types Common types and macro definitions
|
||||
@{
|
||||
|
||||
@brief Common types and macro definitions for the BLE SoftDevice.
|
||||
*/
|
||||
|
||||
#ifndef BLE_TYPES_H__
|
||||
#define BLE_TYPES_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup BLE_TYPES_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/** @defgroup BLE_CONN_HANDLES BLE Connection Handles
|
||||
* @{ */
|
||||
#define BLE_CONN_HANDLE_INVALID 0xFFFF /**< Invalid Connection Handle. */
|
||||
#define BLE_CONN_HANDLE_ALL 0xFFFE /**< Applies to all Connection Handles. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_UUID_VALUES Assigned Values for BLE UUIDs
|
||||
* @{ */
|
||||
/* Generic UUIDs, applicable to all services */
|
||||
#define BLE_UUID_UNKNOWN 0x0000 /**< Reserved UUID. */
|
||||
#define BLE_UUID_SERVICE_PRIMARY 0x2800 /**< Primary Service. */
|
||||
#define BLE_UUID_SERVICE_SECONDARY 0x2801 /**< Secondary Service. */
|
||||
#define BLE_UUID_SERVICE_INCLUDE 0x2802 /**< Include. */
|
||||
#define BLE_UUID_CHARACTERISTIC 0x2803 /**< Characteristic. */
|
||||
#define BLE_UUID_DESCRIPTOR_CHAR_EXT_PROP 0x2900 /**< Characteristic Extended Properties Descriptor. */
|
||||
#define BLE_UUID_DESCRIPTOR_CHAR_USER_DESC 0x2901 /**< Characteristic User Description Descriptor. */
|
||||
#define BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG 0x2902 /**< Client Characteristic Configuration Descriptor. */
|
||||
#define BLE_UUID_DESCRIPTOR_SERVER_CHAR_CONFIG 0x2903 /**< Server Characteristic Configuration Descriptor. */
|
||||
#define BLE_UUID_DESCRIPTOR_CHAR_PRESENTATION_FORMAT 0x2904 /**< Characteristic Presentation Format Descriptor. */
|
||||
#define BLE_UUID_DESCRIPTOR_CHAR_AGGREGATE_FORMAT 0x2905 /**< Characteristic Aggregate Format Descriptor. */
|
||||
/* GATT specific UUIDs */
|
||||
#define BLE_UUID_GATT 0x1801 /**< Generic Attribute Profile. */
|
||||
#define BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED 0x2A05 /**< Service Changed Characteristic. */
|
||||
/* GAP specific UUIDs */
|
||||
#define BLE_UUID_GAP 0x1800 /**< Generic Access Profile. */
|
||||
#define BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME 0x2A00 /**< Device Name Characteristic. */
|
||||
#define BLE_UUID_GAP_CHARACTERISTIC_APPEARANCE 0x2A01 /**< Appearance Characteristic. */
|
||||
#define BLE_UUID_GAP_CHARACTERISTIC_RECONN_ADDR 0x2A03 /**< Reconnection Address Characteristic. */
|
||||
#define BLE_UUID_GAP_CHARACTERISTIC_PPCP 0x2A04 /**< Peripheral Preferred Connection Parameters Characteristic. */
|
||||
#define BLE_UUID_GAP_CHARACTERISTIC_CAR 0x2AA6 /**< Central Address Resolution Characteristic. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_UUID_TYPES Types of UUID
|
||||
* @{ */
|
||||
#define BLE_UUID_TYPE_UNKNOWN 0x00 /**< Invalid UUID type. */
|
||||
#define BLE_UUID_TYPE_BLE 0x01 /**< Bluetooth SIG UUID (16-bit). */
|
||||
#define BLE_UUID_TYPE_VENDOR_BEGIN 0x02 /**< Vendor UUID types start at this index (128-bit). */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_APPEARANCES Bluetooth Appearance values
|
||||
* @note Retrieved from http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml
|
||||
* @{ */
|
||||
#define BLE_APPEARANCE_UNKNOWN 0 /**< Unknown. */
|
||||
#define BLE_APPEARANCE_GENERIC_PHONE 64 /**< Generic Phone. */
|
||||
#define BLE_APPEARANCE_GENERIC_COMPUTER 128 /**< Generic Computer. */
|
||||
#define BLE_APPEARANCE_GENERIC_WATCH 192 /**< Generic Watch. */
|
||||
#define BLE_APPEARANCE_WATCH_SPORTS_WATCH 193 /**< Watch: Sports Watch. */
|
||||
#define BLE_APPEARANCE_GENERIC_CLOCK 256 /**< Generic Clock. */
|
||||
#define BLE_APPEARANCE_GENERIC_DISPLAY 320 /**< Generic Display. */
|
||||
#define BLE_APPEARANCE_GENERIC_REMOTE_CONTROL 384 /**< Generic Remote Control. */
|
||||
#define BLE_APPEARANCE_GENERIC_EYE_GLASSES 448 /**< Generic Eye-glasses. */
|
||||
#define BLE_APPEARANCE_GENERIC_TAG 512 /**< Generic Tag. */
|
||||
#define BLE_APPEARANCE_GENERIC_KEYRING 576 /**< Generic Keyring. */
|
||||
#define BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 640 /**< Generic Media Player. */
|
||||
#define BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 704 /**< Generic Barcode Scanner. */
|
||||
#define BLE_APPEARANCE_GENERIC_THERMOMETER 768 /**< Generic Thermometer. */
|
||||
#define BLE_APPEARANCE_THERMOMETER_EAR 769 /**< Thermometer: Ear. */
|
||||
#define BLE_APPEARANCE_GENERIC_HEART_RATE_SENSOR 832 /**< Generic Heart rate Sensor. */
|
||||
#define BLE_APPEARANCE_HEART_RATE_SENSOR_HEART_RATE_BELT 833 /**< Heart Rate Sensor: Heart Rate Belt. */
|
||||
#define BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 896 /**< Generic Blood Pressure. */
|
||||
#define BLE_APPEARANCE_BLOOD_PRESSURE_ARM 897 /**< Blood Pressure: Arm. */
|
||||
#define BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 898 /**< Blood Pressure: Wrist. */
|
||||
#define BLE_APPEARANCE_GENERIC_HID 960 /**< Human Interface Device (HID). */
|
||||
#define BLE_APPEARANCE_HID_KEYBOARD 961 /**< Keyboard (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_MOUSE 962 /**< Mouse (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_JOYSTICK 963 /**< Joystiq (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_GAMEPAD 964 /**< Gamepad (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_DIGITIZERSUBTYPE 965 /**< Digitizer Tablet (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_CARD_READER 966 /**< Card Reader (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_DIGITAL_PEN 967 /**< Digital Pen (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_BARCODE 968 /**< Barcode Scanner (HID Subtype). */
|
||||
#define BLE_APPEARANCE_GENERIC_GLUCOSE_METER 1024 /**< Generic Glucose Meter. */
|
||||
#define BLE_APPEARANCE_GENERIC_RUNNING_WALKING_SENSOR 1088 /**< Generic Running Walking Sensor. */
|
||||
#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_IN_SHOE 1089 /**< Running Walking Sensor: In-Shoe. */
|
||||
#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_SHOE 1090 /**< Running Walking Sensor: On-Shoe. */
|
||||
#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_HIP 1091 /**< Running Walking Sensor: On-Hip. */
|
||||
#define BLE_APPEARANCE_GENERIC_CYCLING 1152 /**< Generic Cycling. */
|
||||
#define BLE_APPEARANCE_CYCLING_CYCLING_COMPUTER 1153 /**< Cycling: Cycling Computer. */
|
||||
#define BLE_APPEARANCE_CYCLING_SPEED_SENSOR 1154 /**< Cycling: Speed Sensor. */
|
||||
#define BLE_APPEARANCE_CYCLING_CADENCE_SENSOR 1155 /**< Cycling: Cadence Sensor. */
|
||||
#define BLE_APPEARANCE_CYCLING_POWER_SENSOR 1156 /**< Cycling: Power Sensor. */
|
||||
#define BLE_APPEARANCE_CYCLING_SPEED_CADENCE_SENSOR 1157 /**< Cycling: Speed and Cadence Sensor. */
|
||||
#define BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 3136 /**< Generic Pulse Oximeter. */
|
||||
#define BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 3137 /**< Fingertip (Pulse Oximeter subtype). */
|
||||
#define BLE_APPEARANCE_PULSE_OXIMETER_WRIST_WORN 3138 /**< Wrist Worn(Pulse Oximeter subtype). */
|
||||
#define BLE_APPEARANCE_GENERIC_WEIGHT_SCALE 3200 /**< Generic Weight Scale. */
|
||||
#define BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS_ACT 5184 /**< Generic Outdoor Sports Activity. */
|
||||
#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_DISP 5185 /**< Location Display Device (Outdoor Sports Activity subtype). */
|
||||
#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_AND_NAV_DISP 5186 /**< Location and Navigation Display Device (Outdoor Sports Activity subtype). */
|
||||
#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_POD 5187 /**< Location Pod (Outdoor Sports Activity subtype). */
|
||||
#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_AND_NAV_POD 5188 /**< Location and Navigation Pod (Outdoor Sports Activity subtype). */
|
||||
/** @} */
|
||||
|
||||
/** @brief Set .type and .uuid fields of ble_uuid_struct to specified uuid value. */
|
||||
#define BLE_UUID_BLE_ASSIGN(instance, value) do {\
|
||||
instance.type = BLE_UUID_TYPE_BLE; \
|
||||
instance.uuid = value;} while(0)
|
||||
|
||||
/** @brief Copy type and uuid members from src to dst ble_uuid_t pointer. Both pointers must be valid/non-null. */
|
||||
#define BLE_UUID_COPY_PTR(dst, src) do {\
|
||||
(dst)->type = (src)->type; \
|
||||
(dst)->uuid = (src)->uuid;} while(0)
|
||||
|
||||
/** @brief Copy type and uuid members from src to dst ble_uuid_t struct. */
|
||||
#define BLE_UUID_COPY_INST(dst, src) do {\
|
||||
(dst).type = (src).type; \
|
||||
(dst).uuid = (src).uuid;} while(0)
|
||||
|
||||
/** @brief Compare for equality both type and uuid members of two (valid, non-null) ble_uuid_t pointers. */
|
||||
#define BLE_UUID_EQ(p_uuid1, p_uuid2) \
|
||||
(((p_uuid1)->type == (p_uuid2)->type) && ((p_uuid1)->uuid == (p_uuid2)->uuid))
|
||||
|
||||
/** @brief Compare for difference both type and uuid members of two (valid, non-null) ble_uuid_t pointers. */
|
||||
#define BLE_UUID_NEQ(p_uuid1, p_uuid2) \
|
||||
(((p_uuid1)->type != (p_uuid2)->type) || ((p_uuid1)->uuid != (p_uuid2)->uuid))
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_TYPES_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/** @brief 128 bit UUID values. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t uuid128[16]; /**< Little-Endian UUID bytes. */
|
||||
} ble_uuid128_t;
|
||||
|
||||
/** @brief Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t uuid; /**< 16-bit UUID value or octets 12-13 of 128-bit UUID. */
|
||||
uint8_t type; /**< UUID type, see @ref BLE_UUID_TYPES. If type is @ref BLE_UUID_TYPE_UNKNOWN, the value of uuid is undefined. */
|
||||
} ble_uuid_t;
|
||||
|
||||
/** @} */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BLE_TYPES_H__ */
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
@defgroup nrf_error SoftDevice Global Error Codes
|
||||
@{
|
||||
|
||||
@brief Global Error definitions
|
||||
*/
|
||||
|
||||
/* Header guard */
|
||||
#ifndef NRF_ERROR_H__
|
||||
#define NRF_ERROR_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @defgroup NRF_ERRORS_BASE Error Codes Base number definitions
|
||||
* @{ */
|
||||
#define NRF_ERROR_BASE_NUM (0x0) ///< Global error base
|
||||
#define NRF_ERROR_SDM_BASE_NUM (0x1000) ///< SDM error base
|
||||
#define NRF_ERROR_SOC_BASE_NUM (0x2000) ///< SoC error base
|
||||
#define NRF_ERROR_STK_BASE_NUM (0x3000) ///< STK error base
|
||||
/** @} */
|
||||
|
||||
#define NRF_SUCCESS (NRF_ERROR_BASE_NUM + 0) ///< Successful command
|
||||
#define NRF_ERROR_SVC_HANDLER_MISSING (NRF_ERROR_BASE_NUM + 1) ///< SVC handler is missing
|
||||
#define NRF_ERROR_SOFTDEVICE_NOT_ENABLED (NRF_ERROR_BASE_NUM + 2) ///< SoftDevice has not been enabled
|
||||
#define NRF_ERROR_INTERNAL (NRF_ERROR_BASE_NUM + 3) ///< Internal Error
|
||||
#define NRF_ERROR_NO_MEM (NRF_ERROR_BASE_NUM + 4) ///< No Memory for operation
|
||||
#define NRF_ERROR_NOT_FOUND (NRF_ERROR_BASE_NUM + 5) ///< Not found
|
||||
#define NRF_ERROR_NOT_SUPPORTED (NRF_ERROR_BASE_NUM + 6) ///< Not supported
|
||||
#define NRF_ERROR_INVALID_PARAM (NRF_ERROR_BASE_NUM + 7) ///< Invalid Parameter
|
||||
#define NRF_ERROR_INVALID_STATE (NRF_ERROR_BASE_NUM + 8) ///< Invalid state, operation disallowed in this state
|
||||
#define NRF_ERROR_INVALID_LENGTH (NRF_ERROR_BASE_NUM + 9) ///< Invalid Length
|
||||
#define NRF_ERROR_INVALID_FLAGS (NRF_ERROR_BASE_NUM + 10) ///< Invalid Flags
|
||||
#define NRF_ERROR_INVALID_DATA (NRF_ERROR_BASE_NUM + 11) ///< Invalid Data
|
||||
#define NRF_ERROR_DATA_SIZE (NRF_ERROR_BASE_NUM + 12) ///< Invalid Data size
|
||||
#define NRF_ERROR_TIMEOUT (NRF_ERROR_BASE_NUM + 13) ///< Operation timed out
|
||||
#define NRF_ERROR_NULL (NRF_ERROR_BASE_NUM + 14) ///< Null Pointer
|
||||
#define NRF_ERROR_FORBIDDEN (NRF_ERROR_BASE_NUM + 15) ///< Forbidden Operation
|
||||
#define NRF_ERROR_INVALID_ADDR (NRF_ERROR_BASE_NUM + 16) ///< Bad Memory Address
|
||||
#define NRF_ERROR_BUSY (NRF_ERROR_BASE_NUM + 17) ///< Busy
|
||||
#define NRF_ERROR_CONN_COUNT (NRF_ERROR_BASE_NUM + 18) ///< Maximum connection count exceeded.
|
||||
#define NRF_ERROR_RESOURCES (NRF_ERROR_BASE_NUM + 19) ///< Not enough resources for operation
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_ERROR_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
@addtogroup nrf_sdm_api
|
||||
@{
|
||||
@defgroup nrf_sdm_error SoftDevice Manager Error Codes
|
||||
@{
|
||||
|
||||
@brief Error definitions for the SDM API
|
||||
*/
|
||||
|
||||
/* Header guard */
|
||||
#ifndef NRF_ERROR_SDM_H__
|
||||
#define NRF_ERROR_SDM_H__
|
||||
|
||||
#include "nrf_error.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN (NRF_ERROR_SDM_BASE_NUM + 0) ///< Unknown lfclk source.
|
||||
#define NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION (NRF_ERROR_SDM_BASE_NUM + 1) ///< Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts).
|
||||
#define NRF_ERROR_SDM_INCORRECT_CLENR0 (NRF_ERROR_SDM_BASE_NUM + 2) ///< Incorrect CLENR0 (can be caused by erronous SoftDevice flashing).
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_ERROR_SDM_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
@addtogroup nrf_soc_api
|
||||
@{
|
||||
@defgroup nrf_soc_error SoC Library Error Codes
|
||||
@{
|
||||
|
||||
@brief Error definitions for the SoC library
|
||||
|
||||
*/
|
||||
|
||||
/* Header guard */
|
||||
#ifndef NRF_ERROR_SOC_H__
|
||||
#define NRF_ERROR_SOC_H__
|
||||
|
||||
#include "nrf_error.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Mutex Errors */
|
||||
#define NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN (NRF_ERROR_SOC_BASE_NUM + 0) ///< Mutex already taken
|
||||
|
||||
/* NVIC errors */
|
||||
#define NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE (NRF_ERROR_SOC_BASE_NUM + 1) ///< NVIC interrupt not available
|
||||
#define NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED (NRF_ERROR_SOC_BASE_NUM + 2) ///< NVIC interrupt priority not allowed
|
||||
#define NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 3) ///< NVIC should not return
|
||||
|
||||
/* Power errors */
|
||||
#define NRF_ERROR_SOC_POWER_MODE_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 4) ///< Power mode unknown
|
||||
#define NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 5) ///< Power POF threshold unknown
|
||||
#define NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 6) ///< Power off should not return
|
||||
|
||||
/* Rand errors */
|
||||
#define NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES (NRF_ERROR_SOC_BASE_NUM + 7) ///< RAND not enough values
|
||||
|
||||
/* PPI errors */
|
||||
#define NRF_ERROR_SOC_PPI_INVALID_CHANNEL (NRF_ERROR_SOC_BASE_NUM + 8) ///< Invalid PPI Channel
|
||||
#define NRF_ERROR_SOC_PPI_INVALID_GROUP (NRF_ERROR_SOC_BASE_NUM + 9) ///< Invalid PPI Group
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_ERROR_SOC_H__
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,521 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @defgroup nrf_nvic_api SoftDevice NVIC API
|
||||
* @{
|
||||
*
|
||||
* @note In order to use this module, the following code has to be added to a .c file:
|
||||
* \code
|
||||
* nrf_nvic_state_t nrf_nvic_state = {0};
|
||||
* \endcode
|
||||
*
|
||||
* @note Definitions and declarations starting with __ (double underscore) in this header file are
|
||||
* not intended for direct use by the application.
|
||||
*
|
||||
* @brief APIs for the accessing NVIC when using a SoftDevice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NRF_NVIC_H__
|
||||
#define NRF_NVIC_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "nrf.h"
|
||||
|
||||
#include "nrf_error_soc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**@addtogroup NRF_NVIC_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@defgroup NRF_NVIC_ISER_DEFINES SoftDevice NVIC internal definitions
|
||||
* @{ */
|
||||
|
||||
#define __NRF_NVIC_NVMC_IRQn (30) /**< The peripheral ID of the NVMC. IRQ numbers are used to identify peripherals, but the NVMC doesn't have an IRQ number in the MDK. */
|
||||
|
||||
#ifdef NRF51
|
||||
#define __NRF_NVIC_ISER_COUNT (1) /**< The number of ISER/ICER registers in the NVIC that are used. */
|
||||
|
||||
/**@brief Interrupts used by the SoftDevice. */
|
||||
#define __NRF_NVIC_SD_IRQS_0 ((uint32_t)( \
|
||||
(1U << POWER_CLOCK_IRQn) \
|
||||
| (1U << RADIO_IRQn) \
|
||||
| (1U << RTC0_IRQn) \
|
||||
| (1U << TIMER0_IRQn) \
|
||||
| (1U << RNG_IRQn) \
|
||||
| (1U << ECB_IRQn) \
|
||||
| (1U << CCM_AAR_IRQn) \
|
||||
| (1U << TEMP_IRQn) \
|
||||
| (1U << __NRF_NVIC_NVMC_IRQn) \
|
||||
| (1U << (uint32_t)SWI4_IRQn) \
|
||||
| (1U << (uint32_t)SWI5_IRQn) \
|
||||
))
|
||||
|
||||
/**@brief Interrupts available for to application. */
|
||||
#define __NRF_NVIC_APP_IRQS_0 (~__NRF_NVIC_SD_IRQS_0)
|
||||
#endif
|
||||
|
||||
#ifdef NRF52_SERIES
|
||||
#define __NRF_NVIC_ISER_COUNT (2) /**< The number of ISER/ICER registers in the NVIC that are used. */
|
||||
|
||||
/**@brief Interrupts used by the SoftDevice. */
|
||||
#define __NRF_NVIC_SD_IRQS_0 ((uint32_t)( \
|
||||
(1U << POWER_CLOCK_IRQn) \
|
||||
| (1U << RADIO_IRQn) \
|
||||
| (1U << RTC0_IRQn) \
|
||||
| (1U << TIMER0_IRQn) \
|
||||
| (1U << RNG_IRQn) \
|
||||
| (1U << ECB_IRQn) \
|
||||
| (1U << CCM_AAR_IRQn) \
|
||||
| (1U << TEMP_IRQn) \
|
||||
| (1U << __NRF_NVIC_NVMC_IRQn) \
|
||||
| (1U << (uint32_t)SWI4_EGU4_IRQn) \
|
||||
| (1U << (uint32_t)SWI5_EGU5_IRQn) \
|
||||
))
|
||||
#define __NRF_NVIC_SD_IRQS_1 ((uint32_t)0)
|
||||
|
||||
/**@brief Interrupts available for to application. */
|
||||
#define __NRF_NVIC_APP_IRQS_0 (~__NRF_NVIC_SD_IRQS_0)
|
||||
#define __NRF_NVIC_APP_IRQS_1 (~__NRF_NVIC_SD_IRQS_1)
|
||||
#endif
|
||||
/**@} */
|
||||
|
||||
/**@} */
|
||||
|
||||
/**@addtogroup NRF_NVIC_VARIABLES Variables
|
||||
* @{ */
|
||||
|
||||
/**@brief Type representing the state struct for the SoftDevice NVIC module. */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t volatile __irq_masks[__NRF_NVIC_ISER_COUNT]; /**< IRQs enabled by the application in the NVIC. */
|
||||
uint32_t volatile __cr_flag; /**< Non-zero if already in a critical region */
|
||||
} nrf_nvic_state_t;
|
||||
|
||||
/**@brief Variable keeping the state for the SoftDevice NVIC module. This must be declared in an
|
||||
* application source file. */
|
||||
extern nrf_nvic_state_t nrf_nvic_state;
|
||||
|
||||
/**@} */
|
||||
|
||||
/**@addtogroup NRF_NVIC_INTERNAL_FUNCTIONS SoftDevice NVIC internal functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Disables IRQ interrupts globally, including the SoftDevice's interrupts.
|
||||
*
|
||||
* @retval The value of PRIMASK prior to disabling the interrupts.
|
||||
*/
|
||||
__STATIC_INLINE int __sd_nvic_irq_disable(void);
|
||||
|
||||
/**@brief Enables IRQ interrupts globally, including the SoftDevice's interrupts.
|
||||
*/
|
||||
__STATIC_INLINE void __sd_nvic_irq_enable(void);
|
||||
|
||||
/**@brief Checks if IRQn is available to application
|
||||
* @param[in] IRQn irq to check
|
||||
*
|
||||
* @retval 1 (true) if the irq to check is available to the application
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __sd_nvic_app_accessible_irq(IRQn_Type IRQn);
|
||||
|
||||
/**@brief Checks if priority is available to application
|
||||
* @param[in] priority priority to check
|
||||
*
|
||||
* @retval 1 (true) if the priority to check is available to the application
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __sd_nvic_is_app_accessible_priority(uint32_t priority);
|
||||
|
||||
/**@} */
|
||||
|
||||
/**@addtogroup NRF_NVIC_FUNCTIONS SoftDevice NVIC public functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Enable External Interrupt.
|
||||
* @note Corresponds to NVIC_EnableIRQ in CMSIS.
|
||||
*
|
||||
* @pre IRQn is valid and not reserved by the stack.
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_EnableIRQ documentation in CMSIS.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt was enabled.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE The interrupt is not available for the application.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED The interrupt has a priority not available for the application.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t sd_nvic_EnableIRQ(IRQn_Type IRQn);
|
||||
|
||||
/**@brief Disable External Interrupt.
|
||||
* @note Corresponds to NVIC_DisableIRQ in CMSIS.
|
||||
*
|
||||
* @pre IRQn is valid and not reserved by the stack.
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_DisableIRQ documentation in CMSIS.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt was disabled.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE The interrupt is not available for the application.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t sd_nvic_DisableIRQ(IRQn_Type IRQn);
|
||||
|
||||
/**@brief Get Pending Interrupt.
|
||||
* @note Corresponds to NVIC_GetPendingIRQ in CMSIS.
|
||||
*
|
||||
* @pre IRQn is valid and not reserved by the stack.
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_GetPendingIRQ documentation in CMSIS.
|
||||
* @param[out] p_pending_irq Return value from NVIC_GetPendingIRQ.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt is available for the application.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t sd_nvic_GetPendingIRQ(IRQn_Type IRQn, uint32_t * p_pending_irq);
|
||||
|
||||
/**@brief Set Pending Interrupt.
|
||||
* @note Corresponds to NVIC_SetPendingIRQ in CMSIS.
|
||||
*
|
||||
* @pre IRQn is valid and not reserved by the stack.
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_SetPendingIRQ documentation in CMSIS.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt is set pending.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t sd_nvic_SetPendingIRQ(IRQn_Type IRQn);
|
||||
|
||||
/**@brief Clear Pending Interrupt.
|
||||
* @note Corresponds to NVIC_ClearPendingIRQ in CMSIS.
|
||||
*
|
||||
* @pre IRQn is valid and not reserved by the stack.
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_ClearPendingIRQ documentation in CMSIS.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt pending flag is cleared.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t sd_nvic_ClearPendingIRQ(IRQn_Type IRQn);
|
||||
|
||||
/**@brief Set Interrupt Priority.
|
||||
* @note Corresponds to NVIC_SetPriority in CMSIS.
|
||||
*
|
||||
* @pre IRQn is valid and not reserved by the stack.
|
||||
* @pre Priority is valid and not reserved by the stack.
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_SetPriority documentation in CMSIS.
|
||||
* @param[in] priority A valid IRQ priority for use by the application.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt and priority level is available for the application.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED The interrupt priority is not available for the application.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t sd_nvic_SetPriority(IRQn_Type IRQn, uint32_t priority);
|
||||
|
||||
/**@brief Get Interrupt Priority.
|
||||
* @note Corresponds to NVIC_GetPriority in CMSIS.
|
||||
*
|
||||
* @pre IRQn is valid and not reserved by the stack.
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_GetPriority documentation in CMSIS.
|
||||
* @param[out] p_priority Return value from NVIC_GetPriority.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt priority is returned in p_priority.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE - IRQn is not available for the application.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t sd_nvic_GetPriority(IRQn_Type IRQn, uint32_t * p_priority);
|
||||
|
||||
/**@brief System Reset.
|
||||
* @note Corresponds to NVIC_SystemReset in CMSIS.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN
|
||||
*/
|
||||
__STATIC_INLINE uint32_t sd_nvic_SystemReset(void);
|
||||
|
||||
/**@brief Enter critical region.
|
||||
*
|
||||
* @post Application interrupts will be disabled.
|
||||
* @note sd_nvic_critical_region_enter() and ::sd_nvic_critical_region_exit() must be called in matching pairs inside each
|
||||
* execution context
|
||||
* @sa sd_nvic_critical_region_exit
|
||||
*
|
||||
* @param[out] p_is_nested_critical_region If 1, the application is now in a nested critical region.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
__STATIC_INLINE uint32_t sd_nvic_critical_region_enter(uint8_t * p_is_nested_critical_region);
|
||||
|
||||
/**@brief Exit critical region.
|
||||
*
|
||||
* @pre Application has entered a critical region using ::sd_nvic_critical_region_enter.
|
||||
* @post If not in a nested critical region, the application interrupts will restored to the state before ::sd_nvic_critical_region_enter was called.
|
||||
*
|
||||
* @param[in] is_nested_critical_region If this is set to 1, the critical region won't be exited. @sa sd_nvic_critical_region_enter.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
__STATIC_INLINE uint32_t sd_nvic_critical_region_exit(uint8_t is_nested_critical_region);
|
||||
|
||||
/**@} */
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
__STATIC_INLINE int __sd_nvic_irq_disable(void)
|
||||
{
|
||||
int pm = __get_PRIMASK();
|
||||
__disable_irq();
|
||||
return pm;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void __sd_nvic_irq_enable(void)
|
||||
{
|
||||
__enable_irq();
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t __sd_nvic_app_accessible_irq(IRQn_Type IRQn)
|
||||
{
|
||||
if (IRQn < 32)
|
||||
{
|
||||
return ((1UL<<IRQn) & __NRF_NVIC_APP_IRQS_0) != 0;
|
||||
}
|
||||
#ifdef NRF52_SERIES
|
||||
else if (IRQn < 64)
|
||||
{
|
||||
return ((1UL<<(IRQn-32)) & __NRF_NVIC_APP_IRQS_1) != 0;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t __sd_nvic_is_app_accessible_priority(uint32_t priority)
|
||||
{
|
||||
if(priority >= (1 << __NVIC_PRIO_BITS))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#ifdef NRF51
|
||||
if( priority == 0
|
||||
|| priority == 2
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#ifdef NRF52_SERIES
|
||||
if( priority == 0
|
||||
|| priority == 1
|
||||
|| priority == 4
|
||||
|| priority == 5
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
__STATIC_INLINE uint32_t sd_nvic_EnableIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
if (!__sd_nvic_app_accessible_irq(IRQn))
|
||||
{
|
||||
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
|
||||
}
|
||||
if (!__sd_nvic_is_app_accessible_priority(NVIC_GetPriority(IRQn)))
|
||||
{
|
||||
return NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED;
|
||||
}
|
||||
|
||||
if (nrf_nvic_state.__cr_flag)
|
||||
{
|
||||
nrf_nvic_state.__irq_masks[(uint32_t)((int32_t)IRQn) >> 5] |= (uint32_t)(1 << ((uint32_t)((int32_t)IRQn) & (uint32_t)0x1F));
|
||||
}
|
||||
else
|
||||
{
|
||||
NVIC_EnableIRQ(IRQn);
|
||||
}
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t sd_nvic_DisableIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
if (!__sd_nvic_app_accessible_irq(IRQn))
|
||||
{
|
||||
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
if (nrf_nvic_state.__cr_flag)
|
||||
{
|
||||
nrf_nvic_state.__irq_masks[(uint32_t)((int32_t)IRQn) >> 5] &= ~(1UL << ((uint32_t)(IRQn) & 0x1F));
|
||||
}
|
||||
else
|
||||
{
|
||||
NVIC_DisableIRQ(IRQn);
|
||||
}
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t sd_nvic_GetPendingIRQ(IRQn_Type IRQn, uint32_t * p_pending_irq)
|
||||
{
|
||||
if (__sd_nvic_app_accessible_irq(IRQn))
|
||||
{
|
||||
*p_pending_irq = NVIC_GetPendingIRQ(IRQn);
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t sd_nvic_SetPendingIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
if (__sd_nvic_app_accessible_irq(IRQn))
|
||||
{
|
||||
NVIC_SetPendingIRQ(IRQn);
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t sd_nvic_ClearPendingIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
if (__sd_nvic_app_accessible_irq(IRQn))
|
||||
{
|
||||
NVIC_ClearPendingIRQ(IRQn);
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t sd_nvic_SetPriority(IRQn_Type IRQn, uint32_t priority)
|
||||
{
|
||||
if (!__sd_nvic_app_accessible_irq(IRQn))
|
||||
{
|
||||
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
if (!__sd_nvic_is_app_accessible_priority(priority))
|
||||
{
|
||||
return NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED;
|
||||
}
|
||||
|
||||
NVIC_SetPriority(IRQn, (uint32_t)priority);
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t sd_nvic_GetPriority(IRQn_Type IRQn, uint32_t * p_priority)
|
||||
{
|
||||
if (__sd_nvic_app_accessible_irq(IRQn))
|
||||
{
|
||||
*p_priority = (NVIC_GetPriority(IRQn) & 0xFF);
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t sd_nvic_SystemReset(void)
|
||||
{
|
||||
NVIC_SystemReset();
|
||||
return NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t sd_nvic_critical_region_enter(uint8_t * p_is_nested_critical_region)
|
||||
{
|
||||
int was_masked = __sd_nvic_irq_disable();
|
||||
if (!nrf_nvic_state.__cr_flag)
|
||||
{
|
||||
nrf_nvic_state.__cr_flag = 1;
|
||||
nrf_nvic_state.__irq_masks[0] = ( NVIC->ICER[0] & __NRF_NVIC_APP_IRQS_0 );
|
||||
NVIC->ICER[0] = __NRF_NVIC_APP_IRQS_0;
|
||||
#ifdef NRF52_SERIES
|
||||
nrf_nvic_state.__irq_masks[1] = ( NVIC->ICER[1] & __NRF_NVIC_APP_IRQS_1 );
|
||||
NVIC->ICER[1] = __NRF_NVIC_APP_IRQS_1;
|
||||
#endif
|
||||
*p_is_nested_critical_region = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*p_is_nested_critical_region = 1;
|
||||
}
|
||||
if (!was_masked)
|
||||
{
|
||||
__sd_nvic_irq_enable();
|
||||
}
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t sd_nvic_critical_region_exit(uint8_t is_nested_critical_region)
|
||||
{
|
||||
if (nrf_nvic_state.__cr_flag && (is_nested_critical_region == 0))
|
||||
{
|
||||
int was_masked = __sd_nvic_irq_disable();
|
||||
NVIC->ISER[0] = nrf_nvic_state.__irq_masks[0];
|
||||
#ifdef NRF52_SERIES
|
||||
NVIC->ISER[1] = nrf_nvic_state.__irq_masks[1];
|
||||
#endif
|
||||
nrf_nvic_state.__cr_flag = 0;
|
||||
if (!was_masked)
|
||||
{
|
||||
__sd_nvic_irq_enable();
|
||||
}
|
||||
}
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
#endif /* SUPPRESS_INLINE_IMPLEMENTATION */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_NVIC_H__
|
||||
|
||||
/**@} */
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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 NRF_SD_DEF_H__
|
||||
#define NRF_SD_DEF_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SD_PPI_CHANNELS_USED 0xFFFE0000uL /**< PPI channels utilized by SotfDevice (not available to the application). */
|
||||
#define SD_PPI_GROUPS_USED 0x0000000CuL /**< PPI groups utilized by SoftDevice (not available to the application). */
|
||||
#define SD_TIMERS_USED 0x00000001uL /**< Timers used by SoftDevice. */
|
||||
#define SD_SWI_USED 0x0000003CuL /**< Software interrupts used by SoftDevice */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NRF_SD_DEF_H__ */
|
||||
|
|
@ -1,335 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
@defgroup nrf_sdm_api SoftDevice Manager API
|
||||
@{
|
||||
|
||||
@brief APIs for SoftDevice management.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef NRF_SDM_H__
|
||||
#define NRF_SDM_H__
|
||||
|
||||
#include "nrf_svc.h"
|
||||
#include "nrf.h"
|
||||
#include "nrf_soc.h"
|
||||
#include "nrf_error_sdm.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup NRF_SDM_DEFINES Defines
|
||||
* @{ */
|
||||
#ifdef NRFSOC_DOXYGEN
|
||||
/// Declared in nrf_mbr.h
|
||||
#define MBR_SIZE 0
|
||||
#warning test
|
||||
#endif
|
||||
|
||||
/** @brief The major version for the SoftDevice binary distributed with this header file. */
|
||||
#define SD_MAJOR_VERSION (5)
|
||||
|
||||
/** @brief The minor version for the SoftDevice binary distributed with this header file. */
|
||||
#define SD_MINOR_VERSION (0)
|
||||
|
||||
/** @brief The bugfix version for the SoftDevice binary distributed with this header file. */
|
||||
#define SD_BUGFIX_VERSION (0)
|
||||
|
||||
/** @brief The full version number for the SoftDevice binary this header file was distributed
|
||||
* with, as a decimal number in the form Mmmmbbb, where:
|
||||
* - M is major version (one or more digits)
|
||||
* - mmm is minor version (three digits)
|
||||
* - bbb is bugfix version (three digits). */
|
||||
#define SD_VERSION (SD_MAJOR_VERSION * 1000000 + SD_MINOR_VERSION * 1000 + SD_BUGFIX_VERSION)
|
||||
|
||||
/** @brief SoftDevice Manager SVC Base number. */
|
||||
#define SDM_SVC_BASE 0x10
|
||||
|
||||
/** @brief Invalid info field. Returned when an info field does not exist. */
|
||||
#define SDM_INFO_FIELD_INVALID (0)
|
||||
|
||||
/** @brief Defines the SoftDevice Information Structure location (address) as an offset from
|
||||
the start of the softdevice (without MBR)*/
|
||||
#define SOFTDEVICE_INFO_STRUCT_OFFSET (0x2000)
|
||||
|
||||
/** @brief Defines the absolute SoftDevice Information Structure location (address) when the
|
||||
* SoftDevice is installed just above the MBR (the usual case). */
|
||||
#define SOFTDEVICE_INFO_STRUCT_ADDRESS (SOFTDEVICE_INFO_STRUCT_OFFSET + MBR_SIZE)
|
||||
|
||||
/** @brief Defines the offset for the SoftDevice Information Structure size value relative to the
|
||||
* SoftDevice base address. The size value is of type uint8_t. */
|
||||
#define SD_INFO_STRUCT_SIZE_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET)
|
||||
|
||||
/** @brief Defines the offset for the SoftDevice size value relative to the SoftDevice base address.
|
||||
* The size value is of type uint32_t. */
|
||||
#define SD_SIZE_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x08)
|
||||
|
||||
/** @brief Defines the offset for FWID value relative to the SoftDevice base address. The FWID value
|
||||
* is of type uint16_t. */
|
||||
#define SD_FWID_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x0C)
|
||||
|
||||
/** @brief Defines the offset for the SoftDevice ID relative to the SoftDevice base address. The ID
|
||||
* is of type uint32_t. */
|
||||
#define SD_ID_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x10)
|
||||
|
||||
/** @brief Defines the offset for the SoftDevice version relative to the SoftDevice base address in
|
||||
* the same format as @ref SD_VERSION, stored as an uint32_t. */
|
||||
#define SD_VERSION_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x14)
|
||||
|
||||
/** @brief Defines a macro for retreiving the actual SoftDevice Information Structure size value
|
||||
* from a given base address. Use @ref MBR_SIZE as the argument when the SoftDevice is
|
||||
* installed just above the MBR (the usual case). */
|
||||
#define SD_INFO_STRUCT_SIZE_GET(baseaddr) (*((uint8_t *) ((baseaddr) + SD_INFO_STRUCT_SIZE_OFFSET)))
|
||||
|
||||
/** @brief Defines a macro for retreiving the actual SoftDevice size value from a given base
|
||||
* address. Use @ref MBR_SIZE as the argument when the SoftDevice is installed just above
|
||||
* the MBR (the usual case). */
|
||||
#define SD_SIZE_GET(baseaddr) (*((uint32_t *) ((baseaddr) + SD_SIZE_OFFSET)))
|
||||
|
||||
/** @brief Defines a macro for retreiving the actual FWID value from a given base address. Use @ref
|
||||
* MBR_SIZE as the argument when the SoftDevice is installed just above the MBR (the usual
|
||||
* case). */
|
||||
#define SD_FWID_GET(baseaddr) (*((uint16_t *) ((baseaddr) + SD_FWID_OFFSET)))
|
||||
|
||||
/** @brief Defines a macro for retreiving the actual SoftDevice ID from a given base address. Use
|
||||
* @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR (the
|
||||
* usual case). */
|
||||
#define SD_ID_GET(baseaddr) ((SD_INFO_STRUCT_SIZE_GET(baseaddr) > (SD_ID_OFFSET - SOFTDEVICE_INFO_STRUCT_OFFSET)) \
|
||||
? (*((uint32_t *) ((baseaddr) + SD_ID_OFFSET))) : SDM_INFO_FIELD_INVALID)
|
||||
|
||||
/** @brief Defines a macro for retreiving the actual FWID value from a given base address. Use @ref
|
||||
* MBR_SIZE as the argument when the SoftDevice is installed just above the MBR (the usual
|
||||
* case). */
|
||||
#define SD_VERSION_GET(baseaddr) ((SD_INFO_STRUCT_SIZE_GET(baseaddr) > (SD_VERSION_OFFSET - SOFTDEVICE_INFO_STRUCT_OFFSET)) \
|
||||
? (*((uint32_t *) ((baseaddr) + SD_VERSION_OFFSET))) : SDM_INFO_FIELD_INVALID)
|
||||
|
||||
/**@defgroup NRF_FAULT_ID_RANGES Fault ID ranges
|
||||
* @{ */
|
||||
#define NRF_FAULT_ID_SD_RANGE_START 0x00000000 /**< SoftDevice ID range start. */
|
||||
#define NRF_FAULT_ID_APP_RANGE_START 0x00001000 /**< Application ID range start. */
|
||||
/**@} */
|
||||
|
||||
/**@defgroup NRF_FAULT_IDS Fault ID types
|
||||
* @{ */
|
||||
#define NRF_FAULT_ID_SD_ASSERT (NRF_FAULT_ID_SD_RANGE_START + 1) /**< SoftDevice assertion. The info parameter is reserved for future used. */
|
||||
#define NRF_FAULT_ID_APP_MEMACC (NRF_FAULT_ID_APP_RANGE_START + 1) /**< Application invalid memory access (nRF52 only). The info parameter will contain 0x00000000, in case of SoftDevice RAM
|
||||
access violation. In case of SoftDevice peripheral register violation the info parameter will contain the sub-region number of PREGION[0], on whose address range the unallowed
|
||||
write access caused the memory access fault. */
|
||||
/**@} */
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_SDM_ENUMS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief nRF SoftDevice Manager API SVC numbers. */
|
||||
enum NRF_SD_SVCS
|
||||
{
|
||||
SD_SOFTDEVICE_ENABLE = SDM_SVC_BASE, /**< ::sd_softdevice_enable */
|
||||
SD_SOFTDEVICE_DISABLE, /**< ::sd_softdevice_disable */
|
||||
SD_SOFTDEVICE_IS_ENABLED, /**< ::sd_softdevice_is_enabled */
|
||||
SD_SOFTDEVICE_VECTOR_TABLE_BASE_SET, /**< ::sd_softdevice_vector_table_base_set */
|
||||
SVC_SDM_LAST /**< Placeholder for last SDM SVC */
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_SDM_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@defgroup NRF_CLOCK_LF_XTAL_ACCURACY Clock accuracy
|
||||
* @{ */
|
||||
|
||||
#define NRF_CLOCK_LF_XTAL_ACCURACY_250_PPM (0) /**< Default: 250 ppm */
|
||||
#define NRF_CLOCK_LF_XTAL_ACCURACY_500_PPM (1) /**< 500 ppm */
|
||||
#define NRF_CLOCK_LF_XTAL_ACCURACY_150_PPM (2) /**< 150 ppm */
|
||||
#define NRF_CLOCK_LF_XTAL_ACCURACY_100_PPM (3) /**< 100 ppm */
|
||||
#define NRF_CLOCK_LF_XTAL_ACCURACY_75_PPM (4) /**< 75 ppm */
|
||||
#define NRF_CLOCK_LF_XTAL_ACCURACY_50_PPM (5) /**< 50 ppm */
|
||||
#define NRF_CLOCK_LF_XTAL_ACCURACY_30_PPM (6) /**< 30 ppm */
|
||||
#define NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM (7) /**< 20 ppm */
|
||||
|
||||
/** @} */
|
||||
|
||||
/**@defgroup NRF_CLOCK_LF_SRC Possible lfclk oscillator sources
|
||||
* @{ */
|
||||
|
||||
#define NRF_CLOCK_LF_SRC_RC (0) /**< LFCLK RC oscillator. */
|
||||
#define NRF_CLOCK_LF_SRC_XTAL (1) /**< LFCLK crystal oscillator. */
|
||||
#define NRF_CLOCK_LF_SRC_SYNTH (2) /**< LFCLK Synthesized from HFCLK. */
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_SDM_TYPES Types
|
||||
* @{ */
|
||||
|
||||
/**@brief Type representing lfclk oscillator source. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t source; /**< LF oscillator clock source, see @ref NRF_CLOCK_LF_SRC. */
|
||||
uint8_t rc_ctiv; /**< Only for NRF_CLOCK_LF_SRC_RC: Calibration timer interval in 1/4 second
|
||||
units (nRF51: 1-64, nRF52: 1-32).
|
||||
@note To avoid excessive clock drift, 0.5 degrees Celsius is the
|
||||
maximum temperature change allowed in one calibration timer
|
||||
interval. The interval should be selected to ensure this.
|
||||
|
||||
@note Must be 0 if source is not NRF_CLOCK_LF_SRC_RC. */
|
||||
uint8_t rc_temp_ctiv; /**< Only for NRF_CLOCK_LF_SRC_RC: How often (in number of calibration
|
||||
intervals) the RC oscillator shall be calibrated if the temperature
|
||||
hasn't changed.
|
||||
0: Always calibrate even if the temperature hasn't changed.
|
||||
1: Only calibrate if the temperature has changed (nRF51 only).
|
||||
2-33: Check the temperature and only calibrate if it has changed,
|
||||
however calibration will take place every rc_temp_ctiv
|
||||
intervals in any case.
|
||||
|
||||
@note Must be 0 if source is not NRF_CLOCK_LF_SRC_RC.
|
||||
|
||||
@note For nRF52, the application must ensure calibration at least once
|
||||
every 8 seconds to ensure +/-250ppm clock stability. The
|
||||
recommended configuration for NRF_CLOCK_LF_SRC_RC on nRF52 is
|
||||
rc_ctiv=16 and rc_temp_ctiv=2. This will ensure calibration at
|
||||
least once every 8 seconds and for temperature changes of 0.5
|
||||
degrees Celsius every 4 seconds. See the Product Specification
|
||||
for the nRF52 device being used for more information.*/
|
||||
uint8_t xtal_accuracy; /**< External crystal clock accuracy used in the LL to compute timing windows.
|
||||
|
||||
@note For the NRF_CLOCK_LF_SRC_RC clock source this parameter is ignored. */
|
||||
} nrf_clock_lf_cfg_t;
|
||||
|
||||
/**@brief Fault Handler type.
|
||||
*
|
||||
* When certain unrecoverable errors occur within the application or SoftDevice the fault handler will be called back.
|
||||
* The protocol stack will be in an undefined state when this happens and the only way to recover will be to
|
||||
* perform a reset, using e.g. CMSIS NVIC_SystemReset().
|
||||
* If the application returns from the fault handler the SoftDevice will call NVIC_SystemReset().
|
||||
*
|
||||
* @note This callback is executed in HardFault context, thus SVC functions cannot be called from the fault callback.
|
||||
*
|
||||
* @param[in] id Fault identifier. See @ref NRF_FAULT_IDS.
|
||||
* @param[in] pc The program counter of the instruction that triggered the fault.
|
||||
* @param[in] info Optional additional information regarding the fault. Refer to each Fault identifier for details.
|
||||
*
|
||||
* @note When id is set to NRF_FAULT_ID_APP_MEMACC, pc will contain the address of the instruction being executed at the time when
|
||||
* the fault is detected by the CPU. The CPU program counter may have advanced up to 2 instructions (no branching) after the one that triggered the fault.
|
||||
*/
|
||||
typedef void (*nrf_fault_handler_t)(uint32_t id, uint32_t pc, uint32_t info);
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_SDM_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Enables the SoftDevice and by extension the protocol stack.
|
||||
*
|
||||
* @note Some care must be taken if a low frequency clock source is already running when calling this function:
|
||||
* If the LF clock has a different source then the one currently running, it will be stopped. Then, the new
|
||||
* clock source will be started.
|
||||
*
|
||||
* @note This function has no effect when returning with an error.
|
||||
*
|
||||
* @post If return code is ::NRF_SUCCESS
|
||||
* - SoC library and protocol stack APIs are made available.
|
||||
* - A portion of RAM will be unavailable (see relevant SDS documentation).
|
||||
* - Some peripherals will be unavailable or available only through the SoC API (see relevant SDS documentation).
|
||||
* - Interrupts will not arrive from protected peripherals or interrupts.
|
||||
* - nrf_nvic_ functions must be used instead of CMSIS NVIC_ functions for reliable usage of the SoftDevice.
|
||||
* - Interrupt latency may be affected by the SoftDevice (see relevant SDS documentation).
|
||||
* - Chosen low frequency clock source will be running.
|
||||
*
|
||||
* @param p_clock_lf_cfg Low frequency clock source and accuracy.
|
||||
If NULL the clock will be configured as an rc source with rc_ctiv = 16 and .rc_temp_ctiv = 2
|
||||
In the case of XTAL source, the PPM accuracy of the chosen clock source must be greater than or equal to the actual characteristics of your XTAL clock.
|
||||
* @param fault_handler Callback to be invoked in case of fault, cannot be NULL.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid or NULL pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE SoftDevice is already enabled, and the clock source and fault handler cannot be updated.
|
||||
* @retval ::NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION SoftDevice interrupt is already enabled, or an enabled interrupt has an illegal priority level.
|
||||
* @retval ::NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN Unknown low frequency clock source selected.
|
||||
*/
|
||||
SVCALL(SD_SOFTDEVICE_ENABLE, uint32_t, sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg, nrf_fault_handler_t fault_handler));
|
||||
|
||||
|
||||
/**@brief Disables the SoftDevice and by extension the protocol stack.
|
||||
*
|
||||
* Idempotent function to disable the SoftDevice.
|
||||
*
|
||||
* @post SoC library and protocol stack APIs are made unavailable.
|
||||
* @post All interrupts that was protected by the SoftDevice will be disabled and initialized to priority 0 (highest).
|
||||
* @post All peripherals used by the SoftDevice will be reset to default values.
|
||||
* @post All of RAM become available.
|
||||
* @post All interrupts are forwarded to the application.
|
||||
* @post LFCLK source chosen in ::sd_softdevice_enable will be left running.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_SOFTDEVICE_DISABLE, uint32_t, sd_softdevice_disable(void));
|
||||
|
||||
/**@brief Check if the SoftDevice is enabled.
|
||||
*
|
||||
* @param[out] p_softdevice_enabled If the SoftDevice is enabled: 1 else 0.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_SOFTDEVICE_IS_ENABLED, uint32_t, sd_softdevice_is_enabled(uint8_t * p_softdevice_enabled));
|
||||
|
||||
/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the SoftDevice
|
||||
*
|
||||
* This function is only intended to be called when a bootloader is enabled.
|
||||
*
|
||||
* @param[in] address The base address of the interrupt vector table for forwarded interrupts.
|
||||
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_SOFTDEVICE_VECTOR_TABLE_BASE_SET, uint32_t, sd_softdevice_vector_table_base_set(uint32_t address));
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_SDM_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,908 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @defgroup nrf_soc_api SoC Library API
|
||||
* @{
|
||||
*
|
||||
* @brief APIs for the SoC library.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NRF_SOC_H__
|
||||
#define NRF_SOC_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "nrf_svc.h"
|
||||
#include "nrf.h"
|
||||
|
||||
#include "nrf_error_soc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**@addtogroup NRF_SOC_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@brief The number of the lowest SVC number reserved for the SoC library. */
|
||||
#define SOC_SVC_BASE (0x20) /**< Base value for SVCs that are available when the SoftDevice is disabled. */
|
||||
#define SOC_SVC_BASE_NOT_AVAILABLE (0x2B) /**< Base value for SVCs that are not available when the SoftDevice is disabled. */
|
||||
|
||||
/**@brief Guranteed time for application to process radio inactive notification. */
|
||||
#define NRF_RADIO_NOTIFICATION_INACTIVE_GUARANTEED_TIME_US (62)
|
||||
|
||||
/**@brief The minimum allowed timeslot extension time. */
|
||||
#define NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US (200)
|
||||
|
||||
#define SOC_ECB_KEY_LENGTH (16) /**< ECB key length. */
|
||||
#define SOC_ECB_CLEARTEXT_LENGTH (16) /**< ECB cleartext length. */
|
||||
#define SOC_ECB_CIPHERTEXT_LENGTH (SOC_ECB_CLEARTEXT_LENGTH) /**< ECB ciphertext length. */
|
||||
|
||||
#ifdef NRF51
|
||||
#define SD_EVT_IRQn (SWI2_IRQn) /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */
|
||||
#define SD_EVT_IRQHandler (SWI2_IRQHandler) /**< SoftDevice Event IRQ handler. Used for both protocol events and SoC events. */
|
||||
#define RADIO_NOTIFICATION_IRQn (SWI1_IRQn) /**< The radio notification IRQ number. */
|
||||
#define RADIO_NOTIFICATION_IRQHandler (SWI1_IRQHandler) /**< The radio notification IRQ handler. */
|
||||
#endif
|
||||
#ifdef NRF52_SERIES
|
||||
#define SD_EVT_IRQn (SWI2_EGU2_IRQn) /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */
|
||||
#define SD_EVT_IRQHandler (SWI2_EGU2_IRQHandler) /**< SoftDevice Event IRQ handler. Used for both protocol events and SoC events. */
|
||||
#define RADIO_NOTIFICATION_IRQn (SWI1_EGU1_IRQn) /**< The radio notification IRQ number. */
|
||||
#define RADIO_NOTIFICATION_IRQHandler (SWI1_EGU1_IRQHandler) /**< The radio notification IRQ handler. */
|
||||
#endif
|
||||
|
||||
#define NRF_RADIO_LENGTH_MIN_US (100) /**< The shortest allowed radio timeslot, in microseconds. */
|
||||
#define NRF_RADIO_LENGTH_MAX_US (100000) /**< The longest allowed radio timeslot, in microseconds. */
|
||||
|
||||
#define NRF_RADIO_DISTANCE_MAX_US (128000000UL - 1UL) /**< The longest timeslot distance, in microseconds, allowed for the distance parameter (see @ref nrf_radio_request_normal_t) in the request. */
|
||||
|
||||
#define NRF_RADIO_EARLIEST_TIMEOUT_MAX_US (128000000UL - 1UL) /**< The longest timeout, in microseconds, allowed when requesting the earliest possible timeslot. */
|
||||
|
||||
#define NRF_RADIO_START_JITTER_US (2) /**< The maximum jitter in @ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START relative to the requested start time. */
|
||||
|
||||
/**@} */
|
||||
|
||||
/**@addtogroup NRF_SOC_ENUMS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief The SVC numbers used by the SVC functions in the SoC library. */
|
||||
enum NRF_SOC_SVCS
|
||||
{
|
||||
SD_PPI_CHANNEL_ENABLE_GET = SOC_SVC_BASE,
|
||||
SD_PPI_CHANNEL_ENABLE_SET,
|
||||
SD_PPI_CHANNEL_ENABLE_CLR,
|
||||
SD_PPI_CHANNEL_ASSIGN,
|
||||
SD_PPI_GROUP_TASK_ENABLE,
|
||||
SD_PPI_GROUP_TASK_DISABLE,
|
||||
SD_PPI_GROUP_ASSIGN,
|
||||
SD_PPI_GROUP_GET,
|
||||
SD_FLASH_PAGE_ERASE,
|
||||
SD_FLASH_WRITE,
|
||||
SD_FLASH_PROTECT,
|
||||
SD_MUTEX_NEW = SOC_SVC_BASE_NOT_AVAILABLE,
|
||||
SD_MUTEX_ACQUIRE,
|
||||
SD_MUTEX_RELEASE,
|
||||
SD_RAND_APPLICATION_POOL_CAPACITY_GET,
|
||||
SD_RAND_APPLICATION_BYTES_AVAILABLE_GET,
|
||||
SD_RAND_APPLICATION_VECTOR_GET,
|
||||
SD_POWER_MODE_SET,
|
||||
SD_POWER_SYSTEM_OFF,
|
||||
SD_POWER_RESET_REASON_GET,
|
||||
SD_POWER_RESET_REASON_CLR,
|
||||
SD_POWER_POF_ENABLE,
|
||||
SD_POWER_POF_THRESHOLD_SET,
|
||||
SD_POWER_RAMON_SET,
|
||||
SD_POWER_RAMON_CLR,
|
||||
SD_POWER_RAMON_GET,
|
||||
SD_POWER_GPREGRET_SET,
|
||||
SD_POWER_GPREGRET_CLR,
|
||||
SD_POWER_GPREGRET_GET,
|
||||
SD_POWER_DCDC_MODE_SET,
|
||||
SD_APP_EVT_WAIT,
|
||||
SD_CLOCK_HFCLK_REQUEST,
|
||||
SD_CLOCK_HFCLK_RELEASE,
|
||||
SD_CLOCK_HFCLK_IS_RUNNING,
|
||||
SD_RADIO_NOTIFICATION_CFG_SET,
|
||||
SD_ECB_BLOCK_ENCRYPT,
|
||||
SD_ECB_BLOCKS_ENCRYPT,
|
||||
SD_RADIO_SESSION_OPEN,
|
||||
SD_RADIO_SESSION_CLOSE,
|
||||
SD_RADIO_REQUEST,
|
||||
SD_EVT_GET,
|
||||
SD_TEMP_GET,
|
||||
SVC_SOC_LAST
|
||||
};
|
||||
|
||||
/**@brief Possible values of a ::nrf_mutex_t. */
|
||||
enum NRF_MUTEX_VALUES
|
||||
{
|
||||
NRF_MUTEX_FREE,
|
||||
NRF_MUTEX_TAKEN
|
||||
};
|
||||
|
||||
/**@brief Power modes. */
|
||||
enum NRF_POWER_MODES
|
||||
{
|
||||
NRF_POWER_MODE_CONSTLAT, /**< Constant latency mode. See power management in the reference manual. */
|
||||
NRF_POWER_MODE_LOWPWR /**< Low power mode. See power management in the reference manual. */
|
||||
};
|
||||
|
||||
|
||||
/**@brief Power failure thresholds */
|
||||
enum NRF_POWER_THRESHOLDS
|
||||
{
|
||||
NRF_POWER_THRESHOLD_V21, /**< 2.1 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLD_V23, /**< 2.3 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLD_V25, /**< 2.5 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLD_V27 /**< 2.7 Volts power failure threshold. */
|
||||
};
|
||||
|
||||
|
||||
/**@brief DC/DC converter modes. */
|
||||
enum NRF_POWER_DCDC_MODES
|
||||
{
|
||||
NRF_POWER_DCDC_DISABLE, /**< The DCDC is disabled. */
|
||||
NRF_POWER_DCDC_ENABLE /**< The DCDC is enabled. */
|
||||
};
|
||||
|
||||
/**@brief Radio notification distances. */
|
||||
enum NRF_RADIO_NOTIFICATION_DISTANCES
|
||||
{
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_NONE = 0, /**< The event does not have a notification. */
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_800US, /**< The distance from the active notification to start of radio activity. */
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_1740US, /**< The distance from the active notification to start of radio activity. */
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_2680US, /**< The distance from the active notification to start of radio activity. */
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_3620US, /**< The distance from the active notification to start of radio activity. */
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_4560US, /**< The distance from the active notification to start of radio activity. */
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_5500US /**< The distance from the active notification to start of radio activity. */
|
||||
};
|
||||
|
||||
|
||||
/**@brief Radio notification types. */
|
||||
enum NRF_RADIO_NOTIFICATION_TYPES
|
||||
{
|
||||
NRF_RADIO_NOTIFICATION_TYPE_NONE = 0, /**< The event does not have a radio notification signal. */
|
||||
NRF_RADIO_NOTIFICATION_TYPE_INT_ON_ACTIVE, /**< Using interrupt for notification when the radio will be enabled. */
|
||||
NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE, /**< Using interrupt for notification when the radio has been disabled. */
|
||||
NRF_RADIO_NOTIFICATION_TYPE_INT_ON_BOTH, /**< Using interrupt for notification both when the radio will be enabled and disabled. */
|
||||
};
|
||||
|
||||
/**@brief The Radio signal callback types. */
|
||||
enum NRF_RADIO_CALLBACK_SIGNAL_TYPE
|
||||
{
|
||||
NRF_RADIO_CALLBACK_SIGNAL_TYPE_START, /**< This signal indicates the start of the radio timeslot. */
|
||||
NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0, /**< This signal indicates the NRF_TIMER0 interrupt. */
|
||||
NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO, /**< This signal indicates the NRF_RADIO interrupt. */
|
||||
NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_FAILED, /**< This signal indicates extend action failed. */
|
||||
NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_SUCCEEDED /**< This signal indicates extend action succeeded. */
|
||||
};
|
||||
|
||||
/**@brief The actions requested by the signal callback.
|
||||
*
|
||||
* This code gives the SOC instructions about what action to take when the signal callback has
|
||||
* returned.
|
||||
*/
|
||||
enum NRF_RADIO_SIGNAL_CALLBACK_ACTION
|
||||
{
|
||||
NRF_RADIO_SIGNAL_CALLBACK_ACTION_NONE, /**< Return without action. */
|
||||
NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND, /**< Request an extension of the current timeslot (maximum execution time for this action is when the extension succeeded). */
|
||||
NRF_RADIO_SIGNAL_CALLBACK_ACTION_END, /**< End the current radio timeslot. */
|
||||
NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END /**< Request a new radio timeslot and end the current timeslot. */
|
||||
};
|
||||
|
||||
/**@brief Radio timeslot high frequency clock source configuration. */
|
||||
enum NRF_RADIO_HFCLK_CFG
|
||||
{
|
||||
NRF_RADIO_HFCLK_CFG_XTAL_GUARANTEED, /**< The SoftDevice will guarantee that the high frequency clock source is the
|
||||
external crystal for the whole duration of the timeslot. This should be the
|
||||
preferred option for events that use the radio or require high timing accuracy. */
|
||||
NRF_RADIO_HFCLK_CFG_NO_GUARANTEE /**< This configuration allows for earlier and tighter scheduling of timeslots.
|
||||
The RC oscillator may be the clock source in part or for the whole duration of the timeslot.
|
||||
The RC oscillator's accuracy must therefore be taken into consideration.
|
||||
@note If the application will use the radio peripheral in timeslots with this configuration,
|
||||
it must make sure that the crystal is running and stable before starting the radio. */
|
||||
};
|
||||
|
||||
/**@brief Radio timeslot priorities. */
|
||||
enum NRF_RADIO_PRIORITY
|
||||
{
|
||||
NRF_RADIO_PRIORITY_HIGH, /**< High (equal priority as the normal connection priority of the SoftDevice stack(s)). */
|
||||
NRF_RADIO_PRIORITY_NORMAL, /**< Normal (equal priority as the priority of secondary activites of the SoftDevice stack(s)). */
|
||||
};
|
||||
|
||||
/**@brief Radio timeslot request type. */
|
||||
enum NRF_RADIO_REQUEST_TYPE
|
||||
{
|
||||
NRF_RADIO_REQ_TYPE_EARLIEST, /**< Request radio timeslot as early as possible. This should always be used for the first request in a session. */
|
||||
NRF_RADIO_REQ_TYPE_NORMAL /**< Normal radio timeslot request. */
|
||||
};
|
||||
|
||||
/**@brief SoC Events. */
|
||||
enum NRF_SOC_EVTS
|
||||
{
|
||||
NRF_EVT_HFCLKSTARTED, /**< Event indicating that the HFCLK has started. */
|
||||
NRF_EVT_POWER_FAILURE_WARNING, /**< Event indicating that a power failure warning has occurred. */
|
||||
NRF_EVT_FLASH_OPERATION_SUCCESS, /**< Event indicating that the ongoing flash operation has completed successfully. */
|
||||
NRF_EVT_FLASH_OPERATION_ERROR, /**< Event indicating that the ongoing flash operation has timed out with an error. */
|
||||
NRF_EVT_RADIO_BLOCKED, /**< Event indicating that a radio timeslot was blocked. */
|
||||
NRF_EVT_RADIO_CANCELED, /**< Event indicating that a radio timeslot was canceled by SoftDevice. */
|
||||
NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN, /**< Event indicating that a radio timeslot signal callback handler return was invalid. */
|
||||
NRF_EVT_RADIO_SESSION_IDLE, /**< Event indicating that a radio timeslot session is idle. */
|
||||
NRF_EVT_RADIO_SESSION_CLOSED, /**< Event indicating that a radio timeslot session is closed. */
|
||||
NRF_EVT_NUMBER_OF_EVTS
|
||||
};
|
||||
|
||||
/**@} */
|
||||
|
||||
|
||||
/**@addtogroup NRF_SOC_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**@brief Represents a mutex for use with the nrf_mutex functions.
|
||||
* @note Accessing the value directly is not safe, use the mutex functions!
|
||||
*/
|
||||
typedef volatile uint8_t nrf_mutex_t;
|
||||
|
||||
/**@brief Parameters for a request for a timeslot as early as possible. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t hfclk; /**< High frequency clock source, see @ref NRF_RADIO_HFCLK_CFG. */
|
||||
uint8_t priority; /**< The radio timeslot priority, see @ref NRF_RADIO_PRIORITY. */
|
||||
uint32_t length_us; /**< The radio timeslot length (in the range 100 to 100,000] microseconds). */
|
||||
uint32_t timeout_us; /**< Longest acceptable delay until the start of the requested timeslot (up to @ref NRF_RADIO_EARLIEST_TIMEOUT_MAX_US microseconds). */
|
||||
} nrf_radio_request_earliest_t;
|
||||
|
||||
/**@brief Parameters for a normal radio timeslot request. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t hfclk; /**< High frequency clock source, see @ref NRF_RADIO_HFCLK_CFG. */
|
||||
uint8_t priority; /**< The radio timeslot priority, see @ref NRF_RADIO_PRIORITY. */
|
||||
uint32_t distance_us; /**< Distance from the start of the previous radio timeslot (up to @ref NRF_RADIO_DISTANCE_MAX_US microseconds). */
|
||||
uint32_t length_us; /**< The radio timeslot length (in the range [100..100,000] microseconds). */
|
||||
} nrf_radio_request_normal_t;
|
||||
|
||||
/**@brief Radio timeslot request parameters. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t request_type; /**< Type of request, see @ref NRF_RADIO_REQUEST_TYPE. */
|
||||
union
|
||||
{
|
||||
nrf_radio_request_earliest_t earliest; /**< Parameters for requesting a radio timeslot as early as possible. */
|
||||
nrf_radio_request_normal_t normal; /**< Parameters for requesting a normal radio timeslot. */
|
||||
} params; /**< Parameter union. */
|
||||
} nrf_radio_request_t;
|
||||
|
||||
/**@brief Return parameters of the radio timeslot signal callback. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t callback_action; /**< The action requested by the application when returning from the signal callback, see @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION. */
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
nrf_radio_request_t * p_next; /**< The request parameters for the next radio timeslot. */
|
||||
} request; /**< Additional parameters for return_code @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END. */
|
||||
struct
|
||||
{
|
||||
uint32_t length_us; /**< Requested extension of the radio timeslot duration (microseconds) (for minimum time see @ref NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US). */
|
||||
} extend; /**< Additional parameters for return_code @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND. */
|
||||
} params; /**< Parameter union. */
|
||||
} nrf_radio_signal_callback_return_param_t;
|
||||
|
||||
/**@brief The radio timeslot signal callback type.
|
||||
*
|
||||
* @note In case of invalid return parameters, the radio timeslot will automatically end
|
||||
* immediately after returning from the signal callback and the
|
||||
* @ref NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN event will be sent.
|
||||
* @note The returned struct pointer must remain valid after the signal callback
|
||||
* function returns. For instance, this means that it must not point to a stack variable.
|
||||
*
|
||||
* @param[in] signal_type Type of signal, see @ref NRF_RADIO_CALLBACK_SIGNAL_TYPE.
|
||||
*
|
||||
* @return Pointer to structure containing action requested by the application.
|
||||
*/
|
||||
typedef nrf_radio_signal_callback_return_param_t * (*nrf_radio_signal_callback_t) (uint8_t signal_type);
|
||||
|
||||
/**@brief AES ECB parameter typedefs */
|
||||
typedef uint8_t soc_ecb_key_t[SOC_ECB_KEY_LENGTH]; /**< Encryption key type. */
|
||||
typedef uint8_t soc_ecb_cleartext_t[SOC_ECB_CLEARTEXT_LENGTH]; /**< Cleartext data type. */
|
||||
typedef uint8_t soc_ecb_ciphertext_t[SOC_ECB_CIPHERTEXT_LENGTH]; /**< Ciphertext data type. */
|
||||
|
||||
/**@brief AES ECB data structure */
|
||||
typedef struct
|
||||
{
|
||||
soc_ecb_key_t key; /**< Encryption key. */
|
||||
soc_ecb_cleartext_t cleartext; /**< Cleartext data. */
|
||||
soc_ecb_ciphertext_t ciphertext; /**< Ciphertext data. */
|
||||
} nrf_ecb_hal_data_t;
|
||||
|
||||
/**@brief AES ECB block. Used to provide multiple blocks in a single call
|
||||
to @ref sd_ecb_blocks_encrypt.*/
|
||||
typedef struct
|
||||
{
|
||||
soc_ecb_key_t* p_key; /**< Pointer to the Encryption key. */
|
||||
soc_ecb_cleartext_t* p_cleartext; /**< Pointer to the Cleartext data. */
|
||||
soc_ecb_ciphertext_t* p_ciphertext; /**< Pointer to the Ciphertext data. */
|
||||
} nrf_ecb_hal_data_block_t;
|
||||
|
||||
/**@} */
|
||||
|
||||
/**@addtogroup NRF_SOC_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Initialize a mutex.
|
||||
*
|
||||
* @param[in] p_mutex Pointer to the mutex to initialize.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_MUTEX_NEW, uint32_t, sd_mutex_new(nrf_mutex_t * p_mutex));
|
||||
|
||||
/**@brief Attempt to acquire a mutex.
|
||||
*
|
||||
* @param[in] p_mutex Pointer to the mutex to acquire.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The mutex was successfully acquired.
|
||||
* @retval ::NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN The mutex could not be acquired.
|
||||
*/
|
||||
SVCALL(SD_MUTEX_ACQUIRE, uint32_t, sd_mutex_acquire(nrf_mutex_t * p_mutex));
|
||||
|
||||
/**@brief Release a mutex.
|
||||
*
|
||||
* @param[in] p_mutex Pointer to the mutex to release.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_MUTEX_RELEASE, uint32_t, sd_mutex_release(nrf_mutex_t * p_mutex));
|
||||
|
||||
/**@brief Query the capacity of the application random pool.
|
||||
*
|
||||
* @param[out] p_pool_capacity The capacity of the pool.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_RAND_APPLICATION_POOL_CAPACITY_GET, uint32_t, sd_rand_application_pool_capacity_get(uint8_t * p_pool_capacity));
|
||||
|
||||
/**@brief Get number of random bytes available to the application.
|
||||
*
|
||||
* @param[out] p_bytes_available The number of bytes currently available in the pool.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_RAND_APPLICATION_BYTES_AVAILABLE_GET, uint32_t, sd_rand_application_bytes_available_get(uint8_t * p_bytes_available));
|
||||
|
||||
/**@brief Get random bytes from the application pool.
|
||||
*
|
||||
* @param[out] p_buff Pointer to unit8_t buffer for storing the bytes.
|
||||
* @param[in] length Number of bytes to take from pool and place in p_buff.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The requested bytes were written to p_buff.
|
||||
* @retval ::NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES No bytes were written to the buffer, because there were not enough bytes available.
|
||||
*/
|
||||
SVCALL(SD_RAND_APPLICATION_VECTOR_GET, uint32_t, sd_rand_application_vector_get(uint8_t * p_buff, uint8_t length));
|
||||
|
||||
/**@brief Gets the reset reason register.
|
||||
*
|
||||
* @param[out] p_reset_reason Contents of the NRF_POWER->RESETREAS register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_RESET_REASON_GET, uint32_t, sd_power_reset_reason_get(uint32_t * p_reset_reason));
|
||||
|
||||
/**@brief Clears the bits of the reset reason register.
|
||||
*
|
||||
* @param[in] reset_reason_clr_msk Contains the bits to clear from the reset reason register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_RESET_REASON_CLR, uint32_t, sd_power_reset_reason_clr(uint32_t reset_reason_clr_msk));
|
||||
|
||||
/**@brief Sets the power mode when in CPU sleep.
|
||||
*
|
||||
* @param[in] power_mode The power mode to use when in CPU sleep, see @ref NRF_POWER_MODES. @sa sd_app_evt_wait
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The power mode was set.
|
||||
* @retval ::NRF_ERROR_SOC_POWER_MODE_UNKNOWN The power mode was unknown.
|
||||
*/
|
||||
SVCALL(SD_POWER_MODE_SET, uint32_t, sd_power_mode_set(uint8_t power_mode));
|
||||
|
||||
/**@brief Puts the chip in System OFF mode.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN
|
||||
*/
|
||||
SVCALL(SD_POWER_SYSTEM_OFF, uint32_t, sd_power_system_off(void));
|
||||
|
||||
/**@brief Enables or disables the power-fail comparator.
|
||||
*
|
||||
* Enabling this will give a softdevice event (NRF_EVT_POWER_FAILURE_WARNING) when the power failure warning occurs.
|
||||
* The event can be retrieved with sd_evt_get();
|
||||
*
|
||||
* @param[in] pof_enable True if the power-fail comparator should be enabled, false if it should be disabled.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_POF_ENABLE, uint32_t, sd_power_pof_enable(uint8_t pof_enable));
|
||||
|
||||
/**@brief Sets the power-fail threshold value.
|
||||
*
|
||||
* @param[in] threshold The power-fail threshold value to use, see @ref NRF_POWER_THRESHOLDS.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The power failure threshold was set.
|
||||
* @retval ::NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN The power failure threshold is unknown.
|
||||
*/
|
||||
SVCALL(SD_POWER_POF_THRESHOLD_SET, uint32_t, sd_power_pof_threshold_set(uint8_t threshold));
|
||||
|
||||
/**@brief Sets bits in the NRF_POWER->RAMON register.
|
||||
*
|
||||
* @param[in] ramon Contains the bits needed to be set in the NRF_POWER->RAMON register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_RAMON_SET, uint32_t, sd_power_ramon_set(uint32_t ramon));
|
||||
|
||||
/**@brief Clears bits in the NRF_POWER->RAMON register.
|
||||
*
|
||||
* @param ramon Contains the bits needed to be cleared in the NRF_POWER->RAMON register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_RAMON_CLR, uint32_t, sd_power_ramon_clr(uint32_t ramon));
|
||||
|
||||
/**@brief Get contents of NRF_POWER->RAMON register, indicates power status of ram blocks.
|
||||
*
|
||||
* @param[out] p_ramon Content of NRF_POWER->RAMON register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_RAMON_GET, uint32_t, sd_power_ramon_get(uint32_t * p_ramon));
|
||||
|
||||
/**@brief Set bits in the general purpose retention registers (NRF_POWER->GPREGRET*).
|
||||
*
|
||||
* @param[in] gpregret_id 0 for GPREGRET, 1 for GPREGRET2.
|
||||
* @param[in] gpregret_msk Bits to be set in the GPREGRET register.
|
||||
*
|
||||
* @note nRF51 does only have one general purpose retained register, so gpregret_id must be 0 on nRF51.
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_GPREGRET_SET, uint32_t, sd_power_gpregret_set(uint32_t gpregret_id, uint32_t gpregret_msk));
|
||||
|
||||
/**@brief Clear bits in the general purpose retention registers (NRF_POWER->GPREGRET*).
|
||||
*
|
||||
* @param[in] gpregret_id 0 for GPREGRET, 1 for GPREGRET2.
|
||||
* @param[in] gpregret_msk Bits to be clear in the GPREGRET register.
|
||||
*
|
||||
* @note nRF51 does only have one general purpose retained register, so gpregret_id must be 0 on nRF51.
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_GPREGRET_CLR, uint32_t, sd_power_gpregret_clr(uint32_t gpregret_id, uint32_t gpregret_msk));
|
||||
|
||||
/**@brief Get contents of the general purpose retention registers (NRF_POWER->GPREGRET*).
|
||||
*
|
||||
* @param[in] gpregret_id 0 for GPREGRET, 1 for GPREGRET2.
|
||||
* @param[out] p_gpregret Contents of the GPREGRET register.
|
||||
*
|
||||
* @note nRF51 does only have one general purpose retained register, so gpregret_id must be 0 on nRF51.
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_GPREGRET_GET, uint32_t, sd_power_gpregret_get(uint32_t gpregret_id, uint32_t *p_gpregret));
|
||||
|
||||
/**@brief Sets the DCDC mode.
|
||||
*
|
||||
* Enable or disable the DCDC peripheral.
|
||||
*
|
||||
* @param[in] dcdc_mode The mode of the DCDC, see @ref NRF_POWER_DCDC_MODES.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM The DCDC mode is invalid.
|
||||
*/
|
||||
SVCALL(SD_POWER_DCDC_MODE_SET, uint32_t, sd_power_dcdc_mode_set(uint8_t dcdc_mode));
|
||||
|
||||
/**@brief Request the high frequency crystal oscillator.
|
||||
*
|
||||
* Will start the high frequency crystal oscillator, the startup time of the crystal varies
|
||||
* and the ::sd_clock_hfclk_is_running function can be polled to check if it has started.
|
||||
*
|
||||
* @see sd_clock_hfclk_is_running
|
||||
* @see sd_clock_hfclk_release
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_CLOCK_HFCLK_REQUEST, uint32_t, sd_clock_hfclk_request(void));
|
||||
|
||||
/**@brief Releases the high frequency crystal oscillator.
|
||||
*
|
||||
* Will stop the high frequency crystal oscillator, this happens immediately.
|
||||
*
|
||||
* @see sd_clock_hfclk_is_running
|
||||
* @see sd_clock_hfclk_request
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_CLOCK_HFCLK_RELEASE, uint32_t, sd_clock_hfclk_release(void));
|
||||
|
||||
/**@brief Checks if the high frequency crystal oscillator is running.
|
||||
*
|
||||
* @see sd_clock_hfclk_request
|
||||
* @see sd_clock_hfclk_release
|
||||
*
|
||||
* @param[out] p_is_running 1 if the external crystal oscillator is running, 0 if not.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_CLOCK_HFCLK_IS_RUNNING, uint32_t, sd_clock_hfclk_is_running(uint32_t * p_is_running));
|
||||
|
||||
/**@brief Waits for an application event.
|
||||
*
|
||||
* An application event is either an application interrupt or a pended interrupt when the
|
||||
* interrupt is disabled. When the interrupt is enabled it will be taken immediately since
|
||||
* this function will wait in thread mode, then the execution will return in the application's
|
||||
* main thread. When an interrupt is disabled and gets pended it will return to the application's
|
||||
* thread main. The application must ensure that the pended flag is cleared using
|
||||
* ::sd_nvic_ClearPendingIRQ in order to sleep using this function. This is only necessary for
|
||||
* disabled interrupts, as the interrupt handler will clear the pending flag automatically for
|
||||
* enabled interrupts.
|
||||
*
|
||||
* In order to wake up from disabled interrupts, the SEVONPEND flag has to be set in the Cortex-M0
|
||||
* System Control Register (SCR). @sa CMSIS_SCB
|
||||
*
|
||||
* @note If an application interrupt has happened since the last time sd_app_evt_wait was
|
||||
* called this function will return immediately and not go to sleep. This is to avoid race
|
||||
* conditions that can occur when a flag is updated in the interrupt handler and processed
|
||||
* in the main loop.
|
||||
*
|
||||
* @post An application interrupt has happened or a interrupt pending flag is set.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_APP_EVT_WAIT, uint32_t, sd_app_evt_wait(void));
|
||||
|
||||
/**@brief Get PPI channel enable register contents.
|
||||
*
|
||||
* @param[out] p_channel_enable The contents of the PPI CHEN register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_CHANNEL_ENABLE_GET, uint32_t, sd_ppi_channel_enable_get(uint32_t * p_channel_enable));
|
||||
|
||||
/**@brief Set PPI channel enable register.
|
||||
*
|
||||
* @param[in] channel_enable_set_msk Mask containing the bits to set in the PPI CHEN register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_CHANNEL_ENABLE_SET, uint32_t, sd_ppi_channel_enable_set(uint32_t channel_enable_set_msk));
|
||||
|
||||
/**@brief Clear PPI channel enable register.
|
||||
*
|
||||
* @param[in] channel_enable_clr_msk Mask containing the bits to clear in the PPI CHEN register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_CHANNEL_ENABLE_CLR, uint32_t, sd_ppi_channel_enable_clr(uint32_t channel_enable_clr_msk));
|
||||
|
||||
/**@brief Assign endpoints to a PPI channel.
|
||||
*
|
||||
* @param[in] channel_num Number of the PPI channel to assign.
|
||||
* @param[in] evt_endpoint Event endpoint of the PPI channel.
|
||||
* @param[in] task_endpoint Task endpoint of the PPI channel.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_PPI_INVALID_CHANNEL The channel number is invalid.
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_CHANNEL_ASSIGN, uint32_t, sd_ppi_channel_assign(uint8_t channel_num, const volatile void * evt_endpoint, const volatile void * task_endpoint));
|
||||
|
||||
/**@brief Task to enable a channel group.
|
||||
*
|
||||
* @param[in] group_num Number of the channel group.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_GROUP_TASK_ENABLE, uint32_t, sd_ppi_group_task_enable(uint8_t group_num));
|
||||
|
||||
/**@brief Task to disable a channel group.
|
||||
*
|
||||
* @param[in] group_num Number of the PPI group.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid.
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_GROUP_TASK_DISABLE, uint32_t, sd_ppi_group_task_disable(uint8_t group_num));
|
||||
|
||||
/**@brief Assign PPI channels to a channel group.
|
||||
*
|
||||
* @param[in] group_num Number of the channel group.
|
||||
* @param[in] channel_msk Mask of the channels to assign to the group.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid.
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_GROUP_ASSIGN, uint32_t, sd_ppi_group_assign(uint8_t group_num, uint32_t channel_msk));
|
||||
|
||||
/**@brief Gets the PPI channels of a channel group.
|
||||
*
|
||||
* @param[in] group_num Number of the channel group.
|
||||
* @param[out] p_channel_msk Mask of the channels assigned to the group.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid.
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_GROUP_GET, uint32_t, sd_ppi_group_get(uint8_t group_num, uint32_t * p_channel_msk));
|
||||
|
||||
/**@brief Configures the Radio Notification signal.
|
||||
*
|
||||
* @note
|
||||
* - The notification signal latency depends on the interrupt priority settings of SWI used
|
||||
* for notification signal.
|
||||
* - To ensure that the radio notification signal behaves in a consistent way, always
|
||||
* configure radio notifications when there is no protocol stack or other SoftDevice
|
||||
* activity in progress. It is recommended that the radio notification signal is
|
||||
* configured directly after the SoftDevice has been enabled.
|
||||
* - In the period between the ACTIVE signal and the start of the Radio Event, the SoftDevice
|
||||
* will interrupt the application to do Radio Event preparation.
|
||||
* - Using the Radio Notification feature may limit the bandwidth, as the SoftDevice may have
|
||||
* to shorten the connection events to have time for the Radio Notification signals.
|
||||
*
|
||||
* @param[in] type Type of notification signal, see @ref NRF_RADIO_NOTIFICATION_TYPES.
|
||||
* @ref NRF_RADIO_NOTIFICATION_TYPE_NONE shall be used to turn off radio
|
||||
* notification. Using @ref NRF_RADIO_NOTIFICATION_DISTANCE_NONE is
|
||||
* recommended (but not required) to be used with
|
||||
* @ref NRF_RADIO_NOTIFICATION_TYPE_NONE.
|
||||
*
|
||||
* @param[in] distance Distance between the notification signal and start of radio activity, see @ref NRF_RADIO_NOTIFICATION_DISTANCES.
|
||||
* This parameter is ignored when @ref NRF_RADIO_NOTIFICATION_TYPE_NONE or
|
||||
* @ref NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE is used.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM The group number is invalid.
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_RADIO_NOTIFICATION_CFG_SET, uint32_t, sd_radio_notification_cfg_set(uint8_t type, uint8_t distance));
|
||||
|
||||
/**@brief Encrypts a block according to the specified parameters.
|
||||
*
|
||||
* 128-bit AES encryption.
|
||||
*
|
||||
* @note:
|
||||
* - The application may set the SEVONPEND bit in the SCR to 1 to make the SoftDevice sleep while
|
||||
* the ECB is running. The SEVONPEND bit should only be cleared (set to 0) from application
|
||||
* main or low interrupt level.
|
||||
*
|
||||
* @param[in, out] p_ecb_data Pointer to the ECB parameters' struct (two input
|
||||
* parameters and one output parameter).
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_ECB_BLOCK_ENCRYPT, uint32_t, sd_ecb_block_encrypt(nrf_ecb_hal_data_t * p_ecb_data));
|
||||
|
||||
/**@brief Encrypts multiple data blocks provided as an array of data block structures.
|
||||
*
|
||||
* @details: Performs 128-bit AES encryption on multiple data blocks
|
||||
*
|
||||
* @note:
|
||||
* - The application may set the SEVONPEND bit in the SCR to 1 to make the SoftDevice sleep while
|
||||
* the ECB is running. The SEVONPEND bit should only be cleared (set to 0) from application
|
||||
* main or low interrupt level.
|
||||
*
|
||||
* @param[in] block_count Count of blocks in the p_data_blocks array.
|
||||
* @param[in,out] p_data_blocks Pointer to the first entry in a contiguous array of
|
||||
* @ref nrf_ecb_hal_data_block_t structures.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_ECB_BLOCKS_ENCRYPT, uint32_t, sd_ecb_blocks_encrypt(uint8_t block_count, nrf_ecb_hal_data_block_t * p_data_blocks));
|
||||
|
||||
/**@brief Gets any pending events generated by the SoC API.
|
||||
*
|
||||
* The application should keep calling this function to get events, until ::NRF_ERROR_NOT_FOUND is returned.
|
||||
*
|
||||
* @param[out] p_evt_id Set to one of the values in @ref NRF_SOC_EVTS, if any events are pending.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS An event was pending. The event id is written in the p_evt_id parameter.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND No pending events.
|
||||
*/
|
||||
SVCALL(SD_EVT_GET, uint32_t, sd_evt_get(uint32_t * p_evt_id));
|
||||
|
||||
/**@brief Get the temperature measured on the chip
|
||||
*
|
||||
* This function will block until the temperature measurement is done.
|
||||
* It takes around 50us from call to return.
|
||||
*
|
||||
* @param[out] p_temp Result of temperature measurement. Die temperature in 0.25 degrees celsius.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS A temperature measurement was done, and the temperature was written to temp
|
||||
*/
|
||||
SVCALL(SD_TEMP_GET, uint32_t, sd_temp_get(int32_t * p_temp));
|
||||
|
||||
/**@brief Flash Write
|
||||
*
|
||||
* Commands to write a buffer to flash
|
||||
*
|
||||
* If the SoftDevice is enabled:
|
||||
* This call initiates the flash access command, and its completion will be communicated to the
|
||||
* application with exactly one of the following events:
|
||||
* - @ref NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed.
|
||||
* - @ref NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started.
|
||||
*
|
||||
* If the SoftDevice is not enabled no event will be generated, and this call will return @ref NRF_SUCCESS when the
|
||||
* write has been completed
|
||||
*
|
||||
* @note
|
||||
* - This call takes control over the radio and the CPU during flash erase and write to make sure that
|
||||
* they will not interfere with the flash access. This means that all interrupts will be blocked
|
||||
* for a predictable time (depending on the NVMC specification in nRF51 Series Reference Manual
|
||||
* and the command parameters).
|
||||
* - The data in the p_src buffer should not be modified before the @ref NRF_EVT_FLASH_OPERATION_SUCCESS
|
||||
* or the @ref NRF_EVT_FLASH_OPERATION_ERROR have been received if the SoftDevice is enabled.
|
||||
*
|
||||
*
|
||||
* @param[in] p_dst Pointer to start of flash location to be written.
|
||||
* @param[in] p_src Pointer to buffer with data to be written.
|
||||
* @param[in] size Number of 32-bit words to write. Maximum size is 256 32-bit words for nRF51 and 1024 for nRF52.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Tried to write to a non existing flash address, or p_dst or p_src was unaligned.
|
||||
* @retval ::NRF_ERROR_BUSY The previous command has not yet completed.
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH Size was 0, or higher than the maximum allowed size.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Tried to write to or read from protected location.
|
||||
* @retval ::NRF_SUCCESS The command was accepted.
|
||||
*/
|
||||
SVCALL(SD_FLASH_WRITE, uint32_t, sd_flash_write(uint32_t * const p_dst, uint32_t const * const p_src, uint32_t size));
|
||||
|
||||
|
||||
/**@brief Flash Erase page
|
||||
*
|
||||
* Commands to erase a flash page
|
||||
* If the SoftDevice is enabled:
|
||||
* This call initiates the flash access command, and its completion will be communicated to the
|
||||
* application with exactly one of the following events:
|
||||
* - @ref NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed.
|
||||
* - @ref NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started.
|
||||
*
|
||||
* If the SoftDevice is not enabled no event will be generated, and this call will return @ref NRF_SUCCESS when the
|
||||
* erase has been completed
|
||||
*
|
||||
* @note
|
||||
* - This call takes control over the radio and the CPU during flash erase and write to make sure that
|
||||
* they will not interfere with the flash access. This means that all interrupts will be blocked
|
||||
* for a predictable time (depending on the NVMC specification in nRF51 Series Reference Manual
|
||||
* and the command parameters).
|
||||
*
|
||||
*
|
||||
* @param[in] page_number Pagenumber of the page to erase
|
||||
* @retval ::NRF_ERROR_INTERNAL If a new session could not be opened due to an internal error.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Tried to erase to a non existing flash page.
|
||||
* @retval ::NRF_ERROR_BUSY The previous command has not yet completed.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Tried to erase a protected page.
|
||||
* @retval ::NRF_SUCCESS The command was accepted.
|
||||
*/
|
||||
SVCALL(SD_FLASH_PAGE_ERASE, uint32_t, sd_flash_page_erase(uint32_t page_number));
|
||||
|
||||
|
||||
/**@brief Flash Protection set
|
||||
*
|
||||
* Commands to set the flash protection configuration registers.
|
||||
On nRF51 this sets the PROTENSETx registers of the MPU peripheral.
|
||||
On nRF52 this sets the CONFIGx registers of the BPROT peripheral.
|
||||
*
|
||||
* @note To read the values read them directly. They are only write-protected.
|
||||
*
|
||||
* @param[in] block_cfg0 Value to be written to the configuration register.
|
||||
* @param[in] block_cfg1 Value to be written to the configuration register.
|
||||
* @param[in] block_cfg2 Value to be written to the configuration register (ignored on nRF51).
|
||||
* @param[in] block_cfg3 Value to be written to the configuration register (ignored on nRF51).
|
||||
*
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Tried to protect the SoftDevice.
|
||||
* @retval ::NRF_SUCCESS Values successfully written to configuration registers.
|
||||
*/
|
||||
SVCALL(SD_FLASH_PROTECT, uint32_t, sd_flash_protect(uint32_t block_cfg0, uint32_t block_cfg1, uint32_t block_cfg2, uint32_t block_cfg3));
|
||||
|
||||
/**@brief Opens a session for radio timeslot requests.
|
||||
*
|
||||
* @note Only one session can be open at a time.
|
||||
* @note p_radio_signal_callback(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) will be called when the radio timeslot
|
||||
* starts. From this point the NRF_RADIO and NRF_TIMER0 peripherals can be freely accessed
|
||||
* by the application.
|
||||
* @note p_radio_signal_callback(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0) is called whenever the NRF_TIMER0
|
||||
* interrupt occurs.
|
||||
* @note p_radio_signal_callback(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO) is called whenever the NRF_RADIO
|
||||
* interrupt occurs.
|
||||
* @note p_radio_signal_callback() will be called at ARM interrupt priority level 0. This
|
||||
* implies that none of the sd_* API calls can be used from p_radio_signal_callback().
|
||||
*
|
||||
* @param[in] p_radio_signal_callback The signal callback.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR p_radio_signal_callback is an invalid function pointer.
|
||||
* @retval ::NRF_ERROR_BUSY If session cannot be opened.
|
||||
* @retval ::NRF_ERROR_INTERNAL If a new session could not be opened due to an internal error.
|
||||
* @retval ::NRF_SUCCESS Otherwise.
|
||||
*/
|
||||
SVCALL(SD_RADIO_SESSION_OPEN, uint32_t, sd_radio_session_open(nrf_radio_signal_callback_t p_radio_signal_callback));
|
||||
|
||||
/**@brief Closes a session for radio timeslot requests.
|
||||
*
|
||||
* @note Any current radio timeslot will be finished before the session is closed.
|
||||
* @note If a radio timeslot is scheduled when the session is closed, it will be canceled.
|
||||
* @note The application cannot consider the session closed until the @ref NRF_EVT_RADIO_SESSION_CLOSED
|
||||
* event is received.
|
||||
*
|
||||
* @retval ::NRF_ERROR_FORBIDDEN If session not opened.
|
||||
* @retval ::NRF_ERROR_BUSY If session is currently being closed.
|
||||
* @retval ::NRF_SUCCESS Otherwise.
|
||||
*/
|
||||
SVCALL(SD_RADIO_SESSION_CLOSE, uint32_t, sd_radio_session_close(void));
|
||||
|
||||
/**@brief Requests a radio timeslot.
|
||||
*
|
||||
* @note The request type is determined by p_request->request_type, and can be one of @ref NRF_RADIO_REQ_TYPE_EARLIEST
|
||||
* and @ref NRF_RADIO_REQ_TYPE_NORMAL. The first request in a session must always be of type @ref NRF_RADIO_REQ_TYPE_EARLIEST.
|
||||
* @note For a normal request (@ref NRF_RADIO_REQ_TYPE_NORMAL), the start time of a radio timeslot is specified by
|
||||
* p_request->distance_us and is given relative to the start of the previous timeslot.
|
||||
* @note A too small p_request->distance_us will lead to a @ref NRF_EVT_RADIO_BLOCKED event.
|
||||
* @note Timeslots scheduled too close will lead to a @ref NRF_EVT_RADIO_BLOCKED event.
|
||||
* @note See the SoftDevice Specification for more on radio timeslot scheduling, distances and lengths.
|
||||
* @note If an opportunity for the first radio timeslot is not found before 100ms after the call to this
|
||||
* function, it is not scheduled, and instead a @ref NRF_EVT_RADIO_BLOCKED event is sent.
|
||||
* The application may then try to schedule the first radio timeslot again.
|
||||
* @note Successful requests will result in nrf_radio_signal_callback_t(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START).
|
||||
* Unsuccessful requests will result in a @ref NRF_EVT_RADIO_BLOCKED event, see @ref NRF_SOC_EVTS.
|
||||
* @note The jitter in the start time of the radio timeslots is +/- @ref NRF_RADIO_START_JITTER_US us.
|
||||
* @note The nrf_radio_signal_callback_t(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) call has a latency relative to the
|
||||
* specified radio timeslot start, but this does not affect the actual start time of the timeslot.
|
||||
* @note NRF_TIMER0 is reset at the start of the radio timeslot, and is clocked at 1MHz from the high frequency
|
||||
* (16 MHz) clock source. If p_request->hfclk_force_xtal is true, the high frequency clock is
|
||||
* guaranteed to be clocked from the external crystal.
|
||||
* @note The SoftDevice will neither access the NRF_RADIO peripheral nor the NRF_TIMER0 peripheral
|
||||
* during the radio timeslot.
|
||||
*
|
||||
* @param[in] p_request Pointer to the request parameters.
|
||||
*
|
||||
* @retval ::NRF_ERROR_FORBIDDEN If session not opened or the session is not IDLE.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR If the p_request pointer is invalid.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM If the parameters of p_request are not valid.
|
||||
* @retval ::NRF_SUCCESS Otherwise.
|
||||
*/
|
||||
SVCALL(SD_RADIO_REQUEST, uint32_t, sd_radio_request(nrf_radio_request_t * p_request ));
|
||||
|
||||
/**@} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_SOC_H__
|
||||
|
||||
/**@} */
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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 NRF_SVC__
|
||||
#define NRF_SVC__
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef SVCALL_AS_NORMAL_FUNCTION
|
||||
#define SVCALL(number, return_type, signature) return_type signature
|
||||
#else
|
||||
|
||||
#ifndef SVCALL
|
||||
#if defined (__CC_ARM)
|
||||
#define SVCALL(number, return_type, signature) return_type __svc(number) signature
|
||||
#elif defined (__GNUC__)
|
||||
#ifdef __cplusplus
|
||||
#define GCC_CAST_CPP (uint16_t)
|
||||
#else
|
||||
#define GCC_CAST_CPP
|
||||
#endif
|
||||
#define SVCALL(number, return_type, signature) \
|
||||
_Pragma("GCC diagnostic push") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \
|
||||
__attribute__((naked)) \
|
||||
__attribute__((unused)) \
|
||||
static return_type signature \
|
||||
{ \
|
||||
__asm( \
|
||||
"svc %0\n" \
|
||||
"bx r14" : : "I" (GCC_CAST_CPP number) : "r0" \
|
||||
); \
|
||||
} \
|
||||
_Pragma("GCC diagnostic pop")
|
||||
|
||||
#elif defined (__ICCARM__)
|
||||
#define PRAGMA(x) _Pragma(#x)
|
||||
#define SVCALL(number, return_type, signature) \
|
||||
PRAGMA(swi_number = (number)) \
|
||||
__swi return_type signature;
|
||||
#else
|
||||
#define SVCALL(number, return_type, signature) return_type signature
|
||||
#endif
|
||||
#endif // SVCALL
|
||||
|
||||
#endif // SVCALL_AS_NORMAL_FUNCTION
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_SVC__
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,130 +0,0 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TARGET_MCU_NRF51822
|
||||
|
||||
#include "mbed_assert.h"
|
||||
#include "analogin_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
#include "app_util_platform.h"
|
||||
#include "nrf_drv_saadc.h"
|
||||
|
||||
#ifdef DEVICE_ANALOGIN
|
||||
|
||||
#define ADC_12BIT_RANGE 0xFFF
|
||||
#define ADC_RANGE ADC_12BIT_RANGE
|
||||
|
||||
#ifdef TARGET_SDK13
|
||||
__STATIC_INLINE nrf_saadc_input_t nrf_drv_saadc_gpio_to_ain(uint32_t pin);
|
||||
#endif
|
||||
|
||||
|
||||
static void analog_in_event_handler(nrf_drv_saadc_evt_t const *p_event)// type of nrf_drv_saadc_event_handler_t
|
||||
{
|
||||
(void) p_event;
|
||||
}
|
||||
|
||||
static const nrf_drv_saadc_config_t saadc_config =
|
||||
{
|
||||
.resolution = NRF_SAADC_RESOLUTION_12BIT,
|
||||
.oversample = NRF_SAADC_OVERSAMPLE_DISABLED,
|
||||
.interrupt_priority = SAADC_CONFIG_IRQ_PRIORITY
|
||||
};
|
||||
|
||||
void SAADC_IRQHandler(void);
|
||||
|
||||
void analogin_init(analogin_t *obj, PinName pin)
|
||||
{
|
||||
ret_code_t ret_code;
|
||||
|
||||
NVIC_SetVector(SAADC_IRQn, (uint32_t)SAADC_IRQHandler);
|
||||
|
||||
ret_code = nrf_drv_saadc_init(&saadc_config, analog_in_event_handler);
|
||||
MBED_ASSERT(((ret_code == NRF_SUCCESS) || (ret_code == NRF_ERROR_INVALID_STATE))); //NRF_ERROR_INVALID_STATE expected for multiple channels used.
|
||||
|
||||
uint8_t saadcIn = nrf_drv_saadc_gpio_to_ain(pin);
|
||||
MBED_ASSERT(saadcIn != NRF_SAADC_INPUT_DISABLED);
|
||||
|
||||
obj->adc = ADC0_0; // only one instance of ADC in nRF52 SoC
|
||||
obj->adc_pin = saadcIn - 1;
|
||||
|
||||
nrf_saadc_channel_config_t channel_config =
|
||||
NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(saadcIn); //Single ended, negative input to ADC shorted to GND.
|
||||
|
||||
ret_code = nrf_drv_saadc_channel_init(obj->adc_pin, &channel_config);
|
||||
MBED_ASSERT(ret_code == NRF_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
uint16_t analogin_read_u16(analogin_t *obj)
|
||||
{
|
||||
int16_t adc_value;
|
||||
ret_code_t ret_code;
|
||||
|
||||
ret_code = nrf_drv_saadc_sample_convert(obj->adc_pin, &adc_value);
|
||||
MBED_ASSERT(ret_code == NRF_SUCCESS);
|
||||
|
||||
if (adc_value < 0)
|
||||
{
|
||||
// Even in the single ended mode measured value can be {-0}. Saturation for avoid casting to a big integer.
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (uint16_t) adc_value;
|
||||
}
|
||||
}
|
||||
|
||||
float analogin_read(analogin_t *obj)
|
||||
{
|
||||
uint16_t value = analogin_read_u16(obj);
|
||||
return (float)value * (1.0f / (float)ADC_RANGE);
|
||||
}
|
||||
|
||||
#ifdef TARGET_SDK13
|
||||
/**
|
||||
* @brief Function for converting a GPIO pin number to an analog input pin number used in the channel
|
||||
* configuration.
|
||||
*
|
||||
* @param[in] pin GPIO pin.
|
||||
*
|
||||
* @return Value representing an analog input pin. The function returns @ref NRF_SAADC_INPUT_DISABLED
|
||||
* if the specified pin is not an analog input.
|
||||
*/
|
||||
__STATIC_INLINE nrf_saadc_input_t nrf_drv_saadc_gpio_to_ain(uint32_t pin)
|
||||
{
|
||||
// AIN0 - AIN3
|
||||
if (pin >= 2 && pin <= 5)
|
||||
{
|
||||
//0 means "not connected", hence this "+ 1"
|
||||
return (nrf_saadc_input_t)(pin - 2 + 1);
|
||||
}
|
||||
// AIN4 - AIN7
|
||||
else if (pin >= 28 && pin <= 31)
|
||||
{
|
||||
return (nrf_saadc_input_t)(pin - 24 + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NRF_SAADC_INPUT_DISABLED;
|
||||
}
|
||||
}
|
||||
#endif // TARGET_SDK13
|
||||
|
||||
#endif // DEVICE_ANALOGIN
|
||||
|
||||
#endif // !TARGET_MCU_NRF51822
|
||||
|
|
@ -1,404 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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 TARGET_MCU_NRF51822
|
||||
|
||||
#include "mbed_assert.h"
|
||||
#include "mbed_error.h"
|
||||
#include "pwmout_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
#include "sdk_config.h"
|
||||
|
||||
#if DEVICE_PWMOUT
|
||||
|
||||
#include "app_util_platform.h"
|
||||
#include "nrf_drv_pwm.h"
|
||||
|
||||
#define MAX_PWM_COUNTERTOP (0x7FFF) // 0x7FFF is the max of COUNTERTOP value for the PWM peripherial of the nRF52.
|
||||
#define MAX_PWM_PERIOD_US (MAX_PWM_COUNTERTOP * 8) // PWM hw is driven by 16 MHz clock, hence the tick is 1_us/16,
|
||||
// and 128 is the max prescaler value.
|
||||
#define MAX_PWM_PERIOD_MS ((MAX_PWM_PERIOD_US / 1000) + 1) // approximations advance
|
||||
#define MAX_PWM_PERIOD_S ((MAX_PWM_PERIOD_US / 1000000) + 1) // approximations advance
|
||||
|
||||
|
||||
#define PWM_INSTANCE_COUNT (PWM_COUNT) // import from the nrf_drv_config.h file
|
||||
|
||||
///> instances of nRF52 PWM driver
|
||||
static const nrf_drv_pwm_t m_pwm_driver[PWM_INSTANCE_COUNT] =
|
||||
{
|
||||
#if PWM0_ENABLED
|
||||
NRF_DRV_PWM_INSTANCE(0),
|
||||
#endif
|
||||
#if PWM1_ENABLED
|
||||
NRF_DRV_PWM_INSTANCE(1),
|
||||
#endif
|
||||
#if PWM2_ENABLED
|
||||
NRF_DRV_PWM_INSTANCE(2)
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t period_us;
|
||||
uint32_t duty_us;
|
||||
float duty;
|
||||
} pwm_signal_t; /// PWM signal description type
|
||||
|
||||
typedef struct
|
||||
{
|
||||
nrf_drv_pwm_t * p_pwm_driver;
|
||||
pwm_signal_t signal;
|
||||
volatile nrf_pwm_values_common_t seq_values[1];
|
||||
} pwm_t; /// internal PWM instance support type
|
||||
|
||||
static pwm_t m_pwm[PWM_INSTANCE_COUNT] =
|
||||
{
|
||||
#if PWM0_ENABLED
|
||||
{.p_pwm_driver = NULL},
|
||||
#endif
|
||||
#if PWM1_ENABLED
|
||||
{.p_pwm_driver = NULL},
|
||||
#endif
|
||||
#if PWM2_ENABLED
|
||||
{.p_pwm_driver = NULL}
|
||||
#endif
|
||||
}; /// Array of internal PWM instances.
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t period_hwu; // unit related to pwm_clk
|
||||
uint16_t duty_hwu; // unit related to pwm_clk
|
||||
nrf_pwm_clk_t pwm_clk;
|
||||
} pulsewidth_set_t; /// helper type for timing calculations
|
||||
|
||||
|
||||
static void internal_pwmout_exe(pwmout_t *obj, bool new_period, bool initialization);
|
||||
|
||||
// extern PWM nIRQ handler implementations
|
||||
void PWM0_IRQHandler(void);
|
||||
void PWM1_IRQHandler(void);
|
||||
void PWM2_IRQHandler(void);
|
||||
|
||||
static const peripheral_handler_desc_t pwm_handlers[PWM_INSTANCE_COUNT] =
|
||||
{
|
||||
{
|
||||
PWM0_IRQn,
|
||||
(uint32_t)PWM0_IRQHandler
|
||||
},
|
||||
{
|
||||
PWM1_IRQn,
|
||||
(uint32_t)PWM1_IRQHandler
|
||||
},
|
||||
{
|
||||
PWM2_IRQn,
|
||||
(uint32_t)PWM2_IRQHandler
|
||||
}
|
||||
};
|
||||
|
||||
void pwmout_init(pwmout_t *obj, PinName pin)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; PWM_INSTANCE_COUNT; i++)
|
||||
{
|
||||
if (m_pwm[i].p_pwm_driver == NULL) // a driver instance not assigned to the obj?
|
||||
{
|
||||
NVIC_SetVector(pwm_handlers[i].IRQn, pwm_handlers[i].vector);
|
||||
|
||||
obj->pin = pin;
|
||||
|
||||
obj->pwm_channel = i;
|
||||
|
||||
m_pwm[i].p_pwm_driver = (nrf_drv_pwm_t *) &m_pwm_driver[i];
|
||||
m_pwm[i].signal.period_us = 200000; // 0.02 s
|
||||
m_pwm[i].signal.duty_us = 100000;
|
||||
m_pwm[i].signal.duty = 0.5f;
|
||||
|
||||
obj->pwm_struct = &m_pwm[i];
|
||||
|
||||
internal_pwmout_exe(obj, true, true);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MBED_ASSERT(i != PWM_INSTANCE_COUNT); // assert if free instance was not found.
|
||||
}
|
||||
|
||||
void pwmout_free(pwmout_t *obj)
|
||||
{
|
||||
nrf_drv_pwm_uninit( (nrf_drv_pwm_t*) obj->pwm_struct );
|
||||
|
||||
m_pwm[obj->pwm_channel].p_pwm_driver = NULL;
|
||||
}
|
||||
|
||||
void pwmout_write(pwmout_t *obj, float percent)
|
||||
{
|
||||
|
||||
if (percent < 0)
|
||||
{
|
||||
percent = 0;
|
||||
}
|
||||
else if (percent > 1)
|
||||
{
|
||||
percent = 1;
|
||||
}
|
||||
|
||||
pwm_signal_t * p_pwm_signal = &(((pwm_t*)obj->pwm_struct)->signal);
|
||||
|
||||
p_pwm_signal->duty = percent;
|
||||
|
||||
int us = (((int)p_pwm_signal->period_us) * percent);
|
||||
|
||||
pwmout_pulsewidth_us(obj, us);
|
||||
}
|
||||
|
||||
float pwmout_read(pwmout_t *obj)
|
||||
{
|
||||
pwm_signal_t * p_pwm_signal = &(((pwm_t*)obj->pwm_struct)->signal);
|
||||
|
||||
return (float)p_pwm_signal->duty_us / (float)p_pwm_signal->period_us;
|
||||
}
|
||||
|
||||
void pwmout_period(pwmout_t *obj, float seconds)
|
||||
{
|
||||
// raught saturation < 0, quasi-max>
|
||||
if (seconds > MAX_PWM_PERIOD_S)
|
||||
{
|
||||
seconds = MAX_PWM_PERIOD_S;
|
||||
}
|
||||
else if (seconds < 0)
|
||||
{
|
||||
seconds = 0; // f. pwmout_period_us will set period to min. value
|
||||
}
|
||||
|
||||
int us = seconds * 1000000;
|
||||
|
||||
pwmout_period_us(obj, us);
|
||||
}
|
||||
|
||||
void pwmout_period_ms(pwmout_t *obj, int ms)
|
||||
{
|
||||
// reught saturation < 0, quasi-max>
|
||||
if (ms > MAX_PWM_PERIOD_MS)
|
||||
{
|
||||
ms = MAX_PWM_PERIOD_MS;
|
||||
}
|
||||
else if (ms < 0)
|
||||
{
|
||||
ms = 0; // f. pwmout_period_us will set period to min. value
|
||||
}
|
||||
|
||||
int us = ms * 1000;
|
||||
|
||||
pwmout_period_us(obj, us);
|
||||
}
|
||||
|
||||
|
||||
void pwmout_period_us(pwmout_t *obj, int us)
|
||||
{
|
||||
pwm_signal_t * p_pwm_signal = &(((pwm_t*)obj->pwm_struct)->signal);
|
||||
|
||||
// saturation <1, real-max>
|
||||
if (us > MAX_PWM_PERIOD_US)
|
||||
{
|
||||
us = MAX_PWM_PERIOD_US;
|
||||
}
|
||||
else if (us < 1)
|
||||
{
|
||||
us = 1;
|
||||
}
|
||||
|
||||
p_pwm_signal->duty_us = (int)((float)us * p_pwm_signal->duty);
|
||||
|
||||
p_pwm_signal->period_us = us;
|
||||
|
||||
internal_pwmout_exe(obj, true, false);
|
||||
}
|
||||
|
||||
void pwmout_pulsewidth(pwmout_t *obj, float seconds)
|
||||
{
|
||||
// raught saturation < 0, quasi-max>
|
||||
if (seconds > MAX_PWM_PERIOD_S)
|
||||
{
|
||||
seconds = MAX_PWM_PERIOD_S;
|
||||
}
|
||||
else if (seconds < 0)
|
||||
{
|
||||
seconds = 0;
|
||||
}
|
||||
|
||||
int us = seconds * 1000000;
|
||||
|
||||
pwmout_pulsewidth_us(obj,us);
|
||||
}
|
||||
|
||||
void pwmout_pulsewidth_ms(pwmout_t *obj, int ms)
|
||||
{
|
||||
// raught saturation < 0, quasi-max>
|
||||
if (ms > MAX_PWM_PERIOD_MS)
|
||||
{
|
||||
ms = MAX_PWM_PERIOD_MS;
|
||||
}
|
||||
else if (ms < 0)
|
||||
{
|
||||
ms = 0;
|
||||
}
|
||||
|
||||
int us = ms * 1000;
|
||||
|
||||
pwmout_pulsewidth_us(obj, us);
|
||||
}
|
||||
|
||||
void pwmout_pulsewidth_us(pwmout_t *obj, int us)
|
||||
{
|
||||
// saturation <0, real-max>
|
||||
if (us > MAX_PWM_PERIOD_US)
|
||||
{
|
||||
us = MAX_PWM_PERIOD_US;
|
||||
}
|
||||
else if (us < 0)
|
||||
{
|
||||
us = 0;
|
||||
}
|
||||
|
||||
pwm_signal_t * p_pwm_signal = &(((pwm_t*)obj->pwm_struct)->signal);
|
||||
|
||||
p_pwm_signal->duty_us = us;
|
||||
p_pwm_signal->duty = us / p_pwm_signal->period_us;
|
||||
|
||||
internal_pwmout_exe(obj, false, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static ret_code_t pulsewidth_us_set_get(int period_hwu, int duty_hwu, pulsewidth_set_t * p_settings)
|
||||
{
|
||||
uint16_t div;
|
||||
nrf_pwm_clk_t pwm_clk = NRF_PWM_CLK_16MHz;
|
||||
|
||||
for(div = 1; div <= 128 ; div <<= 1) // 128 is the maximum of clock prescaler for PWM peripherial
|
||||
{
|
||||
if (MAX_PWM_COUNTERTOP >= period_hwu)
|
||||
{
|
||||
p_settings->period_hwu = period_hwu; // unit [us/16 * div]
|
||||
p_settings->duty_hwu = duty_hwu; // unit [us/16 * div]
|
||||
p_settings->pwm_clk = pwm_clk;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
period_hwu >>= 1;
|
||||
duty_hwu >>= 1;
|
||||
pwm_clk++;
|
||||
}
|
||||
|
||||
return NRF_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
|
||||
static void internal_pwmout_exe(pwmout_t *obj, bool new_period, bool initialization)
|
||||
{
|
||||
pulsewidth_set_t pulsewidth_set;
|
||||
pwm_signal_t * p_pwm_signal;
|
||||
nrf_drv_pwm_t * p_pwm_driver;
|
||||
ret_code_t ret_code;
|
||||
|
||||
p_pwm_signal = &(((pwm_t*)obj->pwm_struct)->signal);
|
||||
|
||||
if (NRF_SUCCESS == pulsewidth_us_set_get(p_pwm_signal->period_us * 16, // base clk for PWM is 16 MHz
|
||||
p_pwm_signal->duty_us * 16, // base clk for PWM is 16 MHz
|
||||
&pulsewidth_set))
|
||||
{
|
||||
p_pwm_driver = (((pwm_t*)obj->pwm_struct)->p_pwm_driver);
|
||||
|
||||
const nrf_pwm_sequence_t seq =
|
||||
{
|
||||
.values.p_common = (nrf_pwm_values_common_t*) (((pwm_t*)obj->pwm_struct)->seq_values),
|
||||
.length = 1,
|
||||
.repeats = 0,
|
||||
.end_delay = 0
|
||||
};
|
||||
|
||||
(((pwm_t*)obj->pwm_struct)->seq_values)[0] = pulsewidth_set.duty_hwu | 0x8000;
|
||||
|
||||
if (new_period)
|
||||
{
|
||||
nrf_drv_pwm_config_t config0 =
|
||||
{
|
||||
.output_pins =
|
||||
{
|
||||
obj->pin | NRF_DRV_PWM_PIN_INVERTED, // channel 0
|
||||
NRF_DRV_PWM_PIN_NOT_USED, // channel 1
|
||||
NRF_DRV_PWM_PIN_NOT_USED, // channel 2
|
||||
NRF_DRV_PWM_PIN_NOT_USED, // channel 3
|
||||
},
|
||||
.irq_priority = PWM_DEFAULT_CONFIG_IRQ_PRIORITY,
|
||||
.base_clock = pulsewidth_set.pwm_clk,
|
||||
.count_mode = NRF_PWM_MODE_UP,
|
||||
.top_value = pulsewidth_set.period_hwu,
|
||||
.load_mode = NRF_PWM_LOAD_COMMON,
|
||||
.step_mode = NRF_PWM_STEP_AUTO
|
||||
};
|
||||
|
||||
if (!initialization)
|
||||
{
|
||||
nrf_drv_pwm_uninit(p_pwm_driver);
|
||||
}
|
||||
|
||||
ret_code = nrf_drv_pwm_init( p_pwm_driver, &config0, NULL);
|
||||
|
||||
MBED_ASSERT(ret_code == NRF_SUCCESS); // assert if free instance was not found.
|
||||
}
|
||||
|
||||
nrf_drv_pwm_simple_playback(p_pwm_driver, &seq, 0, NRF_DRV_PWM_FLAG_LOOP);
|
||||
}
|
||||
else
|
||||
{
|
||||
MBED_ASSERT(0); // force assertion
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // DEVICE_PWMOUT
|
||||
|
||||
#endif
|
||||
|
|
@ -1,717 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
#include "sdk_common.h"
|
||||
#if NRF_MODULE_ENABLED(BLE_ADVERTISING)
|
||||
#include "ble_advdata.h"
|
||||
#include "ble_advertising.h"
|
||||
#include "nrf_soc.h"
|
||||
#include "nrf_log.h"
|
||||
#include "fstorage.h"
|
||||
#include "sdk_errors.h"
|
||||
|
||||
|
||||
// Total number of possible advertising modes.
|
||||
#define BLE_ADV_MODES (5)
|
||||
|
||||
|
||||
static bool m_initialized;
|
||||
static bool m_advertising_start_pending; /**< Flag to keep track of ongoing operations in flash. */
|
||||
|
||||
static ble_adv_evt_t m_adv_evt; /**< Advertising event propogated to the main application. The event is either a transaction to a new advertising mode, or a request for whitelist or peer address. */
|
||||
|
||||
static ble_adv_mode_t m_adv_mode_current; /**< Variable to keep track of the current advertising mode. */
|
||||
static ble_adv_modes_config_t m_adv_modes_config; /**< Struct to keep track of disabled and enabled advertising modes, as well as time-outs and intervals.*/
|
||||
|
||||
static ble_gap_addr_t m_peer_address; /**< Address of the most recently connected peer, used for direct advertising. */
|
||||
static bool m_peer_addr_reply_expected; /**< Flag to verify that peer address is only set when requested. */
|
||||
|
||||
static ble_advdata_t m_advdata; /**< Used by the initialization function to set name, appearance, and UUIDs and advertising flags visible to peer devices. */
|
||||
static ble_advdata_manuf_data_t m_manuf_specific_data; /**< Manufacturer specific data structure*/
|
||||
static uint8_t m_manuf_data_array[BLE_GAP_ADV_MAX_SIZE]; /**< Array to store the Manufacturer specific data*/
|
||||
static ble_advdata_service_data_t m_service_data; /**< Service data structure. */
|
||||
static uint8_t m_service_data_array[BLE_GAP_ADV_MAX_SIZE]; /**< Array to store the service data. */
|
||||
static ble_advdata_conn_int_t m_slave_conn_int; /**< Connection interval range structure.*/
|
||||
static uint16_t m_current_slave_link_conn_handle; /**< Connection handle for the active link. */
|
||||
|
||||
static ble_advertising_evt_handler_t m_evt_handler; /**< Handler for the advertising events. Can be initialized as NULL if no handling is implemented on in the main application. */
|
||||
static ble_advertising_error_handler_t m_error_handler; /**< Handler for the advertising error events. */
|
||||
|
||||
static bool m_whitelist_temporarily_disabled; /**< Flag to keep track of temporary disabling of the whitelist. */
|
||||
static bool m_whitelist_reply_expected;
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
|
||||
// For SoftDevices v 2.x, this module caches a whitelist which is retrieved from the
|
||||
// application using an event, and which is passed as a parameter when calling
|
||||
// sd_ble_gap_adv_start().
|
||||
|
||||
static ble_gap_addr_t * m_p_whitelist_addrs[BLE_GAP_WHITELIST_ADDR_MAX_COUNT];
|
||||
static ble_gap_irk_t * m_p_whitelist_irks[BLE_GAP_WHITELIST_IRK_MAX_COUNT];
|
||||
static ble_gap_addr_t m_whitelist_addrs[BLE_GAP_WHITELIST_ADDR_MAX_COUNT];
|
||||
static ble_gap_irk_t m_whitelist_irks[BLE_GAP_WHITELIST_IRK_MAX_COUNT];
|
||||
|
||||
static ble_gap_whitelist_t m_whitelist =
|
||||
{
|
||||
.pp_addrs = m_p_whitelist_addrs,
|
||||
.pp_irks = m_p_whitelist_irks
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
// For SoftDevices v 3.x, this module does not need to cache a whitelist, but it needs to
|
||||
// be aware of whether or not a whitelist has been set (e.g. using the Peer Manager)
|
||||
// in order to start advertising with the proper advertising params (filter policy).
|
||||
|
||||
static bool m_whitelist_in_use;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
|
||||
static bool whitelist_has_entries()
|
||||
{
|
||||
return ((m_whitelist.addr_count != 0) || (m_whitelist.irk_count != 0));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static bool whitelist_has_entries()
|
||||
{
|
||||
return m_whitelist_in_use;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**@brief Function for checking if an address is valid.
|
||||
*/
|
||||
static bool addr_is_valid(uint8_t const * const addr)
|
||||
{
|
||||
for (uint32_t i = 0; i < BLE_GAP_ADDR_LEN; i++)
|
||||
{
|
||||
if (addr[i] != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static ble_adv_mode_t adv_mode_next_get(ble_adv_mode_t adv_mode)
|
||||
{
|
||||
return (ble_adv_mode_t)((adv_mode + 1) % BLE_ADV_MODES);
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for handling the Connected event.
|
||||
*
|
||||
* @param[in] p_ble_evt Event received from the BLE stack.
|
||||
*/
|
||||
static void on_connected(ble_evt_t const * p_ble_evt)
|
||||
{
|
||||
if (p_ble_evt->evt.gap_evt.params.connected.role == BLE_GAP_ROLE_PERIPH)
|
||||
{
|
||||
m_current_slave_link_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for handling the Disconnected event.
|
||||
*
|
||||
* @param[in] p_ble_evt Event received from the BLE stack.
|
||||
*/
|
||||
static void on_disconnected(ble_evt_t const * p_ble_evt)
|
||||
{
|
||||
uint32_t ret;
|
||||
|
||||
m_whitelist_temporarily_disabled = false;
|
||||
|
||||
if (p_ble_evt->evt.gap_evt.conn_handle == m_current_slave_link_conn_handle)
|
||||
{
|
||||
ret = ble_advertising_start(BLE_ADV_MODE_DIRECTED);
|
||||
if ((ret != NRF_SUCCESS) && (m_error_handler != NULL))
|
||||
{
|
||||
m_error_handler(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for handling the Timeout event.
|
||||
*
|
||||
* @param[in] p_ble_evt Event received from the BLE stack.
|
||||
*/
|
||||
static void on_timeout(ble_evt_t const * p_ble_evt)
|
||||
{
|
||||
ret_code_t ret;
|
||||
|
||||
if (p_ble_evt->evt.gap_evt.params.timeout.src != BLE_GAP_TIMEOUT_SRC_ADVERTISING)
|
||||
{
|
||||
// Nothing to do.
|
||||
return;
|
||||
}
|
||||
|
||||
// Start advertising in the next mode.
|
||||
ret = ble_advertising_start(adv_mode_next_get(m_adv_mode_current));
|
||||
|
||||
if ((ret != NRF_SUCCESS) && (m_error_handler != NULL))
|
||||
{
|
||||
m_error_handler(ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** @brief Function to determine if a flash write operation in in progress.
|
||||
*
|
||||
* @return true if a flash operation is in progress, false if not.
|
||||
*/
|
||||
static bool flash_access_in_progress()
|
||||
{
|
||||
uint32_t count;
|
||||
|
||||
(void)fs_queued_op_count_get(&count);
|
||||
|
||||
return (count != 0);
|
||||
}
|
||||
|
||||
|
||||
/**@brief Get the next available advertising mode.
|
||||
*
|
||||
* @param[in] adv_mode Requested advertising mode.
|
||||
*
|
||||
* @returns adv_mode if possible, or the best available mode if not.
|
||||
*/
|
||||
static ble_adv_mode_t adv_mode_next_avail_get(ble_adv_mode_t adv_mode)
|
||||
{
|
||||
bool peer_addr_is_valid = addr_is_valid(m_peer_address.addr);
|
||||
|
||||
// If a mode is disabled, continue to the next mode.
|
||||
|
||||
switch (adv_mode)
|
||||
{
|
||||
case BLE_ADV_MODE_DIRECTED:
|
||||
if ((m_adv_modes_config.ble_adv_directed_enabled) && peer_addr_is_valid)
|
||||
{
|
||||
return BLE_ADV_MODE_DIRECTED;
|
||||
}
|
||||
// Fallthrough.
|
||||
|
||||
case BLE_ADV_MODE_DIRECTED_SLOW:
|
||||
if ((m_adv_modes_config.ble_adv_directed_slow_enabled) && peer_addr_is_valid)
|
||||
{
|
||||
return BLE_ADV_MODE_DIRECTED_SLOW;
|
||||
}
|
||||
// Fallthrough.
|
||||
|
||||
case BLE_ADV_MODE_FAST:
|
||||
if (m_adv_modes_config.ble_adv_fast_enabled)
|
||||
{
|
||||
return BLE_ADV_MODE_FAST;
|
||||
}
|
||||
// Fallthrough.
|
||||
|
||||
case BLE_ADV_MODE_SLOW:
|
||||
if (m_adv_modes_config.ble_adv_slow_enabled)
|
||||
{
|
||||
return BLE_ADV_MODE_SLOW;
|
||||
}
|
||||
// Fallthrough.
|
||||
|
||||
default:
|
||||
return BLE_ADV_MODE_IDLE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for starting directed advertising.
|
||||
*
|
||||
* @param[out] p_adv_params Advertising parameters.
|
||||
*
|
||||
* @return NRF_SUCCESS
|
||||
*/
|
||||
static ret_code_t set_adv_mode_directed(ble_gap_adv_params_t * p_adv_params)
|
||||
{
|
||||
m_adv_evt = BLE_ADV_EVT_DIRECTED;
|
||||
|
||||
p_adv_params->p_peer_addr = &m_peer_address;
|
||||
p_adv_params->type = BLE_GAP_ADV_TYPE_ADV_DIRECT_IND;
|
||||
p_adv_params->timeout = 0;
|
||||
p_adv_params->interval = 0;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for starting directed slow advertising.
|
||||
*
|
||||
* @param[out] p_adv_params Advertising parameters.
|
||||
*
|
||||
* @return NRF_SUCCESS
|
||||
*/
|
||||
static ret_code_t set_adv_mode_directed_slow(ble_gap_adv_params_t * p_adv_params)
|
||||
{
|
||||
m_adv_evt = BLE_ADV_EVT_DIRECTED_SLOW;
|
||||
|
||||
p_adv_params->p_peer_addr = &m_peer_address;
|
||||
p_adv_params->type = BLE_GAP_ADV_TYPE_ADV_DIRECT_IND;
|
||||
p_adv_params->timeout = m_adv_modes_config.ble_adv_directed_slow_timeout;
|
||||
p_adv_params->interval = m_adv_modes_config.ble_adv_directed_slow_interval;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for starting fast advertising.
|
||||
*
|
||||
* @param[out] p_adv_params Advertising parameters.
|
||||
*
|
||||
* @return NRF_SUCCESS or an error from @ref ble_advdata_set().
|
||||
*/
|
||||
static ret_code_t set_adv_mode_fast(ble_gap_adv_params_t * p_adv_params)
|
||||
{
|
||||
ret_code_t ret;
|
||||
|
||||
p_adv_params->interval = m_adv_modes_config.ble_adv_fast_interval;
|
||||
p_adv_params->timeout = m_adv_modes_config.ble_adv_fast_timeout;
|
||||
|
||||
if ((m_adv_modes_config.ble_adv_whitelist_enabled) &&
|
||||
(!m_whitelist_temporarily_disabled) &&
|
||||
(whitelist_has_entries()))
|
||||
{
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
p_adv_params->p_whitelist = &m_whitelist;
|
||||
#endif
|
||||
|
||||
p_adv_params->fp = BLE_GAP_ADV_FP_FILTER_CONNREQ;
|
||||
m_advdata.flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
|
||||
|
||||
ret = ble_advdata_set(&m_advdata, NULL);
|
||||
if (ret != NRF_SUCCESS)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
m_adv_evt = BLE_ADV_EVT_FAST_WHITELIST;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_adv_evt = BLE_ADV_EVT_FAST;
|
||||
}
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for starting slow advertising.
|
||||
*
|
||||
* @param[out] p_adv_params Advertising parameters.
|
||||
*
|
||||
* @return NRF_SUCCESS or an error from @ref ble_advdata_set().
|
||||
*/
|
||||
static ret_code_t set_adv_mode_slow(ble_gap_adv_params_t * p_adv_params)
|
||||
{
|
||||
ret_code_t ret;
|
||||
|
||||
p_adv_params->interval = m_adv_modes_config.ble_adv_slow_interval;
|
||||
p_adv_params->timeout = m_adv_modes_config.ble_adv_slow_timeout;
|
||||
|
||||
if ((m_adv_modes_config.ble_adv_whitelist_enabled) &&
|
||||
(!m_whitelist_temporarily_disabled) &&
|
||||
(whitelist_has_entries()))
|
||||
{
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
{
|
||||
p_adv_params->p_whitelist = &m_whitelist;
|
||||
}
|
||||
#endif
|
||||
|
||||
p_adv_params->fp = BLE_GAP_ADV_FP_FILTER_CONNREQ;
|
||||
m_advdata.flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
|
||||
|
||||
ret = ble_advdata_set(&m_advdata, NULL);
|
||||
if (ret != NRF_SUCCESS)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
m_adv_evt = BLE_ADV_EVT_SLOW_WHITELIST;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_adv_evt = BLE_ADV_EVT_SLOW;
|
||||
}
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
uint32_t ble_advertising_init(ble_advdata_t const * p_advdata,
|
||||
ble_advdata_t const * p_srdata,
|
||||
ble_adv_modes_config_t const * p_config,
|
||||
ble_advertising_evt_handler_t const evt_handler,
|
||||
ble_advertising_error_handler_t const error_handler)
|
||||
{
|
||||
uint32_t ret;
|
||||
|
||||
if ((p_advdata == NULL) || (p_config == NULL))
|
||||
{
|
||||
return NRF_ERROR_NULL;
|
||||
}
|
||||
|
||||
m_initialized = true;
|
||||
m_adv_mode_current = BLE_ADV_MODE_IDLE;
|
||||
m_adv_modes_config = *p_config;
|
||||
m_evt_handler = evt_handler;
|
||||
m_error_handler = error_handler;
|
||||
m_current_slave_link_conn_handle = BLE_CONN_HANDLE_INVALID;
|
||||
|
||||
memset(&m_peer_address, 0, sizeof(m_peer_address));
|
||||
memset(&m_advdata, 0, sizeof(m_advdata));
|
||||
|
||||
// Copy advertising data.
|
||||
m_advdata.name_type = p_advdata->name_type;
|
||||
m_advdata.include_appearance = p_advdata->include_appearance;
|
||||
m_advdata.flags = p_advdata->flags;
|
||||
m_advdata.short_name_len = p_advdata->short_name_len;
|
||||
|
||||
m_advdata.uuids_complete = p_advdata->uuids_complete;
|
||||
m_advdata.uuids_more_available = p_advdata->uuids_more_available;
|
||||
m_advdata.uuids_solicited = p_advdata->uuids_solicited;
|
||||
|
||||
if (p_advdata->p_manuf_specific_data != NULL)
|
||||
{
|
||||
m_advdata.p_manuf_specific_data = &m_manuf_specific_data;
|
||||
m_manuf_specific_data.data.p_data = m_manuf_data_array;
|
||||
m_advdata.p_manuf_specific_data->company_identifier =
|
||||
p_advdata->p_manuf_specific_data->company_identifier;
|
||||
m_advdata.p_manuf_specific_data->data.size = p_advdata->p_manuf_specific_data->data.size;
|
||||
|
||||
for (uint32_t i = 0; i < m_advdata.p_manuf_specific_data->data.size; i++)
|
||||
{
|
||||
m_manuf_data_array[i] = p_advdata->p_manuf_specific_data->data.p_data[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (p_advdata->p_service_data_array != NULL)
|
||||
{
|
||||
m_service_data.data.p_data = m_service_data_array;
|
||||
m_advdata.p_service_data_array = &m_service_data;
|
||||
m_advdata.p_service_data_array->data.p_data = m_service_data_array;
|
||||
m_advdata.p_service_data_array->data.size = p_advdata->p_service_data_array->data.size;
|
||||
m_advdata.p_service_data_array->service_uuid = p_advdata->p_service_data_array->service_uuid;
|
||||
|
||||
for (uint32_t i = 0; i < m_advdata.p_service_data_array->data.size; i++)
|
||||
{
|
||||
m_service_data_array[i] = p_advdata->p_service_data_array->data.p_data[i];
|
||||
}
|
||||
|
||||
m_advdata.service_data_count = p_advdata->service_data_count;
|
||||
}
|
||||
|
||||
if (p_advdata->p_slave_conn_int != NULL)
|
||||
{
|
||||
m_advdata.p_slave_conn_int = &m_slave_conn_int;
|
||||
m_advdata.p_slave_conn_int->max_conn_interval = p_advdata->p_slave_conn_int->max_conn_interval;
|
||||
m_advdata.p_slave_conn_int->min_conn_interval = p_advdata->p_slave_conn_int->min_conn_interval;
|
||||
}
|
||||
|
||||
if (p_advdata->p_tx_power_level != NULL)
|
||||
{
|
||||
m_advdata.p_tx_power_level = p_advdata->p_tx_power_level;
|
||||
}
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
for (int i = 0; i <BLE_GAP_WHITELIST_ADDR_MAX_COUNT ; i++)
|
||||
{
|
||||
m_whitelist.pp_addrs[i] = &m_whitelist_addrs[i];
|
||||
}
|
||||
|
||||
for (int i = 0; i <BLE_GAP_WHITELIST_IRK_MAX_COUNT ; i++)
|
||||
{
|
||||
m_whitelist.pp_irks[i] = &m_whitelist_irks[i];
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = ble_advdata_set(&m_advdata, p_srdata);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
uint32_t ble_advertising_start(ble_adv_mode_t advertising_mode)
|
||||
{
|
||||
uint32_t ret;
|
||||
ble_gap_adv_params_t adv_params;
|
||||
|
||||
if (m_initialized == false)
|
||||
{
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
m_adv_mode_current = advertising_mode;
|
||||
|
||||
// Delay starting advertising until the flash operations are complete.
|
||||
if (flash_access_in_progress())
|
||||
{
|
||||
m_advertising_start_pending = true;
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
memset(&m_peer_address, 0, sizeof(m_peer_address));
|
||||
|
||||
if ( ((m_adv_modes_config.ble_adv_directed_enabled) && (m_adv_mode_current == BLE_ADV_MODE_DIRECTED))
|
||||
||((m_adv_modes_config.ble_adv_directed_slow_enabled) && (m_adv_mode_current == BLE_ADV_MODE_DIRECTED))
|
||||
||((m_adv_modes_config.ble_adv_directed_slow_enabled) && (m_adv_mode_current == BLE_ADV_MODE_DIRECTED_SLOW))
|
||||
)
|
||||
{
|
||||
if (m_evt_handler != NULL)
|
||||
{
|
||||
m_peer_addr_reply_expected = true;
|
||||
m_evt_handler(BLE_ADV_EVT_PEER_ADDR_REQUEST);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_peer_addr_reply_expected = false;
|
||||
}
|
||||
}
|
||||
|
||||
m_adv_mode_current = adv_mode_next_avail_get(advertising_mode);
|
||||
|
||||
// Fetch the whitelist.
|
||||
if ((m_evt_handler != NULL) &&
|
||||
(m_adv_mode_current == BLE_ADV_MODE_FAST || m_adv_mode_current == BLE_ADV_MODE_SLOW) &&
|
||||
(m_adv_modes_config.ble_adv_whitelist_enabled) &&
|
||||
(!m_whitelist_temporarily_disabled))
|
||||
{
|
||||
#if (NRF_SD_BLE_API_VERSION >= 3)
|
||||
m_whitelist_in_use = false;
|
||||
#endif
|
||||
m_whitelist_reply_expected = true;
|
||||
m_evt_handler(BLE_ADV_EVT_WHITELIST_REQUEST);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_whitelist_reply_expected = false;
|
||||
}
|
||||
|
||||
// Initialize advertising parameters with default values.
|
||||
memset(&adv_params, 0, sizeof(adv_params));
|
||||
|
||||
adv_params.type = BLE_GAP_ADV_TYPE_ADV_IND;
|
||||
adv_params.fp = BLE_GAP_ADV_FP_ANY;
|
||||
|
||||
// Set advertising parameters and events according to selected advertising mode.
|
||||
switch (m_adv_mode_current)
|
||||
{
|
||||
case BLE_ADV_MODE_DIRECTED:
|
||||
ret = set_adv_mode_directed(&adv_params);
|
||||
break;
|
||||
|
||||
case BLE_ADV_MODE_DIRECTED_SLOW:
|
||||
ret = set_adv_mode_directed_slow(&adv_params);
|
||||
break;
|
||||
|
||||
case BLE_ADV_MODE_FAST:
|
||||
ret = set_adv_mode_fast(&adv_params);
|
||||
break;
|
||||
|
||||
case BLE_ADV_MODE_SLOW:
|
||||
ret = set_adv_mode_slow(&adv_params);
|
||||
break;
|
||||
|
||||
case BLE_ADV_MODE_IDLE:
|
||||
m_adv_evt = BLE_ADV_EVT_IDLE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_adv_mode_current != BLE_ADV_MODE_IDLE)
|
||||
{
|
||||
ret = sd_ble_gap_adv_start(&adv_params);
|
||||
if (ret != NRF_SUCCESS)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_evt_handler != NULL)
|
||||
{
|
||||
m_evt_handler(m_adv_evt);
|
||||
}
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void ble_advertising_on_ble_evt(ble_evt_t const * p_ble_evt)
|
||||
{
|
||||
switch (p_ble_evt->header.evt_id)
|
||||
{
|
||||
case BLE_GAP_EVT_CONNECTED:
|
||||
on_connected(p_ble_evt);
|
||||
break;
|
||||
|
||||
// Upon disconnection, whitelist will be activated and direct advertising is started.
|
||||
case BLE_GAP_EVT_DISCONNECTED:
|
||||
on_disconnected(p_ble_evt);
|
||||
break;
|
||||
|
||||
// Upon time-out, the next advertising mode is started.
|
||||
case BLE_GAP_EVT_TIMEOUT:
|
||||
on_timeout(p_ble_evt);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ble_advertising_on_sys_evt(uint32_t sys_evt)
|
||||
{
|
||||
uint32_t ret;
|
||||
|
||||
switch (sys_evt)
|
||||
{
|
||||
//When a flash operation finishes, re-attempt to start advertising operations.
|
||||
case NRF_EVT_FLASH_OPERATION_SUCCESS:
|
||||
case NRF_EVT_FLASH_OPERATION_ERROR:
|
||||
if (m_advertising_start_pending)
|
||||
{
|
||||
m_advertising_start_pending = false;
|
||||
ret = ble_advertising_start(m_adv_mode_current);
|
||||
if ((ret != NRF_SUCCESS) && (m_error_handler != NULL))
|
||||
{
|
||||
m_error_handler(ret);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// No implementation needed.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint32_t ble_advertising_peer_addr_reply(ble_gap_addr_t * p_peer_address)
|
||||
{
|
||||
if (!m_peer_addr_reply_expected)
|
||||
{
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
m_peer_addr_reply_expected = false;
|
||||
|
||||
memcpy(&m_peer_address, p_peer_address, sizeof(m_peer_address));
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
uint32_t ble_advertising_whitelist_reply(ble_gap_addr_t const * p_gap_addrs,
|
||||
uint32_t addr_cnt,
|
||||
ble_gap_irk_t const * p_gap_irks,
|
||||
uint32_t irk_cnt)
|
||||
{
|
||||
if (!m_whitelist_reply_expected)
|
||||
{
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
m_whitelist_reply_expected = false;
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
|
||||
m_whitelist.addr_count = addr_cnt;
|
||||
m_whitelist.irk_count = irk_cnt;
|
||||
|
||||
for (uint32_t i = 0; i < addr_cnt; i++)
|
||||
{
|
||||
*m_whitelist.pp_addrs[i] = p_gap_addrs[i];
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < irk_cnt; i++)
|
||||
{
|
||||
*m_whitelist.pp_irks[i] = p_gap_irks[i];
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
m_whitelist_in_use = ((addr_cnt > 0) || (irk_cnt > 0));
|
||||
|
||||
#endif
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
uint32_t ble_advertising_restart_without_whitelist(void)
|
||||
{
|
||||
uint32_t ret;
|
||||
|
||||
(void) sd_ble_gap_adv_stop();
|
||||
|
||||
m_whitelist_temporarily_disabled = true;
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION >= 3)
|
||||
m_whitelist_in_use = false;
|
||||
#endif
|
||||
|
||||
m_advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
|
||||
|
||||
ret = ble_advdata_set(&m_advdata, NULL);
|
||||
if (ret != NRF_SUCCESS)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = ble_advertising_start(m_adv_mode_current);
|
||||
if ((ret != NRF_SUCCESS) && (m_error_handler != NULL))
|
||||
{
|
||||
m_error_handler(ret);
|
||||
}
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
#endif // NRF_MODULE_ENABLED(BLE_ADVERTISING)
|
||||
|
|
@ -1,261 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**@file
|
||||
*
|
||||
* @defgroup ble_advertising Advertising Module
|
||||
* @{
|
||||
* @ingroup ble_sdk_lib
|
||||
* @brief Module for handling connectable BLE advertising.
|
||||
*
|
||||
* @details The Advertising Module handles connectable advertising for your application. It can
|
||||
* be configured with advertising modes to suit most typical use cases.
|
||||
* Your main application can react to changes in advertising modes
|
||||
* if an event handler is provided.
|
||||
*
|
||||
* @note The Advertising Module supports only applications with a single peripheral link.
|
||||
*
|
||||
* The application must propagate BLE stack events to this module by calling
|
||||
* @ref ble_advertising_on_ble_evt() and system events by calling
|
||||
* @ref ble_advertising_on_sys_evt().
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BLE_ADVERTISING_H__
|
||||
#define BLE_ADVERTISING_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "nrf_error.h"
|
||||
#include "headers/nrf_ble.h"
|
||||
#include "headers/nrf_ble_gattc.h"
|
||||
#include "ble_advdata.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**@brief Advertising modes.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BLE_ADV_MODE_IDLE, /**< Idle; no connectable advertising is ongoing. */
|
||||
BLE_ADV_MODE_DIRECTED, /**< Directed advertising attempts to connect to the most recently disconnected peer. */
|
||||
BLE_ADV_MODE_DIRECTED_SLOW, /**< Directed advertising (low duty cycle) attempts to connect to the most recently disconnected peer. */
|
||||
BLE_ADV_MODE_FAST, /**< Fast advertising will connect to any peer device, or filter with a whitelist if one exists. */
|
||||
BLE_ADV_MODE_SLOW, /**< Slow advertising is similar to fast advertising. By default, it uses a longer advertising interval and time-out than fast advertising. However, these options are defined by the user. */
|
||||
} ble_adv_mode_t;
|
||||
|
||||
/**@brief Advertising events.
|
||||
*
|
||||
* @details These events are propagated to the main application if a handler was provided during
|
||||
* initialization of the Advertising Module. Events for modes that are not used can be
|
||||
* ignored. Similarly, BLE_ADV_EVT_WHITELIST_REQUEST and BLE_ADV_EVT_PEER_ADDR_REQUEST
|
||||
* can be ignored if whitelist and direct advertising is not used.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BLE_ADV_EVT_IDLE, /**< Idle; no connectable advertising is ongoing.*/
|
||||
BLE_ADV_EVT_DIRECTED, /**< Direct advertising mode has started. */
|
||||
BLE_ADV_EVT_DIRECTED_SLOW, /**< Directed advertising (low duty cycle) has started. */
|
||||
BLE_ADV_EVT_FAST, /**< Fast advertising mode has started. */
|
||||
BLE_ADV_EVT_SLOW, /**< Slow advertising mode has started. */
|
||||
BLE_ADV_EVT_FAST_WHITELIST, /**< Fast advertising mode using the whitelist has started. */
|
||||
BLE_ADV_EVT_SLOW_WHITELIST, /**< Slow advertising mode using the whitelist has started. */
|
||||
BLE_ADV_EVT_WHITELIST_REQUEST, /**< Request a whitelist from the main application. For whitelist advertising to work, the whitelist must be set when this event occurs. */
|
||||
BLE_ADV_EVT_PEER_ADDR_REQUEST /**< Request a peer address from the main application. For directed advertising to work, the peer address must be set when this event occurs. */
|
||||
} ble_adv_evt_t;
|
||||
|
||||
|
||||
/**@brief Options for the different advertisement modes.
|
||||
*
|
||||
* @details This structure is used to enable or disable advertising modes and to configure time-out
|
||||
* periods and advertising intervals.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
bool ble_adv_whitelist_enabled; /**< Enable or disable use of the whitelist. */
|
||||
bool ble_adv_directed_enabled; /**< Enable or disable direct advertising mode. */
|
||||
bool ble_adv_directed_slow_enabled; /**< Enable or disable direct advertising mode. */
|
||||
bool ble_adv_fast_enabled; /**< Enable or disable fast advertising mode. */
|
||||
bool ble_adv_slow_enabled; /**< Enable or disable slow advertising mode. */
|
||||
uint32_t ble_adv_directed_slow_interval; /**< Advertising interval for directed advertising. */
|
||||
uint32_t ble_adv_directed_slow_timeout; /**< Time-out (number of tries) for direct advertising. */
|
||||
uint32_t ble_adv_fast_interval; /**< Advertising interval for fast advertising. */
|
||||
uint32_t ble_adv_fast_timeout; /**< Time-out (in seconds) for fast advertising. */
|
||||
uint32_t ble_adv_slow_interval; /**< Advertising interval for slow advertising. */
|
||||
uint32_t ble_adv_slow_timeout; /**< Time-out (in seconds) for slow advertising. */
|
||||
} ble_adv_modes_config_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t interval;
|
||||
uint32_t timeout;
|
||||
bool enabled;
|
||||
} ble_adv_mode_config_t;
|
||||
|
||||
|
||||
/**@brief BLE advertising event handler type. */
|
||||
typedef void (*ble_advertising_evt_handler_t) (ble_adv_evt_t const adv_evt);
|
||||
|
||||
/**@brief BLE advertising error handler type. */
|
||||
typedef void (*ble_advertising_error_handler_t) (uint32_t nrf_error);
|
||||
|
||||
/**@brief Initialization parameters for the Advertising Module.
|
||||
* @details This structure is used to pass advertising options, advertising data, and an event handler to the Advertising Module during initialization. */
|
||||
typedef struct
|
||||
{
|
||||
ble_adv_modes_config_t options; /**< Parameters for advertising modes.*/
|
||||
ble_advdata_t advdata; /**< Advertising data. */
|
||||
ble_advertising_evt_handler_t evt_handler; /**< Event handler. */
|
||||
} ble_adv_init_t;
|
||||
|
||||
|
||||
/**@brief Function for handling BLE events.
|
||||
*
|
||||
* @details This function must be called from the BLE stack event dispatcher for
|
||||
* the module to handle BLE events that are relevant for the Advertising Module.
|
||||
*
|
||||
* @param[in] p_ble_evt BLE stack event.
|
||||
*/
|
||||
void ble_advertising_on_ble_evt(const ble_evt_t * const p_ble_evt);
|
||||
|
||||
|
||||
/**@brief Function for handling system events.
|
||||
*
|
||||
* @details This function must be called to handle system events that are relevant
|
||||
* for the Advertising Module. Specifically, the advertising module can not use the
|
||||
* softdevice as long as there are pending writes to the flash memory. This
|
||||
* event handler is designed to delay advertising until there is no flash operation.
|
||||
*
|
||||
* @param[in] sys_evt System event.
|
||||
*/
|
||||
void ble_advertising_on_sys_evt(uint32_t sys_evt);
|
||||
|
||||
|
||||
/**@brief Function for initializing the Advertising Module.
|
||||
*
|
||||
* @details Encodes the required advertising data and passes it to the stack.
|
||||
* Also builds a structure to be passed to the stack when starting advertising.
|
||||
* The supplied advertising data is copied to a local structure and is manipulated
|
||||
* depending on what advertising modes are started in @ref ble_advertising_start.
|
||||
*
|
||||
* @param[in] p_advdata Advertising data: name, appearance, discovery flags, and more.
|
||||
* @param[in] p_srdata Scan response data: Supplement to advertising data.
|
||||
* @param[in] p_config Select which advertising modes and intervals will be utilized.
|
||||
* @param[in] evt_handler Event handler that will be called upon advertising events.
|
||||
* @param[in] error_handler Error handler that will propogate internal errors to the main applications.
|
||||
*
|
||||
* @retval NRF_SUCCESS If initialization was successful. Otherwise, an error code is returned.
|
||||
*/
|
||||
uint32_t ble_advertising_init(ble_advdata_t const * p_advdata,
|
||||
ble_advdata_t const * p_srdata,
|
||||
ble_adv_modes_config_t const * p_config,
|
||||
ble_advertising_evt_handler_t const evt_handler,
|
||||
ble_advertising_error_handler_t const error_handler);
|
||||
|
||||
|
||||
/**@brief Function for starting advertising.
|
||||
*
|
||||
* @details You can start advertising in any of the advertising modes that you enabled
|
||||
* during initialization.
|
||||
*
|
||||
* @param[in] advertising_mode Advertising mode.
|
||||
*
|
||||
* @retval @ref NRF_SUCCESS On success, else an error code indicating reason for failure.
|
||||
* @retval @ref NRF_ERROR_INVALID_STATE If the module is not initialized.
|
||||
*/
|
||||
uint32_t ble_advertising_start(ble_adv_mode_t advertising_mode);
|
||||
|
||||
|
||||
/**@brief Function for setting the peer address.
|
||||
*
|
||||
* @details The peer address must be set by the application upon receiving a
|
||||
* @ref BLE_ADV_EVT_PEER_ADDR_REQUEST event. Without the peer address, the directed
|
||||
* advertising mode will not be run.
|
||||
*
|
||||
* @param[in] p_peer_addr Pointer to a peer address.
|
||||
*
|
||||
* @retval @ref NRF_SUCCESS Successfully stored the peer address pointer in the advertising module.
|
||||
* @retval @ref NRF_ERROR_INVALID_STATE If a reply was not expected.
|
||||
*/
|
||||
uint32_t ble_advertising_peer_addr_reply(ble_gap_addr_t * p_peer_addr);
|
||||
|
||||
|
||||
/**@brief Function for setting a whitelist.
|
||||
*
|
||||
* @details The whitelist must be set by the application upon receiving a
|
||||
* @ref BLE_ADV_EVT_WHITELIST_REQUEST event. Without the whitelist, the whitelist
|
||||
* advertising for fast and slow modes will not be run.
|
||||
*
|
||||
* @param[in] p_gap_addrs The list of GAP addresses to whitelist.
|
||||
* @param[in] addr_cnt The number of GAP addresses to whitelist.
|
||||
* @param[in] p_gap_irks The list of peer IRK to whitelist.
|
||||
* @param[in] irk_cnt The number of peer IRK to whitelist.
|
||||
*
|
||||
* @retval @ref NRF_SUCCESS If the operation was successful.
|
||||
* @retval @ref NRF_ERROR_INVALID_STATE If a call to this function was made without a
|
||||
* BLE_ADV_EVT_WHITELIST_REQUEST event being received.
|
||||
*/
|
||||
uint32_t ble_advertising_whitelist_reply(ble_gap_addr_t const * p_gap_addrs,
|
||||
uint32_t addr_cnt,
|
||||
ble_gap_irk_t const * p_gap_irks,
|
||||
uint32_t irk_cnt);
|
||||
|
||||
|
||||
/**@brief Function for disabling whitelist advertising.
|
||||
*
|
||||
* @details This function temporarily disables whitelist advertising.
|
||||
* Calling this function resets the current time-out countdown.
|
||||
*
|
||||
* @retval @ref NRF_SUCCESS On success, else an error message propogated from the Softdevice.
|
||||
*/
|
||||
uint32_t ble_advertising_restart_without_whitelist(void);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // BLE_ADVERTISING_H__
|
||||
|
||||
/** @} */
|
||||
|
|
@ -1,989 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sdk_common.h"
|
||||
#if NRF_MODULE_ENABLED(BLE_DB_DISCOVERY)
|
||||
#include "ble_db_discovery.h"
|
||||
#include <stdlib.h>
|
||||
#include "headers/nrf_ble.h"
|
||||
#include "ble_srv_common.h"
|
||||
#define NRF_LOG_MODULE_NAME "BLE_DB_DISC"
|
||||
#include "nrf_log.h"
|
||||
|
||||
#define SRV_DISC_START_HANDLE 0x0001 /**< The start handle value used during service discovery. */
|
||||
#define DB_DISCOVERY_MAX_USERS BLE_DB_DISCOVERY_MAX_SRV /**< The maximum number of users/registrations allowed by this module. */
|
||||
#define MODULE_INITIALIZED (m_initialized == true) /**< Macro designating whether the module has been initialized properly. */
|
||||
|
||||
|
||||
/**@brief Array of structures containing information about the registered application modules. */
|
||||
static ble_uuid_t m_registered_handlers[DB_DISCOVERY_MAX_USERS];
|
||||
|
||||
|
||||
/**@brief Array of structures containing pending events to be sent to the application modules.
|
||||
*
|
||||
* @details Whenever a discovery related event is to be raised to a user module, it will be stored
|
||||
* in this array first. When all services needed to be discovered have been
|
||||
* discovered, all pending events will be sent to the corresponding user modules.
|
||||
**/
|
||||
static struct
|
||||
{
|
||||
ble_db_discovery_evt_t evt; /**< The pending event. */
|
||||
ble_db_discovery_evt_handler_t evt_handler; /**< The event handler which should be called to raise this event. */
|
||||
} m_pending_user_evts[DB_DISCOVERY_MAX_USERS];
|
||||
|
||||
static ble_db_discovery_evt_handler_t m_evt_handler;
|
||||
static uint32_t m_pending_usr_evt_index; /**< The index to the pending user event array, pointing to the last added pending user event. */
|
||||
static uint32_t m_num_of_handlers_reg; /**< The number of handlers registered with the DB Discovery module. */
|
||||
static bool m_initialized = false; /**< This variable Indicates if the module is initialized or not. */
|
||||
|
||||
/**@brief Function for fetching the event handler provided by a registered application module.
|
||||
*
|
||||
* @param[in] srv_uuid UUID of the service.
|
||||
*
|
||||
* @retval evt_handler Event handler of the module, registered for the given service UUID.
|
||||
* @retval NULL If no event handler is found.
|
||||
*/
|
||||
static ble_db_discovery_evt_handler_t registered_handler_get(const ble_uuid_t * const p_srv_uuid)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < m_num_of_handlers_reg; i++)
|
||||
{
|
||||
if (BLE_UUID_EQ(&(m_registered_handlers[i]), p_srv_uuid))
|
||||
{
|
||||
return (m_evt_handler);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for storing the event handler provided by a registered application module.
|
||||
*
|
||||
* @param[in] p_srv_uuid The UUID of the service.
|
||||
* @param[in] p_evt_handler The event handler provided by the application.
|
||||
*
|
||||
* @retval NRF_SUCCESS If the handler was stored or already present in the list.
|
||||
* @retval NRF_ERROR_NO_MEM If there is no space left to store the handler.
|
||||
*/
|
||||
static uint32_t registered_handler_set(const ble_uuid_t * const p_srv_uuid,
|
||||
ble_db_discovery_evt_handler_t p_evt_handler)
|
||||
{
|
||||
if (registered_handler_get(p_srv_uuid) != NULL)
|
||||
{
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
if (m_num_of_handlers_reg < DB_DISCOVERY_MAX_USERS)
|
||||
{
|
||||
m_registered_handlers[m_num_of_handlers_reg] = *p_srv_uuid;
|
||||
|
||||
m_num_of_handlers_reg++;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NRF_ERROR_NO_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for sending all pending discovery events to the corresponding user modules.
|
||||
*/
|
||||
static void pending_user_evts_send(void)
|
||||
{
|
||||
uint32_t i = 0;
|
||||
|
||||
for (i = 0; i < m_num_of_handlers_reg; i++)
|
||||
{
|
||||
// Pass the event to the corresponding event handler.
|
||||
m_pending_user_evts[i].evt_handler(&(m_pending_user_evts[i].evt));
|
||||
}
|
||||
m_pending_usr_evt_index = 0;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for indicating error to the application.
|
||||
*
|
||||
* @details This function will fetch the event handler based on the UUID of the service being
|
||||
* discovered. (The event handler is registered by the application beforehand).
|
||||
* The error code is added to the pending events together with the event handler.
|
||||
* If no event handler was found, then this function will do nothing.
|
||||
*
|
||||
* @param[in] p_db_discovery Pointer to the DB discovery structure.
|
||||
* @param[in] err_code Error code that should be provided to the application.
|
||||
* @param[in] conn_handle Connection Handle.
|
||||
*
|
||||
*/
|
||||
static void discovery_error_evt_trigger(ble_db_discovery_t * const p_db_discovery,
|
||||
uint32_t err_code,
|
||||
uint16_t const conn_handle)
|
||||
{
|
||||
ble_db_discovery_evt_handler_t p_evt_handler;
|
||||
ble_gatt_db_srv_t * p_srv_being_discovered;
|
||||
|
||||
p_srv_being_discovered = &(p_db_discovery->services[p_db_discovery->curr_srv_ind]);
|
||||
|
||||
p_evt_handler = registered_handler_get(&(p_srv_being_discovered->srv_uuid));
|
||||
|
||||
if (p_evt_handler != NULL)
|
||||
{
|
||||
ble_db_discovery_evt_t evt;
|
||||
|
||||
evt.conn_handle = conn_handle;
|
||||
evt.evt_type = BLE_DB_DISCOVERY_ERROR;
|
||||
evt.params.err_code = err_code;
|
||||
|
||||
p_evt_handler(&evt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for triggering a Discovery Complete or Service Not Found event to the
|
||||
* application.
|
||||
*
|
||||
* @details This function will fetch the event handler based on the UUID of the service being
|
||||
* discovered. (The event handler is registered by the application beforehand).
|
||||
* It then triggers an event indicating the completion of the service discovery.
|
||||
* If no event handler was found, then this function will do nothing.
|
||||
*
|
||||
* @param[in] p_db_discovery Pointer to the DB discovery structure.
|
||||
* @param[in] is_srv_found Variable to indicate if the service was found at the peer.
|
||||
* @param[in] conn_handle Connection Handle.
|
||||
*/
|
||||
static void discovery_complete_evt_trigger(ble_db_discovery_t * const p_db_discovery,
|
||||
bool is_srv_found,
|
||||
uint16_t const conn_handle)
|
||||
{
|
||||
ble_db_discovery_evt_handler_t p_evt_handler;
|
||||
ble_gatt_db_srv_t * p_srv_being_discovered;
|
||||
|
||||
p_srv_being_discovered = &(p_db_discovery->services[p_db_discovery->curr_srv_ind]);
|
||||
|
||||
p_evt_handler = registered_handler_get(&(p_srv_being_discovered->srv_uuid));
|
||||
|
||||
if (p_evt_handler != NULL)
|
||||
{
|
||||
if (m_pending_usr_evt_index < DB_DISCOVERY_MAX_USERS)
|
||||
{
|
||||
// Insert an event into the pending event list.
|
||||
m_pending_user_evts[m_pending_usr_evt_index].evt.conn_handle = conn_handle;
|
||||
|
||||
m_pending_user_evts[m_pending_usr_evt_index].evt.params.discovered_db =
|
||||
*p_srv_being_discovered;
|
||||
if (is_srv_found)
|
||||
{
|
||||
m_pending_user_evts[m_pending_usr_evt_index].evt.evt_type =
|
||||
BLE_DB_DISCOVERY_COMPLETE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pending_user_evts[m_pending_usr_evt_index].evt.evt_type =
|
||||
BLE_DB_DISCOVERY_SRV_NOT_FOUND;
|
||||
}
|
||||
m_pending_user_evts[m_pending_usr_evt_index].evt_handler = p_evt_handler;
|
||||
|
||||
m_pending_usr_evt_index++;
|
||||
|
||||
if (m_pending_usr_evt_index == m_num_of_handlers_reg)
|
||||
{
|
||||
// All registered modules have pending events. Send all pending events to the user
|
||||
// modules.
|
||||
pending_user_evts_send();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Too many events pending. Do nothing. (Ideally this should not happen.)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for handling service discovery completion.
|
||||
*
|
||||
* @details This function will be used to determine if there are more services to be discovered,
|
||||
* and if so, initiate the discovery of the next service.
|
||||
*
|
||||
* @param[in] p_db_discovery Pointer to the DB Discovery Structure.
|
||||
* @param[in] conn_handle Connection Handle.
|
||||
*/
|
||||
static void on_srv_disc_completion(ble_db_discovery_t * p_db_discovery,
|
||||
uint16_t const conn_handle)
|
||||
{
|
||||
p_db_discovery->discoveries_count++;
|
||||
|
||||
// Check if more services need to be discovered.
|
||||
if (p_db_discovery->discoveries_count < m_num_of_handlers_reg)
|
||||
{
|
||||
// Reset the current characteristic index since a new service discovery is about to start.
|
||||
p_db_discovery->curr_char_ind = 0;
|
||||
|
||||
// Initiate discovery of the next service.
|
||||
p_db_discovery->curr_srv_ind++;
|
||||
|
||||
ble_gatt_db_srv_t * p_srv_being_discovered;
|
||||
|
||||
p_srv_being_discovered = &(p_db_discovery->services[p_db_discovery->curr_srv_ind]);
|
||||
|
||||
p_srv_being_discovered->srv_uuid = m_registered_handlers[p_db_discovery->curr_srv_ind];
|
||||
|
||||
// Reset the characteristic count in the current service to zero since a new service
|
||||
// discovery is about to start.
|
||||
p_srv_being_discovered->char_count = 0;
|
||||
|
||||
NRF_LOG_INFO("Starting discovery of service with UUID 0x%x for Connection handle %d\r\n",
|
||||
p_srv_being_discovered->srv_uuid.uuid, conn_handle);
|
||||
|
||||
uint32_t err_code;
|
||||
|
||||
err_code = sd_ble_gattc_primary_services_discover
|
||||
(
|
||||
conn_handle,
|
||||
SRV_DISC_START_HANDLE,
|
||||
&(p_srv_being_discovered->srv_uuid)
|
||||
);
|
||||
if (err_code != NRF_SUCCESS)
|
||||
{
|
||||
p_db_discovery->discovery_in_progress = false;
|
||||
|
||||
// Error with discovering the service.
|
||||
// Indicate the error to the registered user application.
|
||||
discovery_error_evt_trigger(p_db_discovery, err_code, conn_handle);
|
||||
|
||||
m_pending_user_evts[0].evt.evt_type = BLE_DB_DISCOVERY_AVAILABLE;
|
||||
m_pending_user_evts[0].evt.conn_handle = conn_handle;
|
||||
// m_evt_handler(&m_pending_user_evts[0].evt);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No more service discovery is needed.
|
||||
p_db_discovery->discovery_in_progress = false;
|
||||
m_pending_user_evts[0].evt.evt_type = BLE_DB_DISCOVERY_AVAILABLE;
|
||||
m_pending_user_evts[0].evt.conn_handle = conn_handle;
|
||||
//m_evt_handler(&m_pending_user_evts[0].evt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for finding out if a characteristic discovery should be performed after the
|
||||
* last discovered characteristic.
|
||||
*
|
||||
* @details This function is used during the time of database discovery to find out if there is
|
||||
* a need to do more characteristic discoveries. The value handles of the
|
||||
* last discovered characteristic is compared with the end handle of the service.
|
||||
* If the service handle is greater than one of the former characteristic handles,
|
||||
* it means that a characteristic discovery is required.
|
||||
*
|
||||
* @param[in] p_db_discovery The pointer to the DB Discovery structure.
|
||||
* @param[in] p_after_char The pointer to the last discovered characteristic.
|
||||
*
|
||||
* @retval True if a characteristic discovery is required.
|
||||
* @retval False if a characteristic discovery is NOT required.
|
||||
*/
|
||||
static bool is_char_discovery_reqd(ble_db_discovery_t * const p_db_discovery,
|
||||
ble_gattc_char_t * p_after_char)
|
||||
{
|
||||
if (
|
||||
p_after_char->handle_value <
|
||||
p_db_discovery->services[p_db_discovery->curr_srv_ind].handle_range.end_handle
|
||||
)
|
||||
{
|
||||
// Handle value of the characteristic being discovered is less than the end handle of
|
||||
// the service being discovered. There is a possibility of more characteristics being
|
||||
// present. Hence a characteristic discovery is required.
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function to find out if a descriptor discovery is required.
|
||||
*
|
||||
* @details This function finds out if there is a possibility of existence of descriptors between
|
||||
* current characteristic and the next characteristic. If so, this function will compute
|
||||
* the handle range on which the descriptors may be present and will return it.
|
||||
* If the current characteristic is the last known characteristic, then this function
|
||||
* will use the service end handle to find out if the current characteristic can have
|
||||
* descriptors.
|
||||
*
|
||||
* @param[in] p_db_discovery Pointer to the DB Discovery structure.
|
||||
* @param[in] p_curr_char Pointer to the current characteristic.
|
||||
* @param[in] p_next_char Pointer to the next characteristic. This should be NULL if the
|
||||
* caller knows that there is no characteristic after the current
|
||||
* characteristic at the peer.
|
||||
* @param[out] p_handle_range Pointer to the handle range in which descriptors may exist at the
|
||||
* the peer.
|
||||
*
|
||||
* @retval True If a descriptor discovery is required.
|
||||
* @retval False If a descriptor discovery is NOT required.
|
||||
*/
|
||||
static bool is_desc_discovery_reqd(ble_db_discovery_t * p_db_discovery,
|
||||
ble_gatt_db_char_t * p_curr_char,
|
||||
ble_gatt_db_char_t * p_next_char,
|
||||
ble_gattc_handle_range_t * p_handle_range)
|
||||
{
|
||||
if (p_next_char == NULL)
|
||||
{
|
||||
// Current characteristic is the last characteristic in the service. Check if the value
|
||||
// handle of the current characteristic is equal to the service end handle.
|
||||
if (
|
||||
p_curr_char->characteristic.handle_value ==
|
||||
p_db_discovery->services[p_db_discovery->curr_srv_ind].handle_range.end_handle
|
||||
)
|
||||
{
|
||||
// No descriptors can be present for the current characteristic. p_curr_char is the last
|
||||
// characteristic with no descriptors.
|
||||
return false;
|
||||
}
|
||||
|
||||
p_handle_range->start_handle = p_curr_char->characteristic.handle_value + 1;
|
||||
|
||||
// Since the current characteristic is the last characteristic in the service, the end
|
||||
// handle should be the end handle of the service.
|
||||
p_handle_range->end_handle =
|
||||
p_db_discovery->services[p_db_discovery->curr_srv_ind].handle_range.end_handle;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// p_next_char != NULL. Check for existence of descriptors between the current and the next
|
||||
// characteristic.
|
||||
if ((p_curr_char->characteristic.handle_value + 1) == p_next_char->characteristic.handle_decl)
|
||||
{
|
||||
// No descriptors can exist between the two characteristic.
|
||||
return false;
|
||||
}
|
||||
|
||||
p_handle_range->start_handle = p_curr_char->characteristic.handle_value + 1;
|
||||
p_handle_range->end_handle = p_next_char->characteristic.handle_decl - 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for performing characteristic discovery.
|
||||
*
|
||||
* @param[in] p_db_discovery Pointer to the DB Discovery structure.
|
||||
* @param[in] conn_handle Connection Handle.
|
||||
*
|
||||
* @return NRF_SUCCESS if the SoftDevice was successfully requested to perform the characteristic
|
||||
* discovery. Otherwise an error code. This function returns the error code returned
|
||||
* by the SoftDevice API @ref sd_ble_gattc_characteristics_discover.
|
||||
*/
|
||||
static uint32_t characteristics_discover(ble_db_discovery_t * const p_db_discovery,
|
||||
uint16_t const conn_handle)
|
||||
{
|
||||
ble_gatt_db_srv_t * p_srv_being_discovered;
|
||||
ble_gattc_handle_range_t handle_range;
|
||||
|
||||
p_srv_being_discovered = &(p_db_discovery->services[p_db_discovery->curr_srv_ind]);
|
||||
|
||||
if (p_db_discovery->curr_char_ind != 0)
|
||||
{
|
||||
// This is not the first characteristic being discovered. Hence the 'start handle' to be
|
||||
// used must be computed using the handle_value of the previous characteristic.
|
||||
ble_gattc_char_t * p_prev_char;
|
||||
uint8_t prev_char_ind = p_db_discovery->curr_char_ind - 1;
|
||||
|
||||
p_srv_being_discovered = &(p_db_discovery->services[p_db_discovery->curr_srv_ind]);
|
||||
|
||||
p_prev_char = &(p_srv_being_discovered->charateristics[prev_char_ind].characteristic);
|
||||
|
||||
handle_range.start_handle = p_prev_char->handle_value + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is the first characteristic of this service being discovered.
|
||||
handle_range.start_handle = p_srv_being_discovered->handle_range.start_handle;
|
||||
}
|
||||
|
||||
handle_range.end_handle = p_srv_being_discovered->handle_range.end_handle;
|
||||
|
||||
return sd_ble_gattc_characteristics_discover(conn_handle, &handle_range);
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for performing descriptor discovery, if required.
|
||||
*
|
||||
* @details This function will check if descriptor discovery is required and then perform it if
|
||||
* needed. If no more descriptor discovery is required for the service, then the output
|
||||
* parameter p_raise_discov_complete is set to true, indicating to the caller that a
|
||||
* discovery complete event can be triggered to the application.
|
||||
*
|
||||
* @param[in] p_db_discovery Pointer to the DB Discovery structure.
|
||||
* @param[out] p_raise_discov_complete The value pointed to by this pointer will be set to true if
|
||||
* the Discovery Complete event can be triggered to the
|
||||
* application.
|
||||
* @param[in] conn_handle Connection Handle.
|
||||
*
|
||||
* @return NRF_SUCCESS if the SoftDevice was successfully requested to perform the descriptor
|
||||
* discovery, or if no more descriptor discovery is required. Otherwise an error code.
|
||||
* This function returns the error code returned by the SoftDevice API @ref
|
||||
* sd_ble_gattc_descriptors_discover.
|
||||
*/
|
||||
static uint32_t descriptors_discover(ble_db_discovery_t * const p_db_discovery,
|
||||
bool * p_raise_discov_complete,
|
||||
uint16_t const conn_handle)
|
||||
{
|
||||
ble_gattc_handle_range_t handle_range;
|
||||
ble_gatt_db_char_t * p_curr_char_being_discovered;
|
||||
ble_gatt_db_srv_t * p_srv_being_discovered;
|
||||
bool is_discovery_reqd = false;
|
||||
|
||||
p_srv_being_discovered = &(p_db_discovery->services[p_db_discovery->curr_srv_ind]);
|
||||
|
||||
p_curr_char_being_discovered =
|
||||
&(p_srv_being_discovered->charateristics[p_db_discovery->curr_char_ind]);
|
||||
|
||||
if ((p_db_discovery->curr_char_ind + 1) == p_srv_being_discovered->char_count)
|
||||
{
|
||||
// This is the last characteristic of this service.
|
||||
is_discovery_reqd = is_desc_discovery_reqd(p_db_discovery,
|
||||
p_curr_char_being_discovered,
|
||||
NULL,
|
||||
&handle_range);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t i;
|
||||
ble_gatt_db_char_t * p_next_char;
|
||||
|
||||
for (i = p_db_discovery->curr_char_ind;
|
||||
i < p_srv_being_discovered->char_count;
|
||||
i++)
|
||||
{
|
||||
|
||||
if (i == (p_srv_being_discovered->char_count - 1))
|
||||
{
|
||||
// The current characteristic is the last characteristic in the service.
|
||||
p_next_char = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_next_char = &(p_srv_being_discovered->charateristics[i + 1]);
|
||||
}
|
||||
|
||||
// Check if it is possible for the current characteristic to have a descriptor.
|
||||
if (is_desc_discovery_reqd(p_db_discovery,
|
||||
p_curr_char_being_discovered,
|
||||
p_next_char,
|
||||
&handle_range))
|
||||
{
|
||||
is_discovery_reqd = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No descriptors can exist.
|
||||
p_curr_char_being_discovered = p_next_char;
|
||||
p_db_discovery->curr_char_ind++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_discovery_reqd)
|
||||
{
|
||||
// No more descriptor discovery required. Discovery is complete.
|
||||
// This informs the caller that a discovery complete event can be triggered.
|
||||
*p_raise_discov_complete = true;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
*p_raise_discov_complete = false;
|
||||
|
||||
return sd_ble_gattc_descriptors_discover(conn_handle, &handle_range);
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for handling primary service discovery response.
|
||||
*
|
||||
* @details This function will handle the primary service discovery response and start the
|
||||
* discovery of characteristics within that service.
|
||||
*
|
||||
* @param[in] p_db_discovery Pointer to the DB Discovery structure.
|
||||
* @param[in] p_ble_gattc_evt Pointer to the GATT Client event.
|
||||
*/
|
||||
static void on_primary_srv_discovery_rsp(ble_db_discovery_t * const p_db_discovery,
|
||||
const ble_gattc_evt_t * const p_ble_gattc_evt)
|
||||
{
|
||||
ble_gatt_db_srv_t * p_srv_being_discovered;
|
||||
p_srv_being_discovered = &(p_db_discovery->services[p_db_discovery->curr_srv_ind]);
|
||||
|
||||
if (p_ble_gattc_evt->conn_handle != p_db_discovery->conn_handle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (p_ble_gattc_evt->gatt_status == BLE_GATT_STATUS_SUCCESS)
|
||||
{
|
||||
uint32_t err_code;
|
||||
const ble_gattc_evt_prim_srvc_disc_rsp_t * p_prim_srvc_disc_rsp_evt;
|
||||
|
||||
NRF_LOG_INFO("Found service UUID 0x%x\r\n", p_srv_being_discovered->srv_uuid.uuid);
|
||||
|
||||
p_prim_srvc_disc_rsp_evt = &(p_ble_gattc_evt->params.prim_srvc_disc_rsp);
|
||||
|
||||
p_srv_being_discovered->srv_uuid = p_prim_srvc_disc_rsp_evt->services[0].uuid;
|
||||
p_srv_being_discovered->handle_range = p_prim_srvc_disc_rsp_evt->services[0].handle_range;
|
||||
|
||||
err_code = characteristics_discover(p_db_discovery,
|
||||
p_ble_gattc_evt->conn_handle);
|
||||
|
||||
if (err_code != NRF_SUCCESS)
|
||||
{
|
||||
p_db_discovery->discovery_in_progress = false;
|
||||
|
||||
// Error with discovering the service.
|
||||
// Indicate the error to the registered user application.
|
||||
discovery_error_evt_trigger(p_db_discovery,
|
||||
err_code,
|
||||
p_ble_gattc_evt->conn_handle);
|
||||
|
||||
m_pending_user_evts[0].evt.evt_type = BLE_DB_DISCOVERY_AVAILABLE;
|
||||
m_pending_user_evts[0].evt.conn_handle = p_ble_gattc_evt->conn_handle;
|
||||
//m_evt_handler(&m_pending_user_evts[0].evt);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NRF_LOG_INFO("Service UUID 0x%x Not found\r\n", p_srv_being_discovered->srv_uuid.uuid);
|
||||
// Trigger Service Not Found event to the application.
|
||||
discovery_complete_evt_trigger(p_db_discovery,
|
||||
false,
|
||||
p_ble_gattc_evt->conn_handle);
|
||||
|
||||
on_srv_disc_completion(p_db_discovery,
|
||||
p_ble_gattc_evt->conn_handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for handling characteristic discovery response.
|
||||
*
|
||||
* @param[in] p_db_discovery Pointer to the DB Discovery structure.
|
||||
* @param[in] p_ble_gattc_evt Pointer to the GATT Client event.
|
||||
*/
|
||||
static void on_characteristic_discovery_rsp(ble_db_discovery_t * const p_db_discovery,
|
||||
const ble_gattc_evt_t * const p_ble_gattc_evt)
|
||||
{
|
||||
uint32_t err_code;
|
||||
ble_gatt_db_srv_t * p_srv_being_discovered;
|
||||
bool perform_desc_discov = false;
|
||||
|
||||
if (p_ble_gattc_evt->conn_handle != p_db_discovery->conn_handle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
p_srv_being_discovered = &(p_db_discovery->services[p_db_discovery->curr_srv_ind]);
|
||||
|
||||
if (p_ble_gattc_evt->gatt_status == BLE_GATT_STATUS_SUCCESS)
|
||||
{
|
||||
const ble_gattc_evt_char_disc_rsp_t * p_char_disc_rsp_evt;
|
||||
|
||||
p_char_disc_rsp_evt = &(p_ble_gattc_evt->params.char_disc_rsp);
|
||||
|
||||
// Find out the number of characteristics that were previously discovered (in earlier
|
||||
// characteristic discovery responses, if any).
|
||||
uint8_t num_chars_prev_disc = p_srv_being_discovered->char_count;
|
||||
|
||||
// Find out the number of characteristics that are currently discovered (in the
|
||||
// characteristic discovery response being handled).
|
||||
uint8_t num_chars_curr_disc = p_char_disc_rsp_evt->count;
|
||||
|
||||
// Check if the total number of discovered characteristics are supported by this module.
|
||||
if ((num_chars_prev_disc + num_chars_curr_disc) <= BLE_GATT_DB_MAX_CHARS)
|
||||
{
|
||||
// Update the characteristics count.
|
||||
p_srv_being_discovered->char_count += num_chars_curr_disc;
|
||||
}
|
||||
else
|
||||
{
|
||||
// The number of characteristics discovered at the peer is more than the supported
|
||||
// maximum. This module will store only the characteristics found up to this point.
|
||||
p_srv_being_discovered->char_count = BLE_GATT_DB_MAX_CHARS;
|
||||
}
|
||||
|
||||
uint32_t i;
|
||||
uint32_t j;
|
||||
|
||||
for (i = num_chars_prev_disc, j = 0; i < p_srv_being_discovered->char_count; i++, j++)
|
||||
{
|
||||
p_srv_being_discovered->charateristics[i].characteristic =
|
||||
p_char_disc_rsp_evt->chars[j];
|
||||
|
||||
p_srv_being_discovered->charateristics[i].cccd_handle = BLE_GATT_HANDLE_INVALID;
|
||||
p_srv_being_discovered->charateristics[i].ext_prop_handle = BLE_GATT_HANDLE_INVALID;
|
||||
p_srv_being_discovered->charateristics[i].user_desc_handle = BLE_GATT_HANDLE_INVALID;
|
||||
p_srv_being_discovered->charateristics[i].report_ref_handle = BLE_GATT_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
ble_gattc_char_t * p_last_known_char;
|
||||
|
||||
p_last_known_char = &(p_srv_being_discovered->charateristics[i - 1].characteristic);
|
||||
|
||||
// If no more characteristic discovery is required, or if the maximum number of supported
|
||||
// characteristic per service has been reached, descriptor discovery will be performed.
|
||||
if (
|
||||
!is_char_discovery_reqd(p_db_discovery, p_last_known_char) ||
|
||||
(p_srv_being_discovered->char_count == BLE_GATT_DB_MAX_CHARS)
|
||||
)
|
||||
{
|
||||
perform_desc_discov = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update the current characteristic index.
|
||||
p_db_discovery->curr_char_ind = p_srv_being_discovered->char_count;
|
||||
|
||||
// Perform another round of characteristic discovery.
|
||||
err_code = characteristics_discover(p_db_discovery,
|
||||
p_ble_gattc_evt->conn_handle);
|
||||
|
||||
if (err_code != NRF_SUCCESS)
|
||||
{
|
||||
p_db_discovery->discovery_in_progress = false;
|
||||
|
||||
discovery_error_evt_trigger(p_db_discovery,
|
||||
err_code,
|
||||
p_ble_gattc_evt->conn_handle);
|
||||
|
||||
m_pending_user_evts[0].evt.evt_type = BLE_DB_DISCOVERY_AVAILABLE;
|
||||
m_pending_user_evts[0].evt.conn_handle = p_ble_gattc_evt->conn_handle;
|
||||
//m_evt_handler(&m_pending_user_evts[0].evt);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// The previous characteristic discovery resulted in no characteristics.
|
||||
// descriptor discovery should be performed.
|
||||
perform_desc_discov = true;
|
||||
}
|
||||
|
||||
if (perform_desc_discov)
|
||||
{
|
||||
bool raise_discov_complete;
|
||||
|
||||
p_db_discovery->curr_char_ind = 0;
|
||||
|
||||
err_code = descriptors_discover(p_db_discovery,
|
||||
&raise_discov_complete,
|
||||
p_ble_gattc_evt->conn_handle);
|
||||
|
||||
if (err_code != NRF_SUCCESS)
|
||||
{
|
||||
p_db_discovery->discovery_in_progress = false;
|
||||
|
||||
discovery_error_evt_trigger(p_db_discovery,
|
||||
err_code,
|
||||
p_ble_gattc_evt->conn_handle);
|
||||
|
||||
m_pending_user_evts[0].evt.evt_type = BLE_DB_DISCOVERY_AVAILABLE;
|
||||
m_pending_user_evts[0].evt.conn_handle = p_ble_gattc_evt->conn_handle;
|
||||
//m_evt_handler(&m_pending_user_evts[0].evt);
|
||||
|
||||
return;
|
||||
}
|
||||
if (raise_discov_complete)
|
||||
{
|
||||
// No more characteristics and descriptors need to be discovered. Discovery is complete.
|
||||
// Send a discovery complete event to the user application.
|
||||
NRF_LOG_INFO("Discovery of service with UUID 0x%x completed with success for Connection"
|
||||
" handle %d\r\n", p_srv_being_discovered->srv_uuid.uuid,
|
||||
p_ble_gattc_evt->conn_handle);
|
||||
|
||||
discovery_complete_evt_trigger(p_db_discovery,
|
||||
true,
|
||||
p_ble_gattc_evt->conn_handle);
|
||||
|
||||
on_srv_disc_completion(p_db_discovery,
|
||||
p_ble_gattc_evt->conn_handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for handling descriptor discovery response.
|
||||
*
|
||||
* @param[in] p_db_discovery Pointer to the DB Discovery structure.
|
||||
* @param[in] p_ble_gattc_evt Pointer to the GATT Client event.
|
||||
*/
|
||||
static void on_descriptor_discovery_rsp(ble_db_discovery_t * const p_db_discovery,
|
||||
const ble_gattc_evt_t * const p_ble_gattc_evt)
|
||||
{
|
||||
const ble_gattc_evt_desc_disc_rsp_t * p_desc_disc_rsp_evt;
|
||||
ble_gatt_db_srv_t * p_srv_being_discovered;
|
||||
|
||||
if (p_ble_gattc_evt->conn_handle != p_db_discovery->conn_handle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
p_srv_being_discovered = &(p_db_discovery->services[p_db_discovery->curr_srv_ind]);
|
||||
|
||||
p_desc_disc_rsp_evt = &(p_ble_gattc_evt->params.desc_disc_rsp);
|
||||
|
||||
ble_gatt_db_char_t * p_char_being_discovered =
|
||||
&(p_srv_being_discovered->charateristics[p_db_discovery->curr_char_ind]);
|
||||
|
||||
if (p_ble_gattc_evt->gatt_status == BLE_GATT_STATUS_SUCCESS)
|
||||
{
|
||||
// The descriptor was found at the peer.
|
||||
// Iterate through and collect CCCD, Extended Properties,
|
||||
// User Description & Report Reference descriptor handles.
|
||||
for (uint32_t i = 0; i < p_desc_disc_rsp_evt->count; i++)
|
||||
{
|
||||
switch (p_desc_disc_rsp_evt->descs[i].uuid.uuid)
|
||||
{
|
||||
case BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG:
|
||||
p_char_being_discovered->cccd_handle =
|
||||
p_desc_disc_rsp_evt->descs[i].handle;
|
||||
break;
|
||||
|
||||
case BLE_UUID_DESCRIPTOR_CHAR_EXT_PROP:
|
||||
p_char_being_discovered->ext_prop_handle =
|
||||
p_desc_disc_rsp_evt->descs[i].handle;
|
||||
break;
|
||||
|
||||
case BLE_UUID_DESCRIPTOR_CHAR_USER_DESC:
|
||||
p_char_being_discovered->user_desc_handle =
|
||||
p_desc_disc_rsp_evt->descs[i].handle;
|
||||
break;
|
||||
|
||||
case BLE_UUID_REPORT_REF_DESCR:
|
||||
p_char_being_discovered->report_ref_handle =
|
||||
p_desc_disc_rsp_evt->descs[i].handle;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Break if we've found all the descriptors we are looking for. */
|
||||
if (p_char_being_discovered->cccd_handle != BLE_GATT_HANDLE_INVALID &&
|
||||
p_char_being_discovered->ext_prop_handle != BLE_GATT_HANDLE_INVALID &&
|
||||
p_char_being_discovered->user_desc_handle != BLE_GATT_HANDLE_INVALID &&
|
||||
p_char_being_discovered->report_ref_handle != BLE_GATT_HANDLE_INVALID)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool raise_discov_complete = false;
|
||||
|
||||
if ((p_db_discovery->curr_char_ind + 1) == p_srv_being_discovered->char_count)
|
||||
{
|
||||
// No more characteristics and descriptors need to be discovered. Discovery is complete.
|
||||
// Send a discovery complete event to the user application.
|
||||
|
||||
raise_discov_complete = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Begin discovery of descriptors for the next characteristic.
|
||||
uint32_t err_code;
|
||||
|
||||
p_db_discovery->curr_char_ind++;
|
||||
|
||||
err_code = descriptors_discover(p_db_discovery,
|
||||
&raise_discov_complete,
|
||||
p_ble_gattc_evt->conn_handle);
|
||||
|
||||
if (err_code != NRF_SUCCESS)
|
||||
{
|
||||
p_db_discovery->discovery_in_progress = false;
|
||||
|
||||
// Error with discovering the service.
|
||||
// Indicate the error to the registered user application.
|
||||
discovery_error_evt_trigger(p_db_discovery,
|
||||
err_code,
|
||||
p_ble_gattc_evt->conn_handle);
|
||||
|
||||
m_pending_user_evts[0].evt.evt_type = BLE_DB_DISCOVERY_AVAILABLE;
|
||||
m_pending_user_evts[0].evt.conn_handle = p_ble_gattc_evt->conn_handle;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (raise_discov_complete)
|
||||
{
|
||||
NRF_LOG_INFO("Discovery of service with UUID 0x%x completed with success for Connection"
|
||||
" handle %d\r\n", p_srv_being_discovered->srv_uuid.uuid,
|
||||
p_ble_gattc_evt->conn_handle);
|
||||
|
||||
discovery_complete_evt_trigger(p_db_discovery,
|
||||
true,
|
||||
p_ble_gattc_evt->conn_handle);
|
||||
|
||||
on_srv_disc_completion(p_db_discovery,
|
||||
p_ble_gattc_evt->conn_handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint32_t ble_db_discovery_init(const ble_db_discovery_evt_handler_t evt_handler)
|
||||
{
|
||||
uint32_t err_code = NRF_SUCCESS;
|
||||
VERIFY_PARAM_NOT_NULL(evt_handler);
|
||||
|
||||
m_num_of_handlers_reg = 0;
|
||||
m_initialized = true;
|
||||
m_pending_usr_evt_index = 0;
|
||||
m_evt_handler = evt_handler;
|
||||
|
||||
return err_code;
|
||||
|
||||
}
|
||||
|
||||
|
||||
uint32_t ble_db_discovery_close()
|
||||
{
|
||||
m_num_of_handlers_reg = 0;
|
||||
m_initialized = false;
|
||||
m_pending_usr_evt_index = 0;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
uint32_t ble_db_discovery_evt_register(const ble_uuid_t * const p_uuid)
|
||||
{
|
||||
VERIFY_PARAM_NOT_NULL(p_uuid);
|
||||
VERIFY_MODULE_INITIALIZED();
|
||||
|
||||
return registered_handler_set(p_uuid, m_evt_handler);
|
||||
}
|
||||
|
||||
|
||||
uint32_t ble_db_discovery_start(ble_db_discovery_t * const p_db_discovery,
|
||||
uint16_t conn_handle)
|
||||
{
|
||||
VERIFY_PARAM_NOT_NULL(p_db_discovery);
|
||||
VERIFY_MODULE_INITIALIZED();
|
||||
|
||||
if (m_num_of_handlers_reg == 0)
|
||||
{
|
||||
// No user modules were registered. There are no services to discover.
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (p_db_discovery->discovery_in_progress)
|
||||
{
|
||||
return NRF_ERROR_BUSY;
|
||||
}
|
||||
|
||||
p_db_discovery->conn_handle = conn_handle;
|
||||
ble_gatt_db_srv_t * p_srv_being_discovered;
|
||||
|
||||
m_pending_usr_evt_index = 0;
|
||||
|
||||
p_db_discovery->discoveries_count = 0;
|
||||
p_db_discovery->curr_srv_ind = 0;
|
||||
p_db_discovery->curr_char_ind = 0;
|
||||
|
||||
p_srv_being_discovered = &(p_db_discovery->services[p_db_discovery->curr_srv_ind]);
|
||||
|
||||
p_srv_being_discovered->srv_uuid = m_registered_handlers[p_db_discovery->curr_srv_ind];
|
||||
|
||||
NRF_LOG_INFO("Starting discovery of service with UUID 0x%x for Connection handle %d\r\n",
|
||||
p_srv_being_discovered->srv_uuid.uuid, conn_handle);
|
||||
|
||||
uint32_t err_code;
|
||||
|
||||
err_code = sd_ble_gattc_primary_services_discover(conn_handle,
|
||||
SRV_DISC_START_HANDLE,
|
||||
&(p_srv_being_discovered->srv_uuid));
|
||||
VERIFY_SUCCESS(err_code);
|
||||
p_db_discovery->discovery_in_progress = true;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for handling disconnected event.
|
||||
*
|
||||
* @param[in] p_db_discovery Pointer to the DB Discovery structure.
|
||||
* @param[in] p_ble_gattc_evt Pointer to the GAP event.
|
||||
*/
|
||||
static void on_disconnected(ble_db_discovery_t * const p_db_discovery,
|
||||
const ble_gap_evt_t * const p_evt)
|
||||
{
|
||||
if (p_evt->conn_handle == p_db_discovery->conn_handle)
|
||||
{
|
||||
p_db_discovery->discovery_in_progress = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ble_db_discovery_on_ble_evt(ble_db_discovery_t * const p_db_discovery,
|
||||
const ble_evt_t * const p_ble_evt)
|
||||
{
|
||||
VERIFY_PARAM_NOT_NULL_VOID(p_db_discovery);
|
||||
VERIFY_PARAM_NOT_NULL_VOID(p_ble_evt);
|
||||
VERIFY_MODULE_INITIALIZED_VOID();
|
||||
|
||||
switch (p_ble_evt->header.evt_id)
|
||||
{
|
||||
case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP:
|
||||
on_primary_srv_discovery_rsp(p_db_discovery, &(p_ble_evt->evt.gattc_evt));
|
||||
break;
|
||||
|
||||
case BLE_GATTC_EVT_CHAR_DISC_RSP:
|
||||
on_characteristic_discovery_rsp(p_db_discovery, &(p_ble_evt->evt.gattc_evt));
|
||||
break;
|
||||
|
||||
case BLE_GATTC_EVT_DESC_DISC_RSP:
|
||||
on_descriptor_discovery_rsp(p_db_discovery, &(p_ble_evt->evt.gattc_evt));
|
||||
break;
|
||||
|
||||
case BLE_GAP_EVT_DISCONNECTED:
|
||||
on_disconnected(p_db_discovery, &(p_ble_evt->evt.gap_evt));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif // NRF_MODULE_ENABLED(BLE_DB_DISCOVERY)
|
||||
|
|
@ -1,216 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**@file
|
||||
*
|
||||
* @defgroup ble_db_discovery Database Discovery
|
||||
* @{
|
||||
* @ingroup ble_sdk_lib
|
||||
* @brief Database discovery module.
|
||||
*
|
||||
* @details This module contains the APIs and types exposed by the DB Discovery module. These APIs
|
||||
* and types can be used by the application to perform discovery of a service and its
|
||||
* characteristics at the peer server. This module can also be used to discover the
|
||||
* desired services in multiple remote devices.
|
||||
*
|
||||
* @warning The maximum number of characteristics per service that can be discovered by this module
|
||||
* is determined by the number of characteristics in the service structure defined in
|
||||
* db_disc_config.h. If the peer has more than the supported number of characteristics, then
|
||||
* the first found will be discovered and any further characteristics will be ignored. Only the
|
||||
* following descriptors will be searched for at the peer: Client Characteristic Configuration,
|
||||
* Characteristic Extended Properties, Characteristic User Description, and Report Reference.
|
||||
*
|
||||
* @note Presently only one instance of a Primary Service can be discovered by this module. If
|
||||
* there are multiple instances of the service at the peer, only the first instance
|
||||
* of it at the peer is fetched and returned to the application.
|
||||
*
|
||||
* @note The application must propagate BLE stack events to this module by calling
|
||||
* ble_db_discovery_on_ble_evt().
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BLE_DB_DISCOVERY_H__
|
||||
#define BLE_DB_DISCOVERY_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "nrf_error.h"
|
||||
#include "headers/nrf_ble.h"
|
||||
#include "headers/nrf_ble_gattc.h"
|
||||
#include "ble_srv_common.h"
|
||||
#include "ble_gatt_db.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define BLE_DB_DISCOVERY_MAX_SRV 6 /**< Maximum number of services supported by this module. This also indicates the maximum number of users allowed to be registered to this module. (one user per service). */
|
||||
|
||||
|
||||
/**@brief Type of the DB Discovery event.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BLE_DB_DISCOVERY_COMPLETE, /**< Event indicating that the GATT Database discovery is complete. */
|
||||
BLE_DB_DISCOVERY_ERROR, /**< Event indicating that an internal error has occurred in the DB Discovery module. This could typically be because of the SoftDevice API returning an error code during the DB discover.*/
|
||||
BLE_DB_DISCOVERY_SRV_NOT_FOUND, /**< Event indicating that the service was not found at the peer.*/
|
||||
BLE_DB_DISCOVERY_AVAILABLE /**< Event indicating that the DB discovery module is available.*/
|
||||
} ble_db_discovery_evt_type_t;
|
||||
|
||||
|
||||
|
||||
/**@brief Structure for holding the information related to the GATT database at the server.
|
||||
*
|
||||
* @details This module identifies a remote database. Use one instance of this structure per
|
||||
* connection.
|
||||
*
|
||||
* @warning This structure must be zero-initialized.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ble_gatt_db_srv_t services[BLE_DB_DISCOVERY_MAX_SRV]; /**< Information related to the current service being discovered. This is intended for internal use during service discovery.*/
|
||||
uint8_t srv_count; /**< Number of services at the peers GATT database.*/
|
||||
uint8_t curr_char_ind; /**< Index of the current characteristic being discovered. This is intended for internal use during service discovery.*/
|
||||
uint8_t curr_srv_ind; /**< Index of the current service being discovered. This is intended for internal use during service discovery.*/
|
||||
bool discovery_in_progress; /**< Variable to indicate if there is a service discovery in progress. */
|
||||
uint8_t discoveries_count; /**< Number of service discoveries made, both successful and unsuccessful. */
|
||||
uint16_t conn_handle; /**< Connection handle on which the discovery is started*/
|
||||
} ble_db_discovery_t;
|
||||
|
||||
|
||||
/**@brief Structure containing the event from the DB discovery module to the application.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ble_db_discovery_evt_type_t evt_type; /**< Type of event. */
|
||||
uint16_t conn_handle; /**< Handle of the connection for which this event has occurred. */
|
||||
union
|
||||
{
|
||||
ble_gatt_db_srv_t discovered_db; /**< Structure containing the information about the GATT Database at the server. This will be filled when the event type is @ref BLE_DB_DISCOVERY_COMPLETE.*/
|
||||
uint32_t err_code; /**< nRF Error code indicating the type of error which occurred in the DB Discovery module. This will be filled when the event type is @ref BLE_DB_DISCOVERY_ERROR. */
|
||||
} params;
|
||||
} ble_db_discovery_evt_t;
|
||||
|
||||
|
||||
/**@brief DB Discovery event handler type. */
|
||||
typedef void (* ble_db_discovery_evt_handler_t)(ble_db_discovery_evt_t * p_evt);
|
||||
|
||||
|
||||
/**@brief Function for initializing the DB Discovery module.
|
||||
*
|
||||
* @param[in] evt_handler Event handler to be called by the DB discovery module when any event
|
||||
* related to discovery of the registered service occurs.
|
||||
*
|
||||
* @retval NRF_SUCCESS On successful initialization.
|
||||
* @retval NRF_ERROR_NULL If the handler was NULL.
|
||||
*/
|
||||
uint32_t ble_db_discovery_init(ble_db_discovery_evt_handler_t evt_handler);
|
||||
|
||||
|
||||
/**@brief Function for closing the DB Discovery module.
|
||||
*
|
||||
* @details This function will clear up any internal variables and states maintained by the
|
||||
* module. To re-use the module after calling this function, the function @ref
|
||||
* ble_db_discovery_init must be called again.
|
||||
*
|
||||
* @retval NRF_SUCCESS Operation success.
|
||||
*/
|
||||
uint32_t ble_db_discovery_close(void);
|
||||
|
||||
|
||||
/**@brief Function for registering with the DB Discovery module.
|
||||
*
|
||||
* @details The application can use this function to inform which service it is interested in
|
||||
* discovering at the server.
|
||||
*
|
||||
* @param[in] p_uuid Pointer to the UUID of the service to be discovered at the server.
|
||||
*
|
||||
* @note The total number of services that can be discovered by this module is @ref
|
||||
* BLE_DB_DISCOVERY_MAX_SRV. This effectively means that the maximum number of
|
||||
* registrations possible is equal to the @ref BLE_DB_DISCOVERY_MAX_SRV.
|
||||
*
|
||||
* @retval NRF_SUCCESS Operation success.
|
||||
* @retval NRF_ERROR_NULL When a NULL pointer is passed as input.
|
||||
* @retval NRF_ERROR_INVALID_STATE If this function is called without calling the
|
||||
* @ref ble_db_discovery_init.
|
||||
* @retval NRF_ERROR_NO_MEM The maximum number of registrations allowed by this module
|
||||
* has been reached.
|
||||
*/
|
||||
uint32_t ble_db_discovery_evt_register(const ble_uuid_t * const p_uuid);
|
||||
|
||||
|
||||
/**@brief Function for starting the discovery of the GATT database at the server.
|
||||
*
|
||||
* @warning p_db_discovery structure must be zero-initialized.
|
||||
*
|
||||
* @param[out] p_db_discovery Pointer to the DB Discovery structure.
|
||||
* @param[in] conn_handle The handle of the connection for which the discovery should be
|
||||
* started.
|
||||
*
|
||||
* @retval NRF_SUCCESS Operation success.
|
||||
* @retval NRF_ERROR_NULL When a NULL pointer is passed as input.
|
||||
* @retval NRF_ERROR_INVALID_STATE If this function is called without calling the
|
||||
* @ref ble_db_discovery_init, or without calling
|
||||
* @ref ble_db_discovery_evt_register.
|
||||
* @retval NRF_ERROR_BUSY If a discovery is already in progress for the current
|
||||
* connection.
|
||||
*
|
||||
* @return This API propagates the error code returned by the
|
||||
* SoftDevice API @ref sd_ble_gattc_primary_services_discover.
|
||||
*/
|
||||
uint32_t ble_db_discovery_start(ble_db_discovery_t * const p_db_discovery,
|
||||
uint16_t conn_handle);
|
||||
|
||||
|
||||
/**@brief Function for handling the Application's BLE Stack events.
|
||||
*
|
||||
* @param[in,out] p_db_discovery Pointer to the DB Discovery structure.
|
||||
* @param[in] p_ble_evt Pointer to the BLE event received.
|
||||
*/
|
||||
void ble_db_discovery_on_ble_evt(ble_db_discovery_t * const p_db_discovery,
|
||||
const ble_evt_t * const p_ble_evt);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // BLE_DB_DISCOVERY_H__
|
||||
|
||||
/** @} */
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ble_debug_assert_handler.h"
|
||||
#include <string.h>
|
||||
#include "nrf.h"
|
||||
#include "ble_error_log.h"
|
||||
#include "nordic_common.h"
|
||||
|
||||
#define MAX_LENGTH_FILENAME 128 /**< Max length of filename to copy for the debug error handlier. */
|
||||
|
||||
|
||||
// WARNING - DO NOT USE THIS FUNCTION IN END PRODUCT. - WARNING
|
||||
// WARNING - FOR DEBUG PURPOSES ONLY. - WARNING
|
||||
void ble_debug_assert_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name)
|
||||
{
|
||||
// Copying parameters to static variables because parameters may not be accessible in debugger.
|
||||
static volatile uint8_t s_file_name[MAX_LENGTH_FILENAME];
|
||||
static volatile uint16_t s_line_num;
|
||||
static volatile uint32_t s_error_code;
|
||||
|
||||
strncpy((char *)s_file_name, (const char *)p_file_name, MAX_LENGTH_FILENAME - 1);
|
||||
s_file_name[MAX_LENGTH_FILENAME - 1] = '\0';
|
||||
s_line_num = line_num;
|
||||
s_error_code = error_code;
|
||||
UNUSED_VARIABLE(s_file_name);
|
||||
UNUSED_VARIABLE(s_line_num);
|
||||
UNUSED_VARIABLE(s_error_code);
|
||||
|
||||
// WARNING: The PRIMASK register is set to disable ALL interrups during writing the error log.
|
||||
//
|
||||
// Do not use __disable_irq() in normal operation.
|
||||
__disable_irq();
|
||||
|
||||
// This function will write error code, filename, and line number to the flash.
|
||||
// In addition, the Cortex-M0 stack memory will also be written to the flash.
|
||||
//(void) ble_error_log_write(error_code, p_file_name, line_num);
|
||||
|
||||
// For debug purposes, this function never returns.
|
||||
// Attach a debugger for tracing the error cause.
|
||||
for (;;)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @file
|
||||
*
|
||||
* @defgroup ble_debug_assert_handler Assert handler for debug purposes
|
||||
* @{
|
||||
* @ingroup ble_sdk_lib
|
||||
* @brief Module for handling of assert during application development when debugging.
|
||||
*
|
||||
* @details This module may be used during development of an application to facilitate debugging.
|
||||
* It contains a function to write file name, line number and the Stack Memory to flash.
|
||||
* This module is ONLY for debugging purposes and must never be used in final product.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BLE_DEBUG_ASSERT_HANDLER_H__
|
||||
#define BLE_DEBUG_ASSERT_HANDLER_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**@brief Function for handling the Debug assert, which can be called from an error handler.
|
||||
* To be used only for debugging purposes.
|
||||
*
|
||||
*@details This code will copy the filename and line number into local variables for them to always
|
||||
* be accessible in Keil debugger. The function will also write the ARM Cortex-M0 stack
|
||||
* memory into flash where it can be retrieved and manually un-winded in order to
|
||||
* back-trace the location where the error ocured.<br>
|
||||
* @warning <b>ALL INTERRUPTS WILL BE DISABLED.</b>
|
||||
*
|
||||
* @note This function will never return but loop forever for debug purposes.
|
||||
*
|
||||
* @param[in] error_code Error code supplied to the handler.
|
||||
* @param[in] line_num Line number where the original handler is called.
|
||||
* @param[in] p_file_name Pointer to the file name.
|
||||
*/
|
||||
void ble_debug_assert_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BLE_DEBUG_ASSERT_HANDLER_H__ */
|
||||
|
||||
|
||||
/** @} */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue