cordio LL adaptation and config

pull/10666/head
paul-szczepanek-arm 2019-03-06 15:12:17 +00:00 committed by Martin Kojtal
parent 1e8010dd81
commit 11abc6704f
5 changed files with 89 additions and 16 deletions

View File

@ -0,0 +1,16 @@
{
"name": "cordio-controller",
"config": {
"uart-hci": {
"help": "Does the board have a UART HCI. Valid values are 0 (need to provide your own HCI driver) and 1 (HCI trhough UART).",
"value": 0,
"macro_name": "CHCI_TR_UART"
},
"handle-vendor-specific-hci-commands": {
"help": "Handle VS HCI commands. Valid values are 0 (ignore) and 1 (handle).",
"value": 0,
"macro_name": "LHCI_ENABLE_VS"
}
}
}

View File

@ -0,0 +1,33 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* 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.
*/
#include "mbed.h"
#include "fake_lhci_drv.h"
#include "chci_tr.h"
#ifdef __cplusplus
extern "C" {
#endif
uint16_t FakeChciTrRead(uint8_t prot, uint8_t type, uint16_t len, uint8_t *pData) {
chciTrRecv(prot, type, pData);
return len;
}
#ifdef __cplusplus
};
#endif

View File

@ -0,0 +1,32 @@
/* Copyright (c) 2009-2019 Arm Limited
* SPDX-License-Identifier: Apache-2.0
*
* 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 FAKE_LHCI_DRV_H_
#define FAKE_LHCI_DRV_H_
#ifdef __cplusplus
extern "C" {
#endif
uint16_t FakeChciTrRead(uint8_t prot, uint8_t type, uint16_t len, uint8_t *pData);
uint16_t FakeChciTrWrite(uint8_t prot, uint8_t type, uint16_t len, uint8_t *pData);
#ifdef __cplusplus
};
#endif
#endif /* FAKE_LHCI_DRV_H_ */

View File

@ -28,10 +28,9 @@
// Cordio Includes
#include "ll_init_api.h"
#include "ll_defs.h"
#include "chci_drv.h"
#include "fake_lhci_drv.h"
#include "pal_bb.h"
#include "lhci_api.h"
#include "platform_api.h"
#include "platform_ble_api.h"
#include "wsf_assert.h"
#include "wsf_buf.h"
#include "wsf_timer.h"
@ -215,6 +214,8 @@ ble::vendor::cordio::buf_pool_desc_t NRFCordioHCIDriver::get_buffer_pool_descrip
return buf_pool_desc_t(buffer, pool_desc);
}
void PlatformLoadBdAddress(uint8_t *pDevAddr);
void NRFCordioHCIDriver::do_initialize()
{
if(_is_init) {
@ -280,7 +281,7 @@ void NRFCordioHCIDriver::do_initialize()
// If a submodule does not have enough space to allocate its memory from buffer, it will still allocate its memory (and do a buffer overflow) and return 0 (as in 0 byte used)
// however that method will still continue which will lead to undefined behaviour
// So whenever a change of configuration is done, it's a good idea to set CORDIO_LL_MEMORY_FOOTPRINT to a high value and then reduce accordingly
uint32_t mem_used = LlInitControllerExtInit(&ll_init_cfg);
uint32_t mem_used = LlInitControllerInit(&ll_init_cfg);
if( mem_used < CORDIO_LL_MEMORY_FOOTPRINT )
{
// Sub-optimal, give warning
@ -338,12 +339,6 @@ ble::vendor::cordio::CordioHCIDriver& ble_cordio_get_hci_driver() {
return hci_driver;
}
// Do not handle any vendor specific command
extern "C" bool_t lhciCommonVsStdDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf)
{
return false;
}
// Nordic implementation
void PlatformLoadBdAddress(uint8_t *pDevAddr)
{

View File

@ -23,8 +23,7 @@
#include "wsf_math.h"
#include "chci_api.h"
#include "chci_tr.h"
#include "chci_tr_serial.h"
#include "chci_drv.h"
#include "fake_lhci_drv.h"
#include "hci_defs.h"
#include <string.h>
@ -47,9 +46,7 @@ void NRFCordioHCITransportDriver::terminate()
uint16_t NRFCordioHCITransportDriver::write(uint8_t type, uint16_t len, uint8_t *pData)
{
chciTrSerialRxIncoming(&type, 1);
chciTrSerialRxIncoming(pData, len);
return len;
return FakeChciTrRead(CHCI_TR_PROT_BLE, type, len, pData);
}
extern "C" void chciDrvInit(void)
@ -58,7 +55,7 @@ extern "C" void chciDrvInit(void)
}
// Callback from Cordio stack
extern "C" uint16_t chciDrvWrite(uint8_t prot, uint8_t type, uint16_t len, uint8_t *pData)
extern "C" uint16_t FakeChciTrWrite(uint8_t prot, uint8_t type, uint16_t len, uint8_t *pData)
{
uint8_t ctype = (type == CHCI_TR_TYPE_EVT) ? HCI_EVT_TYPE : HCI_ACL_TYPE;
CordioHCITransportDriver::on_data_received(&ctype, 1);