You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/08/03 21:56:54 UTC
[GitHub] rymanluk closed pull request #1312: lora: Add lora common pkg
rymanluk closed pull request #1312: lora: Add lora common pkg
URL: https://github.com/apache/mynewt-core/pull/1312
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/hw/drivers/lora/include/lora/utilities.h b/hw/drivers/lora/include/lora/utilities.h
new file mode 100644
index 0000000000..fa0b81f184
--- /dev/null
+++ b/hw/drivers/lora/include/lora/utilities.h
@@ -0,0 +1,51 @@
+/*!
+ * \file utilities.h
+ *
+ * \brief Helper functions implementation
+ *
+ * \copyright Revised BSD License, see section \ref LICENSE.
+ *
+ * \code
+ * ______ _
+ * / _____) _ | |
+ * ( (____ _____ ____ _| |_ _____ ____| |__
+ * \____ \| ___ | (_ _) ___ |/ ___) _ \
+ * _____) ) ____| | | || |_| ____( (___| | | |
+ * (______/|_____)_|_|_| \__)_____)\____)_| |_|
+ * (C)2013-2017 Semtech
+ *
+ * \endcode
+ *
+ * \author Miguel Luis ( Semtech )
+ *
+ * \author Gregory Cristian ( Semtech )
+ */
+#ifndef __LORA_UTILITIES_H__
+#define __LORA_UTILITIES_H__
+
+#include <stdint.h>
+
+/*!
+ * \brief Read the current time
+ *
+ * \retval time returns current time
+ */
+uint32_t timer_get_current_time(void);
+
+/*!
+ * \brief Return the Time elapsed since a fix moment in Time
+ *
+ * \param [IN] saved_time fix moment in Time
+ * \retval time returns elapsed time
+ */
+uint32_t timer_get_elapsed_time(uint32_t saved_time);
+
+/*!
+ * \brief Return the Time elapsed since a fix moment in Time
+ *
+ * \param [IN] event_in_future fix moment in the future
+ * \retval time returns difference between now and future event
+ */
+uint32_t timer_get_future_time(uint32_t event_in_future);
+
+#endif // __LORA_UTILITIES_H__
diff --git a/hw/drivers/lora/pkg.yml b/hw/drivers/lora/pkg.yml
new file mode 100644
index 0000000000..763315bed4
--- /dev/null
+++ b/hw/drivers/lora/pkg.yml
@@ -0,0 +1,28 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+#
+
+pkg.name: hw/drivers/lora
+pkg.description: LoRaMac-node radio driver common.
+pkg.author: "Apache Mynewt <de...@mynewt.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.keywords:
+ - lora
+
+pkg.deps:
+ - "@apache-mynewt-core/kernel/os"
diff --git a/hw/drivers/lora/src/utilities.c b/hw/drivers/lora/src/utilities.c
new file mode 100644
index 0000000000..e800e6a59a
--- /dev/null
+++ b/hw/drivers/lora/src/utilities.c
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 <stdlib.h>
+
+#include "os/mynewt.h"
+#include "lora/utilities.h"
+
+uint32_t
+timer_get_current_time(void)
+{
+ return hal_timer_read(MYNEWT_VAL(LORA_MAC_TIMER_NUM));
+}
+
+uint32_t
+timer_get_elapsed_time(uint32_t saved_time)
+{
+ return hal_timer_read(MYNEWT_VAL(LORA_MAC_TIMER_NUM)) - saved_time;
+}
+
+uint32_t
+timer_get_future_time(uint32_t event_in_future)
+{
+ return hal_timer_read(MYNEWT_VAL(LORA_MAC_TIMER_NUM)) + event_in_future;
+}
diff --git a/hw/drivers/lora/sx1272/pkg.yml b/hw/drivers/lora/sx1272/pkg.yml
index f1bfdc6b81..38a7ee6a2d 100644
--- a/hw/drivers/lora/sx1272/pkg.yml
+++ b/hw/drivers/lora/sx1272/pkg.yml
@@ -27,6 +27,7 @@ pkg.keywords:
pkg.deps:
- "@apache-mynewt-core/kernel/os"
+ - "@apache-mynewt-core/hw/drivers/lora"
pkg.apis:
- lora_node_driver
diff --git a/hw/drivers/lora/sx1272/src/sx1272.c b/hw/drivers/lora/sx1272/src/sx1272.c
index 253d5dbef9..64b349ad38 100644
--- a/hw/drivers/lora/sx1272/src/sx1272.c
+++ b/hw/drivers/lora/sx1272/src/sx1272.c
@@ -23,7 +23,7 @@ Maintainer: Miguel Luis and Gregory Cristian
#include "radio/radio.h"
#include "sx1272.h"
#include "sx1272-board.h"
-#include "node/utilities.h"
+#include "lora/utilities.h"
#if MYNEWT_VAL(LORA_MAC_TIMER_NUM) == -1
#error "Must define a Lora MAC timer number"
@@ -317,10 +317,10 @@ SX1272IsChannelFree(RadioModems_t modem, uint32_t freq, int16_t rssiThresh,
/* Delay for 1 msec */
hal_timer_delay(SX1272_TIMER_NUM, 1000);
- carrierSenseTime = TimerGetCurrentTime( );
+ carrierSenseTime = timer_get_current_time( );
// Perform carrier sense for maxCarrierSenseTime
- while (TimerGetElapsedTime( carrierSenseTime ) < maxCarrierSenseTime) {
+ while (timer_get_elapsed_time( carrierSenseTime ) < maxCarrierSenseTime) {
rssi = SX1272ReadRssi(modem);
if (rssi > rssiThresh) {
status = false;
diff --git a/hw/drivers/lora/sx1276/pkg.yml b/hw/drivers/lora/sx1276/pkg.yml
index 2b483910b7..994a805a3e 100644
--- a/hw/drivers/lora/sx1276/pkg.yml
+++ b/hw/drivers/lora/sx1276/pkg.yml
@@ -26,6 +26,7 @@ pkg.keywords:
pkg.deps:
- "@apache-mynewt-core/kernel/os"
+ - "@apache-mynewt-core/hw/drivers/lora"
pkg.apis:
- lora_node_driver
diff --git a/hw/drivers/lora/sx1276/src/sx1276.c b/hw/drivers/lora/sx1276/src/sx1276.c
index 892ef7e774..107edb9c2c 100644
--- a/hw/drivers/lora/sx1276/src/sx1276.c
+++ b/hw/drivers/lora/sx1276/src/sx1276.c
@@ -23,7 +23,7 @@ Maintainer: Miguel Luis, Gregory Cristian and Wael Guibene
#include "radio/radio.h"
#include "sx1276.h"
#include "sx1276-board.h"
-#include "node/utilities.h"
+#include "lora/utilities.h"
#if MYNEWT_VAL(LORA_MAC_TIMER_NUM) == -1
#error "Must define a Lora MAC timer number"
@@ -355,10 +355,10 @@ SX1276IsChannelFree(RadioModems_t modem, uint32_t freq, int16_t rssiThresh,
/* Delay for 1 msec */
hal_timer_delay(SX1276_TIMER_NUM, 1000);
- carrierSenseTime = TimerGetCurrentTime();
+ carrierSenseTime = timer_get_current_time();
// Perform carrier sense for maxCarrierSenseTime
- while (TimerGetElapsedTime(carrierSenseTime) < maxCarrierSenseTime) {
+ while (timer_get_elapsed_time(carrierSenseTime) < maxCarrierSenseTime) {
rssi = SX1276ReadRssi(modem);
if (rssi > rssiThresh) {
status = false;
diff --git a/hw/drivers/lora/syscfg.yml b/hw/drivers/lora/syscfg.yml
new file mode 100644
index 0000000000..536db5eb77
--- /dev/null
+++ b/hw/drivers/lora/syscfg.yml
@@ -0,0 +1,23 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+#
+
+syscfg.defs:
+ LORA_MAC_TIMER_NUM:
+ description: Timer number used for lora mac and radio
+ value: -1
diff --git a/net/lora/node/src/utilities.c b/net/lora/node/src/utilities.c
index 00faedeb13..793d260e0b 100644
--- a/net/lora/node/src/utilities.c
+++ b/net/lora/node/src/utilities.c
@@ -19,8 +19,8 @@
#include <stdlib.h>
-#include "os/mynewt.h"
#include "node/utilities.h"
+#include "lora/utilities.h"
#include "node/lora_priv.h"
int32_t
@@ -32,17 +32,17 @@ randr(int32_t min, int32_t max)
TimerTime_t
TimerGetCurrentTime(void)
{
- return hal_timer_read(MYNEWT_VAL(LORA_MAC_TIMER_NUM));
+ return timer_get_current_time();
}
TimerTime_t
TimerGetElapsedTime(TimerTime_t savedTime)
{
- return hal_timer_read(MYNEWT_VAL(LORA_MAC_TIMER_NUM)) - savedTime;
+ return timer_get_elapsed_time(savedTime);
}
TimerTime_t
TimerGetFutureTime(TimerTime_t eventInFuture)
{
- return hal_timer_read(MYNEWT_VAL(LORA_MAC_TIMER_NUM)) + eventInFuture;
+ return timer_get_future_time(eventInFuture);
}
diff --git a/net/lora/node/syscfg.yml b/net/lora/node/syscfg.yml
index ed0365965e..0dd41730d7 100644
--- a/net/lora/node/syscfg.yml
+++ b/net/lora/node/syscfg.yml
@@ -87,11 +87,6 @@ syscfg.defs:
the transmission of join requests by an end device.
value: 5000
-
- LORA_MAC_TIMER_NUM:
- description: Timer number used for lora mac and radio
- value: -1
-
LORA_NODE_PUBLIC_NWK:
description: >
Sets public or private lora network. A value of 1 means
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services