|
| 1 | +/******************************************************************************* |
| 2 | +* \file cy_bt_cordio_cfg.cpp |
| 3 | +* \version 1.0 |
| 4 | +* |
| 5 | +* |
| 6 | +* Low Power Assist BT Pin configuration implementation. |
| 7 | +* |
| 8 | +******************************************************************************** |
| 9 | +* \copyright |
| 10 | +* Copyright 2019 Cypress Semiconductor Corporation |
| 11 | +* SPDX-License-Identifier: Apache-2.0 |
| 12 | +* |
| 13 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
| 14 | +* you may not use this file except in compliance with the License. |
| 15 | +* You may obtain a copy of the License at |
| 16 | +* |
| 17 | +* http://www.apache.org/licenses/LICENSE-2.0 |
| 18 | +* |
| 19 | +* Unless required by applicable law or agreed to in writing, software |
| 20 | +* distributed under the License is distributed on an "AS IS" BASIS, |
| 21 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 22 | +* See the License for the specific language governing permissions and |
| 23 | +* limitations under the License. |
| 24 | +*******************************************************************************/ |
| 25 | + |
| 26 | +#include <stdio.h> |
| 27 | +#include "ble/driver/CordioHCIDriver.h" |
| 28 | +#include "hci_api.h" |
| 29 | +#include "hci_cmd.h" |
| 30 | +#include "hci_core.h" |
| 31 | +#include "bstream.h" |
| 32 | +#include "assert.h" |
| 33 | +#include <stdbool.h> |
| 34 | +#include "hci_mbed_os_adaptation.h" |
| 35 | +#include "CyH4TransportDriver.h" |
| 36 | + |
| 37 | +#define cyhal_gpio_to_rtos(x) (x) |
| 38 | +#define CYCFG_BT_LP_ENABLED (1) |
| 39 | +#define CYCFG_BT_HOST_WAKE_IRQ_EVENT WAKE_EVENT_ACTIVE_LOW |
| 40 | +#define CYCFG_BT_DEV_WAKE_POLARITY WAKE_EVENT_ACTIVE_LOW |
| 41 | + |
| 42 | +/******************************************************************************* |
| 43 | +* Function Name: ble_cordio_get_h4_transport_driver |
| 44 | +******************************************************************************** |
| 45 | +* |
| 46 | +* Strong implementation of function which calls CyH4TransportDriver constructor and return it |
| 47 | +* |
| 48 | +* \param none |
| 49 | +* |
| 50 | +* \return |
| 51 | +* Returns the transport driver object |
| 52 | +*******************************************************************************/ |
| 53 | +ble::vendor::cypress_ble::CyH4TransportDriver& ble_cordio_get_h4_transport_driver() |
| 54 | +{ |
| 55 | +#if (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER) |
| 56 | + |
| 57 | +#if (defined(CYCFG_BT_LP_ENABLED)) |
| 58 | + if (CYCFG_BT_LP_ENABLED) { |
| 59 | + static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver( |
| 60 | + /* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX), |
| 61 | + /* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX), |
| 62 | + /* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS), |
| 63 | + /* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS), |
| 64 | + /* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER), |
| 65 | + DEF_BT_BAUD_RATE, |
| 66 | + cyhal_gpio_to_rtos(CYBSP_BT_HOST_WAKE), |
| 67 | + cyhal_gpio_to_rtos(CYBSP_BT_DEVICE_WAKE), |
| 68 | + CYCFG_BT_HOST_WAKE_IRQ_EVENT, |
| 69 | + CYCFG_BT_DEV_WAKE_POLARITY |
| 70 | + ); |
| 71 | + return s_transport_driver; |
| 72 | + } else { /* CYCFG_BT_LP_ENABLED */ |
| 73 | + static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver( |
| 74 | + /* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX), |
| 75 | + /* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX), |
| 76 | + /* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS), |
| 77 | + /* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS), |
| 78 | + /* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER), |
| 79 | + DEF_BT_BAUD_RATE); |
| 80 | + return s_transport_driver; |
| 81 | + } |
| 82 | +#else /* (defined(CYCFG_BT_LP_ENABLED)) */ |
| 83 | + static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver( |
| 84 | + /* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX), |
| 85 | + /* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX), |
| 86 | + /* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS), |
| 87 | + /* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS), |
| 88 | + /* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER), |
| 89 | + DEF_BT_BAUD_RATE), |
| 90 | + cyhal_gpio_to_rtos(CYBSP_BT_HOST_WAKE), cyhal_gpio_to_rtos(CYBSP_BT_DEVICE_WAKE) |
| 91 | + ); |
| 92 | + return s_transport_driver; |
| 93 | +#endif /* (defined(CYCFG_BT_LP_ENABLED)) */ |
| 94 | + |
| 95 | +#else /* (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER) */ |
| 96 | + static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver( |
| 97 | + /* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX), |
| 98 | + /* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX), |
| 99 | + /* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS), |
| 100 | + /* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS), |
| 101 | + /* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER), |
| 102 | + DEF_BT_BAUD_RATE); |
| 103 | + return s_transport_driver; |
| 104 | +#endif /* (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER) */ |
| 105 | +} |
0 commit comments