The drivers/bluetooth/controller path adds a native BLE Link Layer (controller and HCI) to the Bluetooth subsystem. This first implementation adds support for the nRF5x series of devices from Nordic Semiconductor. The hal/ folder inside the controller contains all IC-specific code to interface with the radio and baseband. Jira: ZEP-702 Origin: Original Change-Id: I4ed61d5f67af6b4735d746a38a5b55f054521075 Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no> Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
234 lines
5.5 KiB
C
234 lines
5.5 KiB
C
/*
|
|
* Copyright (c) 2016 Nordic Semiconductor ASA
|
|
* Copyright (c) 2016 Vinayak Kariappa Chettimada
|
|
*
|
|
* 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 _DEBUG_H_
|
|
#define _DEBUG_H_
|
|
|
|
#ifdef __GNUC__
|
|
#define ASSERT(x) do { \
|
|
if (!(x)) { \
|
|
__asm__ volatile (".inst 0xde00\n"); \
|
|
} \
|
|
} while (0)
|
|
#else
|
|
static __asm void _udf(void)
|
|
{
|
|
UND #0;
|
|
}
|
|
|
|
#define ASSERT(x) do { \
|
|
if (!(x)) { \
|
|
_udf(); \
|
|
} \
|
|
} while (0)
|
|
#endif
|
|
|
|
#if (DEBUG == 1)
|
|
/*
|
|
* P2 is outgoing debug pins.
|
|
* Debug pins are initialized to low.
|
|
*/
|
|
#define DEBUG_INIT() do { \
|
|
NRF_GPIO->DIRSET = 0x03FF0000; \
|
|
NRF_GPIO->OUTCLR = 0x03FF0000; } \
|
|
while (0)
|
|
|
|
#define DEBUG_CPU_SLEEP(flag) do { \
|
|
if (flag) { \
|
|
NRF_GPIO->OUTSET = 0x00010000; \
|
|
NRF_GPIO->OUTCLR = 0x00010000; } \
|
|
else { \
|
|
NRF_GPIO->OUTCLR = 0x00010000; \
|
|
NRF_GPIO->OUTSET = 0x00010000; } \
|
|
} while (0)
|
|
|
|
#define DEBUG_TICKER_ISR(flag) do { \
|
|
if (flag) { \
|
|
NRF_GPIO->OUTCLR = 0x00020000; \
|
|
NRF_GPIO->OUTSET = 0x00020000; } \
|
|
else { \
|
|
NRF_GPIO->OUTSET = 0x00020000; \
|
|
NRF_GPIO->OUTCLR = 0x00020000; } \
|
|
} while (0)
|
|
|
|
#define DEBUG_TICKER_TASK(flag) do { \
|
|
if (flag) { \
|
|
NRF_GPIO->OUTCLR = 0x00020000; \
|
|
NRF_GPIO->OUTSET = 0x00020000; } \
|
|
else { \
|
|
NRF_GPIO->OUTSET = 0x00020000; \
|
|
NRF_GPIO->OUTCLR = 0x00020000; } \
|
|
} while (0)
|
|
|
|
#define DEBUG_TICKER_JOB(flag) do { \
|
|
if (flag) { \
|
|
NRF_GPIO->OUTCLR = 0x00040000; \
|
|
NRF_GPIO->OUTSET = 0x00040000; } \
|
|
else { \
|
|
NRF_GPIO->OUTSET = 0x00040000; \
|
|
NRF_GPIO->OUTCLR = 0x00040000; } \
|
|
} while (0)
|
|
|
|
#define DEBUG_RADIO_ISR(flag) do { \
|
|
if (flag) { \
|
|
NRF_GPIO->OUTCLR = 0x00800000; \
|
|
NRF_GPIO->OUTSET = 0x00800000; } \
|
|
else { \
|
|
NRF_GPIO->OUTSET = 0x00800000; \
|
|
NRF_GPIO->OUTCLR = 0x00800000; } \
|
|
} while (0)
|
|
|
|
#define DEBUG_RADIO_XTAL(flag) do { \
|
|
if (flag) { \
|
|
NRF_GPIO->OUTCLR = 0x01000000; \
|
|
NRF_GPIO->OUTSET = 0x01000000; } \
|
|
else { \
|
|
NRF_GPIO->OUTSET = 0x01000000; \
|
|
NRF_GPIO->OUTCLR = 0x01000000; } \
|
|
} while (0)
|
|
|
|
#define DEBUG_RADIO_ACTIVE(flag) do { \
|
|
if (flag) { \
|
|
NRF_GPIO->OUTCLR = 0x02000000; \
|
|
NRF_GPIO->OUTSET = 0x02000000; } \
|
|
else { \
|
|
NRF_GPIO->OUTSET = 0x02000000; \
|
|
NRF_GPIO->OUTCLR = 0x02000000; } \
|
|
} while (0)
|
|
|
|
#define DEBUG_RADIO_CLOSE(flag) do { \
|
|
if (flag) { \
|
|
NRF_GPIO->OUTCLR = 0x00000000; \
|
|
NRF_GPIO->OUTSET = 0x00000000; } \
|
|
else { \
|
|
NRF_GPIO->OUTCLR = 0x00780000; } \
|
|
} while (0)
|
|
|
|
#define DEBUG_RADIO_PREPARE_A(flag) do { \
|
|
if (flag) { \
|
|
NRF_GPIO->OUTCLR = 0x00080000; \
|
|
NRF_GPIO->OUTSET = 0x00080000; } \
|
|
else { \
|
|
NRF_GPIO->OUTCLR = 0x00080000; \
|
|
NRF_GPIO->OUTSET = 0x00080000; } \
|
|
} while (0)
|
|
|
|
#define DEBUG_RADIO_START_A(flag) do { \
|
|
if (flag) { \
|
|
NRF_GPIO->OUTCLR = 0x00080000; \
|
|
NRF_GPIO->OUTSET = 0x00080000; } \
|
|
else { \
|
|
NRF_GPIO->OUTCLR = 0x00080000; \
|
|
NRF_GPIO->OUTSET = 0x00080000; } \
|
|
} while (0)
|
|
|
|
#define DEBUG_RADIO_PREPARE_S(flag) do { \
|
|
if (flag) { \
|
|
NRF_GPIO->OUTCLR = 0x00100000; \
|
|
NRF_GPIO->OUTSET = 0x00100000; } \
|
|
else { \
|
|
NRF_GPIO->OUTCLR = 0x00100000; \
|
|
NRF_GPIO->OUTSET = 0x00100000; } \
|
|
} while (0)
|
|
|
|
#define DEBUG_RADIO_START_S(flag) do { \
|
|
if (flag) { \
|
|
NRF_GPIO->OUTCLR = 0x00100000; \
|
|
NRF_GPIO->OUTSET = 0x00100000; } \
|
|
else { \
|
|
NRF_GPIO->OUTCLR = 0x00100000; \
|
|
NRF_GPIO->OUTSET = 0x00100000; } \
|
|
} while (0)
|
|
|
|
#define DEBUG_RADIO_PREPARE_O(flag) do { \
|
|
if (flag) { \
|
|
NRF_GPIO->OUTCLR = 0x00200000; \
|
|
NRF_GPIO->OUTSET = 0x00200000; } \
|
|
else { \
|
|
NRF_GPIO->OUTCLR = 0x00200000; \
|
|
NRF_GPIO->OUTSET = 0x00200000; } \
|
|
} while (0)
|
|
|
|
#define DEBUG_RADIO_START_O(flag) do { \
|
|
if (flag) { \
|
|
NRF_GPIO->OUTCLR = 0x00200000; \
|
|
NRF_GPIO->OUTSET = 0x00200000; } \
|
|
else { \
|
|
NRF_GPIO->OUTCLR = 0x00200000; \
|
|
NRF_GPIO->OUTSET = 0x00200000; } \
|
|
} while (0)
|
|
|
|
#define DEBUG_RADIO_PREPARE_M(flag) do { \
|
|
if (flag) { \
|
|
NRF_GPIO->OUTCLR = 0x00400000; \
|
|
NRF_GPIO->OUTSET = 0x00400000; } \
|
|
else { \
|
|
NRF_GPIO->OUTCLR = 0x00400000; \
|
|
NRF_GPIO->OUTSET = 0x00400000; } \
|
|
} while (0)
|
|
|
|
#define DEBUG_RADIO_START_M(flag) do { \
|
|
if (flag) { \
|
|
NRF_GPIO->OUTCLR = 0x00400000; \
|
|
NRF_GPIO->OUTSET = 0x00400000; } \
|
|
else { \
|
|
NRF_GPIO->OUTCLR = 0x00400000; \
|
|
NRF_GPIO->OUTSET = 0x00400000; } \
|
|
} while (0)
|
|
|
|
#else
|
|
|
|
#define DEBUG_INIT()
|
|
|
|
#define DEBUG_CPU_SLEEP(flag)
|
|
|
|
#define DEBUG_TICKER_ISR(flag)
|
|
|
|
#define DEBUG_TICKER_TASK(flag)
|
|
|
|
#define DEBUG_TICKER_JOB(flag)
|
|
|
|
#define DEBUG_RADIO_ISR(flag)
|
|
|
|
#define DEBUG_RADIO_HCTO(flag)
|
|
|
|
#define DEBUG_RADIO_XTAL(flag)
|
|
|
|
#define DEBUG_RADIO_ACTIVE(flag)
|
|
|
|
#define DEBUG_RADIO_CLOSE(flag)
|
|
|
|
#define DEBUG_RADIO_PREPARE_A(flag)
|
|
|
|
#define DEBUG_RADIO_START_A(flag)
|
|
|
|
#define DEBUG_RADIO_PREPARE_S(flag)
|
|
|
|
#define DEBUG_RADIO_START_S(flag)
|
|
|
|
#define DEBUG_RADIO_PREPARE_O(flag)
|
|
|
|
#define DEBUG_RADIO_START_O(flag)
|
|
|
|
#define DEBUG_RADIO_PREPARE_M(flag)
|
|
|
|
#define DEBUG_RADIO_START_M(flag)
|
|
|
|
#endif /* DEBUG */
|
|
|
|
#endif /* _DEBUG_H_ */
|