Skip to content

Commit 11abc67

Browse files
paul-szczepanek-arm0xc0170
authored andcommitted
cordio LL adaptation and config
1 parent 1e8010d commit 11abc67

File tree

5 files changed

+89
-16
lines changed

5 files changed

+89
-16
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "cordio-controller",
3+
"config": {
4+
"uart-hci": {
5+
"help": "Does the board have a UART HCI. Valid values are 0 (need to provide your own HCI driver) and 1 (HCI trhough UART).",
6+
"value": 0,
7+
"macro_name": "CHCI_TR_UART"
8+
},
9+
"handle-vendor-specific-hci-commands": {
10+
"help": "Handle VS HCI commands. Valid values are 0 (ignore) and 1 (handle).",
11+
"value": 0,
12+
"macro_name": "LHCI_ENABLE_VS"
13+
}
14+
15+
}
16+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* Copyright (c) 2009-2019 Arm Limited
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "mbed.h"
18+
#include "fake_lhci_drv.h"
19+
#include "chci_tr.h"
20+
21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
25+
uint16_t FakeChciTrRead(uint8_t prot, uint8_t type, uint16_t len, uint8_t *pData) {
26+
chciTrRecv(prot, type, pData);
27+
return len;
28+
}
29+
30+
#ifdef __cplusplus
31+
};
32+
#endif
33+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* Copyright (c) 2009-2019 Arm Limited
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef FAKE_LHCI_DRV_H_
18+
#define FAKE_LHCI_DRV_H_
19+
20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
23+
24+
uint16_t FakeChciTrRead(uint8_t prot, uint8_t type, uint16_t len, uint8_t *pData);
25+
26+
uint16_t FakeChciTrWrite(uint8_t prot, uint8_t type, uint16_t len, uint8_t *pData);
27+
28+
#ifdef __cplusplus
29+
};
30+
#endif
31+
32+
#endif /* FAKE_LHCI_DRV_H_ */

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCIDriver.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@
2828
// Cordio Includes
2929
#include "ll_init_api.h"
3030
#include "ll_defs.h"
31-
#include "chci_drv.h"
31+
#include "fake_lhci_drv.h"
32+
#include "pal_bb.h"
3233
#include "lhci_api.h"
33-
#include "platform_api.h"
34-
#include "platform_ble_api.h"
3534
#include "wsf_assert.h"
3635
#include "wsf_buf.h"
3736
#include "wsf_timer.h"
@@ -215,6 +214,8 @@ ble::vendor::cordio::buf_pool_desc_t NRFCordioHCIDriver::get_buffer_pool_descrip
215214
return buf_pool_desc_t(buffer, pool_desc);
216215
}
217216

217+
void PlatformLoadBdAddress(uint8_t *pDevAddr);
218+
218219
void NRFCordioHCIDriver::do_initialize()
219220
{
220221
if(_is_init) {
@@ -280,7 +281,7 @@ void NRFCordioHCIDriver::do_initialize()
280281
// 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)
281282
// however that method will still continue which will lead to undefined behaviour
282283
// 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
283-
uint32_t mem_used = LlInitControllerExtInit(&ll_init_cfg);
284+
uint32_t mem_used = LlInitControllerInit(&ll_init_cfg);
284285
if( mem_used < CORDIO_LL_MEMORY_FOOTPRINT )
285286
{
286287
// Sub-optimal, give warning
@@ -338,12 +339,6 @@ ble::vendor::cordio::CordioHCIDriver& ble_cordio_get_hci_driver() {
338339
return hci_driver;
339340
}
340341

341-
// Do not handle any vendor specific command
342-
extern "C" bool_t lhciCommonVsStdDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf)
343-
{
344-
return false;
345-
}
346-
347342
// Nordic implementation
348343
void PlatformLoadBdAddress(uint8_t *pDevAddr)
349344
{

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCITransportDriver.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
#include "wsf_math.h"
2424
#include "chci_api.h"
2525
#include "chci_tr.h"
26-
#include "chci_tr_serial.h"
27-
#include "chci_drv.h"
26+
#include "fake_lhci_drv.h"
2827
#include "hci_defs.h"
2928
#include <string.h>
3029

@@ -47,9 +46,7 @@ void NRFCordioHCITransportDriver::terminate()
4746

4847
uint16_t NRFCordioHCITransportDriver::write(uint8_t type, uint16_t len, uint8_t *pData)
4948
{
50-
chciTrSerialRxIncoming(&type, 1);
51-
chciTrSerialRxIncoming(pData, len);
52-
return len;
49+
return FakeChciTrRead(CHCI_TR_PROT_BLE, type, len, pData);
5350
}
5451

5552
extern "C" void chciDrvInit(void)
@@ -58,7 +55,7 @@ extern "C" void chciDrvInit(void)
5855
}
5956

6057
// Callback from Cordio stack
61-
extern "C" uint16_t chciDrvWrite(uint8_t prot, uint8_t type, uint16_t len, uint8_t *pData)
58+
extern "C" uint16_t FakeChciTrWrite(uint8_t prot, uint8_t type, uint16_t len, uint8_t *pData)
6259
{
6360
uint8_t ctype = (type == CHCI_TR_TYPE_EVT) ? HCI_EVT_TYPE : HCI_ACL_TYPE;
6461
CordioHCITransportDriver::on_data_received(&ctype, 1);

0 commit comments

Comments
 (0)