nrfmin.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2015-2017 Freie Universität Berlin
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
71 #include "net/netdev.h"
72 
73 #ifdef __cplusplus
74 extern "C" {
75 #endif
76 
81 #define NRFMIN_CHAN_MIN (0U)
82 #define NRFMIN_CHAN_DEFAULT (0U) /* 2400MHz */
83 #define NRFMIN_CHAN_MAX (32)
89 #define NRFMIN_TXPOWER_DEFAULT (0) /* 0dBm */
90 
94 #define NRFMIN_ADDR_BCAST (0xffff)
95 
99 #ifndef NRFMIN_PAYLOAD_MAX
100 #define NRFMIN_PAYLOAD_MAX (200U)
101 #endif
102 
107 #define NRFMIN_HDR_LEN (sizeof(nrfmin_hdr_t))
108 #define NRFMIN_PKT_MAX (NRFMIN_HDR_LEN + NRFMIN_PAYLOAD_MAX)
114 typedef struct __attribute__((packed)) {
115  uint8_t len;
116  uint16_t src_addr;
117  uint16_t dst_addr;
118  uint8_t proto;
119 } nrfmin_hdr_t;
120 
124 typedef union {
125  struct __attribute__((packed)) {
127  uint8_t payload[NRFMIN_PAYLOAD_MAX];
128  } pkt;
129  uint8_t raw[NRFMIN_PKT_MAX];
130 } nrfmin_pkt_t;
131 
135 extern netdev_t nrfmin_dev;
136 
140 extern const netdev_driver_t nrfmin_netdev;
141 
145 void nrfmin_setup(void);
146 
152 uint16_t nrfmin_get_addr(void);
153 
159 void nrfmin_set_addr(uint16_t addr);
160 
166 void nrfmin_get_iid(uint16_t *iid);
167 
173 uint16_t nrfmin_get_channel(void);
174 
183 int nrfmin_set_channel(uint16_t chan);
184 
191 
201 
207 int16_t nrfmin_get_txpower(void);
208 
214 void nrfmin_set_txpower(int16_t power);
215 
216 #ifdef __cplusplus
217 }
218 #endif
219 
Definitions low-level network driver interface.
void nrfmin_get_iid(uint16_t *iid)
Get the IID build from the 16-bit node address.
const netdev_driver_t nrfmin_netdev
Reference to the netdev driver interface.
#define NRFMIN_PAYLOAD_MAX
Default maximum payload length (must be <= 250)
Definition: nrfmin.h:100
void nrfmin_setup(void)
Setup the device driver's data structures.
int16_t nrfmin_get_txpower(void)
Get the current transmit power.
netopt_state_t nrfmin_get_state(void)
Get the current radio state.
void nrfmin_set_txpower(int16_t power)
Set the used transmission power.
int nrfmin_set_state(netopt_state_t val)
Put the device into the given state.
uint16_t nrfmin_get_addr(void)
Get the currently active address.
void nrfmin_set_addr(uint16_t addr)
Set the 16-bit radio address.
netdev_t nrfmin_dev
Export the netdev device descriptor.
int nrfmin_set_channel(uint16_t chan)
Set the active channel.
uint16_t nrfmin_get_channel(void)
Get the current channel.
netopt_state_t
Option parameter to be used with NETOPT_STATE to set or get the state of a network device or protocol...
Definition: netopt.h:893
Structure to hold driver interface -> function mapping.
Definition: netdev.h:426
Structure to hold driver state.
Definition: netdev.h:365
Header format used for our custom nrfmin link layer.
Definition: nrfmin.h:114
uint16_t src_addr
source address of the packet
Definition: nrfmin.h:116
uint8_t len
packet length, including this header
Definition: nrfmin.h:115
uint8_t proto
protocol of payload
Definition: nrfmin.h:118
uint16_t dst_addr
destination address
Definition: nrfmin.h:117
In-memory structure of a nrfmin radio packet.
Definition: nrfmin.h:124
nrfmin_hdr_t hdr
the nrfmin header
Definition: nrfmin.h:126