Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
76 changes: 71 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
Ai-Thinker Ai-WB2 Wireless Modules Development Framework
=========



Base on th Bouffalolab bl_iot_sdk. Support BL602 Wi-Fi/BLE Combo RISC-V based Chip and BL70X Zigbee/BLE RISC-V based Chip.



# Linux Users



## Step 1. Install Prerequisites

In order to use Ai-WB2 Development Framework with the Ai-WB2, you need to install some software packages based on your Operating System. This setup guide will help you on getting everything installed on Linux and macOS based systems.
Expand All @@ -15,7 +21,7 @@ In order to use Ai-WB2 Development Framework with the Ai-WB2, you need to instal

- One liner for Arch:

`sudo pacman -S base-devel python python-pip git screen`
`paru -S aithinkerwb2 ` or `yay -S aithinkerwb2`

- Next, clone the SDK repository:

Expand All @@ -25,6 +31,8 @@ if you are coding in the China , recommend you to clone the repository :

`git clone --recursive https://gitee.com/Ai-Thinker-Open/Ai-Thinker-WB2`



## Step 2. Modify Permission
Modify the permissions of the compilation tool chain to enable executable functions.
- Darwin
Expand All @@ -42,25 +50,32 @@ Modify the permissions of the compilation tool chain to enable executable functi
cd toolchain/riscv/MSYS/
. chmod755.sh
```


## Step 3. Compiling

For example, run the cd applications/get-started/helloworld project to compile :

```
```bash
cd applications/get-started/helloworld
make -j8
```



## Step 4. download

Please connect your Ai-WB2 Serial Development board , and press the EN button according to the prompts.

```
```bash
make flash p=/dev/ttyUSB0 b=921600
```


## Step 5. Other

In addition, you can use this command to view help.
```
```bash
make help
```
> Your configuration chipname is Ai-Thinker Ai-WB2 Wi-Fi&BLE Module
Expand All @@ -78,6 +93,57 @@ make help


Note: After erasing the flash, you need to use this command to download it,but always press the BURN button,then press the EN button.next,release all keys.
```
```bash
make eflash
```





# API Guide

---

Read the documentation located in the `docs` directory under `en-us`.

To visualize and load a document locally, you can start an HTTP server in the `docs` directory. Here’s how you can do it:

1. **Using Python** (if you have Python installed):

- Navigate to the docs directory:

```bash
cd /path/to/docs
```

- Start a simple HTTP server

- for Python3.x:

```bash
python3 -m http.server 8000
```

- for Python2.x:

```bash
python -m SimpleHTTPServer 8000
```

2. **Using Node.js**: If you prefer using Node.js, you can use a package like `http-server`:

- Install `http-server` globally:

```bash
npm install -g http-server
```

- Navigate to the `docs` directory and run the server:

```bash
cd /path/to/docs
http-server -p 8000
```

Once the server is running, you can access the documents in your browser by going to `http://localhost:8000`.
6 changes: 6 additions & 0 deletions applications/get-started/helloworld/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ INCLUDE_COMPONENTS += $(COMPONENTS_BLSYS)
INCLUDE_COMPONENTS += $(COMPONENTS_VFS)
INCLUDE_COMPONENTS += $(PROJECT_NAME)


# 添加自定义头文件目录
CFLAGS += -I$(PROJECT_PATH)/include

# 添加自定义源文件
SRC += $(PROJECT_PATH)/OLED.c
include $(BL60X_SDK_PATH)/make_scripts_riscv/project.mk
2 changes: 1 addition & 1 deletion applications/peripherals/demo_adc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# project subdirectory.
#

PROJECT_NAME := demo_adc
PROJECT_NAME := demo_boardtemp
PROJECT_PATH := $(abspath .)
PROJECT_BOARD := evb
export PROJECT_PATH PROJECT_BOARD
Expand Down
89 changes: 36 additions & 53 deletions applications/peripherals/demo_adc/demo_adc/main.c
Original file line number Diff line number Diff line change
@@ -1,67 +1,50 @@
#include <FreeRTOS.h>
#include <blog.h>
#include <hosal_adc.h>
#include <stdio.h>
#include <string.h>
#include <FreeRTOS.h>
#include <task.h>
#include <hosal_adc.h>
#include <blog.h>

/********** BL602 ************
* channel0 -----> gpio12
* channel1 -----> gpio4
* channel2 -----> gpio14
* channel3 -----> gpio13
* channel4 -----> gpio5
* channel5 -----> gpio6
* channel7 -----> gpio9
* channel9 -----> gpio10
* channel10 -----> gpio11
* channel11 -----> gpio15
*/

* channel0 -----> gpio12
* channel1 -----> gpio4
* channel2 -----> gpio14
* channel3 -----> gpio13
* channel4 -----> gpio5
* channel5 -----> gpio6
* channel7 -----> gpio9
* channel9 -----> gpio10
* channel10 -----> gpio11
* channel11 -----> gpio15
*/
#define GPIO_ADC_PIN 11
#define ADC_CHANNEL 10

void main(void)
{
static hosal_adc_dev_t adc0 = {
.cb = NULL,
.config = {
.mode = HOSAL_ADC_ONE_SHOT,
.pin = GPIO_ADC_PIN,
.sampling_freq = 340,
},
.dma_chan = 0,
.p_arg = NULL,
.port = 0,
};
#define ADC_TEMPCHANNEL 14

void main(void) {

hosal_adc_init(&adc0);
static hosal_adc_dev_t adc0 = {
.cb = NULL,
.config =
{
.mode = HOSAL_ADC_ONE_SHOT,
.pin = GPIO_ADC_PIN,
.sampling_freq = 340,
},
.dma_chan = 0,
.p_arg = NULL,
.port = 0,
};

hosal_adc_add_channel(&adc0, ADC_CHANNEL);
hosal_adc_init(&adc0);
hosal_adc_add_channel(&adc0, ADC_TEMPCHANNEL);

for (;;) {
int ret = hosal_adc_value_get(&adc0, ADC_CHANNEL, 100);
for (;;) {

/// ADC
/// |
/// ┌┴┐
/// | | 4.7 kΩ
/// └┬┘
/// |
/// ├-----IO11
/// |
/// ┌┴┐
/// | | 1 kΩ
/// └┬┘
/// |
/// ┴
/// GND
/// Actual Voltage = ADC output * 1000 / (4700 + 1000) (Unit: mV)

ret = ret * (4700 + 1000) / 1000;
int temp = hosal_adc_tsen_value_get(&adc0); // 获取板子温度

blog_info("ADC = %ld mV\r\n", ret);
blog_info("BOARD temp = %d C\r\n", temp);

vTaskDelay(pdMS_TO_TICKS(2000));
}
vTaskDelay(pdMS_TO_TICKS(5000));
}
}
67 changes: 67 additions & 0 deletions applications/peripherals/demo_adc/demo_adc/main.c.bk
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include <FreeRTOS.h>
#include <blog.h>
#include <hosal_adc.h>
#include <stdio.h>
#include <string.h>
#include <task.h>

/********** BL602 ************
* channel0 -----> gpio12
* channel1 -----> gpio4
* channel2 -----> gpio14
* channel3 -----> gpio13
* channel4 -----> gpio5
* channel5 -----> gpio6
* channel7 -----> gpio9
* channel9 -----> gpio10
* channel10 -----> gpio11
* channel11 -----> gpio15
*/

#define GPIO_ADC_PIN 11
#define ADC_CHANNEL 10

void main(void) {
static hosal_adc_dev_t adc0 = {
.cb = NULL,
.config =
{
.mode = HOSAL_ADC_ONE_SHOT,
.pin = GPIO_ADC_PIN,
.sampling_freq = 340,
},
.dma_chan = 0,
.p_arg = NULL,
.port = 0,
};

hosal_adc_init(&adc0);

hosal_adc_add_channel(&adc0, ADC_CHANNEL);
hosal_adc_stop(&adc0);
for (;;) {
int ret = hosal_adc_value_get(&adc0, ADC_CHANNEL, 100);

/// ADC
/// |
/// ┌┴┐
/// | | 4.7 kΩ
/// └┬┘
/// |
/// ├-----IO11
/// |
/// ┌┴┐
/// | | 1 kΩ
/// └┬┘
/// |
/// ┴
/// GND
/// Actual Voltage = ADC output * 1000 / (4700 + 1000) (Unit: mV)

ret = ret * (4700 + 1000) / 1000;

blog_info("ADC = %ld mV\r\n", ret);

vTaskDelay(pdMS_TO_TICKS(2000));
}
}
26 changes: 26 additions & 0 deletions applications/peripherals/demo_adc/demo_boardtemp/bouffalo.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# "main" pseudo-component makefile.
#
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)

include $(BL60X_SDK_PATH)/components/network/ble/ble_common.mk

ifeq ($(CONFIG_ENABLE_PSM_RAM),1)
CPPFLAGS += -DCONF_USER_ENABLE_PSRAM
endif

ifeq ($(CONFIG_ENABLE_CAMERA),1)
CPPFLAGS += -DCONF_USER_ENABLE_CAMERA
endif

ifeq ($(CONFIG_ENABLE_BLSYNC),1)
CPPFLAGS += -DCONF_USER_ENABLE_BLSYNC
endif

ifeq ($(CONFIG_ENABLE_VFS_SPI),1)
CPPFLAGS += -DCONF_USER_ENABLE_VFS_SPI
endif

ifeq ($(CONFIG_ENABLE_VFS_ROMFS),1)
CPPFLAGS += -DCONF_USER_ENABLE_VFS_ROMFS
endif
50 changes: 50 additions & 0 deletions applications/peripherals/demo_adc/demo_boardtemp/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <FreeRTOS.h>
#include <blog.h>
#include <hosal_adc.h>
#include <stdio.h>
#include <string.h>
#include <task.h>

/********** BL602 ************
* channel0 -----> gpio12
* channel1 -----> gpio4
* channel2 -----> gpio14
* channel3 -----> gpio13
* channel4 -----> gpio5
* channel5 -----> gpio6
* channel7 -----> gpio9
* channel9 -----> gpio10
* channel10 -----> gpio11
* channel11 -----> gpio15
*/
#define GPIO_ADC_PIN 11

#define ADC_TEMPCHANNEL 14

void main(void) {

static hosal_adc_dev_t adc0 = {
.cb = NULL,
.config =
{
.mode = HOSAL_ADC_ONE_SHOT,
.pin = 12,
.sampling_freq = 340,
},
.dma_chan = 0,
.p_arg = NULL,
.port = 0,
};

hosal_adc_init(&adc0);
hosal_adc_add_channel(&adc0, ADC_TEMPCHANNEL);

for (;;) {

int temp = hosal_adc_tsen_value_get(&adc0); // 获取板子温度

blog_info("BOARD temp = %d C\r\n", temp);

vTaskDelay(pdMS_TO_TICKS(5000));
}
}
Loading