You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2017/05/18 08:51:17 UTC
[04/12] incubator-mynewt-core git commit: nimble/phy: Cleanup PCNF0
settings
nimble/phy: Cleanup PCNF0 settings
This patch makes PCNF0 settings explicit to make code easier to read:
- always set S1LEN (even though it is predefined to 0)
- set PLEN in ble_phy_mode_set for each case (do not make "implicit" set
to 8bits in ble_phy_init)
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/c91bd6cf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c91bd6cf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c91bd6cf
Branch: refs/heads/bluetooth5
Commit: c91bd6cf8a57bf67ab6bfd4c19365106af270545
Parents: 24131d5
Author: Andrzej Kaczmarek <an...@codecoup.pl>
Authored: Fri May 12 10:58:54 2017 +0200
Committer: Andrzej Kaczmarek <an...@codecoup.pl>
Committed: Wed May 17 11:56:17 2017 +0200
----------------------------------------------------------------------
hw/drivers/nimble/nrf52/src/ble_phy.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c91bd6cf/hw/drivers/nimble/nrf52/src/ble_phy.c
----------------------------------------------------------------------
diff --git a/hw/drivers/nimble/nrf52/src/ble_phy.c b/hw/drivers/nimble/nrf52/src/ble_phy.c
index a9d0150..0947975 100644
--- a/hw/drivers/nimble/nrf52/src/ble_phy.c
+++ b/hw/drivers/nimble/nrf52/src/ble_phy.c
@@ -50,9 +50,10 @@ extern uint32_t g_nrf_irk_list[];
* zero bit S1 field. The preamble is 8 bits long.
*/
#define NRF_LFLEN_BITS (8)
-#define NRF_S0_LEN (1)
-#define NRF_CI_LEN (2)
-#define NRF_TERM_LEN (3)
+#define NRF_S0LEN (1)
+#define NRF_S1LEN_BITS (0)
+#define NRF_CILEN_BITS (2)
+#define NRF_TERMLEN_BITS (3)
/* Maximum length of frames */
#define NRF_MAXLEN (255)
@@ -253,7 +254,8 @@ ble_phy_mode_set(int cur_phy_mode, int txtorx_phy_mode)
{
if (cur_phy_mode == BLE_PHY_MODE_1M) {
NRF_RADIO->MODE = RADIO_MODE_MODE_Ble_1Mbit;
- NRF_RADIO->PCNF0 = g_ble_phy_data.phy_pcnf0; /* Default is 8 bits */
+ NRF_RADIO->PCNF0 = g_ble_phy_data.phy_pcnf0 |
+ (RADIO_PCNF0_PLEN_8bit << RADIO_PCNF0_PLEN_Pos);
} else if (cur_phy_mode == BLE_PHY_MODE_2M) {
NRF_RADIO->MODE = RADIO_MODE_MODE_Ble_2Mbit;
NRF_RADIO->PCNF0 = g_ble_phy_data.phy_pcnf0 |
@@ -262,14 +264,14 @@ ble_phy_mode_set(int cur_phy_mode, int txtorx_phy_mode)
NRF_RADIO->MODE = RADIO_MODE_MODE_Ble_LR125Kbit;
NRF_RADIO->PCNF0 = g_ble_phy_data.phy_pcnf0 |
(RADIO_PCNF0_PLEN_LongRange << RADIO_PCNF0_PLEN_Pos) |
- (NRF_CI_LEN << RADIO_PCNF0_CILEN_Pos) |
- (NRF_TERM_LEN << RADIO_PCNF0_TERMLEN_Pos);
+ (NRF_CILEN_BITS << RADIO_PCNF0_CILEN_Pos) |
+ (NRF_TERMLEN_BITS << RADIO_PCNF0_TERMLEN_Pos);
} else if (cur_phy_mode == BLE_PHY_MODE_CODED_500KBPS) {
NRF_RADIO->MODE = RADIO_MODE_MODE_Ble_LR500Kbit;
NRF_RADIO->PCNF0 = g_ble_phy_data.phy_pcnf0 |
(RADIO_PCNF0_PLEN_LongRange << RADIO_PCNF0_PLEN_Pos) |
- (NRF_CI_LEN << RADIO_PCNF0_CILEN_Pos) |
- (NRF_TERM_LEN << RADIO_PCNF0_TERMLEN_Pos);
+ (NRF_CILEN_BITS << RADIO_PCNF0_CILEN_Pos) |
+ (NRF_TERMLEN_BITS << RADIO_PCNF0_TERMLEN_Pos);
} else {
assert(0);
}
@@ -968,8 +970,8 @@ ble_phy_init(void)
NRF_RADIO->MODE = RADIO_MODE_MODE_Ble_1Mbit;
g_ble_phy_data.phy_pcnf0 = (NRF_LFLEN_BITS << RADIO_PCNF0_LFLEN_Pos) |
RADIO_PCNF0_S1INCL_Msk |
- (NRF_S0_LEN << RADIO_PCNF0_S0LEN_Pos) |
- (RADIO_PCNF0_PLEN_8bit << RADIO_PCNF0_PLEN_Pos);
+ (NRF_S0LEN << RADIO_PCNF0_S0LEN_Pos) |
+ (NRF_S1LEN_BITS << RADIO_PCNF0_S1LEN_Pos);
NRF_RADIO->PCNF0 = g_ble_phy_data.phy_pcnf0;
/* XXX: should maxlen be 251 for encryption? */