Skip to content

Commit 854f362

Browse files
nimble/plna: Add driver for SKY66112
This adds support for SKY66112 front-end module (PA/LNA). CTX and CRX signals are controller by phy and shall be configured using LL syscfg settings for PA/LNA. Other signals can be configured via GPIO or simply driven externally to spare GPIO pins. It's possible to use PA or LNA only, in such case CPS signal has to be driven via GPIO.
1 parent 9ef7145 commit 854f362

File tree

3 files changed

+214
-0
lines changed

3 files changed

+214
-0
lines changed

nimble/drivers/plna/sky66112/pkg.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
pkg.name: nimble/drivers/plna/sky66112
21+
pkg.description: Driver for SKY66112 front-end module
22+
pkg.author: "Apache Mynewt <[email protected]>"
23+
pkg.homepage: "https://mynewt.apache.org/"
24+
pkg.apis:
25+
- ble_ll_pa
26+
- ble_ll_lna
27+
pkg.deps:
28+
- nimble/controller
29+
30+
pkg.init:
31+
sky66112_init: 999
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#include <assert.h>
21+
#include <stdint.h>
22+
#include "syscfg/syscfg.h"
23+
#include "hal/hal_gpio.h"
24+
#include "controller/ble_ll_plna.h"
25+
26+
#define NO_BYPASS \
27+
((MYNEWT_VAL(SKY66112_TX_BYPASS) >= 0) && \
28+
(MYNEWT_VAL(SKY66112_RX_BYPASS) >= 0))
29+
30+
static void
31+
sky66112_bypass(uint8_t enabled)
32+
{
33+
if (NO_BYPASS) {
34+
return;
35+
}
36+
37+
hal_gpio_write(MYNEWT_VAL(SKY66112_PIN_CPS), enabled);
38+
}
39+
40+
void
41+
ble_ll_plna_pa_init(void)
42+
{
43+
/* Nothing to do here */
44+
}
45+
46+
void
47+
ble_ll_plna_pa_enable(void)
48+
{
49+
if (!MYNEWT_VAL(SKY66112_TX_BYPASS)) {
50+
sky66112_bypass(0);
51+
}
52+
}
53+
54+
void
55+
ble_ll_plna_pa_disable(void)
56+
{
57+
if (!MYNEWT_VAL(SKY66112_TX_BYPASS)) {
58+
sky66112_bypass(1);
59+
}
60+
}
61+
62+
void
63+
ble_ll_plna_lna_init(void)
64+
{
65+
/* Nothing to do here */
66+
}
67+
68+
void
69+
ble_ll_plna_lna_enable(void)
70+
{
71+
if (!MYNEWT_VAL(SKY66112_RX_BYPASS)) {
72+
sky66112_bypass(0);
73+
}
74+
}
75+
76+
void
77+
ble_ll_plna_lna_disable(void)
78+
{
79+
if (!MYNEWT_VAL(SKY66112_RX_BYPASS)) {
80+
sky66112_bypass(1);
81+
}
82+
}
83+
84+
void
85+
sky66112_init(void)
86+
{
87+
int pin;
88+
89+
/* Use CRX and CTX to enable sleep mode */
90+
pin = MYNEWT_VAL(SKY66112_PIN_CSD);
91+
if (pin >= 0) {
92+
hal_gpio_init_out(pin, 1);
93+
}
94+
95+
pin = MYNEWT_VAL(SKY66112_PIN_CPS);
96+
if (NO_BYPASS) {
97+
/* Disable bypass */
98+
if (pin >= 0) {
99+
hal_gpio_init_out(pin, 0);
100+
}
101+
} else {
102+
/* Enable bypass, we'll disable it when needed */
103+
assert(pin >= 0);
104+
hal_gpio_init_out(pin, 1);
105+
}
106+
107+
pin = MYNEWT_VAL(SKY66112_PIN_CHL);
108+
if (pin >= 0) {
109+
hal_gpio_init_out(pin, MYNEWT_VAL(SKY66112_TX_HP_MODE));
110+
}
111+
112+
/* Select ANT1 */
113+
pin = MYNEWT_VAL(SKY66112_PIN_SEL);
114+
if (pin >= 0) {
115+
hal_gpio_init_out(pin, 0);
116+
}
117+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
19+
syscfg.defs:
20+
SKY66112_PIN_CSD:
21+
description: >
22+
GPIO pin number to control CSD signal.
23+
When set to '-1', pin state will not be changed and it should be
24+
driven externally.
25+
value: -1
26+
SKY66112_PIN_CPS:
27+
description: >
28+
GPIO pin number to control CPS signal.
29+
When set to '-1', pin state will not be changed and it should be
30+
driven externally.
31+
value: -1
32+
SKY66112_PIN_CHL:
33+
description: >
34+
GPIO pin number to control CHL signal.
35+
When set to '-1', pin state will not be changed and it should be
36+
driven externally.
37+
value: -1
38+
SKY66112_PIN_SEL:
39+
description: >
40+
GPIO pin number to control SEL signal.
41+
When set to '-1', pin state will not be changed and it should be
42+
driven externally.
43+
value: -1
44+
SKY66112_TX_HP_MODE:
45+
description: >
46+
Enables high-power mode for TX.
47+
Only valid if CHL signal is controller by driver.
48+
value: 0
49+
SKY66112_TX_BYPASS:
50+
description: >
51+
Enables bypass for TX which effectively disables operation as PA.
52+
Only valid if CPS signal is controller by driver.
53+
value: 0
54+
SKY66112_RX_BYPASS:
55+
description: >
56+
Enables bypass for RX which effectively disables operation as PA.
57+
Only valid if CPS signal is controller by driver.
58+
value: 0
59+
60+
syscfg.vals.!BLE_LL_PA:
61+
# Enable TX bypass by default if PA is disabled
62+
SKY66112_TX_BYPASS: 1
63+
64+
syscfg.vals.!BLE_LL_LNA:
65+
# Enable RX bypass by default if LNA is disabled
66+
SKY66112_RX_BYPASS: 1

0 commit comments

Comments
 (0)