Skip to content

Commit 3287e71

Browse files
author
Jonas
committed
Initial import of tests for kw2x radio
squash: driver: fixed typo to pass doccheck squash: driver: bug fixes after test squash: adapted Makefiles for correct build behaviour restructured, no spi interaction in isr anymore major bugfixes and restructurization comments addressed introduce new netconf option, ..AUTOCCA squash: minor bugfix and add auto-init mechanism squash: minor fixes to make travis happy
1 parent 49f0947 commit 3287e71

File tree

13 files changed

+1199
-491
lines changed

13 files changed

+1199
-491
lines changed

drivers/Makefile.include

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ endif
1616
ifneq (,$(filter ng_at86rf2xx,$(USEMODULE)))
1717
USEMODULE_INCLUDES += $(RIOTBASE)/drivers/ng_at86rf2xx/include
1818
endif
19+
ifneq (,$(filter kw2xrf,$(USEMODULE)))
20+
USEMODULE_INCLUDES += $(RIOTBASE)/drivers/kw2xrf/include
21+
endif
1922
ifneq (,$(filter isl29020,$(USEMODULE)))
2023
USEMODULE_INCLUDES += $(RIOTBASE)/drivers/isl29020/include
2124
endif

drivers/include/kw2xrf.h

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,19 @@
2222
#ifndef MKW2XDRF_H_
2323
#define MKW2XDRF_H_
2424

25+
#include <stdint.h>
26+
27+
#include "board.h"
28+
#include "periph/spi.h"
29+
#include "periph/gpio.h"
2530
#include "net/ng_netdev.h"
2631

2732
#ifdef __cplusplus
2833
extern "C" {
2934
#endif
3035

3136
/**
32-
* @brief Maximum packet length, including XBee API frame overhead
37+
* @brief Maximum packet length
3338
*/
3439
#define KW2XRF_MAX_PKT_LENGTH (127U)
3540

@@ -47,58 +52,90 @@ extern "C" {
4752
*/
4853
#define KW2XRF_DEFAULT_SHORT_ADDR (0x0002)
4954

55+
/**
56+
* @brief Default short address used after initialization
57+
*/
58+
#define KW2XRF_DEFAULT_ADDR_LONG (0x0000000000000000)
59+
5060
/**
5161
* @brief Default PAN ID used after initialization
5262
*/
53-
#define KW2XRF_DEFAULT_PANID (0x0001)
63+
#define KW2XRF_DEFAULT_PANID (0x0023)
5464

5565
/**
5666
* @brief Default channel used after initialization
5767
*/
58-
#define KW2XRF_DEFAULT_CHANNEL (13U)
68+
#define KW2XRF_DEFAULT_CHANNEL (17U)
69+
70+
/**
71+
* @brief Default TX_POWER in dbm used after initialization
72+
*/
73+
#define KW2XRF_DEFAULT_TX_POWER (0)
5974

6075
/**
6176
* @brief Maximum output power of the kw2x device in dBm
6277
*/
63-
#define MKW2XDRF_OUTPUT_POWER_MAX 8
78+
#define MKW2XDRF_OUTPUT_POWER_MAX (8)
6479

6580
/**
6681
* @brief Minimum output power of the kw2x device in dBm
6782
*/
68-
#define MKW2XDRF_OUTPUT_POWER_MIN (-35)
83+
#define MKW2XDRF_OUTPUT_POWER_MIN (-35)
84+
85+
/**
86+
* @brief Internal device option flags
87+
* @{
88+
*/
89+
#define KW2XRF_OPT_AUTOACK (0x0001) /**< auto ACKs active */
90+
#define KW2XRF_OPT_CSMA (0x0002) /**< CSMA active */
91+
#define KW2XRF_OPT_PROMISCUOUS (0x0004) /**< promiscuous mode active */
92+
#define KW2XRF_OPT_PRELOADING (0x0008) /**< preloading enabled */
93+
#define KW2XRF_OPT_TELL_TX_START (0x0010) /**< notify MAC layer on TX start */
94+
#define KW2XRF_OPT_TELL_TX_END (0x0020) /**< notify MAC layer on TX finished */
95+
#define KW2XRF_OPT_TELL_RX_START (0x0040) /**< notify MAC layer on RX start */
96+
#define KW2XRF_OPT_TELL_RX_END (0x0080) /**< notify MAC layer on RX finished */
97+
#define KW2XRF_OPT_RAWDUMP (0x0100) /**< pass RAW frame data to upper layer */
98+
#define KW2XRF_OPT_SRC_ADDR_LONG (0x0200) /**< send data using long source address */
99+
#define KW2XRF_OPT_USE_SRC_PAN (0x0400) /**< do not compress source PAN ID */
100+
/** @} */
69101

70102
/**
71103
* @brief kw2xrf device descriptor
72104
*/
73105
typedef struct {
74106
/* netdev fields */
75-
ng_netdev_driver_t const *driver; /**< pointer to the devices interface */
76-
ng_netdev_event_cb_t event_cb; /**< netdev event callback */
77-
kernel_pid_t mac_pid; /**< the driver's thread's PID */
78-
/* Devide driver specific fields */
79-
uint8_t buf[KW2XRF_MAX_PKT_LENGTH]; /**> Buffer for the kw2x radio device */
107+
ng_netdev_driver_t const *driver; /**< Pointer to the devices interface */
108+
ng_netdev_event_cb_t event_cb; /**< Netdev event callback */
109+
kernel_pid_t mac_pid; /**< The driver's thread's PID */
110+
/* driver specific fields */
111+
uint8_t buf[KW2XRF_MAX_PKT_LENGTH]; /**< Buffer for incoming or outgoing packets */
80112
ng_netconf_state_t state; /**< Variable to keep radio driver's state */
81113
uint8_t seq_nr; /**< Next packets sequence number */
82114
uint16_t radio_pan; /**< The PAN the radio device is using */
83115
uint8_t radio_channel; /**< The channel the radio device is using */
84116
uint8_t addr_short[2]; /**< The short address the radio device is using */
85117
uint8_t addr_long[8]; /**< The long address the radio device is using */
86-
uint8_t options; /**< Bit field to save enable/disable options */
118+
uint16_t option; /**< Bit field to save enable/disable options */
119+
int8_t tx_power; /**< The current tx-power setting of the device */
87120
ng_nettype_t proto; /**< Protocol the interface speaks */
88121
} kw2xrf_t;
89122

90123
/**
91124
* @brief Initialize the given KW2XRF device
92-
*
93-
* @param[out] dev KW2XRF device to initialize
125+
* @param[out] dev device descriptor
126+
* @param[in] spi SPI bus the device is connected to
127+
* @param[in] spi_speed SPI speed to use
128+
* @param[in] cs_pin GPIO pin connected to chip select
129+
* @param[in] int_pin GPIO pin connected to the interrupt pin
94130
*
95131
* @return 0 on success
96-
* @return -ENODEV on invalid device descriptor
132+
* @return <0 on error
97133
*/
98-
int kw2xrf_init(kw2xrf_t *dev);
134+
int kw2xrf_init(kw2xrf_t *dev, spi_t spi, spi_speed_t spi_speed,
135+
gpio_t cs_pin, gpio_t int_pin);
99136

100137
/**
101-
* Reference to the KW2XRF driver interface.
138+
* @brief Reference to the KW2XRF driver interface
102139
*/
103140
extern const ng_netdev_driver_t kw2xrf_driver;
104141

drivers/kw2xrf/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
MODULE = kw2xrf
2-
31
include $(RIOTBASE)/Makefile.base

0 commit comments

Comments
 (0)