Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: Add support for KW41Z builtin transceiver #7107

Closed
wants to merge 82 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
3e59f40
drivers/kw41zrf: Transceiver driver for the KW41Z radio
May 2, 2017
f8dfec7
squash kw41zrf fix warnings unused arguments
Mar 22, 2018
ff79569
squash kw41zrf vendor whitespace fixes
Jun 10, 2018
a83c963
squash kw41zrf vendor code fix warnings
Mar 22, 2018
0c35238
squash kw41zrf vendor driver RIOT fixes
Jun 11, 2018
63c244b
squash kw41zrf fix vendor LLVM warnings
Jun 14, 2018
907ae8e
squash kw41zrf wait for OSC ready before accessing the link layer in …
Oct 28, 2017
b1ed075
kw41zrf: Disable VLPS+LLS when radio is active
Sep 25, 2017
18c625a
squash kw41zrf LLS fixes
Oct 28, 2017
66f8575
squash kw41zrf Improve RF_OSC_CTRL handling
Dec 3, 2017
bcce5cd
squash kw41zrf Check that radio is awake before attempting to set opt…
Dec 3, 2017
a9ba20d
squash kw41zrf ignore IRQ while in DSM
Dec 3, 2017
461768d
squash kw41zrf Turn power on for netdev get/set if necessary
Dec 3, 2017
8de0889
squash kw41zrf fix init error RF_OSC_EN
Dec 3, 2017
35ad28c
squash kw41zrf set idle_state on sleep
Nov 29, 2017
4f5c067
squash kw41zrf fix race in DSM sleep
Dec 4, 2017
fb0f551
squash kw41zrf avoid crash if transceiver is already in DSM
Dec 5, 2017
dd04c4f
squash kw41zrf fix netdev_get when in DSM
Dec 5, 2017
26b7dfc
squash kw41zrf clean up
Jun 5, 2018
a0d72b1
squash kw41zrf EINVAL on invalid CCA mode
Jun 5, 2018
a9eabaf
squash kw41zrf clean up netdev get
Jun 5, 2018
2e1a258
squash kw41zrf init null return value
Jun 5, 2018
1cf9fb6
squash kw41zrf send while sleeping stability improvements
Jun 7, 2018
4dacd86
squash kw41zrf ifdef MODULE_NETOPT
Jun 8, 2018
f5dcf23
squash kw41zrf allow recv during DSM
Jun 29, 2018
7c9ec71
squash kw41zrf auto-init
Jun 30, 2018
48e9916
fixup! squash kw41zrf auto-init
Aug 11, 2018
7a33172
squash fix cppcheck comments
Aug 24, 2018
82856a9
squash fsl_xcvr extern C
Sep 13, 2018
26718a4
fixup! squash fsl_xcvr extern C
Sep 13, 2018
2f7fed6
squash auto init doxygen typo
Sep 13, 2018
f6ecb7c
squash kw41zrf clean up init
Oct 10, 2018
2ba0911
squash kw41zrf clean up SEQ_IDLE handling
Oct 10, 2018
c226f93
squash kw41zrf correct NETOPT_CHANNEL width check
Oct 16, 2018
2940893
squash kw41zrf add comment on CCA threshold
Oct 16, 2018
b0a4353
squash kw41zrf add cppcheck suppression reason
Oct 16, 2018
1f46ef3
squash kw41zrf refactor tx_exec to avoid races
Oct 27, 2018
d07734a
squash kw41zrf refactor IRQ flags with DSM
Oct 27, 2018
30ee233
squash kw41zrf prevent dead lock when ISR is run while DSM
Oct 27, 2018
c0606ce
REMOVE kw41zrf deugging calibration failures
Oct 28, 2018
90a2ffa
squash kw41zrf Clean up unused vendor code
Oct 28, 2018
fff23d0
squash kw41zrf slimmer vendor init
Oct 28, 2018
9eec35b
squash kw41zrf vendor clean up exports
Oct 29, 2018
acbfb17
squash kw41zrf vendor slimming WIP
Oct 29, 2018
61e5bc0
squash kw41zrf add back handle_ifr
Oct 29, 2018
89bd803
squash kw41zrf WIP eliminate float
Oct 29, 2018
4ec4d5d
squash kw41zrf split xcvr stuff into separate file
Oct 30, 2018
8faf15e
squash kw41zrf clean up xcvr trim
Oct 30, 2018
5936c3f
squash kw41zrf disable debug
Oct 30, 2018
d4fc730
squash kw41zrf slim vendor calibration
Oct 30, 2018
5f7c54f
squash kw41zrf vendor clean up
Oct 30, 2018
7c7aae9
squash kw41zrf refactor RESET
Oct 30, 2018
71a243e
squash kw41zrf refactor vendor code
Oct 30, 2018
e356de6
squash kw41zrf refactor vendor code
Oct 31, 2018
03e39ef
squash kw41zrf refactor vendor code, eliminate dead paths
Oct 31, 2018
56108a7
squash kw41zrf remove debug timing
Oct 31, 2018
10dcf8f
squash kw41zrf Clean up options
Oct 31, 2018
28638a6
squash kw41zrf set the correct state at init
Oct 31, 2018
d77dae4
squash kw41zrf silence codacy
Oct 31, 2018
e3fb55b
squash kw41zrf perform CSMA retry even without NETOPT TELL TX END
Nov 13, 2018
dc5cf26
squash kw41zrf add support for debug LEDs
Nov 13, 2018
7f1e472
squash kw41zrf debug LED updates
Nov 13, 2018
6c7ef37
squash kw41zrf Update flags handling to match changes in #9581
Nov 13, 2018
f31a2c4
squash kw41zrf fixup signed bitmask literals
Nov 13, 2018
ae975b4
fixup! squash kw41zrf debug LED updates
Nov 15, 2018
8e90d22
squash kw41zrf minor clean ups and variable types refactor
Nov 16, 2018
9dffa28
examples/default: Add frdm-kw41z to netif boards list
Oct 31, 2018
063b038
usb-kw41z: Add settings for SoC radio
Dec 1, 2018
767f6eb
usb-kw41z: kw41zrf LED settings
Dec 1, 2018
e30291e
squash kw41zrf: Refactor power management to make pm_layered optional
Dec 6, 2018
4f561b9
squash kw41zrf clean up LED configuration
Dec 7, 2018
fc7c841
fixup! squash kw41zrf: Refactor power management to make pm_layered o…
Dec 10, 2018
e4af47c
squash kw41zrf rm old vendor headers
Dec 10, 2018
bef0d8d
squash kw41zrf: Remove references to netdev_t::stats, required by #9793
Dec 10, 2018
5a362bd
squash kw41zrf remove netdev_t accesses in getset
Dec 10, 2018
27f83ee
squash kw41zrf fix _get_txpower declaration
Dec 10, 2018
43515a8
squash kw41zrf Refactor addr,chan,nid getters/setters
Dec 10, 2018
d3e202d
squash kw41zrf workaround for netdev_t::pan updating until upper laye…
Dec 11, 2018
6d3b252
fixup! squash kw41zrf minor clean ups and variable types refactor
Nov 16, 2018
75cab70
squash kw41zrf disable LEDs by default
Dec 12, 2018
1944a58
phynode-kw41z: Add settings for SoC radio
Dec 14, 2018
09ad33f
squash kw41zrf correct PM name in comment
Dec 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions boards/frdm-kw41z/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += fxos8700
endif

ifneq (,$(filter netdev_default gnrc_netdev_default,$(USEMODULE)))
USEMODULE += kw41zrf
endif

include $(RIOTCPU)/kinetis/Makefile.dep
4 changes: 4 additions & 0 deletions boards/phynode-kw41z/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_adc
endif

ifneq (,$(filter netdev_default gnrc_netdev_default,$(USEMODULE)))
USEMODULE += kw41zrf
endif

include $(RIOTCPU)/kinetis/Makefile.dep
4 changes: 4 additions & 0 deletions boards/usb-kw41z/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
endif

ifneq (,$(filter netdev_default gnrc_netdev_default,$(USEMODULE)))
USEMODULE += kw41zrf
endif

include $(RIOTCPU)/kinetis/Makefile.dep
10 changes: 10 additions & 0 deletions drivers/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,16 @@ ifneq (,$(filter kw2xrf,$(USEMODULE)))
FEATURES_REQUIRED += periph_gpio_irq
endif

ifneq (,$(filter kw41zrf,$(USEMODULE)))
USEMODULE += luid
USEMODULE += netif
USEMODULE += ieee802154
USEMODULE += netdev_ieee802154
USEMODULE += core_thread_flags
USEMODULE += random
USEMODULE += mcux_xcvr_mkw41z
endif

ifneq (,$(filter l3g4200d,$(USEMODULE)))
FEATURES_REQUIRED += periph_i2c
endif
Expand Down
4 changes: 4 additions & 0 deletions drivers/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ ifneq (,$(filter kw2xrf,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/drivers/kw2xrf/include
endif

ifneq (,$(filter kw41zrf,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/drivers/kw41zrf/include
endif

ifneq (,$(filter l3g4200d,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/drivers/l3g4200d/include
endif
Expand Down
153 changes: 153 additions & 0 deletions drivers/include/kw41zrf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/*
* Copyright (C) 2017 SKF AB
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @defgroup drivers_kw41zrf KW41Z radio-driver
* @ingroup drivers_netdev
* @brief Device driver for the NXP KW41Z, KW21Z in-cpu transceiver
* @{
*
* @file
* @brief Interface definition for the kw41zrf driver
*
* @author Joakim Nohlgård <[email protected]>
*/

#ifndef KW41ZRF_H
#define KW41ZRF_H

#include <stdint.h>

#include "mutex.h"
#include "board.h"
#include "net/netdev.h"
#include "net/netdev/ieee802154.h"
#include "net/gnrc/nettype.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Maximum packet length
*/
#define KW41ZRF_MAX_PKT_LENGTH (IEEE802154_FRAME_LEN_MAX)

/**
* @brief Default PAN ID used after initialization
*/
#define KW41ZRF_DEFAULT_PANID (IEEE802154_DEFAULT_PANID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With #10384 close to being merged, this is not required anymore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the notify! 👍
Will address this soon-ish.


/**
* @brief Default channel used after initialization
*
* @{
*/
#ifndef KW41ZRF_DEFAULT_CHANNEL
#define KW41ZRF_DEFAULT_CHANNEL (IEEE802154_DEFAULT_CHANNEL)
#endif
/** @} */

/**
* @brief Allowed range of channels
*
* @{
*/
#define KW41ZRF_MIN_CHANNEL (11U)
#define KW41ZRF_MAX_CHANNEL (26U)
/** @} */

/**
* @brief Default TX_POWER in dbm used after initialization
*/
#define KW41ZRF_DEFAULT_TX_POWER (IEEE802154_DEFAULT_TXPOWER)

/**
* @brief Maximum output power of the kw41z device in dBm
*/
#define KW41ZRF_OUTPUT_POWER_MAX (4)

/**
* @brief Minimum output power of the kw41z device in dBm
*/
#define KW41ZRF_OUTPUT_POWER_MIN (-19)

/**
* @brief ISR callback function type
*/
typedef void (*kw41zrf_cb_t)(void *arg);

/**
* @brief Device descriptor for KW41ZRF radio devices
*
* @extends netdev_ieee802154_t
*/
typedef struct {
netdev_ieee802154_t netdev; /**< netdev parent struct */
/**
* @name device specific fields
* @{
*/
thread_t *thread; /**< Network driver thread, for providing feedback from IRQ handler */
uint32_t tx_warmup_time; /**< TX warmup time, in event timer ticks */
uint32_t rx_warmup_time; /**< RX warmup time, in event timer ticks */
uint32_t rf_osc_en_idle; /**< RF_OSC_EN bits setting when RF module is in standby */
int16_t tx_power; /**< The current tx-power setting of the device */
uint8_t flags; /**< Internal driver option flags */
uint8_t max_retrans; /**< Maximum number of frame retransmissions
* when no Ack frame is received (macMaxFrameRetries) */
uint8_t csma_max_backoffs; /**< Maximum number of CSMA backoffs when
* waiting for channel clear (macMaxCsmaBackoffs) */
uint8_t csma_min_be; /**< Minimum backoff exponent (macMinBe) */
uint8_t csma_max_be; /**< Maximum backoff exponent (macMaxBe) */
uint8_t idle_seq; /**< state to return to after sending */
uint8_t cca_result; /**< Used for passing CCA result from ISR to user */
uint8_t csma_be; /**< Counter used internally by send implementation */
uint8_t csma_num_backoffs; /**< Counter used internally by send implementation */
uint8_t num_retrans; /**< Counter used internally by send implementation */
uint8_t pm_blocked; /**< true if we have blocked a low power mode in the CPU */
uint8_t recv_blocked; /**< blocks moving to XCVSEQ_RECEIVE to prevent
* overwriting the RX buffer before the higher
* layers have copied it to system RAM */
/** @} */
} kw41zrf_t;

/**
* @brief Setup an KW41ZRF based device state
*
* @param[out] dev device descriptor
*/
void kw41zrf_setup(kw41zrf_t *dev);

/**
* @brief Initialize the given KW41ZRF device
*
* @param[out] dev device descriptor
* @param[in] cb irq callback
*
* @return 0 on success
* @return <0 on error
*/
int kw41zrf_init(kw41zrf_t *dev, kw41zrf_cb_t cb);

/**
* @brief Reset radio hardware and restore default settings
*
* @param[in] dev device to reset
*
* @return 0 on success
* @return <0 on initialization failure
*/
int kw41zrf_reset(kw41zrf_t *dev);

#ifdef __cplusplus
}
#endif

#endif /* KW41ZRF_H */
/** @} */
4 changes: 4 additions & 0 deletions drivers/kw41zrf/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Use vendor-supplied low level XCVR hardware initialization
DIRS += vendor/XCVR/MKW41Z4

include $(RIOTBASE)/Makefile.base
Loading