Skip to content

Commit 1c4fc8f

Browse files
krish2718carlescufi
authored andcommitted
Initial commit: Init and de-init working
* Add the directory structure and build support, and skeleton APIs to verify the Sample, BM library and OS agnostic code integration. * Relies on nrfxlib changes to convert OS agnostic code in to a separate static library * This project is both a manifest repo and also a Zephyr external module. * Add init and de-init support, use Zephyr shim (OS, Bus, HW etc) as a separate static library Initialize, fetch version and de-initialize are working. Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
1 parent 25a36e2 commit 1c4fc8f

30 files changed

+4575
-0
lines changed

CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2024 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
4+
add_subdirectory_ifdef(CONFIG_NRF70_BM_LIB nrf70_bm_lib)
5+
add_subdirectory_ifdef(CONFIG_NRF70_ZEPHYR_SHIM nrf70_zephyr_shim)

Kconfig.nrf70bm

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# Copyright (c) 2024 Nordic Semiconductor
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
7+
menu "Nordic nRF70 BM configuration"
8+
9+
rsource "nrf70_zephyr_shim/Kconfig"
10+
rsource "nrf70_bm_lib/Kconfig"
11+
12+
endmenu

nrf70_bm_lib/CMakeLists.txt

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# Copyright (c) 2024 Nordic Semiconductor
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
7+
if (CONFIG_NRF70_BM_LIB)
8+
add_library(nrf70-bm-lib STATIC)
9+
10+
set(NRF_WIFI_DIR ${ZEPHYR_CURRENT_MODULE_DIR}/../nrfxlib/nrf_wifi)
11+
12+
target_include_directories(nrf70-bm-lib PUBLIC
13+
include
14+
# OS agnostic library
15+
$<TARGET_PROPERTY:nrf-wifi,PUBLIC_INCLUDE_DIRECTORIES>
16+
)
17+
18+
target_compile_definitions(nrf70-bm-lib PRIVATE
19+
-DCONFIG_NRF_WIFI_FW_BIN=${NRF_WIFI_DIR}/fw_bins/scan_only/nrf70.bin
20+
)
21+
22+
23+
target_sources(
24+
nrf70-bm-lib
25+
PRIVATE
26+
source/nrf70_bm_lib.c
27+
source/nrf70_bm_init.c
28+
)
29+
30+
target_link_libraries(nrf70-bm-lib PRIVATE nrf-wifi nrf70-zep-shim)
31+
endif()

nrf70_bm_lib/Kconfig

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#
2+
# Copyright (c) 2024 Nordic Semiconductor
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
menu "Nordic nRF70 BM configuration"
7+
8+
config NRF70_BM_LIB
9+
bool "Enable nRF70 BM library"
10+
select NRF_WIFI
11+
help
12+
Enable the nRF70 BM library.
13+
14+
config NRF70_BM_LOG_LEVEL
15+
int "Log level for nRF70 BM library"
16+
default 3
17+
range 0 4
18+
help
19+
Log level for nRF70 BM library.
20+
21+
config NRF70_SCAN_SSID_FILT_MAX
22+
int "Maximum number of SSIDs that can be specified for SSID filtering"
23+
default 1
24+
range 1 4
25+
help
26+
Maximum number of SSIDs that can be specified for SSID filtering.
27+
This can be set based on the underlying chipsets limitations.
28+
29+
config NRF70_SCAN_CHAN_MAX_MANUAL
30+
int "Maximum number of channels that can be manually specified"
31+
range 1 110
32+
default 3
33+
help
34+
There are approximately 100 channels allocated across the three supported bands.
35+
The default of 3 allows the 3 most common channels (2.4GHz: 1, 6, 11) to be specified.
36+
37+
endmenu

nrf70_bm_lib/include/nrf70_bm_init.h

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
/** @file
8+
* @brief nRF70 Bare Metal library initialization.
9+
*/
10+
#ifndef NRF70_BM_INIT_H__
11+
#define NRF70_BM_INIT_H__
12+
13+
#include <stdint.h>
14+
#include <stdbool.h>
15+
#include <stdlib.h>
16+
#include <stddef.h>
17+
#include <stdarg.h>
18+
#include <string.h>
19+
20+
#include <fmac_api.h>
21+
22+
extern struct nrf70_wifi_drv_priv_bm nrf70_bm_priv;
23+
24+
#define NRF70_BM_NUM_VIFS 1
25+
26+
struct nrf70_wifi_vif_bm {
27+
unsigned char vif_idx;
28+
};
29+
30+
struct nrf70_wifi_ctx_bm {
31+
void *rpu_ctx;
32+
struct nrf70_wifi_vif_bm vifs[NRF70_BM_NUM_VIFS];
33+
};
34+
35+
struct nrf70_wifi_drv_priv_bm {
36+
struct nrf_wifi_fmac_priv *fmac_priv;
37+
struct nrf70_wifi_ctx_bm rpu_ctx_bm;
38+
};
39+
40+
int nrf70_fmac_init(void);
41+
int nrf70_fmac_deinit(void);
42+
43+
#endif /* NRF70_BM_INIT_H__ */

nrf70_bm_lib/include/nrf70_bm_lib.h

+178
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
/** @file
8+
* @brief nRF70 Bare Metal library.
9+
* @defgroup nrf70_bm nRF70 Bare Metal library
10+
*/
11+
12+
#ifndef NRF70_BM_H__
13+
#define NRF70_BM_H__
14+
15+
#ifdef __cplusplus
16+
extern "C" {
17+
#endif
18+
19+
#include <stdint.h>
20+
#include <stdbool.h>
21+
#include <stdio.h>
22+
23+
/** @brief Log levels */
24+
#if CONFIG_NRF70_BM_LOG_LEVEL > 0
25+
#define NRF70_LOG_ERR(...) printf(__VA_ARGS__); printf("\n")
26+
#else
27+
#define NRF70_LOG_ERR(...)
28+
#endif
29+
30+
#if CONFIG_NRF70_BM_LOG_LEVEL > 1
31+
#define NRF70_LOG_WRN(...) printf(__VA_ARGS__); printf("\n")
32+
#else
33+
#define NRF70_LOG_WRN(...)
34+
#endif
35+
36+
#if CONFIG_NRF70_BM_LOG_LEVEL > 2
37+
#define NRF70_LOG_INF(...) printf(__VA_ARGS__); printf("\n")
38+
#else
39+
#define NRF70_LOG_INF(...)
40+
#endif
41+
42+
#if CONFIG_NRF70_BM_LOG_LEVEL > 3
43+
#define NRF70_LOG_DBG(...) printf(__VA_ARGS__); printf("\n")
44+
#else
45+
#define NRF70_LOG_DBG(...)
46+
#endif
47+
48+
49+
#define NR70_SCAN_SSID_MAX_LEN 32
50+
#ifdef CONFIG_NRF70_SCAN_SSID_FILT_MAX
51+
#define NRF70_SCAN_SSID_FILT_MAX CONFIG_NRF70_SCAN_SSID_FILT_MAX
52+
#else
53+
#define NRF70_SCAN_SSID_FILT_MAX 1
54+
#endif /* CONFIG_NRF70_SCAN_SSID_FILT_MAX */
55+
56+
#ifdef CONFIG_NRF70_SCAN_CHAN_MAX_MANUAL
57+
#define NRF70_SCAN_CHAN_MAX_MANUAL CONFIG_NRF70_SCAN_CHAN_MAX_MANUAL
58+
#else
59+
#define NRF70_SCAN_CHAN_MAX_MANUAL 1
60+
#endif /* CONFIG_NRF70_SCAN_CHAN_MAX_MANUAL */
61+
62+
/** @brief Wi-Fi version */
63+
struct wifi_version {
64+
/** Driver version */
65+
const char *drv_version;
66+
/** Firmware version */
67+
const char *fw_version;
68+
};
69+
70+
/** @brief Wi-Fi scanning types. */
71+
enum nrf70_scan_type {
72+
/** Active scanning (default). */
73+
WIFI_SCAN_TYPE_ACTIVE = 0,
74+
/** Passive scanning. */
75+
WIFI_SCAN_TYPE_PASSIVE,
76+
};
77+
78+
/**
79+
* @brief Wi-Fi structure to uniquely identify a band-channel pair
80+
*/
81+
struct wifi_band_channel {
82+
/** Frequency band */
83+
uint8_t band;
84+
/** Channel */
85+
uint8_t channel;
86+
};
87+
88+
/**
89+
* @brief Wi-Fi scan parameters structure.
90+
* Used to specify parameters which can control how the Wi-Fi scan
91+
* is performed.
92+
*/
93+
struct nrf70_scan_params {
94+
/** Scan type, see enum wifi_scan_type.
95+
*
96+
* The scan_type is only a hint to the underlying Wi-Fi chip for the
97+
* preferred mode of scan. The actual mode of scan can depend on factors
98+
* such as the Wi-Fi chip implementation support, regulatory domain
99+
* restrictions etc.
100+
*/
101+
enum nrf70_scan_type scan_type;
102+
/** Bitmap of bands to be scanned.
103+
* Refer to ::wifi_frequency_bands for bit position of each band.
104+
*/
105+
uint8_t bands;
106+
/** Active scan dwell time (in ms) on a channel.
107+
*/
108+
uint16_t dwell_time_active;
109+
/** Passive scan dwell time (in ms) on a channel.
110+
*/
111+
uint16_t dwell_time_passive;
112+
/** Array of SSID strings to scan.
113+
*/
114+
const char *ssids[NRF70_SCAN_SSID_FILT_MAX];
115+
/** Specifies the maximum number of scan results to return. These results would be the
116+
* BSSIDS with the best RSSI values, in all the scanned channels. This should only be
117+
* used to limit the number of returned scan results, and cannot be counted upon to limit
118+
* the scan time, since the underlying Wi-Fi chip might have to scan all the channels to
119+
* find the max_bss_cnt number of APs with the best signal strengths. A value of 0
120+
* signifies that there is no restriction on the number of scan results to be returned.
121+
*/
122+
uint16_t max_bss_cnt;
123+
/** Channel information array indexed on Wi-Fi frequency bands and channels within that
124+
* band.
125+
* E.g. to scan channel 6 and 11 on the 2.4 GHz band, channel 36 on the 5 GHz band:
126+
* @code{.c}
127+
* chan[0] = {WIFI_FREQ_BAND_2_4_GHZ, 6};
128+
* chan[1] = {WIFI_FREQ_BAND_2_4_GHZ, 11};
129+
* chan[2] = {WIFI_FREQ_BAND_5_GHZ, 36};
130+
* @endcode
131+
*
132+
* This list specifies the channels to be __considered for scan__. The underlying
133+
* Wi-Fi chip can silently omit some channels due to various reasons such as channels
134+
* not conforming to regulatory restrictions etc. The invoker of the API should
135+
* ensure that the channels specified follow regulatory rules.
136+
*/
137+
struct wifi_band_channel band_chan[NRF70_SCAN_CHAN_MAX_MANUAL];
138+
};
139+
140+
/**@brief Initialize the WiFi module.
141+
*
142+
* @retval 0 If the operation was successful.
143+
* @retval -1 If the operation failed.
144+
*/
145+
int nrf70_init(void);
146+
147+
/**@brief Start scanning for WiFi networks.
148+
*
149+
* @param[in] scan_params Scan parameters.
150+
*
151+
* @retval 0 If the operation was successful.
152+
* @retval -EINVAL If the scan parameters are invalid.
153+
* @retval -EBUSY If the scan is already in progress.
154+
* @retval -EIO If the operation failed.
155+
* @retval -ENOMEM If there is not enough memory to start the scan.
156+
*/
157+
int nrf70_scan_start(struct nrf70_scan_params *scan_params);
158+
159+
/**@brief Check if the WiFi scan is done.
160+
*
161+
* @retval 0 If the scan is not done.
162+
* @retval 1 If the scan is done.
163+
*/
164+
bool nrf70_scan_done(void);
165+
166+
/**@brief Print the WiFi scan results.
167+
*/
168+
void nrf70_scan_print_results(void);
169+
170+
/**@brief Clean up the WiFi module.
171+
*/
172+
int nrf70_deinit(void);
173+
174+
#ifdef __cplusplus
175+
}
176+
#endif
177+
178+
#endif /* NRF70_BM_H__ */

0 commit comments

Comments
 (0)